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