Tyro/Makefile

119 lines
2.7 KiB
Makefile
Raw Normal View History

CXX += -I include -I.
2015-04-22 09:19:09 -04:00
SOURCES = $(wildcard include/**/*.cpp include/*.cpp src/network/*.cpp src/settings/*.cpp)
OBJECTS = $(patsubst %.cpp,%.o, $(SOURCES))
2015-04-22 21:06:35 -04:00
TYRO_LIB = build/Tyro.a
JSON_FILES = $(patsubst config/%.json,%.json, $(wildcard config/*.json))
PROGRAM_SRC = $(wildcard src/*.cpp src/widgets/*.cpp)
PROGRAM = build/Tyro
2015-04-16 22:07:51 -04:00
PROGRAM_OBJECTS = $(patsubst %.cpp,%.o, $(PROGRAM_SRC))
2015-04-22 21:06:35 -04:00
WX_LDLIBS = $(shell wx-config --libs base core aui stc adv)
2015-04-16 22:07:51 -04:00
WX_CXXFLAGS = $(shell wx-config --cxxflags)
WX_RES = $(shell wx-config --rescomp)
DEV_CXXFLAGS = -g -Wall -Wextra -DDEBUG -DSTATIC_BUILD
CXXFLAGS = -Os -DNDEBUG -DSTATIC_BUILD
2015-04-16 22:07:51 -04:00
2015-04-16 13:16:36 -04:00
TEST_SRC = $(wildcard tests/*.cpp)
TESTS = $(patsubst %.cpp,%,$(TEST_SRC))
2015-04-16 22:07:51 -04:00
OS ?= $(shell uname -s)
2015-04-16 13:16:36 -04:00
2015-04-22 21:06:35 -04:00
LDLIBS =
2015-04-22 09:19:09 -04:00
ifeq ($(OS),Darwin)
2015-04-22 11:06:25 -04:00
CXX += -std=c++98 -mmacosx-version-min=10.5
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-22 09:19:09 -04:00
endif
2015-04-16 22:07:51 -04:00
ifeq ($(OS),Windows_NT)
2015-04-22 21:06:35 -04:00
CXX += -I/include -DWIN32
LDLIBS += -L/lib -lwsock32
2015-04-16 22:07:51 -04:00
endif
2015-04-16 13:16:36 -04:00
2015-04-22 21:06:35 -04:00
LDLIBS += -lssh2
all: build json_wrapper $(TYRO_LIB) $(PROGRAM)
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
2015-04-22 21:06:35 -04:00
$(TYRO_LIB): $(OBJECTS)
ar rcs $@ $(OBJECTS)
ranlib $@
2015-04-22 21:06:35 -04:00
$(PROGRAM): CXXFLAGS += $(WX_CXXFLAGS) $(TYRO_LIB)
2015-04-07 20:19:05 -04:00
$(PROGRAM):
2015-04-22 21:06:35 -04:00
$(CXX) $(CXXFLAGS) $(PROGRAM_SRC) $(TYRO_LIB) $(WX_LDLIBS) -o $(PROGRAM)
run:
./build/Tyro
2015-04-22 10:09:43 -04:00
run-grind:
valgrind ./build/Tryo
# Make optimized and striped executable
release: all
strip -SXx $(PROGRAM)
2015-04-16 22:07:51 -04:00
ifeq ($(OS),Darwin)
2015-04-16 13:16:36 -04:00
make Tyro.app
endif
2015-04-16 22:07:51 -04:00
ifeq ($(OS),Windows_NT)
make exe
endif
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: msw_resource all
2015-04-22 10:09:43 -04:00
# OS X application bundle
2015-04-07 10:59:08 -04:00
Tyro.app: all resources/platform/osx/Info.plist
2015-04-22 21:06:35 -04:00
SetFile -t APPL $(TYRO_LIB)
-mkdir Tyro.app
-mkdir Tyro.app/Contents
-mkdir Tyro.app/Contents/MacOS
-mkdir Tyro.app/Contents/Resources
-mkdir Tyro.app/Contents/Resources/English.lproj
2015-04-07 10:59:08 -04:00
cp resources/platform/osx/Info.plist Tyro.app/Contents/
echo -n 'APPL????' > Tyro.app/Contents/PkgInfo
cp build/Tyro Tyro.app/Contents/MacOS/Tyro
2015-04-07 10:59:08 -04:00
cp resources/platform/osx/tyro.icns Tyro.app/Contents/Resources/
2015-04-22 21:06:35 -04:00
$(TESTS): $(TYRO_LIB)
2015-04-23 11:03:50 -04:00
$(foreach var, $(TEST_SRC), $(CXX) $(CXXFLAGS) $(var) $(TYRO_LIB) $(LDLIBS) -o $(patsubst %.cpp,%, $(var));)
2015-04-22 21:06:35 -04:00
.PHONY: tests
tests: $(TESTS)
sh ./tests/runtests.sh
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 Tyro.app
2015-04-22 21:06:35 -04:00
rm -rf build $(OBJECTS) $(PROGRAM) $(TYRO_LIB) $(TESTS)
find . -name "*.gc*" -exec rm {} \;
rm -rf `find . -name "*.dSYM" -print`