Commit 80912f2f09f4c06b2f720ff243d7b9b6795093f9

Clément Chigot 2022-09-01T14:47:16

Makefile: enable target overridings. (#661) This patch allows target to provide extra files enabling the override of Makefile rules. This patch is not needed for libffi itself but only for GCC on AIX. The t-aix file which is here empty will be replaced in GCC repository. We cannot include GCC version directly here because it has no sense for a standalone libffi. Co-authored-by: Clement <clement.chigot@atos.net>

diff --git a/Makefile.am b/Makefile.am
index a1a8912..31ece7b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -150,3 +150,5 @@ dist-hook:
 	if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog
 	s=`awk '/was released on/{ print NR; exit}' $(top_srcdir)/README.md`; tail -n +$$(($$s-1)) $(top_srcdir)/README.md > $(distdir)/README.md
 
+# target overrides
+-include $(tmake_file)
diff --git a/configure.ac b/configure.ac
index 7a17a23..915b820 100644
--- a/configure.ac
+++ b/configure.ac
@@ -431,6 +431,16 @@ else
 fi
 AC_SUBST(toolexeclibdir)
 
+# Conditionalize the makefile for this target machine.
+tmake_file_=
+for f in ${tmake_file}; do
+  if test -f ${srcdir}/src/$TARGETDIR/$f; then
+     tmake_file_="${tmake_file_} \$(srcdir)/src/$TARGETDIR/$f"
+  fi
+done
+tmake_file="${tmake_file_}"
+AC_SUBST(tmake_file)
+
 # Check linker support.
 LIBFFI_ENABLE_SYMVERS
 
diff --git a/configure.host b/configure.host
index 9d73f18..5cd5fc4 100644
--- a/configure.host
+++ b/configure.host
@@ -212,6 +212,8 @@ case "${host}" in
 	;;
   powerpc-*-aix* | rs6000-*-aix*)
 	TARGET=POWERPC_AIX; TARGETDIR=powerpc
+	# Create AIX-style "FAT" libraries.
+	tmake_file="t-aix"
 	;;
   powerpc-*-freebsd* | powerpc-*-openbsd* | powerpc-*-netbsd*)
 	TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
diff --git a/src/powerpc/t-aix b/src/powerpc/t-aix
new file mode 100644
index 0000000..e7be1ca
--- /dev/null
+++ b/src/powerpc/t-aix
@@ -0,0 +1,5 @@
+# This file is needed by GCC in order to correctly build AIX FAT
+# library for libffi.
+# However, it has no sense to include this code here, as it depends
+# on GCC multilib architecture.
+# Thus, this file is a simple stub replaced in GCC repository.