#!/usr/bin/make -f
CPPFLAGS = $$(pkg-config --cflags gtkmm-3.0) -I. -I ../badge
-CFLAGS = -Wall -Wextra -pedantic -std=c99 -Werror -O0 -g
-CXXFLAGS = -Wall -Wextra -pedantic -std=c++11 -Werror -O0 -g
+CFLAGS = -Wall -Wextra -pedantic -std=c99 -Werror -O0 -g -fstack-protector-all
+CXXFLAGS = -Wall -Wextra -pedantic -std=c++0x -Werror -O0 -g -fstack-protector-all
+LDLIBS = $$(pkg-config --libs gtkmm-3.0)
BADGE = badge
CONVERTER = level-converter
+LEVELLIST = levels.txt
GLADEFILES = lcd-display.glade
-VPATH = ../badge
-
BADGE_CXXSRCS = mock-main.cc \
mock/badge_worker.cc \
mock/display.cc \
mock/event.cc \
mock/lcd-window.cc
-BADGE_CSRCS = badge_main_loop.c \
- ui/font.c \
- ui/sprite.c \
- jumpnrun/collision.c \
- jumpnrun/enemies.c \
- jumpnrun/game_state.c \
- jumpnrun/items.c \
- jumpnrun/jumpnrun.c \
- jumpnrun/level_load.c \
- jumpnrun/moveable.c \
- jumpnrun/player.c \
- jumpnrun/render.c \
- jumpnrun/shots.c \
- jumpnrun/stats.c \
- jumpnrun/tiles.c
+BADGE_CSRCS = badge_main_loop.c
+
+BADGE_FAROBJS = ui/font.o \
+ ui/menu.o \
+ ui/sprite.o \
+ jumpnrun/collision.o \
+ jumpnrun/enemies.o \
+ jumpnrun/game_state.o \
+ jumpnrun/items.o \
+ jumpnrun/jumpnrun.o \
+ jumpnrun/level_load.o \
+ jumpnrun/player.o \
+ jumpnrun/render.o \
+ jumpnrun/shots.o \
+ jumpnrun/stats.o \
+ jumpnrun/tiles.o
BADGE_CXXOBJS = $(BADGE_CXXSRCS:%.cc=%.o)
BADGE_COBJS = $(BADGE_CSRCS:%.c=%.o)
-BADGE_OBJS = $(BADGE_CXXOBJS) $(BADGE_COBJS)
+BADGE_OBJS = $(BADGE_CXXOBJS) $(BADGE_COBJS) $(BADGE_FAROBJS)
CONVERTER_SRCS = tools/level-converter.cc
CONVERTER_OBJS = $(CONVERTER_SRCS:%.cc=%.o)
CDEPS = $(BADGE_CSRCS:%.c=%.dep)
CXXDEPS = $(BADGE_CXXSRCS:%.cc=%.dep) $(CONVERTER_SRCS:%.cc=%.dep)
-DEPS = $(CDEPS) $(CXXDEPS)
+FARDEPS = $(BADGE_FAROBJS:%.o=%.dep)
+DEPS = $(CDEPS) $(CXXDEPS) $(FARDEPS)
-LDLIBS = $$(pkg-config --libs gtkmm-3.0)
RM = rm -f
.PHONY: all dep clean distclean play
$(BADGE_COBJS) : %.o : %.c
- $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c -o $(@:../badge/%=%) $< $(LDLIBS)
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(BADGE_CXXOBJS) : %.o : %.cc
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -c -o $@ $< $(LDLIBS)
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
+
+$(BADGE_FAROBJS) : %.o : ../badge/%.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(BADGE): $(BADGE_OBJS)
- $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(+:../badge/%=%) $(LDLIBS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LDLIBS)
dep: $(DEPS)
$(CDEPS): %.dep : %.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -MM $< -MT $(<:%.c=%.o) -MF $@
+ $(CC) $(CPPFLAGS) $(CFLAGS) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@
$(CXXDEPS): %.dep : %.cc
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MM $< -MT $(<:%.cc=%.o) -MF $@
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@
+
+$(FARDEPS): %.dep : ../badge/%.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@
sinclude $(DEPS)
$(RM) $(DEPS) $(wildcard *~)
$(CONVERTER): $(CONVERTER_OBJS)
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $+
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LDLIBS)
play: all
+ echo > $(LEVELLIST)
+ ls ../badge/jumpnrun/levels/*.lv | xargs -n1 basename | cut -d . -f 1 > $(LEVELLIST)
./$(CONVERTER)
./$(BADGE)