Revert "Request SSE floating-point math from GCC for x86 systems"
[neverball] / Makefile
1
2 #------------------------------------------------------------------------------
3
4 VERSION := $(shell sh scripts/version.sh)
5 ifeq ($(VERSION),unknown)
6     $(warning Failed to obtain sane version for this build.)
7 endif
8
9 # Provide a target system hint for the Makefile.
10
11 ifeq ($(shell uname), Darwin)
12     DARWIN := 1
13 endif
14
15 #------------------------------------------------------------------------------
16 # Optional flags (CFLAGS, CPPFLAGS, ...)
17
18 ifeq ($(DEBUG),1)
19     CFLAGS   := -g
20     CPPFLAGS :=
21 else
22     CFLAGS   := -O2
23     CPPFLAGS := -DNDEBUG
24 endif
25
26 #------------------------------------------------------------------------------
27 # Mandatory flags
28
29 # Compiler...
30
31 ifeq ($(ENABLE_WII),1)
32     # -std=c99 because we need isnormal and -fms-extensions because
33     # libwiimote headers make heavy use of the "unnamed fields" GCC
34     # extension.
35
36     ALL_CFLAGS := -Wall -std=c99 -pedantic -fms-extensions $(CFLAGS)
37 else
38     ALL_CFLAGS := -Wall -ansi -pedantic $(CFLAGS)
39 endif
40
41 # Preprocessor...
42
43 SDL_CPPFLAGS := $(shell sdl-config --cflags) -U_GNU_SOURCE
44 PNG_CPPFLAGS := $(shell libpng-config --cflags)
45
46 ALL_CPPFLAGS := $(SDL_CPPFLAGS) $(PNG_CPPFLAGS) -Ishare \
47     -DVERSION=\"$(VERSION)\"
48
49 ifeq ($(ENABLE_NLS),0)
50     ALL_CPPFLAGS += -DENABLE_NLS=0
51 else
52     ALL_CPPFLAGS += -DENABLE_NLS=1
53 endif
54
55 ifeq ($(ENABLE_WII),1)
56     ALL_CPPFLAGS += -DENABLE_WII=1
57 endif
58
59 ifdef DARWIN
60     ALL_CPPFLAGS += -I/opt/local/include
61 endif
62
63 ALL_CPPFLAGS += $(CPPFLAGS)
64
65 #------------------------------------------------------------------------------
66 # Libraries
67
68 SDL_LIBS := $(shell sdl-config --libs)
69 PNG_LIBS := $(shell libpng-config --libs)
70 FS_LIBS := -lphysfs
71
72 # The  non-conditionalised values  below  are specific  to the  native
73 # system. The native system of this Makefile is Linux (or GNU+Linux if
74 # you prefer). Please be sure to  override ALL of them for each target
75 # system in the conditional parts below.
76
77 INTL_LIBS :=
78
79 ifeq ($(ENABLE_WII),1)
80     TILT_LIBS := -lcwiimote -lbluetooth
81 endif
82
83 OGL_LIBS := -lGL -lm
84
85 ifdef MINGW
86     ifneq ($(ENABLE_NLS),0)
87         INTL_LIBS := -lintl
88     endif
89
90     TILT_LIBS :=
91     OGL_LIBS  := -lopengl32 -lm
92 endif
93
94 ifdef DARWIN
95     ifneq ($(ENABLE_NLS),0)
96         INTL_LIBS := -lintl
97     endif
98
99     TILT_LIBS :=
100     OGL_LIBS  := -framework OpenGL
101 endif
102
103 BASE_LIBS := -ljpeg $(PNG_LIBS) $(FS_LIBS)
104
105 ifdef DARWIN
106     BASE_LIBS += -L/opt/local/lib
107 endif
108
109 ALL_LIBS := $(SDL_LIBS) $(BASE_LIBS) $(TILT_LIBS) $(INTL_LIBS) -lSDL_ttf \
110     -lvorbisfile $(OGL_LIBS)
111
112 #------------------------------------------------------------------------------
113
114 ifdef MINGW
115     EXT := .exe
116 endif
117
118 MAPC_TARG := mapc$(EXT)
119 BALL_TARG := neverball$(EXT)
120 PUTT_TARG := neverputt$(EXT)
121
122 ifdef MINGW
123     MAPC := $(WINE) ./$(MAPC_TARG)
124 else
125     MAPC := ./$(MAPC_TARG)
126 endif
127
128
129 #------------------------------------------------------------------------------
130
131 MAPC_OBJS := \
132         share/vec3.o        \
133         share/base_image.o  \
134         share/solid.o       \
135         share/binary.o      \
136         share/base_config.o \
137         share/common.o      \
138         share/fs.o          \
139         share/fs_png.o      \
140         share/fs_jpg.o      \
141         share/dir.o         \
142         share/array.o       \
143         share/mapc.o
144 BALL_OBJS := \
145         share/lang.o        \
146         share/st_resol.o    \
147         share/vec3.o        \
148         share/base_image.o  \
149         share/image.o       \
150         share/solid.o       \
151         share/solid_gl.o    \
152         share/solid_phys.o  \
153         share/part.o        \
154         share/back.o        \
155         share/geom.o        \
156         share/item.o        \
157         share/ball.o        \
158         share/gui.o         \
159         share/base_config.o \
160         share/config.o      \
161         share/video.o       \
162         share/binary.o      \
163         share/state.o       \
164         share/audio.o       \
165         share/text.o        \
166         share/tilt.o        \
167         share/common.o      \
168         share/keynames.o    \
169         share/syswm.o       \
170         share/list.o        \
171         share/queue.o       \
172         share/cmd.o         \
173         share/array.o       \
174         share/dir.o         \
175         share/fs.o          \
176         share/fs_png.o      \
177         share/fs_jpg.o      \
178         share/fs_rwops.o    \
179         share/fs_ov.o       \
180         ball/hud.o          \
181         ball/game_common.o  \
182         ball/game_client.o  \
183         ball/game_server.o  \
184         ball/game_proxy.o   \
185         ball/score.o        \
186         ball/level.o        \
187         ball/progress.o     \
188         ball/set.o          \
189         ball/demo.o         \
190         ball/demo_dir.o     \
191         ball/util.o         \
192         ball/st_conf.o      \
193         ball/st_demo.o      \
194         ball/st_save.o      \
195         ball/st_goal.o      \
196         ball/st_fall_out.o  \
197         ball/st_time_out.o  \
198         ball/st_done.o      \
199         ball/st_level.o     \
200         ball/st_over.o      \
201         ball/st_play.o      \
202         ball/st_set.o       \
203         ball/st_start.o     \
204         ball/st_title.o     \
205         ball/st_help.o      \
206         ball/st_name.o      \
207         ball/st_shared.o    \
208         ball/st_pause.o     \
209         ball/st_ball.o      \
210         ball/main.o
211 PUTT_OBJS := \
212         share/lang.o        \
213         share/st_resol.o    \
214         share/vec3.o        \
215         share/base_image.o  \
216         share/image.o       \
217         share/solid.o       \
218         share/solid_gl.o    \
219         share/solid_phys.o  \
220         share/part.o        \
221         share/geom.o        \
222         share/ball.o        \
223         share/back.o        \
224         share/base_config.o \
225         share/config.o      \
226         share/video.o       \
227         share/binary.o      \
228         share/audio.o       \
229         share/state.o       \
230         share/gui.o         \
231         share/text.o        \
232         share/common.o      \
233         share/syswm.o       \
234         share/list.o        \
235         share/fs.o          \
236         share/fs_png.o      \
237         share/fs_jpg.o      \
238         share/fs_rwops.o    \
239         share/fs_ov.o       \
240         share/dir.o         \
241         share/array.o       \
242         putt/hud.o          \
243         putt/game.o         \
244         putt/hole.o         \
245         putt/course.o       \
246         putt/st_all.o       \
247         putt/st_conf.o      \
248         putt/main.o
249
250 ifdef MINGW
251 BALL_OBJS += neverball.ico.o
252 PUTT_OBJS += neverputt.ico.o
253 endif
254
255 BALL_DEPS := $(BALL_OBJS:.o=.d)
256 PUTT_DEPS := $(PUTT_OBJS:.o=.d)
257 MAPC_DEPS := $(MAPC_OBJS:.o=.d)
258
259 MAPS := $(shell find data -name "*.map" \! -name "*.autosave.map")
260 SOLS := $(MAPS:%.map=%.sol)
261
262 DESKTOPS := $(basename $(wildcard dist/*.desktop.in))
263
264 #------------------------------------------------------------------------------
265
266 %.o : %.c
267         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $<
268         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -o $@ -c $<
269
270 %.sol : %.map $(MAPC_TARG)
271         $(MAPC) $< data
272
273 %.desktop : %.desktop.in
274         sh scripts/translate-desktop.sh < $< > $@
275
276 %.ico.o: dist/ico/%.ico
277         echo "1 ICON \"$<\"" | $(WINDRES) -o $@
278
279 #------------------------------------------------------------------------------
280
281 all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales desktops
282
283 $(BALL_TARG) : $(BALL_OBJS)
284         $(CC) $(ALL_CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LDFLAGS) $(ALL_LIBS)
285
286 $(PUTT_TARG) : $(PUTT_OBJS)
287         $(CC) $(ALL_CFLAGS) -o $(PUTT_TARG) $(PUTT_OBJS) $(LDFLAGS) $(ALL_LIBS)
288
289 $(MAPC_TARG) : $(MAPC_OBJS)
290         $(CC) $(ALL_CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(LDFLAGS) $(BASE_LIBS)
291
292 # Work around some extremely helpful sdl-config scripts.
293
294 ifdef MINGW
295 $(MAPC_TARG) : ALL_CPPFLAGS := $(ALL_CPPFLAGS) -Umain
296 endif
297
298 sols : $(SOLS)
299
300 locales :
301 ifneq ($(ENABLE_NLS),0)
302         $(MAKE) -C po
303 endif
304
305 desktops : $(DESKTOPS)
306
307 clean-src :
308         $(RM) $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS)
309         $(RM) $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS)
310         $(RM) $(MAPC_TARG) $(MAPC_OBJS) $(MAPC_DEPS)
311
312 clean : clean-src
313         $(RM) $(SOLS)
314         $(RM) $(DESKTOPS)
315         $(MAKE) -C po clean
316
317 test : all
318         ./neverball
319
320 TAGS :
321         $(RM) $@
322         find . -name '*.[ch]' | xargs etags -a
323
324 #------------------------------------------------------------------------------
325
326 .PHONY : all sols locales clean-src clean test TAGS
327
328 -include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS)
329
330 #------------------------------------------------------------------------------
331
332 ifdef MINGW
333
334 #------------------------------------------------------------------------------
335
336 INSTALLER := ../neverball-$(VERSION)-setup.exe
337
338 MAKENSIS := makensis
339 MAKENSIS_FLAGS := -DVERSION=$(VERSION) -DOUTFILE=$(INSTALLER)
340
341 TODOS   := todos
342 FROMDOS := fromdos
343
344 CP := cp
345
346 TEXT_DOCS := \
347         doc/AUTHORS \
348         doc/MANUAL  \
349         CHANGES     \
350         COPYING     \
351         README
352
353 TXT_DOCS := $(TEXT_DOCS:%=%.txt)
354
355 #------------------------------------------------------------------------------
356
357 .PHONY: setup
358 setup: $(INSTALLER)
359
360 $(INSTALLER): install-dlls convert-text-files all contrib
361         $(MAKENSIS) $(MAKENSIS_FLAGS) -nocd scripts/neverball.nsi
362
363 $(INSTALLER): LDFLAGS := -s $(LDFLAGS)
364
365 .PHONY: clean-setup
366 clean-setup: clean
367         $(RM) install-dlls.sh *.dll $(TXT_DOCS)
368         find data -name "*.txt" -exec $(FROMDOS) {} \;
369         $(MAKE) -C contrib EXT=$(EXT) clean
370
371 #------------------------------------------------------------------------------
372
373 .PHONY: install-dlls
374 install-dlls: install-dlls.sh
375         sh $<
376
377 install-dlls.sh: $(MAPC_TARG) $(BALL_TARG) $(PUTT_TARG)
378         mingw-list-dlls --format=shell $^ > $@
379
380 #------------------------------------------------------------------------------
381
382 .PHONY: convert-text-files
383 convert-text-files: $(TXT_DOCS)
384         find data -name "*.txt" -exec $(TODOS) {} \;
385
386 %.txt: %
387         $(CP) $< $@
388         $(TODOS) $@
389
390 #------------------------------------------------------------------------------
391
392 .PHONY: contrib
393 contrib:
394         $(MAKE) -C contrib EXT=$(EXT)
395
396 #------------------------------------------------------------------------------
397
398 endif
399
400 #------------------------------------------------------------------------------