diff --git a/c3s/configure b/c3s/configure
index 4fc719c..aa45181 100755
--- a/c3s/configure
+++ b/c3s/configure
@@ -51,7 +51,8 @@ LIBS="${LIBS:=-lm}"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
CPPFLAGS="$CPPFLAGS -I../libffi/include"
-LIBS="$LIBS -L../libffi/.libs/ -lffi"
+LDFLAGS="-L../libffi/.libs/ $LDFLAGS"
+LIBS="$LIBS -lffi"
config_asan
config_gnu
pkg_config libbsd-overlay
diff --git a/ic3/configure b/ic3/configure
index d4dbbbf..b7b9506 100755
--- a/ic3/configure
+++ b/ic3/configure
@@ -51,7 +51,8 @@ LIBS="${LIBS:=-lm}"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
CPPFLAGS="$CPPFLAGS -I../libffi/include"
-LIBS="$LIBS -L../libffi/.libs/ -lffi"
+LDFLAGS="-L../libffi/.libs/ $LDFLAGS"
+LIBS="$LIBS -lffi"
config_asan
config_gnu
pkg_config libbsd-overlay
diff --git a/libc3/configure b/libc3/configure
index 9e61d8d..e4987a7 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -40,10 +40,11 @@ LIBS="${LIBS} -lm -pthread -rpath ${PREFIX}/lib"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
CPPFLAGS="$CPPFLAGS -I../libffi/include"
+LDFLAGS="-L../libffi/.libs/ $LDFLAGS"
+LIBS="$LIBS -lffi"
config_asan
config_gnu
pkg_config libbsd-overlay
-pkg_config libffi
pkg_config libmd
config_lib libmd -lmd
config_lib dl -ldl
diff --git a/test/configure b/test/configure
index 450236b..af18696 100755
--- a/test/configure
+++ b/test/configure
@@ -51,7 +51,8 @@ LIBS="${LIBS:=} -lm"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
CPPFLAGS="$CPPFLAGS -I../libffi/include"
-LIBS="$LIBS -L../libffi/.libs/ -lffi"
+LDFLAGS="-L../libffi/.libs/ $LDFLAGS"
+LIBS="$LIBS -lffi"
config_asan
config_gnu
pkg_config libbsd-overlay