forked from idispatch/opentyrian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (56 loc) · 1.53 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# BUILD SETTINGS ###########################################
#PLATFORM := UNIX
PLATFORM := QNX
TARGET := opentyrian
############################################################
ifneq ($(PLATFORM), QNX)
STRIP := strip
SDL_CONFIG := sdl-config
ifneq ($(PLATFORM), UNIX)
include crosscompile.mk
endif
SRCS := $(wildcard src/*.c)
OBJS := $(SRCS:src/%.c=obj/%.o)
# FLAGS ####################################################
ifneq ($(MAKECMDGOALS), release)
EXTRA_CFLAGS += -g3 -O0 -Werror
else
EXTRA_CFLAGS += -g0 -O2 -DNDEBUG
endif
EXTRA_CFLAGS += -MMD -pedantic -Wall -Wextra -Wno-missing-field-initializers
HG_REV := $(shell hg id -ib && touch src/hg_revision.h)
ifneq ($(HG_REV), )
EXTRA_CFLAGS += '-DHG_REV="$(HG_REV)"'
endif
EXTRA_LDLIBS += -lm
SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
SDL_LDLIBS := $(shell $(SDL_CONFIG) --libs) -lSDL_net
ALL_CFLAGS += -std=c99 -I./src -DTARGET_$(PLATFORM) $(EXTRA_CFLAGS) $(SDL_CFLAGS) $(CFLAGS)
ALL_LDFLAGS += $(LDFLAGS)
LDLIBS += $(EXTRA_LDLIBS) $(SDL_LDLIBS)
# RULES ####################################################
.PHONY : all release clean
all : $(TARGET)
release : all
$(STRIP) $(TARGET)
clean :
rm -rf obj/*
rm -f $(TARGET)
ifneq ($(MAKECMDGOALS), clean)
-include $(OBJS:.o=.d)
endif
$(TARGET) : $(OBJS)
$(CC) -o $@ $(ALL_LDFLAGS) $^ $(LDLIBS)
obj/%.o : src/%.c
@mkdir -p "$(dir $@)"
$(CC) -c -o $@ $(ALL_CFLAGS) $<
else #QNX
LIST=CPU
ifndef QRECURSE
QRECURSE=recurse.mk
ifdef QCONFIG
QRDIR=$(dir $(QCONFIG))
endif
endif
include $(QRDIR)$(QRECURSE)
endif #QNX