dtb.build.mk 2.6 KB

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