Makefile revision 1.40
11.40Smrg#	$NetBSD: Makefile,v 1.40 2019/02/17 05:29:08 mrg Exp $
21.6Smrg
31.6Smrg.include <bsd.own.mk>
41.6Smrg
51.6Smrg.if ${MKX11} != "no"
61.33SchristosEXTRA_DIST_FILES=	NetBSD.dist.Xorg
71.6Smrg.endif
81.6Smrg
91.40Smrg# Derived from MACHINE_CPU, but keeping 32/64bit for most.
101.40SmrgMTREE_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/}
111.40Smrg
121.40Smrg# The compat specific files
131.40Smrg
141.28Smartin.if defined(MKCOMPAT) && ${MKCOMPAT} != "no"
151.25Smatt.include "${NETBSDSRCDIR}/compat/archdirs.mk"
161.40Smrg.if exists(NetBSD.compat.${MTREE_MACHINE_ARCH})
171.40SmrgEXTRA_DIST_FILES+=	NetBSD.compat.${MTREE_MACHINE_ARCH}
181.13Smrg.endif
191.25SmattEXTRA_DIST_FILES+=	NetBSD.dist.compat	# autogenerated
201.29Smrg.if defined(MKCOMPATX11) && ${MKCOMPATX11} != "no" && ${MKX11} != "no"
211.26SmattEXTRA_DIST_FILES+=	NetBSD.dist.xcompat	# autogenerated
221.26Smatt.endif
231.19Smrg.endif
241.13Smrg
251.40Smrg
261.40Smrg# Platform specific files.
271.40Smrg# First we grab the mtree-specific, then either the MACHINE_ARCH or
281.40Smrg# MACHINE_CPU files, and finally the MACHINE files, as long as they
291.40Smrg# aren't the same files.
301.40Smrg
311.40Smrg.if exists(NetBSD.dist.${MTREE_MACHINE_ARCH})
321.40SmrgEXTRA_DIST_FILES+=	NetBSD.dist.${MTREE_MACHINE_ARCH}
331.40Smrg.endif
341.40Smrg
351.40Smrg.if empty(MTREE_MACHINE_ARCH:M${MACHINE_ARCH}) && \
361.40Smrg    exists(NetBSD.dist.${MACHINE_ARCH})
371.39SmrgEXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE_ARCH}
381.40Smrg.elif empty(MTREE_MACHINE_ARCH:M${MACHINE_CPU}) && \
391.40Smrg    exists(NetBSD.dist.${MACHINE_CPU})
401.40SmrgEXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE_CPU}
411.39Smrg.endif
421.39Smrg
431.40Smrg.if empty(MTREE_MACHINE_ARCH:M${MACHINE}) && \
441.40Smrg    exists(NetBSD.dist.${MACHINE})
451.37SmrgEXTRA_DIST_FILES+=	NetBSD.dist.${MACHINE}
461.37Smrg.endif
471.37Smrg
481.40Smrg
491.40Smrg# The build specific files.
501.40Smrg
511.18Snjoly.if ${MKATF} != "no"
521.33SchristosEXTRA_DIST_FILES+=	NetBSD.dist.tests
531.28Smartin.if defined(MKCOMPATTESTS) && ${MKCOMPATTESTS} != "no"
541.25SmattEXTRA_DIST_FILES+=	NetBSD.dist.tests.compat
551.25Smatt.endif
561.18Snjoly.endif
571.18Snjoly
581.30Sriz.if ${MKDTRACE} != "no"
591.33SchristosEXTRA_DIST_FILES+=	NetBSD.dist.dtrace
601.30Sriz.endif
611.30Sriz
621.11Suebayasi.if ${MKEXTSRC} != "no"
631.33SchristosEXTRA_DIST_FILES+=	NetBSD.dist.extsrc
641.11Suebayasi.endif
651.11Suebayasi
661.38Smrg.if ${MKISCSI} != "no"
671.38SmrgEXTRA_DIST_FILES+=	NetBSD.dist.iscsi
681.38Smrg.endif
691.38Smrg
701.22SapbNetBSD.dist:	NetBSD.dist.tmp
711.22Sapb	cmp -s NetBSD.dist.tmp NetBSD.dist || { \
721.14Suebayasi		echo "Updating NetBSD.dist"; \
731.22Sapb		mv NetBSD.dist.tmp NetBSD.dist; \
741.14Suebayasi	}
751.35Schristos# Rebuild every time
761.35Schristos.PHONY: NetBSD.dist.tmp
771.33SchristosNetBSD.dist.tmp: NetBSD.dist.base ${EXTRA_DIST_FILES}
781.33Schristos	${TOOL_CAT} ${.ALLSRC} > ${.TARGET}
791.1Smrg
801.33SchristosNetBSD.dist.compat: NetBSD.dist.compat.in mkcompat.awk
811.25Smatt	${MKCREATE}
821.33Schristos	${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \
831.33Schristos	    ${.ALLSRC:M*.in} > ${.TARGET}
841.25Smatt
851.33SchristosNetBSD.dist.xcompat: NetBSD.dist.xcompat.in mkcompat.awk
861.26Smatt	${MKCREATE}
871.33Schristos	${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \
881.33Schristos	    ${.ALLSRC:M*.in} > ${.TARGET}
891.26Smatt
901.33SchristosNetBSD.dist.tests.compat: NetBSD.dist.tests mkcompattree.awk 
911.25Smatt	${MKCREATE}
921.36Smatt	${TOOL_AWK} -f ${.ALLSRC:M*.awk} \
931.25Smatt	    -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} -v S="usr/tests" \
941.33Schristos		${.ALLSRC:M*.tests} > ${.TARGET}
951.25Smatt
961.5SlukemCONFIGFILES=	NetBSD.dist special
971.1SmrgFILESDIR=	/etc/mtree
981.1Smrg
991.6Smrg# distrib-dirs --
1001.6Smrg#	Populate $DESTDIR with directories needed by NetBSD
1011.6Smrg#
1021.6Smrg.if ${MKUNPRIVED} == "no"
1031.6SmrgTOOL_MTREE.unpriv=
1041.6Smrg.else
1051.6SmrgTOOL_MTREE.unpriv=	-W
1061.6Smrg.endif
1071.6Smrg
1081.17Sdyoung# postinstall(8) invokes this target to produce the right
1091.17Sdyoung# /etc/mtree/NetBSD.dist content without duplicating logic from
1101.17Sdyoung# the Makefile.
1111.17Sdyoung#
1121.33Schristosemit_dist_file:	NetBSD.dist.base ${EXTRA_DIST_FILES}
1131.33Schristos	@cat ${.ALLSRC}
1141.16Sdyoung
1151.10Sdrochnerdistrib-dirs: .PHONY check_DESTDIR NetBSD.dist
1161.6Smrg.if !defined(DISTRIBUTION_DONE)						# {
1171.6Smrg# Create DESTDIR using HOST_INSTALL_DIR, not INSTALL_DIR, because
1181.6Smrg# INSTALL_DIR would want to write to the metalog, and it can't do that
1191.6Smrg# if the metalog is inside DESTDIR but DESTDIR doesn't yet exist.
1201.6Smrg	${HOST_INSTALL_DIR} -m 755 ${DESTDIR}
1211.20Sjym# Invoke mtree to create the directories listed in NetBSD.dist;
1221.6Smrg# then invoke mtree again to register those directories in the metalog.
1231.6Smrg	${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \
1241.6Smrg	    -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv}
1251.6Smrg.if ${MKUNPRIVED} != "no"						# {
1261.6Smrg	${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \
1271.6Smrg	    -p ${DESTDIR}/ -C -k all | \
1281.6Smrg	    ${TOOL_AWK} '/ optional/ {next} // {print}' | ${METALOG.add}
1291.6Smrg.endif	# MKUNPRIVED							# }
1301.6Smrg.endif	# DISTRIBUTION_DONE						# }
1311.6Smrg
1321.22SapbCLEANFILES+=	NetBSD.dist NetBSD.dist.tmp
1331.25SmattCLEANFILES+=	NetBSD.dist.compat
1341.25SmattCLEANFILES+=	NetBSD.dist.tests.compat
1351.10Sdrochner
1361.1Smrg.include <bsd.prog.mk>
137