Commit 5f5303010434757121431f46f65cffe6383a71cb

Thomas de Grivel 2023-11-16T16:37:56

demo on mac

diff --git a/.gitignore b/.gitignore
index 0e12d77..cf755b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,10 @@ ic3/ic3_debug
 *.la
 libc3/window/cairo/quartz/build
 libc3/window/cairo/quartz/demo/demo.xcodeproj/project.xcworkspace/xcuserdata
+libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/MacOS/c3_window_cairo_quartz_demo
+libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/Frameworks
+libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/MacOS/c3_window_cairo_quartz_demo_debug
+libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/Frameworks
 libc3/window/cairo/xcb/demo/c3_window_cairo_xcb_demo
 libc3/window/cairo/xcb/demo/c3_window_cairo_xcb_demo_asan
 libc3/window/cairo/xcb/demo/c3_window_cairo_xcb_demo_cov
diff --git a/libc3/window/cairo/quartz/demo/Makefile b/libc3/window/cairo/quartz/demo/Makefile
index 65fc5d1..6062e4e 100644
--- a/libc3/window/cairo/quartz/demo/Makefile
+++ b/libc3/window/cairo/quartz/demo/Makefile
@@ -21,7 +21,7 @@ DISTCLEANFILES = ${CLEANFILES} config.mk
 
 build:
 	${MAKE} ${APP_PROG}
-	${MAKE} ${APP_PROG_FRAMEWORKS}
+	${MAKE} ${APP}/Contents/Frameworks
 
 all:
 	${MAKE} build
@@ -31,6 +31,7 @@ all:
 
 asan:
 	${MAKE} ${APP_PROG_ASAN}
+	${MAKE} ${APP_ASAN}/Contents/Frameworks
 
 clean:
 	rm -rf ${CLEANFILES}
@@ -40,12 +41,14 @@ clean_cov:
 
 cov:
 	${MAKE} ${APP_PROG_COV}
+	${MAKE} ${APP_COV}/Contents/Frameworks
 
 debug:
 	${MAKE} ${APP_PROG_DEBUG}
+	${MAKE} ${APP_DEBUG}/Contents/Frameworks
 
-demo: ${APP_PROG}
-	time open ${APP}
+demo: build
+	time ${APP_PROG}
 
 distclean:
 	rm -rf ${DISTCLEANFILES}
@@ -62,7 +65,6 @@ install:
 
 .PHONY: \
 	all \
-	${APP_PROG} \
 	asan \
 	clean \
 	clean_cov \
diff --git a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/MacOS/c3_window_cairo_quartz_demo b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/MacOS/c3_window_cairo_quartz_demo
deleted file mode 100755
index ce05762..0000000
Binary files a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/MacOS/c3_window_cairo_quartz_demo and /dev/null differ
diff --git a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/MacOS/c3_window_cairo_quartz_demo_debug b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/MacOS/c3_window_cairo_quartz_demo_debug
deleted file mode 100755
index f1564ac..0000000
Binary files a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo_debug.app/Contents/MacOS/c3_window_cairo_quartz_demo_debug and /dev/null differ
diff --git a/libc3/window/cairo/quartz/demo/configure b/libc3/window/cairo/quartz/demo/configure
index 5109e5b..28e0d7e 100755
--- a/libc3/window/cairo/quartz/demo/configure
+++ b/libc3/window/cairo/quartz/demo/configure
@@ -197,20 +197,84 @@ echo >> ${CONFIG_MK}
 echo "${APP_PROG_DEBUG}: ${PROG_DEBUG}" >> ${CONFIG_MK}
 echo "	cp .libs/${PROG_DEBUG} ${APP_PROG_DEBUG}" >> ${CONFIG_MK}
 
-BUNDLE_LIBS="
-../../../../.libs/libc3.0.dylib
-../../../.libs/libc3_window.0.dylib
-../../.libs/libc3_window_cairo.0.dylib
-../.libs/libc3_window_cairo_quartz.dylib
-"
-
-echo "${APP_PROG_FRAMEWORKS}: ${BUNDLE_LIBS}" >> ${CONFIG_MK}
+BUNDLE_LIBS="../../../../../libffi/.libs/libffi.8.dylib ../../../../.libs/libc3.0.dylib ../../../.libs/libc3_window.0.dylib ../../.libs/libc3_window_cairo.0.dylib ../.libs/libc3_window_cairo_quartz.0.dylib"
+echo >> ${CONFIG_MK}
+echo "${APP}/Contents/Frameworks: ${BUNDLE_LIBS}" >> ${CONFIG_MK}
 echo "	mkdir -p ${APP}/Contents/Frameworks" >> ${CONFIG_MK}
 echo "	cp ${BUNDLE_LIBS} ${APP}/Contents/Frameworks/" >> ${CONFIG_MK}
 for BUNDLE_LIB in ${BUNDLE_LIBS}; do
     L=$(basename $BUNDLE_LIB)
-    echo "	install_name_tool -id @executable_path/../Frameworks/ ${APP}/Contents/Frameworks/$L"
-    echo "	install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP}/Contents/MacOS/${PROG}"
+    echo "	install_name_tool -id @executable_path/../Frameworks/ ${APP}/Contents/Frameworks/$L" >> ${CONFIG_MK}
+    echo "	install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP}/Contents/MacOS/${PROG}" >> ${CONFIG_MK}
+    DEPS=$(otool -L "$BUNDLE_LIB" | awk '/^\t.+(\/usr\/lib|\/System)/ { next } /^\t/ { print $1 }')
+    for DEP in $DEPS; do
+        D=$(basename "$DEP")
+        echo "	if [ -f $APP/Contents/Frameworks/$D ]; then install_name_tool -change \"$DEP\" @executable_path/../Frameworks/$D $APP/Contents/Frameworks/$L; fi" >> ${CONFIG_MK}
+    done
 done
+echo >> ${CONFIG_MK}
+echo ".PHONY: \\" >> ${CONFIG_MK}
+echo "	${APP}/Contents/Frameworks \\" >> ${CONFIG_MK}
+echo "	${APP_PROG}" >> ${CONFIG_MK}
+
+BUNDLE_LIBS_ASAN="../../../../../libffi/.libs/libffi.8.dylib ../../../../.libs/libc3_asan.0.dylib ../../../.libs/libc3_window_asan.0.dylib ../../.libs/libc3_window_cairo_asan.0.dylib ../.libs/libc3_window_cairo_quartz_asan.0.dylib"
+echo >> ${CONFIG_MK}
+echo "${APP_ASAN}/Contents/Frameworks: ${BUNDLE_LIBS_ASAN}" >> ${CONFIG_MK}
+echo "	mkdir -p ${APP_ASAN}/Contents/Frameworks" >> ${CONFIG_MK}
+echo "	cp ${BUNDLE_LIBS_ASAN} ${APP_ASAN}/Contents/Frameworks/" >> ${CONFIG_MK}
+for BUNDLE_LIB in ${BUNDLE_LIBS_ASAN}; do
+    L=$(basename $BUNDLE_LIB)
+    echo "	install_name_tool -id @executable_path/../Frameworks/ ${APP_ASAN}/Contents/Frameworks/$L" >> ${CONFIG_MK}
+    echo "	install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP_ASAN}/Contents/MacOS/${PROG_ASAN}" >> ${CONFIG_MK}
+    DEPS=$(otool -L "$BUNDLE_LIB" | awk '/^\t.+(\/usr\/lib|\/System)/ { next } /^\t/ { print $1 }')
+    for DEP in $DEPS; do
+        D=$(basename "$DEP")
+        echo "	if [ -f $APP_ASAN/Contents/Frameworks/$D ]; then install_name_tool -change \"$DEP\" @executable_path/../Frameworks/$D $APP_ASAN/Contents/Frameworks/$L; fi" >> ${CONFIG_MK}
+    done
+done
+echo >> ${CONFIG_MK}
+echo ".PHONY: \\" >> ${CONFIG_MK}
+echo "	${APP_ASAN}/Contents/Frameworks \\" >> ${CONFIG_MK}
+echo "	${APP_PROG_ASAN}" >> ${CONFIG_MK}
+
+BUNDLE_LIBS_COV="../../../../../libffi/.libs/libffi.8.dylib ../../../../.libs/libc3_cov.0.dylib ../../../.libs/libc3_window_cov.0.dylib ../../.libs/libc3_window_cairo_cov.0.dylib ../.libs/libc3_window_cairo_quartz_cov.0.dylib"
+echo >> ${CONFIG_MK}
+echo "${APP_COV}/Contents/Frameworks: ${BUNDLE_LIBS_COV}" >> ${CONFIG_MK}
+echo "	mkdir -p ${APP_COV}/Contents/Frameworks" >> ${CONFIG_MK}
+echo "	cp ${BUNDLE_LIBS_COV} ${APP_COV}/Contents/Frameworks/" >> ${CONFIG_MK}
+for BUNDLE_LIB in ${BUNDLE_LIBS_COV}; do
+    L=$(basename $BUNDLE_LIB)
+    echo "	install_name_tool -id @executable_path/../Frameworks/ ${APP_COV}/Contents/Frameworks/$L" >> ${CONFIG_MK}
+    echo "	install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP_COV}/Contents/MacOS/${PROG}" >> ${CONFIG_MK}
+    DEPS=$(otool -L "$BUNDLE_LIB" | awk '/^\t.+(\/usr\/lib|\/System)/ { next } /^\t/ { print $1 }')
+    for DEP in $DEPS; do
+        D=$(basename "$DEP")
+        echo "	if [ -f $APP_COV/Contents/Frameworks/$D ]; then install_name_tool -change \"$DEP\" @executable_path/../Frameworks/$D $APP_COV/Contents/Frameworks/$L; fi" >> ${CONFIG_MK}
+    done
+done
+echo >> ${CONFIG_MK}
+echo ".PHONY: \\" >> ${CONFIG_MK}
+echo "	${APP_COV}/Contents/Frameworks \\" >> ${CONFIG_MK}
+echo "	${APP_PROG}" >> ${CONFIG_MK}
+
+BUNDLE_LIBS_DEBUG="../../../../../libffi/.libs/libffi.8.dylib ../../../../.libs/libc3_debug.0.dylib ../../../.libs/libc3_window_debug.0.dylib ../../.libs/libc3_window_cairo_debug.0.dylib ../.libs/libc3_window_cairo_quartz_debug.0.dylib"
+echo >> ${CONFIG_MK}
+echo "${APP_DEBUG}/Contents/Frameworks: ${BUNDLE_LIBS_DEBUG}" >> ${CONFIG_MK}
+echo "	mkdir -p ${APP_DEBUG}/Contents/Frameworks" >> ${CONFIG_MK}
+echo "	cp ${BUNDLE_LIBS_DEBUG} ${APP_DEBUG}/Contents/Frameworks/" >> ${CONFIG_MK}
+for BUNDLE_LIB in ${BUNDLE_LIBS_DEBUG}; do
+    L=$(basename $BUNDLE_LIB)
+    echo "	install_name_tool -id @executable_path/../Frameworks/ ${APP_DEBUG}/Contents/Frameworks/$L" >> ${CONFIG_MK}
+    echo "	install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP_DEBUG}/Contents/MacOS/${PROG_DEBUG}" >> ${CONFIG_MK}
+    DEPS=$(otool -L "$BUNDLE_LIB" | awk '/^\t.+(\/usr\/lib|\/System)/ { next } /^\t/ { print $1 }')
+    for DEP in $DEPS; do
+        D=$(basename "$DEP")
+        echo "	if [ -f $APP_DEBUG/Contents/Frameworks/$D ]; then install_name_tool -change \"$DEP\" @executable_path/../Frameworks/$D $APP_DEBUG/Contents/Frameworks/$L; fi" >> ${CONFIG_MK}
+    done
+done
+echo >> ${CONFIG_MK}
+echo ".PHONY: \\" >> ${CONFIG_MK}
+echo "	${APP_DEBUG}/Contents/Frameworks \\" >> ${CONFIG_MK}
+echo "	${APP_PROG_DEBUG}" >> ${CONFIG_MK}
 
 update_config_mk