Commit cfbf48c4b01fac7efa8ecf737cf9b657a24586d8

Thomas de Grivel 2024-03-28T09:21:43

config.subr: report compile errors

diff --git a/config.subr b/config.subr
index d67f251..a74a94d 100644
--- a/config.subr
+++ b/config.subr
@@ -83,17 +83,20 @@ build_lo_objc() {
 
 build_prog() {
     echo >> ${CONFIG_MK}
-    echo "$PROG_ASAN: $LOCAL_LIBS_ASAN $OBJECTS_ASAN .build/ld_asan" >> ${CONFIG_MK}
+    echo "$PROG_ASAN: $LOCAL_LIBS_ASAN $OBJECTS_ASAN .build/ld_asan" \
+         >> ${CONFIG_MK}
     echo "	.build/ld_asan $PROG_ASAN" >> ${CONFIG_MK}
 
     if $HAVE_GCOV; then
         echo >> ${CONFIG_MK}
-        echo "$PROG_COV: $LOCAL_LIBS_COV $OBJECTS_COV .build/ld_cov" >> ${CONFIG_MK}
+        echo "$PROG_COV: $LOCAL_LIBS_COV $OBJECTS_COV .build/ld_cov" \
+             >> ${CONFIG_MK}
         echo "	.build/ld_cov $PROG_COV" >> ${CONFIG_MK}
     fi
 
     echo >> ${CONFIG_MK}
-    echo "$PROG_DEBUG: $LOCAL_LIBS_DEBUG $OBJECTS_DEBUG .build/ld_debug" >> ${CONFIG_MK}
+    echo "$PROG_DEBUG: $LOCAL_LIBS_DEBUG $OBJECTS_DEBUG .build/ld_debug" \
+         >> ${CONFIG_MK}
     echo "	.build/ld_debug $PROG_DEBUG" >> ${CONFIG_MK}
 
     echo >> ${CONFIG_MK}
@@ -102,7 +105,9 @@ build_prog() {
 }
 
 c_o_rule() {
-    "$CC" $CPPFLAGS $CFLAGS -M "$1" || { echo "$1" | sed -e 's/^\(.*\)\.c$/\1.o: \1.c/'; }
+    "$CC" $CPPFLAGS $CFLAGS -M "$1" || {
+        echo "$1" | sed -e 's/^\(.*\)\.c$/\1.o: \1.c/'
+    }
     echo "$1: $2" | sed -e 's/^\(.*\)\.c:/\1.o:/'
 }
 
@@ -159,9 +164,11 @@ config_have_stat_mtim() {
     echo "  struct stat tmp;" >> "$OUT_C"
     echo "  tmp.st_mtim.tv_sec = 0;" >> "$OUT_C"
     echo "  tmp.st_mtim.tv_nsec = 0;" >> "$OUT_C"
-    echo "  return tmp.st_mtim.tv_sec + tmp.st_mtim.tv_nsec;" >> "$OUT_C"
+    echo "  return tmp.st_mtim.tv_sec + tmp.st_mtim.tv_nsec;" \
+         >> "$OUT_C"
     echo "}" >> "$OUT_C"
-    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT_C" -o "$OUT"; then
+    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} \
+                "$OUT_C" -o "$OUT"; then
         echo "#define HAVE_STAT_MTIM 1" >> "${CONFIG_H}"
         HAVE_STAT_MTIM=true
     else
@@ -188,7 +195,8 @@ config_include() {
         shift
     done
     echo "int main (void) { return 0; }" >> "$OUT_C"
-    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT_C" -o "$OUT" >/dev/null 2>&1; then
+    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} \
+                "$OUT_C" -o "$OUT" >/dev/null 2>&1; then
         echo "#define $1 1" >> "${CONFIG_H}"
         eval "$1=Yes"
     else
@@ -207,7 +215,8 @@ config_include_have() {
     echo "/* generated by configure */" > "$OUT_C"
     echo "$@" >> "$OUT_C"
     echo "int main (void) { return 0; }" >> "$OUT_C"
-    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT_C" ${LIBS} -o "$OUT"; then
+    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} \
+                "$OUT_C" ${LIBS} -o "$OUT"; then
         eval "HAVE_$NAME=true"
         echo "HAVE_$NAME = true" >> ${CONFIG_MK}
     else
@@ -224,7 +233,9 @@ config_lib() {
     OUT=".config_$NAME"
     echo "/* generated by configure */" > "$OUT_C"
     echo "int main (void) { return 0; }" >> "$OUT_C"
-    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT_C" ${LDFLAGS} ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
+    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} \
+                "$OUT_C" ${LDFLAGS} ${LIBS} $@ -o "$OUT" \
+                >/dev/null 2>&1; then
         LIBS="$LIBS $@"
     fi
     rm -f "$OUT" "$OUT_C"
@@ -237,7 +248,8 @@ config_lib_have() {
     OUT=".config_$NAME"
     echo "/* generated by configure */" > "$OUT_C"
     echo "int main (void) { return 0; }" >> "$OUT_C"
-    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT_C" ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
+    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} \
+                "$OUT_C" ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
         eval "HAVE_$NAME=true"
         echo "HAVE_$NAME = true" >> ${CONFIG_MK}
     else
@@ -252,7 +264,9 @@ config_no_undefined() {
     OUT=".config_no_undefined"
     echo "/* generated by configure */" > "$OUT_C"
     echo "int main (void) { return 0; }" >> "$OUT_C"
-    if ${LIBTOOL} --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT_C" ${LDFLAGS} -no-undefined ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
+    if ${LIBTOOL} --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} \
+                  "$OUT_C" ${LDFLAGS} -no-undefined ${LIBS} $@ \
+                  -o "$OUT" >/dev/null 2>&1; then
         LDFLAGS="$LDFLAGS -no-undefined"
     fi
     rm -f "$OUT" "$OUT_C"
@@ -266,7 +280,8 @@ config_objc_include_have() {
     echo "/* generated by configure */" > "$OUT_M"
     echo "$@" >> "$OUT_M"
     echo "int main (void) { return 0; }" >> "$OUT_M"
-    if $LIBTOOL --tag CC --mode link ${OBJCC} ${CPPFLAGS} ${OBJCFLAGS} "$OUT_M" ${LIBS} -o "$OUT" >/dev/null 2>&1; then
+    if $LIBTOOL --tag CC --mode link ${OBJCC} ${CPPFLAGS} ${OBJCFLAGS} \
+                "$OUT_M" ${LIBS} -o "$OUT" >/dev/null 2>&1; then
         eval "HAVE_$NAME=true"
         echo "HAVE_$NAME = true" >> ${CONFIG_MK}
     else
@@ -283,7 +298,9 @@ config_objc_lib() {
     OUT=".config_$NAME"
     echo "/* generated by configure */" > "$OUT_M"
     echo "int main (void) { return 0; }" >> "$OUT_M"
-    if $LIBTOOL --tag CC --mode link ${OBJCC} ${CPPFLAGS} ${OBJCFLAGS} "$OUT_M" ${LDFLAGS} ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
+    if $LIBTOOL --tag CC --mode link ${OBJCC} ${CPPFLAGS} ${OBJCFLAGS} \
+                "$OUT_M" ${LDFLAGS} ${LIBS} $@ \
+                -o "$OUT" >/dev/null 2>&1; then
         LIBS="$LIBS $@"
     fi
     rm -f "$OUT" "$OUT_M"
@@ -296,7 +313,8 @@ config_objc_lib_have() {
     OUT=".config_$NAME"
     echo "/* generated by configure */" > "$OUT_M"
     echo "int main (void) { return 0; }" >> "$OUT_M"
-    if $LIBTOOL --tag CC --mode link ${OBJCC} ${CPPFLAGS} ${OBJCFLAGS} "$OUT_M" ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
+    if $LIBTOOL --tag CC --mode link ${OBJCC} ${CPPFLAGS} ${OBJCFLAGS} \
+                "$OUT_M" ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
         eval "HAVE_$NAME=true"
         echo "HAVE_$NAME = true" >> ${CONFIG_MK}
     else
@@ -313,20 +331,22 @@ config_subdirs() {
 }
 
 cpp_o_rule() {
-    "$CXX" $CPPFLAGS $CXXFLAGS -M "$1" || { echo "$1" | sed -e 's/^\(.*\)\.cpp$/\1.o: \1.cpp/'; }
-    echo "$1" | sed -e 's/^\(.*\)\.cpp$/\1.o: Makefile config.mk/'
+    "$CXX" $CPPFLAGS $CXXFLAGS -M "$1" || {
+        echo "$1" | sed -e 's/^\(.*\)\.cpp$/\1.o: \1.cpp/'
+    }
+    echo "$1: $2" | sed -e 's/^\(.*\)\.cpp: $/\1.o: /'
 }
 
 cpp_ext_rule() {
-    cpp_o_rule "$2" | sed -e "s/[.]o:/$1:/"
+    cpp_o_rule "$2" "$3" | sed -e "s/[.]o:/$1:/"
 }
 
 cpp_lo_rule() {
-    cpp_ext_rule .lo "$1"
+    cpp_ext_rule .lo "$1" "$2"
 }
 
 cpp_prog_rule() {
-    { cpp_o_rule "$1" || exit 1; } | sed -e 's/[.]o:/:/'
+    { cpp_o_rule "$1" "$2" || exit 1; } | sed -e 's/[.]o:/:/'
 }
 
 cpp2ext() {
@@ -360,11 +380,11 @@ env_reset() {
 
 objc_o_rule() {
     echo "$1" | sed -e 's/^\(.*\)\.m$/\1.o: \1.m/'
-    echo "$1" | sed -e 's/^\(.*\)\.m$/\1.o: Makefile config.mk/'
+    echo "$1: $2" | sed -e 's/^\(.*\)\.m: $/\1.o: /'
 }
 
 objc_ext_rule() {
-    objc_o_rule "$2" | sed -e "s/[.]o:/$1:/"
+    objc_o_rule "$2" "$3" | sed -e "s/[.]o:/$1:/"
 }
 
 objc2ext() {
@@ -448,7 +468,6 @@ update_build() {
     echo "$COMPILE > \"\$LOG\" 2>&1 || $COMPILE" >> ${CC_COV}
     update_and_chmod 755 ${CC_COV} .build/cc_cov
 
-    COMPILE_DEBUG="${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\""
     echo "#!/bin/sh" >> ${CC_DEBUG}
     echo "# gen by configure" >> ${CC_DEBUG}
     echo "LOG=\".build/\$1.debug.log\"" >> ${CC_DEBUG}
@@ -458,7 +477,6 @@ update_build() {
     echo "$COMPILE > \"\$LOG\" 2>&1 || $COMPILE" >> ${CC_DEBUG}
     update_and_chmod 755 ${CC_DEBUG} .build/cc_debug
 
-    COMPILE_MAIN="${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\""
     echo "#!/bin/sh" >> ${CC_MAIN}
     echo "# gen by configure" >> ${CC_MAIN}
     echo "LOG=\".build/\$1.main.log\"" >> ${CC_MAIN}
diff --git a/configure b/configure
index e890950..50eeed2 100755
--- a/configure
+++ b/configure
@@ -13,7 +13,8 @@
 
 set -e
 
-export SRC_TOP="$(pwd)"
+export SRC_TOP="$PWD"
+echo "$PWD/configure"
 
 : ${PREFIX:=/usr/local}
 if [ "x$1" = "x--prefix" ]; then