--- a/configure Thu Apr 10 21:34:33 2025 +0200 +++ b/configure Wed May 07 23:59:13 2025 +0200 @@ -1,5 +1,118 @@ #!/bin/sh + +# 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 + [$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 + +__EOF__ +} + # create temporary directory TEMP_DIR=".tmp-`uname -n`" rm -Rf "$TEMP_DIR" @@ -36,42 +149,6 @@ # features -# 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] - -__EOF__ -} - # # parse arguments # @@ -94,9 +171,9 @@ "--infodir="*) infodir=${ARG#--infodir=} ;; "--mandir"*) mandir=${ARG#--mandir} ;; "--localedir"*) localedir=${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" ;; "-"*) echo "unknown option: $ARG"; abort_configure ;; esac done @@ -120,6 +197,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 @@ -138,75 +231,25 @@ 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 -} - # 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 __EOF__ # toolchain detection utilities @@ -239,8 +282,13 @@ return 0 } - - +print_check_msg() +{ + if [ -z "$1" ]; then + shift + printf "$@" + fi +} # start collecting dependency information @@ -249,9 +297,9 @@ DEPENDENCIES_FAILED= ERROR=0 # unnamed dependencies -TEMP_CFLAGS= -TEMP_CXXFLAGS= -TEMP_LDFLAGS= +TEMP_CFLAGS="$CFLAGS" +TEMP_CXXFLAGS="$CXXFLAGS" +TEMP_LDFLAGS="$LDFLAGS" while true do while true @@ -266,12 +314,22 @@ break done +# 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 @@ -297,28 +355,12 @@ # Features -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 [ "$BUILD_TYPE" = "debug" ]; then - if [ -n "$lang_c" ]; then - echo 'CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" - fi - if [ -n "$lang_cpp" ]; then - echo 'CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" - fi -fi -if [ "$BUILD_TYPE" = "release" ]; then - if [ -n "$lang_c" ]; then - echo 'CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" - fi - if [ -n "$lang_cpp" ]; then - echo 'CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" - fi -fi if [ -n "${TEMP_LDFLAGS}" ]; then echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" fi @@ -334,20 +376,78 @@ 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 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" - -