dtb.build.mk 2.5 KB

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