summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure104
1 files changed, 34 insertions, 70 deletions
diff --git a/configure b/configure
index b4dece3..9683b68 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
-name='configure' # Luke's configureation script
+name='configure' # Luke's configuration script
#version='1.0'
-# Copyright (C) 2009 Luke Shumaker
+# Copyright (C) 2009, 2016 Luke Shumaker
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -17,83 +17,47 @@ name='configure' # Luke's configureation script
# along with this program; see the file COPYING.
# If not, see <http://www.gnu.org/licenses>.
-srcdir=$(readlink -f `dirname "$0"`)
-
- _DESTDIR=''
- _prefix='/usr/local'
-_exec_prefix='$(prefix)'
- _bindir='$(exec_prefix)/bin'
- _sbindir='$(exec_prefix)/sbin'
- _libexecdir='$(exec_prefix)/libexec'
- _CONFIG="$@"
-vars='DESTDIR prefix exec_prefix bindir sbindir libexecdir CONFIG'
-if [ -f "$srcdir/config" ]; then . "$srcdir/config"; fi
+srcdir="$(dirname -- "$0")"
+outdir="."
error() {
- echo "$name: $1" >> /dev/stderr
+ echo "$name: $1" >&2
exit 1
}
-varargs=`echo "$vars " | sed -e 's/ */:,/g' -e 's/,$//'`
-args=`getopt -n "$name" -o "${sopt}" -l "${lopt}${varargs}" -- "$@"`
-if [ $? == 0 ]; then
- set -- $args
- while [ $# -gt 0 ]; do case "$1" in
+edit=(sed -E -e '')
+setvar() {
+ edit+=(-e "s@^(\s*$1\s*:?=).*@\1 $2@")
+}
+setvar topsrcdir "$srcdir"
+
+vars=($(<"$srcdir/config.mk.in" sed -n 's/^\([ a-z_-]*\)=.*/\1/p'))
+
+printf -v lopt '%s:,' "${vars[@]}"
+lopt+='enable-autodeps,disable-autodeps'
+
+sopt=''
+
+args=$(getopt -n "$name" -o "${sopt}" -l "${lopt}" -- "$@") || exit $?
+eval set -- "$args"
+while [ $# -gt 0 ]; do
+ case "$1" in
--) break;;
- --srcdir) srcdir="$2"; shift;;
- --*)
- var0="${1/--/}"
- match='false'
- for var1 in $vars; do
- if [ "$var0" == "$var1" ]; then
- match='true'
- break;
- fi
- done
- if [ "$match" == 'true' ]; then
- shift
- val="$1"
- eval _$var0=$val
- else
- error "unrecognized option \`$1'";
- fi
- :;;
+ --enable-autodeps) setvar AUTODEPS t;;
+ --disable-autodeps) setvar AUTODEPS '';;
+ --*) setvar "${1#--}" "$2" shift;;
*) error "unrecognized option \`$1'";
esac
shift
- done
-else
- error 'unable to parse command line arguments'
-fi
-
-echo '#!/bin/sed -f' > var.sed
-for var in $vars; do
- var1="_$var"
- val=${!var1}
-
- # GNU bash optimized version
- var=${var//:/\\:}
- val=${val//:/\\:}
- # POSIX version
- #var=`echo "$var" | sed 's@:@\\:@g'`
- #val=`echo "$val" | sed 's@:@\\:@g'`
-
- echo "s:@$var@:$val:g" >> var.sed
done
-Makefiles="`find "$srcdir/" -type f -name 'Makefile.in'`"
-Makefiles="`find "$srcdir/" -type f -name '*.mk.in'` $Makefiles"
-for orig in $Makefiles; do
- new=${orig/%.in/} #bashism
- new=${new/#$srcdir\//} #bashism
- path=`dirname "$orig"`
- mkdir -p `dirname "$new"`
- sed -f var.sed "${orig}" | sed \
--e "s:@srcdir@:${path//:/\\:}/:g" \
--e '19 a# DO NOT edit this file, it has been generated by configure, and will' \
--e "19 a# be overwritten. Instead, edit the file \``basename ${orig}`'" \
--e "19 a
- " > "${new}"
-done
-rm var.sed
+"${edit[@]}" < "$srcdir/config.mk.in" > "$outdir/config.mk"
+Makefiles=($(find "$srcdir/" -name 'Makefile') "$srcdir"/*.mk "$srcdir"/modules/module.mk "$srcdir"/modules/*/Makefile.inc.mk)
+for src in "${Makefiles[@]}"; do
+ out="$outdir/${src#$srcdir/}"
+ mkdir -p -- $(dirname -- "$out")
+ if ! test "$src" -ef "$out"; then
+ cp -fTv -- "$src" "$out"
+ fi
+done