Modified frogger to use new OBJ mover policy, and to take advantage of Krabby Krap...
[neverball] / Makefile
1 #-------------------------------------------------------------------------------
2
3 VERSION := $(shell sh scripts/version.sh)
4 ifeq ($(VERSION),unknown)
5     $(warning Failed to obtain sane version for this build.)
6 endif
7
8 #------------------------------------------------------------------------------
9
10 # Optional flags
11 #CFLAGS := -Wall -g -ansi -pedantic
12 CFLAGS := -Wall -O2 -ansi -pedantic
13
14 # Mandatory flags
15 SDL_CPPFLAGS := $(shell sdl-config --cflags)
16 PNG_CPPFLAGS := $(shell libpng-config --cflags)
17
18 ALL_CFLAGS   := $(CFLAGS)
19 ALL_CPPFLAGS := $(SDL_CPPFLAGS) $(PNG_CPPFLAGS) -Ishare \
20     -DVERSION=\"$(VERSION)\"
21
22 ifeq ($(ENABLE_NLS),0)
23     ALL_CPPFLAGS += -DENABLE_NLS=0
24 else
25     ALL_CPPFLAGS += -DENABLE_NLS=1
26 endif
27
28 ALL_CPPFLAGS += $(CPPFLAGS)
29
30 #------------------------------------------------------------------------------
31
32 SDL_LIBS := $(shell sdl-config --libs)
33 PNG_LIBS := $(shell libpng-config --libs)
34
35 ifdef MINGW
36 ifneq ($(ENABLE_NLS),0)
37     INTL_LIBS := -lintl -liconv
38 endif
39     OGL_LIBS  := -lopengl32 -lm
40     BASE_LIBS := -lSDL -lSDL_image $(INTL_LIBS)
41     ALL_LIBS  := $(SDL_LIBS) -lSDL_image $(INTL_LIBS) \
42         $(PNG_LIBS) -lSDL_ttf -lSDL_mixer $(OGL_LIBS)
43 else
44     OGL_LIBS  := -lGL -lm
45     BASE_LIBS := $(SDL_LIBS) -lSDL_image
46     ALL_LIBS  := $(BASE_LIBS) $(PNG_LIBS) -lSDL_ttf -lSDL_mixer $(OGL_LIBS)
47 endif
48
49 #------------------------------------------------------------------------------
50
51 ifdef MINGW
52     EXT  := .exe
53     WINE := wine
54 endif
55
56 #------------------------------------------------------------------------------
57
58 MAPC_TARG := mapc$(EXT)
59 BALL_TARG := neverball$(EXT)
60 PUTT_TARG := neverputt$(EXT)
61
62 #------------------------------------------------------------------------------
63
64 MAPC_OBJS := \
65         share/vec3.o        \
66         share/base_image.o  \
67         share/solid.o       \
68         share/binary.o      \
69         share/base_config.o \
70         share/mapc.o
71 BALL_OBJS := \
72         share/lang.o        \
73         share/st_resol.o    \
74         share/vec3.o        \
75         share/base_image.o  \
76         share/image.o       \
77         share/solid.o       \
78         share/solid_gl.o    \
79         share/part.o        \
80         share/back.o        \
81         share/geom.o        \
82         share/gui.o         \
83         share/base_config.o \
84         share/config.o      \
85         share/binary.o      \
86         share/state.o       \
87         share/audio.o       \
88         share/text.o        \
89         ball/hud.o          \
90         ball/mode.o         \
91         ball/game.o         \
92         ball/score.o        \
93         ball/level.o        \
94         ball/levels.o       \
95         ball/set.o          \
96         ball/demo.o         \
97         ball/util.o         \
98         ball/st_conf.o      \
99         ball/st_demo.o      \
100         ball/st_save.o      \
101         ball/st_goal.o      \
102         ball/st_fall_out.o  \
103         ball/st_time_out.o  \
104         ball/st_done.o      \
105         ball/st_level.o     \
106         ball/st_over.o      \
107         ball/st_play.o      \
108         ball/st_set.o       \
109         ball/st_start.o     \
110         ball/st_title.o     \
111         ball/st_help.o      \
112         ball/st_name.o      \
113         ball/st_shared.o    \
114         ball/st_pause.o     \
115         ball/main.o
116 PUTT_OBJS := \
117         share/lang.o        \
118         share/st_resol.o    \
119         share/vec3.o        \
120         share/base_image.o  \
121         share/image.o       \
122         share/solid.o       \
123         share/solid_gl.o    \
124         share/part.o        \
125         share/geom.o        \
126         share/back.o        \
127         share/base_config.o \
128         share/config.o      \
129         share/binary.o      \
130         share/audio.o       \
131         share/state.o       \
132         share/gui.o         \
133         share/text.o        \
134         putt/hud.o          \
135         putt/game.o         \
136         putt/hole.o         \
137         putt/course.o       \
138         putt/st_all.o       \
139         putt/st_conf.o      \
140         putt/main.o
141
142 BALL_DEPS := $(BALL_OBJS:.o=.d)
143 PUTT_DEPS := $(PUTT_OBJS:.o=.d)
144 MAPC_DEPS := $(MAPC_OBJS:.o=.d)
145
146 MAPS := $(shell find data -name "*.map" \! -name "*.autosave.map")
147 SOLS := $(MAPS:%.map=%.sol)
148
149 #------------------------------------------------------------------------------
150
151 %.o : %.c
152         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $<
153         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -o $@ -c $<
154
155 %.sol : %.map $(MAPC_TARG)
156         $(WINE) ./$(MAPC_TARG) $< data
157
158 #------------------------------------------------------------------------------
159
160 all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales
161
162 $(BALL_TARG) : $(BALL_OBJS)
163         $(CC) $(ALL_CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LDFLAGS) $(ALL_LIBS)
164
165 $(PUTT_TARG) : $(PUTT_OBJS)
166         $(CC) $(ALL_CFLAGS) -o $(PUTT_TARG) $(PUTT_OBJS) $(LDFLAGS) $(ALL_LIBS)
167
168 $(MAPC_TARG) : $(MAPC_OBJS)
169         $(CC) $(ALL_CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(LDFLAGS) $(BASE_LIBS)
170
171 sols : $(SOLS)
172
173 locales :
174 ifneq ($(ENABLE_NLS),0)
175         $(MAKE) -C po
176 endif
177
178 clean-src :
179         $(RM) $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS)
180         $(RM) $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS)
181         $(RM) $(MAPC_TARG) $(MAPC_OBJS) $(MAPC_DEPS)
182
183 clean : clean-src
184         $(RM) $(SOLS)
185         $(MAKE) -C po clean
186
187 test : all
188         ./neverball
189
190 #------------------------------------------------------------------------------
191
192 .PHONY : all sols locales clean-src clean test
193
194 -include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS)
195
196 #------------------------------------------------------------------------------
197
198 ifdef MINGW
199
200 #------------------------------------------------------------------------------
201
202 INSTALLER := ../neverball-$(VERSION)-setup.exe
203
204 MAKENSIS := makensis
205 MAKENSIS_FLAGS := -DVERSION=$(VERSION) -DOUTFILE=$(INSTALLER)
206
207 TODOS   := todos
208 FROMDOS := fromdos
209
210 CP := cp
211
212 TEXT_DOCS := \
213         doc/AUTHORS \
214         doc/MANUAL  \
215         CHANGES     \
216         COPYING     \
217         README
218
219 TXT_DOCS := $(TEXT_DOCS:%=%.txt)
220
221 #-----------------------------------------------------------------------------
222
223 .PHONY: setup
224 setup: $(INSTALLER)
225
226 $(INSTALLER): install-dlls convert-text-files all tools
227         $(MAKENSIS) $(MAKENSIS_FLAGS) -nocd scripts/neverball.nsi
228
229 $(INSTALLER): LDFLAGS := -s $(LDFLAGS)
230
231 .PHONY: clean-setup
232 clean-setup: clean
233         $(RM) install-dlls.sh *.dll $(TXT_DOCS)
234         find data -name "*.txt" -exec $(FROMDOS) {} \;
235         $(MAKE) -C tools EXT=$(EXT) clean
236
237 #-----------------------------------------------------------------------------
238
239 .PHONY: install-dlls
240 install-dlls: install-dlls.sh
241         sh $<
242
243 install-dlls.sh:
244         if ! sh scripts/gen-install-dlls.sh > $@; then \
245             $(RM) $@; \
246             exit 1; \
247         fi
248         @echo --------------------------------------------------------
249         @echo You can probably ignore any file-not-found errors above.
250         @echo Now edit $@ to your needs before restarting make.
251         @echo --------------------------------------------------------
252         @exit 1
253
254 #-----------------------------------------------------------------------------
255
256 .PHONY: convert-text-files
257 convert-text-files: $(TXT_DOCS)
258         find data -name "*.txt" -exec $(TODOS) {} \;
259
260 %.txt: %
261         $(CP) $< $@
262         $(TODOS) $@
263
264 #-----------------------------------------------------------------------------
265
266 .PHONY: tools
267 tools:
268         $(MAKE) -C tools EXT=$(EXT)
269
270 #------------------------------------------------------------------------------
271
272 endif
273
274 #------------------------------------------------------------------------------