-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.pc
286 lines (220 loc) · 6.38 KB
/
makefile.pc
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# C-Dogs SDL Makefile
### Variables ###
# Make sure only one variable in the provided set is uncommented!
# Can be: "linux", "macosx", "xmingw" or "mingw32"
#SYSTEM := "macosx"
#SYSTEM := "linux"
#SYSTEM := "xmingw"
SYSTEM := "mingw32"
# Can be either: sdlmixer, nomix or oldmix
# sdlmixer is recommended, as you get proper music and sounds =)
#SOUND_CODE := "sdlmixer"
#SOUND_CODE := "nomix"
#SOUND_CODE := "oldmix"
# Destdir is where the base dir where everything is installed
DESTDIR := ../dist
#DESTDIR := /
DATA := ../data
#DATA := /path/to/where/data/is/unpacked/
# Prefix is the *actual* base directory
# Bindir is where the cdogs binary is placed
# Datadir is where the data is
PREFIX := /usr/local
BINDIR := $(PREFIX)/games/bin
DATADIR := $(PREFIX)/share/games/cdogs
DOCDIR := $(PREFIX)/share/doc/cdogs
# The following are for a self-contained install
#PREFIX := .
#BINDIR := $(PREFIX)/
DATADIR := data
#CFGDIR := $(PREFIX)/config
#DOCDIR := $(PREFIX)/doc
# intel, powerpc... uncomment only one (if at all)
#CF_ARCH += -march=pentium2 -mcpu=pentium2
#CF_ARCH += -mcpu=G3 -mtune=G3
#CF_ARCH += -mcpu=G4 -mtune=G4 -maltivec
CF_OPTIMISE += -O2
CC := gcc
STRIP := strip
# Set to 1 for debugging
DEBUG=0
DEBUG_PROFILE=0
### Change this to yes, once you are ready
I_AM_CONFIGURED=yes
# Name of the cdogs binary (probably doesn't need to be changed)
CDOGS=cdogs
CDOGSED=cdogs-editor
# Suffix of the executable
PROG_SUFFIX :=
### Some logic to work out things
### Sound code
ifeq ($(SOUND_CODE), "sdlmixer")
DEFS += -DSND_SDLMIXER
endif
ifeq ($(SOUND_CODE), "nomix")
DEFS += -DSND_NOMIX
endif
# Just assume it's Linux, by default
ifeq ($(SYSTEM),)
SYSTEM := "linux"
endif
# detect MacOS X
ifeq ($(shell uname -s), Darwin)
SYSTEM := "macosx"
endif
### System specific parts
ifeq ($(SYSTEM), "macosx")
DEFS += -DSYS_MACOSX
LDFLAGS += -framework SDL -framework SDL_mixer -framework AppKit -framework Foundation
FRAMEWORK_DIR := /Library/Frameworks
SDL_FRAMEWORK := $(FRAMEWORK_DIR)/SDL.framework
SDLMIXER_FRAMEWORK := $(FRAMEWORK_DIR)/SDL_mixer.framework
INCLUDES += -I$(SDL_FRAMEWORK)/Headers
ifeq ($(SOUND_CODE), "sdlmixer")
INCLUDES += -I$(SDLMIXER_FRAMEWORK)/Headers
endif
EXTRA_OBJS = SDLmain.o
endif
ifeq ($(SYSTEM), "linux")
LDFLAGS += $(shell sdl-config --libs)
INCLUDES += $(shell sdl-config --cflags)
ifeq ($(SOUND_CODE), "sdlmixer")
LDFLAGS += -lSDL_mixer
endif
endif
ifeq ($(SYSTEM), "xmingw")
CC := i386-mingw32msvc-gcc
STRIP := i386-mingw32msvc-strip
WINDRES := i386-mingw32msvc-windres
SDLCONFIG := i386-mingw32msvc-sdl-config
LDFLAGS += $(shell $(SDLCONFIG) --libs)
INCLUDES += $(shell $(SDLCONFIG) --cflags)
DEFS += -DSYS_WIN
ifeq ($(SOUND_CODE), "sdlmixer")
LDFLAGS += -lSDL_mixer
endif
PROG_SUFFIX := .exe
EXTRA_OBJS = rc.o
endif
ifeq ($(SYSTEM), "mingw32")
CC := mingw32-gcc
STRIP := mingw32-strip
WINDRES := mingw32-windres
SDLCONFIG := sdl-config
LDFLAGS += $(shell $(SDLCONFIG) --libs)
INCLUDES += $(shell $(SDLCONFIG) --cflags)
DEFS += -DSYS_WIN
ifeq ($(SOUND_CODE), "sdlmixer")
LDFLAGS += -lSDL_mixer
endif
PROG_SUFFIX := .exe
#EXTRA_OBJS = rc.o
endif
### Debugging
ifeq ($(DEBUG), 1)
DEFS += -DCDOGS_DEBUG
CF_DEBUG += -ggdb -Wall
ifeq ($(DEBUG_PROFILE), 1)
CF_DEBUG += -pg
LDFLAGS += -pg
endif
else
# suppress warnings
CF_DEBUG += -w
endif
### No need to edit below here ###
CFLAGS += $(CF_OPTIMISE) $(CF_ARCH) $(CF_DEBUG)
INCLUDES += -I./include -I./missions -Ic:/MinGW/include/SDL
LDFLAGS +=
DEFS += -DCDOGS_DATA_DIR=\"$(DATADIR)\"
CDOGS_OBJS = \
cdogs.o draw.o pics.o actors.o map.o sounds.o defs.o objs.o \
gamedata.o ai.o triggers.o input.o prep.o hiscores.o automap.o \
mission.o game.o mainmenu.o password.o files.o menu.o joystick.o \
sprcomp.o grafx.o blit.o text.o keyboard.o events.o utils.o \
drawtools.o
CDOGSED_OBJS = \
cdogsed.o draw.o pics.o actors.o map.o sounds.o defs.o objs.o \
gamedata.o triggers.o input.o hiscores.o automap.o mission.o game.o \
ai.o charsed.o events.o joystick.o sprcomp.o grafx.o blit.o text.o \
keyboard.o drawtools.o utils.o
### Targets ###
.PHONY: clean install info tidy help
#help:
@echo "C-Dogs SDL Build System..."
@echo
@echo "REMEMBER TO EDIT THE MAKEFILE!"
@echo
@echo "Targets:"
@echo " * $(CDOGS) - build cdogs binary"
@echo " * $(CDOGSED) - build cdogs editor binary"
@echo " * install - install cdogs binary (and data)"
@echo " * info - show configuration"
@echo " * clean - clean tree for building"
@echo " * help - this help"
@echo
@echo "Usage: make <target>"
$(CDOGS): $(CDOGS_OBJS) $(EXTRA_OBJS)
@echo "Linking... ($(CDOGS))"
$(CC) $(CDOGS_OBJS) $(EXTRA_OBJS) -o $(CDOGS)$(PROG_SUFFIX) $(LDFLAGS)
@echo "Now type 'make install' as root!"
$(CDOGSED): $(CDOGSED_OBJS) $(EXTRA_OBJS)
@echo "Linking... ($(CDOGSED))"
@$(CC) $(CDOGSED_OBJS) $(EXTRA_OBJS) -o $(CDOGSED)$(PROG_SUFFIX) $(LDFLAGS)
.c.o: include/*.h
@if [ "$(I_AM_CONFIGURED)" != "yes" ] ; then \
echo "Have you really configured the Makefile?" ; \
echo "Change I_AM_CONFIGURED to yes" ; \
exit 1 ; \
fi
@echo "Compiling $<... (debug=$(DEBUG),profile=$(DEBUG_PROFILE))"
$(CC) \
$(CFLAGS) \
$(INCLUDES) \
$(DEFS) \
-c $<
# This is for Mac OS X
SDLmain.o: ../build/macosx/SDLmain.m ../build/macosx/SDLmain.h
@echo "Compiling SDLmain.m (MacOSX) (debug=$(DEBUG))"
@$(CC) \
$(CFLAGS) \
$(INCLUDES) \
-c ../build/macosx/SDLmain.m
# Windows resource
#rc.o: ../build/windows/cdogs.rc ../build/windows/cdogs-icon.ico
# @echo "Compiling Windows resourcs (cdogs.rc) (debug=$(DEBUG))"
# $(WINDRES) -o rc.o -I ../build/windows/ ../build/windows/cdogs.rc
info:
@echo "=[ Program ]="
@echo "C-Dogs: $(CDOGS)$(PROG_SUFFIX)"
@echo "Editor: $(CDOGSED)$(PROG_SUFFIX)"
@echo ""
@echo "=[ System ]="
@echo "System: $(SYSTEM)"
@echo "Sound: $(SOUND_CODE)"
@echo ""
@echo "=[ Paths ]="
@echo "Prefix: $(PREFIX)"
@echo "Bin dir: $(BINDIR)"
@echo "Data dir: $(DATADIR)"
@echo "Doc dir: $(DOCDIR)"
@echo "Dest dir: $(DESTDIR)"
@echo ""
@echo "=[ Compilation ]="
@echo "CC: $(CC)"
@echo "CFLAGS: $(CFLAGS)"
@echo "INCLUDES: $(INCLUDES)"
@echo "DEFS: $(DEFS)"
@echo "LDFLAGS: $(LDFLAGS)"
install:
DESTDIR=$(DESTDIR) \
DOCDIR=$(DOCDIR) \
DATADIR=$(DATADIR) \
BINDIR=$(BINDIR) \
PREFIX=$(PREFIX) \
PROG=$(CDOGS)$(PROG_SUFFIX) \
LOCALDATA=$(DATA) \
LOCALDOCS="../doc/" \
./install.sh
clean:
rm -f *.o $(CDOGS)$(PROG_SUFFIX) $(CDOGSED)$(PROG_SUFFIX)