1# Halibut master makefile 2 3# Currently depends on gcc, because: 4# - the dependency tracking uses -MD in order to avoid needing an 5# explicit `make depend' step 6# - the definition of CFLAGS includes the gcc-specific flag 7# `-Wall' 8# 9# Currently depends on GNU make, because: 10# - the Makefile uses GNU ifdef / ifndef commands and GNU make `%' 11# pattern rules 12# - we use .PHONY 13 14prefix=/usr/local 15exec_prefix=$(prefix) 16bindir=$(exec_prefix)/bin 17INSTALL=install -c 18 19.PHONY: all install clean spotless topclean release 20 21ifdef RELEASE 22ifndef VERSION 23VERSION := $(RELEASE) 24endif 25else 26CFLAGS += -g 27endif 28 29ifeq (x$(VERSION)y,xy) 30RELDIR := halibut 31else 32RELDIR := halibut-$(VERSION) 33endif 34 35# `make' from top level will build in directory `build' 36# `make BUILDDIR=foo' from top level will build in directory foo 37ifndef REALBUILD 38ifndef BUILDDIR 39ifdef TEST 40BUILDDIR := test 41else 42BUILDDIR := build 43endif 44endif 45 46all install: 47 @test -d $(BUILDDIR) || mkdir $(BUILDDIR) 48 @$(MAKE) -C $(BUILDDIR) -f ../Makefile $@ REALBUILD=yes 49 50spotless: topclean 51 @test -d $(BUILDDIR) || mkdir $(BUILDDIR) 52 @$(MAKE) -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes 53 54clean: topclean 55 @test -d $(BUILDDIR) || mkdir $(BUILDDIR) 56 @$(MAKE) -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes 57 58# Remove Halibut output files in the source directory (may 59# have been created by running, for example, `build/halibut 60# inputs/test.but'). 61topclean: 62 rm -f *.html output.* *.tar.gz 63 64# Makef a release archive. 65release: release.sh 66 ./release.sh $(RELDIR) $(VERSION) 67 68else 69 70# The `real' makefile part. 71 72CFLAGS += -Wall -W -ansi -pedantic 73 74ifdef TEST 75CFLAGS += -DLOGALLOC 76LIBS += -lefence 77endif 78 79EXE =# 80 81all: halibut$(EXE) 82 83SRC := ../ 84 85ifeq ($(shell test -d $(SRC)charset && echo yes),yes) 86LIBCHARSET_SRCDIR = $(SRC)charset/ 87else 88LIBCHARSET_SRCDIR = $(SRC)../charset/ 89endif 90LIBCHARSET_OBJDIR = ./# 91LIBCHARSET_OBJPFX = cs-# 92LIBCHARSET_GENPFX = charset-# 93MD = -MD 94CFLAGS += -I$(LIBCHARSET_SRCDIR) -I$(LIBCHARSET_OBJDIR) 95include $(LIBCHARSET_SRCDIR)Makefile 96CC_LINK = $(CC) -o $@ 97 98MODULES := main malloc ustring error help licence version misc tree234 99MODULES += input in_afm in_pf in_sfnt keywords contents index biblio 100MODULES += bk_text bk_html bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf 101MODULES += winhelp winchm deflate lzx lz77 huffman psdata wcwidth 102 103OBJECTS := $(addsuffix .o,$(MODULES)) $(LIBCHARSET_OBJS) 104DEPS := $(addsuffix .d,$(MODULES)) 105 106halibut$(EXE): $(OBJECTS) 107 $(CC_LINK) $(LFLAGS) $(OBJECTS) $(LIBS) 108 109%.o: $(SRC)%.c 110 $(CC) $(CFLAGS) -MD -c $< 111 112version.o: FORCE 113 $(CC) $(VDEF) -MD -c $(SRC)version.c 114 115spotless:: clean 116 rm -f *.d 117 118clean:: 119 rm -f *.o halibut core 120 121install: 122 mkdir -p $(prefix) $(bindir) 123 $(INSTALL) -m 755 halibut $(DESTDIR)$(bindir)/halibut 124 $(MAKE) -C ../doc install prefix="$(DESTDIR)$(prefix)" INSTALL="$(INSTALL)" 125 126FORCE: # phony target to force version.o to be rebuilt every time 127 128-include $(DEPS) 129 130endif 131