Home | History | Annotate | Line # | Download | only in mk
      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)
      9 S=      ${NETBSDSRCDIR}/sys
     10 .   elif defined(BSDSRCDIR)
     11 S=      ${BSDSRCDIR}/sys
     12 .   else
     13 S=      /sys
     14 .   endif
     15 .endif
     16 
     17 ##### Basic targets
     18 .PHONY:		dtbinstall dtblist dtb
     19 realinstall:	dtbinstall
     20 realall:	dtb
     21 
     22 DTSPADDING?=	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 
     32 DTSINC?=$S/external/gpl2/dts/dist/include
     33 .for _arch in ${DTSARCH}
     34 DTSDIR+=$S/arch/${_arch}/dts
     35 .endfor
     36 .for _arch in ${DTSGNUARCH}
     37 DTSDIR+=$S/external/gpl2/dts/dist/arch/${_arch}/boot/dts
     38 .if defined(DTSSUBDIR)
     39 DTSDIR+=$S/external/gpl2/dts/dist/arch/${_arch}/boot/dts/${DTSSUBDIR}
     40 .endif
     41 .endfor
     42 
     43 DTSPATH=${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 
     55 DTB= 		 ${DTS:.dts=.dtb}
     56 
     57 dtb:		${DTB}
     58 
     59 .if defined(DTSSUBDIR)
     60 DTBINSTDIR=	${DTBDIR}/${DTSSUBDIR}
     61 .else
     62 DTBINSTDIR=	${DTBDIR}
     63 .endif
     64 
     65 dtbinstall:	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 
     84 dtblist:
     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 
     98 clean:  .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