Commit 282059bb7a89a84f4db705ab5479ae5cff578485

Thomas de Grivel 2024-01-29T18:17:51

c11 -> use system libffi

diff --git a/Makefile b/Makefile
index 06582d5..f866b72 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,6 @@
 
 build:
 	${MAKE} gen
-	${GMAKE} -C libffi all
 	${MAKE} -C libtommath build
 	${MAKE} -C ucd2c build
 	${MAKE} -C libc3 build
@@ -22,7 +21,6 @@ build:
 
 all:
 	${MAKE} gen
-	${GMAKE} -C libffi all
 	${MAKE} -C libtommath all
 	${MAKE} -C ucd2c all
 	${MAKE} -C libc3 all
@@ -31,7 +29,6 @@ all:
 	${MAKE} -C test all
 
 asan:
-	${GMAKE} -C libffi all
 	${MAKE} -C libtommath asan
 	${MAKE} -C libc3 asan
 	${MAKE} -C ic3 asan
@@ -39,7 +36,6 @@ asan:
 	${MAKE} -C test asan
 
 clean:
-	${GMAKE} -C libffi clean
 	${MAKE} -C libtommath clean
 	${MAKE} -C ucd2c clean
 	${MAKE} -C libc3 clean
@@ -56,7 +52,6 @@ clean_cov:
 
 cov:
 	${MAKE} gen
-	${GMAKE} -C libffi all
 	${MAKE} -C libtommath cov
 	${MAKE} -C libc3 cov
 	${MAKE} -C ic3 cov
@@ -64,7 +59,6 @@ cov:
 	${MAKE} -C test cov
 
 debug:
-	${GMAKE} -C libffi all
 	${MAKE} -C libtommath debug
 	${MAKE} -C libc3 debug
 	${MAKE} -C ic3 debug
@@ -156,7 +150,6 @@ ic3_gcovr:
 	${MAKE} gcovr
 
 install:
-	${GMAKE} -C libffi install
 	${MAKE} -C libc3 install
 	${MAKE} -C ic3 install
 	${MAKE} -C c3s install
@@ -166,9 +159,6 @@ libc3_gcovr:
 	${MAKE} libc3_test_cov
 	${MAKE} gcovr
 
-libffi:
-	${GMAKE} -C libffi all
-
 license:
 	update_header config.subr ${C3_CONFIGURES}
 	update_header Makefile ${C3_MAKEFILES}
@@ -259,7 +249,6 @@ test_libc3_debug:
 	install \
 	libc3 \
 	libtommath \
-	libffi \
 	license \
 	test \
 	test_asan \
diff --git a/c3s/configure b/c3s/configure
index 4b263c6..7313358 100755
--- a/c3s/configure
+++ b/c3s/configure
@@ -39,16 +39,16 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
 
 # Common config for all targets
-CPPFLAGS="-I../libffi/include $CPPFLAGS"
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -fPIC"
 LDFLAGS="$LDFLAGS -rdynamic"
 config_asan
 config_gnu
 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 ../libffi/libffi.la -pthread -lm"
+LIBS="$LIBS -pthread -lm"
 
 # Asan config
 CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
diff --git a/configure b/configure
index 3dadc8b..917ff41 100755
--- a/configure
+++ b/configure
@@ -36,7 +36,6 @@ echo "HAVE_ASAN = ${HAVE_ASAN}" >> ${CONFIG_MK}
 update_config_mk
 env_reset
 
-( cd libffi; sh autogen.sh; MAKE="${GMAKE}" ./configure --prefix "${PREFIX}" --disable-multi-os-directory --disable-dependency-tracking; )
 ( cd libtommath; ./configure; )
 ( cd ucd2c     ; ./configure; )
 ( cd libc3     ; ./configure; )
diff --git a/ic3/configure b/ic3/configure
index 9b48bd4..d251313 100755
--- a/ic3/configure
+++ b/ic3/configure
@@ -26,17 +26,17 @@ PROG_DEBUG=ic3_debug
 . ./sources.sh
 
 # Common config for all targets
-CPPFLAGS="-I../libffi/include $CPPFLAGS"
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -fPIC"
 LDFLAGS="$LDFLAGS -rdynamic"
 config_asan
 config_gnu
 pkg_config libbsd-overlay
+pkg_config libffi
 pkg_config libmd
 config_lib libmd -lmd 2>/dev/null
 config_lib dl -ldl 2>/dev/null
 pkg_config wineditline
-LIBS="$LIBS ../libffi/libffi.la -pthread"
+LIBS="$LIBS -pthread"
 
 if pkg-config wineditline; then
     echo "#define HAVE_WINEDITLINE 1" >> ${CONFIG_H}
diff --git a/libc3/configure b/libc3/configure
index 439f8f6..2ae4c8d 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -37,12 +37,12 @@ OBJECTS_COV="$(c2ext .cov.lo "$LO_SOURCES")"
 OBJECTS_DEBUG="$(c2ext .debug.lo "$LO_SOURCES")"
 
 # Common config for all targets
-CPPFLAGS="-I../libffi/include $CPPFLAGS"
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -fPIC"
 LDFLAGS="--shared $LDFLAGS -rdynamic"
 config_asan
 config_gnu
 pkg_config libbsd-overlay
+pkg_config libffi
 pkg_config libmd
 config_lib libmd -lmd 2>/dev/null
 config_lib dl -ldl 2>/dev/null
@@ -51,7 +51,7 @@ config_include sha1_h sys/types.h sha1.h HAVE_SHA1_H
 config_define PREFIX "\"${PREFIX}\""
 config_have_stat_mtim
 update_config_h
-LIBS="$LIBS ../libffi/libffi.la -lm -pthread -rpath ${PREFIX}/lib"
+LIBS="$LIBS -lm -pthread -rpath ${PREFIX}/lib"
 
 if ! [ -f ../ucd2c/ucd.c ]; then
     touch ../ucd2c/ucd.c
diff --git a/libc3/window/cairo/configure b/libc3/window/cairo/configure
index ea26c67..5fff858 100755
--- a/libc3/window/cairo/configure
+++ b/libc3/window/cairo/configure
@@ -36,14 +36,15 @@ OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
 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"
+CPPFLAGS="-I../../.. $CPPFLAGS"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic"
 OBJCFLAGS="$CFLAGS -W -Wall -Werror"
 LDFLAGS="--shared ${LDFLAGS}"
 LIBS="$LIBS -rpath ${PREFIX}/lib"
 config_asan
 config_gnu
 pkg_config libbsd-overlay
+pkg_config libffi
 pkg_config cairo
 pkg_config cairo-ft
 pkg_config freetype2
diff --git a/libc3/window/cairo/demo/configure b/libc3/window/cairo/demo/configure
index 94e186a..535863a 100755
--- a/libc3/window/cairo/demo/configure
+++ b/libc3/window/cairo/demo/configure
@@ -36,14 +36,15 @@ OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
 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"
+CPPFLAGS="-I../../../.. $CPPFLAGS"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic"
 LDFLAGS="--shared ${LDFLAGS}"
 LIBS="$LIBS -rpath ${PREFIX}/lib"
 config_asan
 config_gnu
-pkg_config cairo
 pkg_config libbsd-overlay
+pkg_config libffi
+pkg_config cairo
 pkg_config xkbcommon
 config_define PREFIX "\"${PREFIX}\""
 
diff --git a/libc3/window/cairo/xcb/configure b/libc3/window/cairo/xcb/configure
index 3614681..3e7cf94 100755
--- a/libc3/window/cairo/xcb/configure
+++ b/libc3/window/cairo/xcb/configure
@@ -36,12 +36,14 @@ 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"
+CPPFLAGS="$CPPFLAGS -I../../../.."
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -fPIC"
 LDFLAGS="--shared ${LDFLAGS}"
 LIBS="$LIBS -rpath ${PREFIX}/lib"
 config_asan
 config_gnu
+pkg_config libbsd-overlay
+pkg_config libffi
 pkg_config xcb
 pkg_config xkbcommon
 pkg_config cairo
diff --git a/libc3/window/cairo/xcb/demo/configure b/libc3/window/cairo/xcb/demo/configure
index 84ff760..cce9afb 100755
--- a/libc3/window/cairo/xcb/demo/configure
+++ b/libc3/window/cairo/xcb/demo/configure
@@ -44,10 +44,12 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
 
 # Common config for all targets
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
-CPPFLAGS="$CPPFLAGS -I../../../../../libffi/include -I../../../../.."
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic"
+CPPFLAGS="$CPPFLAGS -I../../../../.."
 config_asan
 config_gnu
+pkg_config libbsd-overlay
+pkg_config libffi
 pkg_config xcb
 pkg_config cairo
 LIBS="$LIBS"
diff --git a/libc3/window/configure b/libc3/window/configure
index 7f67cfa..9f6ab94 100755
--- a/libc3/window/configure
+++ b/libc3/window/configure
@@ -36,13 +36,14 @@ OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
 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"
+CPPFLAGS="-I../.. $CPPFLAGS"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic"
 LDFLAGS="--shared ${LDFLAGS}"
 LIBS="$LIBS -rpath ${PREFIX}/lib"
 config_asan
 config_gnu
 pkg_config libbsd-overlay
+pkg_config libffi
 config_define PREFIX "\"${PREFIX}\""
 
 # Address Sanitizer config
diff --git a/libc3/window/sdl2/configure b/libc3/window/sdl2/configure
index f459153..5eb6bb4 100755
--- a/libc3/window/sdl2/configure
+++ b/libc3/window/sdl2/configure
@@ -36,10 +36,9 @@ OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
 OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 
 # Common config for all targets
-CPPFLAGS="-I../../../libffi/include -I../../.. $CPPFLAGS"
-CPPFLAGS="-Iftgl/src $CPPFLAGS"
+CPPFLAGS="-I../../.. $CPPFLAGS"
 #CPPFLAGS="$CPPFLAGS -DGL_SILENCE_DEPRECATION=1"
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic"
 LDFLAGS="--shared ${LDFLAGS}"
 LIBS="$LIBS -rpath ${PREFIX}/lib"
 config_asan
diff --git a/libc3/window/sdl2/demo/configure b/libc3/window/sdl2/demo/configure
index df153c6..0f8cd83 100755
--- a/libc3/window/sdl2/demo/configure
+++ b/libc3/window/sdl2/demo/configure
@@ -44,9 +44,9 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
 
 # Common config for all targets
-CPPFLAGS="-I../../../../libffi/include -I../../../.. $CPPFLAGS"
+CPPFLAGS="-I../../../.. $CPPFLAGS"
 #CPPFLAGS="$CPPFLAGS -DGL_SILENCE_DEPRECATION=1"
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic"
 LIBS="$LIBS -lm"
 config_asan
 config_gnu
diff --git a/libtommath b/libtommath
index 552579a..aec1d55 160000
--- a/libtommath
+++ b/libtommath
@@ -1 +1 @@
-Subproject commit 552579a911978fc813f98f2b465a01ad1ff71134
+Subproject commit aec1d55c4755ec769a4649ec3fedbaea30c6b9a8
diff --git a/test/configure b/test/configure
index 744af2f..3b01f02 100755
--- a/test/configure
+++ b/test/configure
@@ -39,16 +39,16 @@ OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
 
 # Common config for all targets
-CPPFLAGS="-I../libffi/include $CPPFLAGS"
-CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -fPIC"
 LDFLAGS="$LDFLAGS -rdynamic"
 config_asan
 config_gnu
 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 ../libffi/libffi.la -pthread -lm"
+LIBS="$LIBS -pthread -lm"
 
 # Asan config
 CFLAGS_ASAN="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"