Home | History | Annotate | Line # | Download | only in mk
bsd.dtb.mk revision 1.1
      1 #	$NetBSD: bsd.dtb.mk,v 1.1 2020/05/18 21:19:35 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 
     75 dtblist:
     76 .if defined(DTSSUBDIR)
     77 	@echo ".${DTBINSTDIR}\t\tdtb-base-boot\tdtb"
     78 .endif
     79 .for _dtb in ${DTB}
     80 	@echo ".${DTBINSTDIR}/${_dtb}\t\tdtb-base-boot\tdtb"
     81 .endfor
     82 
     83 clean:  .PHONY
     84 	rm -f ${DTB}
     85 .for _arch in ${DTSGNUARCH}
     86 	rm -f dts/${_arch}
     87 .endfor
     88 	test -d dts && rmdir dts || true
     89 
     90 
     91 ##### Pull in related .mk logic
     92 .include <bsd.obj.mk>
     93 .include <bsd.kinc.mk>
     94