chiark / gitweb /
build, debian/: Add a `configure' script to make things easier.
[preload-hacks] / configure
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..635c9c0
--- /dev/null
+++ b/configure
@@ -0,0 +1,81 @@
+#! /bin/sh -e
+###
+### Cheesy configuration script.
+###
+### (c) 2018 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the preload-hacks package.
+###
+### Preload-hacks are free software; you can redistribute it and/or modify
+### them 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.
+###
+### Preload-hacks are 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 preload-hacks; if not, write to the Free Software Foundation, Inc.,
+### 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+## Check for a `help' option.
+case $1,$# in
+  ,0) ;;
+  -h,* | --help,*)
+    echo "usage: $0 [--VAR=VAL ...] -- [VAR=VAL ...]"
+    exit 0
+    ;;
+esac
+
+## Find a relative path to the source directory.
+case $0 in */*) ;; *) echo >&2 "$0: invoke as PATH/configure"; exit 2 ;; esac
+srcdir=${0%/*}
+
+## Build the actual makefile.
+rm -f Makefile.new
+cat >Makefile.new <<EOF
+### -*-makefile-*-
+srcdir = $srcdir
+include \$(srcdir)/Make.rules
+EOF
+
+## Build a configuration fragment.
+rm -f config.mk.new
+exec 3>config.mk.new
+cat >&3 <<EOF
+### -*-makefile-*-
+
+## Settings from \`configure'.
+EOF
+
+## Parse the options.
+while :; do
+  case $1,$# in
+    ,0) break ;;
+    --,*) shift; break ;;
+    --*=*) o=${1#--}; k=${o%%=*} v=${o#*=}; echo >&3 "$k = $v" ;;
+    --*,*) k=${1#--}; echo >&3 "$k = t" ;;
+    *) break ;;
+  esac
+  shift
+done
+
+## Parse any remaining assignments.
+while :; do
+  case $1,$# in
+    ,0) break ;;
+    *=*) k=${1%%=*} v=${1#*=}; echo >&3 "$k = $v" ;;
+    *) echo >&2 "$0: unexpected argument $1"; exit 2 ;;
+  esac
+  shift
+done
+
+## All over.
+exec 3>&-
+mv config.mk.new config.mk
+mv Makefile.new Makefile