blob: 823c1628c34c7737abe171fc74aca4bbc23e2391 [file] [log] [blame]
Michiel Van Der Kolk27be5bc2005-03-17 20:50:03 +00001# Main Makefile for DUMB.
2
3# In theory, this Makefile can be used without modifications on DOS, Windows,
4# Linux, BeOS and Mac OS X. Caveats are as follows:
5
6# - For DOS and Windows users, COMSPEC (or ComSpec) must be set to point to
7# command.com or cmd.exe. If they point to a Unix-style shell, this
8# Makefile will die horribly.
9
10# - Users of other platforms must NOT set COMSPEC or ComSpec. They must be
11# undefined.
12
13# Commands are as follows:
14
15# make - Build the library (does make config for you first time).
16# make install - Install the library and examples into the system.
17# make uninstall - Remove the above.
18# make config - Do or redo the configuration.
19# make clean - Delete all object files; examples and libraries remain.
20# make veryclean - Delete examples and libraries too.
21
22# TODO: consider whether to delete config.txt and/or dumbask(.exe)
23
24
25.PHONY: all install uninstall clean veryclean config config-if-necessary
26
27PHONY_TARGETS := core allegro core-examples allegro-examples core-headers allegro-headers
28
29.PHONY: $(PHONY_TARGETS)
30.PHONY: $(PHONY_TARGETS:%=install-%)
31.PHONY: $(PHONY_TARGETS:%=uninstall-%)
32
33
34COMMA := ,
35
36#CC := gcc
37#AR := ar
38
39
40# Configuration.
41# The configuration is done by an MS-DOS batch file if COMSPEC is set.
42# Otherwise it is done by a Unix shell script. A file called 'config.txt',
43# containing variables that control the build process, is created, and
44# included by this Makefile.
45
46
47ifeq "$(COMSPEC)" ""
48ifdef ComSpec
49COMSPEC := $(ComSpec)
50endif
51endif
52
53
54-include make/config.txt
55
56
57ifeq "$(OSTYPE)" "beos"
58
59INCLUDE_INSTALL_PATH := /boot/develop/headers
60LIB_INSTALL_PATH := /boot/develop/lib/x86
61BIN_INSTALL_PATH := /boot/home/config/bin
62# DEFAULT_PREFIX is not set, so config.sh will not prompt for PREFIX.
63LINK_MATH :=
64
65else
66
67ifdef PREFIX
68DEFAULT_PREFIX := $(PREFIX)
69else
70DEFAULT_PREFIX := /usr/local
71endif
72export DEFAULT_PREFIX
73INCLUDE_INSTALL_PATH := $(PREFIX)/include
74LIB_INSTALL_PATH := $(PREFIX)/lib
75BIN_INSTALL_PATH := $(PREFIX)/bin
76
77endif
78
79
80all: config-if-necessary
81 @$(MAKE) --no-print-directory $(ALL_TARGETS)
82 $(call ECHO,DUMB has been built. Run $(APOST)make install$(APOST) to install it.)
83
84install: config-if-necessary
85 @$(MAKE) --no-print-directory $(ALL_TARGETS:%=install-%)
86 $(call ECHO,DUMB has been installed.)
87 $(call ECHO,See readme.txt for details on the example programs.)
88 $(call ECHO,When you$(APOST)re ready to start using DUMB$(COMMA) see docs/howto.txt.)
89 $(call ECHO,Enjoy!)
90
91uninstall: config-if-necessary
92 @$(MAKE) --no-print-directory $(ALL_TARGETS:%=uninstall-%)
93 $(call ECHO,DUMB has been uninstalled.)
94
95
Michiel Van Der Kolk27be5bc2005-03-17 20:50:03 +000096# Assume a Unix-compatible system.
97CONFIG_COMMAND := make/config.sh
98DUMBASK_EXE := make/dumbask
Michiel Van Der Kolk27be5bc2005-03-17 20:50:03 +000099
100# This will always configure.
101config: $(DUMBASK_EXE)
102 $(CONFIG_COMMAND)
103
104# This will only configure if the configuration file is absent. We don't use
105# config.txt as the target name, because Make then runs the config initially,
106# and again when it sees the 'config' target, so an initial 'make config'
107# causes the configuration to be done twice.
108ifeq "$(wildcard make/config.txt)" ""
109config-if-necessary: config
110else
111config-if-necessary:
112endif
113
114$(DUMBASK_EXE): make/dumbask.c
115 $(CC) $< -o $@
116
117
118ifdef PLATFORM
119
120
121# Build.
122
123
124CORE_MODULES := \
125 core/atexit.c \
126 core/duhlen.c \
127 core/dumbfile.c \
128 core/loadduh.c \
129 core/makeduh.c \
130 core/rawsig.c \
131 core/readduh.c \
132 core/register.c \
133 core/rendduh.c \
134 core/rendsig.c \
135 core/unload.c \
136 helpers/clickrem.c \
137 helpers/memfile.c \
138 helpers/resample.c \
139 helpers/sampbuf.c \
140 helpers/silence.c \
141 it/itload.c \
142 it/itread.c \
143 it/itrender.c \
144 it/itunload.c \
145 it/loads3m.c \
146 it/reads3m.c \
147 it/loadxm.c \
148 it/readxm.c \
149 it/loadmod.c \
150 it/readmod.c \
151 it/xmeffect.c \
152 it/itorder.c \
153 it/itmisc.c
154# helpers/stdfile.c
Linus Nielsen Feltzing8970ea52005-03-18 08:37:28 +0000155
Michiel Van Der Kolk27be5bc2005-03-17 20:50:03 +0000156ALLEGRO_MODULES := \
157 allegro/alplay.c \
158 allegro/datduh.c \
159 allegro/datit.c \
160 allegro/datxm.c \
161 allegro/dats3m.c \
162 allegro/datmod.c \
163 allegro/datunld.c \
164 allegro/packfile.c
165
166CORE_EXAMPLES := examples/dumbout.c
167ALLEGRO_EXAMPLES := examples/dumbplay.c
168
169CORE_HEADERS := include/dumb.h
170ALLEGRO_HEADERS := include/aldumb.h
171
172
173LIBDIR := lib/$(PLATFORM)
174OBJDIR_BASE := obj/$(PLATFORM)
175
176
177WFLAGS := -Wall -W -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -DDUMB_DECLARE_DEPRECATED
178WFLAGS_ALLEGRO := -Wno-missing-declarations
179OFLAGS := -O2 -ffast-math -fomit-frame-pointer
180DBGFLAGS := -DDEBUGMODE=1 -g3
181
182CFLAGS_RELEASE := -Iinclude $(WFLAGS) $(OFLAGS)
183CFLAGS_DEBUG := -Iinclude $(WFLAGS) $(DBGFLAGS)
184
185LDFLAGS := -s
186
187
188CORE_EXAMPLES_OBJ := $(addprefix examples/, $(notdir $(patsubst %.c, %.o, $(CORE_EXAMPLES))))
189ALLEGRO_EXAMPLES_OBJ := $(addprefix examples/, $(notdir $(patsubst %.c, %.o, $(ALLEGRO_EXAMPLES))))
190
191CORE_EXAMPLES_EXE := $(addprefix examples/, $(notdir $(patsubst %.c, %$(EXE_SUFFIX), $(CORE_EXAMPLES))))
192ALLEGRO_EXAMPLES_EXE := $(addprefix examples/, $(notdir $(patsubst %.c, %$(EXE_SUFFIX), $(ALLEGRO_EXAMPLES))))
193
194
195CORE_LIB_FILE_RELEASE := $(LIBDIR)/libdumb.a
196ALLEGRO_LIB_FILE_RELEASE := $(LIBDIR)/libaldmb.a
197
198CORE_LIB_FILE_DEBUG := $(LIBDIR)/libdumbd.a
199ALLEGRO_LIB_FILE_DEBUG := $(LIBDIR)/libaldmd.a
200
201
202core: $(CORE_LIB_FILE_RELEASE) $(CORE_LIB_FILE_DEBUG)
203allegro: $(ALLEGRO_LIB_FILE_RELEASE) $(ALLEGRO_LIB_FILE_DEBUG)
204
205core-examples: $(CORE_EXAMPLES_EXE)
206allegro-examples: $(ALLEGRO_EXAMPLES_EXE)
207
208core-headers:
209
210allegro-headers:
211
212install-core: core
213 $(call COPY,$(CORE_LIB_FILE_RELEASE),$(LIB_INSTALL_PATH))
214 $(call COPY,$(CORE_LIB_FILE_DEBUG),$(LIB_INSTALL_PATH))
215
216install-allegro: allegro
217 $(call COPY,$(ALLEGRO_LIB_FILE_RELEASE),$(LIB_INSTALL_PATH))
218 $(call COPY,$(ALLEGRO_LIB_FILE_DEBUG),$(LIB_INSTALL_PATH))
219
220ifeq "$(COMSPEC)" ""
221install-core-examples: core-examples
222 $(call COPY,$(CORE_EXAMPLES_EXE),$(BIN_INSTALL_PATH))
223
224install-allegro-examples: allegro-examples
225 $(call COPY,$(ALLEGRO_EXAMPLES_EXE),$(BIN_INSTALL_PATH))
226else
227# Don't install the examples on a Windows system.
228install-core-examples:
229install-allegro-examples:
230endif
231
232install-core-headers:
233 $(call COPY,$(CORE_HEADERS),$(INCLUDE_INSTALL_PATH))
234
235install-allegro-headers:
236 $(call COPY,$(ALLEGRO_HEADERS),$(INCLUDE_INSTALL_PATH))
237
238
239uninstall-core:
240 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(CORE_LIB_FILE_RELEASE)))
241 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(CORE_LIB_FILE_DEBUG)))
242
243uninstall-allegro:
244 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(ALLEGRO_LIB_FILE_RELEASE)))
245 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(ALLEGRO_LIB_FILE_DEBUG)))
246
247ifeq "$COMSPEC" ""
248uninstall-core-examples:
249 $(call DELETE,$(patsubst %,$(BIN_INSTALL_PATH)/%,$(notdir $(CORE_EXAMPLES_EXE))))
250
251uninstall-allegro-examples:
252 $(call DELETE,$(patsubst %,$(BIN_INSTALL_PATH)/%,$(notdir $(ALLEGRO_EXAMPLES_EXE))))
253else
254# The examples wouldn't have been installed on a Windows system.
255uninstall-core-examples:
256uninstall-allegro-examples:
257endif
258
259uninstall-core-headers:
260 $(call DELETE,$(patsubst %,$(INCLUDE_INSTALL_PATH)/%,$(notdir $(CORE_HEADERS))))
261
262uninstall-allegro-headers:
263 $(call DELETE,$(patsubst %,$(INCLUDE_INSTALL_PATH)/%,$(notdir $(ALLEGRO_HEADERS))))
264
265
266OBJDIR := $(OBJDIR_BASE)/release
267CFLAGS := $(CFLAGS_RELEASE)
268CORE_LIB_FILE := $(LIBDIR)/libdumb.a
269ALLEGRO_LIB_FILE := $(LIBDIR)/libaldmb.a
270include make/Makefile.inc
271
272OBJDIR := $(OBJDIR_BASE)/debug
273CFLAGS := $(CFLAGS_DEBUG)
274CORE_LIB_FILE := $(LIBDIR)/libdumbd.a
275ALLEGRO_LIB_FILE := $(LIBDIR)/libaldmd.a
276include make/Makefile.inc
277
278
279$(CORE_EXAMPLES_EXE): examples/%$(EXE_SUFFIX): examples/%.o $(CORE_LIB_FILE_RELEASE)
Daniel Stenberg2505e7b2005-05-07 22:09:19 +0000280 @echo "(dumb) compiling $^"
281 @$(CC) $^ -o $@ $(LDFLAGS) $(LINK_MATH)
Michiel Van Der Kolk27be5bc2005-03-17 20:50:03 +0000282
283$(ALLEGRO_EXAMPLES_EXE): examples/%$(EXE_SUFFIX): examples/%.o $(ALLEGRO_LIB_FILE_RELEASE) $(CORE_LIB_FILE_RELEASE)
Daniel Stenberg2505e7b2005-05-07 22:09:19 +0000284 @echo "(dumb) compiling $^"
285 @$(CC) $^ -o $@ $(LDFLAGS) $(LINK_ALLEGRO)
Michiel Van Der Kolk27be5bc2005-03-17 20:50:03 +0000286
287$(CORE_EXAMPLES_OBJ): examples/%.o: examples/%.c include/dumb.h
Daniel Stenberg2505e7b2005-05-07 22:09:19 +0000288 @echo "(dumb) compiling $^"
289 @$(CC) -c $< -o $@ $(CFLAGS_RELEASE)
Michiel Van Der Kolk27be5bc2005-03-17 20:50:03 +0000290
291$(ALLEGRO_EXAMPLES_OBJ): examples/%.o: examples/%.c include/dumb.h include/aldumb.h
Daniel Stenberg2505e7b2005-05-07 22:09:19 +0000292 @echo "(dumb) compiling $^"
293 @$(CC) -c $< -o $@ $(CFLAGS_RELEASE) -Wno-missing-declarations
Michiel Van Der Kolk27be5bc2005-03-17 20:50:03 +0000294
295clean:
296 $(call DELETE,$(call FIX,$(OBJDIR_BASE)/release/*.o))
297 $(call DELETE,$(call FIX,$(OBJDIR_BASE)/debug/*.o))
298 $(call DELETE,$(call FIX,examples/*.o))
299
300veryclean: clean
301 $(call DELETE,$(call FIX,$(CORE_LIB_FILE)))
302 $(call DELETE,$(call FIX,$(ALLEGRO_LIB_FILE)))
303 $(call DELETE,$(call FIX,$(CORE_EXAMPLES_EXE)))
304 $(call DELETE,$(call FIX,$(ALLEGRO_EXAMPLES_EXE)))
305
306
307endif # ifdef PLATFORM