Add installation instructions.
[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
13# `make' from top level will build in directory `build'
14# `make BUILDDIR=foo' from top level will build in directory foo
15ifndef REALBUILD
16ifndef BUILDDIR
17ifdef TEST
18BUILDDIR := test
19else
20BUILDDIR := build
21endif
22endif
23all:
24 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
25 @make -C $(BUILDDIR) -f ../Makefile REALBUILD=yes
48f8f266 26spotless: topclean
d7482997 27 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
28 @make -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes
48f8f266 29clean: topclean
d7482997 30 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
31 @make -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes
48f8f266 32topclean:
33 # Remove Halibut output files in the source directory (may
34 # have been created by running, for example, `build/halibut
35 # inputs/test.but').
36 rm -f *.html output.*
d7482997 37else
38
39# The `real' makefile part.
40
41CFLAGS += -Wall -W
42
43ifdef TEST
44CFLAGS += -DLOGALLOC
45LIBS += -lefence
46endif
47
48ifdef RELEASE
49ifndef VERSION
50VERSION := $(RELEASE)
51endif
52else
53CFLAGS += -g
54endif
55
56ifndef VER
57ifdef VERSION
58VER := $(VERSION)
59endif
60endif
61ifdef VER
62VDEF := -DVERSION=\"$(VER)\"
63endif
64
65SRC := ../
66
67MODULES := main malloc ustring error help licence version misc tree234
68MODULES += input keywords contents index style biblio
7136a6c7 69MODULES += bk_text bk_xhtml bk_whlp bk_man
d7482997 70MODULES += winhelp
71
72OBJECTS := $(addsuffix .o,$(MODULES))
73DEPS := $(addsuffix .d,$(MODULES))
74
75halibut: $(OBJECTS)
76 $(CC) $(LFLAGS) -o halibut $(OBJECTS) $(LIBS)
77
78%.o: $(SRC)%.c
79 $(CC) $(CFLAGS) -MD -c $<
80
81version.o: FORCE
82 $(CC) $(VDEF) -MD -c $(SRC)version.c
83
84spotless:: clean
85 rm -f *.d
86
87clean::
88 rm -f *.o halibut core
89
90FORCE: # phony target to force version.o to be rebuilt every time
91
92-include $(DEPS)
93
94endif