| 1 | #! /bin/sh -e |
| 2 | ### |
| 3 | ### Cheesy configuration script. |
| 4 | ### |
| 5 | ### (c) 2018 Straylight/Edgeware |
| 6 | ### |
| 7 | |
| 8 | ###----- Licensing notice --------------------------------------------------- |
| 9 | ### |
| 10 | ### This file is part of the preload-hacks package. |
| 11 | ### |
| 12 | ### Preload-hacks are free software; you can redistribute it and/or modify |
| 13 | ### them under the terms of the GNU General Public License as published by |
| 14 | ### the Free Software Foundation; either version 2 of the License, or (at |
| 15 | ### your option) any later version. |
| 16 | ### |
| 17 | ### Preload-hacks are distributed in the hope that it will be useful, but |
| 18 | ### WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
| 20 | ### Public License for more details. |
| 21 | ### |
| 22 | ### You should have received a copy of the GNU General Public License along |
| 23 | ### with preload-hacks; if not, write to the Free Software Foundation, Inc., |
| 24 | ### 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | |
| 26 | ## Check for a `help' option. |
| 27 | case $1,$# in |
| 28 | ,0) ;; |
| 29 | -h,* | --help,*) |
| 30 | echo "usage: $0 [--VAR=VAL ...] -- [VAR=VAL ...]" |
| 31 | exit 0 |
| 32 | ;; |
| 33 | esac |
| 34 | |
| 35 | ## Find a relative path to the source directory. |
| 36 | case $0 in */*) ;; *) echo >&2 "$0: invoke as PATH/configure"; exit 2 ;; esac |
| 37 | srcdir=${0%/*} |
| 38 | |
| 39 | ## Build the actual makefile. |
| 40 | rm -f Makefile.new |
| 41 | cat >Makefile.new <<EOF |
| 42 | ### -*-makefile-*- |
| 43 | srcdir = $srcdir |
| 44 | include \$(srcdir)/Make.rules |
| 45 | EOF |
| 46 | |
| 47 | ## Build a configuration fragment. |
| 48 | rm -f config.mk.new |
| 49 | exec 3>config.mk.new |
| 50 | cat >&3 <<EOF |
| 51 | ### -*-makefile-*- |
| 52 | |
| 53 | ## Settings from \`configure'. |
| 54 | EOF |
| 55 | |
| 56 | ## Parse the options. |
| 57 | while :; do |
| 58 | case $1,$# in |
| 59 | ,0) break ;; |
| 60 | --,*) shift; break ;; |
| 61 | --*=*) o=${1#--}; k=${o%%=*} v=${o#*=}; echo >&3 "$k = $v" ;; |
| 62 | --*,*) k=${1#--}; echo >&3 "$k = t" ;; |
| 63 | *) break ;; |
| 64 | esac |
| 65 | shift |
| 66 | done |
| 67 | |
| 68 | ## Parse any remaining assignments. |
| 69 | while :; do |
| 70 | case $1,$# in |
| 71 | ,0) break ;; |
| 72 | *=*) k=${1%%=*} v=${1#*=}; echo >&3 "$k = $v" ;; |
| 73 | *) echo >&2 "$0: unexpected argument $1"; exit 2 ;; |
| 74 | esac |
| 75 | shift |
| 76 | done |
| 77 | |
| 78 | ## All over. |
| 79 | exec 3>&- |
| 80 | mv config.mk.new config.mk |
| 81 | mv Makefile.new Makefile |