-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
189 lines (158 loc) · 3.98 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# ----------------------------------------------------- #
# Makefile for the Chaos game module for Quake II #
# #
# Just type "make" to compile the #
# - Chaos Game (game.so / game.dll) #
# #
# Dependencies: #
# - None, but you need a Quake II to play. #
# While in theorie every one should work #
# Yamagi Quake II ist recommended. #
# #
# Platforms: #
# - FreeBSD #
# - Linux #
# - Mac OS X #
# - OpenBSD #
# - Windows #
# ----------------------------------------------------- #
# Detect the OS
ifdef SystemRoot
OSTYPE := Windows
else
OSTYPE := $(shell uname -s)
endif
# Special case for MinGW
ifneq (,$(findstring MINGW,$(OSTYPE)))
OSTYPE := Windows
endif
# ----------
# Base CFLAGS.
#
# -O2 are enough optimizations.
#
# -fno-strict-aliasing since the source doesn't comply
# with strict aliasing rules and it's next to impossible
# to get it there...
#
# -fomit-frame-pointer since the framepointer is mostly
# useless for debugging Quake II and slows things down.
#
# -g to build allways with debug symbols. Please do not
# change this, since it's our only chance to debug this
# crap when random crashes happen!
#
# -fPIC for position independend code.
#
# -MMD to generate header dependencies.
ifeq ($(OSTYPE), Darwin)
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -fwrapv -arch i386 -arch x86_64
else
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -MMD -fwrapv
endif
# ----------
# Base LDFLAGS.
ifeq ($(OSTYPE), Darwin)
LDFLAGS := -shared -arch i386 -arch x86_64
else
LDFLAGS := -shared
endif
# ----------
# Builds everything
all: chaos
# ----------
# When make is invoked by "make VERBOSE=1" print
# the compiler and linker commands.
ifdef VERBOSE
Q :=
else
Q := @
endif
# ----------
# Phony targets
.PHONY : all clean chaos
# ----------
# Cleanup
clean:
@echo "===> CLEAN"
${Q}rm -Rf build release
# ----------
# The Chaos game
ifeq ($(OSTYPE), Windows)
chaos:
@echo "===> Building game.dll"
$(Q)mkdir -p release
$(MAKE) release/game.dll
build/%.o: %.c
@echo "===> CC $<"
$(Q)mkdir -p $(@D)
$(Q)$(CC) -c $(CFLAGS) -o $@ $<
else
chaos:
@echo "===> Building game.so"
$(Q)mkdir -p release
$(MAKE) release/game.so
build/%.o: %.c
@echo "===> CC $<"
$(Q)mkdir -p $(@D)
$(Q)$(CC) -c $(CFLAGS) -o $@ $<
release/game.so : CFLAGS += -fPIC
endif
# ----------
CHAOS_OBJS_ = \
src/c_base.o \
src/c_botai.o \
src/c_botmisc.o \
src/c_botnav.o \
src/c_cam.o \
src/c_item.o \
src/c_weapon.o \
src/g_cmds.o \
src/g_combat.o \
src/g_ctf.o \
src/g_func.o \
src/g_items.o \
src/g_main.o \
src/g_misc.o \
src/g_phys.o \
src/g_save.o \
src/g_spawn.o \
src/g_svcmds.o \
src/g_target.o \
src/g_trigger.o \
src/g_utils.o \
src/g_weapon.o \
src/gslog.o \
src/m_move.o \
src/p_client.o \
src/p_hud.o \
src/p_menu.o \
src/p_view.o \
src/p_weapon.o \
src/q_shared.o \
src/stdlog.o
# ----------
# Rewrite pathes to our object directory
CHAOS_OBJS = $(patsubst %,build/%,$(CHAOS_OBJS_))
# ----------
# Generate header dependencies
CHAOS_DEPS= $(CHAOS:.o=.d)
# ----------
# Suck header dependencies in
-include $(CHAOS_DEPS)
# ----------
ifeq ($(OSTYPE), Windows)
release/game.dll : $(CHAOS_OBJS)
@echo "===> LD $@"
$(Q)$(CC) $(LDFLAGS) -o $@ $(CHAOS_OBJS)
release/game.dylib : $(CHAOS_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) -o $@ $(CHAOS_OBJS)
else
release/game.so : $(CHAOS_OBJS)
@echo "===> LD $@"
$(Q)$(CC) $(LDFLAGS) -o $@ $(CHAOS_OBJS)
endif
# ----------