ohsp

Prototype for a game with dual thruster controls.
git clone git://git.amin.space/ohsp.git
Log | Files | Refs | LICENSE

Makefile (1684B)


      1 CC = gcc
      2 CFLAGS = -std=c99 -Wall -Wextra -Wshadow -Wswitch-enum -Wno-unused-parameter
      3 LDFLAGS = $(SDL_LDFLAGS) -ldl -lm
      4 
      5 SDL_CFLAGS := $(shell sdl2-config --cflags)
      6 SDL_LDFLAGS := $(shell sdl2-config --libs)
      7 
      8 override CFLAGS += $(SDL_CFLAGS)
      9 
     10 SRC_FILES = platform_sdl.c game.c entity.c vector.c
     11 SRC = $(addprefix src/, $(SRC_FILES))
     12 EXE_FILE = ohsp
     13 
     14 LIB_FILES = game.c entity.c vector.c
     15 LIB = $(addprefix src/, $(LIB_FILES))
     16 LIB_NAME = game.so
     17 
     18 DBGDIR = debug
     19 DBGEXE = $(DBGDIR)/$(EXE_FILE)
     20 DBGLIB = $(DBGDIR)/$(LIB_NAME)
     21 DBGLIBTMP = $(DBGLIB).tmp
     22 DBGCFLAGS = -g -Og -Werror
     23 
     24 RELDIR = release
     25 RELEXE = $(RELDIR)/$(EXE_FILE)
     26 RELLIB = $(RELDIR)/$(LIB_NAME)
     27 RELLIBTMP = $(RELLIB).tmp
     28 RELCFLAGS = -O2 -Os
     29 
     30 .PHONY: all clean compile_debug compile_release debug lib_debug lib_release memcheck prep run todo
     31 
     32 all: compile_debug compile_release
     33 
     34 clean:
     35 	rm -f $(RELDIR)/* $(DBGDIR)/*
     36 
     37 compile_debug: prep lib_debug
     38 	$(CC) $(CFLAGS) $(DBGCFLAGS) $(SRC) -o $(DBGEXE) $(LDFLAGS)
     39 
     40 compile_release: prep lib_release
     41 	$(CC) $(CFLAGS) $(RELCFLAGS) $(SRC) -o $(RELEXE) $(LDFLAGS)
     42 
     43 debug: compile_debug
     44 	gdb $(DBGEXE)
     45 
     46 lib_debug:
     47 	$(CC) $(CFLAGS) -fpic -shared $(DBGCFLAGS) $(LIB) -o $(DBGLIBTMP) $(LDFLAGS)
     48 	mv $(DBGLIBTMP) $(DBGLIB)
     49 
     50 lib_release:
     51 	$(CC) $(CFLAGS) -fpic -shared $(RELCFLAGS) $(LIB) -o $(RELLIBTMP) $(LDFLAGS)
     52 	mv $(RELLIBTMP) $(RELLIB)
     53 
     54 memcheck: compile_debug
     55 	valgrind --track-origins=yes ./$(DBGEXE)
     56 
     57 prep:
     58 	@mkdir -p $(DBGDIR) $(RELDIR)
     59 
     60 run: compile_release
     61 	./$(RELEXE)
     62 
     63 todo:
     64 	@grep -FIR --colour=never --ignore-case --line-number todo src/ \
     65 	| sed -re  's/^([^:]+):[[:space:]]*(.*)/\1\x01\2/' \
     66 	| sed -re  's/^([^:]+):[[:space:]]*(.*)/\1\x01\2/' \
     67 	| column -s $$'\x01' -t