d7e0163005af0792c8d43fd9010df4cc98f3855c
[neverball] / Makefile
1
2 #------------------------------------------------------------------------------
3
4 # Maybe you need one of these.  Maybe you don't.
5
6 #X11_PATH= -L/usr/X11/lib
7 #X11_PATH= -L/usr/X11R6/lib
8
9 OGL_LIBS= -lGL -lm
10 #OGL_LIBS= -lm                                                # Think Different
11
12 #------------------------------------------------------------------------------
13 # Configuration constants
14 #------------------------------------------------------------------------------
15
16 CFLAGS= -Wall -g -O3 -ansi -pedantic $(shell sdl-config --cflags)
17 #CFLAGS= -Wall -g -O1 -ansi -pedantic $(shell sdl-config --cflags)
18 #CFLAGS= -Wall -pg -ansi $(shell sdl-config --cflags)
19
20 CPPFLAGS := -Ishare $(CPPFLAGS)
21
22 SDL_LIBS= $(shell sdl-config --libs)
23 PNG_LIBS= $(shell libpng-config --libs)
24
25 MAPC_TARG= mapc
26 BALL_TARG= neverball
27 PUTT_TARG= neverputt
28
29 MAPC_EXEC= ./$(MAPC_TARG)
30
31 LOCALEDIR= locale
32 LOCALEDOM= neverball
33
34 POTFILE= po/neverball.pot
35
36 #-------------------------------------------------------------------------------
37
38 MAPC_OBJS= \
39         share/vec3.o   \
40         share/base_image.o  \
41         share/solid.o  \
42         share/binary.o \
43         share/base_config.o \
44         share/mapc.o
45 BALL_OBJS= \
46         share/i18n.o    \
47         share/st_lang.o \
48         share/st_resol.o \
49         share/vec3.o    \
50         share/base_image.o   \
51         share/image.o   \
52         share/solid.o   \
53         share/solid_gl.o\
54         share/part.o    \
55         share/back.o    \
56         share/geom.o    \
57         share/gui.o     \
58         share/base_config.o  \
59         share/config.o  \
60         share/binary.o  \
61         share/state.o   \
62         share/audio.o   \
63         ball/hud.o      \
64         ball/game.o     \
65         ball/level.o    \
66         ball/levels.o   \
67         ball/set.o      \
68         ball/demo.o     \
69         ball/util.o     \
70         ball/st_conf.o  \
71         ball/st_demo.o  \
72         ball/st_save.o  \
73         ball/st_play_end.o  \
74         ball/st_done.o  \
75         ball/st_level.o \
76         ball/st_over.o  \
77         ball/st_play.o  \
78         ball/st_set.o   \
79         ball/st_start.o \
80         ball/st_title.o \
81         ball/st_help.o  \
82         ball/st_name.o  \
83         ball/st_shared.o  \
84         ball/main.o
85 PUTT_OBJS= \
86         share/i18n.o    \
87         share/st_lang.o \
88         share/st_resol.o \
89         share/vec3.o   \
90         share/base_image.o  \
91         share/image.o  \
92         share/solid.o  \
93         share/solid_gl.o  \
94         share/part.o   \
95         share/geom.o   \
96         share/back.o   \
97         share/base_config.o  \
98         share/config.o \
99         share/binary.o \
100         share/audio.o  \
101         share/state.o  \
102         share/gui.o    \
103         putt/hud.o     \
104         putt/game.o    \
105         putt/hole.o    \
106         putt/course.o  \
107         putt/st_all.o  \
108         putt/st_conf.o \
109         putt/main.o
110
111 BALL_DEPS= $(BALL_OBJS:.o=.d)
112 PUTT_DEPS= $(PUTT_OBJS:.o=.d)
113 MAPC_DEPS= $(MAPC_OBJS:.o=.d)
114
115 BASE_LIBS= $(SDL_LIBS) -lSDL_image
116 LIBS= $(X11_PATH) $(BASE_LIBS) $(PNG_LIBS) -lSDL_ttf -lSDL_mixer $(OGL_LIBS)
117
118 MESSAGEPART= /LC_MESSAGES/$(LOCALEDOM).mo
119 MESSAGES= $(LINGUAS:%=$(LOCALEDIR)/%$(MESSAGEPART))
120
121 MAPS= $(shell find data/ -name '*.map')
122 SOLS= $(MAPS:%.map=%.sol)
123
124 POS= $(shell echo po/*.po)
125 LINGUAS= $(POS:po/%.po=%)
126
127 #------------------------------------------------------------------------------
128 # Implicit rules
129 #------------------------------------------------------------------------------
130
131 %.d : %.c
132         $(CC) $(CFLAGS) $(CPPFLAGS) -MM -MF $@ -MT '$*.o $@' $<
133
134 %.o : %.c
135         $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
136
137 %.sol : %.map $(MAPC_TARG)
138         $(MAPC_EXEC) $< data
139
140 $(LOCALEDIR)/%$(MESSAGEPART) : po/%.po
141         mkdir -p `dirname $@`
142         msgfmt -c -v -o $@ $<
143
144 #------------------------------------------------------------------------------
145 # Main rules
146 #------------------------------------------------------------------------------
147
148 all : $(BALL_TARG) $(PUTT_TARG) $(MAPC_TARG) sols locales
149
150 $(BALL_TARG) : $(BALL_OBJS)
151         $(CC) $(CFLAGS) -o $(BALL_TARG) $(BALL_OBJS) $(LIBS)
152
153 $(PUTT_TARG) : $(PUTT_OBJS)
154         $(CC) $(CFLAGS) -o $(PUTT_TARG) $(PUTT_OBJS) $(LIBS)
155
156 $(MAPC_TARG) : $(MAPC_OBJS)
157         $(CC) $(CFLAGS) -o $(MAPC_TARG) $(MAPC_OBJS) $(BASE_LIBS)
158
159 sols : $(SOLS)
160
161 locales : $(MESSAGES)
162
163 clean-src :
164         rm -f $(BALL_TARG) $(BALL_OBJS) $(BALL_DEPS)
165         rm -f $(PUTT_TARG) $(PUTT_OBJS) $(PUTT_DEPS)
166         rm -f $(MAPC_TARG) $(MAPC_OBJS) $(MAPC_DEPS)
167
168 clean : clean-src
169         rm -f $(SOLS)
170         rm -rf $(LOCALEDIR)
171
172 test : all
173         ./neverball
174
175 tools :
176         cd tools && $(MAKE)
177
178 #------------------------------------------------------------------------------
179 # PO update rules
180 #------------------------------------------------------------------------------
181
182 po/%.po : $(POTFILE)
183         msgmerge -U $@ $<
184         touch $@
185         
186 po-update-extract :
187         sh extractpo.sh $(POTFILE) $(LOCALEDOM)
188
189 po-update-merge : $(POS)
190
191 po-update : po-update-extract po-update-merge
192
193 #------------------------------------------------------------------------------
194
195 .PHONY : all sols locales clean-src clean test \
196         po-update-extract po-update-merge po-update \
197         tools
198
199 -include $(BALL_DEPS) $(PUTT_DEPS) $(MAPC_DEPS)