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