xref: /freebsd/sys/conf/dtb.mk (revision 076ad2f836d5f49dc1375f1677335a48fe0d4b82)
1 # $FreeBSD$
2 #
3 # The include file <dtb.mk> handles building and installing dtb files.
4 #
5 # +++ variables +++
6 #
7 # DTS		List of the dts files to build and install.
8 #
9 # DTBDIR	Base path for dtb modules [/boot/dtb]
10 #
11 # DTBOWN	.dtb file owner. [${BINOWN}]
12 #
13 # DTBGRP	.dtb file group. [${BINGRP}]
14 #
15 # DTBMODE	Module file mode. [${BINMODE}]
16 #
17 # DESTDIR	The tree where the module gets installed. [not set]
18 #
19 # +++ targets +++
20 #
21 # 	install:
22 #               install the kernel module; if the Makefile
23 #               does not itself define the target install, the targets
24 #               beforeinstall and afterinstall may also be used to cause
25 #               actions immediately before and after the install target
26 #		is executed.
27 #
28 
29 .include <bsd.init.mk>
30 # Grab all the options for a kernel build. For backwards compat, we need to
31 # do this after bsd.own.mk.
32 .include "kern.opts.mk"
33 
34 # Search for kernel source tree in standard places.
35 .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
36 .if !defined(SYSDIR) && exists(${_dir}/kern/)
37 SYSDIR=	${_dir:tA}
38 .endif
39 .endfor
40 .if !defined(SYSDIR) || !exists(${SYSDIR}/kern/)
41 .error "can't find kernel source tree"
42 .endif
43 
44 .SUFFIXES: .dtb .dts
45 
46 .PATH: ${SYSDIR}/gnu/dts/${MACHINE} ${SYSDIR}/boot/fdt/dts/${MACHINE}
47 
48 DTB=${DTS:R:S/$/.dtb/}
49 
50 all: ${DTB}
51 
52 .if defined(DTS)
53 .for _dts in ${DTS}
54 ${_dts:R:S/$/.dtb/}:	${_dts} ${OP_META}
55 	@echo Generating ${.TARGET} from ${_dts}
56 	@${SYSDIR}/tools/fdt/make_dtb.sh ${SYSDIR} ${_dts} ${.OBJDIR}
57 CLEANFILES+=${_dts:R:S/$/.dtb/}
58 .endfor
59 .endif
60 
61 .if !target(install)
62 .if !target(realinstall)
63 realinstall: _dtbinstall
64 .ORDER: beforeinstall _kmodinstall
65 _dtbinstall:
66 # Need to create this because installkernel doesn't invoke mtree with BSD.root.mtree
67 # to make sure the tree is setup properly. We don't recreate it to avoid duplicate
68 # entries in the NO_ROOT case.
69 	test -d ${DESTDIR}${DTBDIR} || ${INSTALL} -d -o ${DTBOWN} -g ${DTBGRP} ${DESTDIR}${DTBDIR}
70 .for _dtb in ${DTB}
71 	${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \
72 	    ${_INSTALLFLAGS} ${_dtb} ${DESTDIR}${DTBDIR}/
73 .endfor
74 .endif # !target(realinstall)
75 .endif # !target(install)
76 
77 .include <bsd.dep.mk>
78 .include <bsd.obj.mk>
79 .include <bsd.links.mk>
80