Makefile revision 1.46
1#	$NetBSD: Makefile,v 1.46 2022/05/25 20:44:01 nia 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/mipsn?64e[bl]/mips64/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/e?arm.*/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 ${MKDHCPD} != "no"
61EXTRA_DIST_FILES+=	NetBSD.dist.dhcpd
62.endif
63
64.if ${MKDTB} != "no"
65EXTRA_DIST_FILES+=	NetBSD.dist.dtb
66.endif
67
68.if ${MKDTRACE} != "no"
69EXTRA_DIST_FILES+=	NetBSD.dist.dtrace
70.endif
71
72.if ${MKEXTSRC} != "no"
73EXTRA_DIST_FILES+=	NetBSD.dist.extsrc
74.endif
75
76.if ${MKISCSI} != "no"
77EXTRA_DIST_FILES+=	NetBSD.dist.iscsi
78.endif
79
80NetBSD.dist:	NetBSD.dist.tmp
81	cmp -s NetBSD.dist.tmp NetBSD.dist || { \
82		echo "Updating NetBSD.dist"; \
83		mv NetBSD.dist.tmp NetBSD.dist; \
84	}
85# Rebuild every time
86.PHONY: NetBSD.dist.tmp
87NetBSD.dist.tmp: NetBSD.dist.base ${EXTRA_DIST_FILES}
88	${TOOL_CAT} ${.ALLSRC} > ${.TARGET}
89
90NetBSD.dist.machine:
91	${MKCREATE}
92	echo ./usr/include/${MACHINE} > ${.TARGET}
93
94NetBSD.dist.compat: NetBSD.dist.compat.in mkcompat.awk
95	${MKCREATE}
96	${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \
97	    ${.ALLSRC:M*.in} > ${.TARGET}
98
99NetBSD.dist.xcompat: NetBSD.dist.xcompat.in mkcompat.awk
100	${MKCREATE}
101	${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \
102	    ${.ALLSRC:M*.in} > ${.TARGET}
103
104NetBSD.dist.tests.compat: NetBSD.dist.tests mkcompattree.awk 
105	${MKCREATE}
106	${TOOL_AWK} -f ${.ALLSRC:M*.awk} \
107	    -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} -v S="usr/tests" \
108		${.ALLSRC:M*.tests} > ${.TARGET}
109
110CONFIGFILES=	NetBSD.dist special
111FILESDIR=	/etc/mtree
112
113# distrib-dirs --
114#	Populate $DESTDIR with directories needed by NetBSD
115#
116.if ${MKUNPRIVED} == "no"
117TOOL_MTREE.unpriv=
118.else
119TOOL_MTREE.unpriv=	-W
120.endif
121
122# postinstall(8) invokes this target to produce the right
123# /etc/mtree/NetBSD.dist content without duplicating logic from
124# the Makefile.
125#
126emit_dist_file:	NetBSD.dist.base ${EXTRA_DIST_FILES}
127	@cat ${.ALLSRC}
128
129distrib-dirs: .PHONY check_DESTDIR NetBSD.dist
130.if !defined(DISTRIBUTION_DONE)						# {
131# Create DESTDIR using HOST_INSTALL_DIR, not INSTALL_DIR, because
132# INSTALL_DIR would want to write to the metalog, and it can't do that
133# if the metalog is inside DESTDIR but DESTDIR doesn't yet exist.
134	${HOST_INSTALL_DIR} -m 755 ${DESTDIR}
135# Invoke mtree to create the directories listed in NetBSD.dist;
136# then invoke mtree again to register those directories in the metalog.
137	${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \
138	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
139.if ${MKUNPRIVED} != "no"						# {
140	${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \
141	    -p ${DESTDIR}/ -C -k all | \
142	    ${TOOL_AWK} '/ optional/ {next} // {print}' | ${METALOG.add}
143.endif	# MKUNPRIVED							# }
144.endif	# DISTRIBUTION_DONE						# }
145
146CLEANFILES+=	NetBSD.dist NetBSD.dist.tmp
147CLEANFILES+=	NetBSD.dist.machine
148CLEANFILES+=	NetBSD.dist.compat
149CLEANFILES+=	NetBSD.dist.tests.compat
150
151.include <bsd.prog.mk>
152