From ba4d97a46a046f5170b58a29c8f1c0524c63694c Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 22 Mar 2008 12:52:34 +0000 Subject: [PATCH] Uprate build system again, for new style. Use confsubst for building the scripts, which is a good excuse for adding it to the collection. --- .gitignore | 1 + Makefile.am | 171 ++++++++++++++++++++++++++++++++++++++++------------------- build-setup | 7 ++- configure.ac | 32 ++++++++--- confsubst | 89 +++++++++++++++++++++++++++++++ mdw-setup | 8 +-- mklinks.in | 11 ++-- 7 files changed, 249 insertions(+), 70 deletions(-) create mode 100755 confsubst diff --git a/.gitignore b/.gitignore index 336a211..c9055e0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ autom4te.cache missing install-sh acinclude.m4 +config diff --git a/Makefile.am b/Makefile.am index 7dcce91..3f87396 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,64 +1,127 @@ -## Process this file with Automake to generate `Makefile.in' -## -*-Makefile-*- -## -## Building the distribution -## -## (c) 1997 Mark Wooding -## - -##----- Licensing notice ---------------------------------------------------- -## -## This file is part of the Common Files Distribution (`common') -## -## `Common' 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. -## -## `Common' 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 `common'; if not, write to the Free Software Foundation, -## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -## --- What needs building --- - -bin_SCRIPTS = mklinks findlinks mdw-setup - -## --- Files to install in the repository --- - -pkgdata_DATA = \ - COPYING COPYING.LIB INSTALL \ - gpl.tex lgpl.tex gpl.texi lgpl.texi texinice.tex \ - mdwopt.c mdwopt.h \ - getdate.y getdate.h - -EXTRA_DIST = \ - aclocal.glob \ - $(pkgdata_DATA) $(pkgdata_SCRIPTS) mdw-setup \ - debian/control debian/copyright debian/rules debian/changelog - -pkgdata_SCRIPTS = \ - install-ac maninst - -dist-hook: - echo $(VERSION) >$(distdir)/RELEASE +### -*-makefile-*- +### +### Building the distribution +### +### (c) 1997 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This file is part of the Common Files Distribution (`common') +### +### `Common' 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. +### +### `Common' 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 `common'; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +bin_SCRIPTS = +pkgdata_SCRIPTS = +pkgdata_DATA = + +EXTRA_DIST = +CLEANFILES = + +###-------------------------------------------------------------------------- +### Handy variables. + +confsubst = $(srcdir)/confsubst +mkdir_p = $(srcdir)/config/install-sh -d + +###-------------------------------------------------------------------------- +### Main scripts. + +## mklinks +bin_SCRIPTS += mklinks +CLEANFILES += mklinks +EXTRA_DIST += mklinks.in + +mklinks: mklinks.in Makefile + $(confsubst) $(srcdir)/mklinks.in >$@.new \ + pkgdatadir=$(pkgdatadir) VERSION=$(VERSION) + chmod +x $@.new + mv $@.new $@ + +## findlinks +bin_SCRIPTS += findlinks +CLEANFILES += findlinks +EXTRA_DIST += findlinks.in + +findlinks: findlinks.in Makefile + $(confsubst) $(srcdir)/findlinks.in >$@.new \ + pkgdatadir=$(pkgdatadir) VERSION=$(VERSION) + chmod +x $@.new + mv $@.new $@ + +## mdw-setup +bin_SCRIPTS += mdw-setup +EXTRA_DIST += mdw-setup + +###-------------------------------------------------------------------------- +### Files to install. -install-data-hook: - $(mkinstalldirs) $(DESTDIR)$(aclocaldir) +## Licences. +pkgdata_DATA += COPYING COPYING.LIB +pkgdata_DATA += gpl.tex lgpl.tex gpl.texi lgpl.texi + +## Documentation. +pkgdata_DATA += INSTALL +pkgdata_DATA += texinice.tex + +## Useful code. +pkgdata_DATA += mdwopt.c mdwopt.h +pkgdata_DATA += getdate.y getdate.h + +## Scripts. +pkgdata_SCRIPTS += install-ac +pkgdata_SCRIPTS += maninst +pkgdata_SCRIPTS += confsubst + +EXTRA_DIST += $(pkgdata_DATA) +EXTRA_DIST += $(pkgdata_SCRIPTS) + +## Autoconf snippets. +EXTRA_DIST += aclocal.glob + +install-data-hook:: + $(mkdir_p) $(DESTDIR)$(aclocaldir) $(srcdir)/install-ac install \ $(srcdir)/aclocal.glob $(DESTDIR)$(aclocaldir) -uninstall-hook: + +uninstall-hook:: $(srcdir)/install-ac rm \ $(srcdir)/aclocal.glob $(DESTDIR)$(aclocaldir) -## --- Documentation --- +###-------------------------------------------------------------------------- +### Documentation. info_TEXINFOS = common.texi -## --- Cleaning up --- +###-------------------------------------------------------------------------- +### Other special tweaks. + +## Make `make distcheck' work. +DISTCHECK_CONFIGURE_FLAGS = \ + --with-aclocaldir='$${prefix}/share/aclocal' + +## Distribute the release number. +dist-hook:: + echo $(VERSION) >$(distdir)/RELEASE + +###-------------------------------------------------------------------------- +### Debian. + +EXTRA_DIST += debian/control +EXTRA_DIST += debian/copyright +EXTRA_DIST += debian/rules +EXTRA_DIST += debian/changelog -CLEANFILES = $(bin_SCRIPTS) +###----- That's all, folks -------------------------------------------------- diff --git a/build-setup b/build-setup index b923188..30cfaf8 100755 --- a/build-setup +++ b/build-setup @@ -1,4 +1,9 @@ #! /bin/sh +### Build setup script set -e -ln -sf aclocal.glob acinclude.m4 +case "$1" in + start) + ln -sf aclocal.glob acinclude.m4 + ;; +esac diff --git a/configure.ac b/configure.ac index 4f3c066..e5a9e88 100644 --- a/configure.ac +++ b/configure.ac @@ -23,17 +23,35 @@ dnl You should have received a copy of the GNU General Public License dnl along with `common'; if not, write to the Free Software Foundation, dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +dnl-------------------------------------------------------------------------- +dnl Initialization. + mdw_AUTO_VERSION AC_INIT([Common Files Distribution], AUTO_VERSION, - [mdw@distorted.org.uk], [cfd]) -AM_INIT_AUTOMAKE([foreign]) + [mdw@distorted.org.uk], [cfd]) AC_CONFIG_SRCDIR([mdw-setup]) +AC_CONFIG_AUX_DIR([config]) +AM_INIT_AUTOMAKE([foreign]) -AC_CACHE_CHECK([where to stash Autoconf macros], [aclocaldir], [ - aclocaldir=`aclocal --print-ac-dir` - if test $? -ne 0; then AC_MSG_ERROR([aclocal not installed]); fi -]) +dnl-------------------------------------------------------------------------- +dnl Finding installation directories. + +AC_ARG_WITH( + [aclocaldir], + AS_HELP_STRING([--with-aclocaldir=DIR], + [store autoconf snippets in DIR]), + [aclocaldir=$withval], + [AC_CACHE_CHECK([where to stash Autoconf macros], [mdw_cv_aclocaldir], [ + mdw_cv_aclocaldir=$(aclocal --print-ac-dir) + if test $? -ne 0; then AC_MSG_ERROR([aclocal not installed]); fi + ]) + aclocaldir=$mdw_cv_aclocaldir]) AC_SUBST([aclocaldir]) -AC_CONFIG_FILES([Makefile mklinks findlinks]) +dnl-------------------------------------------------------------------------- +dnl Output. + +AC_CONFIG_FILES([Makefile]) AC_OUTPUT + +dnl----- That's all, folks -------------------------------------------------- diff --git a/confsubst b/confsubst new file mode 100755 index 0000000..45a85c2 --- /dev/null +++ b/confsubst @@ -0,0 +1,89 @@ +#! /bin/sh +### -*-sh-*- +### +### Make autoconf-like substitutions in files +### +### (c) 2008 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This file is part of the Common Files Distribution (`common'). +### +### `Common' 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. +### +### `Common' 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 `common'; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set -e + +VERSION="@VERSION@" + +###-------------------------------------------------------------------------- +### Parse command line arguments. + +while [ $# -gt 0 ]; do + case $1 in + -h | --h | --he | --hel | --help) + cat <&2 + exit 1 + ;; + *) + break + ;; + esac + shift +done + +if [ $# -lt 1 ]; then + echo >&2 "Usage: confsubst FILE TAG=VALUE..." + exit 1 +fi +file=$1; shift + +###-------------------------------------------------------------------------- +### Main code. + +subst="" +for fixup; do + case "$fixup" in + *?=*?) ;; + *) echo >&2 "$0: bad substitution: $fixup"; exit 1 ;; + esac + tag=$(echo "$fixup" | sed 's/=.*$//') && \ + value=$(echo "$fixup" | sed 's/^[^=]*=//') && \ + subst="$subst s@$tag@$valueg;" +done + +sed "$subst" $file || exit $? + +###----- That's all, folks -------------------------------------------------- diff --git a/mdw-setup b/mdw-setup index 57dbd90..f60a45e 100755 --- a/mdw-setup +++ b/mdw-setup @@ -1,7 +1,7 @@ #! /bin/sh ### -*-sh-*- ### -### Create links to the repository +### Set up a new project ### ### (c) 1997 Mark Wooding ### @@ -66,7 +66,7 @@ fi ###-------------------------------------------------------------------------- ### Do any initial local stuff. -[ -x build-setup ] && ./build-setup start +if [ -x build-setup ]; then ./build-setup start; fi ###-------------------------------------------------------------------------- ### Grind through the Autoconf machinery. @@ -76,7 +76,7 @@ for i in configure.ac configure.in; do [ -f $i ] && configure=$i done if [ "$configure" ]; then - grep >/dev/null AM_PROG_LIBTOOL $configure && libtoolize + grep >/dev/null AM_PROG_LIBTOOL $configure && libtoolize -f find . -name Makefile.m4 -print | while read m4; do dir=$(echo $m4 | sed 's:/[^/]*$::') (cd $dir && @@ -99,6 +99,6 @@ fi ###-------------------------------------------------------------------------- ### Do any final local stuff. -[ -x build-setup ] && ./build-setup end +if [ -x build-setup ]; then ./build-setup end; fi ###------ That's all, folks ------------------------------------------------- diff --git a/mklinks.in b/mklinks.in index 0d57afd..fd126f2 100755 --- a/mklinks.in +++ b/mklinks.in @@ -71,10 +71,13 @@ done [ $# = 0 ] && set .links cat "$@" | while read name; do - base="$(echo $name | sed 's;^.*/;;')" - dir="$(echo $name | sed 's;/[^/]*$;;')" - mkdir -p "$dir" - [ -r "$pkgdatadir/$base" ] && ln -sf "$pkgdatadir/$base" "$name" + base="$(echo $name | sed 's:^.*/::')" + dir="$(echo $name | sed 's:^[^/]:./&:; s:/[^/]*$::')" + if [ -r "$pkgdatadir/$base" ]; then + mkdir -p "$dir" + rm -f "$name" + ln -sf "$pkgdatadir/$base" "$name" + fi done ###----- That's all, folks -------------------------------------------------- -- 2.11.0