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