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