xref: /netbsd-src/etc/mtree/Makefile (revision d90047b5d07facf36e6c01dcc0bded8997ce9cc2)
1#	$NetBSD: Makefile,v 1.44 2020/06/12 14:12:20 roy Exp $
2
3.include <bsd.own.mk>
4
5EXTRA_DIST_FILES=	NetBSD.dist.machine	# autogenerated
6
7.if ${MKX11} != "no"
8EXTRA_DIST_FILES+=	NetBSD.dist.Xorg
9.endif
10
11# Derived from MACHINE_CPU, but keeping 32/64bit for most.
12MTREE_MACHINE_ARCH=${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips64/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/arm.*/arm/:C/earm.*/arm/:S/earm/arm/:S/aarch64eb/aarch64/:S/or1knd/or1k/}
13
14# The compat specific files
15
16.if defined(MKCOMPAT) && ${MKCOMPAT} != "no"
17.include "${NETBSDSRCDIR}/compat/archdirs.mk"
18.if exists(NetBSD.compat.${MTREE_MACHINE_ARCH})
19EXTRA_DIST_FILES+=	NetBSD.compat.${MTREE_MACHINE_ARCH}
20.endif
21EXTRA_DIST_FILES+=	NetBSD.dist.compat	# autogenerated
22.if defined(MKCOMPATX11) && ${MKCOMPATX11} != "no" && ${MKX11} != "no"
23EXTRA_DIST_FILES+=	NetBSD.dist.xcompat	# autogenerated
24.endif
25.endif
26
27
28# Platform specific files.
29# First we grab the mtree-specific, then either the MACHINE_ARCH or
30# MACHINE_CPU files, and finally the MACHINE files, as long as they
31# aren't the same files.
32
33.if exists(NetBSD.dist.${MTREE_MACHINE_ARCH})
34EXTRA_DIST_FILES+=	NetBSD.dist.${MTREE_MACHINE_ARCH}
35.endif
36
37.if empty(MTREE_MACHINE_ARCH:M${MACHINE_ARCH}) && \
38    exists(NetBSD.dist.${MACHINE_ARCH})
39EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE_ARCH}
40.elif empty(MTREE_MACHINE_ARCH:M${MACHINE_CPU}) && \
41    exists(NetBSD.dist.${MACHINE_CPU})
42EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE_CPU}
43.endif
44
45.if empty(MTREE_MACHINE_ARCH:M${MACHINE}) && \
46    exists(NetBSD.dist.${MACHINE})
47EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE}
48.endif
49
50
51# The build specific files.
52
53.if ${MKATF} != "no"
54EXTRA_DIST_FILES+=	NetBSD.dist.tests
55.if defined(MKCOMPATTESTS) && ${MKCOMPATTESTS} != "no"
56EXTRA_DIST_FILES+=	NetBSD.dist.tests.compat
57.endif
58.endif
59
60.if ${MKDTB} != "no"
61EXTRA_DIST_FILES+=	NetBSD.dist.dtb
62.endif
63
64.if ${MKDTRACE} != "no"
65EXTRA_DIST_FILES+=	NetBSD.dist.dtrace
66.endif
67
68.if ${MKEXTSRC} != "no"
69EXTRA_DIST_FILES+=	NetBSD.dist.extsrc
70.endif
71
72.if ${MKISCSI} != "no"
73EXTRA_DIST_FILES+=	NetBSD.dist.iscsi
74.endif
75
76NetBSD.dist:	NetBSD.dist.tmp
77	cmp -s NetBSD.dist.tmp NetBSD.dist || { \
78		echo "Updating NetBSD.dist"; \
79		mv NetBSD.dist.tmp NetBSD.dist; \
80	}
81# Rebuild every time
82.PHONY: NetBSD.dist.tmp
83NetBSD.dist.tmp: NetBSD.dist.base ${EXTRA_DIST_FILES}
84	${TOOL_CAT} ${.ALLSRC} > ${.TARGET}
85
86NetBSD.dist.machine:
87	${MKCREATE}
88	echo ./usr/include/${MACHINE} > ${.TARGET}
89
90NetBSD.dist.compat: NetBSD.dist.compat.in mkcompat.awk
91	${MKCREATE}
92	${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \
93	    ${.ALLSRC:M*.in} > ${.TARGET}
94
95NetBSD.dist.xcompat: NetBSD.dist.xcompat.in mkcompat.awk
96	${MKCREATE}
97	${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \
98	    ${.ALLSRC:M*.in} > ${.TARGET}
99
100NetBSD.dist.tests.compat: NetBSD.dist.tests mkcompattree.awk
101	${MKCREATE}
102	${TOOL_AWK} -f ${.ALLSRC:M*.awk} \
103	    -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} -v S="usr/tests" \
104		${.ALLSRC:M*.tests} > ${.TARGET}
105
106CONFIGFILES=	NetBSD.dist special
107FILESDIR=	/etc/mtree
108
109# distrib-dirs --
110#	Populate $DESTDIR with directories needed by NetBSD
111#
112.if ${MKUNPRIVED} == "no"
113TOOL_MTREE.unpriv=
114.else
115TOOL_MTREE.unpriv=	-W
116.endif
117
118# postinstall(8) invokes this target to produce the right
119# /etc/mtree/NetBSD.dist content without duplicating logic from
120# the Makefile.
121#
122emit_dist_file:	NetBSD.dist.base ${EXTRA_DIST_FILES}
123	@cat ${.ALLSRC}
124
125distrib-dirs: .PHONY check_DESTDIR NetBSD.dist
126.if !defined(DISTRIBUTION_DONE)						# {
127# Create DESTDIR using HOST_INSTALL_DIR, not INSTALL_DIR, because
128# INSTALL_DIR would want to write to the metalog, and it can't do that
129# if the metalog is inside DESTDIR but DESTDIR doesn't yet exist.
130	${HOST_INSTALL_DIR} -m 755 ${DESTDIR}
131# Invoke mtree to create the directories listed in NetBSD.dist;
132# then invoke mtree again to register those directories in the metalog.
133	${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \
134	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
135.if ${MKUNPRIVED} != "no"						# {
136	${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \
137	    -p ${DESTDIR}/ -C -k all | \
138	    ${TOOL_AWK} '/ optional/ {next} // {print}' | ${METALOG.add}
139.endif	# MKUNPRIVED							# }
140.endif	# DISTRIBUTION_DONE						# }
141
142CLEANFILES+=	NetBSD.dist NetBSD.dist.tmp
143CLEANFILES+=	NetBSD.dist.machine
144CLEANFILES+=	NetBSD.dist.compat
145CLEANFILES+=	NetBSD.dist.tests.compat
146
147.include <bsd.prog.mk>
148