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