make/configure.vm

changeset 1523
b5c32391802f
parent 1492
cc83ce484bf7
child 1526
047f8a19f7fa
--- a/make/configure.vm	Fri Nov 28 15:23:40 2025 +0100
+++ b/make/configure.vm	Sun Nov 30 13:29:07 2025 +0100
@@ -86,27 +86,30 @@
 printhelp()
 {
     echo "Usage: $0 [OPTIONS]..."
-    cat << __EOF__
-Installation directories:
-  --prefix=PREFIX         path prefix for architecture-independent files
-                          [${D}prefix]
-  --exec-prefix=EPREFIX   path prefix for architecture-dependent files
-                          [PREFIX]
-
-  --bindir=DIR            user executables [EPREFIX/bin]
-  --sbindir=DIR           system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR        program executables [EPREFIX/libexec]
-  --sysconfdir=DIR        system configuration files [PREFIX/etc]
-  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       run-time variable data [LOCALSTATEDIR/run]
-  --libdir=DIR            object code libraries [EPREFIX/lib]
-  --includedir=DIR        C header files [PREFIX/include]
-  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
-  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
-  --infodir=DIR           info documentation [DATAROOTDIR/info]
-  --mandir=DIR            man documentation [DATAROOTDIR/man]
-  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+    echo 'Configuration:'
+#foreach( $cfg in $config )
+if true \
+#if( $cfg.platform )
+    && isplatform "${cfg.platform}" \
+#end
+#foreach( $np in $cfg.notList )
+      && notisplatform "${np}" \
+#end
+      ; then
+    :
+    #foreach( $var in $cfg.vars )
+    #if( $var.overridable )
+    if test -z "${D}${var.varName}__described__"; then
+        ${var.varName}__described__=1
+        cat << '__EOF__'
+${var.helpText}
+__EOF__
+    fi
+    #end
+    #end
+fi
+#end
+    cat << '__EOF__'
 
 Build Types:
   --debug                 add extra compile flags for debug builds
@@ -127,6 +130,7 @@
 #end
 
 __EOF__
+    abort_configure
 }
 
 # create temporary directory
@@ -142,26 +146,7 @@
 touch "$TEMP_DIR/options"
 touch "$TEMP_DIR/features"
 
-# define standard variables
-# also define standard prefix (this is where we will search for config.site)
-prefix=/usr
-exec_prefix=
-bindir=
-sbindir=
-libdir=
-libexecdir=
-datarootdir=
-datadir=
-sysconfdir=
-sharedstatedir=
-localstatedir=
-runstatedir=
-includedir=
-infodir=
-localedir=
-mandir=
-
-# custom variables
+# config variables
 #foreach( $cfg in $config )
 if true \
 #if( $cfg.platform )
@@ -171,12 +156,16 @@
       && notisplatform "${np}" \
 #end
       ; then
+    :
     #foreach( $var in $cfg.vars )
-    #if( $var.exec )
-    ${var.varName}=`${var.value}`
-    #else
-    ${var.varName}="${var.value}"
-    #end
+    if test -z "${D}${var.varName}__initialized__"; then
+        ${var.varName}__initialized__=1
+        #if( $var.exec )
+        ${var.varName}=`${var.value}`
+        #else
+        ${var.varName}="${var.value}"
+        #end
+    fi
     #end
 fi
 #end
@@ -195,28 +184,17 @@
 for ARG in "$@"
 do
     case "$ARG" in
-        "--prefix="*)         prefix=${D}{ARG#--prefix=} ;;
-        "--exec-prefix="*)    exec_prefix=${D}{ARG#--exec-prefix=} ;;
-        "--bindir="*)         bindir=${D}{ARG#----bindir=} ;;
-        "--sbindir="*)        sbindir=${D}{ARG#--sbindir=} ;;
-        "--libdir="*)         libdir=${D}{ARG#--libdir=} ;;
-        "--libexecdir="*)     libexecdir=${D}{ARG#--libexecdir=} ;;
-        "--datarootdir="*)    datarootdir=${D}{ARG#--datarootdir=} ;;
-        "--datadir="*)        datadir=${D}{ARG#--datadir=} ;;
-        "--sysconfdir="*)     sysconfdir=${D}{ARG#--sysconfdir=} ;;
-        "--sharedstatedir="*) sharedstatedir=${D}{ARG#--sharedstatedir=} ;;
-        "--localstatedir="*)  localstatedir=${D}{ARG#--localstatedir=} ;;
-        "--runstatedir="*)    runstatedir=${D}{ARG#--runstatedir=} ;;
-        "--includedir="*)     includedir=${D}{ARG#--includedir=} ;;
-        "--infodir="*)        infodir=${D}{ARG#--infodir=} ;;
-        "--mandir"*)          mandir=${D}{ARG#--mandir} ;;
-        "--localedir"*)       localedir=${D}{ARG#--localedir} ;;
-        "--help"*)            printhelp; abort_configure ;;
-        "--debug")            BUILD_TYPE="debug" ;;
-        "--release")          BUILD_TYPE="release" ;;
+    #foreach( $var in $vars )
+    #if ($var.overridable)
+        "--${var.arg}="*) ${var.varName}=${D}{ARG#--${var.arg}=} ;;
+    #end
+    #end
+        "--help"*) printhelp ;;
+        "--debug") BUILD_TYPE="debug" ;;
+        "--release") BUILD_TYPE="release" ;;
     #foreach( $opt in $options )
         "--${opt.arg}="*) ${opt.varName}=${D}{ARG#--${opt.arg}=} ;;
-        "--${opt.arg}")  echo "option '$ARG' needs a value:"; echo "  $ARG=${opt.valuesString}"; abort_configure ;;
+        "--${opt.arg}") echo "option '$ARG' needs a value:"; echo "  $ARG=${opt.valuesString}"; abort_configure ;;
     #end
     #foreach( $feature in $features )
         "--enable-${feature.arg}") ${feature.varName}=on ;;
@@ -226,6 +204,18 @@
     esac
 done
 
+# toolchain detection utilities
+. make/toolchain.sh
+
+# check languages
+lang_c=
+lang_cpp=
+#foreach( $lang in $languages )
+if detect_${lang}_compiler ; then
+    lang_${lang}=1
+fi
+#end
+
 ## Begin unparsed content. **
 #[[
 
@@ -264,58 +254,49 @@
 : ${mandir:='${datarootdir}/man'}
 : ${localedir:='${datarootdir}/locale'}
 
-# remember the above values and compare them later
-orig_bindir="$bindir"
-orig_sbindir="$sbindir"
-orig_libdir="$libdir"
-orig_libexecdir="$libexecdir"
-orig_datarootdir="$datarootdir"
-orig_datadir="$datadir"
-orig_sysconfdir="$sysconfdir"
-orig_sharedstatedir="$sharedstatedir"
-orig_localstatedir="$localstatedir"
-orig_runstatedir="$runstatedir"
-orig_includedir="$includedir"
-orig_infodir="$infodir"
-orig_mandir="$mandir"
-orig_localedir="$localedir"
 
 # check if a config.site exists and load it
+CONFIG_SITE_OK=0
 if [ -n "$CONFIG_SITE" ]; then
     # CONFIG_SITE may contain space separated file names
     for cs in $CONFIG_SITE; do
         printf "loading defaults from $cs... "
-        . "$cs"
-        echo ok
+        if [ -f "$cs" ]; then
+            . "$cs"
+            echo ok
+            CONFIG_SITE_OK=1
+            break
+        else
+            echo "not found"
+        fi
     done
 elif [ -f "$prefix/share/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/share/config.site"
     echo ok
+    CONFIG_SITE_OK=1
 elif [ -f "$prefix/etc/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/etc/config.site"
     echo ok
-else
+    CONFIG_SITE_OK=1
+fi
+
+if [ $CONFIG_SITE_OK -eq 0 ]; then
     # try to detect the correct libdir on our own, except it was changed by the user
-    if test "$libdir" = '${exec_prefix}/lib'; then
-        if [ "$OS" = "SunOS" ]; then
-            test -d "${exec_prefix}/lib/amd64" && libdir='${exec_prefix}/lib/amd64'
-        else
-            # check if the standard libdir even exists
-            if test -d "${exec_prefix}/lib" ; then
-                :
+    if [ "$libdir" = '${exec_prefix}/lib' ] ; then
+        if [ "$TOOLCHAIN_WSIZE" = "64" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/64" ] && libdir='${exec_prefix}/lib/64'
             else
-                # if it does not, maybe a lib32 exists
-                test -d "${exec_prefix}/lib32" && libdir='${exec_prefix}/lib32'
+                [ -d "${exec_prefix}/lib64" ] && libdir='${exec_prefix}/lib64'
             fi
-            # now check if there is a special 64bit libdir that we should use
-            for i in x86_64 ppc64 s390x aarch64 aarch64_be arm64 ; do
-                if [ $ARCH = $i ]; then
-                    test -d "${exec_prefix}/lib64" && libdir='${exec_prefix}/lib64'
-                    break
-                fi
-            done
+        elif [ "$TOOLCHAIN_WSIZE" = "32" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/32" ] && libdir='${exec_prefix}/lib/32'
+            else
+                [ -d "${exec_prefix}/lib32" ] && libdir='${exec_prefix}/lib32'
+            fi
         fi
     fi
 fi
@@ -324,42 +305,17 @@
 
 # generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
-prefix=$prefix
-exec_prefix=$exec_prefix
-bindir=$bindir
-sbindir=$sbindir
-libdir=$libdir
-libexecdir=$libexecdir
-datarootdir=$datarootdir
-datadir=$datadir
-sysconfdir=$sysconfdir
-sharedstatedir=$sharedstatedir
-localstatedir=$localstatedir
-runstatedir=$runstatedir
-includedir=$includedir
-infodir=$infodir
-mandir=$mandir
-localedir=$localedir
 #foreach( $var in $vars )
 ${var.varName}=${D}${var.varName}
 #end
 __EOF__
 
-# toolchain detection utilities
-. make/toolchain.sh
 
 #
 # DEPENDENCIES
 #
 
-# check languages
-lang_c=
-lang_cpp=
-#foreach( $lang in $languages )
-if detect_${lang}_compiler ; then
-    lang_${lang}=1
-fi
-#end
+
 
 # create buffer for make variables required by dependencies
 echo > "$TEMP_DIR/make.mk"
@@ -744,7 +700,7 @@
 
 echo "configure finished"
 echo
-echo "Toolchain"
+echo "Toolchain:"
 echo "  name:           $TOOLCHAIN_NAME"
 if [ -n "$TOOLCHAIN_CC" ]; then
     echo "  cc:             $TOOLCHAIN_CC"
@@ -759,51 +715,13 @@
     echo "  default C std:  $TOOLCHAIN_CSTD"
 fi
 echo
-echo "Build Config:"
-echo "  prefix:         $prefix"
-echo "  exec_prefix:    $exec_prefix"
-if [ "$orig_bindir" != "$bindir" ]; then
-    echo "  bindir:      $bindir"
-fi
-if [ "$orig_sbindir" != "$sbindir" ]; then
-    echo "  sbindir:     $sbindir"
-fi
-if [ "$orig_libdir" != "$libdir" ]; then
-    echo "  libdir:         $libdir"
-fi
-if [ "$orig_libexecdir" != "$libexecdir" ]; then
-    echo "  libexecdir:     $libexecdir"
-fi
-if [ "$orig_datarootdir" != "$datarootdir" ]; then
-    echo "  datarootdir:    $datarootdir"
-fi
-if [ "$orig_datadir" != "$datadir" ]; then
-    echo "  datadir:        $datadir"
-fi
-if [ "$orig_sysconfdir" != "$sysconfdir" ]; then
-    echo "  sysconfdir:     $sysconfdir"
-fi
-if [ "$orig_sharedstatedir" != "$sharedstatedir" ]; then
-    echo "  sharedstatedir: $sharedstatedir"
-fi
-if [ "$orig_localstatedir" != "$localstatedir" ]; then
-    echo "  localstatedir:  $localstatedir"
-fi
-if [ "$orig_runstatedir" != "$runstatedir" ]; then
-    echo "  runstatedir:    $runstatedir"
-fi
-if [ "$orig_includedir" != "$includedir" ]; then
-    echo "  includedir:     $includedir"
-fi
-if [ "$orig_infodir" != "$infodir" ]; then
-    echo "  infodir:        $infodir"
-fi
-if [ "$orig_mandir" != "$mandir" ]; then
-    echo "  mandir:         $mandir"
-fi
-if [ "$orig_localedir" != "$localedir" ]; then
-    echo "  localedir:      $localedir"
-fi
+echo "Config:"
+#foreach( $var in $vars )
+#if ($var.overridable)
+    printf '  %-16s' '${var.arg}:'
+    echo "${D}${var.varName}"
+#end
+#end
 #if ( $options.size() > 0 )
 echo
 echo "Options:"
@@ -813,10 +731,11 @@
 echo
 echo "Features:"
 #foreach( $feature in $features )
+printf '  %-16s' '$feature.name:'
 if [ -n "${D}${feature.varName}" ]; then
-echo "  $feature.name: on"
+    echo 'on'
 else
-echo "  $feature.name: off"
+    echo 'off'
 fi
 #end
 #end

mercurial