@@@ Makefile, Project.mk: Replace the build system.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 7 Sep 2020 01:16:15 +0000 (02:16 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 7 Sep 2020 16:50:22 +0000 (17:50 +0100)
Abolish Autoconf, and the awful `m4' thing.  The new build system
scrapes most of the information it needs out of the `docstrip' input.

@@@ FIXME cfd notice on the Makefile?

.gitignore
Makefile [new file with mode: 0644]
Makefile.m4 [deleted file]
Project.mk [new file with mode: 0644]
configure.in [deleted file]
debian/rules

index 2e9d025..ae44a24 100644 (file)
@@ -1,32 +1,16 @@
-*.ans
-*.aux
 *.def
 *.dvi
-*.ps
-*.pdf
 *.fd
-*.idx
-*.ilg
-*.ind
 *.log
-*.lot
+*.pdf
+*.ps
 *.sty
-*.thm
-*.tmp
-*.toc
-Makefile
-Makefile.am
-Makefile.in
-aclocal.m4
-config.cache
-config.status
-configure
-doafter.tex
-mdwkey.tex
 *.tar.gz
-COPYING
-autom4te.cache
-build
-gpl.tex
-install-sh
-missing
+*.thm
+
+/COPYING
+/auto-version
+/gpl.tex
+
+/doafter.tex
+/mdwkey.tex
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..a2d9dd3
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,250 @@
+### -*-makefile-*-
+###
+### Build script for TeX packages
+###
+### (c) 2020 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+
+###--------------------------------------------------------------------------
+### Extension points.
+
+all::
+.PHONY: all
+
+install::
+.PHONY: install
+
+uninstall::
+.PHONY: uninstall
+
+check::
+.PHONY: check
+
+clean::; rm -f $(CLEANFILES)
+.PHONY: clean
+
+realclean:: clean; rm -f $(REALCLEANFILES)
+.PHONY: clean
+
+distdir:: recreate-distdir
+.PHONY: distdir
+
+###--------------------------------------------------------------------------
+### Project identification.
+
+VERSION                        := $(shell ./auto-version)
+DISTFILES              += auto-version
+
+distdir:: recreate-distdir
+       $(v_at)echo "$(VERSION)" >$(distdir)/RELEASE
+
+###--------------------------------------------------------------------------
+### Tools.
+
+TEX                     = tex
+DVILATEX                = latex
+PDFLATEX                = pdflatex
+DVIPS                   = dvips
+
+###--------------------------------------------------------------------------
+### Installation directories.
+
+## Determine a sensible TeX base directory.
+prefix                  = /usr/local
+texmfdir               := $(shell \
+       for d in $(prefix)/share/texmf $(prefix)/lib/texmf $(prefix)/texmf; do \
+         if [ -d $$d ]; then echo $$d; exit 0; fi; \
+       done; \
+       echo /invalid/)
+
+ifeq ($(texmfdir),/invalid/)
+  $(error "Failed to choose a TeX installation directory.")
+endif
+
+INSTALLDIRS            += pkglatex
+pkglatexdir             = $(texmfdir)/tex/latex/$(PACKAGE)
+
+INSTALLDIRS            += pkgdoc
+pkgdocdir               = $(texmfdir)/doc/latex/$(PACKAGE)
+
+###--------------------------------------------------------------------------
+### Preliminary definitions.
+
+.SECONDEXPANSION: # sorry
+
+## Silent-rules.
+V                       = 0
+
+v_at                    = $(v_at_$V)
+v_at_0                  = @
+
+v_tag                   = $(call v_tag_$V,$1,$2)
+v_tag_0                         = @printf "  %-8s %s\n" "$1" "$2";
+
+v_null                  = $(v_null_$V)
+v_null_0                = >/dev/null
+
+v_quiet                         = $(v_quiet_$V)
+v_quiet_0               = -q
+
+## Runes for building rules.
+define output-targets
+$$(firstword $$($3_OUT)): $3 $4
+       $$(call v_tag,$2,$$<)$1 $$< $$(v_null)
+$$(wordlist 2,$$(words $$($3_OUT)),$$($3_OUT)): \
+       $$(firstword $$($3_OUT))
+endef
+
+###--------------------------------------------------------------------------
+### Project specific definitions.
+
+include Project.mk
+DISTFILES              += Project.mk
+
+###--------------------------------------------------------------------------
+### Parse the `docstrip' installation files.
+
+parse-names             = $(shell \
+       sed -n '/^\\mdwgen/,$$ s:^.*\\$1 *{\([^}]*\)}.*$$:\1:p' $2 | sort -u)
+
+define parse-insfile
+$1_DTX := $$(call parse-names,from,$1)
+$1_OUT := $$(call parse-names,mdwf,$1)
+endef
+$(foreach i,$(INS), $(eval $(call parse-insfile,$i)))
+
+DTX                    += $(sort $(foreach i,$(INS), $($i_DTX)))
+OUT                    += $(sort $(foreach i,$(INS), $($i_OUT)))
+
+###--------------------------------------------------------------------------
+### Extract output files from the `doc' files.
+
+all:: $(OUT)
+$(foreach i,$(INS), $(eval $(call output-targets,$$(TEX),TEX,$i,$($i_DTX))))
+
+DISTFILES              += $(INS)
+DISTFILES              += $(sort $(DTX) $(EXTRA))
+CLEANFILES             += $(addsuffix .log,$(basename $(INS)))
+DISTFILES              += $(OUT)
+REALCLEANFILES         += $(OUT)
+
+###--------------------------------------------------------------------------
+### Build the documentation.
+
+## The main rune for running LaTeX.
+##
+## We run LaTeX in a subdirectory to prevent the temporary files (e.g., the
+## `.aux' files) from interfering with each other.  The `\jobname' isn't
+## enough, because we might be building DVI and PDF versions of the same
+## document at the same time.
+run-latex               = \
+       rm -rf t.$@/ && mkdir t.$@/ && cd t.$@/ && \
+       TEXINPUTS=..:$$TEXINPUTS && export TEXINPUTS && \
+       $1 "\def\indexing{n} \nonstopmode \input $<" $(v_null) && \
+       $1 "\def\indexing{y} \nonstopmode \input $<" $(v_null) && \
+       makeindex $(v_quiet) -s gind.ist $*.idx $(v_null) && \
+       $1 "\def\indexing{n} \nonstopmode \input $<" $(v_null) && \
+       mv $@ ../ && cd ../ && rm -rf t.$@/
+clean::; rm -rf t.*/
+
+## Good old-fashioned DVI.
+DVI                     = $(addsuffix .dvi,$(basename $(DTX)))
+pkgdoc_FILES           += $(DVI)
+all:: $(DVI)
+%.dvi: %.dtx $(OUT) $(EXTRA)
+       $(call v_tag,DVILATEX,$@)$(call run-latex,$(DVILATEX))
+%.dvi: %.tex $(OUT) $(EXTRA)
+       $(call v_tag,DVILATEX,$@)$(call run-latex,$(DVILATEX))
+DISTFILES              += $(DVI)
+REALCLEANFILES         += $(DVI)
+
+## Build PostScript from the DVI.
+PS                      = $(addsuffix .ps,$(basename $(DTX)))
+pkgdoc_FILES           += $(PS)
+all:: $(PS)
+%.ps: %.dvi
+       $(call v_tag,DVIPS,$@)$(DVIPS) $(v_quiet) -o $@ $<
+DISTFILES              += $(PS)
+REALCLEANFILES         += $(PS)
+
+## Build PDF using PDFTeX.
+PDF                     = $(addsuffix .pdf,$(basename $(DTX)))
+pkgdoc_FILES           += $(PDF)
+all:: $(PDF)
+%.pdf: %.dtx $(OUT) $(EXTRA)
+       $(call v_tag,PDFLATEX,$@)$(call run-latex,$(PDFLATEX))
+%.pdf: %.tex $(OUT) $(EXTRA)
+       $(call v_tag,PDFLATEX,$@)$(call run-latex,$(PDFLATEX))
+DISTFILES              += $(PDF)
+REALCLEANFILES         += $(PDF)
+
+###--------------------------------------------------------------------------
+### Installation.
+
+install-targets                 = $(foreach d,$(INSTALLDIRS), install/$d)
+install:: $(install-targets)
+$(install-targets): install/%: $$($$*_FILES)
+       $(v_at)mkdir -p $(DESTDIR)$($*dir)
+       $(call v_tag,INSTALL,$($*dir))install -m$(or $($*_FILEMODE),644) \
+               $($*_FILES) $(DESTDIR)$($*dir)
+
+uninstall-targets       = $(foreach d,$(INSTALLDIRS), uninstall/$d)
+uninstall:: $(uninstall-targets)
+$(uninstall-targets): uninstall/%: $$($$*_FILES)
+       $(call v_tag,UNINSTALL,$($*dir))rm -f \
+               $(addprefix $(DESTDIR)$($*dir)/,$($*_FILES))
+
+###--------------------------------------------------------------------------
+### Distribution.
+
+DISTFILES              += COPYING $(wildcard README)
+DISTFILES              += Makefile
+
+DISTFILES              += debian/control debian/rules
+DISTFILES              += debian/copyright debian/changelog
+DISTFILES              += debian/compat
+
+distdir                         = $(PACKAGE)-$(VERSION)
+tarball                         = $(distdir).tar.gz
+
+distdir:: recreate-distdir $(DISTFILES)
+       $(v_at)set -e; \
+       for i in $(DISTFILES); do \
+         case $$i in */*) mkdir -p $(distdir)/$${i%/*} ;; esac; \
+         ln $$i $(distdir)/$$i; \
+       done
+
+dist: distdir
+       $(call v_tag,TAR,$(tarball))tar chzf $(tarball) $(distdir)
+       $(v_at)rm -rf $(distdir)/
+.PHONY: dist
+CLEANFILES             += $(tarball)
+clean::; rm -rf $(distdir)/
+
+recreate-distdir:
+       $(v_at)rm -rf $(distdir)/
+       $(v_at)mkdir $(distdir)
+.PHONY: recreate-distdir
+
+distcheck: dist
+       rm -rf _distcheck/
+       mkdir _distcheck/ && cd _distcheck/ && \
+               tar xzf ../$(tarball) && cd $(distdir)/ && \
+               $(MAKE) check && \
+               $(MAKE) install texmfdir=../_install && \
+               $(MAKE) realclean && \
+               $(MAKE) install texmfdir=../_install && \
+               $(MAKE) uninstall texmfdir=../_install && \
+               $(MAKE) install DESTDIR=../_root && \
+               $(MAKE) uninstall DESTDIR=../_root && \
+               cd ../../ && \
+               find _distcheck/_install/ _distcheck/_root ! -type d | \
+                       diff -u - /dev/null && \
+               rm -rf _distcheck
+.PHONY: distcheck
+clean::; rm -rf _distcheck/
+
+###----- That's all, folks --------------------------------------------------
diff --git a/Makefile.m4 b/Makefile.m4
deleted file mode 100644 (file)
index 91062fa..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-## -*-makefile-*-
-##
-## Build system for mdwtools
-##
-## (c) 2002 Mark Wooding
-##
-
-##----- Licensing notice ----------------------------------------------------
-##
-## This file is part of the mdwtools LaTeX package collection.
-##
-## mdwtools is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## mdwtools is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with mdwtools; if not, write to the Free Software Foundation,
-## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-AUTOMAKE_OPTIONS = foreign
-
-pkglatexdir = ${texmfdir}/tex/latex/${PACKAGE}
-pkgdocdir = ${texmfdir}/doc/latex/${PACKAGE}
-
-define(`addsuffix', `patsubst(`$1', `\>', `$2')')
-define(`BASE', `\
-       at centre cmtt colour crypto doafter exercise footnote mdwkey \
-       mdwlist mdwmath mdwref mdwtab mdwthm poetry slowbox sverb syntax')
-
-AUX = mdwtools.tex gpl.tex
-SRC = addsuffix(BASE, `.dtx')
-DVI = addsuffix(BASE, `.dvi') mdwtools.dvi
-PS = addsuffix(BASE, `.ps') mdwtools.ps
-PDF = addsuffix(BASE, `.pdf') mdwtools.pdf
-OBJ = \
-       at.sty \
-       cmtt.sty mttcmtt.fd mttenc.def \
-       centre.sty \
-       colour.sty \
-       crypto.sty \
-       doafter.sty \
-       doafter.tex \
-       exercise.sty \
-       footnote.sty \
-       mdwkey.sty \
-       mdwlist.sty \
-       mdwmath.sty \
-       mdwref.sty \
-       mdwtab.sty mathenv.sty mtcolour.sty mtcolor.sty \
-       mdwthm.sty mdwmargin.thm \
-       poetry.sty \
-       slowbox.sty \
-       sverb.sty svcolor.sty svcolour.sty svsplit.sty \
-       syntax.sty
-
-pkglatex_DATA = $(OBJ) mdwtools.tex
-pkgdoc_DATA = $(DVI) $(PS) $(PDF)
-
-SUFFIXES = .dtx .tex .dvi .ps
-define(`run_latex', `rm -rf t.$`'@/ && mkdir t.$`'@/ && \
-       cd t.$`'@/ && \
-       TEXINPUTS=..:$$TEXINPUTS && export TEXINPUTS && \
-       $1 "\def\indexing{n} \nonstopmode \input $<" && \
-       $1 "\def\indexing{y} \nonstopmode \input $<" && \
-       makeindex -s gind.ist $`'*.idx && \
-       $1 "\def\indexing{n} \nonstopmode \input $<" && \
-       mv $`'@ ../ && cd ../ && rm -rf t.$`'@/')
-
-.dtx.dvi:; run_latex(`latex')
-.tex.dvi:; run_latex(`latex')
-.dtx.pdf:; run_latex(`pdflatex')
-.tex.pdf:; run_latex(`pdflatex')
-.dvi.ps:; dvips -e0 -o $@ $<
-clean-local::; rm -rf t.*/
-
-$(DVI) $(PDF): gpl.tex $(OBJ) mdwtools.tex
-
-$(wordlist 2,$(words $(OBJ)),$(OBJ)): $(firstword $(OBJ))
-$(firstword $(OBJ)): $(SRC) mdwtools.ins
-       tex mdwtools.ins
-
-EXTRA_DIST = $(SRC) $(AUX) $(DVI) $(OBJ) $(PS) $(PDF) \
-       mdwtools.ins Makefile.m4
-
-MAINTAINERCLEANFILES = $(OBJ) $(DVI) $(PS) $(PDF)
-CLEANFILES = *.tmp *.aux *.idx *.ilg *.log *.toc *.ind *.lot *.ans
-
-Makefile.am: Makefile.m4
-       m4 $(srcdir)/Makefile.m4 >Makefile.am.new
-       mv Makefile.am.new $(srcdir)/Makefile.am
-
-dist-hook::
-       echo $(VERSION) >$(distdir)/RELEASE
-EXTRA_DIST += auto-version
-
-EXTRA_DIST += debian/changelog debian/control debian/copyright debian/compat
-EXTRA_DIST += debian/rules
-
-.PHONY: dvi
-
-##----- That's all, folks ---------------------------------------------------
diff --git a/Project.mk b/Project.mk
new file mode 100644 (file)
index 0000000..36eb771
--- /dev/null
@@ -0,0 +1,43 @@
+### -*-makefile-gmake-*-
+###
+### Package-specfic definitions for the build script
+###
+### (c) 2020 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the `mdwtools' LaTeX package collection.
+###
+### `mdwtools' is free software: you can redistribute it and/or modify it
+### under the terms of the GNU General Public License as published by the
+### Free Software Foundation; either version 2 of the License, or (at your
+### option) any later version.
+###
+### `mdwtools' is distributed in the hope that it will be useful, but
+### WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+### General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with `mdwtools'.  If not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+## Package identification.
+PACKAGE                         = mdwtools
+
+## Installation files.
+INS                     = mdwtools.ins
+
+## Install all of our output files in the LaTeX directory.
+pkglatex_FILES         += $(OUT)
+
+## Also format the main `mdwtools.tex' file.  Things will depend on this.
+DTX                    += mdwtools.tex
+EXTRA                  += mdwtools.tex
+pkglatex_FILES         += mdwtools.tex
+
+## Format the licence text.
+EXTRA                  += gpl.tex
+
+###----- That's all, folks --------------------------------------------------
diff --git a/configure.in b/configure.in
deleted file mode 100644 (file)
index 4a4ec53..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-dnl -*-autoconf-*-
-dnl
-dnl Configuration script for mdwtools
-dnl
-dnl (c) 2002 Mark Wooding
-dnl
-
-dnl ----- Licensing notice --------------------------------------------------
-dnl
-dnl This file is part of the mdwtools LaTeX package collection.
-dnl
-dnl mdwtools is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl mdwtools is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-dnl GNU General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with mdwtools; if not, write to the Free Software Foundation,
-dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-mdw_AUTO_VERSION
-AC_INIT(mdwtools, AUTO_VERSION, mdw@distorted.org.uk)
-AC_CONFIG_SRCDIR(mdwtools.ins)
-AC_CONFIG_AUX_DIR(.)
-AM_INIT_AUTOMAKE(foreign)
-mdw_DIR_TEXMF
-AC_OUTPUT(Makefile)
-
-dnl ----- That's all, folks -------------------------------------------------
index e8a488a..5982eb0 100644 (file)
@@ -2,6 +2,9 @@
 
 %:; dh $@ --parallel --with tex
 
+override_dh_auto_install:
+       dh_auto_install -- texmfdir=/usr/share/texmf
+
 override_dh_clean:
        dh_clean
        rm -f *.dvi *.ps *.pdf *.sty *.fd *.thm