Commit b57850d9e6185e81aa2700212f269a279c98e027

Thomas de Grivel 2023-12-06T22:34:02

fix compilation without -framework Cocoa

diff --git a/config.subr b/config.subr
index 6abad1c..0974221 100644
--- a/config.subr
+++ b/config.subr
@@ -96,12 +96,13 @@ config_include() {
     rm -f "$OUT"
 }
 
-config_lib_have() {
+config_include_have() {
     NAME="$1"
     shift
     OUT_C=".config_$NAME.c"
     OUT=".config_$NAME"
     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
         eval "HAVE_$NAME=true"
@@ -126,6 +127,23 @@ config_lib() {
     rm -f "$OUT" "$OUT_C"
 }
 
+config_lib_have() {
+    NAME="$1"
+    shift
+    OUT_C=".config_$NAME.c"
+    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"; then
+        eval "HAVE_$NAME=true"
+        echo "HAVE_$NAME = true" >> ${CONFIG_MK}
+    else
+        eval "HAVE_$NAME=false"
+        echo "HAVE_$NAME = false" >> ${CONFIG_MK}
+    fi
+    rm -f "$OUT" "$OUT_C"
+}
+
 config_no_undefined() {
     OUT_C=".config_no_undefined.c"
     OUT=".config_no_undefined"
diff --git a/libc3/window/cairo/configure b/libc3/window/cairo/configure
index 390fb25..07e9b07 100755
--- a/libc3/window/cairo/configure
+++ b/libc3/window/cairo/configure
@@ -47,6 +47,9 @@ pkg_config cairo
 pkg_config freetype2
 pkg_config xkbcommon
 config_lib_have COCOA -framework Cocoa
+if $HAVE_COCOA; then
+    config_include_have COCOA '#import <Cocoa/Cocoa.h>'
+fi
 config_define PREFIX "\"${PREFIX}\""
 
 # Address Sanitizer config
diff --git a/libc3/window/cairo/demo/.config_no_undefined.c b/libc3/window/cairo/demo/.config_no_undefined.c
deleted file mode 100644
index 2e12ed6..0000000
--- a/libc3/window/cairo/demo/.config_no_undefined.c
+++ /dev/null
@@ -1,2 +0,0 @@
-/* generated by configure */
-int main (void) { return 0; }