1 # $NetBSD: Makefile,v 1.48 2022/08/21 07:10:03 lukem Exp $ 2 3 .include <bsd.own.mk> 4 5 EXTRA_DIST_FILES= NetBSD.dist.machine # autogenerated 6 7 .if ${MKX11} != "no" 8 EXTRA_DIST_FILES+= NetBSD.dist.Xorg 9 .endif 10 11 # Derived from MACHINE_CPU, but keeping 32/64bit for most. 12 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/} 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}) 19 EXTRA_DIST_FILES+= NetBSD.compat.${MTREE_MACHINE_ARCH} 20 .endif 21 EXTRA_DIST_FILES+= NetBSD.dist.compat # autogenerated 22 .if defined(MKCOMPATX11) && ${MKCOMPATX11} != "no" && ${MKX11} != "no" 23 EXTRA_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}) 34 EXTRA_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}) 39 EXTRA_DIST_FILES+= NetBSD.dist.${MACHINE_ARCH} 40 .elif empty(MTREE_MACHINE_ARCH:M${MACHINE_CPU}) && \ 41 exists(NetBSD.dist.${MACHINE_CPU}) 42 EXTRA_DIST_FILES+= NetBSD.dist.${MACHINE_CPU} 43 .endif 44 45 .if empty(MTREE_MACHINE_ARCH:M${MACHINE}) && \ 46 exists(NetBSD.dist.${MACHINE}) 47 EXTRA_DIST_FILES+= NetBSD.dist.${MACHINE} 48 .endif 49 50 51 # The build specific files. 52 53 .if ${MKATF} != "no" 54 EXTRA_DIST_FILES+= NetBSD.dist.tests 55 .if defined(MKCOMPATTESTS) && ${MKCOMPATTESTS} != "no" 56 EXTRA_DIST_FILES+= NetBSD.dist.tests.compat 57 .endif 58 .endif 59 60 .if ${MKDTB} != "no" 61 EXTRA_DIST_FILES+= NetBSD.dist.dtb 62 .endif 63 64 .if ${MKDTRACE} != "no" 65 EXTRA_DIST_FILES+= NetBSD.dist.dtrace 66 .endif 67 68 .if ${MKISCSI} != "no" 69 EXTRA_DIST_FILES+= NetBSD.dist.iscsi 70 .endif 71 72 NetBSD.dist: NetBSD.dist.tmp 73 cmp -s NetBSD.dist.tmp NetBSD.dist || { \ 74 echo "Updating NetBSD.dist"; \ 75 mv NetBSD.dist.tmp NetBSD.dist; \ 76 } 77 # Rebuild every time 78 .PHONY: NetBSD.dist.tmp 79 NetBSD.dist.tmp: NetBSD.dist.base ${EXTRA_DIST_FILES} 80 ${TOOL_CAT} ${.ALLSRC} > ${.TARGET} 81 82 NetBSD.dist.machine: 83 ${MKCREATE} 84 echo ./usr/include/${MACHINE} > ${.TARGET} 85 86 NetBSD.dist.compat: NetBSD.dist.compat.in mkcompat.awk 87 ${MKCREATE} 88 ${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \ 89 ${.ALLSRC:M*.in} > ${.TARGET} 90 91 NetBSD.dist.xcompat: NetBSD.dist.xcompat.in mkcompat.awk 92 ${MKCREATE} 93 ${TOOL_AWK} -f ${.ALLSRC:M*.awk} -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} \ 94 ${.ALLSRC:M*.in} > ${.TARGET} 95 96 NetBSD.dist.tests.compat: NetBSD.dist.tests mkcompattree.awk 97 ${MKCREATE} 98 ${TOOL_AWK} -f ${.ALLSRC:M*.awk} \ 99 -v COMPATDIRS=${ARCHDIR_SUBDIR:T:Q} -v S="usr/tests" \ 100 ${.ALLSRC:M*.tests} > ${.TARGET} 101 102 CONFIGFILES= NetBSD.dist special 103 FILESDIR= /etc/mtree 104 105 # distrib-dirs -- 106 # Populate $DESTDIR with directories needed by NetBSD 107 # 108 .if ${MKUNPRIVED} == "no" 109 TOOL_MTREE.unpriv= 110 .else 111 TOOL_MTREE.unpriv= -W 112 .endif 113 114 # postinstall(8) invokes this target to produce the right 115 # /etc/mtree/NetBSD.dist content without duplicating logic from 116 # the Makefile. 117 # 118 emit_dist_file: NetBSD.dist.base ${EXTRA_DIST_FILES} 119 @cat ${.ALLSRC} 120 121 distrib-dirs: .PHONY check_DESTDIR NetBSD.dist 122 .if !defined(DISTRIBUTION_DONE) # { 123 # Create DESTDIR using HOST_INSTALL_DIR, not INSTALL_DIR, because 124 # INSTALL_DIR would want to write to the metalog, and it can't do that 125 # if the metalog is inside DESTDIR but DESTDIR doesn't yet exist. 126 ${HOST_INSTALL_DIR} -m 755 ${DESTDIR} 127 # Invoke mtree to create the directories listed in NetBSD.dist; 128 # then invoke mtree again to register those directories in the metalog. 129 ${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \ 130 -p ${DESTDIR}/ -U ${TOOL_MTREE.unpriv} 131 .if ${MKUNPRIVED} != "no" # { 132 ${TOOL_MTREE} -def ${.OBJDIR}/NetBSD.dist -N ${.CURDIR}/.. \ 133 -p ${DESTDIR}/ -C -k all | \ 134 ${TOOL_AWK} '/ optional/ {next} // {print}' | ${METALOG.add} 135 .endif # MKUNPRIVED # } 136 .endif # DISTRIBUTION_DONE # } 137 138 CLEANFILES+= NetBSD.dist NetBSD.dist.tmp 139 CLEANFILES+= NetBSD.dist.machine 140 CLEANFILES+= NetBSD.dist.compat 141 CLEANFILES+= NetBSD.dist.tests.compat 142 143 .include <bsd.prog.mk> 144