summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-12-30 22:53:42 +0100
committertomsmeding <tom.smeding@gmail.com>2016-12-30 22:53:42 +0100
commit1002b8640b80c0ec4ba5c242ca2873ee1fc591d5 (patch)
tree66a34e66c3a078d9a7adc4593fa057dc0d8334dc /Makefile
parentda86e33dcba7d66e2e5b55efa8a7265c5d2989b9 (diff)
Drawing text (also added Liberation font with license)
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile39
1 files changed, 31 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index a5f5962..2d77ef1 100644
--- a/Makefile
+++ b/Makefile
@@ -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"