SEVERAL LEVELS ARE TEMPORARILY BROKEN.
[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 MAPS := data/map-misc/test.map data/map-easy/bumper.map
148 SOLS := $(MAPS:%.map=%.sol)
149
150 #------------------------------------------------------------------------------
151
152 %.o : %.c
153         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -MM -MP -MF $*.d -MT "$@" $<
154         $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) -o $@ -c $<
155
156 %.sol : %.map $(MAPC_TARG)
157         $(WINE) ./$(MAPC_TARG) $< data
158
159 #------------------------------------------------------------------------------
160
161 all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales
162
163 $(BALL_TARG) : $(BALL_OBJS)
164         $(CC) $(ALL_CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LDFLAGS) $(ALL_LIBS)
165
166 $(PUTT_TARG) : $(PUTT_OBJS)
167         $(CC) $(ALL_CFLAGS) -o $(PUTT_TARG) $(PUTT_OBJS) $(LDFLAGS) $(ALL_LIBS)
168
169 $(MAPC_TARG) : $(MAPC_OBJS)
170         $(CC) $(ALL_CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(LDFLAGS) $(BASE_LIBS)
171
172 sols : $(SOLS)
173
174 locales :
175 ifneq ($(ENABLE_NLS),0)
176         $(MAKE) -C po
177 endif
178
179 clean-src :
180         $(RM) $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS)
181         $(RM) $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS)
182         $(RM) $(MAPC_TARG) $(MAPC_OBJS) $(MAPC_DEPS)
183
184 clean : clean-src
185         $(RM) $(SOLS)
186         $(MAKE) -C po clean
187
188 test : all
189         ./neverball
190
191 #------------------------------------------------------------------------------
192
193 .PHONY : all sols locales clean-src clean test
194
195 -include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS)
196
197 #------------------------------------------------------------------------------
198
199 ifdef MINGW
200
201 #------------------------------------------------------------------------------
202
203 INSTALLER := ../neverball-$(VERSION)-setup.exe
204
205 MAKENSIS := makensis
206 MAKENSIS_FLAGS := -DVERSION=$(VERSION) -DOUTFILE=$(INSTALLER)
207
208 TODOS   := todos
209 FROMDOS := fromdos
210
211 CP := cp
212
213 TEXT_DOCS := \
214         doc/AUTHORS \
215         doc/MANUAL  \
216         CHANGES     \
217         COPYING     \
218         README
219
220 TXT_DOCS := $(TEXT_DOCS:%=%.txt)
221
222 #-----------------------------------------------------------------------------
223
224 .PHONY: setup
225 setup: $(INSTALLER)
226
227 $(INSTALLER): install-dlls convert-text-files all tools
228         $(MAKENSIS) $(MAKENSIS_FLAGS) -nocd scripts/neverball.nsi
229
230 $(INSTALLER): LDFLAGS := -s $(LDFLAGS)
231
232 .PHONY: clean-setup
233 clean-setup: clean
234         $(RM) install-dlls.sh *.dll $(TXT_DOCS)
235         find data -name "*.txt" -exec $(FROMDOS) {} \;
236         $(MAKE) -C tools EXT=$(EXT) clean
237
238 #-----------------------------------------------------------------------------
239
240 .PHONY: install-dlls
241 install-dlls: install-dlls.sh
242         sh $<
243
244 install-dlls.sh:
245         if ! sh scripts/gen-install-dlls.sh > $@; then \
246             $(RM) $@; \
247             exit 1; \
248         fi
249         @echo --------------------------------------------------------
250         @echo You can probably ignore any file-not-found errors above.
251         @echo Now edit $@ to your needs before restarting make.
252         @echo --------------------------------------------------------
253         @exit 1
254
255 #-----------------------------------------------------------------------------
256
257 .PHONY: convert-text-files
258 convert-text-files: $(TXT_DOCS)
259         find data -name "*.txt" -exec $(TODOS) {} \;
260
261 %.txt: %
262         $(CP) $< $@
263         $(TODOS) $@
264
265 #-----------------------------------------------------------------------------
266
267 .PHONY: tools
268 tools:
269         $(MAKE) -C tools EXT=$(EXT)
270
271 #------------------------------------------------------------------------------
272
273 endif
274
275 #------------------------------------------------------------------------------