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.rdy 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 := /boot/develop/headers 70LIB_INSTALL_PATH := /boot/develop/lib/x86 71BIN_INSTALL_PATH := /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 := $(PREFIX)/include 84LIB_INSTALL_PATH := $(PREFIX)/lib 85BIN_INSTALL_PATH := $(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 := -O2 219DBGFLAGS := -DDEBUGMODE=1 220else 221ifdef USE_SGICC 222WFLAGS := -fullwarn -DDUMB_DECLARE_DEPRECATED 223WFLAGS_ALLEGRO := 224OFLAGS := -n32 -O2 -use_readonly_const 225DBGFLAGS := -n32 -g3 -DDEBUGMODE=1 226else 227WFLAGS := -Wall -W -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -DDUMB_DECLARE_DEPRECATED 228WFLAGS_ALLEGRO := -Wno-missing-declarations 229OFLAGS := -O2 -ffast-math -fomit-frame-pointer 230DBGFLAGS := -DDEBUGMODE=1 -g3 231endif 232endif 233 234CFLAGS_RELEASE := -Iinclude $(WFLAGS) $(OFLAGS) 235CFLAGS_DEBUG := -Iinclude $(WFLAGS) $(DBGFLAGS) 236 237LDFLAGS := -s 238 239 240CORE_EXAMPLES_OBJ := $(addprefix examples/, $(notdir $(patsubst %.c, %.o, $(CORE_EXAMPLES)))) 241ALLEGRO_EXAMPLES_OBJ := $(addprefix examples/, $(notdir $(patsubst %.c, %.o, $(ALLEGRO_EXAMPLES)))) 242 243CORE_EXAMPLES_EXE := $(addprefix examples/, $(notdir $(patsubst %.c, %$(EXE_SUFFIX), $(CORE_EXAMPLES)))) 244ALLEGRO_EXAMPLES_EXE := $(addprefix examples/, $(notdir $(patsubst %.c, %$(EXE_SUFFIX), $(ALLEGRO_EXAMPLES)))) 245 246 247CORE_LIB_FILE_RELEASE := $(LIBDIR)/libdumb.a 248ALLEGRO_LIB_FILE_RELEASE := $(LIBDIR)/libaldmb.a 249 250CORE_LIB_FILE_DEBUG := $(LIBDIR)/libdumbd.a 251ALLEGRO_LIB_FILE_DEBUG := $(LIBDIR)/libaldmd.a 252 253 254core: $(CORE_LIB_FILE_RELEASE) $(CORE_LIB_FILE_DEBUG) 255allegro: $(ALLEGRO_LIB_FILE_RELEASE) $(ALLEGRO_LIB_FILE_DEBUG) 256 257core-examples: $(CORE_EXAMPLES_EXE) 258allegro-examples: $(ALLEGRO_EXAMPLES_EXE) 259 260core-headers: 261 262allegro-headers: 263 264install-core: core 265 $(call COPY,$(CORE_LIB_FILE_RELEASE),$(LIB_INSTALL_PATH)) 266 $(call COPY,$(CORE_LIB_FILE_DEBUG),$(LIB_INSTALL_PATH)) 267 268install-allegro: allegro 269 $(call COPY,$(ALLEGRO_LIB_FILE_RELEASE),$(LIB_INSTALL_PATH)) 270 $(call COPY,$(ALLEGRO_LIB_FILE_DEBUG),$(LIB_INSTALL_PATH)) 271 272ifeq "$(COMSPEC)" "" 273install-core-examples: core-examples 274 $(call COPY,$(CORE_EXAMPLES_EXE),$(BIN_INSTALL_PATH)) 275 276install-allegro-examples: allegro-examples 277 $(call COPY,$(ALLEGRO_EXAMPLES_EXE),$(BIN_INSTALL_PATH)) 278else 279# Don't install the examples on a Windows system. 280install-core-examples: 281install-allegro-examples: 282endif 283 284install-core-headers: 285 $(call COPY,$(CORE_HEADERS),$(INCLUDE_INSTALL_PATH)) 286 287install-allegro-headers: 288 $(call COPY,$(ALLEGRO_HEADERS),$(INCLUDE_INSTALL_PATH)) 289 290 291uninstall-core: 292 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(CORE_LIB_FILE_RELEASE))) 293 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(CORE_LIB_FILE_DEBUG))) 294 295uninstall-allegro: 296 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(ALLEGRO_LIB_FILE_RELEASE))) 297 $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(ALLEGRO_LIB_FILE_DEBUG))) 298 299ifeq "$(COMSPEC)" "" 300uninstall-core-examples: 301 $(call DELETE,$(patsubst %,$(BIN_INSTALL_PATH)/%,$(notdir $(CORE_EXAMPLES_EXE)))) 302 303uninstall-allegro-examples: 304 $(call DELETE,$(patsubst %,$(BIN_INSTALL_PATH)/%,$(notdir $(ALLEGRO_EXAMPLES_EXE)))) 305else 306# The examples wouldn't have been installed on a Windows system. 307uninstall-core-examples: 308uninstall-allegro-examples: 309endif 310 311uninstall-core-headers: 312 $(call DELETE,$(patsubst %,$(INCLUDE_INSTALL_PATH)/%,$(notdir $(CORE_HEADERS)))) 313 314uninstall-allegro-headers: 315 $(call DELETE,$(patsubst %,$(INCLUDE_INSTALL_PATH)/%,$(notdir $(ALLEGRO_HEADERS)))) 316 317 318OBJDIR := $(OBJDIR_BASE)/release 319CFLAGS := $(CFLAGS_RELEASE) 320CORE_LIB_FILE := $(LIBDIR)/libdumb.a 321ALLEGRO_LIB_FILE := $(LIBDIR)/libaldmb.a 322include make/Makefile.inc 323 324OBJDIR := $(OBJDIR_BASE)/debug 325CFLAGS := $(CFLAGS_DEBUG) 326CORE_LIB_FILE := $(LIBDIR)/libdumbd.a 327ALLEGRO_LIB_FILE := $(LIBDIR)/libaldmd.a 328include make/Makefile.inc 329 330 331$(CORE_EXAMPLES_EXE): examples/%$(EXE_SUFFIX): examples/%.o $(CORE_LIB_FILE_RELEASE) 332 $(CC) $^ -o $@ $(LDFLAGS) $(LINK_MATH) 333 334$(ALLEGRO_EXAMPLES_EXE): examples/%$(EXE_SUFFIX): examples/%.o $(ALLEGRO_LIB_FILE_RELEASE) $(CORE_LIB_FILE_RELEASE) 335 $(CC) $^ -o $@ $(LDFLAGS) $(LINK_ALLEGRO) 336 337$(CORE_EXAMPLES_OBJ): examples/%.o: examples/%.c include/dumb.h 338 $(CC) $(CFLAGS_RELEASE) -c $< -o $@ 339 340$(ALLEGRO_EXAMPLES_OBJ): examples/%.o: examples/%.c include/dumb.h include/aldumb.h 341 $(CC) $(CFLAGS_RELEASE) -Wno-missing-declarations -c $< -o $@ 342 343 344clean: 345 $(call DELETE,$(OBJDIR_BASE)/release/*.o) 346 $(call DELETE,$(OBJDIR_BASE)/debug/*.o) 347 $(call DELETE,examples/*.o) 348 349veryclean: clean 350 $(call DELETE,$(CORE_LIB_FILE)) 351 $(call DELETE,$(ALLEGRO_LIB_FILE)) 352 $(call DELETE,$(CORE_EXAMPLES_EXE)) 353 $(call DELETE,$(ALLEGRO_EXAMPLES_EXE)) 354 355distclean: veryclean 356 $(call DELETE,make/config.txt) 357 $(call DELETE,$(DUMBASK_EXE)) 358 359 360else 361 362make-outdirs: # don't make output before configuration 363 364endif # ifdef PLATFORM 365