-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (38 loc) · 1.02 KB
/
Makefile
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
LIB_MODE=1
PROGRAM := game
# Must be the first rule
.PHONY: default
default: $(PROGRAM)
SOURCES := $(wildcard src/*.c)
OBJECTS := $(SOURCES:src/%.c=obj/%.o)
DEPENDS := $(SOURCES:src/%.c=deps/%.d)
MAKEFILES := Makefile
CUSTOM_OBJ := obj/mapio.o obj/tempo.o
LIB := lib/libgame.a
#CC=gcc
CFLAGS := -O3 -g -std=c99 -Wall -Wno-unused-function
CFLAGS += -DPADAWAN
CFLAGS += -I./include
CFLAGS += $(shell pkg-config SDL2_image SDL2_mixer --cflags)
LDLIBS := $(shell pkg-config SDL2_image SDL2_mixer --libs)
$(OBJECTS): $(MAKEFILES)
ifndef LIB_MODE
$(LIB): $(filter-out $(CUSTOM_OBJ),$(OBJECTS))
ar -crs $(LIB) $^
endif
$(PROGRAM): $(CUSTOM_OBJ) $(LIB)
$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS) -lpthread
$(OBJECTS): obj/%.o: src/%.c
$(CC) -o $@ $(CFLAGS) -c $<
.PHONY: depend
depend: $(DEPENDS)
$(DEPENDS): $(MAKEFILES)
$(DEPENDS): deps/%.d: src/%.c
$(CC) $(CFLAGS) -MM $< | \
sed -e 's|\(.*\)\.o:|deps/\1.d obj/\1.o:|g' > $@
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPENDS)
endif
.PHONY: clean
clean:
rm -f game obj/*.o deps/*.d