Revert "Tabbed in st_balt.o in Makefile"
[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 ($(ENABLE_WII),1)
19     # libwiimote is NOT ANSI compliant
20     CFLAGS := -O2
21 else
22     #CFLAGS := -Wall -g -ansi -pedantic
23     CFLAGS := -Wall -O2 -ansi -pedantic
24 endif
25
26 #------------------------------------------------------------------------------
27 # Mandatory flags
28
29 # Compiler...
30
31 ALL_CFLAGS := $(CFLAGS)
32
33 # Preprocessor...
34
35 SDL_CPPFLAGS := $(shell sdl-config --cflags)
36 PNG_CPPFLAGS := $(shell libpng-config --cflags)
37
38 ALL_CPPFLAGS := $(SDL_CPPFLAGS) $(PNG_CPPFLAGS) -Ishare \
39     -DVERSION=\"$(VERSION)\"
40
41 ifeq ($(ENABLE_NLS),0)
42     ALL_CPPFLAGS += -DENABLE_NLS=0
43 else
44     ALL_CPPFLAGS += -DENABLE_NLS=1
45 endif
46
47 ifeq ($(ENABLE_WII),1)
48     ALL_CPPFLAGS += -DENABLE_WII=1
49 endif
50
51 ifdef DARWIN
52     ALL_CPPFLAGS += -I/opt/local/include
53 endif
54
55 ALL_CPPFLAGS += $(CPPFLAGS)
56
57 #------------------------------------------------------------------------------
58 # Libraries
59
60 SDL_LIBS := $(shell sdl-config --libs)
61 PNG_LIBS := $(shell libpng-config --libs)
62
63 # The  non-conditionalised values  below  are specific  to the  native
64 # system. The native system of this Makefile is Linux (or GNU+Linux if
65 # you prefer). Please be sure to  override ALL of them for each target
66 # system in the conditional parts below.
67
68 INTL_LIBS :=
69
70 ifeq ($(ENABLE_WII),1)
71     TILT_LIBS := -lcwiimote -lbluetooth
72 endif
73
74 OGL_LIBS := -lGL -lm
75
76 ifdef MINGW
77     ifneq ($(ENABLE_NLS),0)
78         INTL_LIBS := -lintl -liconv
79     endif
80
81     TILT_LIBS :=
82     OGL_LIBS  := -lopengl32 -lm
83 endif
84
85 ifdef DARWIN
86     ifneq ($(ENABLE_NLS),0)
87         INTL_LIBS := -lintl -liconv
88     endif
89
90     TILT_LIBS :=
91     OGL_LIBS  := -framework OpenGL
92 endif
93
94 BASE_LIBS := -ljpeg $(PNG_LIBS)
95
96 ifdef DARWIN
97     BASE_LIBS += -L/opt/local/lib
98 endif
99
100 ALL_LIBS := $(SDL_LIBS) $(BASE_LIBS) $(TILT_LIBS) $(INTL_LIBS) -lSDL_ttf \
101     -lvorbisfile $(OGL_LIBS)
102
103 #------------------------------------------------------------------------------
104
105 ifdef MINGW
106     EXT := .exe
107 endif
108
109 MAPC_TARG := mapc$(EXT)
110 BALL_TARG := neverball$(EXT)
111 PUTT_TARG := neverputt$(EXT)
112
113 ifdef MINGW
114     MAPC := $(WINE) ./$(MAPC_TARG)
115 else
116     MAPC := ./$(MAPC_TARG)
117 endif
118
119
120 #------------------------------------------------------------------------------
121
122 MAPC_OBJS := \
123         share/vec3.o        \
124         share/base_image.o  \
125         share/solid.o       \
126         share/binary.o      \
127         share/base_config.o \
128         share/config.o      \
129         share/sync.o        \
130         share/mapc.o
131 BALL_OBJS := \
132         share/lang.o        \
133         share/st_resol.o    \
134         share/vec3.o        \
135         share/base_image.o  \
136         share/image.o       \
137         share/solid.o       \
138         share/solid_gl.o    \
139         share/part.o        \
140         share/back.o        \
141         share/geom.o        \
142         share/ball.o        \
143         share/gui.o         \
144         share/base_config.o \
145         share/config.o      \
146         share/binary.o      \
147         share/state.o       \
148         share/audio.o       \
149         share/text.o        \
150         share/sync.o        \
151         share/tilt.o        \
152         share/common.o      \
153         ball/hud.o          \
154         ball/game.o         \
155         ball/score.o        \
156         ball/level.o        \
157         ball/progress.o     \
158         ball/set.o          \
159         ball/demo.o         \
160         ball/util.o         \
161         ball/st_conf.o      \
162         ball/st_demo.o      \
163         ball/st_save.o      \
164         ball/st_goal.o      \
165         ball/st_fall_out.o  \
166         ball/st_time_out.o  \
167         ball/st_done.o      \
168         ball/st_level.o     \
169         ball/st_over.o      \
170         ball/st_play.o      \
171         ball/st_set.o       \
172         ball/st_start.o     \
173         ball/st_title.o     \
174         ball/st_help.o      \
175         ball/st_name.o      \
176         ball/st_shared.o    \
177         ball/st_pause.o     \
178         ball/main.o
179 PUTT_OBJS := \
180         share/lang.o        \
181         share/st_resol.o    \
182         share/vec3.o        \
183         share/base_image.o  \
184         share/image.o       \
185         share/solid.o       \
186         share/solid_gl.o    \
187         share/part.o        \
188         share/geom.o        \
189         share/ball.o        \
190         share/back.o        \
191         share/base_config.o \
192         share/config.o      \
193         share/binary.o      \
194         share/audio.o       \
195         share/state.o       \
196         share/gui.o         \
197         share/text.o        \
198         share/sync.o        \
199         putt/hud.o          \
200         putt/game.o         \
201         putt/hole.o         \
202         putt/course.o       \
203         putt/st_all.o       \
204     putt/st_balt.o      \
205         putt/st_conf.o      \
206         putt/main.o
207
208 BALL_DEPS := $(BALL_OBJS:.o=.d)
209 PUTT_DEPS := $(PUTT_OBJS:.o=.d)
210 MAPC_DEPS := $(MAPC_OBJS:.o=.d)
211
212 MAPS := $(shell find data -name "*.map" \! -name "*.autosave.map")
213 SOLS := $(MAPS:%.map=%.sol)
214
215 #------------------------------------------------------------------------------
216
217 %.o : %.c
218         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $<
219         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -o $@ -c $<
220
221 %.sol : %.map $(MAPC_TARG)
222         $(MAPC) $< data
223
224 #------------------------------------------------------------------------------
225
226 all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales
227
228 $(BALL_TARG) : $(BALL_OBJS)
229         $(CC) $(ALL_CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LDFLAGS) $(ALL_LIBS)
230
231 $(PUTT_TARG) : $(PUTT_OBJS)
232         $(CC) $(ALL_CFLAGS) -o $(PUTT_TARG) $(PUTT_OBJS) $(LDFLAGS) $(ALL_LIBS)
233
234 $(MAPC_TARG) : $(MAPC_OBJS)
235         $(CC) $(ALL_CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(LDFLAGS) $(ALL_LIBS)
236
237 # Work around some extremely helpful sdl-config scripts.
238
239 ifdef MINGW
240 $(MAPC_TARG) : ALL_CPPFLAGS := $(ALL_CPPFLAGS) -Umain
241 endif
242
243 sols : $(SOLS)
244
245 locales :
246 ifneq ($(ENABLE_NLS),0)
247         $(MAKE) -C po
248 endif
249
250 clean-src :
251         $(RM) $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS)
252         $(RM) $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS)
253         $(RM) $(MAPC_TARG) $(MAPC_OBJS) $(MAPC_DEPS)
254
255 clean : clean-src
256         $(RM) $(SOLS)
257         $(MAKE) -C po clean
258
259 test : all
260         ./neverball
261
262 #------------------------------------------------------------------------------
263
264 .PHONY : all sols locales clean-src clean test
265
266 -include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS)
267
268 #------------------------------------------------------------------------------
269
270 ifdef MINGW
271
272 #------------------------------------------------------------------------------
273
274 INSTALLER := ../neverball-$(VERSION)-setup.exe
275
276 MAKENSIS := makensis
277 MAKENSIS_FLAGS := -DVERSION=$(VERSION) -DOUTFILE=$(INSTALLER)
278
279 TODOS   := todos
280 FROMDOS := fromdos
281
282 CP := cp
283
284 TEXT_DOCS := \
285         doc/AUTHORS \
286         doc/MANUAL  \
287         CHANGES     \
288         COPYING     \
289         README
290
291 TXT_DOCS := $(TEXT_DOCS:%=%.txt)
292
293 #------------------------------------------------------------------------------
294
295 .PHONY: setup
296 setup: $(INSTALLER)
297
298 $(INSTALLER): install-dlls convert-text-files all tools
299         $(MAKENSIS) $(MAKENSIS_FLAGS) -nocd scripts/neverball.nsi
300
301 $(INSTALLER): LDFLAGS := -s $(LDFLAGS)
302
303 .PHONY: clean-setup
304 clean-setup: clean
305         $(RM) install-dlls.sh *.dll $(TXT_DOCS)
306         find data -name "*.txt" -exec $(FROMDOS) {} \;
307         $(MAKE) -C tools EXT=$(EXT) clean
308
309 #------------------------------------------------------------------------------
310
311 .PHONY: install-dlls
312 install-dlls: install-dlls.sh
313         sh $<
314
315 install-dlls.sh:
316         if ! sh scripts/gen-install-dlls.sh > $@; then \
317             $(RM) $@; \
318             exit 1; \
319         fi
320         @echo --------------------------------------------------------
321         @echo You can probably ignore any file-not-found errors above.
322         @echo Now edit $@ to your needs before restarting make.
323         @echo --------------------------------------------------------
324         @exit 1
325
326 #------------------------------------------------------------------------------
327
328 .PHONY: convert-text-files
329 convert-text-files: $(TXT_DOCS)
330         find data -name "*.txt" -exec $(TODOS) {} \;
331
332 %.txt: %
333         $(CP) $< $@
334         $(TODOS) $@
335
336 #------------------------------------------------------------------------------
337
338 .PHONY: tools
339 tools:
340         $(MAKE) -C tools EXT=$(EXT)
341
342 #------------------------------------------------------------------------------
343
344 endif
345
346 #------------------------------------------------------------------------------