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