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