diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-12-30 22:53:42 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-12-30 22:53:42 +0100 |
commit | 1002b8640b80c0ec4ba5c242ca2873ee1fc591d5 (patch) | |
tree | 66a34e66c3a078d9a7adc4593fa057dc0d8334dc /Makefile | |
parent | da86e33dcba7d66e2e5b55efa8a7265c5d2989b9 (diff) |
Drawing text (also added Liberation font with license)
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 39 |
1 files changed, 31 insertions, 8 deletions
@@ -1,5 +1,5 @@ CXX := g++ -CXXFLAGS := -Wall -Wextra -std=c++11 -O2 -I. -I/usr/local/lib +CXXFLAGS := -Wall -Wextra -std=c++11 -O2 -fwrapv -I. -I/usr/local/lib LIBS := -L/usr/local/lib -lsfml-{system,window,graphics} BIN := game @@ -19,8 +19,14 @@ sprite_skipped := $(filter-out %.png,$(sprite_allfiles)) sprite_obj := $(patsubst src/sprites/%.png,build/sprites/%.o,$(sprite_fnames)) sprite_externs := $(shell echo $$(for f in $(sprite_obj); do basename $$f | sed 's/\.[^.]*$$//' | sed 's/.*/extern Sprite *&;/'; done)) +font_allfiles := $(wildcard src/fonts/*) +font_fnames := $(filter %.ttf,$(font_allfiles)) +font_skipped := $(filter-out %.ttf %/LICENSE,$(font_allfiles)) +font_obj := $(patsubst src/fonts/%.ttf,build/fonts/%.o,$(font_fnames)) +font_externs := $(shell echo $$(for f in $(font_obj); do basename $$f | sed 's/\.[^.]*$$//' | sed 's/.*/extern Font *&;/'; done)) + base_src := $(wildcard *_base.cpp) -base_src += library.cpp sprite.cpp main.cpp +base_src += library.cpp sprite.cpp font.cpp main.cpp base_obj := $(patsubst %.cpp,build/%.o,$(base_src)) .PHONY: all clean remake run @@ -43,16 +49,16 @@ run: all ./$(BIN) -$(BIN): $(base_obj) $(object_obj) $(sprite_obj) +$(BIN): $(base_obj) $(object_obj) $(sprite_obj) $(font_obj) echo Linking $(CXX) $(CXXFLAGS) $(LIBS) -o $(BIN) $^ -build/main.o: main.cpp build/objects.h build/sprites.h +build/main.o: main.cpp build/objects.h build/sprites.h build/fonts.h echo Building main mkdir -p $(dir $@) $(CXX) $(CXXFLAGS) -c -o "$@" "$<" "-DOBJECT_CLASSES_XLIST=$(object_xlist)" "-DGAME_NAME=\"$(BIN)\"" -build/objects/%.o: build/objects/%.cpp build/objects.h build/sprites.h +build/objects/%.o: build/objects/%.cpp build/objects.h build/sprites.h build/fonts.h echo Building $* mkdir -p $(dir $@) $(CXX) $(CXXFLAGS) -c -o "$@" "$<" @@ -80,15 +86,32 @@ build/%.o: %.cpp build/sprites/%.o: build/sprites/%.cpp echo Building sprite $* mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) -Wno-unused-const-variable -c -o "$@" "$<" + $(CXX) $(CXXFLAGS) -c -o "$@" "$<" build/sprites/%.cpp: src/sprites/%.png echo Generating for sprite $* mkdir -p $(dir $@) - printf "#include \"sprite.h\"\n\nstatic const unsigned char data[]={\n%s, 0\n};\n\nstatic Sprite struct_data=Sprite(data,%d);\nSprite *$*=&struct_data;\n" "$$($(BIN2C) <"$<")" $$(stat -f '%z' "$<") >"$@" + printf "#include \"sprite.h\"\n\nstatic const unsigned char data[]={\n%s\n};\n\nstatic Sprite struct_data=Sprite(data,%d);\nSprite *$*=&struct_data;\n" "$$($(BIN2C) <"$<")" $$(stat -f '%z' "$<") >"$@" -build/sprites.h: +build/sprites.h: $(sprite_fnames) echo Collecting generated sprite files mkdir -p $(dir $@) printf "#include \"sprite.h\"\n\n$(sprite_externs)\n" >"$@" test -z "$(sprite_skipped)" || printf "\x1B[1mWARNING: skipped files in src/sprites: $(notdir $(sprite_skipped))\x1B[0m\n" + + +build/fonts/%.o: build/fonts/%.cpp + echo Building font $* + mkdir -p $(dir $@) + $(CXX) $(CXXFLAGS) -c -o "$@" "$<" + +build/fonts/%.cpp: src/fonts/%.* + echo Generating for font $* + mkdir -p $(dir $@) + printf "#include \"font.h\"\n\nstatic const unsigned char data[]={\n%s\n};\n\nstatic Font struct_data=Font(data,%d);\nFont *$*=&struct_data;\n" "$$($(BIN2C) <"$<")" $$(stat -f '%z' "$<") >"$@" + +build/fonts.h: $(font_fnames) + echo Collecting generated font files + mkdir -p $(dir $@) + printf "#include \"font.h\"\n\n$(font_externs)\n" >"$@" + test -z "$(font_skipped)" || printf "\x1B[1mWARNING: skipped files in src/fonts: $(notdir $(font_skipped))\x1B[0m\n" |