diff options
author | tomsmeding <hallo@tomsmeding.nl> | 2015-11-02 06:55:15 +0100 |
---|---|---|
committer | tomsmeding <hallo@tomsmeding.nl> | 2015-11-02 06:55:15 +0100 |
commit | dcaa318d677a1a6881ccc87640ae75c0fc578bfb (patch) | |
tree | 3ff05dc8494d6629dddfde30f859e0c72e620926 /Makefile |
Initial
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..05676ee --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +CXX := g++ +CXXFLAGS := -Wall -Wextra -std=c++11 -O2 -isystem /usr/local/include -I. +LIBS := -lfltk -L/usr/local/lib +BIN := game + +object_src := $(wildcard src/objects/*.cpp) +object_obj := $(patsubst src/objects/%.cpp,build/objects/%.o,$(object_src)) +object_head := $(patsubst src/objects/%.cpp,build/objects/%.h,$(object_src)) +object_xlist := $(shell echo $$(for f in $(object_src); do basename $$f | sed 's/\.[^.]*$$//' | sed 's/.*/X(&)/'; done)) + +base_src := $(wildcard *_base.cpp) +base_src += library.cpp main.cpp +base_obj := $(patsubst %.cpp,build/%.o,$(base_src)) + +.PHONY: all clean remake + +#keep all intermediate files! +.SECONDARY: + +all: $(BIN) + +clean: + rm -rf build $(BIN) + +remake: clean all + + +$(BIN): $(base_obj) $(object_obj) + $(CXX) $(CXXFLAGS) $(LIBS) -o $(BIN) $^ + +build/main.o: main.cpp build/objects.h + @mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o "$@" "$<" "-DOBJECT_CLASSES_XLIST=$(object_xlist)" "-DGAME_NAME=\"$(BIN)\"" + +build/objects/%.o: build/objects/%.cpp + @mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o "$@" $^ + +build/objects/%.cpp: src/objects/%.cpp + @mkdir -p $(dir $@) + $(CXX) -E object_wrapper.cpp "-D__OBJECT_FNAME__=\"$<\"" "-D__OBJECT_NAME__=$(basename $(notdir $<))" | sed 's/^# [0-9]\+ ".*//' >"$@" + +build/objects/%.h: src/objects/%.cpp + @mkdir -p $(dir $@) + $(CXX) -E object_header_maker.cpp "-D__OBJECT_NAME__=$(basename $(notdir $<))" "-DEVENT_XLIST=$$($(CXX) -E object_header_extractor.cpp "-D__OBJECT_FNAME__=\"$<\"" | sed 's/__________EVENT_NEWLINE__________/\n/g' | grep -oe '__________EVENT_COUNTER_TAG_[^_]*__________' | sed 's/[^G]*G_\(.*\)__________.*/X(\1)/g' | xargs)" | sed 's/^# [0-9]\+ ".*//' >"$@" + +build/objects.h: $(object_head) + echo $(object_head) | xargs -n 1 basename | sed 's,.*,#include "objects/&",' >"$@" + +build/%.o: %.cpp + @mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o "$@" $^ |