Bug in utoi(), which made it ignore a leading minus sign when
[sgt/halibut] / Makefile
index ae1a5c9..6af0dc2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,28 @@
 # Currently depends on GNU make, because:
 #  - the Makefile uses GNU ifdef / ifndef commands and GNU make `%'
 #    pattern rules
+#  - we use .PHONY
+
+prefix=/usr/local
+exec_prefix=$(prefix)
+bindir=$(exec_prefix)/bin
+INSTALL=install -c
+
+.PHONY: all install clean spotless topclean release
+
+ifdef RELEASE
+ifndef VERSION
+VERSION := $(RELEASE)
+endif
+else
+CFLAGS += -g
+endif
+
+ifeq (x$(VERSION)y,xy)
+RELDIR := halibut
+else
+RELDIR := halibut-$(VERSION)
+endif
 
 # `make' from top level will build in directory `build'
 # `make BUILDDIR=foo' from top level will build in directory foo
@@ -20,56 +42,75 @@ else
 BUILDDIR := build
 endif
 endif
-all:
+
+all install:
        @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
-       @make -C $(BUILDDIR) -f ../Makefile REALBUILD=yes
+       @$(MAKE) -C $(BUILDDIR) -f ../Makefile $@ REALBUILD=yes
+
 spotless: topclean
        @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
-       @make -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes
+       @$(MAKE) -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes
+
 clean: topclean
        @test -d $(BUILDDIR) || mkdir $(BUILDDIR)
-       @make -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes
+       @$(MAKE) -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes
+
+# Remove Halibut output files in the source directory (may
+# have been created by running, for example, `build/halibut
+# inputs/test.but').
 topclean:
-       # Remove Halibut output files in the source directory (may
-       # have been created by running, for example, `build/halibut
-       # inputs/test.but').
-       rm -f *.html output.*
+       rm -f *.html output.* *.tar.gz
+
+# Make a release archive. If $(VERSION) is specified, this will
+# also contain a `manifest' file which will be used to decide the
+# version number automatically.
+release: release.sh
+       ./release.sh $(RELDIR) $(VERSION)
+
 else
 
 # The `real' makefile part.
 
-CFLAGS += -Wall -W
+CFLAGS += -Wall -W -ansi -pedantic
 
 ifdef TEST
 CFLAGS += -DLOGALLOC
 LIBS += -lefence
 endif
 
-ifdef RELEASE
-ifndef VERSION
-VERSION := $(RELEASE)
-endif
-else
-CFLAGS += -g
-endif
-
 ifndef VER
 ifdef VERSION
 VER := $(VERSION)
 endif
 endif
 ifdef VER
-VDEF := -DVERSION=\"$(VER)\"
+VDEF = -DVERSION=\"$(VER)\"
+else
+VDEF = `(cd $(SRC); md5sum -c manifest >/dev/null 2>&1 && cat version)`
 endif
 
+all: halibut
+
 SRC := ../
 
+ifeq ($(shell test -d $(SRC)charset && echo yes),yes)
+LIBCHARSET_SRCDIR = $(SRC)charset/
+else
+LIBCHARSET_SRCDIR = $(SRC)../charset/
+endif
+LIBCHARSET_OBJDIR = ./#
+LIBCHARSET_OBJPFX = cs-#
+LIBCHARSET_GENPFX = charset-#
+MD = -MD
+CFLAGS += -I$(LIBCHARSET_SRCDIR) -I$(LIBCHARSET_OBJDIR)
+include $(LIBCHARSET_SRCDIR)Makefile
+
 MODULES := main malloc ustring error help licence version misc tree234
-MODULES += input keywords contents index style biblio
-MODULES += bk_text bk_xhtml bk_whlp bk_man
-MODULES += winhelp
+MODULES += input in_afm in_pf in_sfnt keywords contents index biblio
+MODULES += bk_text bk_html bk_whlp bk_man bk_info bk_paper bk_ps bk_pdf
+MODULES += winhelp deflate psdata wcwidth
 
-OBJECTS := $(addsuffix .o,$(MODULES))
+OBJECTS := $(addsuffix .o,$(MODULES)) $(LIBCHARSET_OBJS)
 DEPS := $(addsuffix .d,$(MODULES))
 
 halibut: $(OBJECTS)
@@ -87,6 +128,10 @@ spotless:: clean
 clean::
        rm -f *.o halibut core
 
+install:
+       $(INSTALL) -m 755 halibut $(bindir)/halibut
+       $(MAKE) -C ../doc install prefix="$(prefix)" INSTALL="$(INSTALL)"
+
 FORCE: # phony target to force version.o to be rebuilt every time
 
 -include $(DEPS)