diff --git a/config.subr b/config.subr
index bc337a2..fbb90b2 100644
--- a/config.subr
+++ b/config.subr
@@ -183,6 +183,12 @@ config_gnu() {
fi
}
+config_i386() {
+ if [ "x$(uname -m)" = "xi386" ]; then
+ CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
+ fi
+}
+
config_include() {
OUT=".config_$1"
OUT_C=".config_$1.c"
diff --git a/ekc3/configure b/ekc3/configure
index a917aaf..a6a5846 100755
--- a/ekc3/configure
+++ b/ekc3/configure
@@ -42,10 +42,10 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
# Common config for all targets
CPPFLAGS="-I.. $CPPFLAGS"
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="-export-dynamic $LDFLAGS -rdynamic"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
config_define PREFIX "\"${PREFIX}\""
diff --git a/http/configure b/http/configure
index a4c02b1..8abda39 100755
--- a/http/configure
+++ b/http/configure
@@ -42,10 +42,10 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
# Common config for all targets
CPPFLAGS="-I.. $CPPFLAGS"
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="-export-dynamic $LDFLAGS -rdynamic"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
config_define PREFIX "\"${PREFIX}\""
diff --git a/ikc3/configure b/ikc3/configure
index e6ffb7b..5c08e6e 100755
--- a/ikc3/configure
+++ b/ikc3/configure
@@ -30,10 +30,10 @@ PROG_DEBUG=ikc3_debug
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -fPIC"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="$LDFLAGS -rdynamic"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/kc3c/configure b/kc3c/configure
index 757644c..7b37223 100755
--- a/kc3c/configure
+++ b/kc3c/configure
@@ -15,57 +15,100 @@ set -e
echo "$PWD/configure"
+export SRC_TOP="$(dirname "$PWD")"
+
+CONFIG_H_PREFIX=KC3S_
+
. ../config.subr
-PROG=c3c
-LIBRARY=../libkc3/libkc3.la
+PROG=kc3s
+PROG_ASAN=kc3s_asan
+PROG_COV=kc3s_cov
+PROG_DEBUG=kc3s_debug
-SOURCES="$(ls *.c | tr '\n' ' ')"
-echo "SOURCES = $SOURCES" >> ${CONFIG_MK}
+. ./sources.sh
-OBJECTS="$(c2lo "$SOURCES")"
+OBJECTS="$(c2ext .main.lo "$SOURCES")"
echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
-check_libbsd
+OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
+echo "OBJECTS_ASAN = $OBJECTS_ASAN" >> ${CONFIG_MK}
-if pkg-config libbsd-overlay; then
- CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE -D__USE_MISC"
+if $HAVE_GCOV; then
+ OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
+ echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
fi
-if [ x"$DEBUG" = x"yes" ]; then
- CFLAGS="$CFLAGS -DDEBUG -O0 -ggdb"
-else
- CFLAGS="$CFLAGS -DNDEBUG -O2"
-fi
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
-if pkg-config libbsd-overlay; then
- CFLAGS="$CFLAGS $(pkg-config --cflags libbsd-overlay)"
-fi
+OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
+echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
+
+# Common config for all targets
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
+LDFLAGS="$LDFLAGS -rdynamic"
+config_asan
+config_gnu
+config_i386
+pkg_config libbsd-overlay
+pkg_config libffi
+pkg_config libmd
+config_lib libmd -lmd 2>/dev/null
+config_lib dl -ldl 2>/dev/null
+LIBS="$LIBS -pthread -lm"
+
+# Asan config
+CFLAGS_ASAN="$CFLAGS -DDEBUG -O1 -g"
+CFLAGS_ASAN="$CFLAGS_ASAN -fsanitize=address -fno-omit-frame-pointer"
+LDFLAGS_ASAN="$LDFLAGS"
+LIBKC3_ASAN=../libkc3/libkc3_asan.la
+LOCAL_LIBS_ASAN="$LIBKC3_ASAN"
+LIBS_ASAN="$LOCAL_LIBS_ASAN $LIBS"
+
+# Coverage config
+CFLAGS_COV="$CFLAGS -fprofile-arcs -ftest-coverage"
+LDFLAGS_COV="$LDFLAGS --coverage"
+LIBKC3_COV=../libkc3/libkc3_cov.la
+LOCAL_LIBS_COV="$LIBKC3_COV"
+LIBS_COV="$LOCAL_LIBS_COV $LIBS -lgcov"
-LIBS="$LIBS $LIBRARY"
-if pkg-config libbsd-overlay; then
- LIBS="$LIBS $(pkg-config --libs libbsd-overlay)"
+# Debug config
+CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -ggdb"
+LDFLAGS_DEBUG="$LDFLAGS"
+LIBKC3_DEBUG=../libkc3/libkc3_debug.la
+LOCAL_LIBS_DEBUG="$LIBKC3_DEBUG"
+LIBS_DEBUG="$LOCAL_LIBS_DEBUG $LIBS"
+
+# Main config
+DEFAULT_CFLAGS="-O2 -fPIC"
+if [ "x$ENV_CFLAGS" = "x" ]; then
+ CFLAGS="$CFLAGS $DEFAULT_CFLAGS"
fi
+CFLAGS="$CFLAGS -DNDEBUG"
+LIBKC3=../libkc3/libkc3.la
+LOCAL_LIBS="$LIBKC3"
+LIBS="$LOCAL_LIBS $LIBS"
+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 "CFLAGS_ASAN = $CFLAGS_ASAN" >> ${CONFIG_MK}
+echo "LDFLAGS_ASAN = $LDFLAGS_ASAN" >> ${CONFIG_MK}
+echo "LIBS_ASAN = $LIBS_ASAN" >> ${CONFIG_MK}
+echo >> ${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 "CFLAGS_DEBUG = $CFLAGS_DEBUG" >> ${CONFIG_MK}
+echo "LDFLAGS_DEBUG = $LDFLAGS_DEBUG" >> ${CONFIG_MK}
+echo "LIBS_DEBUG = $LIBS_DEBUG" >> ${CONFIG_MK}
-for SRC in $SOURCES; do
- SRC_LO=$(c2lo $SRC)
- echo >> ${CONFIG_MK}
- lo_rule $SRC >> ${CONFIG_MK}
- echo " \${LIBTOOL} --tag CC --mode compile \${CC} \${CPPFLAGS} \${CFLAGS} -c $SRC -o $SRC_LO" >> ${CONFIG_MK}
-done
+update_build
+update_build_prog
-echo >> ${CONFIG_MK}
-echo "$PROG: $LIBRARY $OBJECTS" >> ${CONFIG_MK}
-echo " ${LIBTOOL} --tag=CC --mode=link \${CC} \${LDFLAGS} ${OBJECTS} ${LIBRARY} ${LIBS} -o $PROG" >> ${CONFIG_MK}
+build_lo
+build_prog
-echo >> ${CONFIG_MK}
-echo "install: $LIBRARY $PROG" >> ${CONFIG_MK}
-echo " \${INSTALL} -o \${OWNER} -g \${GROUP} -m 0755 -d \${LIBDIR}" >> ${CONFIG_MK}
-echo " \${LIBTOOL} --tag=CC --mode=install \${INSTALL} -o \${OWNER} -g \${GROUP} -m 0755 $LIBRARY \${LIBDIR}" >> ${CONFIG_MK}
-echo " \${INSTALL} -o \${OWNER} -g \${GROUP} -m 0755 -d \${BINDIR}" >> ${CONFIG_MK}
-echo " \${LIBTOOL} --tag=CC --mode=install \${INSTALL} -o \${OWNER} -g \${GROUP} -m 0755 $PROG \${BINDIR}/$PROG" >> ${CONFIG_MK}
+update_config_mk
diff --git a/kc3s/configure b/kc3s/configure
index b0f3c7e..7b37223 100755
--- a/kc3s/configure
+++ b/kc3s/configure
@@ -44,10 +44,10 @@ echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="$LDFLAGS -rdynamic"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/libkc3/configure b/libkc3/configure
index 842f863..6419637 100755
--- a/libkc3/configure
+++ b/libkc3/configure
@@ -41,10 +41,10 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$LO_SOURCES")"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="-export-dynamic $LDFLAGS -rdynamic"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/libkc3_window/cairo/configure b/libkc3_window/cairo/configure
index 3111f9d..eeaf2da 100755
--- a/libkc3_window/cairo/configure
+++ b/libkc3_window/cairo/configure
@@ -43,11 +43,11 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
CPPFLAGS="-I../.. $CPPFLAGS"
OBJCFLAGS="$CFLAGS -W -Wall -Werror"
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="--shared ${LDFLAGS}"
LIBS="$LIBS -rpath ${PREFIX}/lib"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/libkc3_window/cairo/demo/configure b/libkc3_window/cairo/demo/configure
index 57e779a..682e3dd 100755
--- a/libkc3_window/cairo/demo/configure
+++ b/libkc3_window/cairo/demo/configure
@@ -46,6 +46,7 @@ LDFLAGS="--shared ${LDFLAGS}"
LIBS="$LIBS -rpath ${PREFIX}/lib"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/libkc3_window/cairo/quartz/configure b/libkc3_window/cairo/quartz/configure
index 1696a04..bc1d544 100755
--- a/libkc3_window/cairo/quartz/configure
+++ b/libkc3_window/cairo/quartz/configure
@@ -50,12 +50,12 @@ echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
CPPFLAGS="$CPPFLAGS -I../../.."
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
OBJCFLAGS="$CFLAGS -W -Wall -Werror"
LDFLAGS="--shared $LDFLAGS"
LIBS="$LIBS"
config_asan
config_gnu
+config_i386
pkg_config cairo
pkg_config cairo-ft
config_lib COCOA -framework Cocoa
diff --git a/libkc3_window/cairo/quartz/demo/configure b/libkc3_window/cairo/quartz/demo/configure
index a41886c..5debc85 100755
--- a/libkc3_window/cairo/quartz/demo/configure
+++ b/libkc3_window/cairo/quartz/demo/configure
@@ -68,12 +68,12 @@ echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
CPPFLAGS="$CPPFLAGS -I../../../.."
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
OBJCFLAGS="$CFLAGS -W -Wall -Werror"
LDFLAGS="$LDFLAGS -framework Cocoa"
LIBS="$LIBS"
config_asan
config_gnu
+config_i386
pkg_config cairo
pkg_config cairo-ft
pkg_config libffi
diff --git a/libkc3_window/cairo/win32/configure b/libkc3_window/cairo/win32/configure
index 3f6e2a5..885d1d4 100644
--- a/libkc3_window/cairo/win32/configure
+++ b/libkc3_window/cairo/win32/configure
@@ -43,11 +43,11 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
# Common config for all targets
CPPFLAGS="-I../../../../libffi/include -I../../../.. $CPPFLAGS"
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="--shared $LDFLAGS"
LIBS="$LIBS -rpath ${PREFIX}/lib"
config_asan
config_gnu
+config_i386
pkg_config xkbcommon
pkg_config cairo
pkg_config cairo-win32
diff --git a/libkc3_window/cairo/win32/demo/configure b/libkc3_window/cairo/win32/demo/configure
index e32003b..11b1cb7 100644
--- a/libkc3_window/cairo/win32/demo/configure
+++ b/libkc3_window/cairo/win32/demo/configure
@@ -45,10 +45,10 @@ echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
CPPFLAGS="-I../../../../../libffi/include -I../../../../.. $CPPFLAGS"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config cairo
pkg_config cairo-win32
diff --git a/libkc3_window/cairo/xcb/configure b/libkc3_window/cairo/xcb/configure
index eeff497..8666872 100755
--- a/libkc3_window/cairo/xcb/configure
+++ b/libkc3_window/cairo/xcb/configure
@@ -42,10 +42,10 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
# Common config for all targets
CPPFLAGS="$CPPFLAGS -I../../.."
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="--shared ${LDFLAGS}"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/libkc3_window/cairo/xcb/demo/configure b/libkc3_window/cairo/xcb/demo/configure
index 4647975..9e16ca9 100755
--- a/libkc3_window/cairo/xcb/demo/configure
+++ b/libkc3_window/cairo/xcb/demo/configure
@@ -47,10 +47,10 @@ echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
CPPFLAGS="$CPPFLAGS -I../../../.."
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/libkc3_window/configure b/libkc3_window/configure
index f9f4751..52f09e4 100755
--- a/libkc3_window/configure
+++ b/libkc3_window/configure
@@ -42,10 +42,10 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
# Common config for all targets
CPPFLAGS="-I.. $CPPFLAGS"
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="--shared ${LDFLAGS} -rdynamic"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/libkc3_window/sdl2/configure b/libkc3_window/sdl2/configure
index 3fe5f6f..c2d1d93 100755
--- a/libkc3_window/sdl2/configure
+++ b/libkc3_window/sdl2/configure
@@ -40,10 +40,10 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
# Common config for all targets
CPPFLAGS="-I../.. $CPPFLAGS"
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="--shared ${LDFLAGS}"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libmd
pkg_config freetype2
diff --git a/libkc3_window/sdl2/demo/configure b/libkc3_window/sdl2/demo/configure
index c7a1b23..490f1e9 100755
--- a/libkc3_window/sdl2/demo/configure
+++ b/libkc3_window/sdl2/demo/configure
@@ -49,10 +49,10 @@ echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
CPPFLAGS="-I../../.. $CPPFLAGS"
CFLAGS="$CFLAGS -W -Wall -Werror -Wno-error=unknown-pragmas"
CFLAGS="$CFLAGS -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LIBS="$LIBS -lm"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libmd
pkg_config freetype2
diff --git a/libtommath b/libtommath
index d481898..3bd6700 160000
--- a/libtommath
+++ b/libtommath
@@ -1 +1 @@
-Subproject commit d4818983e34f7faf8da74643027dc70e5a1beec7
+Subproject commit 3bd6700b68f2f8ebbc56d8990e5aef0d69b2ad3b
diff --git a/math/configure b/math/configure
index 1ac3c40..c98df39 100755
--- a/math/configure
+++ b/math/configure
@@ -49,6 +49,7 @@ LIBS="${LIBS:=-lm}"
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/test/configure b/test/configure
index 0fe6ef2..9f98f67 100755
--- a/test/configure
+++ b/test/configure
@@ -42,10 +42,10 @@ echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
LDFLAGS="$LDFLAGS -rdynamic"
config_asan
config_gnu
+config_i386
pkg_config libbsd-overlay
pkg_config libffi
pkg_config libmd
diff --git a/ucd2c/configure b/ucd2c/configure
index cbdea46..1287345 100755
--- a/ucd2c/configure
+++ b/ucd2c/configure
@@ -34,7 +34,7 @@ LIBS="${LIBS:=}"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -O2"
-CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
+config_i386
pkg_config libbsd-overlay
# Main config