Tyro/Makefile

180 lines
4.4 KiB
Makefile
Raw Normal View History

2015-07-02 15:05:05 -04:00
SOURCES = $(wildcard include/**/*.cpp include/*.cpp src/base/*.cpp)
OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES))
2015-05-08 09:53:48 -04:00
BASE_LIB = build/base.a
JSON_FILES = $(patsubst config/%.json,%.json, $(wildcard config/*.json))
2015-05-28 16:25:16 -04:00
PROGRAM_SRC = $(wildcard src/*.cpp)
PROGRAM = build/Tyro
2015-05-28 16:25:16 -04:00
CONFIG_SRC = $(wildcard src/settings/*.cpp)
CONFIG_OBJ = $(patsubst %.cpp,%.o, $(CONFIG_SRC))
CONFIG_LIB = build/config.a
2015-07-02 15:05:05 -04:00
WIDGET_SRC = $(wildcard src/settings/*.cpp src/widgets/*.cpp src/base/widget/*.cpp)
2015-05-28 16:25:16 -04:00
WIDGET_OBJ = $(patsubst %.cpp,%.o, $(WIDGET_SRC))
WIDGET_LIB = build/widget.a
2015-04-16 22:07:51 -04:00
WX_RES = $(shell wx-config --rescomp)
2015-04-30 17:10:26 -04:00
WX_CXXFLAGS = $(shell wx-config --cxxflags)
2015-04-16 22:07:51 -04:00
INC_FLAGS = -Iinclude -I. -I/usr/local/include
DEV_CXXFLAGS = -O0 -g -Wall -Wextra -pipe -DDEBUG $(INC_FLAGS)
CXXFLAGS += -Os -pipe -DNDEBUG $(INC_FLAGS)
2015-04-16 22:07:51 -04:00
TEST_SRC = $(wildcard tests/*Test.cpp)
TESTS = $(patsubst %.cpp,%.o,$(TEST_SRC))
2015-07-02 15:05:05 -04:00
TEST_RUNNER = tests/runner
2015-04-29 13:10:52 -04:00
LDLIBS =
2015-04-16 22:07:51 -04:00
OS ?= $(shell uname -s)
2015-04-16 13:16:36 -04:00
2015-04-29 13:10:52 -04:00
# Get static version of libs to link to on platforms that support it
ifneq ($(OS),Linux)
WX_LDLIBS = $(shell wx-config --static --libs base core aui stc adv)
2015-04-29 13:10:52 -04:00
else
WX_LDLIBS = $(shell wx-config --libs base core aui stc adv)
endif
2015-04-22 21:06:35 -04:00
2015-04-29 13:10:52 -04:00
# Platform compiler flags
ifeq ($(OS),Darwin)
CXX = $(shell wx-config --cxx) -D__WXMAC__ -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_ -std=gnu++11
2015-06-24 14:12:05 -04:00
LDLIBS += $(shell pkg-config libssh2 --libs)
2015-05-08 22:20:59 -04:00
else
LDLIBS += -lssh2
2015-04-22 21:06:35 -04:00
endif
2015-05-08 22:20:59 -04:00
2015-04-16 22:07:51 -04:00
ifeq ($(OS),Windows_NT)
CXXFLAGS += -static
CXX += -std=gnu++11 -Wno-unknown-pragmas -Wno-missing-field-initializers -I/include -DWIN32
2015-06-24 14:12:05 -04:00
LDLIBS += -L/lib -lws2_32 -lssh2
endif
ifeq ($(OS),Linux)
2015-06-01 09:34:26 -04:00
CXX += -std=c++11 -Wno-unknown-pragmas -Wno-missing-field-initializers
2015-04-16 22:07:51 -04:00
endif
2015-04-16 13:16:36 -04:00
2015-05-06 17:08:41 -04:00
ifdef $(DEV)
2015-05-06 16:58:07 -04:00
all: CXXFLAGS = $(DEV_CXXFLAGS)
endif
2015-05-28 16:25:16 -04:00
all: build json_wrapper $(BASE_LIB) $(WIDGET_LIB) $(PROGRAM)
ifeq ($(OS),Darwin)
all: Tyro.app
endif
2015-05-06 16:58:07 -04:00
dev: DEV = true
dev: CXXFLAGS += $(DEV_CXXFLAGS)
dev: all
json_wrapper: json_wrapper_build
$(foreach var, $(JSON_FILES), config/json2c config/$(var) $(patsubst %.json,config/%_json.h,$(var)) $(patsubst %.json,%_json,$(var));)
json_wrapper_build:
$(CC) config/json2c.c -o config/json2c
build:
@mkdir -p build
$(BASE_LIB): build $(OBJECTS)
ar rcs $@ $(OBJECTS)
ranlib $@
2015-05-28 16:25:16 -04:00
$(CONFIG_LIB): build
$(foreach var, $(CONFIG_SRC), $(CXX) $(CXXFLAGS) $(WX_CXXFLAGS) -c -o $(patsubst %.cpp,%.o,$(var)) $(var);)
ar rcs $@ $(CONFIG_OBJ)
ranlib $@
$(WIDGET_LIB): build $(CONFIG_LIB)
$(foreach var, $(WIDGET_SRC), $(CXX) $(CXXFLAGS) $(WX_CXXFLAGS) -c -o $(patsubst %.cpp,%.o,$(var)) $(var);)
ar rcs $@ $(WIDGET_OBJ)
ranlib $@
$(PROGRAM): $(WIDGET_LIB)
$(CXX) $(CXXFLAGS) $(WX_CXXFLAGS) $(PROGRAM_SRC) $(WIDGET_LIB) $(CONFIG_LIB) $(BASE_LIB) $(WX_LDLIBS) $(LDLIBS) -o $(PROGRAM)
2015-05-28 16:25:16 -04:00
lib: $(OBJECTS) $(BASE_LIB) $(CONFIG_LIB) $(WIDGET_LIB)
run:
ifneq ($(OS),Darwin)
./$(PROGRAM)
else
./build/Tyro.app/Contents/MacOS/Tyro
endif
ifeq ($(OS),Darwin)
run-app:
open -a $(PWD)/build/Tyro.app
endif
2015-04-22 10:09:43 -04:00
run-grind:
2015-04-28 09:55:43 -04:00
valgrind $(PROGRAM)
2015-04-22 10:09:43 -04:00
# Make optimized and striped executable
2015-05-06 17:08:41 -04:00
release: DEV=
2015-04-16 22:07:51 -04:00
ifeq ($(OS),Darwin)
2015-05-06 17:08:41 -04:00
release: all
2015-04-16 13:16:36 -04:00
endif
2015-04-16 22:07:51 -04:00
ifeq ($(OS),Windows_NT)
2015-05-06 17:08:41 -04:00
release: exe
release:
strip -SXx $(PROGRAM).exe
2015-04-16 22:07:51 -04:00
endif
2015-04-28 09:55:43 -04:00
ifeq ($(OS),Linux)
2015-05-06 17:08:41 -04:00
release: all
release:
2015-04-28 09:55:43 -04:00
strip -SXx $(PROGRAM)
endif
2015-04-16 22:07:51 -04:00
2015-04-22 10:09:43 -04:00
# Windows resource linking
2015-04-16 22:07:51 -04:00
msw_resource:
$(WX_RES) resources/platform/msw/resource.rc -O coff -o resource.res
exe: LDLIBS += resource.res
exe: json_wrapper_build json_wrapper $(BASE_LIB)
2015-04-28 09:55:43 -04:00
exe: msw_resource $(PROGRAM)
2015-04-22 10:09:43 -04:00
# OS X application bundle
Tyro.app:
2015-05-06 17:08:41 -04:00
ifndef DEV
2015-05-06 16:58:07 -04:00
strip -SXx $(PROGRAM)
endif
SetFile -t APPL $(BASE_LIB)
2015-04-29 13:10:52 -04:00
-mkdir -p build/Tyro.app/Contents/MacOS
-mkdir -p build/Tyro.app/Contents/Resources/English.lproj
cp resources/platform/osx/Info.plist build/Tyro.app/Contents/
echo -n 'APPL????' > build/Tyro.app/Contents/PkgInfo
cp build/Tyro build/Tyro.app/Contents/MacOS/Tyro
cp resources/platform/osx/tyro.icns build/Tyro.app/Contents/Resources/
2015-04-22 21:06:35 -04:00
$(TESTS):
$(foreach var, $(TEST_SRC), $(CXX) $(CXXFLAGS) $(WX_CXXFLAGS) -c -o $(patsubst %.cpp,%.o,$(var)) $(var);)
.PHONY: tests
tests: $(TESTS) json_wrapper $(BASE_LIB) $(WIDGET_LIB)
2015-06-24 14:12:05 -04:00
$(CXX) $(CXXFLAGS) $(WX_CXXFLAGS) tests/main.cpp $(TESTS) $(WIDGET_LIB) $(BASE_LIB) $(LDLIBS) $(WX_LDLIBS) -o tests/runner
run-tests: tests
./tests/runner
clean:
2015-04-16 22:07:51 -04:00
rm -f *.res
2015-04-15 09:56:00 -04:00
rm -f config/json2c
2015-04-16 22:07:51 -04:00
rm -f config/json2c.exe
2015-04-15 09:56:00 -04:00
rm -f config/*_json.h
2015-04-16 22:07:51 -04:00
rm -rf *.o
rm -rf build
rm -rf $(OBJECTS) $(TESTS)
rm -f tests/runner
find . -name "*.gc*" -exec rm {} \;
rm -rf `find . -name "*.dSYM" -print`
2015-07-02 15:05:05 -04:00
mkdir -p build