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