--- a/src/test/resources/golden-sample/configure Mon Sep 18 22:49:54 2023 +0200 +++ b/src/test/resources/golden-sample/configure Mon Sep 18 23:20:29 2023 +0200 @@ -167,7 +167,7 @@ } -# generate config.mk +# generate vars.mk cat > "$TEMP_DIR/vars.mk" << __EOF__ PREFIX=$PREFIX EPREFIX=$EPREFIX @@ -186,22 +186,11 @@ PREFIX=$PREFIX INSTALL_DIR=$INSTALL_DIR __EOF__ -cat > "$TEMP_DIR/config.mk" << __EOF__ -# -# config.mk generated by configure -# -__EOF__ -sort -u "$TEMP_DIR/vars.mk" >> "$TEMP_DIR/config.mk" +sort -u -o "$TEMP_DIR/vars.mk" "$TEMP_DIR/vars.mk" -# toolchain detection -# this will insert make vars to config.mk +# toolchain detection utilities . make/toolchain.sh -if [ -n "$TOOLCHAIN_ERROR" ]; then - echo "Toolchain error: $TOOLCHAIN_ERROR" - echo "Abort." - abort_configure -fi # # DEPENDENCIES @@ -214,11 +203,11 @@ { if "$PKG_CONFIG" --exists "$1" ; then : else return 1 ; fi - if [ -n "$2" ] && "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : + if [ -z "$2" ] || "$PKG_CONFIG" --atleast-version="$2" "$1" ; then : else return 1 ; fi - if [ -n "$3" ] && "$PKG_CONFIG" --exact-version="$3" "$1" ; then : + if [ -z "$3" ] || "$PKG_CONFIG" --exact-version="$3" "$1" ; then : else return 1 ; fi - if [ -n "$4" ] && "$PKG_CONFIG" --max-version="$4" "$1" ; then : + if [ -z "$4" ] || "$PKG_CONFIG" --max-version="$4" "$1" ; then : else return 1 ; fi return 0 } @@ -321,28 +310,41 @@ return 0 } +# start collecting dependency information +echo > "$TEMP_DIR/flags.mk" + DEPENDENCIES_FAILED= ERROR=0 # unnamed dependencies TEMP_CFLAGS= +TEMP_CXXFLAGS= TEMP_LDFLAGS= while true do while true do + if detect_cpp_compiler ; then + : + else + ERROR=1 + break + fi break done break done -# add unnamed dependency flags to config.mk -echo >> "$TEMP_DIR/config.mk" +# add general dependency flags to flags.mk +echo "# general flags" >> "$TEMP_DIR/flags.mk" if [ -n "${TEMP_CFLAGS}" ]; then - echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk" + echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_CXXFLAGS}" ]; then + echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" fi if [ -n "${TEMP_LDFLAGS}" ]; then - echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk" + echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" fi # @@ -353,8 +355,11 @@ # TARGETS # +echo >> "$TEMP_DIR/flags.mk" # Target +echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk" TEMP_CFLAGS= +TEMP_CXXFLAGS= TEMP_LDFLAGS= if dependency_error_libxml2; then @@ -381,20 +386,26 @@ fi -echo >> "$TEMP_DIR/config.mk" if [ -n "${TEMP_CFLAGS}" ]; then - echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk" + echo "CFLAGS += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk" +fi +if [ -n "${TEMP_CXXFLAGS}" ]; then + echo "CXXFLAGS += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk" fi if [ "$BUILD_TYPE" = "debug" ]; then - echo 'CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk" + echo 'CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + echo 'CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" fi if [ "$BUILD_TYPE" = "release" ]; then - echo 'CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk" + echo 'CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk" + echo 'CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk" fi if [ -n "${TEMP_LDFLAGS}" ]; then - echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk" + echo "LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk" fi + +# final result if [ $ERROR -ne 0 ]; then echo echo "Error: Unresolved dependencies" @@ -414,7 +425,16 @@ echo " pg: off" fi echo -cat "$TEMP_DIR/config.mk" "$TEMP_DIR/make.mk" > config.mk + +# generate the config.mk file +cat > "$TEMP_DIR/config.mk" << __EOF__ +# +# config.mk generated by configure +# + +__EOF__ +write_toolchain_defaults "$TEMP_DIR/config.mk" +cat "$TEMP_DIR/config.mk" "$TEMP_DIR/flags.mk" "$TEMP_DIR/make.mk" > config.mk rm -Rf "$TEMP_DIR"