1# $FreeBSD$ 2 3.include <bsd.init.mk> 4# Grab all the options for a kernel build. For backwards compat, we need to 5# do this after bsd.own.mk. 6.include "kern.opts.mk" 7 8DTC?= dtc 9 10.if !defined(SYSDIR) 11.if defined(S) 12SYSDIR= ${S} 13.else 14.include <bsd.sysdir.mk> 15.endif # defined(S) 16.endif # defined(SYSDIR) 17 18.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/) 19.error "can't find kernel source tree" 20.endif 21 22.for _dts in ${DTS} 23# DTB for aarch64 needs to preserve the immediate parent of the .dts, because 24# these DTS are vendored and should be installed into their vendored directory. 25.if ${MACHINE_ARCH} == "aarch64" 26DTB+= ${_dts:R:S/$/.dtb/} 27.else 28DTB+= ${_dts:T:R:S/$/.dtb/} 29.endif 30.endfor 31 32DTBO=${DTSO:T:R:S/$/.dtbo/} 33 34.SUFFIXES: .dtb .dts .dtbo .dtso 35.PATH.dts: ${SYSDIR}/gnu/dts/${MACHINE} ${SYSDIR}/dts/${MACHINE} 36.PATH.dtso: ${SYSDIR}/dts/${MACHINE}/overlays 37 38.export DTC ECHO 39 40.dts.dtb: ${OP_META} 41 @${ECHO} Generating ${.TARGET} from ${.IMPSRC} 42 @${SYSDIR}/tools/fdt/make_dtb.sh ${SYSDIR} ${.IMPSRC} ${.OBJDIR} 43 44.dtso.dtbo: ${OP_META} 45 @${ECHO} Generating ${.TARGET} from ${.IMPSRC} 46 @${SYSDIR}/tools/fdt/make_dtbo.sh ${SYSDIR} ${.IMPSRC} ${.OBJDIR} 47 48# Add dependencies on the source file so that out-of-tree things can be included 49# without any .PATH additions. 50.for _dts in ${DTS} ${FDT_DTS_FILE} 51${_dts:R:T}.dtb: ${_dts} 52.endfor 53 54.for _dtso in ${DTSO} 55${_dtso:R:T}.dtbo: ${_dtso} 56.endfor 57 58_dtbinstall: 59# Need to create this because installkernel doesn't invoke mtree with BSD.root.mtree 60# to make sure the tree is setup properly. We don't recreate it to avoid duplicate 61# entries in the NO_ROOT case. 62 test -d ${DESTDIR}${DTBDIR} || ${INSTALL} -d -o ${DTBOWN} -g ${DTBGRP} ${DESTDIR}${DTBDIR} 63.for _dtb in ${DTB} 64.if ${MACHINE_CPUARCH} == "aarch64" 65 # :H:T here to grab the vendor component of the DTB path in a way that 66 # allows out-of-tree DTS builds, too. We make the assumption that 67 # out-of-tree DTS will have a similar directory structure to in-tree, 68 # with .dts files appearing in a vendor/ directory. 69 test -d ${DESTDIR}${DTBDIR}/${_dtb:H:T} || ${INSTALL} -d -o ${DTBOWN} -g ${DTBGRP} ${DESTDIR}${DTBDIR}/${_dtb:H:T} 70 ${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ 71 ${_INSTALLFLAGS} ${_dtb:T} ${DESTDIR}${DTBDIR}/${_dtb:H:T} 72.else 73 ${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ 74 ${_INSTALLFLAGS} ${_dtb} ${DESTDIR}${DTBDIR}/ 75.endif 76.endfor 77 test -d ${DESTDIR}${DTBODIR} || ${INSTALL} -d -o ${DTBOWN} -g ${DTBGRP} ${DESTDIR}${DTBODIR} 78.for _dtbo in ${DTBO} 79 ${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ 80 ${_INSTALLFLAGS} ${_dtbo} ${DESTDIR}${DTBODIR}/ 81.endfor 82