diff options
author | Simon Glass <sjg@chromium.org> | 2011-08-17 15:32:26 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 12:28:32 -0700 |
commit | 5b973a2e8704bbd8b88e7aff48346ed4213d7a62 (patch) | |
tree | c52fc13cf871f9c10d78083c65c95cb924efc011 /dts | |
parent | dca1391773f23078eca06892058bda67daa875b2 (diff) |
fdt: Build embedded fdt with correct architecture
This is hard-coded to ARM at present, but really should be getting the correct
architecture from the lds file, however unpleasant this is.
BUG=chromium-os:19353
TEST=build for Seaboard
Change-Id: I7974b742a286efb3fd80b84cd47713fb3fc29c9e
Reviewed-on: http://gerrit.chromium.org/gerrit/6256
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'dts')
-rw-r--r-- | dts/Makefile | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/dts/Makefile b/dts/Makefile index 01989818f8b..7d89025f309 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -46,10 +46,35 @@ DT_BIN := $(obj)dt.dtb $(DT_BIN): $(TOPDIR)/board/$(BOARDDIR)/$(DEVICE_TREE).dts $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} $< -# TODO: get arch properly for objcopy line. +process_lds = \ + $(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p' + +# Run the compiler and get the link script from the linker +GET_LDS = $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--verbose 2>&1 + $(obj)dt.o: $(DT_BIN) + # We want the output format and arch. + # We also hope to win a prize for ugliest Makefile / shell interaction + # We look in the LDSCRIPT first. + # Then try the linker which should give us the answer. + # Then check it worked. + oformat=`$(call process_lds,cat $(LDSCRIPT),FORMAT)` ;\ + oarch=`$(call process_lds,cat $(LDSCRIPT),ARCH)` ;\ + \ + [ -z $${oformat} ] && \ + oformat=`$(call process_lds,$(GET_LDS),FORMAT)` ;\ + [ -z $${oarch} ] && \ + oarch=`$(call process_lds,$(GET_LDS),ARCH)` ;\ + \ + [ -z $${oformat} ] && \ + echo "Cannot read OUTPUT_FORMAT from lds file $(LDSCRIPT)" && \ + exit 1 || true ;\ + [ -z $${oarch} ] && \ + echo "Cannot read OUTPUT_ARCH from lds file $(LDSCRIPT)" && \ + exit 1 || true ;\ + \ cd $(dir ${DT_BIN}) && \ - $(OBJCOPY) -B armv5te -I binary -O elf32-littlearm \ + $(OBJCOPY) -I binary -O $${oformat} -B $${oarch} \ $(notdir ${DT_BIN}) $@ rm $(DT_BIN) |