diff --git a/config.subr b/config.subr
index 299404a..da07a65 100644
--- a/config.subr
+++ b/config.subr
@@ -57,6 +57,30 @@ build_lo() {
done
}
+build_lo_objc() {
+ for SRC in $OBJC_SOURCES; do
+ echo >> ${CONFIG_MK}
+ SRC_LO="$(objc2ext .main.lo "$SRC")"
+ objc_ext_rule .main.lo "$SRC" .build/objcc_main >> ${CONFIG_MK}
+ echo " .build/objcc_main $SRC $SRC_LO" >> ${CONFIG_MK}
+
+ echo >> ${CONFIG_MK}
+ SRC_LO="$(objc2ext .asan.lo "$SRC")"
+ objc_ext_rule .asan.lo "$SRC" .build/objcc_asan >> ${CONFIG_MK}
+ echo " .build/objcc_asan $SRC $SRC_LO" >> ${CONFIG_MK}
+
+ echo >> ${CONFIG_MK}
+ SRC_LO="$(objc2ext .cov.lo "$SRC")"
+ objc_ext_rule .cov.lo "$SRC" .build/objcc_cov >> ${CONFIG_MK}
+ echo " .build/objcc_cov $SRC $SRC_LO" >> ${CONFIG_MK}
+
+ echo >> ${CONFIG_MK}
+ SRC_LO="$(objc2ext .debug.lo "$SRC")"
+ objc_ext_rule .debug.lo "$SRC" .build/objcc_debug >> ${CONFIG_MK}
+ echo " .build/objcc_debug $SRC $SRC_LO" >> ${CONFIG_MK}
+ done
+}
+
build_prog() {
echo >> ${CONFIG_MK}
echo "$PROG_ASAN: $LOCAL_LIBS_ASAN $OBJECTS_ASAN .build/ld_asan" >> ${CONFIG_MK}
@@ -483,6 +507,46 @@ update_build_lib() {
update_and_chmod 755 ${LD_MAIN} .build/ld_main
}
+update_build_objc() {
+ OBJCC_MAIN=.build/objcc_main.tmp
+ OBJCC_ASAN=.build/objcc_asan.tmp
+ OBJCC_COV=.build/objcc_cov.tmp
+ OBJCC_DEBUG=.build/objcc_debug.tmp
+ mkdir -p .build
+
+ echo "#!/bin/sh" >> ${OBJCC_ASAN}
+ echo "# gen by configure" >> ${OBJCC_ASAN}
+ echo "OBJCC=\"${OBJCC}\"" >> ${OBJCC_ASAN}
+ echo "CPPFLAGS=\"${CPPFLAGS_ASAN}\"" >> ${OBJCC_ASAN}
+ echo "CFLAGS=\"${CFLAGS_ASAN}\"" >> ${OBJCC_ASAN}
+ echo "${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJCC_ASAN}
+ update_and_chmod 755 ${OBJCC_ASAN} .build/objcc_asan
+
+ echo "#!/bin/sh" >> ${OBJCC_COV}
+ echo "# gen by configure" >> ${OBJCC_COV}
+ echo "OBJCC=\"${OBJCC}\"" >> ${OBJCC_COV}
+ echo "CPPFLAGS=\"${CPPFLAGS_COV}\"" >> ${OBJCC_COV}
+ echo "CFLAGS=\"${CFLAGS_COV}\"" >> ${OBJCC_COV}
+ echo "${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJCC_COV}
+ update_and_chmod 755 ${OBJCC_COV} .build/objcc_cov
+
+ echo "#!/bin/sh" >> ${OBJCC_DEBUG}
+ echo "# gen by configure" >> ${OBJCC_DEBUG}
+ echo "OBJCC=\"${OBJCC}\"" >> ${OBJCC_DEBUG}
+ echo "CPPFLAGS=\"${CPPFLAGS_DEBUG}\"" >> ${OBJCC_DEBUG}
+ echo "CFLAGS=\"${CFLAGS_DEBUG}\"" >> ${OBJCC_DEBUG}
+ echo "${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJCC_DEBUG}
+ update_and_chmod 755 ${OBJCC_DEBUG} .build/objcc_debug
+
+ echo "#!/bin/sh" >> ${OBJCC_MAIN}
+ echo "# gen by configure" >> ${OBJCC_MAIN}
+ echo "OBJCC=\"${OBJCC}\"" >> ${OBJCC_MAIN}
+ echo "CPPFLAGS=\"${CPPFLAGS}\"" >> ${OBJCC_MAIN}
+ echo "CFLAGS=\"${CFLAGS}\"" >> ${OBJCC_MAIN}
+ echo "${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c \"\$1\" -o \"\$2\" >> .build/log 2>&1" >> ${OBJCC_MAIN}
+ update_and_chmod 755 ${OBJCC_MAIN} .build/objcc_main
+}
+
update_build_prog() {
LD_MAIN=.build/ld_main.tmp
LD_ASAN=.build/ld_asan.tmp
diff --git a/libc3_window/cairo/quartz/configure b/libc3_window/cairo/quartz/configure
index c8f75b0..c395e23 100755
--- a/libc3_window/cairo/quartz/configure
+++ b/libc3_window/cairo/quartz/configure
@@ -63,18 +63,21 @@ pkg_config libmd
pkg_config xkbcommon
# Asan config
+CPPFLAGS_ASAN="$CPPFLAGS"
CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
LDFLAGS_ASAN="$LDFLAGS"
LOCAL_LIBS_ASAN="../libc3_window_cairo_asan.la"
LIBS_ASAN="$LOCAL_LIBS_ASAN $LIBS"
# Coverage config
+CPPFLAGS_COV="$CPPFLAGS"
CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs -fprofile-generate"
LDFLAGS_COV="$LDFLAGS --coverage"
LOCAL_LIBS_COV="../libc3_window_cairo_cov.la"
LIBS_COV="$LOCAL_LIBS_COV $LIBS"
# Debug config
+CPPFLAGS_DEBUG="$CPPFLAGS"
CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
LDFLAGS_DEBUG="$LDFLAGS"
LOCAL_LIBS_DEBUG="../libc3_window_cairo_debug.la"
@@ -107,65 +110,13 @@ 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}
+update_build
+update_build_objc
+update_build_lib
-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
-
-for SRC in $OBJC_SOURCES; do
- echo >> ${CONFIG_MK}
- SRC_LO="$(objc2ext .main.lo "$SRC")"
- objc_ext_rule .main.lo "$SRC" >> ${CONFIG_MK}
- echo " ${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
-
- echo >> ${CONFIG_MK}
- SRC_LO="$(objc2ext .asan.lo "$SRC")"
- objc_ext_rule .asan.lo "$SRC" >> ${CONFIG_MK}
- echo " ${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS_ASAN} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
-
- echo >> ${CONFIG_MK}
- SRC_LO="$(objc2ext .cov.lo "$SRC")"
- objc_ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
- echo " ${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
-
- echo >> ${CONFIG_MK}
- SRC_LO="$(objc2ext .debug.lo "$SRC")"
- objc_ext_rule .debug.lo "$SRC" >> ${CONFIG_MK}
- echo " ${LIBTOOL} --tag=CC --mode=compile \${OBJCC} \${CPPFLAGS} \${CFLAGS_DEBUG} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
-done
+build_lo
+build_lo_objc
+build_lib
update_config_mk
env_reset
diff --git a/libc3_window/cairo/quartz/demo/configure b/libc3_window/cairo/quartz/demo/configure
index ffb9a12..af1daee 100755
--- a/libc3_window/cairo/quartz/demo/configure
+++ b/libc3_window/cairo/quartz/demo/configure
@@ -50,30 +50,22 @@ echo "APP_PROG_DEBUG = $APP_PROG_DEBUG" >> ${CONFIG_MK}
. ./sources.sh
OBJECTS="$(c2ext .main.lo "$SOURCES")"
-OBJECTS="$OBJECTS $(objc2ext .main.lo "$OBJ_SOURCES")"
-OBJECTS="$OBJECTS $(swift2ext .main.lo "$SWIFT_SOURCES")"
echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
-OBJECTS_ASAN="$OBJECTS_ASAN $(objc2ext .asan.lo "$OBJ_SOURCES")"
-OBJECTS_ASAN="$OBJECTS_ASAN $(swift2ext .asan.lo "$SWIFT_SOURCES")"
echo "OBJECTS_ASAN = $OBJECTS_ASAN" >> ${CONFIG_MK}
if $HAVE_GCOV; then
OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
- OBJECTS_COV="$OBJECTS_COV $(objc2ext .cov.lo "$OBJ_SOURCES")"
- OBJECTS_COV="$OBJECTS_COV $(swift2ext .cov.lo "$SWIFT_SOURCES")"
echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
fi
OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
-OBJECTS_DEBUG="$OBJECTS_DEBUG $(objc2ext .debug.lo "$OBJ_SOURCES")"
-OBJECTS_DEBUG="$OBJECTS_DEBUG $(swift2ext .debug.lo "$SWIFT_SOURCES")"
echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
CPPFLAGS="$CPPFLAGS -I../../../.."
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
OBJCFLAGS="$CFLAGS -W -Wall -Werror"
LDFLAGS="$LDFLAGS -framework Cocoa"
LIBS="$LIBS"
@@ -86,31 +78,39 @@ pkg_config libmd
pkg_config xkbcommon
# Asan config
-CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
+CPPFLAGS_ASAN="$CPPFLAGS"
+CFLAGS_ASAN="$CFLAGS -DDEBUG -O1 -g"
+CFLAGS_ASAN="$CFLAGS_ASAN -fsanitize=address -fno-omit-frame-pointer"
LDFLAGS_ASAN="$LDFLAGS"
-LOCAL_LIBS_ASAN="../../demo/libc3_window_cairo_demo_asan.la ../libc3_window_cairo_quartz_asan.la"
+LOCAL_LIBS_ASAN="../../demo/libc3_window_cairo_demo_asan.la"
+LOCAL_LIBS_ASAN="$LOCAL_LIBS_ASAN ../libc3_window_cairo_quartz_asan.la"
LIBS_ASAN="$LOCAL_LIBS_ASAN $LIBS"
# Coverage config
-CFLAGS_COV="$CFLAGS -ftest-coverage -fprofile-arcs -fprofile-generate"
-LDFLAGS_COV="$LDFLAGS --coverage"
-LOCAL_LIBS_COV="../../demo/libc3_window_cairo_demo_cov.la ../libc3_window_cairo_quartz_cov.la"
+CPPFLAGS_COV="$CPPFLAGS"
+CFLAGS_COV="$CFLAGS -DDEBUG --coverage"
+LDFLAGS_COV="$LDFLAGS"
+LOCAL_LIBS_COV="../../demo/libc3_window_cairo_demo_cov.la"
+LOCAL_LIBS_COV="$LOCAL_LIBS_COV ../libc3_window_cairo_quartz_cov.la"
LIBS_COV="$LOCAL_LIBS_COV $LIBS"
# Debug config
+CPPFLAGS_DEBUG="$CPPFLAGS"
CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
LDFLAGS_DEBUG="$LDFLAGS"
-LOCAL_LIBS_DEBUG="../../demo/libc3_window_cairo_demo_debug.la ../libc3_window_cairo_quartz_debug.la"
+LOCAL_LIBS_DEBUG="../../demo/libc3_window_cairo_demo_debug.la"
+LOCAL_LIBS_DEBUG="$LOCAL_LIBS_DEBUG ../libc3_window_cairo_quartz_debug.la"
LIBS_DEBUG="$LOCAL_LIBS_DEBUG $LIBS"
# Main config
-DEFAULT_CFLAGS="-O2 -pipe"
+DEFAULT_CFLAGS="-O2 -fPIC"
if [ "x$ENV_CFLAGS" = "x" ]; then
CFLAGS="$CFLAGS $DEFAULT_CFLAGS"
fi
CFLAGS="$CFLAGS -DNDEBUG"
LIBC3=../libc3/libc3.la
-LOCAL_LIBS="../../demo/libc3_window_cairo_demo.la ../libc3_window_cairo_quartz.la"
+LOCAL_LIBS="../../demo/libc3_window_cairo_demo.la"
+LOCAL_LIBS="$LOCAL_LIBS ../libc3_window_cairo_quartz.la"
LIBS="$LOCAL_LIBS $LIBS"
echo "HAVE_ASAN = $HAVE_ASAN" >> ${CONFIG_MK}
@@ -131,61 +131,11 @@ 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 "$PROG: $LOCAL_LIBS $OBJECTS" >> ${CONFIG_MK}
-echo " ${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS} \${LDFLAGS} ${OBJECTS} ${LIBS} -o $PROG" >> ${CONFIG_MK}
-
-echo >> ${CONFIG_MK}
-echo "$PROG_ASAN: $LOCAL_LIBS_ASAN $OBJECTS_ASAN" >> ${CONFIG_MK}
-echo " ${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_ASAN} \${LDFLAGS_ASAN} ${OBJECTS_ASAN} ${LIBS_ASAN} -o $PROG_ASAN" >> ${CONFIG_MK}
-
-if $HAVE_GCOV; then
- echo >> ${CONFIG_MK}
- echo "$PROG_COV: $LOCAL_LIBS_COV $OBJECTS_COV" >> ${CONFIG_MK}
- echo " ${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_COV} \${LDFLAGS_COV} ${OBJECTS_COV} ${LIBS_COV} -o $PROG_COV" >> ${CONFIG_MK}
-fi
-
-echo >> ${CONFIG_MK}
-echo "$PROG_DEBUG: $LOCAL_LIBS_DEBUG $OBJECTS_DEBUG" >> ${CONFIG_MK}
-echo " ${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_DEBUG} \${LDFLAGS_DEBUG} ${OBJECTS_DEBUG} ${LIBS_DEBUG} -o $PROG_DEBUG" >> ${CONFIG_MK}
+update_build
+update_build_prog
-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}
-
- if $HAVE_GCOV; then
- 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}
- fi
-
- 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
-
-for SRC in $SWIFT_SOURCES; do
- echo >> ${CONFIG_MK}
- SRC_LO="$(swift2ext .main.lo "$SRC")"
- swift_ext_rule .main.lo "$SRC" >> ${CONFIG_MK}
- echo " \${SWIFTC} \${SWIFT_CFLAGS} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
-done
-
-for SRC in $OBJC_SOURCES; do
- echo >> ${CONFIG_MK}
- SRC_LO="$(objc2ext .main.lo "$SRC")"
- objc_ext_rule .main.lo "$SRC" >> ${CONFIG_MK}
- echo " ${LIBTOOL} --tag=OBJCC --mode=compile \${OBJCC} \${CFLAGS} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
-done
+build_lo
+build_prog
echo >> ${CONFIG_MK}
echo "${APP_PROG}: ${PROG}" >> ${CONFIG_MK}