summaryrefslogtreecommitdiff
path: root/etc/mtree/Makefile
blob: 6359fb2c075d79184939dbcc8daa30838b68e39b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#	$NetBSD: Makefile,v 1.48 2022/08/21 07:10:03 lukem Exp $

.include <bsd.own.mk>

EXTRA_DIST_FILES=	NetBSD.dist.machine	# autogenerated

.if ${MKX11} != "no"
EXTRA_DIST_FILES+=	NetBSD.dist.Xorg
.endif

# Derived from MACHINE_CPU, but keeping 32/64bit for most.
MTREE_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/}

# The compat specific files

.if defined(MKCOMPAT) && ${MKCOMPAT} != "no"
.include "${NETBSDSRCDIR}/compat/archdirs.mk"
.if exists(NetBSD.compat.${MTREE_MACHINE_ARCH})
EXTRA_DIST_FILES+=	NetBSD.compat.${MTREE_MACHINE_ARCH}
.endif
EXTRA_DIST_FILES+=	NetBSD.dist.compat	# autogenerated
.if defined(MKCOMPATX11) && ${MKCOMPATX11} != "no" && ${MKX11} != "no"
EXTRA_DIST_FILES+=	NetBSD.dist.xcompat	# autogenerated
.endif
.endif


# Platform specific files.
# First we grab the mtree-specific, then either the MACHINE_ARCH or
# MACHINE_CPU files, and finally the MACHINE files, as long as they
# aren't the same files.

.if exists(NetBSD.dist.${MTREE_MACHINE_ARCH})
EXTRA_DIST_FILES+=	NetBSD.dist.${MTREE_MACHINE_ARCH}
.endif

.if empty(MTREE_MACHINE_ARCH:M${MACHINE_ARCH}) && \
    exists(NetBSD.dist.${MACHINE_ARCH})
EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE_ARCH}
.elif empty(MTREE_MACHINE_ARCH:M${MACHINE_CPU}) && \
    exists(NetBSD.dist.${MACHINE_CPU})
EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE_CPU}
.endif

.if empty(MTREE_MACHINE_ARCH:M${MACHINE}) && \
    exists(NetBSD.dist.${MACHINE})
EXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE}
.endif


# The build specific files.

.if ${MKATF} != "no"
EXTRA_DIST_FILES+=	NetBSD.dist.tests
.if defined(MKCOMPATTESTS) && ${MKCOMPATTESTS} != "no"
EXTRA_DIST_FILES+=	NetBSD.dist.tests.compat
.endif
.endif

.if ${MKDTB} != "no"
EXTRA_DIST_FILES+=	NetBSD.dist.dtb
.endif

.if ${MKDTRACE} != "no"
EXTRA_DIST_FILES+=	NetBSD.dist.dtrace
.endif

.if ${MKISCSI} != "no"
EXTRA_DIST_FILES+=	NetBSD.dist.iscsi
.endif

NetBSD.dist:	NetBSD.dist.tmp
	cmp -s NetBSD.dist.tmp NetBSD.dist || { \
		echo "Updating NetBSD.dist"; \
		mv NetBSD.dist.tmp NetBSD.dist; \
	}
# Rebuild every time
.PHONY: NetBSD.dist.tmp
NetBSD.dist.tmp: NetBSD.dist.base ${EXTRA_DIST_FILES}
	${TOOL_CAT} ${.ALLSRC} > ${.TARGET}

NetBSD.dist.machine:
	${MKCREATE}
	echo ./usr/include/${MACHINE} > ${.TARGET}

NetBSD.dist.compat: NetBSD.dist.compat.in mkcompat.awk
	${MKCREATE}
	${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \
	    ${.ALLSRC:M*.in} > ${.TARGET}

NetBSD.dist.xcompat: NetBSD.dist.xcompat.in mkcompat.awk
	${MKCREATE}
	${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \
	    ${.ALLSRC:M*.in} > ${.TARGET}

NetBSD.dist.tests.compat: NetBSD.dist.tests mkcompattree.awk 
	${MKCREATE}
	${TOOL_AWK} -f ${.ALLSRC:M*.awk} \
	    -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} -v S="usr/tests" \
		${.ALLSRC:M*.tests} > ${.TARGET}

CONFIGFILES=	NetBSD.dist special
FILESDIR=	/etc/mtree

# distrib-dirs --
#	Populate $DESTDIR with directories needed by NetBSD
#
.if ${MKUNPRIVED} == "no"
TOOL_MTREE.unpriv=
.else
TOOL_MTREE.unpriv=	-W
.endif

# postinstall(8) invokes this target to produce the right
# /etc/mtree/NetBSD.dist content without duplicating logic from
# the Makefile.
#
emit_dist_file:	NetBSD.dist.base ${EXTRA_DIST_FILES}
	@cat ${.ALLSRC}

distrib-dirs: .PHONY check_DESTDIR NetBSD.dist
.if !defined(DISTRIBUTION_DONE)						# {
# Create DESTDIR using HOST_INSTALL_DIR, not INSTALL_DIR, because
# INSTALL_DIR would want to write to the metalog, and it can't do that
# if the metalog is inside DESTDIR but DESTDIR doesn't yet exist.
	${HOST_INSTALL_DIR} -m 755 ${DESTDIR}
# Invoke mtree to create the directories listed in NetBSD.dist;
# then invoke mtree again to register those directories in the metalog.
	${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \
	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
.if ${MKUNPRIVED} != "no"						# {
	${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \
	    -p ${DESTDIR}/ -C -k all | \
	    ${TOOL_AWK} '/ optional/ {next} // {print}' | ${METALOG.add}
.endif	# MKUNPRIVED							# }
.endif	# DISTRIBUTION_DONE						# }

CLEANFILES+=	NetBSD.dist NetBSD.dist.tmp
CLEANFILES+=	NetBSD.dist.machine
CLEANFILES+=	NetBSD.dist.compat
CLEANFILES+=	NetBSD.dist.tests.compat

.include <bsd.prog.mk>