src/test/resources/golden-sample/configure2

changeset 66
dc758dcd4645
parent 63
ac47c2fb2c4a
child 67
e43d30273f74
--- a/src/test/resources/golden-sample/configure2	Mon Sep 18 22:49:54 2023 +0200
+++ b/src/test/resources/golden-sample/configure2	Mon Sep 18 23:20:29 2023 +0200
@@ -173,7 +173,7 @@
 }
 
 
-# generate config.mk
+# generate vars.mk
 cat > "$TEMP_DIR/vars.mk" << __EOF__
 PREFIX=$PREFIX
 EPREFIX=$EPREFIX
@@ -189,22 +189,11 @@
 INFODIR=$INFODIR
 MANDIR=$MANDIR
 __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
@@ -217,11 +206,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
 }
@@ -434,15 +423,25 @@
     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_c_compiler ; then
+            :
+        else
+            ERROR=1
+            break
+        fi
 
         cat >> "$TEMP_DIR/make.mk" << __EOF__
 MVAR = 123
@@ -454,13 +453,16 @@
     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
 
 #
@@ -476,6 +478,7 @@
         return 1
     fi
         TEMP_CFLAGS="$TEMP_CFLAGS -Da=b"
+        TEMP_CXXFLAGS="$TEMP_CXXFLAGS -Da=b"
     cat >> "$TEMP_DIR/make.mk" << __EOF__
 UIOBJ += graphics_cairo.o
 
@@ -523,8 +526,11 @@
 # TARGETS
 #
 
+echo >> "$TEMP_DIR/flags.mk"
 # Target: dav
+echo "# flags for target dav" >> "$TEMP_DIR/flags.mk"
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 
 if dependency_error_curl; then
@@ -631,22 +637,29 @@
     fi
 fi
 
-echo >> "$TEMP_DIR/config.mk"
 if [ -n "${TEMP_CFLAGS}" ]; then
-    echo "DAV_CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "DAV_CFLAGS  += $TEMP_CFLAGS" >> "$TEMP_DIR/flags.mk"
+fi
+if [ -n "${TEMP_CXXFLAGS}" ]; then
+    echo "DAV_CXXFLAGS  += $TEMP_CXXFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "debug" ]; then
-    echo 'DAV_CFLAGS += ${DEBUG_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'DAV_CFLAGS += ${DEBUG_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'DAV_CXXFLAGS += ${DEBUG_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ "$BUILD_TYPE" = "release" ]; then
-    echo 'DAV_CFLAGS += ${RELEASE_FLAGS}' >> "$TEMP_DIR/config.mk"
+    echo 'DAV_CFLAGS += ${RELEASE_CC_FLAGS}' >> "$TEMP_DIR/flags.mk"
+    echo 'DAV_CXXFLAGS += ${RELEASE_CXX_FLAGS}' >> "$TEMP_DIR/flags.mk"
 fi
 if [ -n "${TEMP_LDFLAGS}" ]; then
-    echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/config.mk"
+    echo "DAV_LDFLAGS += $TEMP_LDFLAGS" >> "$TEMP_DIR/flags.mk"
 fi
 
+echo >> "$TEMP_DIR/flags.mk"
 # Target
+echo "# flags for unnamed target" >> "$TEMP_DIR/flags.mk"
 TEMP_CFLAGS=
+TEMP_CXXFLAGS=
 TEMP_LDFLAGS=
 
 if dependency_error_deptest; then
@@ -657,20 +670,26 @@
 # Features
 
 
-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"
@@ -697,7 +716,16 @@
 echo "  gui: 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"
 
 

mercurial