diff options
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 107 |
1 files changed, 59 insertions, 48 deletions
@@ -1,5 +1,5 @@ #!/bin/sh -# rvs configureation script +name='configure' # rvs configureation script # version 0.7.0 # Copyright (C) 2009 Luke Shumaker # This program is distributed in the hope that it will be useful, @@ -9,59 +9,70 @@ # # Originally written by Luke Shumaker <lukeshu@sbcglobal.net>. -sourcedir=`dirname "$0"` -pre='./var.sed' + _srcdir=$(readlink -f `dirname "$0"`) + _SHELL='/bin/sh' + _prefix='/usr/local' +_exec_prefix='$(prefix)' + _bindir='$(exec_prefix)/bin' + _sbindir='$(exec_prefix)/sbin' + rvsdir='/etc' -while [ $# -gt 0 ]; do case "$1" in - --*) - var0=`echo "$1" | sed -e 's/^--//' -e 's/=.*$//'` - match='false' - while read line; do - var1=`echo "$line" | cut -f 1 ` - if [ "$var0" == "$var1" ]; then - match='true' - break; +vars='srcdir SHELL prefix exec_prefix bindir sbindir rvsdir' + +error() { + echo "$name: $1" >> /dev/stderr + exit 1 +} + +args=`getopt -n "$name" -o "${sopt}" -l "${lopt}${vars}" -- "$@"` +if [ $? == 0 ]; then + set -- $args + while [ $# -gt 0 ]; do case "$1" in + --) break;; + --*) + var0="${1/--/}" + match='false' + for var1 in $vars; do + if [ "$var0" == "$var1" ]; then + match='true' + break; + fi + done + if [ "$match" == 'true' ]; then + val="$2" + eval _$var0=$val + else + error "option \`$1' not recognized"; fi - done < Variables - if [ "$match" == 'false' ]; then - echo "configure: option \`$1' not recognized" - exit 255; - else - val=`echo "$1" | sed -e "s/^--$var0=//"` - eval _$var0=$val - fi - :;; - *) echo "configure: option \`$1' not recognized"; exit 255;; + :;; + *) error "option \`$1' not recognized";; esac shift -done + done +else + error 'unable to parse command line arguments' +fi -echo '#!/bin/sed -f' > "$pre" -while read line; do - var=`echo "$line" | cut -f 1 ` - val=$(eval echo `echo "$line" | cut -f 2-`) # load from Variables file - val=$(eval echo '${'`echo _$var`-$val'}') # check for option overide +echo '#!/bin/sed -f' > var.sed +for var in $vars; do + var1="_$var" + val=${!var1} - # evaluate the values, so that we may use env variables as values - # escape slashes, as they cause problems for sed - var=`echo "$var" | sed 's:/:\\\\/:g'` - val=`echo "$val" | sed 's:/:\\\\/:g'` + var=${var//':'/'\:'} + val=${val//':'/'\:'} - echo 's/$$'"${var}"'$\$/'"${val}"'/' >> "$pre" - #sed -i.bak 's/$$'"${var}"'$\$/'"${val}"'/' "$files" - unset var val -done < "$sourcedir/Variables" + echo "s:@$var@:$val:g" >> var.sed +done -chmod +x "$pre" -"$pre" < "$sourcedir/Makefile.orig" > Makefile +echo "11 a# DO NOT edit this file, it has been generated by configure, and will +11 a# be overwritten. Instead, edit the file \`Makefile.orig'" >> var.sed + +Makefiles=`find "${_srcdir}/" -regextype posix-extended \ +-regex '(.*/)?Makefile\.orig' -type f` + +for orig in $Makefiles; do + new=${orig/%.orig/} + new=${new/#$_srcdir/} + sed -f var.sed < "${orig}" > "${new}" +done -n0='# DO NOT edit this file, it has been generated by configure, and will be' -n1='# overwritten. Instead, edit the file `Makefile.orig'\' -sourcedir=`echo "$sourcedir" | sed 's:/:\\\\/:g'` - pre=`echo "$pre" | sed 's:/:\\\\/:g'` -sed -i \ --e "11 a$n0" \ --e "11 a$n1" \ --e "s/@@sourcedir@@/$sourcedir/" \ --e "s/@@pre@@/$pre/" \ -Makefile |