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