fix help text and config summary generated even when there are no variables

Mon, 01 Dec 2025 20:32:12 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 01 Dec 2025 20:32:12 +0100
changeset 175
4869b7779d6d
parent 174
bb760ad2211d
child 176
f0f3d19a0aa1

fix help text and config summary generated even when there are no variables

fixes #765

src/main/resources/make/configure.vm file | annotate | diff | comparison | revisions
test/configure file | annotate | diff | comparison | revisions
test/configure2 file | annotate | diff | comparison | revisions
test/make/configure.vm file | annotate | diff | comparison | revisions
--- a/src/main/resources/make/configure.vm	Mon Dec 01 20:31:54 2025 +0100
+++ b/src/main/resources/make/configure.vm	Mon Dec 01 20:32:12 2025 +0100
@@ -86,7 +86,10 @@
 printhelp()
 {
     echo "Usage: $0 [OPTIONS]..."
-    echo 'Configuration:'
+    if [ $has_config_vars__ -eq 1 ] ; then
+        echo
+        echo "Configuration:"
+    fi
 #foreach( $cfg in $config )
 if true \
 #if( $cfg.platform )
@@ -99,7 +102,7 @@
     :
     #foreach( $var in $cfg.vars )
     #if( $var.overridable )
-    if test -z "${D}${var.varName}__described__"; then
+    if [ -z "${D}${var.varName}__described__" ] ; then
         ${var.varName}__described__=1
         cat << '__EOF__'
 ${var.helpText}
@@ -147,6 +150,7 @@
 touch "$TEMP_DIR/features"
 
 # config variables
+has_config_vars__=0
 #foreach( $cfg in $config )
 if true \
 #if( $cfg.platform )
@@ -158,7 +162,8 @@
       ; then
     :
     #foreach( $var in $cfg.vars )
-    if test -z "${D}${var.varName}__initialized__"; then
+    if [ -z "${D}${var.varName}__initialized__" ] ; then
+        has_config_vars__=1
         ${var.varName}__initialized__=1
         #if( $var.exec )
         ${var.varName}=`${var.value}`
@@ -715,14 +720,18 @@
 if [ -n "$TOOLCHAIN_CSTD" ]; then
     echo "  default C std:  $TOOLCHAIN_CSTD"
 fi
-echo
-echo "Config:"
+if [ ${D}has_config_vars__ -eq 1 ]; then
+    echo
+    echo "Config:"
 #foreach( $var in $vars )
 #if ($var.overridable)
-    printf '  %-16s' '${var.arg}:'
-    echo "${D}${var.varName}"
+    if [ -n "${D}${var.varName}__initialized__" ]; then
+        printf '  %-16s' '${var.arg}:'
+        echo "${D}${var.varName}"
+    fi
 #end
 #end
+fi
 #if ( $options.size() > 0 )
 echo
 echo "Options:"
--- a/test/configure	Mon Dec 01 20:31:54 2025 +0100
+++ b/test/configure	Mon Dec 01 20:32:12 2025 +0100
@@ -85,23 +85,26 @@
 printhelp()
 {
     echo "Usage: $0 [OPTIONS]..."
-    echo 'Configuration:'
+    if [ $has_config_vars__ -eq 1 ] ; then
+        echo
+        echo "Configuration:"
+    fi
 if true \
       ; then
     :
-    if test -z "$prefix__described__"; then
+    if [ -z "$prefix__described__" ] ; then
         prefix__described__=1
         cat << '__EOF__'
   --prefix                path prefix for architecture-independent files [/usr]
 __EOF__
     fi
-    if test -z "$exec_prefix__described__"; then
+    if [ -z "$exec_prefix__described__" ] ; then
         exec_prefix__described__=1
         cat << '__EOF__'
   --exec-prefix           path prefix for architecture-dependent files [PREFIX]
 __EOF__
     fi
-    if test -z "$libdir__described__"; then
+    if [ -z "$libdir__described__" ] ; then
         libdir__described__=1
         cat << '__EOF__'
   --libdir                object code libraries [EPREFIX/lib]
@@ -145,22 +148,27 @@
 touch "$TEMP_DIR/features"
 
 # config variables
+has_config_vars__=0
 if true \
       ; then
     :
-    if test -z "$prefix__initialized__"; then
+    if [ -z "$prefix__initialized__" ] ; then
+        has_config_vars__=1
         prefix__initialized__=1
         prefix='/usr'
     fi
-    if test -z "$exec_prefix__initialized__"; then
+    if [ -z "$exec_prefix__initialized__" ] ; then
+        has_config_vars__=1
         exec_prefix__initialized__=1
         exec_prefix=''
     fi
-    if test -z "$libdir__initialized__"; then
+    if [ -z "$libdir__initialized__" ] ; then
+        has_config_vars__=1
         libdir__initialized__=1
         libdir=''
     fi
-    if test -z "$HOST__initialized__"; then
+    if [ -z "$HOST__initialized__" ] ; then
+        has_config_vars__=1
         HOST__initialized__=1
         HOST=`uname -n`
     fi
@@ -169,7 +177,8 @@
       && notisplatform "mingw" \
       ; then
     :
-    if test -z "$PWD__initialized__"; then
+    if [ -z "$PWD__initialized__" ] ; then
+        has_config_vars__=1
         PWD__initialized__=1
         PWD='pwd'
     fi
@@ -178,7 +187,8 @@
     && isplatform "mingw" \
       ; then
     :
-    if test -z "$PWD__initialized__"; then
+    if [ -z "$PWD__initialized__" ] ; then
+        has_config_vars__=1
         PWD__initialized__=1
         PWD='pwd -W'
     fi
@@ -685,14 +695,22 @@
 if [ -n "$TOOLCHAIN_CSTD" ]; then
     echo "  default C std:  $TOOLCHAIN_CSTD"
 fi
-echo
-echo "Config:"
-    printf '  %-16s' 'prefix:'
-    echo "$prefix"
-    printf '  %-16s' 'exec-prefix:'
-    echo "$exec_prefix"
-    printf '  %-16s' 'libdir:'
-    echo "$libdir"
+if [ $has_config_vars__ -eq 1 ]; then
+    echo
+    echo "Config:"
+    if [ -n "$prefix__initialized__" ]; then
+        printf '  %-16s' 'prefix:'
+        echo "$prefix"
+    fi
+    if [ -n "$exec_prefix__initialized__" ]; then
+        printf '  %-16s' 'exec-prefix:'
+        echo "$exec_prefix"
+    fi
+    if [ -n "$libdir__initialized__" ]; then
+        printf '  %-16s' 'libdir:'
+        echo "$libdir"
+    fi
+fi
 echo
 echo "Features:"
 printf '  %-16s' 'pg:'
--- a/test/configure2	Mon Dec 01 20:31:54 2025 +0100
+++ b/test/configure2	Mon Dec 01 20:32:12 2025 +0100
@@ -85,49 +85,52 @@
 printhelp()
 {
     echo "Usage: $0 [OPTIONS]..."
-    echo 'Configuration:'
+    if [ $has_config_vars__ -eq 1 ] ; then
+        echo
+        echo "Configuration:"
+    fi
 if true \
       ; then
     :
-    if test -z "$prefix__described__"; then
+    if [ -z "$prefix__described__" ] ; then
         prefix__described__=1
         cat << '__EOF__'
   --prefix                path prefix for architecture-independent files 
                           [`pwd`/work]
 __EOF__
     fi
-    if test -z "$exec_prefix__described__"; then
+    if [ -z "$exec_prefix__described__" ] ; then
         exec_prefix__described__=1
         cat << '__EOF__'
   --exec-prefix           path prefix for architecture-dependent files [PREFIX]
 __EOF__
     fi
-    if test -z "$libdir__described__"; then
+    if [ -z "$libdir__described__" ] ; then
         libdir__described__=1
         cat << '__EOF__'
   --libdir                object code libraries [EPREFIX/lib]
 __EOF__
     fi
-    if test -z "$datarootdir__described__"; then
+    if [ -z "$datarootdir__described__" ] ; then
         datarootdir__described__=1
         cat << '__EOF__'
   --datarootdir           read-only architecture-independent data root 
                           [PREFIX/share]
 __EOF__
     fi
-    if test -z "$localstatedir__described__"; then
+    if [ -z "$localstatedir__described__" ] ; then
         localstatedir__described__=1
         cat << '__EOF__'
   --localstatedir         modifiable single-machine data [PREFIX/var]
 __EOF__
     fi
-    if test -z "$libdatadir__described__"; then
+    if [ -z "$libdatadir__described__" ] ; then
         libdatadir__described__=1
         cat << '__EOF__'
   --libdatadir            miscellaneous files for libraries [PREFIX/libdata]
 __EOF__
     fi
-    if test -z "$TOOLKIT_HOME__described__"; then
+    if [ -z "$TOOLKIT_HOME__described__" ] ; then
         TOOLKIT_HOME__described__=1
         cat << '__EOF__'
   --toolkit-home          the location of the toolkit installation [/usr]
@@ -170,38 +173,47 @@
 touch "$TEMP_DIR/features"
 
 # config variables
+has_config_vars__=0
 if true \
       ; then
     :
-    if test -z "$prefix__initialized__"; then
+    if [ -z "$prefix__initialized__" ] ; then
+        has_config_vars__=1
         prefix__initialized__=1
         prefix='`pwd`/work'
     fi
-    if test -z "$exec_prefix__initialized__"; then
+    if [ -z "$exec_prefix__initialized__" ] ; then
+        has_config_vars__=1
         exec_prefix__initialized__=1
         exec_prefix=''
     fi
-    if test -z "$libdir__initialized__"; then
+    if [ -z "$libdir__initialized__" ] ; then
+        has_config_vars__=1
         libdir__initialized__=1
         libdir=''
     fi
-    if test -z "$datarootdir__initialized__"; then
+    if [ -z "$datarootdir__initialized__" ] ; then
+        has_config_vars__=1
         datarootdir__initialized__=1
         datarootdir=''
     fi
-    if test -z "$localstatedir__initialized__"; then
+    if [ -z "$localstatedir__initialized__" ] ; then
+        has_config_vars__=1
         localstatedir__initialized__=1
         localstatedir='/var'
     fi
-    if test -z "$libdatadir__initialized__"; then
+    if [ -z "$libdatadir__initialized__" ] ; then
+        has_config_vars__=1
         libdatadir__initialized__=1
         libdatadir='$prefix/libdata'
     fi
-    if test -z "$SRCDIR__initialized__"; then
+    if [ -z "$SRCDIR__initialized__" ] ; then
+        has_config_vars__=1
         SRCDIR__initialized__=1
         SRCDIR=`pwd`
     fi
-    if test -z "$TOOLKIT_HOME__initialized__"; then
+    if [ -z "$TOOLKIT_HOME__initialized__" ] ; then
+        has_config_vars__=1
         TOOLKIT_HOME__initialized__=1
         TOOLKIT_HOME='/usr'
     fi
@@ -916,22 +928,38 @@
 if [ -n "$TOOLCHAIN_CSTD" ]; then
     echo "  default C std:  $TOOLCHAIN_CSTD"
 fi
-echo
-echo "Config:"
-    printf '  %-16s' 'prefix:'
-    echo "$prefix"
-    printf '  %-16s' 'exec-prefix:'
-    echo "$exec_prefix"
-    printf '  %-16s' 'libdir:'
-    echo "$libdir"
-    printf '  %-16s' 'datarootdir:'
-    echo "$datarootdir"
-    printf '  %-16s' 'localstatedir:'
-    echo "$localstatedir"
-    printf '  %-16s' 'libdatadir:'
-    echo "$libdatadir"
-    printf '  %-16s' 'toolkit-home:'
-    echo "$TOOLKIT_HOME"
+if [ $has_config_vars__ -eq 1 ]; then
+    echo
+    echo "Config:"
+    if [ -n "$prefix_initialized__" ]; then
+        printf '  %-16s' 'prefix:'
+        echo "$prefix"
+    fi
+    if [ -n "$exec_prefix_initialized__" ]; then
+        printf '  %-16s' 'exec-prefix:'
+        echo "$exec_prefix"
+    fi
+    if [ -n "$libdir_initialized__" ]; then
+        printf '  %-16s' 'libdir:'
+        echo "$libdir"
+    fi
+    if [ -n "$datarootdir_initialized__" ]; then
+        printf '  %-16s' 'datarootdir:'
+        echo "$datarootdir"
+    fi
+    if [ -n "$localstatedir_initialized__" ]; then
+        printf '  %-16s' 'localstatedir:'
+        echo "$localstatedir"
+    fi
+    if [ -n "$libdatadir_initialized__" ]; then
+        printf '  %-16s' 'libdatadir:'
+        echo "$libdatadir"
+    fi
+    if [ -n "$TOOLKIT_HOME_initialized__" ]; then
+        printf '  %-16s' 'toolkit-home:'
+        echo "$TOOLKIT_HOME"
+    fi
+fi
 echo
 echo "Options:"
 cat "$TEMP_DIR/options"
--- a/test/make/configure.vm	Mon Dec 01 20:31:54 2025 +0100
+++ b/test/make/configure.vm	Mon Dec 01 20:32:12 2025 +0100
@@ -86,7 +86,10 @@
 printhelp()
 {
     echo "Usage: $0 [OPTIONS]..."
-    echo 'Configuration:'
+    if [ $has_config_vars__ -eq 1 ] ; then
+        echo
+        echo "Configuration:"
+    fi
 #foreach( $cfg in $config )
 if true \
 #if( $cfg.platform )
@@ -99,7 +102,7 @@
     :
     #foreach( $var in $cfg.vars )
     #if( $var.overridable )
-    if test -z "${D}${var.varName}__described__"; then
+    if [ -z "${D}${var.varName}__described__" ] ; then
         ${var.varName}__described__=1
         cat << '__EOF__'
 ${var.helpText}
@@ -147,6 +150,7 @@
 touch "$TEMP_DIR/features"
 
 # config variables
+has_config_vars__=0
 #foreach( $cfg in $config )
 if true \
 #if( $cfg.platform )
@@ -158,7 +162,8 @@
       ; then
     :
     #foreach( $var in $cfg.vars )
-    if test -z "${D}${var.varName}__initialized__"; then
+    if [ -z "${D}${var.varName}__initialized__" ] ; then
+        has_config_vars__=1
         ${var.varName}__initialized__=1
         #if( $var.exec )
         ${var.varName}=`${var.value}`
@@ -715,14 +720,18 @@
 if [ -n "$TOOLCHAIN_CSTD" ]; then
     echo "  default C std:  $TOOLCHAIN_CSTD"
 fi
-echo
-echo "Config:"
+if [ ${D}has_config_vars__ -eq 1 ]; then
+    echo
+    echo "Config:"
 #foreach( $var in $vars )
 #if ($var.overridable)
-    printf '  %-16s' '${var.arg}:'
-    echo "${D}${var.varName}"
+    if [ -n "${D}${var.varName}__initialized__" ]; then
+        printf '  %-16s' '${var.arg}:'
+        echo "${D}${var.varName}"
+    fi
 #end
 #end
+fi
 #if ( $options.size() > 0 )
 echo
 echo "Options:"

mercurial