2015-04-29 17:03:15 -04:00
|
|
|
SOURCES = $(wildcard include/**/*.cpp include/*.cpp src/base/**/*.cpp)
|
2015-03-31 16:43:42 -04:00
|
|
|
OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES))
|
2015-05-07 14:06:12 -04:00
|
|
|
BASE_LIB = build/Tyro.a
|
2015-04-07 17:08:28 -04:00
|
|
|
|
2015-04-15 09:47:20 -04:00
|
|
|
JSON_FILES = $(patsubst config/%.json,%.json, $(wildcard config/*.json))
|
|
|
|
|
2015-05-07 14:06:12 -04:00
|
|
|
PROGRAM_SRC = $(wildcard src/*.cpp)
|
2015-04-07 17:08:28 -04:00
|
|
|
PROGRAM = build/Tyro
|
2015-05-07 14:06:12 -04:00
|
|
|
|
|
|
|
WIDGET_SRC = $(wildcard src/widgets/*.cpp src/settings/*.cpp)
|
|
|
|
WIDGET_OBJ = $(patsubst %.cpp,%.o, $(WIDGET_SRC))
|
|
|
|
WIDGET_LIB = build/widget.a
|
2015-04-07 17:08:28 -04:00
|
|
|
|
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
|
|
|
|
2015-04-29 13:10:52 -04:00
|
|
|
DEV_CXXFLAGS = -g -Wall -Wextra -DDEBUG
|
|
|
|
CXXFLAGS = -Os -DNDEBUG
|
2015-04-16 22:07:51 -04:00
|
|
|
|
2015-04-16 13:16:36 -04:00
|
|
|
TEST_SRC = $(wildcard tests/*.cpp)
|
2015-04-07 17:08:28 -04:00
|
|
|
TESTS = $(patsubst %.cpp,%,$(TEST_SRC))
|
2015-03-31 16:43:42 -04:00
|
|
|
|
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)
|
|
|
|
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)
|
2015-05-04 09:11:56 -04:00
|
|
|
CXX = $(shell wx-config --cxx)
|
2015-04-30 12:08:35 -04:00
|
|
|
LDLIBS += /usr/local/lib/libssh2.a
|
2015-04-22 21:06:35 -04:00
|
|
|
endif
|
|
|
|
ifeq ($(OS),Linux)
|
2015-04-22 11:06:25 -04:00
|
|
|
CXX += -std=c++11
|
2015-04-30 12:08:35 -04:00
|
|
|
LDLIBS += -lssh2
|
2015-04-22 09:19:09 -04:00
|
|
|
endif
|
2015-04-16 22:07:51 -04:00
|
|
|
ifeq ($(OS),Windows_NT)
|
2015-05-07 14:06:12 -04:00
|
|
|
CXXFLAGS += -static
|
2015-04-22 21:06:35 -04:00
|
|
|
CXX += -I/include -DWIN32
|
2015-04-30 12:08:35 -04:00
|
|
|
LDLIBS += -L/lib -lwsock32 -lssh2
|
2015-04-16 22:07:51 -04:00
|
|
|
endif
|
2015-04-16 13:16:36 -04:00
|
|
|
|
2015-05-04 16:26:23 -04:00
|
|
|
CXX += -Iinclude -I. -I/usr/local/include
|
2015-04-22 21:06:35 -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-07 14:06:12 -04:00
|
|
|
all: build json_wrapper $(BASE_LIB) $(PROGRAM)
|
2015-05-04 16:26:23 -04:00
|
|
|
ifeq ($(OS),Darwin)
|
|
|
|
all: Tyro.app
|
|
|
|
endif
|
2015-03-31 16:43:42 -04:00
|
|
|
|
2015-05-06 16:58:07 -04:00
|
|
|
dev: DEV = true
|
2015-05-06 17:08:41 -04:00
|
|
|
dev: CXXFLAGS = $(DEV_CXXFLAGS)
|
2015-03-31 16:43:42 -04:00
|
|
|
dev: all
|
2015-04-15 09:47:20 -04:00
|
|
|
|
|
|
|
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
|
2015-03-31 16:43:42 -04:00
|
|
|
|
|
|
|
build:
|
|
|
|
@mkdir -p build
|
|
|
|
|
2015-05-07 14:06:12 -04:00
|
|
|
$(BASE_LIB): build $(OBJECTS)
|
2015-04-07 17:08:28 -04:00
|
|
|
ar rcs $@ $(OBJECTS)
|
|
|
|
ranlib $@
|
2015-05-07 14:06:12 -04:00
|
|
|
|
|
|
|
$(WIDGET_OBJ): CXXFLAGS += $(WX_CXXFLAGS)
|
|
|
|
|
|
|
|
$(WIDGET_LIB): $(WIDGET_OBJ)
|
|
|
|
ar rcs $@ $(WIDGET_OBJ)
|
|
|
|
ranlib $@
|
2015-04-07 17:08:28 -04:00
|
|
|
|
2015-04-29 13:10:52 -04:00
|
|
|
$(PROGRAM): CXXFLAGS += $(WX_CXXFLAGS)
|
2015-05-07 14:06:12 -04:00
|
|
|
$(PROGRAM): $(WIDGET_LIB)
|
|
|
|
$(CXX) $(CXXFLAGS) $(PROGRAM_SRC) $(WIDGET_LIB) $(BASE_LIB) $(WX_LDLIBS) $(LDLIBS) -o $(PROGRAM)
|
2015-04-07 17:08:28 -04:00
|
|
|
|
2015-05-07 14:06:12 -04:00
|
|
|
lib: $(OBJECTS) $(BASE_LIB)
|
2015-03-31 16:43:42 -04:00
|
|
|
|
|
|
|
run:
|
2015-05-04 16:26:23 -04:00
|
|
|
ifneq ($(OS),Darwin)
|
2015-03-31 16:43:42 -04:00
|
|
|
./build/Tyro
|
2015-05-04 16:26:23 -04:00
|
|
|
else
|
|
|
|
open -a $(PWD)/build/Tyro.app
|
|
|
|
endif
|
2015-03-31 16:43:42 -04:00
|
|
|
|
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:
|
2015-04-30 19:35:21 -04:00
|
|
|
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
|
2015-05-07 14:06:12 -04:00
|
|
|
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
|
|
|
|
2015-05-04 16:26:23 -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
|
2015-05-07 14:06:12 -04:00
|
|
|
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-03-31 16:43:42 -04:00
|
|
|
|
2015-05-07 14:06:12 -04:00
|
|
|
$(TESTS): $(BASE_LIB)
|
|
|
|
$(foreach var, $(TEST_SRC), $(CXX) $(CXXFLAGS) $(var) $(BASE_LIB) $(WX_LDLIBS) $(LDLIBS) -o $(patsubst %.cpp,%, $(var));)
|
2015-04-22 21:06:35 -04:00
|
|
|
|
2015-04-07 17:08:28 -04:00
|
|
|
.PHONY: tests
|
|
|
|
tests: $(TESTS)
|
|
|
|
sh ./tests/runtests.sh
|
|
|
|
|
2015-03-31 16:43:42 -04:00
|
|
|
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
|
2015-05-07 14:06:12 -04:00
|
|
|
rm -rf build
|
|
|
|
rm -rf build $(OBJECTS) $(PROGRAM) $(BASE_LIB) $(TESTS)
|
2015-03-31 16:43:42 -04:00
|
|
|
find . -name "*.gc*" -exec rm {} \;
|
|
|
|
rm -rf `find . -name "*.dSYM" -print`
|