Commit 59bcfc8529a40f171a072ce5fc59bb8b9f016b7d

Thomas de Grivel 2023-12-12T03:04:16

config.h HAVE_STAT_MTIM

diff --git a/config.subr b/config.subr
index 569b5d8..4ab7c8a 100644
--- a/config.subr
+++ b/config.subr
@@ -58,10 +58,32 @@ config_asan() {
     config_lib_have ASAN -lasan
 }
 
-config_define () {
+config_define() {
     echo "#define $1 $2" >> "${CONFIG_H}"
 }
 
+config_have_stat_mtim() {
+    OUT=".config_have_stat_mtim"
+    OUT_C=".config_have_stat_mtim.c"
+    echo "/* generated by configure */" > "$OUT_C"
+    echo "#include <stat.h>" >> "$OUT_C"
+    echo "int main (void) {" >> "$OUT_C"
+    echo "  s_stat tmp;" >> "$OUT_C"
+    echo "  tmp.st_mtim.tv_sec = 0;" >> "$OUT_C"
+    echo "  tmp.st_mtim.tv_nsec = 0;" >> "$OUT_C"
+    echo "  return 0;" >> "$OUT_C"
+    echo "}" >> "$OUT_C"
+    if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT_C" -o "$OUT" >/dev/null 2>&1; then
+        echo "#define HAVE_STAT_MTIM 1" >> "${CONFIG_H}"
+        HAVE_STAT_MTIM=true
+    else
+        echo "#define HAVE_STAT_MTIM 0" >> "${CONFIG_H}"
+        HAVE_STAT_MTIM=false
+    fi
+    rm -f "$OUT_C"
+    rm -f "$OUT"
+}
+
 config_gnu() {
     if grep -q _GNU_SOURCE /usr/include/features.h 2>/dev/null; then
 	CFLAGS="$CFLAGS -D_GNU_SOURCE"
diff --git a/libc3/configure b/libc3/configure
index 34f5b98..8c372ac 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -49,6 +49,7 @@ config_lib dl -ldl 2>/dev/null
 config_include sha_h sys/types.h sha.h HAVE_SHA_H
 config_include sha1_h sys/types.h sha1.h HAVE_SHA1_H
 config_define PREFIX "\"${PREFIX}\""
+config_have_stat_mtim
 update_config_h
 LIBS="$LIBS ../libffi/libffi.la"