summaryrefslogtreecommitdiff
path: root/mcon/U/Options.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/Options.U')
-rw-r--r--mcon/U/Options.U142
1 files changed, 125 insertions, 17 deletions
diff --git a/mcon/U/Options.U b/mcon/U/Options.U
index 0985d3e..0508d27 100644
--- a/mcon/U/Options.U
+++ b/mcon/U/Options.U
@@ -1,12 +1,12 @@
-?RCS: $Id: Options.U,v 3.0.1.7 1997/02/28 15:08:15 ram Exp $
+?RCS: $Id$
?RCS:
-?RCS: Copyright (c) 1991-1993, Raphael Manfredi
+?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic Licence,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic Licence; a copy of which may be found at the root
-?RCS: of the source tree for dist 3.0.
+?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: Options.U,v $
?RCS: Revision 3.0.1.7 1997/02/28 15:08:15 ram
@@ -47,12 +47,52 @@
?MAKE: -pick wipe $@ %<
?V:reuseval alldone error realsilent silent extractsh fastread \
override knowitall: config_sh
-?T:arg symbol
-?F:./optdef.sh
+?T:arg argn symbol config_arg0 config_args config_argc xxx yyy zzz uuu
+?T:args_exp args_sep arg_exp
+?F:!Configure
+?F:./optdef.sh ./cmdline.opt ./posthint.sh ./cmdl.opt
+: Save command line options in file UU/cmdline.opt for later use in
+: generating config.sh.
+?X: This temporary file will be read by Oldsym.U. I used a temporary
+?X: file to preserve all sorts of potential command line quotes and
+?X: also because we don't know in advance how many variables we'll
+?X: need, so I can't actually declare them on the MAKE line.
+?X: The config_args variable won't be quite correct if Configure is
+?X: fed something like ./Configure -Dcc="gcc -B/usr/ccs/bin/"
+?X: since the quotes are gone by the time we see them. You'd have to
+?X: reconstruct the command line from the config_arg? lines, but since
+?X: I don't imagine anyone actually having to do that, I'm not going
+?X: to worry too much.
+cat > cmdline.opt <<EOSH
+: Configure command line arguments.
+config_arg0='$0'
+config_args='$*'
+config_argc=$#
+EOSH
+argn=1
+args_exp=''
+args_sep=''
+for arg in "$@"; do
+ cat >>cmdline.opt <<EOSH
+config_arg$argn='$arg'
+EOSH
+?X: Extreme backslashitis: replace each ' by '"'"'
+ cat <<EOC | sed -e "s/'/'"'"'"'"'"'"'/g" > cmdl.opt
+$arg
+EOC
+ arg_exp=`cat cmdl.opt`
+ args_exp="$args_exp$args_sep'$arg_exp'"
+ argn=`expr $argn + 1`
+ args_sep=' '
+done
+?X: args_exp is good for restarting self: eval "set X $args_exp"; shift; $0 "$@"
+?X: used by hints/os2.sh in Perl, for instance
+rm -f cmdl.opt
+
: produce awk script to parse command line options
cat >options.awk <<'EOF'
BEGIN {
- optstr = "dD:eEf:hKOrsSU:V"; # getopt-style specification
+ optstr = "A:dD:eEf:hKOrsSU:V"; # getopt-style specification
len = length(optstr);
for (i = 1; i <= len; i++) {
@@ -118,7 +158,7 @@ silent=''
extractsh=''
override=''
knowitall=''
-rm -f optdef.sh
+rm -f optdef.sh posthint.sh
cat >optdef.sh <<EOS
$startsh
EOS
@@ -185,8 +225,58 @@ while test $# -gt 0; do
esac
shift
;;
- -V) echo "$me generated by metaconfig <VERSION> PL<PATCHLEVEL>." >&2
- exit 0;;
+ -A)
+ shift
+ xxx=''
+ yyy="$1"
+ zzz=''
+ uuu=undef
+ case "$yyy" in
+ *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
+ case "$zzz" in
+ *:*) zzz='' ;;
+ *) xxx=append
+ zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
+ yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
+ esac
+ ;;
+ esac
+ case "$xxx" in
+ '') case "$yyy" in
+ *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
+ yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
+ zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
+ yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
+ *) xxx=`echo "$yyy"|sed 's!:.*!!'`
+ yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
+ esac
+ ;;
+ esac
+ case "$xxx" in
+ append)
+ echo "$yyy=\"\${$yyy}$zzz\"" >> posthint.sh ;;
+ clear)
+ echo "$yyy=''" >> posthint.sh ;;
+ define)
+ case "$zzz" in
+ '') zzz=define ;;
+ esac
+ echo "$yyy='$zzz'" >> posthint.sh ;;
+ eval)
+ echo "eval \"$yyy=$zzz\"" >> posthint.sh ;;
+ prepend)
+ echo "$yyy=\"$zzz\${$yyy}\"" >> posthint.sh ;;
+ undef)
+ case "$zzz" in
+ '') zzz="$uuu" ;;
+ esac
+ echo "$yyy=$zzz" >> posthint.sh ;;
+ *) echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
+ esac
+ shift
+ ;;
+ -V) echo "$me generated by metaconfig <VERSION>-<REVISION>." >&2
+ exit 0;;
--) break;;
-*) echo "$me: unknown option $1" >&2; shift; error=true;;
*) break;;
@@ -197,7 +287,7 @@ case "$error" in
true)
cat >&2 <<EOM
Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
- [-U symbol] [-U symbol=]
+ [-U symbol] [-U symbol=] [-A command:symbol...]
-d : use defaults for all answers.
-e : go on without questioning past the production of config.sh.
-f : specify an alternate default configuration file.
@@ -214,6 +304,16 @@ Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
-U : undefine symbol:
-U symbol symbol gets the value 'undef'
-U symbol= symbol gets completely empty
+ -A : manipulate symbol after the platform specific hints have been applied:
+ -A symbol=value append " "value to symbol
+ -A append:symbol=value append value to symbol
+ -A define:symbol=value define symbol to have value
+ -A clear:symbol define symbol to be ''
+ -A define:symbol define symbol to be 'define'
+ -A eval:symbol=value define symbol to be eval of value
+ -A prepend:symbol=value prepend value to symbol
+ -A undef:symbol define symbol to be 'undef'
+ -A undef:symbol= define symbol to be ''
-V : print version number and exit (with a zero status).
EOM
exit 1
@@ -221,9 +321,9 @@ EOM
esac
?X:
-?X: Unless they specified both -d and -e/E, make sure we're running
-?X: interactively, i.e. attached to a terminal. Moved from Head.U to be able
-?X: to handle batch configurations...
+?X: Unless they specified either -S or both -d and -e/E, make sure we're
+?X: running interactively, i.e. attached to a terminal. Moved from Head.U to
+?X: be able to handle batch configurations...
?X:
?X: We have to hardwire the Configure name and cannot use $me, since if they
?X: said 'sh <Configure', then $me is 'sh'...
@@ -232,10 +332,15 @@ esac
case "$fastread$alldone" in
yescont|yesexit) ;;
*)
- if test ! -t 0; then
- echo "Say 'sh Configure', not 'sh <Configure'"
- exit 1
- fi
+ case "$extractsh" in
+ true) ;;
+ *)
+ if test ! -t 0; then
+ echo "Say 'sh Configure', not 'sh <Configure'"
+ exit 1
+ fi
+ ;;
+ esac
;;
esac
@@ -252,4 +357,7 @@ esac
: run the defines and the undefines, if any, but leave the file out there...
touch optdef.sh
. ./optdef.sh
+: create the posthint manipulation script and leave the file out there...
+?X: this file will be perused by Oldconfig.U
+touch posthint.sh