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