Discard the 'master' makefile, in favour of using Automake for all
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 25 Jul 2011 18:08:35 +0000 (18:08 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 25 Jul 2011 18:08:35 +0000 (18:08 +0000)
builds of agedu. Building the man page from the .but file is included
in the Automake makefile, but omitted if configure can't find halibut,
in which case 'make clean' also won't destroy the now-non-rebuildable
agedu.1.

git-svn-id: svn://svn.tartarus.org/sgt/agedu@9245 cda61777-01e9-0310-a592-d414129be87e

Buildscr
GNUmakefile [deleted file]
Makefile.am
configure.ac
mkauto.sh [new file with mode: 0755]

index 76e5b2c..29075e4 100644 (file)
--- a/Buildscr
+++ b/Buildscr
@@ -4,19 +4,23 @@
 
 module agedu
 
-# Build the man page.
-in agedu do make doc
-
 in agedu do sed '/AC_INIT/s/6.66/r$(revision)/' configure.ac > tmp.ac
 in agedu do mv tmp.ac configure.ac
-in agedu do aclocal
-in agedu do autoconf
-in agedu do autoheader
-in agedu do automake -a --foreign
+in agedu do ./mkauto.sh
 in agedu do rm -rf autom4te.cache
 
+# Build the man page. This also tests the automake setup to ensure
+# configure actually works; but we use a self-delegation (i.e. do all
+# of this in a throwaway copy of the build directory) to avoid
+# accidentally shipping any outputs of configure. Instead we return
+# only the actual man page from the delegation environment.
+delegate -
+  in agedu do ./configure
+  in agedu do make doc
+  return agedu/*.1
+enddelegate
+
 in . do cp -R agedu agedu-r$(revision)
-in . do rm agedu-r$(revision)/GNUmakefile
 in . do tar chzvf agedu-r$(revision).tar.gz agedu-r$(revision)
 
 in agedu do halibut --html=manpage.html agedu.but
diff --git a/GNUmakefile b/GNUmakefile
deleted file mode 100644 (file)
index 30e061b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-# Makefile for agedu.
-
-prefix = /usr/local
-bindir = $(prefix)/bin
-mandir = $(prefix)/man
-man1dir = $(mandir)/man1
-
-INSTALL = install
-
-CFLAGS = -Wall --std=c99 -pedantic $(XFLAGS)
-
--include Makefile.local
-
-AGEDU_MODULES := agedu du alloc trie index html httpd fgetline licence
-AGEDU_OBJS := $(patsubst %,%.o,$(AGEDU_MODULES))
-
-ALLMODULES := $(sort $(AGEDU_MODULES))
-ALLOBJS := $(patsubst %,%.o,$(ALLMODULES))
-ALLDEPS := $(patsubst %,%.d,$(ALLMODULES))
-
-BINARIES = agedu
-
-binaries: $(BINARIES)
-
-agedu: config.h $(AGEDU_OBJS)
-       gcc $(LFLAGS) -o agedu $(AGEDU_OBJS)
-
-config.h: configure
-       ./configure -q && touch config.h
-       rm -f Makefile # we keep using _this_ Makefile
-
-configure: configure.ac
-       aclocal
-       autoconf
-       autoheader
-       automake -a --foreign
-
-INTERNALFLAGS=#
-
-$(ALLOBJS): %.o: %.c
-       gcc $(CFLAGS) -MM $*.c > $*.d
-       gcc $(CFLAGS) $(INTERNALFLAGS) -c $*.c
-
-MANPAGES = agedu.1
-
-doc: $(MANPAGES)
-$(MANPAGES): %.1: %.but
-       halibut --man=$*.1 $*.but
-
-clean:
-       rm -f $(ALLOBJS) $(ALLDEPS) $(MANPAGES) $(BINARIES)
-
-spotless: clean
-       rm -f config.h config.h.in config.log config.status configure
-       rm -f depcomp install-sh missing stamp-h1
-       rm -f Makefile.in aclocal.m4
-       rm -rf autom4te.cache .deps
-
--include $(ALLDEPS)
index 6c549a8..6b9da2b 100644 (file)
@@ -3,3 +3,18 @@ agedu_SOURCES = agedu.c du.c alloc.c trie.c index.c html.c httpd.c \
                 fgetline.c licence.c
 agedu_LDADD = $(LIBOBJS)
 man1_MANS = agedu.1
+
+# If Halibut is available to rebuild the man pages from their .but
+# source, then man pages are treated as derived files in the obvious
+# way, and deleted by 'make clean'. If Halibut is not available (the
+# typical case if someone has downloaded the source archive and rerun
+# mkauto.sh), the man pages are treated as source files by this
+# makefile.
+if HAVE_HALIBUT
+BUILT_MANS = $(man1_MANS)
+CLEANFILES = $(BUILT_MANS)
+.SUFFIXES = .but .1
+.but.1:
+       halibut --man=$@ $<
+doc: $(BUILT_MANS)
+endif
index 70a356e..5d774b0 100644 (file)
@@ -10,6 +10,8 @@ AM_INIT_AUTOMAKE
 AC_PROG_CC
 AC_PROG_CC_C99
 AC_PROG_INSTALL
+AC_CHECK_PROG([HALIBUT],[halibut],[yes],[no])
+AM_CONDITIONAL([HAVE_HALIBUT],[test "x$HALIBUT" = "xyes"])
 
 # Checks for libraries.
 
diff --git a/mkauto.sh b/mkauto.sh
new file mode 100755 (executable)
index 0000000..93670e9
--- /dev/null
+++ b/mkauto.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+aclocal && autoconf && autoheader && automake -a --foreign