1# $NetBSD: bsd.dtb.mk,v 1.3 2021/06/02 10:28:21 jmcneill Exp $ 2 3.include <bsd.init.mk> 4.include <bsd.own.mk> 5 6##### Default values 7.if !defined(S) 8. if defined(NETBSDSRCDIR) 9S= ${NETBSDSRCDIR}/sys 10. elif defined(BSDSRCDIR) 11S= ${BSDSRCDIR}/sys 12. else 13S= /sys 14. endif 15.endif 16 17##### Basic targets 18.PHONY: dtbinstall dtblist dtb 19realinstall: dtbinstall 20realall: dtb 21 22DTSPADDING?= 1024 23 24.if !make(obj) && !make(clean) && !make(cleandir) 25.BEGIN:: 26 -@mkdir -p ${.OBJDIR}/dts 27.for _arch in ${DTSGNUARCH} 28 -@ln -snf ${S:S@^../@../../@}/external/gpl2/dts/dist/arch/${_arch}/boot/dts ${.OBJDIR}/dts/${_arch} 29.endfor 30.endif 31 32DTSINC?=$S/external/gpl2/dts/dist/include 33.for _arch in ${DTSARCH} 34DTSDIR+=$S/arch/${_arch}/dts 35.endfor 36.for _arch in ${DTSGNUARCH} 37DTSDIR+=$S/external/gpl2/dts/dist/arch/${_arch}/boot/dts 38.if defined(DTSSUBDIR) 39DTSDIR+=$S/external/gpl2/dts/dist/arch/${_arch}/boot/dts/${DTSSUBDIR} 40.endif 41.endfor 42 43DTSPATH=${DTSINC} ${DTSDIR} ${.OBJDIR}/dts 44 45.SUFFIXES: .dtb .dts 46 47.dts.dtb: 48 ${CPP} -P -xassembler-with-cpp ${DTSPATH:@v@-I ${v}@} \ 49 -include ${.IMPSRC} /dev/null | \ 50 ${TOOL_DTC} ${DTSPATH:@v@-i ${v}@} -I dts -O dtb \ 51 -p ${DTSPADDING} -b 0 -@ -o ${.TARGET} 52 53.PATH.dts: ${DTSDIR} 54 55DTB= ${DTS:.dts=.dtb} 56 57dtb: ${DTB} 58 59.if defined(DTSSUBDIR) 60DTBINSTDIR= ${DTBDIR}/${DTSSUBDIR} 61.else 62DTBINSTDIR= ${DTBDIR} 63.endif 64 65dtbinstall: dtb 66 ${INSTALL_DIR} ${DESTDIR}${DTBINSTDIR} 67.for _dtb in ${DTB} 68 ${_MKSHMSG_INSTALL} ${_dtb} 69 ${_MKSHECHO} "${INSTALL_FILE} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ 70 ${.OBJDIR}/${_dtb} ${DESTDIR}${DTBINSTDIR}" 71 ${INSTALL_FILE} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ 72 ${.OBJDIR}/${_dtb} ${DESTDIR}${DTBINSTDIR} 73.endfor 74.if defined(DTSSUBDIR) 75.for _dtb in ${DTB_NOSUBDIR} 76 ${_MKSHMSG_INSTALL} ${_dtb} 77 ${_MKSHECHO} "${INSTALL_FILE} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ 78 ${.OBJDIR}/${_dtb} ${DESTDIR}${DTBDIR}" 79 ${INSTALL_FILE} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \ 80 ${.OBJDIR}/${_dtb} ${DESTDIR}${DTBDIR} 81.endfor 82.endif 83 84dtblist: 85.if defined(DTSSUBDIR) 86 @echo ".${DTBINSTDIR}\t\tdtb-base-boot\tdtb" | \ 87 ${TOOL_SED} 's/\\t/ /g' 88.for _dtb in ${DTB_NOSUBDIR} 89 @echo ".${DTBDIR}/${_dtb}\t\tdtb-base-boot\tdtb" | \ 90 ${TOOL_SED} 's/\\t/ /g' 91.endfor 92.endif 93.for _dtb in ${DTB} 94 @echo ".${DTBINSTDIR}/${_dtb}\t\tdtb-base-boot\tdtb" | \ 95 ${TOOL_SED} 's/\\t/ /g' 96.endfor 97 98clean: .PHONY 99 rm -f ${DTB} 100.for _arch in ${DTSGNUARCH} 101 rm -f dts/${_arch} 102.endfor 103 test -d dts && rmdir dts || true 104 105 106##### Pull in related .mk logic 107.include <bsd.obj.mk> 108.include <bsd.kinc.mk> 109