Add an error check for correct formatting in Deflate uncompressed
[sgt/halibut] / Makefile
CommitLineData
d7482997 1# Halibut master makefile
2
73a05796 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
7ce668da 12# - we use .PHONY
d7482997 13
a4d3c848 14prefix=/usr/local
15exec_prefix=$(prefix)
16bindir=$(exec_prefix)/bin
17INSTALL=install -c
18
7ce668da 19.PHONY: all install clean spotless topclean release
20
574825cf 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
d7482997 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
574825cf 45
a4d3c848 46all install:
d7482997 47 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
1b7cc907 48 @$(MAKE) -C $(BUILDDIR) -f ../Makefile $@ REALBUILD=yes
574825cf 49
48f8f266 50spotless: topclean
d7482997 51 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
1b7cc907 52 @$(MAKE) -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes
574825cf 53
48f8f266 54clean: topclean
d7482997 55 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
1b7cc907 56 @$(MAKE) -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes
574825cf 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').
48f8f266 61topclean:
574825cf 62 rm -f *.html output.* *.tar.gz
63
64# Make a release archive. If $(VERSION) is specified, this will
65# also contain a `manifest' file which will be used to decide the
66# version number automatically.
dc69abf1 67release: release.sh
68 ./release.sh $(RELDIR) $(VERSION)
574825cf 69
d7482997 70else
71
72# The `real' makefile part.
73
ee90d1f0 74CFLAGS += -Wall -W -ansi -pedantic
d7482997 75
76ifdef TEST
77CFLAGS += -DLOGALLOC
78LIBS += -lefence
79endif
80
d7482997 81ifndef VER
82ifdef VERSION
83VER := $(VERSION)
84endif
85endif
86ifdef VER
574825cf 87VDEF = -DVERSION=\"$(VER)\"
88else
e5ac6866 89VDEF = `(cd $(SRC); md5sum -c manifest >/dev/null 2>&1 && cat version)`
d7482997 90endif
91
a4d3c848 92all: halibut
05a1519d 93
d7482997 94SRC := ../
95
dc69abf1 96ifeq ($(shell test -d $(SRC)charset && echo yes),yes)
05a1519d 97LIBCHARSET_SRCDIR = $(SRC)charset/
dc69abf1 98else
99LIBCHARSET_SRCDIR = $(SRC)../charset/
100endif
05a1519d 101LIBCHARSET_OBJDIR = ./#
102LIBCHARSET_OBJPFX = cs-#
103LIBCHARSET_GENPFX = charset-#
104MD = -MD
105CFLAGS += -I$(LIBCHARSET_SRCDIR) -I$(LIBCHARSET_OBJDIR)
106include $(LIBCHARSET_SRCDIR)Makefile
107
d7482997 108MODULES := main malloc ustring error help licence version misc tree234
babfe3e2 109MODULES += input in_afm in_pf in_sfnt keywords contents index biblio
78c73085 110MODULES += bk_text bk_html bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf
7e2417cc 111MODULES += winhelp deflate psdata wcwidth
d7482997 112
05a1519d 113OBJECTS := $(addsuffix .o,$(MODULES)) $(LIBCHARSET_OBJS)
d7482997 114DEPS := $(addsuffix .d,$(MODULES))
115
116halibut: $(OBJECTS)
117 $(CC) $(LFLAGS) -o halibut $(OBJECTS) $(LIBS)
118
119%.o: $(SRC)%.c
120 $(CC) $(CFLAGS) -MD -c $<
121
122version.o: FORCE
123 $(CC) $(VDEF) -MD -c $(SRC)version.c
124
125spotless:: clean
126 rm -f *.d
127
128clean::
129 rm -f *.o halibut core
130
a4d3c848 131install:
132 $(INSTALL) -m 755 halibut $(bindir)/halibut
133 $(MAKE) -C ../doc install prefix="$(prefix)" INSTALL="$(INSTALL)"
134
d7482997 135FORCE: # phony target to force version.o to be rebuilt every time
136
137-include $(DEPS)
138
139endif