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