Commit 9c35dcaf9448f0573d46ab00579c5083439a06fe

Thomas de Grivel 2023-01-26T10:24:53

config_lib libmd

diff --git a/config.subr b/config.subr
index 9ff8086..651f280 100644
--- a/config.subr
+++ b/config.subr
@@ -89,6 +89,21 @@ config_include() {
     rm "$OUT"
 }
 
+config_lib() {
+    LIBS_SAVE="$LIBS"
+    OUT=".config_$1.c"
+    shift
+    echo "/* generated by configure */" > "$OUT"
+    echo "int main () { return 0; }" >> "$OUT"
+    LIBS="${LIBS} $@"
+    if ${CC} ${CPPFLAGS} ${CFLAGS} "$OUT" ${LIBS} -o /dev/null 2>/dev/null; then
+        :
+    else
+        LIBS="${LIBS_SAVE}"
+    fi
+    rm "$OUT"
+}
+
 pkg_config() {
     if pkg-config "$1"; then
 	CFLAGS="$CFLAGS $(pkg-config --cflags "$1")"
diff --git a/ic3/configure b/ic3/configure
index 101cc31..80ca284 100755
--- a/ic3/configure
+++ b/ic3/configure
@@ -53,6 +53,7 @@ config_gnu
 pkg_config libbsd-overlay
 pkg_config libffi
 pkg_config libmd
+config_lib libmd -lmd
 
 # Asan config
 CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
diff --git a/libc3/configure b/libc3/configure
index 32cc7be..deb5309 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -45,14 +45,11 @@ config_gnu
 pkg_config libbsd-overlay
 pkg_config libffi
 pkg_config libmd
+config_lib libmd -lmd
 config_include sha_h sys/types.h sha.h HAVE_SHA_H
 config_include sha1_h sys/types.h sha1.h HAVE_SHA1_H
 update_config_h
 
-if [ "x${HAVE_SHA_H}" = "xYes" ]; then
-    LIBS="${LIBS} -lmd"
-fi
-
 # Address Sanitizer config
 CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
 LDFLAGS_ASAN="$LDFLAGS"
diff --git a/test/configure b/test/configure
index cc2a1a8..5461637 100755
--- a/test/configure
+++ b/test/configure
@@ -53,6 +53,7 @@ config_gnu
 pkg_config libbsd-overlay
 pkg_config libffi
 pkg_config libmd
+config_lib libmd -lmd
 
 # Asan config
 CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"