summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rules/dtc.make52
-rw-r--r--rules/post/dts.make5
-rw-r--r--scripts/lib/ptxd_make_dts_dtc.sh69
3 files changed, 84 insertions, 42 deletions
diff --git a/rules/dtc.make b/rules/dtc.make
index 4176a579c..6aa321f16 100644
--- a/rules/dtc.make
+++ b/rules/dtc.make
@@ -25,52 +25,22 @@ ptx/dtb = $(notdir $(basename $(strip $(1)))).dtb
ptx/dts = $(shell p=$(PTXCONF_DTC_OFTREE_DTS_PATH) ptxd_in_path p "$(strip $(1))" && echo "$${ptxd_reply}")
ifdef PTXCONF_DTC_OFTREE_DTS
+# Note: this must match the magic in ptxd_make_dts_dtb
DTC_OFTREE_DTS = $(foreach dts, $(call remove_quotes,$(PTXCONF_DTC_OFTREE_DTS)), \
$(if $(filter /%,$(dts)),$(dts),$(call ptx/dts,$(dts))))
endif
-%.dtb: TMP_DTS = $(STATEDIR)/$(notdir $<).tmp
-%.dtb: TMP_DEPS = $(PTXDIST_TEMPDIR)/dts.deps
-%.dtb: DEPS = $(STATEDIR)/dtc.$(notdir $<).deps
-%.dtb:
+dts/env = \
+ $(call ptx/env) \
+ dts_path=$(PTXCONF_DTC_OFTREE_DTS_PATH) \
+ dts_dtb="$(strip $(1))" \
+ dts_dts="$(strip $(2))" \
+ dts_kernel_dir="$(KERNEL_DIR)" \
+ dts_kernel_arch="$(GENERIC_KERNEL_ARCH)"
+
+%.dtb: $(STATEDIR)/dtc.install
@$(call targetinfo)
- @if [ -z "$(strip $<)" ]; then \
- ptxd_bailout "Device-tree for `ptxd_print_path '$@'` undefined!"; \
- fi
- @if [ ! -e "$(strip $<)" ]; then \
- ptxd_bailout "Device-tree '$<' not found!"; \
- fi
- @echo CPP `ptxd_print_path "$(TMP_DTS)"`
- @cpp \
- -Wp,-MD,$(TMP_DEPS) \
- -Wp,-MT,$(TMP_DTS) \
- -nostdinc \
- -P \
- -I$(dir $<) \
- -I$(KERNEL_DIR)/arch/$(GENERIC_KERNEL_ARCH)/boot/dts \
- -I$(KERNEL_DIR)/arch/$(GENERIC_KERNEL_ARCH)/boot/dts/include \
- -I$(KERNEL_DIR)/include \
- -undef -D__DTS__ -x assembler-with-cpp \
- -o $(TMP_DTS) \
- $<
- @sed -e 's;^$(TMP_DTS):;$@:;' -e 's;^ \([^ ]*\); $$(wildcard \1);' $(TMP_DEPS) > $(DEPS)
- @echo DTC `ptxd_print_path "$@"`
- @if $(PTXCONF_SYSROOT_HOST)/bin/dtc -h 2>&1 | grep -q "^[[:space:]]\+-i\(,.*\)\?$$"; then \
- dtc_include="-i $(dir $<) -i $(KERNEL_DIR)/arch/$(GENERIC_KERNEL_ARCH)/boot/dts"; \
- fi; \
- $(PTXCONF_SYSROOT_HOST)/bin/dtc \
- $(call remove_quotes,$(PTXCONF_DTC_EXTRA_ARGS)) \
- $$dtc_include \
- -d $(TMP_DEPS) \
- -I dts -O dtb -b 0 \
- -o "$@" "$(TMP_DTS)"
- @awk '{ \
- printf "%s", $$1 ; \
- for (i = 2; i <= NF; i++) { \
- printf " $$(wildcard %s)", $$i; \
- }; \
- print "" \
- }' $(TMP_DEPS) >> $(DEPS)
+ @$(call dts/env, $@, $(DTB_DTS)) ptxd_make_dts_dtb
@$(call finish)
DTC_DTB = $(foreach dts, $(call remove_quotes,$(PTXCONF_DTC_OFTREE_DTS)), $(IMAGEDIR)/$(call ptx/dtb, $(dts)))
diff --git a/rules/post/dts.make b/rules/post/dts.make
index 4781625d5..53be7d10a 100644
--- a/rules/post/dts.make
+++ b/rules/post/dts.make
@@ -13,7 +13,10 @@
# .dtb depends on the .dts and dtc.install for all other dependencies
#
$(foreach dts, $(call remove_quotes,$(DTC_OFTREE_DTS)), \
- $(eval $(IMAGEDIR)/$(call ptx/dtb, $(dts)): $(dts) $(STATEDIR)/dtc.install))
+ $(eval $(IMAGEDIR)/$(call ptx/dtb, $(dts)): $(dts)))
+
+$(foreach dts, $(call remove_quotes,$(PTXCONF_DTC_OFTREE_DTS)), \
+ $(eval $(IMAGEDIR)/$(call ptx/dtb, $(dts)): DTB_DTS=$(dts)))
$(foreach dts, $(call remove_quotes,$(DTC_OFTREE_DTS)), \
$(eval $(dts): $(STATEDIR)/kernel.extract.post))
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