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