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