a-game

2D platformer written from scratch.
git clone git://git.amin.space/a-game.git
Log | Files | Refs | README | LICENSE

Makefile (1720B)


      1 CC = clang
      2 CFLAGS = -std=c11 -Ilib -Wall -Wextra -Wshadow -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces
      3 LDFLAGS = -ldl -lglfw -lGL -lm
      4 
      5 SRC_FILES = platform_linux.c
      6 SRC = $(addprefix src/, $(SRC_FILES))
      7 EXE_FILE = a_game
      8 
      9 LIB_FILES = game.c
     10 LIB = $(addprefix src/, $(LIB_FILES))
     11 LIB_NAME = game.so
     12 
     13 DBGDIR = out/debug
     14 DBGEXE = $(DBGDIR)/$(EXE_FILE)
     15 DBGLIB = $(DBGDIR)/$(LIB_NAME)
     16 DBGLIBTMP = $(DBGLIB).tmp
     17 DBGCFLAGS = -g -O0
     18 
     19 RELDIR = out/release
     20 RELEXE = $(RELDIR)/$(EXE_FILE)
     21 RELLIB = $(RELDIR)/$(LIB_NAME)
     22 RELLIBTMP = $(RELLIB).tmp
     23 RELCFLAGS = -O2 -Os -DPLATFORM_HOTLOAD_GAME_CODE
     24 
     25 DEBUGGER = gdb -q
     26 
     27 .PHONY: default all build_debug build_lib build_release clean debug dir_debug dir_release memcheck run todo
     28 
     29 default: build_release
     30 
     31 all: build_debug build_release
     32 
     33 build_debug: dir_debug build_lib_debug
     34 	$(CC) $(CFLAGS) $(DBGCFLAGS) $(SRC) -o $(DBGEXE) $(LDFLAGS)
     35 
     36 build_lib_debug:
     37 	$(CC) $(CFLAGS) -fpic -shared $(DBGCFLAGS) $(LIB) -o $(DBGLIBTMP) $(LDFLAGS)
     38 	mv $(DBGLIBTMP) $(DBGLIB)
     39 
     40 build_lib_release:
     41 	$(CC) $(CFLAGS) -fpic -shared $(RELCFLAGS) $(LIB) -o $(RELLIBTMP) $(LDFLAGS)
     42 	mv $(RELLIBTMP) $(RELLIB)
     43 
     44 build_release: dir_release build_lib_release
     45 	$(CC) $(CFLAGS) $(RELCFLAGS) $(SRC) -o $(RELEXE) $(LDFLAGS)
     46 
     47 clean:
     48 	rm -f $(RELDIR)/* $(DBGDIR)/*
     49 
     50 debug: build_debug
     51 	$(DEBUGGER) $(DBGEXE)
     52 
     53 dir_debug:
     54 	@mkdir -p $(DBGDIR)
     55 
     56 dir_release:
     57 	@mkdir -p $(RELDIR)
     58 
     59 dump:
     60 	$(CC) -E $(SRC)
     61 
     62 memcheck: build_debug
     63 	valgrind --track-origins=yes ./$(DBGEXE)
     64 
     65 run: build_release
     66 	./$(RELEXE)
     67 
     68 todo:
     69 	@grep -FIR --colour=never --ignore-case --line-number todo src/ \
     70 	| sed -re  's/^([^:]+):[[:space:]]*(.*)/\1\x01\2/' \
     71 	| sed -re  's/^([^:]+):[[:space:]]*(.*)/\1\x01\2/' \
     72 	| column -s $$'\x01' -t