Michiel Van Der Kolk | 27be5bc | 2005-03-17 20:50:03 +0000 | [diff] [blame] | 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 | |
| 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 | |
| 27 | PHONY_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 | |
| 34 | COMMA := , |
| 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 | |
| 47 | ifeq "$(COMSPEC)" "" |
| 48 | ifdef ComSpec |
| 49 | COMSPEC := $(ComSpec) |
| 50 | endif |
| 51 | endif |
| 52 | |
| 53 | |
| 54 | -include make/config.txt |
| 55 | |
| 56 | |
| 57 | ifeq "$(OSTYPE)" "beos" |
| 58 | |
| 59 | INCLUDE_INSTALL_PATH := /boot/develop/headers |
| 60 | LIB_INSTALL_PATH := /boot/develop/lib/x86 |
| 61 | BIN_INSTALL_PATH := /boot/home/config/bin |
| 62 | # DEFAULT_PREFIX is not set, so config.sh will not prompt for PREFIX. |
| 63 | LINK_MATH := |
| 64 | |
| 65 | else |
| 66 | |
| 67 | ifdef PREFIX |
| 68 | DEFAULT_PREFIX := $(PREFIX) |
| 69 | else |
| 70 | DEFAULT_PREFIX := /usr/local |
| 71 | endif |
| 72 | export DEFAULT_PREFIX |
| 73 | INCLUDE_INSTALL_PATH := $(PREFIX)/include |
| 74 | LIB_INSTALL_PATH := $(PREFIX)/lib |
| 75 | BIN_INSTALL_PATH := $(PREFIX)/bin |
| 76 | |
| 77 | endif |
| 78 | |
| 79 | |
| 80 | all: 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 | |
| 84 | install: 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 | |
| 91 | uninstall: config-if-necessary |
| 92 | @$(MAKE) --no-print-directory $(ALL_TARGETS:%=uninstall-%) |
| 93 | $(call ECHO,DUMB has been uninstalled.) |
| 94 | |
| 95 | |
Michiel Van Der Kolk | 27be5bc | 2005-03-17 20:50:03 +0000 | [diff] [blame] | 96 | # Assume a Unix-compatible system. |
| 97 | CONFIG_COMMAND := make/config.sh |
| 98 | DUMBASK_EXE := make/dumbask |
Michiel Van Der Kolk | 27be5bc | 2005-03-17 20:50:03 +0000 | [diff] [blame] | 99 | |
| 100 | # This will always configure. |
| 101 | config: $(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. |
| 108 | ifeq "$(wildcard make/config.txt)" "" |
| 109 | config-if-necessary: config |
| 110 | else |
| 111 | config-if-necessary: |
| 112 | endif |
| 113 | |
| 114 | $(DUMBASK_EXE): make/dumbask.c |
| 115 | $(CC) $< -o $@ |
| 116 | |
| 117 | |
| 118 | ifdef PLATFORM |
| 119 | |
| 120 | |
| 121 | # Build. |
| 122 | |
| 123 | |
| 124 | CORE_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 Feltzing | 8970ea5 | 2005-03-18 08:37:28 +0000 | [diff] [blame] | 155 | |
Michiel Van Der Kolk | 27be5bc | 2005-03-17 20:50:03 +0000 | [diff] [blame] | 156 | ALLEGRO_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 | |
| 166 | CORE_EXAMPLES := examples/dumbout.c |
| 167 | ALLEGRO_EXAMPLES := examples/dumbplay.c |
| 168 | |
| 169 | CORE_HEADERS := include/dumb.h |
| 170 | ALLEGRO_HEADERS := include/aldumb.h |
| 171 | |
| 172 | |
| 173 | LIBDIR := lib/$(PLATFORM) |
| 174 | OBJDIR_BASE := obj/$(PLATFORM) |
| 175 | |
| 176 | |
| 177 | WFLAGS := -Wall -W -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations -DDUMB_DECLARE_DEPRECATED |
| 178 | WFLAGS_ALLEGRO := -Wno-missing-declarations |
| 179 | OFLAGS := -O2 -ffast-math -fomit-frame-pointer |
| 180 | DBGFLAGS := -DDEBUGMODE=1 -g3 |
| 181 | |
| 182 | CFLAGS_RELEASE := -Iinclude $(WFLAGS) $(OFLAGS) |
| 183 | CFLAGS_DEBUG := -Iinclude $(WFLAGS) $(DBGFLAGS) |
| 184 | |
| 185 | LDFLAGS := -s |
| 186 | |
| 187 | |
| 188 | CORE_EXAMPLES_OBJ := $(addprefix examples/, $(notdir $(patsubst %.c, %.o, $(CORE_EXAMPLES)))) |
| 189 | ALLEGRO_EXAMPLES_OBJ := $(addprefix examples/, $(notdir $(patsubst %.c, %.o, $(ALLEGRO_EXAMPLES)))) |
| 190 | |
| 191 | CORE_EXAMPLES_EXE := $(addprefix examples/, $(notdir $(patsubst %.c, %$(EXE_SUFFIX), $(CORE_EXAMPLES)))) |
| 192 | ALLEGRO_EXAMPLES_EXE := $(addprefix examples/, $(notdir $(patsubst %.c, %$(EXE_SUFFIX), $(ALLEGRO_EXAMPLES)))) |
| 193 | |
| 194 | |
| 195 | CORE_LIB_FILE_RELEASE := $(LIBDIR)/libdumb.a |
| 196 | ALLEGRO_LIB_FILE_RELEASE := $(LIBDIR)/libaldmb.a |
| 197 | |
| 198 | CORE_LIB_FILE_DEBUG := $(LIBDIR)/libdumbd.a |
| 199 | ALLEGRO_LIB_FILE_DEBUG := $(LIBDIR)/libaldmd.a |
| 200 | |
| 201 | |
| 202 | core: $(CORE_LIB_FILE_RELEASE) $(CORE_LIB_FILE_DEBUG) |
| 203 | allegro: $(ALLEGRO_LIB_FILE_RELEASE) $(ALLEGRO_LIB_FILE_DEBUG) |
| 204 | |
| 205 | core-examples: $(CORE_EXAMPLES_EXE) |
| 206 | allegro-examples: $(ALLEGRO_EXAMPLES_EXE) |
| 207 | |
| 208 | core-headers: |
| 209 | |
| 210 | allegro-headers: |
| 211 | |
| 212 | install-core: core |
| 213 | $(call COPY,$(CORE_LIB_FILE_RELEASE),$(LIB_INSTALL_PATH)) |
| 214 | $(call COPY,$(CORE_LIB_FILE_DEBUG),$(LIB_INSTALL_PATH)) |
| 215 | |
| 216 | install-allegro: allegro |
| 217 | $(call COPY,$(ALLEGRO_LIB_FILE_RELEASE),$(LIB_INSTALL_PATH)) |
| 218 | $(call COPY,$(ALLEGRO_LIB_FILE_DEBUG),$(LIB_INSTALL_PATH)) |
| 219 | |
| 220 | ifeq "$(COMSPEC)" "" |
| 221 | install-core-examples: core-examples |
| 222 | $(call COPY,$(CORE_EXAMPLES_EXE),$(BIN_INSTALL_PATH)) |
| 223 | |
| 224 | install-allegro-examples: allegro-examples |
| 225 | $(call COPY,$(ALLEGRO_EXAMPLES_EXE),$(BIN_INSTALL_PATH)) |
| 226 | else |
| 227 | # Don't install the examples on a Windows system. |
| 228 | install-core-examples: |
| 229 | install-allegro-examples: |
| 230 | endif |
| 231 | |
| 232 | install-core-headers: |
| 233 | $(call COPY,$(CORE_HEADERS),$(INCLUDE_INSTALL_PATH)) |
| 234 | |
| 235 | install-allegro-headers: |
| 236 | $(call COPY,$(ALLEGRO_HEADERS),$(INCLUDE_INSTALL_PATH)) |
| 237 | |
| 238 | |
| 239 | uninstall-core: |
| 240 | $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(CORE_LIB_FILE_RELEASE))) |
| 241 | $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(CORE_LIB_FILE_DEBUG))) |
| 242 | |
| 243 | uninstall-allegro: |
| 244 | $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(ALLEGRO_LIB_FILE_RELEASE))) |
| 245 | $(call DELETE,$(LIB_INSTALL_PATH)/$(notdir $(ALLEGRO_LIB_FILE_DEBUG))) |
| 246 | |
| 247 | ifeq "$COMSPEC" "" |
| 248 | uninstall-core-examples: |
| 249 | $(call DELETE,$(patsubst %,$(BIN_INSTALL_PATH)/%,$(notdir $(CORE_EXAMPLES_EXE)))) |
| 250 | |
| 251 | uninstall-allegro-examples: |
| 252 | $(call DELETE,$(patsubst %,$(BIN_INSTALL_PATH)/%,$(notdir $(ALLEGRO_EXAMPLES_EXE)))) |
| 253 | else |
| 254 | # The examples wouldn't have been installed on a Windows system. |
| 255 | uninstall-core-examples: |
| 256 | uninstall-allegro-examples: |
| 257 | endif |
| 258 | |
| 259 | uninstall-core-headers: |
| 260 | $(call DELETE,$(patsubst %,$(INCLUDE_INSTALL_PATH)/%,$(notdir $(CORE_HEADERS)))) |
| 261 | |
| 262 | uninstall-allegro-headers: |
| 263 | $(call DELETE,$(patsubst %,$(INCLUDE_INSTALL_PATH)/%,$(notdir $(ALLEGRO_HEADERS)))) |
| 264 | |
| 265 | |
| 266 | OBJDIR := $(OBJDIR_BASE)/release |
| 267 | CFLAGS := $(CFLAGS_RELEASE) |
| 268 | CORE_LIB_FILE := $(LIBDIR)/libdumb.a |
| 269 | ALLEGRO_LIB_FILE := $(LIBDIR)/libaldmb.a |
| 270 | include make/Makefile.inc |
| 271 | |
| 272 | OBJDIR := $(OBJDIR_BASE)/debug |
| 273 | CFLAGS := $(CFLAGS_DEBUG) |
| 274 | CORE_LIB_FILE := $(LIBDIR)/libdumbd.a |
| 275 | ALLEGRO_LIB_FILE := $(LIBDIR)/libaldmd.a |
| 276 | include make/Makefile.inc |
| 277 | |
| 278 | |
| 279 | $(CORE_EXAMPLES_EXE): examples/%$(EXE_SUFFIX): examples/%.o $(CORE_LIB_FILE_RELEASE) |
Daniel Stenberg | 2505e7b | 2005-05-07 22:09:19 +0000 | [diff] [blame] | 280 | @echo "(dumb) compiling $^" |
| 281 | @$(CC) $^ -o $@ $(LDFLAGS) $(LINK_MATH) |
Michiel Van Der Kolk | 27be5bc | 2005-03-17 20:50:03 +0000 | [diff] [blame] | 282 | |
| 283 | $(ALLEGRO_EXAMPLES_EXE): examples/%$(EXE_SUFFIX): examples/%.o $(ALLEGRO_LIB_FILE_RELEASE) $(CORE_LIB_FILE_RELEASE) |
Daniel Stenberg | 2505e7b | 2005-05-07 22:09:19 +0000 | [diff] [blame] | 284 | @echo "(dumb) compiling $^" |
| 285 | @$(CC) $^ -o $@ $(LDFLAGS) $(LINK_ALLEGRO) |
Michiel Van Der Kolk | 27be5bc | 2005-03-17 20:50:03 +0000 | [diff] [blame] | 286 | |
| 287 | $(CORE_EXAMPLES_OBJ): examples/%.o: examples/%.c include/dumb.h |
Daniel Stenberg | 2505e7b | 2005-05-07 22:09:19 +0000 | [diff] [blame] | 288 | @echo "(dumb) compiling $^" |
| 289 | @$(CC) -c $< -o $@ $(CFLAGS_RELEASE) |
Michiel Van Der Kolk | 27be5bc | 2005-03-17 20:50:03 +0000 | [diff] [blame] | 290 | |
| 291 | $(ALLEGRO_EXAMPLES_OBJ): examples/%.o: examples/%.c include/dumb.h include/aldumb.h |
Daniel Stenberg | 2505e7b | 2005-05-07 22:09:19 +0000 | [diff] [blame] | 292 | @echo "(dumb) compiling $^" |
| 293 | @$(CC) -c $< -o $@ $(CFLAGS_RELEASE) -Wno-missing-declarations |
Michiel Van Der Kolk | 27be5bc | 2005-03-17 20:50:03 +0000 | [diff] [blame] | 294 | |
| 295 | clean: |
| 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 | |
| 300 | veryclean: 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 | |
| 307 | endif # ifdef PLATFORM |