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