1# 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# make distclean - Delete examples, libraries and configuration. 22# (Note that this is unable to delete the dumbask 23# executable if the configuration is absent.) 24 25MAKEFILE = Makefile 26 27.PHONY: all install uninstall clean veryclean distclean config config-if-necessary make-outdirs 28 29PHONY_TARGETS := core allegro core-examples allegro-examples core-headers allegro-headers 30 31.PHONY: $(PHONY_TARGETS) 32.PHONY: $(PHONY_TARGETS:%=install-%) 33.PHONY: $(PHONY_TARGETS:%=uninstall-%) 34 35 36COMMA := , 37 38ifdef USE_ICC 39CC ?= icc 40else 41ifdef USE_SGICC 42CC ?= cc 43else 44CC ?= gcc 45endif 46endif 47AR := ar 48 49 50# Configuration. 51# The configuration is done by an MS-DOS batch file if COMSPEC is set. 52# Otherwise it is done by a Unix shell script. A file called 'config.txt', 53# containing variables that control the build process, is created, and 54# included by this Makefile. 55 56 57ifeq "$(COMSPEC)" "" 58ifdef ComSpec 59COMSPEC := $(ComSpec) 60endif 61endif 62 63 64-include make/config.txt 65 66 67ifeq "$(OSTYPE)" "beos" 68 69INCLUDE_INSTALL_PATH := ${DESTDIR}/boot/develop/headers 70LIB_INSTALL_PATH := ${DESTDIR}/boot/develop/lib/x86 71BIN_INSTALL_PATH := ${DESTDIR}/boot/home/config/bin 72# DEFAULT_PREFIX is not set, so config.sh will not prompt for PREFIX. 73LINK_MATH := 74 75else 76 77ifdef PREFIX 78DEFAULT_PREFIX := $(PREFIX) 79else 80DEFAULT_PREFIX := /usr/local 81endif 82export DEFAULT_PREFIX 83INCLUDE_INSTALL_PATH := ${DESTDIR}$(PREFIX)/include 84LIB_INSTALL_PATH := ${DESTDIR}$(PREFIX)/lib 85BIN_INSTALL_PATH := ${DESTDIR}$(PREFIX)/bin 86 87endif 88 89 90all: config-if-necessary make-outdirs 91 @$(MAKE) -f $(MAKEFILE) --no-print-directory $(ALL_TARGETS) 92 $(call ECHO,DUMB has been built. Run $(APOST)make install$(APOST) to install it.) 93 94install: config-if-necessary 95 @$(MAKE) -f $(MAKEFILE) --no-print-directory $(ALL_TARGETS:%=install-%) 96 $(call ECHO,DUMB has been installed.) 97 $(call ECHO,See readme.txt for details on the example programs.) 98 $(call ECHO,When you$(APOST)re ready to start using DUMB$(COMMA) see docs/howto.txt.) 99 $(call ECHO,Enjoy!) 100 101uninstall: config-if-necessary 102 @$(MAKE) -f $(MAKEFILE) --no-print-directory $(ALL_TARGETS:%=uninstall-%) 103 $(call ECHO,DUMB has been uninstalled.) 104 105 106ifdef COMSPEC 107# Assume DOS or Windows. 108SHELL := $(COMSPEC) 109CONFIG_COMMAND := make\config.bat 110DUMBASK_EXE := make/dumbask.exe 111else 112# Assume a Unix-compatible system. 113CONFIG_COMMAND := make/config.sh 114DUMBASK_EXE := make/dumbask 115endif 116 117# This will always configure. 118config: $(DUMBASK_EXE) 119 $(CONFIG_COMMAND) 120 121# This will only configure if the configuration file is absent. We don't use 122# config.txt as the target name, because Make then runs the config initially, 123# and again when it sees the 'config' target, so an initial 'make config' 124# causes the configuration to be done twice. 125ifeq "$(wildcard make/config.txt)" "" 126config-if-necessary: config 127else 128config-if-necessary: 129endif 130 131$(DUMBASK_EXE): make/dumbask.c 132 $(CC) $< -o $@ 133 134 135ifdef PLATFORM 136 137 138# Build. 139 140 141CORE_MODULES := \ 142 core/atexit.c \ 143 core/duhlen.c \ 144 core/duhtag.c \ 145 core/dumbfile.c \ 146 core/loadduh.c \ 147 core/makeduh.c \ 148 core/rawsig.c \ 149 core/readduh.c \ 150 core/register.c \ 151 core/rendduh.c \ 152 core/rendsig.c \ 153 core/unload.c \ 154 helpers/clickrem.c \ 155 helpers/memfile.c \ 156 helpers/resample.c \ 157 helpers/sampbuf.c \ 158 helpers/silence.c \ 159 helpers/stdfile.c \ 160 it/itload.c \ 161 it/itread.c \ 162 it/itload2.c \ 163 it/itread2.c \ 164 it/itrender.c \ 165 it/itunload.c \ 166 it/loads3m.c \ 167 it/reads3m.c \ 168 it/loadxm.c \ 169 it/readxm.c \ 170 it/loadmod.c \ 171 it/readmod.c \ 172 it/loads3m2.c \ 173 it/reads3m2.c \ 174 it/loadxm2.c \ 175 it/readxm2.c \ 176 it/loadmod2.c \ 177 it/readmod2.c \ 178 it/xmeffect.c \ 179 it/itorder.c \ 180 it/itmisc.c 181 182ALLEGRO_MODULES := \ 183 allegro/alplay.c \ 184 allegro/datduh.c \ 185 allegro/datit.c \ 186 allegro/datxm.c \ 187 allegro/dats3m.c \ 188 allegro/datmod.c \ 189 allegro/datitq.c \ 190 allegro/datxmq.c \ 191 allegro/dats3mq.c \ 192 allegro/datmodq.c \ 193 allegro/datunld.c \ 194 allegro/packfile.c 195 196CORE_EXAMPLES := examples/dumbout.c examples/dumb2wav.c 197ALLEGRO_EXAMPLES := examples/dumbplay.c 198 199CORE_HEADERS := include/dumb.h 200ALLEGRO_HEADERS := include/aldumb.h 201 202 203LIBDIR := lib/$(PLATFORM) 204OBJDIR_BASE := obj/$(PLATFORM) 205 206make-outdirs: 207 -$(call MKDIR,lib) 208 -$(call MKDIR,lib/$(PLATFORM)) 209 -$(call MKDIR,obj) 210 -$(call MKDIR,obj/$(PLATFORM)) 211 -$(call MKDIR,obj/$(PLATFORM)/debug) 212 -$(call MKDIR,obj/$(PLATFORM)/release) 213 214 215ifdef USE_ICC 216WFLAGS := -Wall -DDUMB_DECLARE_DEPRECATED 217WFLAGS_ALLEGRO := 218OFLAGS=$(CFLAGS) 219else 220ifdef USE_SGICC 221WFLAGS := -fullwarn -DDUMB_DECLARE_DEPRECATED 222WFLAGS_ALLEGRO := 223OFLAGS=$(CFLAGS) 224else 225WFLAGS := -Wall -W -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -DDUMB_DECLARE_DEPRECATED 226WFLAGS_ALLEGRO := -Wno-missing-declarations 227OFLAGS=$(CFLAGS) 228endif 229endif 230 231CFLAGS_RELEASE := -Iinclude -I$(PREFIX)/include $(_PORT_ALLEGRO_CFLAGS) $(WFLAGS) $(OFLAGS) 232CFLAGS_DEBUG := -Iinclude -I$(PREFIX)/include $(_PORT_ALLEGRO_CFLAGS) $(WFLAGS) $(DBGFLAGS) 233 234LDFLAGS := -s 235 236 237CORE_EXAMPLES_OBJ := $(addprefix examples/, $(notdir $(patsubst %.c, %.o, $(CORE_EXAMPLES)))) 238ALLEGRO_EXAMPLES_OBJ := $(addprefix examples/, $(notdir $(patsubst %.c, %.o, $(ALLEGRO_EXAMPLES)))) 239 240CORE_EXAMPLES_EXE := $(addprefix examples/, $(notdir $(patsubst %.c, %$(EXE_SUFFIX), $(CORE_EXAMPLES)))) 241ALLEGRO_EXAMPLES_EXE := $(addprefix examples/, $(notdir $(patsubst %.c, %$(EXE_SUFFIX), $(ALLEGRO_EXAMPLES)))) 242 243 244CORE_LIB_FILE_RELEASE := $(LIBDIR)/libdumb.a 245ALLEGRO_LIB_FILE_RELEASE := $(LIBDIR)/libaldmb.a 246 247CORE_LIB_FILE_DEBUG := $(LIBDIR)/libdumbd.a 248ALLEGRO_LIB_FILE_DEBUG := $(LIBDIR)/libaldmd.a 249 250 251core: $(CORE_LIB_FILE_RELEASE) 252allegro: $(ALLEGRO_LIB_FILE_RELEASE) 253 254core-examples: $(CORE_EXAMPLES_EXE) 255allegro-examples: $(ALLEGRO_EXAMPLES_EXE) 256 257core-headers: 258 259allegro-headers: 260 261install-core: core 262 $(call COPY,$(CORE_LIB_FILE_RELEASE),$(LIB_INSTALL_PATH)) 263 264install-allegro: allegro 265 $(call COPY,$(ALLEGRO_LIB_FILE_RELEASE),$(LIB_INSTALL_PATH)) 266 267ifeq "$(COMSPEC)" "" 268install-core-examples: core-examples 269 $(call COPY,$(CORE_EXAMPLES_EXE),$(BIN_INSTALL_PATH)) 270 271install-allegro-examples: allegro-examples 272 $(call COPY,$(ALLEGRO_EXAMPLES_EXE),$(BIN_INSTALL_PATH)) 273else 274# Don't install the examples on a Windows system. 275install-core-examples: 276install-allegro-examples: 277endif 278 279install-core-headers: 280 $(call COPY,$(CORE_HEADERS),$(INCLUDE_INSTALL_PATH)) 281 282install-allegro-headers: 283 $(call COPY,$(ALLEGRO_HEADERS),$(INCLUDE_INSTALL_PATH)) 284 285 286uninstall-core: 287 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(CORE_LIB_FILE_RELEASE))) 288 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(CORE_LIB_FILE_DEBUG))) 289 290uninstall-allegro: 291 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(ALLEGRO_LIB_FILE_RELEASE))) 292 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(ALLEGRO_LIB_FILE_DEBUG))) 293 294ifeq "$(COMSPEC)" "" 295uninstall-core-examples: 296 $(call DELETE,$(patsubst %,$(BIN_INSTALL_PATH)/%,$(notdir $(CORE_EXAMPLES_EXE)))) 297 298uninstall-allegro-examples: 299 $(call DELETE,$(patsubst %,$(BIN_INSTALL_PATH)/%,$(notdir $(ALLEGRO_EXAMPLES_EXE)))) 300else 301# The examples wouldn't have been installed on a Windows system. 302uninstall-core-examples: 303uninstall-allegro-examples: 304endif 305 306uninstall-core-headers: 307 $(call DELETE,$(patsubst %,$(INCLUDE_INSTALL_PATH)/%,$(notdir $(CORE_HEADERS)))) 308 309uninstall-allegro-headers: 310 $(call DELETE,$(patsubst %,$(INCLUDE_INSTALL_PATH)/%,$(notdir $(ALLEGRO_HEADERS)))) 311 312 313OBJDIR := $(OBJDIR_BASE)/release 314CFLAGS := $(CFLAGS_RELEASE) 315CORE_LIB_FILE := $(LIBDIR)/libdumb.a 316ALLEGRO_LIB_FILE := $(LIBDIR)/libaldmb.a 317include make/Makefile.inc 318 319 320$(CORE_EXAMPLES_EXE): examples/%$(EXE_SUFFIX): examples/%.o $(CORE_LIB_FILE_RELEASE) 321 $(CC) $^ -o $@ $(LDFLAGS) $(LINK_MATH) 322 323$(ALLEGRO_EXAMPLES_EXE): examples/%$(EXE_SUFFIX): examples/%.o $(ALLEGRO_LIB_FILE_RELEASE) $(CORE_LIB_FILE_RELEASE) 324 $(CC) $^ -o $@ $(LDFLAGS) $(LINK_ALLEGRO) 325 326$(CORE_EXAMPLES_OBJ): examples/%.o: examples/%.c include/dumb.h 327 $(CC) $(CFLAGS_RELEASE) -c $< -o $@ 328 329$(ALLEGRO_EXAMPLES_OBJ): examples/%.o: examples/%.c include/dumb.h include/aldumb.h 330 $(CC) $(CFLAGS_RELEASE) -Wno-missing-declarations -c $< -o $@ 331 332 333clean: 334 $(call DELETE,$(OBJDIR_BASE)/release/*.o) 335 $(call DELETE,$(OBJDIR_BASE)/debug/*.o) 336 $(call DELETE,examples/*.o) 337 338veryclean: clean 339 $(call DELETE,$(CORE_LIB_FILE)) 340 $(call DELETE,$(ALLEGRO_LIB_FILE)) 341 $(call DELETE,$(CORE_EXAMPLES_EXE)) 342 $(call DELETE,$(ALLEGRO_EXAMPLES_EXE)) 343 344distclean: veryclean 345 $(call DELETE,make/config.txt) 346 $(call DELETE,$(DUMBASK_EXE)) 347 348 349else 350 351make-outdirs: # don't make output before configuration 352 353endif # ifdef PLATFORM 354