Commit 4cff83ece30657d1ebfcda917a39a3a9951d4171

Thomas de Grivel 2023-11-15T11:38:59

libs everywhere

diff --git a/libc3/window/Makefile b/libc3/window/Makefile
index 4d5ddb9..8594686 100644
--- a/libc3/window/Makefile
+++ b/libc3/window/Makefile
@@ -12,7 +12,7 @@
 
 include config.mk
 
-build:
+build: ${LIB}
 	if ${HAVE_CAIRO}; then ${MAKE} -C cairo build; fi
 
 all:
@@ -21,7 +21,7 @@ all:
 	${MAKE} debug
 	if ${HAVE_ASAN}; then ${MAKE} asan; fi
 
-asan:
+asan: ${LIB_ASAN}
 	if ${HAVE_CAIRO}; then ${MAKE} -C cairo asan; fi
 
 clean:
@@ -30,10 +30,10 @@ clean:
 clean_cov:
 	if ${HAVE_CAIRO}; then ${MAKE} -C cairo clean_cov; fi
 
-cov:
+cov: ${LIB_COV}
 	if ${HAVE_CAIRO}; then ${MAKE} -C cairo cov; fi
 
-debug:
+debug: ${LIB_DEBUG}
 	if ${HAVE_CAIRO}; then ${MAKE} -C cairo debug; fi
 
 demo: build
diff --git a/libc3/window/cairo/Makefile b/libc3/window/cairo/Makefile
index 68a4613..c4886da 100644
--- a/libc3/window/cairo/Makefile
+++ b/libc3/window/cairo/Makefile
@@ -12,7 +12,7 @@
 
 include config.mk
 
-build:
+build: ${LIB}
 	if ${HAVE_SWIFT}; then ${MAKE} -C quartz build; fi
 	if ${HAVE_XCB}; then ${MAKE} -C xcb build; fi
 
@@ -22,7 +22,7 @@ all:
 	${MAKE} debug
 	if ${HAVE_ASAN}; then ${MAKE} asan; fi
 
-asan:
+asan: ${LIB_ASAN}
 	if ${HAVE_SWIFT}; then ${MAKE} -C quartz asan; fi
 	if ${HAVE_XCB}; then ${MAKE} -C xcb asan; fi
 
@@ -34,11 +34,11 @@ clean_cov:
 	if ${HAVE_SWIFT}; then ${MAKE} -C quartz clean_cov; fi
 	if ${HAVE_XCB}; then ${MAKE} -C xcb clean_cov; fi
 
-cov:
+cov: ${LIB_COV}
 	if ${HAVE_SWIFT}; then ${MAKE} -C quartz cov; fi
 	if ${HAVE_XCB}; then ${MAKE} -C xcb cov; fi
 
-debug:
+debug: ${LIB_DEBUG}
 	if ${HAVE_SWIFT}; then ${MAKE} -C quartz debug; fi
 	if ${HAVE_XCB}; then ${MAKE} -C xcb debug; fi
 
@@ -78,6 +78,7 @@ update_sources:
 	debug \
 	demo \
 	distclean \
+	gdb_demo \
 	install \
 	test \
 	update_sources
diff --git a/libc3/window/cairo/configure b/libc3/window/cairo/configure
index 048492a..dce9ec2 100755
--- a/libc3/window/cairo/configure
+++ b/libc3/window/cairo/configure
@@ -27,10 +27,10 @@ echo "LIB_ASAN = $LIB_ASAN" >> ${CONFIG_MK}
 echo "LIB_COV = $LIB_COV" >> ${CONFIG_MK}
 echo "LIB_DEBUG = $LIB_DEBUG" >> ${CONFIG_MK}
 
-LIBC3=../../libc3.la
-LIBC3_ASAN=../../libc3_asan.la
-LIBC3_COV=../../libc3_cov.la
-LIBC3_DEBUG=../../libc3_debug.la
+#LIBC3=../../libc3.la
+#LIBC3_ASAN=../../libc3_asan.la
+#LIBC3_COV=../../libc3_cov.la
+#LIBC3_DEBUG=../../libc3_debug.la
 
 . ./sources.sh
 
@@ -53,19 +53,19 @@ config_define PREFIX "\"${PREFIX}\""
 # Address Sanitizer config
 CFLAGS_ASAN="$CFLAGS -O1 -fsanitize=address -fno-omit-frame-pointer -g"
 LDFLAGS_ASAN="$LDFLAGS"
-LIBS_LOCAL_ASAN="$LIBC3_ASAN"
+LIBS_LOCAL_ASAN="../libc3_window_asan.la"
 LIBS_ASAN="$LIBS_LOCAL_ASAN $LIBS"
 
 # Coverage config
 CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs -fprofile-generate"
 LDFLAGS_COV="$LDFLAGS --coverage"
-LIBS_LOCAL_COV="$LIBC3_COV"
+LIBS_LOCAL_COV="../libc3_window_cov.la"
 LIBS_COV="$LIBS_LOCAL_COV $LIBS"
 
 # Debug config
 CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
 LDFLAGS_DEBUG="$LDFLAGS"
-LIBS_LOCAL_DEBUG="$LIBC3_DEBUG"
+LIBS_LOCAL_DEBUG="../libc3_window_debug.la"
 LIBS_DEBUG="$LIBS_LOCAL_DEBUG $LIBS"
 
 # Main config
@@ -74,7 +74,7 @@ if [ "x$ENV_CFLAGS" = "x" ]; then
     CFLAGS="$CFLAGS $DEFAULT_CFLAGS"
 fi
 CFLAGS="$CFLAGS -DNDEBUG"
-LIBS_LOCAL="$LIBC3"
+LIBS_LOCAL="../libc3_window.la"
 LIBS="$LIBS_LOCAL $LIBS"
 
 echo "LIB = $LIB" >> ${CONFIG_MK}
diff --git a/libc3/window/cairo/xcb/configure b/libc3/window/cairo/xcb/configure
index 3fd18d2..8f9a72e 100755
--- a/libc3/window/cairo/xcb/configure
+++ b/libc3/window/cairo/xcb/configure
@@ -27,10 +27,10 @@ echo "LIB_ASAN = $LIB_ASAN" >> ${CONFIG_MK}
 echo "LIB_COV = $LIB_COV" >> ${CONFIG_MK}
 echo "LIB_DEBUG = $LIB_DEBUG" >> ${CONFIG_MK}
 
-LIBC3=../../../libc3.la
-LIBC3_ASAN=../../../libc3_asan.la
-LIBC3_COV=../../../libc3_cov.la
-LIBC3_DEBUG=../../../libc3_debug.la
+#LIBC3=../../../libc3.la
+#LIBC3_ASAN=../../../libc3_asan.la
+#LIBC3_COV=../../../libc3_cov.la
+#LIBC3_DEBUG=../../../libc3_debug.la
 
 . ./sources.sh
 
@@ -56,19 +56,19 @@ LIBS="$LIBS"
 # Address Sanitizer config
 CFLAGS_ASAN="$CFLAGS -O1 -fsanitize=address -fno-omit-frame-pointer -g"
 LDFLAGS_ASAN="$LDFLAGS"
-LIBS_LOCAL_ASAN="$LIBC3_ASAN"
+LIBS_LOCAL_ASAN="../libc3_window_cairo_.la"
 LIBS_ASAN="$LIBS_LOCAL_ASAN $LIBS"
 
 # Coverage config
 CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs -fprofile-generate"
 LDFLAGS_COV="$LDFLAGS --coverage"
-LIBS_LOCAL_COV="$LIBC3_COV"
+LIBS_LOCAL_COV="../libc3_window_cairo_cov.la"
 LIBS_COV="$LIBS_LOCAL_COV $LIBS"
 
 # Debug config
 CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
 LDFLAGS_DEBUG="$LDFLAGS"
-LIBS_LOCAL_DEBUG="$LIBC3_DEBUG"
+LIBS_LOCAL_DEBUG="../libc3_window_cairo_debug.la"
 LIBS_DEBUG="$LIBS_LOCAL_DEBUG $LIBS"
 
 # Main config
@@ -77,7 +77,7 @@ if [ "x$ENV_CFLAGS" = "x" ]; then
     CFLAGS="$CFLAGS $DEFAULT_CFLAGS"
 fi
 CFLAGS="$CFLAGS -DNDEBUG"
-LIBS_LOCAL="$LIBC3"
+LIBS_LOCAL="../libc3_window_cairo.la"
 LIBS="$LIBS_LOCAL $LIBS"
 
 echo "LIB = $LIB" >> ${CONFIG_MK}
diff --git a/libc3/window/cairo/xcb/sources.mk b/libc3/window/cairo/xcb/sources.mk
index 4d93565..12a0a76 100644
--- a/libc3/window/cairo/xcb/sources.mk
+++ b/libc3/window/cairo/xcb/sources.mk
@@ -1,8 +1,8 @@
 # sources.mk generated by update_sources
 HEADERS = \
 	config.h \
-	window_cairo_xcb.h ../window_cairo.h \
+	window_cairo_xcb.h \
 
 SOURCES = \
-	window_cairo_xcb.c ../window_cairo.c \
+	window_cairo_xcb.c \
 
diff --git a/libc3/window/cairo/xcb/sources.sh b/libc3/window/cairo/xcb/sources.sh
index 0c8c926..3bb21bc 100644
--- a/libc3/window/cairo/xcb/sources.sh
+++ b/libc3/window/cairo/xcb/sources.sh
@@ -1,3 +1,3 @@
 # sources.sh generated by update_sources
-HEADERS='config.h window_cairo_xcb.h ../window_cairo.h '
-SOURCES='window_cairo_xcb.c ../window_cairo.c '
+HEADERS='config.h window_cairo_xcb.h '
+SOURCES='window_cairo_xcb.c '
diff --git a/libc3/window/cairo/xcb/update_sources b/libc3/window/cairo/xcb/update_sources
index d2aa523..1a5b896 100755
--- a/libc3/window/cairo/xcb/update_sources
+++ b/libc3/window/cairo/xcb/update_sources
@@ -16,10 +16,10 @@
 echo "# sources.mk generated by update_sources" > ${SOURCES_MK}
 echo "# sources.sh generated by update_sources" > ${SOURCES_SH}
 
-HEADERS="$(ls *.h | sort) ../window_cairo.h"
+HEADERS="$(ls *.h | sort)"
 sources HEADERS "$HEADERS"
 
-SOURCES="$(ls *.c | sort) ../window_cairo.c"
+SOURCES="$(ls *.c | sort)"
 sources SOURCES "$SOURCES"
 
 update_sources_mk
diff --git a/libc3/window/configure b/libc3/window/configure
index 4f4cfdb..3a25b5e 100755
--- a/libc3/window/configure
+++ b/libc3/window/configure
@@ -17,8 +17,119 @@ export SRC_TOP="$(dirname "$PWD")"
 
 . ../../config.subr
 
+LIB=libc3_window.la
+LIB_ASAN=libc3_window_asan.la
+LIB_COV=libc3_window_cov.la
+LIB_DEBUG=libc3_window_debug.la
+
+echo "LIB = $LIB" >> ${CONFIG_MK}
+echo "LIB_ASAN = $LIB_ASAN" >> ${CONFIG_MK}
+echo "LIB_COV = $LIB_COV" >> ${CONFIG_MK}
+echo "LIB_DEBUG = $LIB_DEBUG" >> ${CONFIG_MK}
+
+. ./sources.sh
+
+OBJECTS="$(c2ext .main.lo "$SOURCES")"
+echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
+OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
+OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
+OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
+
+# Common config for all targets
+CPPFLAGS="$CPPFLAGS -I../../libffi/include -I../.."
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
+LDFLAGS="--shared --no-undefined ${LDFLAGS}"
+LIBS="$LIBS -rpath ${PREFIX}/lib"
 config_asan
+config_gnu
+config_define PREFIX "\"${PREFIX}\""
+
+# Address Sanitizer config
+CFLAGS_ASAN="$CFLAGS -O1 -fsanitize=address -fno-omit-frame-pointer -g"
+LDFLAGS_ASAN="$LDFLAGS"
+LIBS_LOCAL_ASAN="../libc3_asan.la"
+LIBS_ASAN="$LIBS_LOCAL_ASAN $LIBS"
+
+# Coverage config
+CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs -fprofile-generate"
+LDFLAGS_COV="$LDFLAGS --coverage"
+LIBS_LOCAL_COV="../libc3_cov.la"
+LIBS_COV="$LIBS_LOCAL_COV $LIBS"
+
+# Debug config
+CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
+LDFLAGS_DEBUG="$LDFLAGS"
+LIBS_LOCAL_DEBUG="../libc3_debug.la"
+LIBS_DEBUG="$LIBS_LOCAL_DEBUG $LIBS"
+
+# Main config
+DEFAULT_CFLAGS="-O2 -pipe"
+if [ "x$ENV_CFLAGS" = "x" ]; then
+    CFLAGS="$CFLAGS $DEFAULT_CFLAGS"
+fi
+CFLAGS="$CFLAGS -DNDEBUG"
+LIBS_LOCAL="../libc3.la"
+LIBS="$LIBS_LOCAL $LIBS"
+
+echo "LIB = $LIB" >> ${CONFIG_MK}
 echo "HAVE_ASAN = $HAVE_ASAN" >> ${CONFIG_MK}
+echo "CPPFLAGS = $CPPFLAGS" >> ${CONFIG_MK}
+echo "CFLAGS = $CFLAGS" >> ${CONFIG_MK}
+echo "LDFLAGS = $LDFLAGS" >> ${CONFIG_MK}
+echo "LIBS = $LIBS" >> ${CONFIG_MK}
+echo >> ${CONFIG_MK}
+echo "LIB_ASAN = $LIB_ASAN" >> ${CONFIG_MK}
+echo "CFLAGS_ASAN = $CFLAGS_ASAN" >> ${CONFIG_MK}
+echo "LDFLAGS_ASAN = $LDFLAGS_ASAN" >> ${CONFIG_MK}
+echo "LIBS_ASAN = $LIBS_ASAN" >> ${CONFIG_MK}
+echo >> ${CONFIG_MK}
+echo "LIB_COV = $LIB_COV" >> ${CONFIG_MK}
+echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
+echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
+echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
+echo >> ${CONFIG_MK}
+echo "LIB_DEBUG = $LIB_DEBUG" >> ${CONFIG_MK}
+echo "CFLAGS_DEBUG = $CFLAGS_DEBUG" >> ${CONFIG_MK}
+echo "LDFLAGS_DEBUG = $LDFLAGS_DEBUG" >> ${CONFIG_MK}
+echo "LIBS_DEBUG = $LIBS_DEBUG" >> ${CONFIG_MK}
+
+echo >> ${CONFIG_MK}
+echo "$LIB: $LIBS_LOCAL $OBJECTS" >> ${CONFIG_MK}
+echo "	${LIBTOOL} --tag=CC --mode=link \${CC} -shared \${LDFLAGS} ${OBJECTS} \${LIBS} -rpath ${LIBDIR} -o ${LIB}" >> ${CONFIG_MK}
+
+echo >> ${CONFIG_MK}
+echo "$LIB_ASAN: $LIBS_LOCAL_ASAN $OBJECTS_ASAN" >> ${CONFIG_MK}
+echo "	${LIBTOOL} --tag=CC --mode=link \${CC} -shared \${LDFLAGS_ASAN} ${OBJECTS_ASAN} \${LIBS_ASAN} -rpath ${LIBDIR} -o ${LIB_ASAN}" >> ${CONFIG_MK}
+
+echo >> ${CONFIG_MK}
+echo "$LIB_COV: $LIBS_LOCAL_COV $OBJECTS_COV" >> ${CONFIG_MK}
+echo "	${LIBTOOL} --tag=CC --mode=link \${CC} -shared \${LDFLAGS_COV} ${OBJECTS_COV} \${LIBS_COV} -rpath ${LIBDIR} -o ${LIB_COV}" >> ${CONFIG_MK}
+
+echo >> ${CONFIG_MK}
+echo "$LIB_DEBUG: $LIBS_LOCAL_DEBUG $OBJECTS_DEBUG" >> ${CONFIG_MK}
+echo "	${LIBTOOL} --tag=CC --mode=link \${CC} -shared \${LDFLAGS_DEBUG} ${OBJECTS_DEBUG} \${LIBS_DEBUG} -rpath ${LIBDIR} -o ${LIB_DEBUG}" >> ${CONFIG_MK}
+
+for SRC in $SOURCES; do
+    echo >> ${CONFIG_MK}
+    SRC_LO="$(c2ext .main.lo "$SRC")"
+    c_ext_rule .main.lo "$SRC" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
+
+    echo >> ${CONFIG_MK}
+    SRC_ASAN_LO="$(c2ext .asan.lo "$SRC")"
+    c_ext_rule .asan.lo "$SRC" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_ASAN} -c $SRC -o $SRC_ASAN_LO" >> ${CONFIG_MK}
+
+    echo >> ${CONFIG_MK}
+    SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
+    c_ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+
+    echo >> ${CONFIG_MK}
+    SRC_DEBUG_LO="$(c2ext .debug.lo "$SRC")"
+    c_ext_rule .debug.lo "$SRC" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_DEBUG} -c $SRC -o $SRC_DEBUG_LO" >> ${CONFIG_MK}
+done
 
 if pkg-config cairo; then
     HAVE_CAIRO=true