~jb55/polyadvent

ref: 5d1a173bea9026bf34c8e135d3fe68d122710aa7 polyadvent/Makefile -rw-r--r-- 1.6 KiB
5d1a173bWilliam Casarin no debug 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
NAME ?= polyadvent
BIN ?= $(NAME)
PREFIX ?= /usr/local
DEFS= -DGLFW_INCLUDE_NONE
# release build lol
# DEFS= -DGLFW_INCLUDE_NONE -DNDEBUG

# CFLAGS = $(DEFS) -ggdb -O0 -I src -Wall -Wextra -std=c99 \

CFLAGS = $(DEFS) -O1 -g -I src -Wall -Werror -Wextra -std=c99  \
						-Wno-unused-function \
						-Wno-unused-parameter \
						-Wno-unused-variable \
						-Wmissing-field-initializers \
						-Wno-cast-align \
						-Wno-padded
LDFLAGS = -lSDL2 -lGL -lm
SRC=src

SRCS=$(wildcard $(SRC)/*.c)
PLYS=$(wildcard data/models/*.ply)

MODELS=$(PLYS:.ply=.mdl)
OBJS=$(SRCS:.c=.o)

TESTS =  test/test_dae
TESTS += test/test_resource
TESTS += test/test_scene

TOOLS = tools/compile-model

all: $(BIN) $(MODELS)

clean:
	rm -f main.o polyadvent.o src/main.o test/*.o tools/*.o $(OBJS) $(TESTS) $(TOOLS) $(MODELS) $(SHLIB) $(BIN) $(SRC)/*.d*

%.d: %.c
	@rm -f $@; \
	$(CC) -MM $(CFLAGS) $< > $@.$$$$; \
	sed 's,\(.*\)\.o[ :]*,src/\1.o $@ : ,g' < $@.$$$$ > $@; \
	rm -f $@.$$$$

%.o: %.c %.h
	@echo "cc $<"
	@$(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<

test/%: test/%.o $(OBJS)
	@echo "link $@"
	@$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

tools/%: tools/%.o $(OBJS)
	@echo "link $@"
	@$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

tools: $(TOOLS)

data/models/%.mdl: data/models/%.ply tools/compile-model
	@echo "compile-model $@"
	@./tools/compile-model $< $@

check: $(TESTS) $(MODELS)
	./test/test_dae
	./test/test_resource
	./test/test_scene

$(BIN): main.o $(OBJS)
	@echo "link $@"
	@$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@

install: $(BIN)
	install -d $(PREFIX)/bin
	install $(BIN) $(PREFIX)/bin

TAGS:
	etags $(SRCS)

.PHONY: TAGS