tennis.map: Texture tweak
[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
97 ifeq ($(ENABLE_FS),stdio)
98 FS_LIBS :=
99 else
100 FS_LIBS := -lphysfs
101 endif
102
103 # The  non-conditionalised values  below  are specific  to the  native
104 # system. The native system of this Makefile is Linux (or GNU+Linux if
105 # you prefer). Please be sure to  override ALL of them for each target
106 # system in the conditional parts below.
107
108 INTL_LIBS :=
109
110 ifeq ($(ENABLE_TILT),wii)
111     TILT_LIBS := -lcwiimote -lbluetooth
112 else
113 ifeq ($(ENABLE_TILT),loop)
114     TILT_LIBS := -lusb-1.0 -lfreespace
115 endif
116 endif
117
118 OGL_LIBS := -lGL -lm
119
120 ifeq ($(PLATFORM),mingw)
121     ifneq ($(ENABLE_NLS),0)
122         INTL_LIBS := -lintl
123     endif
124
125     TILT_LIBS :=
126     OGL_LIBS  := -lopengl32 -lm
127 endif
128
129 ifeq ($(PLATFORM),darwin)
130     ifneq ($(ENABLE_NLS),0)
131         INTL_LIBS := -lintl
132     endif
133
134     TILT_LIBS :=
135     OGL_LIBS  := -framework OpenGL
136 endif
137
138 BASE_LIBS := -ljpeg $(PNG_LIBS) $(FS_LIBS)
139
140 ifeq ($(PLATFORM),darwin)
141     BASE_LIBS += -L/opt/local/lib
142 endif
143
144 ALL_LIBS := $(SDL_LIBS) $(BASE_LIBS) $(TILT_LIBS) $(INTL_LIBS) -lSDL_ttf \
145     -lvorbisfile $(OGL_LIBS)
146
147 #------------------------------------------------------------------------------
148
149 ifeq ($(PLATFORM),mingw)
150     EXT := .exe
151 endif
152
153 MAPC_TARG := mapc$(EXT)
154 BALL_TARG := neverball$(EXT)
155 PUTT_TARG := neverputt$(EXT)
156
157 ifeq ($(PLATFORM),mingw)
158     MAPC := $(WINE) ./$(MAPC_TARG)
159 else
160     MAPC := ./$(MAPC_TARG)
161 endif
162
163
164 #------------------------------------------------------------------------------
165
166 MAPC_OBJS := \
167         share/vec3.o        \
168         share/base_image.o  \
169         share/solid_base.o  \
170         share/binary.o      \
171         share/base_config.o \
172         share/common.o      \
173         share/fs_common.o   \
174         share/fs_png.o      \
175         share/fs_jpg.o      \
176         share/dir.o         \
177         share/array.o       \
178         share/list.o        \
179         share/mapc.o
180 BALL_OBJS := \
181         share/lang.o        \
182         share/st_resol.o    \
183         share/vec3.o        \
184         share/base_image.o  \
185         share/image.o       \
186         share/solid_base.o  \
187         share/solid_vary.o  \
188         share/solid_draw.o  \
189         share/solid_cmd.o   \
190         share/solid_all.o   \
191         share/part.o        \
192         share/geom.o        \
193         share/item.o        \
194         share/ball.o        \
195         share/gui.o         \
196         share/base_config.o \
197         share/config.o      \
198         share/video.o       \
199         share/glext.o       \
200         share/binary.o      \
201         share/state.o       \
202         share/audio.o       \
203         share/text.o        \
204         share/common.o      \
205         share/keynames.o    \
206         share/syswm.o       \
207         share/list.o        \
208         share/queue.o       \
209         share/cmd.o         \
210         share/array.o       \
211         share/dir.o         \
212         share/fs_common.o   \
213         share/fs_png.o      \
214         share/fs_jpg.o      \
215         share/fs_rwops.o    \
216         share/fs_ov.o       \
217         share/sync.o        \
218         ball/hud.o          \
219         ball/game_common.o  \
220         ball/game_client.o  \
221         ball/game_server.o  \
222         ball/game_proxy.o   \
223         ball/game_draw.o    \
224         ball/score.o        \
225         ball/level.o        \
226         ball/progress.o     \
227         ball/set.o          \
228         ball/demo.o         \
229         ball/demo_dir.o     \
230         ball/util.o         \
231         ball/speed.o        \
232         ball/st_conf.o      \
233         ball/st_demo.o      \
234         ball/st_save.o      \
235         ball/st_goal.o      \
236         ball/st_fail.o      \
237         ball/st_done.o      \
238         ball/st_level.o     \
239         ball/st_over.o      \
240         ball/st_play.o      \
241         ball/st_set.o       \
242         ball/st_start.o     \
243         ball/st_title.o     \
244         ball/st_help.o      \
245         ball/st_name.o      \
246         ball/st_shared.o    \
247         ball/st_pause.o     \
248         ball/st_ball.o      \
249         ball/main.o
250 PUTT_OBJS := \
251         share/lang.o        \
252         share/st_resol.o    \
253         share/vec3.o        \
254         share/base_image.o  \
255         share/image.o       \
256         share/solid_base.o  \
257         share/solid_vary.o  \
258         share/solid_draw.o  \
259         share/solid_cmd.o   \
260         share/solid_all.o   \
261         share/part.o        \
262         share/geom.o        \
263         share/ball.o        \
264         share/base_config.o \
265         share/config.o      \
266         share/video.o       \
267         share/glext.o       \
268         share/binary.o      \
269         share/audio.o       \
270         share/state.o       \
271         share/gui.o         \
272         share/text.o        \
273         share/common.o      \
274         share/syswm.o       \
275         share/list.o        \
276         share/fs_common.o   \
277         share/fs_png.o      \
278         share/fs_jpg.o      \
279         share/fs_rwops.o    \
280         share/fs_ov.o       \
281         share/dir.o         \
282         share/array.o       \
283         share/sync.o        \
284         putt/hud.o          \
285         putt/game.o         \
286         putt/hole.o         \
287         putt/course.o       \
288         putt/st_all.o       \
289         putt/st_conf.o      \
290         putt/main.o
291
292 BALL_OBJS += share/solid_sim_sol.o
293 PUTT_OBJS += share/solid_sim_sol.o
294
295 ifeq ($(ENABLE_FS),stdio)
296 BALL_OBJS += share/fs_stdio.o
297 PUTT_OBJS += share/fs_stdio.o
298 MAPC_OBJS += share/fs_stdio.o
299 else
300 BALL_OBJS += share/fs_physfs.o
301 PUTT_OBJS += share/fs_physfs.o
302 MAPC_OBJS += share/fs_physfs.o
303 endif
304
305 ifeq ($(ENABLE_TILT),wii)
306 BALL_OBJS += share/tilt_wii.o
307 else
308 ifeq ($(ENABLE_TILT),loop)
309 BALL_OBJS += share/tilt_loop.o
310 else
311 BALL_OBJS += share/tilt_null.o
312 endif
313 endif
314
315 ifeq ($(PLATFORM),mingw)
316 BALL_OBJS += neverball.ico.o
317 PUTT_OBJS += neverputt.ico.o
318 endif
319
320 BALL_DEPS := $(BALL_OBJS:.o=.d)
321 PUTT_DEPS := $(PUTT_OBJS:.o=.d)
322 MAPC_DEPS := $(MAPC_OBJS:.o=.d)
323
324 MAPS := $(shell find data -name "*.map" \! -name "*.autosave.map")
325 SOLS := $(MAPS:%.map=%.sol)
326
327 DESKTOPS := $(basename $(wildcard dist/*.desktop.in))
328
329 #------------------------------------------------------------------------------
330
331 %.o : %.c
332         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $<
333         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -o $@ -c $<
334
335 %.sol : %.map $(MAPC_TARG)
336         $(MAPC) $< data
337
338 %.desktop : %.desktop.in
339         sh scripts/translate-desktop.sh < $< > $@
340
341 %.ico.o: dist/ico/%.ico
342         echo "1 ICON \"$<\"" | $(WINDRES) -o $@
343
344 #------------------------------------------------------------------------------
345
346 all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales desktops
347
348 $(BALL_TARG) : $(BALL_OBJS)
349         $(CC) $(ALL_CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LDFLAGS) $(ALL_LIBS)
350
351 $(PUTT_TARG) : $(PUTT_OBJS)
352         $(CC) $(ALL_CFLAGS) -o $(PUTT_TARG) $(PUTT_OBJS) $(LDFLAGS) $(ALL_LIBS)
353
354 $(MAPC_TARG) : $(MAPC_OBJS)
355         $(CC) $(ALL_CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(LDFLAGS) $(BASE_LIBS)
356
357 # Work around some extremely helpful sdl-config scripts.
358
359 ifeq ($(PLATFORM),mingw)
360 $(MAPC_TARG) : ALL_CPPFLAGS := $(ALL_CPPFLAGS) -Umain
361 endif
362
363 sols : $(SOLS)
364
365 locales :
366 ifneq ($(ENABLE_NLS),0)
367         $(MAKE) -C po
368 endif
369
370 desktops : $(DESKTOPS)
371
372 clean-src :
373         $(RM) $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS)
374         $(RM) $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS)
375         $(RM) $(MAPC_TARG) $(MAPC_OBJS) $(MAPC_DEPS)
376
377 clean : clean-src
378         $(RM) $(SOLS)
379         $(RM) $(DESKTOPS)
380         $(MAKE) -C po clean
381
382 test : all
383         ./neverball
384
385 TAGS :
386         $(RM) $@
387         find . -name '*.[ch]' | xargs etags -a
388
389 #------------------------------------------------------------------------------
390
391 .PHONY : all sols locales clean-src clean test TAGS
392
393 -include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS)
394
395 #------------------------------------------------------------------------------
396
397 ifeq ($(PLATFORM),mingw)
398
399 #------------------------------------------------------------------------------
400
401 INSTALLER := ../neverball-$(VERSION)-setup.exe
402
403 MAKENSIS := makensis
404 MAKENSIS_FLAGS := -DVERSION=$(VERSION) -DOUTFILE=$(INSTALLER)
405
406 TODOS   := todos
407 FROMDOS := fromdos
408
409 CP := cp
410
411 TEXT_DOCS := \
412         doc/AUTHORS \
413         doc/MANUAL  \
414         CHANGES     \
415         COPYING     \
416         README
417
418 TXT_DOCS := $(TEXT_DOCS:%=%.txt)
419
420 #------------------------------------------------------------------------------
421
422 .PHONY: setup
423 setup: $(INSTALLER)
424
425 $(INSTALLER): install-dlls convert-text-files all contrib
426         $(MAKENSIS) $(MAKENSIS_FLAGS) -nocd scripts/neverball.nsi
427
428 $(INSTALLER): LDFLAGS := -s $(LDFLAGS)
429
430 .PHONY: clean-setup
431 clean-setup: clean
432         $(RM) install-dlls.sh *.dll $(TXT_DOCS)
433         find data -name "*.txt" -exec $(FROMDOS) {} \;
434         $(MAKE) -C contrib EXT=$(EXT) clean
435
436 #------------------------------------------------------------------------------
437
438 .PHONY: install-dlls
439 install-dlls: install-dlls.sh
440         sh $<
441
442 install-dlls.sh: $(MAPC_TARG) $(BALL_TARG) $(PUTT_TARG)
443         mingw-list-dlls --format=shell $^ > $@
444
445 #------------------------------------------------------------------------------
446
447 .PHONY: convert-text-files
448 convert-text-files: $(TXT_DOCS)
449         find data -name "*.txt" -exec $(TODOS) {} \;
450
451 %.txt: %
452         $(CP) $< $@
453         $(TODOS) $@
454
455 #------------------------------------------------------------------------------
456
457 .PHONY: contrib
458 contrib:
459         $(MAKE) -C contrib EXT=$(EXT)
460
461 #------------------------------------------------------------------------------
462
463 endif
464
465 #------------------------------------------------------------------------------