Stop the PDF backend from crashing if no outline elements appear. It
[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
d7482997 12
574825cf 13ifdef RELEASE
14ifndef VERSION
15VERSION := $(RELEASE)
16endif
17else
18CFLAGS += -g
19endif
20
21ifeq (x$(VERSION)y,xy)
22RELDIR := halibut
23else
24RELDIR := halibut-$(VERSION)
25endif
26
d7482997 27# `make' from top level will build in directory `build'
28# `make BUILDDIR=foo' from top level will build in directory foo
29ifndef REALBUILD
30ifndef BUILDDIR
31ifdef TEST
32BUILDDIR := test
33else
34BUILDDIR := build
35endif
36endif
574825cf 37
d7482997 38all:
39 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
40 @make -C $(BUILDDIR) -f ../Makefile REALBUILD=yes
574825cf 41
48f8f266 42spotless: topclean
d7482997 43 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
44 @make -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes
574825cf 45
48f8f266 46clean: topclean
d7482997 47 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
48 @make -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes
574825cf 49
50# Remove Halibut output files in the source directory (may
51# have been created by running, for example, `build/halibut
52# inputs/test.but').
48f8f266 53topclean:
574825cf 54 rm -f *.html output.* *.tar.gz
55
56# Make a release archive. If $(VERSION) is specified, this will
57# also contain a `manifest' file which will be used to decide the
58# version number automatically.
59release:
60 find . -name CVS -prune -o -name build -prune -o -name reltmp -prune \
61 -o -type d -exec mkdir -p reltmp/$(RELDIR)/{} \;
62 find . -name CVS -prune -o -name build -prune -o -name reltmp -prune \
63 -o -name '*.orig' -prune -o -name '*.rej' -prune \
64 -o -name '*.txt' -prune -o -name '*.html' -prune \
65 -o -name '*.1' -prune -o -name '.cvsignore' -prune \
66 -o -name '*.gz' -prune -o -name '.[^.]*' -prune \
67 -o -type f -exec ln -s $(PWD)/{} reltmp/$(RELDIR)/{} \;
68 if test "x$(VERSION)y" != "xy"; then \
69 (cd reltmp/$(RELDIR); \
70 find . -name '*.[ch]' -exec md5sum {} \; \
71 ) > reltmp/$(RELDIR)/manifest; \
72 echo "-DVERSION=\"$(VERSION)\"" > reltmp/$(RELDIR)/version; \
73 fi
74 tar chzvCf reltmp - $(RELDIR) > $(RELDIR).tar.gz
75 rm -rf reltmp
76
d7482997 77else
78
79# The `real' makefile part.
80
81CFLAGS += -Wall -W
82
83ifdef TEST
84CFLAGS += -DLOGALLOC
85LIBS += -lefence
86endif
87
d7482997 88ifndef VER
89ifdef VERSION
90VER := $(VERSION)
91endif
92endif
93ifdef VER
574825cf 94VDEF = -DVERSION=\"$(VER)\"
95else
96VDEF = `(cd $(SRC); md5sum -c manifest && cat version)`
d7482997 97endif
98
05a1519d 99halibut:
100
d7482997 101SRC := ../
102
05a1519d 103LIBCHARSET_SRCDIR = $(SRC)charset/
104LIBCHARSET_OBJDIR = ./#
105LIBCHARSET_OBJPFX = cs-#
106LIBCHARSET_GENPFX = charset-#
107MD = -MD
108CFLAGS += -I$(LIBCHARSET_SRCDIR) -I$(LIBCHARSET_OBJDIR)
109include $(LIBCHARSET_SRCDIR)Makefile
110
d7482997 111MODULES := main malloc ustring error help licence version misc tree234
112MODULES += input keywords contents index style biblio
43341922 113MODULES += bk_text bk_xhtml bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf
e5cd393f 114MODULES += winhelp psdata wcwidth
d7482997 115
05a1519d 116OBJECTS := $(addsuffix .o,$(MODULES)) $(LIBCHARSET_OBJS)
d7482997 117DEPS := $(addsuffix .d,$(MODULES))
118
119halibut: $(OBJECTS)
120 $(CC) $(LFLAGS) -o halibut $(OBJECTS) $(LIBS)
121
122%.o: $(SRC)%.c
123 $(CC) $(CFLAGS) -MD -c $<
124
125version.o: FORCE
126 $(CC) $(VDEF) -MD -c $(SRC)version.c
127
128spotless:: clean
129 rm -f *.d
130
131clean::
132 rm -f *.o halibut core
133
134FORCE: # phony target to force version.o to be rebuilt every time
135
136-include $(DEPS)
137
138endif