transparent-cube

Minimal cross-platform native/wasm graphics example.
git clone git://git.amin.space/transparent-cube.git
Log | Files | Refs | README | LICENSE

Makefile (1533B)


      1 CC = clang
      2 CFLAGS = -std=c11 -Ilib -Wall -Wextra -Wshadow -Wswitch-enum -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces
      3 LDFLAGS = -ldl -lglfw -lGL
      4 
      5 SRC_FILES = platform_linux.c
      6 SRC = $(addprefix src/, $(SRC_FILES))
      7 EXE_FILE = transparent_cube
      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 DBGCFLAGS = -g -Og -Werror
     16 
     17 RELDIR = out/release
     18 RELEXE = $(RELDIR)/$(EXE_FILE)
     19 RELLIB = $(RELDIR)/$(LIB_NAME)
     20 RELLIBTMP = $(RELLIB).tmp
     21 RELCFLAGS = -DPLATFORM_HOTLOAD_GAME_CODE -O2 -Os
     22 
     23 .PHONY: default all build_debug build_lib build_release clean debug dir_debug dir_release memcheck run todo wasm
     24 
     25 default: build_release
     26 
     27 all: build_debug build_release wasm
     28 
     29 build_debug: dir_debug
     30 	$(CC) $(CFLAGS) $(DBGCFLAGS) $(SRC) -o $(DBGEXE) $(LDFLAGS)
     31 
     32 build_lib:
     33 	$(CC) $(CFLAGS) -fpic -shared $(RELCFLAGS) $(LIB) -o $(RELLIBTMP) $(LDFLAGS)
     34 	mv $(RELLIBTMP) $(RELLIB)
     35 
     36 build_release: dir_release build_lib
     37 	$(CC) $(CFLAGS) $(RELCFLAGS) $(SRC) -o $(RELEXE) $(LDFLAGS)
     38 
     39 clean:
     40 	rm -rf out/
     41 
     42 debug: build_debug
     43 	gdb $(DBGEXE)
     44 
     45 dir_debug:
     46 	@mkdir -p $(DBGDIR)
     47 
     48 dir_release:
     49 	@mkdir -p $(RELDIR)
     50 
     51 dir_wasm:
     52 	@mkdir -p $(EMSDIR)
     53 
     54 memcheck: build_debug
     55 	valgrind --track-origins=yes ./$(DBGEXE)
     56 
     57 run: build_release
     58 	./$(RELEXE)
     59 
     60 todo:
     61 	@grep -FIR --colour=never --ignore-case --line-number todo src/ \
     62 	| sed -re  's/^([^:]+):[[:space:]]*(.*)/\1\x01\2/' \
     63 	| sed -re  's/^([^:]+):[[:space:]]*(.*)/\1\x01\2/' \
     64 	| column -s $$'\x01' -t
     65 
     66 wasm:
     67 	./build_wasm.sh