From 63c4c233624154d6dcbf21ecab10b4444d332d3c Mon Sep 17 00:00:00 2001 From: Alistair Popple Date: Thu, 13 Jul 2017 16:43:58 +1000 Subject: configure.ac: Detect architecture objcopy parameters The objcopy parameters required to turn device-tree blobs into elf objects for linking are architecture specific but were hard-coded. This required manual updates to Makefile.am when compiling for other architectures. Instead detect the parameters using an autoconf test. Signed-off-by: Alistair Popple --- Makefile.am | 3 +-- configure.ac | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1db5546..2bd3f83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,5 +60,4 @@ p9w-fsi.dtb.o: p9w-fsi.dts p9-fsi.dtsi # unflattening the device-tree dd if=$@.tmp of=$@ ibs=16 conv=sync rm $@.tmp -# objcopy -I binary -O elf32-littlearm -B arm $@ $@ - objcopy -I binary -O elf64-x86-64 -B i386:x86-64 $@ $@ + objcopy -I binary -O @ARCH_FF@ $@ $@ diff --git a/configure.ac b/configure.ac index 8bd9c3b..298c1e8 100644 --- a/configure.ac +++ b/configure.ac @@ -6,5 +6,13 @@ AC_PROG_LIBTOOL AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile]) - +AC_LANG(C) +AC_SUBST([ARCH_FF]) +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[]])], + ARCH_FF=$(${OBJDUMP} -f conftest.$OBJEXT | + sed -ne "s/.*file format //p" -e "s/.*architecture: \(.*\),.*/\1/p" | + tr "\n" " " | + sed -e "s/ / -B /"), + AC_MSG_FAILURE([Unable to determine architecture output file format])) AC_OUTPUT -- cgit v1.2.1