httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf S. Engelschall" <...@engelschall.com>
Subject [PATCH] Straight-foreward parameter usage for `configure'
Date Wed, 22 Apr 1998 10:10:42 GMT

Straight-foreward parameter usage for `configure'
=================================================

Background
----------

The current `configure' script from APACI provides only the strict Autoconf
way for specifying parameters like CC, CFLAGS, LDFLAGS, etc. Although it is
part of the GNU standard for `configure' style interfaces, it is a bad design
the GNU people have done here for a couple of reasons.

   1. It is unintuitive to use shell variables for parameters while
      all other customization takes place via command line options.

   2. Because of 1.) we get PR's from users who not even found out that they
      could use shell variables because although it is documented it is not
      the expected by non-Autoconf-experienced users.

   3. Using shell variables is erroneous because of the various types
      of shells. "KEY=VALUE ./configure" is Bourne-Shell only, C-Shell users
      have to use "setenv KEY VALUE; ./configure ..." etc. Additionally
      exporting those variables cause side-effects in our src/Configuration
      script.

Solution
--------

Although we still have to provide the

   $ KEY=VALUE KEY=VALUE ./configure ...

syntax to be both conforming to the GNU standards and to make package
maintainers life not harder as it has to be (e.g. FreeBSD port) there is no
law who says we have to use this syntax as the default and thus recommended
one. No one prevents us from just supporting this syntax as an acceptable
alternative.  But alternative to what? TO COMMAND LINE OPTIONS, OF COURSE!

So, the idea is to use

   $ ./configure --set-KEY=VALUE --set-KEY=VALUE ...

as the recommended syntax, because it is more straight-foreward, more friendly
to the user, more friendly for us (less side-effects in src/Configuration),
etc. And additionally its looks cleaner, better and more intuitive than the
strict Autoconf syntax (which I personally dislike, too).

The appended patch provides this. Of course the INSTALL and README.configure
documents have to be adjusted to show the new recommended syntax and only note
that the problematic Autoconf-style is supported for compatbility. I'll update
these documents when comitting this patch, too.

Greetings,
                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com
Index: configure
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/configure,v
retrieving revision 1.15
diff -u -r1.15 configure
--- configure	1998/04/21 16:00:33	1.15
+++ configure	1998/04/22 09:51:03
@@ -203,17 +203,33 @@
     fi
 done
 
-#   backward compatibility from old src/Configuration.tmpl
-#   parameter names to the canonical Autoconf-style shell
-#   variable names.
+#   determine variables
+vars=""
+varsnew=""
 IFS='
 '
-for var in CFLAGS LDFLAGS LIBS INCLUDES; do
-    eval "val=\$EXTRA_$var"
+for var in `egrep '^#?[A-Z_]+=.*' $src/Configuration.tmpl`; do
+    name=`echo "$var" | sed -e 's:^#::' -e 's/=.*$//'`
+    arg=`echo "$var" | sed -e 's/^.*=//'`
+    eval "var_$name=\"$arg\""
+    eval "customized_$name=0"
+    vars="$vars:$name"
+done
+
+#   overlay variables with strict Autoconf-style shell parameters
+IFS=" 	
+"
+for var in CC OPTIM CFLAGS CFLAGS_SHLIB LDFLAGS LDFLAGS_SHLIB \
+           LDFLAGS_SHLIB_EXPORT LIBS INCLUDES RANLIB; do
+    case "$var" in
+        CFLAGS|LDFLAGS|LIBS|INCLUDES) name="EXTRA_$apc_param" ;;
+        *) name="$var" ;;
+    esac
+    eval "val=\$$var"
     if [ ".$val" != . ]; then
-        eval "$var=\$val"
-        eval "EXTRA_$var=\"\"; export EXTRA_$var"
-        echo " + Hint: please use $var instead of EXTRA_$var next time"
+        eval "var_$name=\"$val\""
+        eval "customized_$name=1"
+        eval "$var=\"\""
     fi
 done
 
@@ -302,6 +318,8 @@
             echo " --compat               install with old Apache 1.2 installation paths"
             echo ""
             echo "Configuration options:"
+            echo " --set-NAME=VALUE       set variable 'NAME' to 'VALUE'"
+            $aux/ppl.sh $vars
             echo " --enable-rule=NAME     enable  a particular Rule named 'NAME'"
             echo " --disable-rule=NAME    disable a particular Rule named 'NAME'"
             $aux/ppl.sh $rulelist
@@ -591,6 +609,41 @@
         --suexec-userdir=*)
             suexec_userdir="$apc_optarg"
             ;;
+        --set-custom-*)
+            apc_param=`echo $apc_option | sed -e 's/-*set-custom-//' -e 's/=.*//'`
+            apc_param=`echo $apc_param | sed -e 's/-/_/g' | tr 'a-z' 'A-Z'`
+            case "$apc_option" in
+                *=*) ;;
+                  *) apc_optarg="" ;;
+            esac
+            eval "var_${apc_param}=\"${apc_optarg}\""
+            varsnew="$varsnew:${apc_param}"
+			;;
+        --set-*)
+            apc_param=`echo $apc_option | sed -e 's/-*set-//' -e 's/=.*//'`
+            apc_param=`echo $apc_param | sed -e 's/-/_/g' | tr 'a-z' 'A-Z'`
+            case "$apc_param" in
+                CFLAGS|LDFLAGS|LIBS|INCLUDES) apc_param="EXTRA_$apc_param" ;;
+            esac
+            case "$apc_option" in
+                *=*) ;;
+                  *) apc_optarg="" ;;
+            esac
+			exists=0
+            IFS=:
+            for var in `echo "$vars" | sed -e 's/^://'`; do
+				if [ ".$var" = ".$apc_param" ]; then
+					exists=1
+				fi
+			done
+            if [ $exists = 0 ]; then
+                echo "configure:Error: No such variable named '${apc_param}'"
+				exit 1
+            fi
+            echo "var_${apc_param}=\"${apc_optarg}\""
+            eval "var_${apc_param}=\"${apc_optarg}\"" 
+            eval "customized_${apc_param}=1"
+            ;;
         * )
             echo "configure:Error: invalid option '$apc_option'"
             exit 1
@@ -754,7 +807,8 @@
 echo "echo '-DACCESS_CONFIG_FILE=\"${sysconfdir_relative}access.conf\"'" >>$src/apaci
 echo "echo '-DRESOURCE_CONFIG_FILE=\"${sysconfdir_relative}srm.conf\"'" >>$src/apaci
 chmod a+x $src/apaci
-CFLAGS="$CFLAGS \\\`\$(SRCDIR)/apaci\\\`"
+var_CFLAGS="$var_CFLAGS \\\`\$(SRCDIR)/apaci\\\`"
+customized_CFLAGS=1
 
 ##
 ##  create $src/Configuration.apaci file
@@ -765,25 +819,28 @@
 rm -f sedsubst 2>/dev/null
 touch sedsubst
 
-#   generate settings from imported environment variables
-IFS='
-'
-for var in CC OPTIM CFLAGS CFLAGS_SHLIB LDFLAGS LDFLAGS_SHLIB \
-           LDFLAGS_SHLIB_EXPORT LIBS INCLUDES RANLIB; do
-    eval "val=\$$var";
-    if [ ".$val" != . ]; then
-        case $var in 
-            CFLAGS|LDFLAGS|LIBS|INCLUDES) 
-                echo "s%^#*\\(EXTRA_$var=\\).*%\\1$val%g" >>sedsubst
-                ;;
-            *)
-                echo "s%^#*\\($var=\\).*%\\1$val%g" >>sedsubst
-                ;;
-        esac
-        eval "$var=\"\"; export $var"
-    fi
+#   generate variable definitions (for existing ones)
+IFS=":"
+for var in `echo "$vars" | sed -e 's/^://'`; do
+    eval "customized=\$customized_$var";
+    if [ ".$customized" = .1 ]; then
+        eval "val=\"\$var_$var\"";
+        echo "s%^#*\\($var=\\).*%\\1$val%g" >>sedsubst
+	fi
 done
 
+#   generate variable definitions (for new custom ones)
+if [ ".$varsnew" != . ]; then
+    rm -f sedsubst2 2>/dev/null
+    touch sedsubst2
+    IFS=":"
+    for var in `echo "$varsnew" | sed -e 's/^://'`; do
+        eval "val=\"\$var_$var\"";
+	    echo "$var=$val" >>sedsubst2
+    done
+    echo "/#RANLIB=/r sedsubst2" >>sedsubst
+fi
+
 #   generate rule directives 
 IFS=:
 for rule in `echo "$rules" | sed -e 's/^://'`; do
@@ -852,15 +909,18 @@
     cat $src/Configuration.tmpl | sed -f sedsubst >$src/Configuration.apaci
 fi
 rm -f sedsubst 2>/dev/null
+if [ ".$varsnew" != . ]; then
+    rm -f sedsubst2 2>/dev/null
+fi
 
 ##
 ##  create all other Makefiles by running the proprietary 
 ##  $src/Configure script with our custom Configuration.apaci file
 ##
 if [ .$quiet = .yes ]; then
-    (cd $src; CFLAGS= ./Configure -file Configuration.apaci >/dev/null);
+    (cd $src; ./Configure -file Configuration.apaci >/dev/null);
 else
-    (cd $src; CFLAGS= ./Configure -file Configuration.apaci |\
+    (cd $src; ./Configure -file Configuration.apaci |\
      sed -e '/^Using config file:.*/d' \
          -e "s:Makefile in :Makefile in $src\\/:" \
          -e "s:Makefile\$:Makefile in $src:")

Mime
View raw message