Debian Codegraph @

Makefile

raw symbols SCIP
1 # Makefile for Unix Frotz
2 # GNU make is required.
3
4 # Choose your preferred C compiler
5 #CC = gcc
6 #CC = clang
7
8 # Enable compiler warnings. This is an absolute minimum.
9 CFLAGS += -Wall -std=c99 -O3 #-Wextra
10
11 # Define your optimization flags.
12 #
13 # These are good for regular use.
14 #CFLAGS += -O2 -fomit-frame-pointer -falign-functions=2 -falign-loops=2 -falign-jumps=2
15 # These are handy for debugging.
16 CFLAGS += -g
17
18 # Define where you want Frotz installed
19 PREFIX ?= /usr/local
20 MANDIR ?= $(MAN_PREFIX)/man
21 BINDIR ?= $(PREFIX)/bin
22 #BINDIR ?= $(PREFIX)/games
23 MAN_PREFIX ?= $(PREFIX)/share
24 SYSCONFDIR ?= /etc
25
26 # Choose your sound support
27 # OPTIONS: ao, none
28 SOUND_TYPE ?= ao
29
30 # Choose DOS options
31 #DOS_NO_SOUND ?= yes
32 DOS_NO_BLORB ?= yes
33 DOS_NO_GRAPHICS ?= yes
34 DOS_NO_TRUECOLOUR ?= yes
35
36
37 ##########################################################################
38 # The configuration options below are intended mainly for older flavors
39 # of Unix. For Linux, BSD, and Solaris released since 2003, you can
40 # ignore this section.
41 ##########################################################################
42
43 # Default sample rate for sound effects.
44 # All modern sound interfaces can be expected to support 44100 Hz sample
45 # rates. Earlier ones, particularly ones in Sun 4c workstations support
46 # only up to 8000 Hz.
47 SAMPLERATE ?= 44100
48
49 # Audio buffer size in frames
50 BUFFSIZE ?= 4096
51
52 # Default sample rate converter type
53 DEFAULT_CONVERTER ?= SRC_SINC_MEDIUM_QUALITY
54
55 # Comment this out if you don't want UTF-8 support
56 USE_UTF8 ?= yes
57
58 # Comment this out if your machine's version of curses doesn't support color.
59 COLOR ?= yes
60
61 # Comment this out if your machine's version of curses doesn't support italic.
62 ITALIC ?= yes
63
64 # Select your chosen version of curses. Unless something old is going
65 # on, ncursesw should be used because that's how UTF8 is supported.
66 #CURSES ?= curses
67 #CURSES ?= ncurses
68 CURSES ?= ncursesw
69
70 # This Makefile uses the pkgconf utility to get information on
71 # installed libraries. If your system is missing that utility and
72 # cannot install it for whatever reason (usually very old systems), you
73 # will need to uncomment and perhaps modify some of these lines.
74 # I don't see any way around not having pkgconf for SDL.
75 #CURSES_LDLAGS += -l$(CURSES) -ltinfo
76 #CURSES_CFLAGS += -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
77
78 # Uncomment this to disable Blorb support for dumb and curses interfaces.
79 # SDL interface always has Blorb support.
80 # Doing this for the X11 interface will make it use old-style graphics.
81 #NO_BLORB = yes
82
83
84 ################################
85 # Potentially Missing Functions
86 #
87 # These are for enabling local version of certain functions which may be
88 # missing or behave differently from what's expected in modern system.
89 # If you're running on a system made in the past 20 years, you should be
90 # safe leaving these alone. If not or you're using something modern,
91 # but very strange intended for very limited machines, you probably know
92 # what you're doing. Therefore further commentary on what these
93 # functions do is probably not necessary.
94
95 # For missing memmove()
96 #NO_MEMMOVE = yes
97
98 # For missing strdup()
99 #NO_STRDUP = yes
100
101 # For missing strndup()
102 #NO_STRNDUP = yes
103
104 # For missing strrchr()
105 #NO_STRRCHR = yes
106
107 # For missing basename()
108 #NO_BASENAME = yes
109
110 # Uncomment to disable format codes for dumb interface
111 #DISABLE_FORMATS = yes
112
113 # If your target complains excessively about unused parameters, uncomment this
114 #SILENCE_UNUSED = yes
115
116 # Assorted constants
117 MAX_UNDO_SLOTS = 500
118 MAX_FILE_NAME = 80
119 TEXT_BUFFER_SIZE = 512
120 INPUT_BUFFER_SIZE = 200
121 STACK_SIZE = 1024
122
123 # If SDL2 is available, you most certainly will/should have pkgconf
124 # available, but if not, these defaults should work;
125 SDL_CFLAGS_DEF = -I/usr/include/libpng16 -I/usr/include/SDL2 \
126 -D_REENTRANT -I/usr/include/freetype2
127 SDL_SOUND_CFLAGS_DEF = -I/usr/include/glib-2.0 -I/usr/include/opus \
128 -I/usr/include/dbus-1.0 -I/usr/include/libinstpatch-2 -pthread \
129 -D_REENTRANT -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
130 SDL_LDFLAGS_DEF = -lm -lpng16 -ljpeg -lSDL2 -lfreetype -lz
131 SDL_SOUND_LDFLAGS_DEF = -lSDL2_mixer
132
133 # Here are some reasonable defaults for the the X11 interface.
134 X11_CFLAGS_DEF = -I/usr/include/libpng16
135 X11_LDFLAGS_DEF = -lXt -lX11 -lpng16 -ljpeg -lz -lm
136
137
138 #########################################################################
139 # This section is where Frotz is actually built.
140 # Under normal circumstances, nothing in this section should be changed.
141 #########################################################################
142
143 # Windows - don't build
144 ifeq ($(OS),Windows_NT)
145 $(error Compilation on Windows not supported)
146 endif
147
148 # Determine what system we are on.
149 RANLIB ?= $(shell which ranlib)
150 AR ?= $(shell which ar)
151 # For now, assume !windows == unix.
152 OS_TYPE ?= unix
153 UNAME_S := $(shell uname -s)
154
155 ifeq ($(MAKECMDGOALS),tops20)
156 EXPORT_TYPE = tops20
157 endif
158 ifeq ($(MAKECMDGOALS),dos)
159 EXPORT_TYPE = dos
160 endif
161 ifeq ($(MAKECMDGOALS),owdos)
162 EXPORT_TYPE = dos
163 endif
164 ifeq ($(MAKECMDGOALS),dosdefs)
165 EXPORT_TYPE = dos
166 endif
167 ifeq ($(MAKECMDGOALS),simple)
168 EXPORT_TYPE = simple
169 endif
170
171 RANLIB ?= ranlib
172
173 # Check to see if pkgconf or pkg-config is available.
174 # Both are functionally identical with the name pkg-config being deprecated.
175 PKGCONF_BIN ?= pkgconf
176 PKG_CONFIG_BIN ?= pkg-config
177 # If we don't have pkgconf", check if pkg-config is available.
178 ifneq ($(shell which $(PKGCONF_BIN)),)
179 PKGCONF = $(PKGCONF_BIN)
180 else
181 $(warning *** Could not find $(PKGCONF_BIN). Is $(PKG_CONFIG_BIN) available?)
182 # Check if pkg-config is available.
183 ifneq ($(shell which $(PKG_CONFIG_BIN)),)
184 $(warning *** Found $(PKG_CONFIG_BIN)! Now proceeding normally.)
185 PKGCONF = $(PKG_CONFIG_BIN)
186 else
187 # Neither pkgconf nor pkg-config found.
188 $(warning *** Neither $(PKGCONF_BIN) nor $(PKG_CONFIG_BIN) are found!)
189 $(warning *** Trying default configuration settings. If these don't work,)
190 $(warning *** check the configuration section of the main Makefile.)
191 NO_PKGCONF = yes
192 endif
193 endif
194
195
196 #######################
197 # Curses configuration.
198 ifeq ($(NO_PKGCONF), yes)
199 CURSES_LDFLAGS += -l$(CURSES)
200 CURSES_CFLAGS += -D_DEFAULT_SOURCE
201 else
202 # if pkgconf has $(CURSES)
203 ifeq ($(shell $(PKGCONF) --exists $(CURSES) && echo 0),0)
204 # use pkgconf $(CURSES) info
205 PKGCONF_CURSES = yes
206 CURSES_LDFLAGS += $(shell $(PKGCONF) $(CURSES) --libs)
207 CURSES_CFLAGS += $(shell $(PKGCONF) $(CURSES) --cflags)
208 else # Otherwise, try something obvious like before.
209 CURSES_LDFLAGS += -l$(CURSES)
210 CURSES_CFLAGS += -D_DEFAULT_SOURCE
211 endif
212 endif
213
214
215 #############################
216 # OS-specific configurations.
217 # NetBSD
218 ifeq ($(UNAME_S),NetBSD)
219 NETBSD = yes
220 CFLAGS += -D_NETBSD_SOURCE -I/usr/pkg/include
221 LDFLAGS += -Wl,-R/usr/pkg/lib -L/usr/pkg/lib
222 SDL_LDFLAGS += -lexecinfo
223 ifeq ($(CURSES), ncursesw)
224 CURSES_CFLAGS += -I/usr/pkg/include/ncursesw
225 else
226 CURSES_CFLAGS += -I/usr/pkg/include/ncurses
227 endif
228 endif
229
230 # FreeBSD
231 ifeq ($(UNAME_S),FreeBSD)
232 FREEBSD = yes
233 CFLAGS += -I/usr/local/include -D__BSD_VISIBLE=1
234 LDFLAGS += -L/usr/local/lib
235 SDL_LDFLAGS += -lexecinfo
236 endif
237
238 # OpenBSD
239 ifeq ($(UNAME_S),OpenBSD)
240 OPENBSD = yes
241 NO_EXECINFO_H = yes
242 NO_UCONTEXT_H = yes
243 NO_IMMINTRIN_H = yes
244 CFLAGS += -I/usr/local/include
245 LDFLAGS += -L/usr/local/lib
246 SDL_CFLAGS += -DSDL_DISABLE_IMMINTRIN_H
247 SDL_LDFLAGS += -lexecinfo
248 endif
249
250 # Linux
251 ifeq ($(UNAME_S),Linux)
252 LINUX = yes
253 CFLAGS += -D_POSIX_C_SOURCE=200809L
254 NPROCS = $(shell grep -c ^processor /proc/cpuinfo)
255 endif
256
257 # macOS
258 ifeq ($(UNAME_S),Darwin)
259 MACOS = yes
260 # On macOS, we'll try to use Homebrew's ncurses
261 HOMEBREW_PREFIX ?= $(shell brew --prefix)
262 LDFLAGS += -L$(HOMEBREW_PREFIX)/lib
263
264 CURSES_MACOS ?= ncurses
265 CURSES = $(CURSES_MACOS)
266
267 CURSES_CONFIG ?= $(shell stat -f'%N' $(HOMEBREW_PREFIX)/opt/ncurses/bin/ncurses6-config)
268 # Reset CURSES_LDFLAGS, CURSES_CFLAGS.
269 CURSES_LDFLAGS = $(shell $(CURSES_CONFIG) --libs)
270 CURSES_CFLAGS = $(shell $(CURSES_CONFIG) --cflags)
271 ifeq ($(CURSES_CONFIG),)
272 $(error no ncurses6-config found. Install Homebrew and brew install ncurses, or set CURSES_CONFIG yourself)
273 endif
274 SDL_CFLAGS += -D_XOPEN_SOURCE
275 endif
276
277
278 # Make sure the right curses include file is included.
279 ifeq ($(CURSES), curses)
280 CURSES_DEFINE = USE_CURSES_H
281 else ifneq ($(findstring ncurses,$(CURSES)),)
282 CURSES_CFLAGS += -D_XOPEN_SOURCE_EXTENDED
283 CURSES_DEFINE = USE_NCURSES_H
284 endif
285
286
287 # Export variables to sub-Makefiles.
288 export CC
289 export CFLAGS
290 export CURSES_CFLAGS
291 export NPROCS
292 export MAKEFLAGS
293 export AR
294 export RANLIB
295 export SYSCONFDIR
296 export COLOR
297 export ITALIC
298 export SOUND_TYPE
299 export NO_SOUND
300 export DESTDIR
301 export PREFIX
302 export PKGCONF
303 export NO_PKGCONF
304
305 export CURSES_DEFINE
306 export SAMPLERATE
307 export BUFFSIZE
308 export DEFAULT_CONVERTER
309 export USE_UTF8
310
311 export SDL_PKGS
312 export SDL_SOUND_PKGS
313 export SDL_CFLAGS
314 export SDL_LDFLAGS
315 export SDL_SOUND_CFLAGS
316 export SDL_SOUND_LDFLAGS
317 export SDL_CFLAGS_DEF
318 export SDL_SOUND_CFLAGS_DEF
319 export SDL_LDFLAGS_DEF
320 export SDL_SOUND_LDFLAGS_DEF
321
322 export X11_PKGS
323 export X11_CFLAGS
324 export X11_CFLAGS_DEF
325
326 NAME = frotz
327 VERSION = 2.55
328 RELEASE_NOTES = "Official release."
329 #RELEASE_NOTES = "Development release."
330
331 # If we're working from git, we have access to proper variables.
332 # If not, make it clear that we're working from a release.
333 #
334 GIT_DIR ?= .git
335 ifneq ($(and $(wildcard $(GIT_DIR)),$(shell which git)),)
336 GIT_HASH = $(shell git rev-parse HEAD)
337 GIT_HASH_SHORT = $(shell git rev-parse --short=8 HEAD)
338 GIT_DATE = $(shell git show -s --format=%ci)
339 else
340 GIT_HASH = acf205585a9472d27c07c0fe62da4b8bc89d1ec7
341 GIT_HASH_SHORT = acf20558
342 GIT_DATE = 2025-02-01 14:36:37 -0800
343 endif
344 export CFLAGS
345
346
347 # Source locations
348 #
349 SRCDIR = src
350 COMMON_DIR = $(SRCDIR)/common
351 COMMON_LIB = $(COMMON_DIR)/frotz_common.a
352 COMMON_DEFINES = $(COMMON_DIR)/defs.h
353 HASH = $(COMMON_DIR)/hash.h
354
355 MISC_DIR = $(SRCDIR)/misc
356 FONTS_DIR = fonts
357
358 BLORB_DIR = $(SRCDIR)/blorb
359 BLORB_LIB = $(BLORB_DIR)/blorblib.a
360
361 CURSES_DIR = $(SRCDIR)/curses
362 CURSES_LIB = $(CURSES_DIR)/frotz_curses.a
363
364 DUMB_DIR = $(SRCDIR)/dumb
365 DUMB_LIB = $(DUMB_DIR)/frotz_dumb.a
366
367 DOS_DIR = $(SRCDIR)/dos
368
369 X11_DIR = $(SRCDIR)/x11
370 X11_LIB = $(X11_DIR)/frotz_x11.a
371 X11_PKGS = x11 xt libpng libjpeg zlib
372
373 SDL_DIR = $(SRCDIR)/sdl
374 SDL_LIB = $(SDL_DIR)/frotz_sdl.a
375 SDL_PKGS = libpng libjpeg sdl2 freetype2 zlib
376 SDL_SOUND_PKGS = SDL2_mixer
377 SDL_LDFLAGS += -lm
378
379 SUBDIRS = $(COMMON_DIR) $(CURSES_DIR) $(X11_DIR) $(SDL_DIR) $(DUMB_DIR) $(BLORB_DIR) $(DOS_DIR) $(FONTS_DIR)
380 SUB_CLEAN = $(SUBDIRS:%=%-clean)
381
382 FROTZ_BIN = frotz$(EXTENSION)
383 DFROTZ_BIN = dfrotz$(EXTENSION)
384 XFROTZ_BIN = xfrotz$(EXTENSION)
385 SFROTZ_BIN = sfrotz$(EXTENSION)
386 DOS_BIN = frotz.exe
387
388 FROTZ_LIBS = $(COMMON_LIB) $(CURSES_LIB) $(BLORB_LIB) $(COMMON_LIB)
389 DFROTZ_LIBS = $(COMMON_LIB) $(DUMB_LIB) $(BLORB_LIB) $(COMMON_LIB)
390 XFROTZ_LIBS = $(COMMON_LIB) $(X11_LIB) $(BLORB_LIB) $(COMMON_LIB)
391 SFROTZ_LIBS = $(COMMON_LIB) $(SDL_LIB) $(BLORB_LIB) $(COMMON_LIB)
392
393 # Tools
394 SNAVIG = $(MISC_DIR)/snavig.pl
395 SNAVIG_DIR = snavig
396
397 ifdef NO_BLORB
398 SOUND_TYPE = none
399 CURSES_SOUND = disabled
400 BLORB_SUPPORT = disabled
401 FROTZ_LIBS = $(COMMON_LIB) $(CURSES_LIB) $(COMMON_LIB)
402 DFROTZ_LIBS = $(COMMON_LIB) $(DUMB_LIB) $(COMMON_LIB)
403 else
404 BLORB_SUPPORT = enabled
405 endif
406
407 ifeq ($(SOUND_TYPE), ao)
408 CURSES_SOUND_LDFLAGS += -lao -lpthread -lm \
409 -lsndfile -lvorbisfile -lmodplug -lsamplerate
410 CURSES_SOUND = enabled
411 else
412 CURSES_SOUND = disabled
413 endif
414
415 # Check to see if the -Orecurse option is available. It's nice for
416 # watching the output of a parallel build, but is otherwise not
417 # necessary.
418 ifneq ($(filter output-sync,$(value .FEATURES)),)
419 MAKEFLAGS += -Orecurse
420 endif
421
422 # Just the version number without the dot
423 DOSVER = $(shell echo $(VERSION) | sed s/\\.//g)
424
425 # Build recipes
426 #
427 curses: $(FROTZ_BIN)
428 ncurses: $(FROTZ_BIN)
429 $(FROTZ_BIN): $(FROTZ_LIBS)
430 $(CC) $+ -o $@ $(LDFLAGS) $(CURSES_LDFLAGS) $(CURSES_SOUND_LDFLAGS)
431 @echo "** Done building Frotz with curses interface"
432 @echo "** Audio support $(CURSES_SOUND) (type $(SOUND_TYPE))"
433 @echo "** Blorb support $(BLORB_SUPPORT)"
434
435 nosound: nosound_helper $(FROTZ_BIN) | nosound_helper
436 nosound_helper:
437 $(eval SOUND_TYPE= none)
438 $(eval CURSES_SOUND_LDFLAGS= )
439 $(eval CURSES_SOUND= disabled)
440
441 dumb: $(DFROTZ_BIN)
442 $(DFROTZ_BIN): $(DFROTZ_LIBS)
443 $(CC) $+ -o $@ $(LDFLAGS)
444 @echo "** Done building Frotz with dumb interface."
445 @echo "** Blorb support $(BLORB_SUPPORT)"
446
447 x11: $(XFROTZ_BIN)
448 $(XFROTZ_BIN): $(XFROTZ_LIBS)
449 ifneq ($(NO_PKGCONF), yes)
450 $(eval X11_LDFLAGS += $(shell $(PKGCONF) $(X11_PKGS) --libs))
451 else
452 $(eval X11_LDFLAGS += $(X11_LDFLAGS_DEF))
453 endif
454 $(CC) $+ -o $@ $(LDFLAGS) $(X11_LDFLAGS) -lm
455 @echo "** Done building Frotz with X11 interface."
456
457 sdl: $(SFROTZ_BIN)
458 $(SFROTZ_BIN): $(SFROTZ_LIBS)
459 ifneq ($(NO_PKGCONF), yes)
460 $(eval SDL_LDFLAGS += $(shell $(PKGCONF) $(SDL_PKGS) --libs))
461 $(eval SDL_SOUND_LDFLAGS = $(shell $(PKGCONF) $(SDL_SOUND_PKGS) --libs))
462 else
463 $(eval SDL_LDFLAGS += $(SDL_LDFLAGS_DEF))
464 $(eval SDL_SOUND_LDFLAGS += $(SDL_SOUND_LDFLAGS_DEF))
465 endif
466 $(CC) $+ -o $@ $(LDFLAGS) $(SDL_LDFLAGS) $(SDL_SOUND_LDFLAGS)
467 @echo "** Done building Frotz with SDL interface."
468
469 sdl_nosound: sdl_nosound_helper $(SFROTZ_BIN) | sdl_nosound_helper
470 sdl_nosound_helper:
471 $(eval SOUND_TYPE= none)
472 $(eval SDL_SOUND_LDFLAGS= )
473 $(eval SDL_SOUND_CFLAGS= )
474 $(eval SDL_SOUND_PKGS= )
475
476
477 owdos: $(DOS_BIN)
478 $(DOS_BIN): $(COMMON_DEFINES) $(HASH)
479 ifneq ($(shell which wmake),)
480 wmake -f Makefile.ow
481 else
482 $(error wmake command not found. Cannot make the DOS version)
483 endif
484
485 all: $(FROTZ_BIN) $(DFROTZ_BIN) $(SFROTZ_BIN) $(XFROTZ_BIN)
486
487 # Snavig-processed targets
488 #
489 snavig:
490 @echo "Snavig: Change an object's shape..."
491 @echo " Snavig processes source code for compilation on very old"
492 @echo " systems which may have trouble with how the Frotz source"
493 @echo " is normally presented."
494 @echo "Possible snavig-processed targets:"
495 @echo " dos (done)"
496 @echo " tops20 (done)"
497 @echo " simple (done)"
498 @echo " its (not even started)"
499 @echo " tops10 (not even started)"
500 @echo " tenex (not even started)"
501 @echo " waits (not even started)"
502 @echo "That's all for now."
503
504 dos: $(COMMON_DEFINES) $(HASH)
505 @rm -rf $(SNAVIG_DIR)
506 @mkdir $(SNAVIG_DIR)
507 @echo "** Copying support text files to $(SNAVIG_DIR)"
508 @cp Makefile.tc Makefile.ow $(SNAVIG_DIR)
509 @cp owbuild.bat tcbuild.bat $(SNAVIG_DIR)
510 @cp INSTALL_DOS $(SNAVIG_DIR)/INSTALL.txt
511 @cp doc/frotz.txt $(SNAVIG_DIR)
512 @sed -i "/^OW_DOS_DIR.*/d" $(SNAVIG_DIR)/Makefile.ow
513 @sed -i "/^CORE_DIR.*/d" $(SNAVIG_DIR)/Makefile.ow
514 @sed -i "/^BLORB_DIR.*/d" $(SNAVIG_DIR)/Makefile.ow
515 @echo "** Invoking snavig"
516 @$(SNAVIG) -t dos $(COMMON_DIR) $(BLORB_DIR) $(DOS_DIR) $(SNAVIG_DIR)
517 @echo "** Adding frotz.prj for building with Turbo C IDE"
518 @cp frotz.prj $(SNAVIG_DIR)
519 @echo "$(SNAVIG_DIR)/ now contains Frotz source code for 16-bit DOS."
520 @echo "Supported compilers are:"
521 @echo " Borland Turbo C 3.00 and Borland MAKE 3.6"
522 @echo " Open Watcom C 2.0 and Open Watcom MAKE (wmake)"
523
524 tops20: $(COMMON_DEFINES) $(HASH)
525 @rm -rf $(SNAVIG_DIR)
526 @mkdir $(SNAVIG_DIR)
527 @echo "** Invoking snavig"
528 @cp Makefile.kcc $(SNAVIG_DIR)/Makefile
529 @$(SNAVIG) -t tops20 $(COMMON_DIR) $(DUMB_DIR) $(SNAVIG_DIR)
530 @echo "$(SNAVIG_DIR)/ now contains Frotz source code for $(EXPORT_TYPE)."
531 @echo "Supported compilers are:"
532 @echo " KCC-6.620(c2l3)"
533
534 simple: $(COMMON_DEFINES) $(HASH)
535 @rm -rf $(SNAVIG_DIR)
536 @mkdir $(SNAVIG_DIR)
537 @echo "** Invoking snavig"
538 @$(SNAVIG) -t simple $(COMMON_DIR) $(DUMB_DIR) $(SNAVIG_DIR)
539 @echo "$(SNAVIG_DIR)/ now contains Frotz source code for $(EXPORT_TYPE)."
540 @echo "Compile with \"cc -o dfrotz *.c\""
541
542
543 common_lib: $(COMMON_LIB)
544 curses_lib: $(CURSES_LIB)
545 x11_lib: $(X11_LIB)
546 sdl_lib: $(SDL_LIB)
547 dumb_lib: $(DUMB_LIB)
548 blorb_lib: $(BLORB_LIB)
549 dos_lib: $(DOS_LIB)
550
551 common-lib: $(COMMON_LIB)
552 curses-lib: $(CURSES_LIB)
553 x11-lib: $(X11_LIB)
554 sdl-lib: $(SDL_LIB)
555 dumb-lib: $(DUMB_LIB)
556 blorb-lib: $(BLORB_LIB)
557 dos-lib: $(DOS_LIB)
558
559 $(COMMON_LIB): $(COMMON_DEFINES) $(HASH)
560 $(MAKE) -C $(COMMON_DIR)
561
562 $(CURSES_LIB): $(COMMON_DEFINES) $(HASH)
563 $(MAKE) -C $(CURSES_DIR)
564
565 $(X11_LIB): $(COMMON_DEFINES) $(HASH)
566 $(MAKE) -C $(X11_DIR)
567
568 $(SDL_LIB): $(COMMON_DEFINES) $(HASH) $(SDL_DIR)
569 $(MAKE) -C $(SDL_DIR)
570
571 $(DUMB_LIB): $(COMMON_DEFINES) $(HASH)
572 $(MAKE) -C $(DUMB_DIR)
573
574 $(BLORB_LIB): $(COMMON_DEFINES) $(HASH)
575 $(MAKE) -C $(BLORB_DIR)
576
577 $(SUB_CLEAN):
578 -$(MAKE) -C $(@:%-clean=%) clean
579
580
581 # Compile-time generated defines and strings
582 # Stuff common to all interfaces are generated here to allow for parallel
583 # compilation to work without having to wait for the common module to finish.
584 dosdefs: hash defs
585 defs: common_defines
586 common-defines: common_defines
587 common_defines: $(COMMON_DEFINES)
588 $(COMMON_DEFINES):
589 ifeq ($(wildcard $(COMMON_DEFINES)),)
590 @echo "** Generating $@"
591 @echo "#ifndef COMMON_DEFINES_H" > $@
592 @echo "#define COMMON_DEFINES_H" >> $@
593 @echo "#define RELEASE_NOTES \"$(RELEASE_NOTES)\"" >> $@
594
595 ifeq ($(EXPORT_TYPE), dos)
596 @echo "#define MSDOS_16BIT" >> $@
597
598 @echo "/* Uncomment this to disable Blorb support. */" >> $@
599 ifeq ($(DOS_NO_BLORB), yes)
600 @echo "#define NO_BLORB" >> $@
601 else
602 @echo "/* #define NO_BLORB */" >> $@
603 endif
604
605 @echo "/* Uncomment this to disable sound support. */" >> $@
606 ifeq ($(DOS_NO_SOUND), yes)
607 @echo "#define NO_SOUND" >> $@
608 else
609 @echo "/* #define NO_SOUND */" >> $@
610 endif
611
612 @echo "/* Uncomment this to disable graphics support. */" >> $@
613 ifeq ($(DOS_NO_GRAPHICS), yes)
614 @echo "#define NO_GRAPHICS" >> $@
615 else
616 @echo "/* #define NO_GRAPHICS */" >> $@
617 endif
618
619 @echo "/* Uncomment this to disable true-colour support. */" >> $@
620 ifeq ($(DOS_NO_TRUECOLOUR), yes)
621 @echo "#define NO_TRUECOLOUR" >> $@
622 else
623 @echo "/* #define NO_TRUECOLOUR */" >> $@
624 endif
625
626
627 else
628 ifeq ($(EXPORT_TYPE), tops20)
629 @echo "#ifndef TOPS20" >> $@
630 @echo "#define TOPS20" >> $@
631 @echo "#endif" >> $@
632 @echo "#define NO_STRDUP" >> $@
633 @echo "#define NO_STRNDUP" >> $@
634 @echo "#define NO_BASENAME" >> $@
635 @echo "#define MAXPATHLEN 39" >> $@
636 @echo "#define NO_BLORB" >> $@
637 else
638
639 ifdef MACOS
640 @echo "#define MACOS" >> $@
641 endif
642
643 ifeq ($(OS_TYPE), unix)
644 @echo "#define UNIX" >> $@
645 endif
646 endif
647 endif
648
649 @echo "#define MAX_UNDO_SLOTS $(MAX_UNDO_SLOTS)" >> $@
650 @echo "#define MAX_FILE_NAME $(MAX_FILE_NAME)" >> $@
651 @echo "#define TEXT_BUFFER_SIZE $(TEXT_BUFFER_SIZE)" >> $@
652 @echo "#define INPUT_BUFFER_SIZE $(INPUT_BUFFER_SIZE)" >> $@
653 @echo "#define STACK_SIZE $(STACK_SIZE)" >> $@
654 ifdef NO_BLORB
655 @echo "#define NO_BLORB" >> $@
656 endif
657 ifdef NO_BASENAME
658 @echo "#define NO_BASENAME" >> $@
659 endif
660 ifdef NO_STRRCHR
661 @echo "#define NO_STRRCHR" >> $@
662 endif
663 ifdef NO_MEMMOVE
664 @echo "#define NO_MEMMOVE" >> $@
665 endif
666 ifdef NO_STRDUP
667 @echo "#define NO_STRDUP" >> $@
668 endif
669 ifdef NO_STRNDUP
670 @echo "#define NO_STRNDUP" >> $@
671 endif
672 ifdef NO_UCONTEXT_H
673 @echo "#define NO_UCONTEXT_H" >> $@
674 endif
675 ifdef NO_EXECINFO_H
676 @echo "#define NO_EXECINFO_H" >> $@
677 endif
678
679 # When exporting source code rather than compiling it here, the target machine
680 # typically can't do UTF8.
681 ifeq ($(EXPORT_TYPE),)
682 $(if $(findstring yes,$(USE_UTF8)), @echo "#define USE_UTF8" >> $@)
683 endif
684
685 ifdef FREEBSD
686 @echo "#define __BSD_VISIBLE 1" >> $@
687 endif
688 ifdef DISABLE_FORMATS
689 @echo "#define DISABLE_FORMATS" >> $@
690 endif
691 @echo "#endif /* COMMON_DEFINES_H */" >> $@
692 endif
693
694
695 hash: $(HASH)
696 $(HASH):
697 ifeq ($(wildcard $(HASH)),)
698 @echo "** Generating $@"
699 @echo "#ifndef VERSION" > $@
700 @echo "#define VERSION \"$(VERSION)\"" >> $@
701 @echo "#endif" >> $@
702 @echo "#ifndef RELEASE_NOTES" >> $@
703 @echo "#define RELEASE_NOTES \"$(RELEASE_NOTES)\"" >> $@
704 @echo "#endif" >> $@
705 @echo "#define GIT_HASH \"$(GIT_HASH)\"" >> $@
706 @echo "#define GIT_HASH_SHORT \"$(GIT_HASH_SHORT)\"" >> $@
707 @echo "#define GIT_DATE \"$(GIT_DATE)\"" >> $@
708 endif
709
710
711 # Administrative stuff
712 #
713 install: install_frotz
714 install-frotz: install_frotz
715 install_frotz: $(FROTZ_BIN)
716 mkdir -p $(DESTDIR)$(BINDIR) && test -w $(DESTDIR)$(BINDIR)
717 install -c -m 755 $(FROTZ_BIN) $(DESTDIR)$(BINDIR)
718 mkdir -p $(DESTDIR)$(MANDIR)/man6 && test -w $(DESTDIR)$(MANDIR)/man6
719 install -m 644 doc/frotz.6 $(DESTDIR)$(MANDIR)/man6/
720
721 uninstall: uninstall_frotz
722 uninstall-frotz: uninstall-frotz
723 uninstall_frotz:
724 rm -f $(DESTDIR)$(BINDIR)/frotz
725 rm -f $(DESTDIR)$(MANDIR)/man6/frotz.6
726
727 install_dumb: install_dfrotz
728 install-dumb: install_dfrotz
729 install-dfrotz: install_dfrotz
730 install_dfrotz: $(DFROTZ_BIN)
731 mkdir -p $(DESTDIR)$(BINDIR) && test -w $(DESTDIR)$(BINDIR)
732 install -c -m 755 $(DFROTZ_BIN) $(DESTDIR)$(BINDIR)
733 mkdir -p $(DESTDIR)$(MANDIR)/man6 && test -w $(DESTDIR)$(MANDIR)/man6
734 install -m 644 doc/dfrotz.6 $(DESTDIR)$(MANDIR)/man6/
735
736 uninstall_dumb: uninstall_dfrotz
737 uninstall-dumb: uninstall_dfrotz
738 uninstall-dfrotz: uninstall_dfrotz
739 uninstall_dfrotz:
740 rm -f $(DESTDIR)$(BINDIR)/dfrotz
741 rm -f $(DESTDIR)$(MANDIR)/man6/dfrotz.6
742
743 fonts_pcf:
744 $(MAKE) -C $(FONTS_DIR) pcf
745
746 install_x11: install_xfrotz
747 install-x11: install_xfrotz
748 install-xfrotz: install_xfrotz
749 install_xfrotz: $(XFROTZ_BIN)
750 mkdir -p "$(DESTDIR)$(PREFIX)/bin" && test -w $(DESTDIR)$(BINDIR)
751 mkdir -p "$(DESTDIR)$(MANDIR)/man6" && test -w $(DESTDIR)$(MANDIR)/man6
752 install "$(XFROTZ_BIN)" "$(DESTDIR)$(PREFIX)/bin/"
753 install -m 644 doc/xfrotz.6 "$(DESTDIR)$(MANDIR)/man6/"
754 $(MAKE) -C $(FONTS_DIR) install_pcf
755
756 uninstall_x11: uninstall_xfrotz
757 uninstall-x11: uninstall_xfrotz
758 uninstall-xfrotz: uninstall_xfrotz
759 uninstall_xfrotz:
760 rm -f "$(DESTDIR)$(PREFIX)/bin/xfrotz"
761 rm -f "$(DESTDIR)$(MANDIR)/man6/xfrotz.6"
762 $(MAKE) -C $(FONTS_DIR) uninstall_pcf
763
764 install-sdl: install_sfrotz
765 install_sdl: install_sfrotz
766 install-sfrotz: install_sfrotz
767 install_sfrotz: $(SFROTZ_BIN)
768 mkdir -p $(DESTDIR)$(BINDIR) && test -w $(DESTDIR)$(BINDIR)
769 install -c -m 755 $(SFROTZ_BIN) $(DESTDIR)$(BINDIR)
770 mkdir -p $(DESTDIR)$(MANDIR)/man6 && test -w $(DESTDIR)$(MANDIR)/man6
771 install -m 644 doc/sfrotz.6 $(DESTDIR)$(MANDIR)/man6/
772
773 uninstall-sdl: uninstall_sfrotz
774 uninstall_sdl: uninstall_sfrotz
775 uninstall-sfrotz: uninstall_sfrotz
776 uninstall_sfrotz:
777 rm -f $(DESTDIR)$(BINDIR)/sfrotz
778 rm -f $(DESTDIR)$(MANDIR)/man6/sfrotz.6
779
780 install-all: install_all
781 install_all: install_frotz install_dfrotz install_sfrotz install_xfrotz
782
783 uninstall-all: uninstall_all
784 uninstall_all: uninstall_frotz uninstall_dfrotz uninstall_sfrotz uninstall_xfrotz
785
786
787 dist: $(NAME)-$(VERSION).tar.gz
788 frotz-$(VERSION).tar.gz:
789 ifneq ($(and $(wildcard $(GIT_DIR)),$(shell which git)),)
790 git archive --format=tgz --prefix $(NAME)-$(VERSION)/ HEAD -o $(NAME)-$(VERSION).tar.gz
791 @echo $(NAME)-$(VERSION).tar.gz created.
792 else
793 @echo "Not in a git repository or git command not found. Cannot make an archive file."
794 endif
795
796 dosdist:
797 @echo
798 @echo " ** Populating $(NAME)$(DOSVER) with things for the DOS Frotz precompiled zipfile."
799 @echo " ** Just add frotz.exe compiled wherever."
800 @echo " ** Then do \"zip -r $(NAME)$(DOSVER).zip $(NAME)$(DOSVER)\""
801 @echo
802 @mkdir -p $(NAME)$(DOSVER)
803 @cp ChangeLog $(NAME)$(DOSVER)/changes.txt
804 @cp frotz.lsm $(NAME)$(DOSVER)
805 @cp doc/frotz.txt $(NAME)$(DOSVER)
806 @cp doc/file_id.diz $(NAME)$(DOSVER)
807 @cp HOW_TO_PLAY $(NAME)$(DOSVER)/howto.txt
808 @cp README $(NAME)$(DOSVER)/README.txt
809 @cp AUTHORS $(NAME)$(DOSVER)/AUTHORS.txt
810 @cp COPYING $(NAME)$(DOSVER)/COPYING.txt
811 @unix2dos -q $(NAME)$(DOSVER)/*
812 @touch $(NAME)$(DOSVER)/*
813
814 owdosdist: $(NAME)$(DOSVER).zip
815 $(NAME)$(DOSVER).zip: dosdist $(DOS_BIN)
816 @cp $(DOS_BIN) $(NAME)$(DOSVER)/$(DOS_BIN)
817 @zip -r $(NAME)$(DOSVER).zip $(NAME)$(DOSVER)
818
819 clean: $(SUB_CLEAN)
820 rm -rf $(NAME)-$(VERSION)
821 rm -rf $(COMMON_DEFINES) $(HASH)
822 rm -f FROTZ.BAK FROTZ.EXE FROTZ.LIB FROTZ.DSK *.OBJ
823 rm -f FROTZ.MAP *.ERR
824 rm -f frotz.map *.err
825
826 distclean: clean
827 rm -f $(FROTZ_BIN) $(DFROTZ_BIN) $(SFROTZ_BIN) $(XFROTZ_BIN) $(DOS_BIN)
828 rm -f a.out
829 rm -rf $(NAME)src $(NAME)$(DOSVER) $(SNAVIG_DIR)
830 rm -f $(NAME)*.tar.gz $(NAME)src.zip $(NAME)$(DOSVER).zip snavig.zip
831
832 help:
833 @echo "Targets:"
834 @echo " frotz: (default target) the standard curses version"
835 @echo " install/uninstall: install or uninstall the curses version"
836 @echo " nosound: build the curses edition without sound support"
837 @echo " dumb: for dumb terminals and wrapper scripts"
838 @echo " sdl: for SDL graphics and sound"
839 @echo " x11: for X11 graphics"
840 @echo " all: build curses, dumb, SDL, and x11 versions"
841 @echo " owdos: Cross-compile to DOS with Open Watcom C for Unix"
842 @echo "There are also install_X and uninstall_X where X is one of"
843 @echo " curses, dumb, sdl, or x11 for installing and deinstalling"
844 @echo " Frotz built with just that interface."
845 @echo "Use Snavig to rework the source code for compilation on very old systems:"
846 @echo " dos: For compilation on DOS with TurboC or OpenWatcom C"
847 @echo " tops20: For compilation on TOPS20 with KCC"
848 @echo " simple: For a very simplified dumb-frotz"
849 @echo "Housekeeping targets:"
850 @echo " clean: clean up files created by compilation"
851 @echo " distclean: like clean, but also delete executables"
852 @echo " dist: create a source tarball"
853 @echo ""
854
855 .SUFFIXES:
856 .SUFFIXES: .c .o .h
857
858 .PHONY: all clean dist dosdist curses ncurses dumb sdl hash help snavig \
859 common_defines dosdefs curses_defines nosound nosound_helper \
860 $(COMMON_DEFINES) $(HASH) \
861 blorb_lib common_lib curses_lib dumb_lib \
862 install install_dfrotz install_sfrotz install_xfrotz $(SUB_CLEAN)
863 uninstall uninstall_dfrotz uninstall_sfrotz uninstall_xfrotz