--- a/make/configure.vm Thu Apr 10 21:34:33 2025 +0200 +++ b/make/configure.vm Wed May 07 23:59:13 2025 +0200 @@ -1,5 +1,133 @@ #!/bin/sh +#set( $D = '$' ) +#[[ +# some utility functions +isplatform() +{ + for p in $PLATFORM + do + if [ "$p" = "$1" ]; then + return 0 + fi + done + return 1 +} +notisplatform() +{ + for p in $PLATFORM + do + if [ "$p" = "$1" ]; then + return 1 + fi + done + return 0 +} +istoolchain() +{ + for t in $TOOLCHAIN + do + if [ "$t" = "$1" ]; then + return 0 + fi + done + return 1 +} +notistoolchain() +{ + for t in $TOOLCHAIN + do + if [ "$t" = "$1" ]; then + return 1 + fi + done + return 0 +} + +# clean abort +abort_configure() +{ + rm -Rf "$TEMP_DIR" + exit 1 +} + +# Test for availability of pkg-config +PKG_CONFIG=`command -v pkg-config` +: ${PKG_CONFIG:="false"} + +# Simple uname based platform detection +# $PLATFORM is used for platform dependent dependency selection +OS=`uname -s` +OS_VERSION=`uname -r` +printf "detect platform... " +if [ "$OS" = "SunOS" ]; then + PLATFORM="solaris sunos unix svr4" +elif [ "$OS" = "Linux" ]; then + PLATFORM="linux unix" +elif [ "$OS" = "FreeBSD" ]; then + PLATFORM="freebsd bsd unix" +elif [ "$OS" = "OpenBSD" ]; then + PLATFORM="openbsd bsd unix" +elif [ "$OS" = "NetBSD" ]; then + PLATFORM="netbsd bsd unix" +elif [ "$OS" = "Darwin" ]; then + PLATFORM="macos osx bsd unix" +elif echo "$OS" | grep -i "MINGW" > /dev/null; then + PLATFORM="windows mingw" +fi +: ${PLATFORM:="unix"} + +PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` +echo "$PLATFORM_NAME" +]]# + +# help text +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] + +Build Types: + --debug add extra compile flags for debug builds + --release add extra compile flags for release builds +#if( $options.size() > 0 ) + +Options: +#foreach( $opt in $options ) + --${opt.argument}=${opt.valuesString} +#end +#end +#if( $features.size() > 0 ) + +Optional Features: +#foreach( $feature in $features ) +${feature.helpText} +#end +#end + +__EOF__ +} + # create temporary directory TEMP_DIR=".tmp-`uname -n`" rm -Rf "$TEMP_DIR" @@ -33,12 +161,23 @@ mandir= # custom variables -#foreach( $var in $vars ) -#if( $var.exec ) -${var.varName}=`${var.value}` -#else -${var.varName}="${var.value}" +#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.exec ) + ${var.varName}=`${var.value}` + #else + ${var.varName}="${var.value}" + #end + #end +fi #end # features @@ -48,67 +187,10 @@ #end #end -# clean abort -abort_configure() -{ - rm -Rf "$TEMP_DIR" - exit 1 -} - -# help text -printhelp() -{ - echo "Usage: $0 [OPTIONS]..." - cat << __EOF__ -Installation directories: - --prefix=PREFIX path prefix for architecture-independent files - [/usr] - --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] - -#if( $options.size() > 0 ) -Options: - --debug add extra compile flags for debug builds - --release add extra compile flags for release builds -#foreach( $opt in $options ) - --${opt.argument}=${opt.valuesString} -#end - -#end -#if( $features.size() > 0 ) -Optional Features: -#foreach( $feature in $features ) -#if( $feature.auto ) - --disable-${feature.arg} -#else - --enable-${feature.arg} -#end -#end - -#end -__EOF__ -} - # # parse arguments # BUILD_TYPE="default" -#set( $D = '$' ) for ARG in "$@" do case "$ARG" in @@ -127,11 +209,12 @@ "--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" ;; + "--help"*) printhelp; abort_configure ;; + "--debug") BUILD_TYPE="debug" ;; + "--release") BUILD_TYPE="release" ;; #foreach( $opt in $options ) "--${opt.argument}="*) ${opt.varName}=${D}{ARG#--${opt.argument}=} ;; + "--${opt.argument}") echo "option '$ARG' needs a value:"; echo " $ARG=${opt.valuesString}"; abort_configure ;; #end #foreach( $feature in $features ) "--enable-${feature.arg}") ${feature.varName}=on ;; @@ -161,6 +244,22 @@ : ${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 if [ -n "$CONFIG_SITE" ]; then # CONFIG_SITE may contain space separated file names @@ -178,79 +277,29 @@ . "$prefix/etc/config.site" echo ok fi - -# Test for availability of pkg-config -PKG_CONFIG=`command -v pkg-config` -: ${PKG_CONFIG:="false"} - -# Simple uname based platform detection -# $PLATFORM is used for platform dependent dependency selection -OS=`uname -s` -OS_VERSION=`uname -r` -printf "detect platform... " -if [ "$OS" = "SunOS" ]; then - PLATFORM="solaris sunos unix svr4" -fi -if [ "$OS" = "Linux" ]; then - PLATFORM="linux unix" -fi -if [ "$OS" = "FreeBSD" ]; then - PLATFORM="freebsd bsd unix" -fi -if [ "$OS" = "Darwin" ]; then - PLATFORM="macos osx bsd unix" -fi -if echo "$OS" | grep -i "MINGW" > /dev/null; then - PLATFORM="windows mingw" -fi -: ${PLATFORM:="unix"} - -PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -` -echo "$PLATFORM_NAME" - -isplatform() -{ - for p in $PLATFORM - do - if [ "$p" = "$1" ]; then - return 0 - fi - done - return 1 -} -notisplatform() -{ - for p in $PLATFORM - do - if [ "$p" = "$1" ]; then - return 1 - fi - done - return 0 -} ]]# ## End of unparsed content ** # 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" +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}" +${var.varName}=${D}${var.varName} #end __EOF__ @@ -286,10 +335,18 @@ return 0 } +print_check_msg() +{ + if [ -z "$1" ]; then + shift + printf "$@" + fi +} + #foreach( $dependency in $namedDependencies ) dependency_error_${dependency.id}() { - printf "checking for ${dependency.name}... " + print_check_msg "${D}dep_checked_${dependency.id}" "checking for ${dependency.name}... " #foreach( $sub in $dependency.subdependencies ) # dependency $sub.fullName while true @@ -299,8 +356,13 @@ break fi #end + #if( $sub.toolchain ) + if notistoolchain "${sub.toolchain}"; then + break + fi + #end #foreach( $np in $sub.notList ) - if isplatform "${np}"; then + if isplatform "${np}" || istoolchain "${np}"; then break fi #end @@ -346,19 +408,18 @@ $sub.make __EOF__ #end - echo yes + print_check_msg "${D}dep_checked_${dependency.id}" "yes\n" + dep_checked_${dependency.id}=1 return 1 done #end - echo no + print_check_msg "${D}dep_checked_${dependency.id}" "no\n" + dep_checked_${dependency.id}=1 return 0 } #end - - - # start collecting dependency information echo > "$TEMP_DIR/flags.mk" @@ -366,9 +427,9 @@ ERROR=0 #if( $dependencies.size() > 0 ) # unnamed dependencies -TEMP_CFLAGS= -TEMP_CXXFLAGS= -TEMP_LDFLAGS= +TEMP_CFLAGS="$CFLAGS" +TEMP_CXXFLAGS="$CXXFLAGS" +TEMP_LDFLAGS="$LDFLAGS" #foreach( $dependency in $dependencies ) while true do @@ -377,8 +438,13 @@ break fi #end + #if( $dependency.toolchain ) + if notistoolchain "${dependency.toolchain}"; then + break + fi + #end #foreach( $np in $dependency.notList ) - if isplatform "${np}"; then + if isplatform "${np}" || istoolchain "${np}"; then break fi #end @@ -397,13 +463,15 @@ fi #end #foreach( $pkg in $dependency.pkgconfig ) - printf "checking for pkg-config package $pkg.name... " + print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "checking for pkg-config package $pkg.name... " if test_pkg_config "$pkg.name" "$pkg.atleast" "$pkg.exact" "$pkg.max" ; then - echo yes + print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "yes\n" + dep_pkgconfig_checked_${pkg.id}=1 TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags $pkg.name`" TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs $pkg.name`" else - echo no + print_check_msg "${D}dep_pkgconfig_checked_${pkg.id}" "no\n" + dep_pkgconfig_checked_${pkg.id}=1 ERROR=1 break fi @@ -433,12 +501,22 @@ done #end +# build type +if [ "$BUILD_TYPE" = "debug" ]; then + TEMP_CFLAGS="\${DEBUG_CFLAGS}$TEMP_CFLAGS" + TEMP_CXXFLAGS="\${DEBUG_CXXFLAGS}$TEMP_CXXFLAGS" +fi +if [ "$BUILD_TYPE" = "release" ]; then + TEMP_CFLAGS="\${RELEASE_CFLAGS}$TEMP_CFLAGS" + TEMP_CXXFLAGS="\${RELEASE_CXXFLAGS}$TEMP_CXXFLAGS" +fi + # add general dependency flags to flags.mk echo "# general flags" >> "$TEMP_DIR/flags.mk" -if [ -n "${TEMP_CFLAGS}" -a -n "$lang_c" ]; then +if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ -n "${TEMP_CXXFLAGS}" -a -n "$lang_cpp" ]; then +if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" fi if [ -n "${TEMP_LDFLAGS}" ]; then @@ -519,6 +597,35 @@ unset ${feature.varName} fi fi +if [ -n "${D}${feature.varName}" ]; then + : +#foreach( $def in $feature.defines ) + TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" + TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" +#end +#if( $feature.hasMake() ) + cat >> "$TEMP_DIR/make.mk" << __EOF__ +$feature.make +__EOF__ +#end +else + : +#foreach( $def in $feature.disabled.defines ) + TEMP_CFLAGS="$TEMP_CFLAGS ${def.toFlags()}" + TEMP_CXXFLAGS="$TEMP_CXXFLAGS ${def.toFlags()}" +#end +#if( $feature.disabled.hasMake() ) + cat >> "$TEMP_DIR/make.mk" << __EOF__ +$feature.disabled.make +__EOF__ +#end +#foreach( $dependency in $feature.disabled.dependencies ) + if dependency_error_$dependency ; then + DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED ${dependency} " + ERROR=1 + fi +#end +fi #end #foreach( $opt in $target.options ) @@ -565,32 +672,21 @@ DEPENDENCIES_FAILED="option '${opt.argument}' $DEPENDENCIES_FAILED" fi #end + else + echo + echo "Invalid option value - usage:" + echo " --${opt.argument}=${opt.valuesString}" + abort_configure fi fi #end -if [ -n "${TEMP_CFLAGS}" -a -n "$lang_c" ]; then +if [ -n "${TEMP_CFLAGS}" ] && [ -n "$lang_c" ]; then echo "${target.cFlags} += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ -n "${TEMP_CXXFLAGS}" -a -n "$lang_cpp" ]; then +if [ -n "${TEMP_CXXFLAGS}" ] && [ -n "$lang_cpp" ]; then echo "${target.cxxFlags} += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" fi -if [ "$BUILD_TYPE" = "debug" ]; then - if [ -n "$lang_c" ]; then - echo '${target.cFlags} += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" - fi - if [ -n "$lang_cpp" ]; then - echo '${target.cxxFlags} += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" - fi -fi -if [ "$BUILD_TYPE" = "release" ]; then - if [ -n "$lang_c" ]; then - echo '${target.cFlags} += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" - fi - if [ -n "$lang_cpp" ]; then - echo '${target.cxxFlags} += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" - fi -fi if [ -n "${TEMP_LDFLAGS}" ]; then echo "${target.ldFlags} += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" fi @@ -607,14 +703,73 @@ echo "configure finished" echo +echo "Toolchain" +echo " name: $TOOLCHAIN_NAME" +if [ -n "$TOOLCHAIN_CC" ]; then + echo " cc: $TOOLCHAIN_CC" +fi +if [ -n "$TOOLCHAIN_CXX" ]; then + echo " cxx: $TOOLCHAIN_CXX" +fi +if [ -n "$TOOLCHAIN_WSIZE" ]; then + echo " word size: $TOOLCHAIN_WSIZE bit" +fi +if [ -n "$TOOLCHAIN_CSTD" ]; then + echo " default C std: $TOOLCHAIN_CSTD" +fi +echo echo "Build Config:" -echo " PREFIX: $prefix" -echo " TOOLCHAIN: $TOOLCHAIN_NAME" +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 #if ( $options.size() > 0 ) +echo echo "Options:" cat "$TEMP_DIR/options" #end #if ( $features.size() > 0 ) +echo echo "Features:" #foreach( $feature in $features ) if [ -n "${D}${feature.varName}" ]; then @@ -627,14 +782,15 @@ echo # generate the config.mk file +pwd=`pwd` cat > "$TEMP_DIR/config.mk" << __EOF__ # -# config.mk generated by configure +# config.mk generated by: +# pwd: $pwd +# $0 $@ # __EOF__ write_toolchain_defaults "$TEMP_DIR/toolchain.mk" -cat "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk +cat "$TEMP_DIR/config.mk" "$TEMP_DIR/vars.mk" "$TEMP_DIR/toolchain.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk rm -Rf "$TEMP_DIR" - -