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 |
7ce668da |
12 | # - we use .PHONY |
d7482997 |
13 | |
a4d3c848 |
14 | prefix=/usr/local |
15 | exec_prefix=$(prefix) |
16 | bindir=$(exec_prefix)/bin |
17 | INSTALL=install -c |
18 | |
7ce668da |
19 | .PHONY: all install clean spotless topclean release |
20 | |
574825cf |
21 | ifdef RELEASE |
22 | ifndef VERSION |
23 | VERSION := $(RELEASE) |
24 | endif |
25 | else |
26 | CFLAGS += -g |
27 | endif |
28 | |
29 | ifeq (x$(VERSION)y,xy) |
30 | RELDIR := halibut |
31 | else |
32 | RELDIR := halibut-$(VERSION) |
33 | endif |
34 | |
d7482997 |
35 | # `make' from top level will build in directory `build' |
36 | # `make BUILDDIR=foo' from top level will build in directory foo |
37 | ifndef REALBUILD |
38 | ifndef BUILDDIR |
39 | ifdef TEST |
40 | BUILDDIR := test |
41 | else |
42 | BUILDDIR := build |
43 | endif |
44 | endif |
574825cf |
45 | |
a4d3c848 |
46 | all install: |
d7482997 |
47 | @test -d $(BUILDDIR) || mkdir $(BUILDDIR) |
1b7cc907 |
48 | @$(MAKE) -C $(BUILDDIR) -f ../Makefile $@ REALBUILD=yes |
574825cf |
49 | |
48f8f266 |
50 | spotless: topclean |
d7482997 |
51 | @test -d $(BUILDDIR) || mkdir $(BUILDDIR) |
1b7cc907 |
52 | @$(MAKE) -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes |
574825cf |
53 | |
48f8f266 |
54 | clean: topclean |
d7482997 |
55 | @test -d $(BUILDDIR) || mkdir $(BUILDDIR) |
1b7cc907 |
56 | @$(MAKE) -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes |
574825cf |
57 | |
58 | # Remove Halibut output files in the source directory (may |
59 | # have been created by running, for example, `build/halibut |
60 | # inputs/test.but'). |
48f8f266 |
61 | topclean: |
574825cf |
62 | rm -f *.html output.* *.tar.gz |
63 | |
64 | # Make a release archive. If $(VERSION) is specified, this will |
65 | # also contain a `manifest' file which will be used to decide the |
66 | # version number automatically. |
dc69abf1 |
67 | release: release.sh |
68 | ./release.sh $(RELDIR) $(VERSION) |
574825cf |
69 | |
d7482997 |
70 | else |
71 | |
72 | # The `real' makefile part. |
73 | |
ee90d1f0 |
74 | CFLAGS += -Wall -W -ansi -pedantic |
7e2417cc |
75 | LIBS += -lm |
d7482997 |
76 | |
77 | ifdef TEST |
78 | CFLAGS += -DLOGALLOC |
79 | LIBS += -lefence |
80 | endif |
81 | |
d7482997 |
82 | ifndef VER |
83 | ifdef VERSION |
84 | VER := $(VERSION) |
85 | endif |
86 | endif |
87 | ifdef VER |
574825cf |
88 | VDEF = -DVERSION=\"$(VER)\" |
89 | else |
faaa472f |
90 | VDEF = `(cd $(SRC); md5sum -c manifest >& /dev/null && cat version)` |
d7482997 |
91 | endif |
92 | |
a4d3c848 |
93 | all: halibut |
05a1519d |
94 | |
d7482997 |
95 | SRC := ../ |
96 | |
dc69abf1 |
97 | ifeq ($(shell test -d $(SRC)charset && echo yes),yes) |
05a1519d |
98 | LIBCHARSET_SRCDIR = $(SRC)charset/ |
dc69abf1 |
99 | else |
100 | LIBCHARSET_SRCDIR = $(SRC)../charset/ |
101 | endif |
05a1519d |
102 | LIBCHARSET_OBJDIR = ./# |
103 | LIBCHARSET_OBJPFX = cs-# |
104 | LIBCHARSET_GENPFX = charset-# |
105 | MD = -MD |
106 | CFLAGS += -I$(LIBCHARSET_SRCDIR) -I$(LIBCHARSET_OBJDIR) |
107 | include $(LIBCHARSET_SRCDIR)Makefile |
108 | |
d7482997 |
109 | MODULES := main malloc ustring error help licence version misc tree234 |
44407fea |
110 | MODULES += input in_afm in_pf keywords contents index biblio |
78c73085 |
111 | MODULES += bk_text bk_html bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf |
7e2417cc |
112 | MODULES += winhelp deflate psdata wcwidth |
d7482997 |
113 | |
05a1519d |
114 | OBJECTS := $(addsuffix .o,$(MODULES)) $(LIBCHARSET_OBJS) |
d7482997 |
115 | DEPS := $(addsuffix .d,$(MODULES)) |
116 | |
117 | halibut: $(OBJECTS) |
118 | $(CC) $(LFLAGS) -o halibut $(OBJECTS) $(LIBS) |
119 | |
120 | %.o: $(SRC)%.c |
121 | $(CC) $(CFLAGS) -MD -c $< |
122 | |
123 | version.o: FORCE |
124 | $(CC) $(VDEF) -MD -c $(SRC)version.c |
125 | |
126 | spotless:: clean |
127 | rm -f *.d |
128 | |
129 | clean:: |
130 | rm -f *.o halibut core |
131 | |
a4d3c848 |
132 | install: |
133 | $(INSTALL) -m 755 halibut $(bindir)/halibut |
134 | $(MAKE) -C ../doc install prefix="$(prefix)" INSTALL="$(INSTALL)" |
135 | |
d7482997 |
136 | FORCE: # phony target to force version.o to be rebuilt every time |
137 | |
138 | -include $(DEPS) |
139 | |
140 | endif |