summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_dts_dtc.sh
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2014-06-18 12:37:47 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2014-06-18 12:58:51 +0200
commit10eafd629720672ce099898b460aae3d3a3d9e5d (patch)
tree21765fed0a1f964f63ad878f8f48371e5608f8ec /scripts/lib/ptxd_make_dts_dtc.sh
parenta364b545b028a5ca49179a616f1fb838840d0297 (diff)
downloadptxdist-10eafd629720672ce099898b460aae3d3a3d9e5d.tar.gz
ptxdist-10eafd629720672ce099898b460aae3d3a3d9e5d.tar.xz
dtc: move dtb creation to shell
The latest changes broke the dependencies and variable resolution again. Fixing this in shell was a lot easier and cleaner. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts/lib/ptxd_make_dts_dtc.sh')
-rw-r--r--scripts/lib/ptxd_make_dts_dtc.sh69
1 files changed, 69 insertions, 0 deletions
diff --git a/scripts/lib/ptxd_make_dts_dtc.sh b/scripts/lib/ptxd_make_dts_dtc.sh
new file mode 100644
index 000000000..74638a93f
--- /dev/null
+++ b/scripts/lib/ptxd_make_dts_dtc.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+# Copyright (C) 2014 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+ptxd_make_dts_dtb() {
+ local dts tmp_dts deps tmp_deps
+
+ case "${dts_dts}" in
+ /*)
+ if [ ! -e "${dts_dts}" ]; then
+ ptxd_bailout "Device-tree '${dts_dts}' not found."
+ fi
+ dts="${dts_dts}"
+ ;;
+ *)
+ if ! ptxd_in_path dts_path "${dts_dts}"; then
+ ptxd_bailout "Device-tree '${dts_dts}' not found in '${dts_path}'."
+ fi
+ dts="${ptxd_reply}"
+ ;;
+ esac
+ tmp_dts="${ptx_state_dir}/$(basename "${dts}").tmp"
+ deps="${ptx_state_dir}/dtc.$(basename "${dts}").deps"
+ tmp_deps="${PTXDIST_TEMPDIR}/dts.deps"
+
+ echo "CPP $(ptxd_print_path "${tmp_dts}")"
+ cpp \
+ -Wp,-MD,${tmp_deps} \
+ -Wp,-MT,${tmp_dts} \
+ -nostdinc \
+ -P \
+ -I$(dirname "${dts}") \
+ -I${dts_kernel_dir}/arch/${dts_kernel_arch}/boot/dts \
+ -I${dts_kernel_dir}/arch/${dts_kernel_arch}/boot/dts/include \
+ -I${dts_kernel_dir}/include \
+ -undef -D__DTS__ -x assembler-with-cpp \
+ -o ${tmp_dts} \
+ ${dts}
+
+ sed -e "s;^${tmp_dts}:;${dts_dtb}:;" \
+ -e 's;^ \([^ ]*\); $(wildcard \1);' "${tmp_deps}" > "${deps}"
+
+ if dtc -h 2>&1 | grep -q '^[[:space:]]\+-i\(,.*\)\?$'; then
+ dtc_include="-i $(dirname "${dts}") -i ${dts_kernel_dir}/arch/${dts_kernel_arch}/boot/dts"
+ fi
+
+ echo "DTC $(ptxd_print_path "${dts_dtb}")"
+ dtc \
+ $(ptxd_get_ptxconf PTXCONF_DTC_EXTRA_ARGS) \
+ ${dtc_include} \
+ -d "${tmp_deps}" \
+ -I dts -O dtb -b 0 \
+ -o "${dts_dtb}" "${tmp_dts}"
+
+ awk '{ \
+ printf "%s", $1 ; \
+ for (i = 2; i <= NF; i++) { \
+ printf " $(wildcard %s)", $i; \
+ }; \
+ print "" \
+ }' "${tmp_deps}" >> "${deps}"
+}
+export -f ptxd_make_dts_dtb