Mac OS X gcc warns about a signed/unsigned comparison here. Explicit cast.
[sgt/halibut] / Makefile
... / ...
CommitLineData
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
13prefix=/usr/local
14exec_prefix=$(prefix)
15bindir=$(exec_prefix)/bin
16INSTALL=install -c
17
18ifdef RELEASE
19ifndef VERSION
20VERSION := $(RELEASE)
21endif
22else
23CFLAGS += -g
24endif
25
26ifeq (x$(VERSION)y,xy)
27RELDIR := halibut
28else
29RELDIR := halibut-$(VERSION)
30endif
31
32# `make' from top level will build in directory `build'
33# `make BUILDDIR=foo' from top level will build in directory foo
34ifndef REALBUILD
35ifndef BUILDDIR
36ifdef TEST
37BUILDDIR := test
38else
39BUILDDIR := build
40endif
41endif
42
43all install:
44 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
45 @$(MAKE) -C $(BUILDDIR) -f ../Makefile $@ REALBUILD=yes
46
47spotless: topclean
48 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
49 @$(MAKE) -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes
50
51clean: 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').
58topclean:
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.
64release: release.sh
65 ./release.sh $(RELDIR) $(VERSION)
66
67else
68
69# The `real' makefile part.
70
71CFLAGS += -Wall -W
72
73ifdef TEST
74CFLAGS += -DLOGALLOC
75LIBS += -lefence
76endif
77
78ifndef VER
79ifdef VERSION
80VER := $(VERSION)
81endif
82endif
83ifdef VER
84VDEF = -DVERSION=\"$(VER)\"
85else
86VDEF = `(cd $(SRC); md5sum -c manifest && cat version)`
87endif
88
89all: halibut
90
91SRC := ../
92
93ifeq ($(shell test -d $(SRC)charset && echo yes),yes)
94LIBCHARSET_SRCDIR = $(SRC)charset/
95else
96LIBCHARSET_SRCDIR = $(SRC)../charset/
97endif
98LIBCHARSET_OBJDIR = ./#
99LIBCHARSET_OBJPFX = cs-#
100LIBCHARSET_GENPFX = charset-#
101MD = -MD
102CFLAGS += -I$(LIBCHARSET_SRCDIR) -I$(LIBCHARSET_OBJDIR)
103include $(LIBCHARSET_SRCDIR)Makefile
104
105MODULES := main malloc ustring error help licence version misc tree234
106MODULES += input keywords contents index style biblio
107MODULES += bk_text bk_html bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf
108MODULES += winhelp psdata wcwidth
109
110OBJECTS := $(addsuffix .o,$(MODULES)) $(LIBCHARSET_OBJS)
111DEPS := $(addsuffix .d,$(MODULES))
112
113halibut: $(OBJECTS)
114 $(CC) $(LFLAGS) -o halibut $(OBJECTS) $(LIBS)
115
116%.o: $(SRC)%.c
117 $(CC) $(CFLAGS) -MD -c $<
118
119version.o: FORCE
120 $(CC) $(VDEF) -MD -c $(SRC)version.c
121
122spotless:: clean
123 rm -f *.d
124
125clean::
126 rm -f *.o halibut core
127
128install:
129 $(INSTALL) -m 755 halibut $(bindir)/halibut
130 $(MAKE) -C ../doc install prefix="$(prefix)" INSTALL="$(INSTALL)"
131
132FORCE: # phony target to force version.o to be rebuilt every time
133
134-include $(DEPS)
135
136endif