Mac OS X gcc warns about a signed/unsigned comparison here. Explicit cast.
[sgt/halibut] / Makefile
CommitLineData
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
d7482997 12
a4d3c848 13prefix=/usr/local
14exec_prefix=$(prefix)
15bindir=$(exec_prefix)/bin
16INSTALL=install -c
17
574825cf 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
d7482997 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
574825cf 42
a4d3c848 43all install:
d7482997 44 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
1b7cc907 45 @$(MAKE) -C $(BUILDDIR) -f ../Makefile $@ REALBUILD=yes
574825cf 46
48f8f266 47spotless: topclean
d7482997 48 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
1b7cc907 49 @$(MAKE) -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes
574825cf 50
48f8f266 51clean: topclean
d7482997 52 @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
1b7cc907 53 @$(MAKE) -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes
574825cf 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').
48f8f266 58topclean:
574825cf 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.
dc69abf1 64release: release.sh
65 ./release.sh $(RELDIR) $(VERSION)
574825cf 66
d7482997 67else
68
69# The `real' makefile part.
70
71CFLAGS += -Wall -W
72
73ifdef TEST
74CFLAGS += -DLOGALLOC
75LIBS += -lefence
76endif
77
d7482997 78ifndef VER
79ifdef VERSION
80VER := $(VERSION)
81endif
82endif
83ifdef VER
574825cf 84VDEF = -DVERSION=\"$(VER)\"
85else
86VDEF = `(cd $(SRC); md5sum -c manifest && cat version)`
d7482997 87endif
88
a4d3c848 89all: halibut
05a1519d 90
d7482997 91SRC := ../
92
dc69abf1 93ifeq ($(shell test -d $(SRC)charset && echo yes),yes)
05a1519d 94LIBCHARSET_SRCDIR = $(SRC)charset/
dc69abf1 95else
96LIBCHARSET_SRCDIR = $(SRC)../charset/
97endif
05a1519d 98LIBCHARSET_OBJDIR = ./#
99LIBCHARSET_OBJPFX = cs-#
100LIBCHARSET_GENPFX = charset-#
101MD = -MD
102CFLAGS += -I$(LIBCHARSET_SRCDIR) -I$(LIBCHARSET_OBJDIR)
103include $(LIBCHARSET_SRCDIR)Makefile
104
d7482997 105MODULES := main malloc ustring error help licence version misc tree234
106MODULES += input keywords contents index style biblio
78c73085 107MODULES += bk_text bk_html bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf
e5cd393f 108MODULES += winhelp psdata wcwidth
d7482997 109
05a1519d 110OBJECTS := $(addsuffix .o,$(MODULES)) $(LIBCHARSET_OBJS)
d7482997 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
a4d3c848 128install:
129 $(INSTALL) -m 755 halibut $(bindir)/halibut
130 $(MAKE) -C ../doc install prefix="$(prefix)" INSTALL="$(INSTALL)"
131
d7482997 132FORCE: # phony target to force version.o to be rebuilt every time
133
134-include $(DEPS)
135
136endif