add support for config.site - fixes #313

Tue, 10 Oct 2023 20:33:49 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 10 Oct 2023 20:33:49 +0200
changeset 88
0a663c3692a0
parent 87
60bd4f61e89f
child 89
9817c08f9637

add support for config.site - fixes #313

test/configure file | annotate | diff | comparison | revisions
test/make/configure.vm file | annotate | diff | comparison | revisions
test/make/project.xml file | annotate | diff | comparison | revisions
--- a/test/configure	Tue Oct 10 18:52:47 2023 +0200
+++ b/test/configure	Tue Oct 10 20:33:49 2023 +0200
@@ -14,24 +14,28 @@
 touch "$TEMP_DIR/features"
 
 # define standard variables
-PREFIX=/usr
-EPREFIX=
-BINDIR=
-SBINDIR=
-LIBDIR=
-LIBEXECDIR=
-DATADIR=
-SYSCONFDIR=
-SHAREDSTATEDIR=
-LOCALSTATEDIR=
-INCLUDEDIR=
-INFODIR=
-MANDIR=
+# 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
 HOST=`uname -n`
-PREFIX="`pwd`/work"
-INSTALL_DIR="$PREFIX"
+prefix="`pwd`/work"
+install_dir="$prefix"
 
 # features
 FEATURE_PG=auto
@@ -60,12 +64,14 @@
   --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]
 
 Optional Features:
   --disable-pg
@@ -80,19 +86,21 @@
 for ARG in "$@"
 do
     case "$ARG" in
-        "--prefix="*)         PREFIX=${ARG#--prefix=} ;;
-        "--exec-prefix="*)    EPREFIX=${ARG#--exec-prefix=} ;;
-        "--bindir="*)         BINDIR=${ARG#----bindir=} ;;
-        "--sbindir="*)        SBINDIR=${ARG#--sbindir=} ;;
-        "--libdir="*)         LIBDIR=${ARG#--libdir=} ;;
-        "--libexecdir="*)     LIBEXECDIR=${ARG#--libexecdir=} ;;
-        "--datadir="*)        DATADIR=${ARG#--datadir=} ;;
-        "--sysconfdir="*)     SYSCONFDIR=${ARG#--sysconfdir=} ;;
-        "--sharedstatedir="*) SHAREDSTATEDIR=${ARG#--sharedstatedir=} ;;
-        "--localstatedir="*)  LOCALSTATEDIR=${ARG#--localstatedir=} ;;
-        "--includedir="*)     INCLUDEDIR=${ARG#--includedir=} ;;
-        "--infodir="*)        INFODIR=${ARG#--infodir=} ;;
-        "--mandir"*)          MANDIR=${ARG#--mandir} ;;
+        "--prefix="*)         prefix=${ARG#--prefix=} ;;
+        "--exec-prefix="*)    exec_prefix=${ARG#--exec-prefix=} ;;
+        "--bindir="*)         bindir=${ARG#----bindir=} ;;
+        "--sbindir="*)        sbindir=${ARG#--sbindir=} ;;
+        "--libdir="*)         libdir=${ARG#--libdir=} ;;
+        "--libexecdir="*)     libexecdir=${ARG#--libexecdir=} ;;
+        "--datarootdir="*)    datarootdir=${ARG#--datarootdir=} ;;
+        "--datadir="*)        datadir=${ARG#--datadir=} ;;
+        "--sysconfdir="*)     sysconfdir=${ARG#--sysconfdir=} ;;
+        "--sharedstatedir="*) sharedstatedir=${ARG#--sharedstatedir=} ;;
+        "--localstatedir="*)  localstatedir=${ARG#--localstatedir=} ;;
+        "--includedir="*)     includedir=${ARG#--includedir=} ;;
+        "--infodir="*)        infodir=${ARG#--infodir=} ;;
+        "--mandir"*)          mandir=${ARG#--mandir} ;;
+        "--localedir"*)       localedir=${ARG#--localedir} ;;
         "--help"*) printhelp; abort_configure ;;
         "--debug")           BUILD_TYPE="debug" ;;
         "--release")         BUILD_TYPE="release" ;;
@@ -103,19 +111,41 @@
 done
 
 
-# set dir variables
-: ${EPREFIX:="$PREFIX"}
-: ${BINDIR:="$EPREFIX/bin"}
-: ${SBINDIR:="$EPREFIX/sbin"}
-: ${LIBDIR:="$EPREFIX/lib"}
-: ${LIBEXECDIR:="$EPREFIX/libexec"}
-: ${DATADIR:="$PREFIX/share"}
-: ${SYSCONFDIR:="$PREFIX/etc"}
-: ${SHAREDSTATEDIR:="$PREFIX/com"}
-: ${LOCALSTATEDIR:="$PREFIX/var"}
-: ${INCLUDEDIR:="$PREFIX/include"}
-: ${INFODIR:="$PREFIX/info"}
-: ${MANDIR:="$PREFIX/man"}
+
+# set defaults for dir variables
+: ${exec_prefix:="$prefix"}
+: ${bindir:='${exec_prefix}/bin'}
+: ${sbindir:='${exec_prefix}/sbin'}
+: ${libdir:='${exec_prefix}/lib'}
+: ${libexecdir:='${exec_prefix}/libexec'}
+: ${datarootdir:='${prefix}/share'}
+: ${datadir:='${datarootdir}'}
+: ${sysconfdir:='${prefix}/etc'}
+: ${sharedstatedir:='${prefix}/com'}
+: ${localstatedir:='${prefix}/var'}
+: ${runstatedir:='${localstatedir}/run'}
+: ${includedir:='${prefix}/include'}
+: ${infodir:='${datarootdir}/info'}
+: ${mandir:='${datarootdir}/man'}
+: ${localedir:='${datarootdir}/locale'}
+
+# check if a config.site exists and load it
+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
+    done
+elif [ -f "$prefix/share/config.site" ]; then
+    printf "loading site defaults... "
+    . "$prefix/share/config.site"
+    echo ok
+elif [ -f "$prefix/etc/config.site" ]; then
+    printf "loading site defaults... "
+    . "$prefix/etc/config.site"
+    echo ok
+fi
 
 # Test for availability of pkg-config
 PKG_CONFIG=`command -v pkg-config`
@@ -170,25 +200,26 @@
 
 # generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
-PREFIX="$PREFIX"
-EPREFIX="$EPREFIX"
-BINDIR="$BINDIR"
-SBINDIR="$SBINDIR"
-LIBDIR="$LIBDIR"
-LIBEXECDIR="$LIBEXECDIR"
-DATADIR="$DATADIR"
-SYSCONFDIR="$SYSCONFDIR"
-SHAREDSTATEDIR="$SHAREDSTATEDIR"
-LOCALSTATEDIR="$LOCALSTATEDIR"
-INCLUDEDIR="$INCLUDEDIR"
-INFODIR="$INFODIR"
-MANDIR="$MANDIR"
+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"
 HOST="$HOST"
-PREFIX="$PREFIX"
-INSTALL_DIR="$INSTALL_DIR"
+prefix="$prefix"
+install_dir="$install_dir"
 __EOF__
-sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk"
-
 
 # toolchain detection utilities
 . make/toolchain.sh
@@ -468,8 +499,8 @@
 echo "configure finished"
 echo
 echo "Build Config:"
-echo "  PREFIX:    $PREFIX"
-echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+echo "  PREFIX:      $prefix"
+echo "  TOOLCHAIN:   $TOOLCHAIN_NAME"
 echo "Features:"
 if [ -n "$FEATURE_PG" ]; then
 echo "  pg: on"
--- a/test/make/configure.vm	Tue Oct 10 18:52:47 2023 +0200
+++ b/test/make/configure.vm	Tue Oct 10 20:33:49 2023 +0200
@@ -14,19 +14,23 @@
 touch "$TEMP_DIR/features"
 
 # define standard variables
-PREFIX=/usr
-EPREFIX=
-BINDIR=
-SBINDIR=
-LIBDIR=
-LIBEXECDIR=
-DATADIR=
-SYSCONFDIR=
-SHAREDSTATEDIR=
-LOCALSTATEDIR=
-INCLUDEDIR=
-INFODIR=
-MANDIR=
+# 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
 #foreach( $var in $vars )
@@ -68,12 +72,14 @@
   --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]
 
 #if( $options.size() > 0 )
 Options:
@@ -106,19 +112,21 @@
 for ARG in "$@"
 do
     case "$ARG" in
-        "--prefix="*)         PREFIX=${D}{ARG#--prefix=} ;;
-        "--exec-prefix="*)    EPREFIX=${D}{ARG#--exec-prefix=} ;;
-        "--bindir="*)         BINDIR=${D}{ARG#----bindir=} ;;
-        "--sbindir="*)        SBINDIR=${D}{ARG#--sbindir=} ;;
-        "--libdir="*)         LIBDIR=${D}{ARG#--libdir=} ;;
-        "--libexecdir="*)     LIBEXECDIR=${D}{ARG#--libexecdir=} ;;
-        "--datadir="*)        DATADIR=${D}{ARG#--datadir=} ;;
-        "--sysconfdir="*)     SYSCONFDIR=${D}{ARG#--sysconfdir=} ;;
-        "--sharedstatedir="*) SHAREDSTATEDIR=${D}{ARG#--sharedstatedir=} ;;
-        "--localstatedir="*)  LOCALSTATEDIR=${D}{ARG#--localstatedir=} ;;
-        "--includedir="*)     INCLUDEDIR=${D}{ARG#--includedir=} ;;
-        "--infodir="*)        INFODIR=${D}{ARG#--infodir=} ;;
-        "--mandir"*)          MANDIR=${D}{ARG#--mandir} ;;
+        "--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=} ;;
+        "--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" ;;
@@ -135,19 +143,41 @@
 
 ## Begin unparsed content. **
 #[[
-# set dir variables
-: ${EPREFIX:="$PREFIX"}
-: ${BINDIR:="$EPREFIX/bin"}
-: ${SBINDIR:="$EPREFIX/sbin"}
-: ${LIBDIR:="$EPREFIX/lib"}
-: ${LIBEXECDIR:="$EPREFIX/libexec"}
-: ${DATADIR:="$PREFIX/share"}
-: ${SYSCONFDIR:="$PREFIX/etc"}
-: ${SHAREDSTATEDIR:="$PREFIX/com"}
-: ${LOCALSTATEDIR:="$PREFIX/var"}
-: ${INCLUDEDIR:="$PREFIX/include"}
-: ${INFODIR:="$PREFIX/info"}
-: ${MANDIR:="$PREFIX/man"}
+
+# set defaults for dir variables
+: ${exec_prefix:="$prefix"}
+: ${bindir:='${exec_prefix}/bin'}
+: ${sbindir:='${exec_prefix}/sbin'}
+: ${libdir:='${exec_prefix}/lib'}
+: ${libexecdir:='${exec_prefix}/libexec'}
+: ${datarootdir:='${prefix}/share'}
+: ${datadir:='${datarootdir}'}
+: ${sysconfdir:='${prefix}/etc'}
+: ${sharedstatedir:='${prefix}/com'}
+: ${localstatedir:='${prefix}/var'}
+: ${runstatedir:='${localstatedir}/run'}
+: ${includedir:='${prefix}/include'}
+: ${infodir:='${datarootdir}/info'}
+: ${mandir:='${datarootdir}/man'}
+: ${localedir:='${datarootdir}/locale'}
+
+# check if a config.site exists and load it
+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
+    done
+elif [ -f "$prefix/share/config.site" ]; then
+    printf "loading site defaults... "
+    . "$prefix/share/config.site"
+    echo ok
+elif [ -f "$prefix/etc/config.site" ]; then
+    printf "loading site defaults... "
+    . "$prefix/etc/config.site"
+    echo ok
+fi
 
 # Test for availability of pkg-config
 PKG_CONFIG=`command -v pkg-config`
@@ -203,25 +233,26 @@
 
 # generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
-PREFIX="$PREFIX"
-EPREFIX="$EPREFIX"
-BINDIR="$BINDIR"
-SBINDIR="$SBINDIR"
-LIBDIR="$LIBDIR"
-LIBEXECDIR="$LIBEXECDIR"
-DATADIR="$DATADIR"
-SYSCONFDIR="$SYSCONFDIR"
-SHAREDSTATEDIR="$SHAREDSTATEDIR"
-LOCALSTATEDIR="$LOCALSTATEDIR"
-INCLUDEDIR="$INCLUDEDIR"
-INFODIR="$INFODIR"
-MANDIR="$MANDIR"
+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__
-sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk"
-
 
 # toolchain detection utilities
 . make/toolchain.sh
@@ -577,8 +608,8 @@
 echo "configure finished"
 echo
 echo "Build Config:"
-echo "  PREFIX:    $PREFIX"
-echo "  TOOLCHAIN: $TOOLCHAIN_NAME"
+echo "  PREFIX:      $prefix"
+echo "  TOOLCHAIN:   $TOOLCHAIN_NAME"
 #if ( $options.size() > 0 )
 echo "Options:"
 cat "$TEMP_DIR/options"
--- a/test/make/project.xml	Tue Oct 10 18:52:47 2023 +0200
+++ b/test/make/project.xml	Tue Oct 10 20:33:49 2023 +0200
@@ -3,8 +3,8 @@
 	<!-- makefile config -->
 	<config>
 		<var name="HOST" exec="true">uname -n</var>
-		<var name="PREFIX">`pwd`/work</var>
-		<var name="INSTALL_DIR">$PREFIX</var>
+		<var name="prefix">`pwd`/work</var>
+		<var name="install_dir">$prefix</var>
 	</config>
 	
 	<dependency>

mercurial