Index: sys/conf/Makefile.arm =================================================================== --- sys/conf/Makefile.arm +++ sys/conf/Makefile.arm @@ -169,3 +169,4 @@ %RULES .include "$S/conf/kern.post.mk" +.include "$S/conf/dtb.mk" Index: sys/conf/Makefile.arm64 =================================================================== --- sys/conf/Makefile.arm64 +++ sys/conf/Makefile.arm64 @@ -46,3 +46,4 @@ %RULES .include "$S/conf/kern.post.mk" +.include "$S/conf/dtb.mk" Index: sys/conf/dtb.mk =================================================================== --- sys/conf/dtb.mk +++ sys/conf/dtb.mk @@ -49,35 +49,51 @@ .PATH: ${SYSDIR}/gnu/dts/${MACHINE} ${SYSDIR}/dts/${MACHINE} ${SYSDIR}/dts/${MACHINE}/overlays -DTB=${DTS:R:S/$/.dtb/} -DTBO=${DTSO:R:S/$/.dtbo/} - -all: ${DTB} ${DTBO} - .if defined(DTS) -.export DTC ECHO .for _dts in ${DTS} -${_dts:R:S/$/.dtb/}: ${_dts} ${OP_META} - @${ECHO} Generating ${.TARGET} from ${_dts} - @${SYSDIR}/tools/fdt/make_dtb.sh ${SYSDIR} ${_dts} ${.OBJDIR} -CLEANFILES+=${_dts:R:S/$/.dtb/} +_dtb=${_dts:T:R:S/$/.dtb/} +.if !empty(DTS_${_dtb}) +.warning "Duplicated DTS ${_dts}" +.endif + +DTB:=${DTB} ${_dtb} +DTS_${_dtb}:=${_dts} .endfor .endif .if defined(DTSO) -.export DTC ECHO .for _dtso in ${DTSO} -${_dtso:R:S/$/.dtbo/}: ${_dtso} ${OP_META} - @${ECHO} Generating ${.TARGET} from ${_dtso} - @${SYSDIR}/tools/fdt/make_dtbo.sh ${SYSDIR} overlays/${_dtso} ${.OBJDIR} -CLEANFILES+=${_dtso:R:S/$/.dtbo/} +_dtso_path=${_dtso:C/^([^\/])/overlays\/\\1/} +_dtbo=${_dtso:T:R:S/$/.dtbo/} +.if !empty(DTSO_${_dtbo}) +.warning "Duplicated DTSO ${_dtso}" +.endif + +DTBO:=${DTBO} ${_dtbo} +DTSO_${_dtbo}:=${_dtso_path} +.endfor +.endif + +.if defined(DTB) +.export DTC ECHO +.for _dtb in ${DTB} +${_dtb}: ${_dts} ${OP_META} + @${ECHO} Generating ${.TARGET} from ${DTS_${.TARGET}} + @${SYSDIR}/tools/fdt/make_dtb.sh ${SYSDIR} ${DTS_${.TARGET}} ${.OBJDIR} +CLEANFILES+=${_dtb} +.endfor +.endif + +.if defined(DTBO) +.export DTC ECHO +.for _dtbo in ${DTBO} +${_dtbo}: ${DTSO_${.TARGET}} ${OP_META} + @${ECHO} Generating ${.TARGET} from ${DTSO_${.TARGET}} + @${SYSDIR}/tools/fdt/make_dtbo.sh ${SYSDIR} ${DTSO_${.TARGET}} ${.OBJDIR} +CLEANFILES+=${_dtbo} .endfor .endif -.if !target(install) -.if !target(realinstall) -realinstall: _dtbinstall -.ORDER: beforeinstall _kmodinstall _dtbinstall: # Need to create this because installkernel doesn't invoke mtree with BSD.root.mtree # to make sure the tree is setup properly. We don't recreate it to avoid duplicate @@ -85,9 +101,13 @@ test -d ${DESTDIR}${DTBDIR} || ${INSTALL} -d -o ${DTBOWN} -g ${DTBGRP} ${DESTDIR}${DTBDIR} .for _dtb in ${DTB} .if ${MACHINE_CPUARCH} == "aarch64" - test -d ${DESTDIR}${DTBDIR}/${_dtb:H} || ${INSTALL} -d -o ${DTBOWN} -g ${DTBGRP} ${DESTDIR}${DTBDIR}/${_dtb:H} + # :H:T here to grab the vendor component of the DTB path in a way that + # allows out-of-tree DTS builds, too. We make the assumption that + # out-of-tree DTS will have a similar directory structure to in-tree, + # with .dts files appearing in a vendor/ directory. + test -d ${DESTDIR}${DTBDIR}/${_dtb:H:T} || ${INSTALL} -d -o ${DTBOWN} -g ${DTBGRP} ${DESTDIR}${DTBDIR}/${_dtb:H:T} ${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ - ${_INSTALLFLAGS} ${_dtb:T} ${DESTDIR}${DTBDIR}/${_dtb:H} + ${_INSTALLFLAGS} ${_dtb:T} ${DESTDIR}${DTBDIR}/${_dtb:H:T} .else ${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ ${_INSTALLFLAGS} ${_dtb} ${DESTDIR}${DTBDIR}/ @@ -98,9 +118,16 @@ ${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ ${_INSTALLFLAGS} ${_dtbo} ${DESTDIR}${DTBODIR}/ .endfor -.endif # !target(realinstall) -.endif # !target(install) -.include +.if target(kernel-install) +kernel-all: ${DTB} ${DTBO} +kernel-install: _dtbinstall +.ORDER: beforeinstall _dtbinstall +.elif !target(install) && !target(realinstall) +all: ${DTB} ${DTBO} +realinstall: _dtbinstall +.ORDER: beforeinstall _dtbinstall + .include .include +.endif # !target(install) && !target(realinstall)