1 1.111 mrg # $NetBSD: Makefile,v 1.111 2024/03/09 06:50:15 mrg Exp $ 2 1.81 uebayasi 3 1.81 uebayasi # Experimental RCS METALOG versioning 4 1.81 uebayasi # (Needs host's rcs(1) commands) 5 1.83 uebayasi # 6 1.83 uebayasi # TODO: 7 1.83 uebayasi # - In 'build.sh distribution', print diff to previous 8 1.81 uebayasi #RCSMETALOG=1 9 1.1 thorpej 10 1.1 thorpej # The `all' target must appear before bsd.own.mk is pulled in. 11 1.1 thorpej all: 12 1.1 thorpej @echo "Please understand what you are doing, first." 13 1.1 thorpej @false 14 1.1 thorpej 15 1.1 thorpej .include <bsd.own.mk> 16 1.15 lukem .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 17 1.1 thorpej 18 1.106 martin COMPRESS_PROGRAM=${"${USE_XZ_SETS:Uno}"!="no":?${TOOL_XZ}:${TOOL_GZIP}} 19 1.106 martin TAR_SUFF=${"${USE_XZ_SETS:Uno}"!="no":?tar.xz:tgz} 20 1.111 mrg XZ_OPT?= -9 21 1.106 martin GZIP_FLAGS= ${GZIP_N_FLAG} 22 1.110 christos UMASK= umask 022 23 1.80 mrg 24 1.78 uebayasi SETSENV= DESTDIR=${DESTDIR:Q} \ 25 1.76 uebayasi MACHINE=${MACHINE:Q} \ 26 1.76 uebayasi MACHINE_ARCH=${MACHINE_ARCH:Q} \ 27 1.62 apb AWK=${TOOL_AWK:Q} \ 28 1.49 apb CKSUM=${TOOL_CKSUM:Q} \ 29 1.49 apb DB=${TOOL_DB:Q} \ 30 1.99 joerg EGREP=${TOOL_GREP:Q}\ -E \ 31 1.49 apb HOST_SH=${HOST_SH:Q} \ 32 1.49 apb MAKE=${MAKE:Q} \ 33 1.49 apb MKTEMP=${TOOL_MKTEMP:Q} \ 34 1.49 apb MTREE=${TOOL_MTREE:Q} \ 35 1.49 apb PAX=${TOOL_PAX:Q} \ 36 1.80 mrg COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \ 37 1.94 apb GZIP=${GZIP_FLAGS:Q} \ 38 1.104 martin XZ_OPT=${XZ_OPT:Q} \ 39 1.104 martin TAR_SUFF=${TAR_SUFF:Q} \ 40 1.72 uebayasi PKG_CREATE=${TOOL_PKG_CREATE:Q} \ 41 1.63 apb SED=${TOOL_SED:Q} \ 42 1.78 uebayasi TSORT=${TSORT:Q} 43 1.78 uebayasi SETSCMD= cd ${.CURDIR} && \ 44 1.78 uebayasi ${SETSENV} \ 45 1.43 lukem ${HOST_SH} 46 1.30 tron 47 1.57 lukem MAKETARS_FLAGS= 48 1.100 christos .if ${MKREPRO_TIMESTAMP:Uno} != "no" 49 1.100 christos MAKETARS_FLAGS+= -T "${MKREPRO_TIMESTAMP}" 50 1.100 christos .endif 51 1.64 mrg .if ${MKX11} != "no" 52 1.71 uebayasi MAKESRCTARS_X11_FLAGS= -x ${X11SRCDIR} 53 1.71 uebayasi .endif 54 1.71 uebayasi .if ${MKX11} != "no" 55 1.71 uebayasi MAKEFLIST_X11_FLAGS= ,x 56 1.71 uebayasi .endif 57 1.108 lukem MAKEFLIST_FLAGS= -L base${MAKEFLIST_X11_FLAGS} 58 1.48 jmc MAKESRCTARS_FLAGS= -N ${NETBSDSRCDIR}/etc 59 1.40 lukem 60 1.65 apb .if ${MAKEVERBOSE} < 2 61 1.57 lukem MAKETARS_FLAGS+= -q 62 1.57 lukem MAKESRCTARS_FLAGS+= -q 63 1.57 lukem .endif 64 1.57 lukem 65 1.33 jmc .if !defined(MAKETARSETS) 66 1.43 lukem MAKETARSETS!= ${SETSCMD} ./makeflist -l ${MAKEFLIST_FLAGS} 67 1.33 jmc .endif 68 1.33 jmc 69 1.103 mrg print_have_xorg_server_ver: .PHONY 70 1.103 mrg @echo ${HAVE_XORG_SERVER_VER} 71 1.103 mrg 72 1.107 mrg print_have_mesa_ver: .PHONY 73 1.107 mrg @echo ${HAVE_MESA_VER} 74 1.107 mrg 75 1.52 mrg print_have_gcc: .PHONY 76 1.52 mrg @echo ${HAVE_GCC} 77 1.6 lukem 78 1.3 thorpej print_machine: .PHONY 79 1.3 thorpej @echo ${MACHINE} 80 1.3 thorpej 81 1.3 thorpej print_machine_arch: .PHONY 82 1.3 thorpej @echo ${MACHINE_ARCH} 83 1.3 thorpej 84 1.3 thorpej print_machine_cpu: .PHONY 85 1.3 thorpej @echo ${MACHINE_CPU} 86 1.3 thorpej 87 1.3 thorpej print_object_fmt: .PHONY 88 1.3 thorpej @echo ${OBJECT_FMT} 89 1.3 thorpej 90 1.17 lukem print_toolchain_missing: .PHONY 91 1.17 lukem @echo "${TOOLCHAIN_MISSING}" 92 1.29 mrg 93 1.78 uebayasi print_mkvars \ 94 1.78 uebayasi print_set_lists_base print_set_lists_x print_set_lists_ext \ 95 1.78 uebayasi list_set_lists_base list_set_lists_x list_set_lists_ext \ 96 1.78 uebayasi list_set_files_base list_set_files_x list_set_files_ext \ 97 1.78 uebayasi : .PHONY 98 1.102 christos @${SETSENV}; rundir="${.CURDIR}"; . ./sets.subr; ${.TARGET} 99 1.74 uebayasi 100 1.1 thorpej # 101 1.67 apb # METALOG MANIPULATION TARGETS 102 1.67 apb # 103 1.67 apb # METALOG is the name of a metadata log file, and is set in <bsd.own.mk> 104 1.67 apb # if MKUNPRIVED is not "no". 105 1.67 apb # 106 1.67 apb # METALOG.unpriv is a command line option passed to various scripts; 107 1.67 apb # it is either blank or "-M ${METALOG}.sanitised", depending on the 108 1.67 apb # MKUNPRIVED flag. 109 1.67 apb # 110 1.67 apb # The sanitise_METALOG target creates METALOG.sanitised from METALOG, 111 1.92 apb # without modifying METALOG itself. This is used near the end of 112 1.92 apb # a build, after build products have been installed in DESTDIR 113 1.92 apb # and corresponding lines have been added to METALOG, but before 114 1.92 apb # METALOG.sanitised is used in the creation of sets in RELEASEDIR. 115 1.92 apb # For update builds, METALOG.sanitised has duplicates merged (keeping 116 1.92 apb # only the last of multiple entries for the same item), but for clean 117 1.92 apb # builds it's an error if a file or directory name appears twice. 118 1.92 apb # METALOG.sanitised is always sorted and has timestamps removed. 119 1.67 apb # 120 1.92 apb # The clean_METALOG target either deletes METALOG, or replaces METALOG with 121 1.67 apb # a sanitised version of itself, depending on the MKUPDATE flag, and 122 1.67 apb # deletes old METALOG.* files. This is intended to be used at the start 123 1.67 apb # of a build, to ensure that repeated MKUPDATE builds do not cause 124 1.67 apb # unbounded growth of METALOG. 125 1.1 thorpej # 126 1.1 thorpej 127 1.92 apb METALOG_REMOVE_DUPLICATES= \ 128 1.92 apb ${TOOL_AWK} '{ a[$$1] = $$0; } END { for (f in a) print a[f]; }' 129 1.92 apb 130 1.27 lukem .if ${MKUNPRIVED} == "no" 131 1.27 lukem METALOG.unpriv= 132 1.49 apb sanitise_METALOG: .PHONY 133 1.49 apb @true 134 1.67 apb clean_METALOG: .PHONY 135 1.67 apb @true 136 1.67 apb .else # MKUNPRIVED 137 1.67 apb METALOG.unpriv= -M ${METALOG}.sanitised 138 1.67 apb sanitise_METALOG: .PHONY ${METALOG}.sanitised 139 1.67 apb ${METALOG}.sanitised: ${METALOG} 140 1.109 lukem ${_MKMSG_CREATE} METALOG.sanitised 141 1.92 apb <${METALOG} \ 142 1.92 apb ${${MKUPDATE} != "no" :? ${METALOG_REMOVE_DUPLICATES} | :} \ 143 1.92 apb sort | ${TOOL_MTREE} -CSM -k all -R time -N ${NETBSDSRCDIR}/etc \ 144 1.86 christos >${METALOG}.new 145 1.67 apb mv ${METALOG}.new ${METALOG}.sanitised 146 1.81 uebayasi .if defined(RCSMETALOG) 147 1.81 uebayasi . ./metalog.subr; \ 148 1.81 uebayasi xrcs_descr="build distribution METALOG"; \ 149 1.81 uebayasi xrcs_msg="$$(date)"; \ 150 1.81 uebayasi xrcs_cur=${METALOG}.sanitised; \ 151 1.81 uebayasi xrcs update 152 1.81 uebayasi .endif 153 1.67 apb .if ${MKUPDATE} == "no" || !exists(${METALOG}) 154 1.67 apb clean_METALOG: .PHONY 155 1.67 apb rm -f ${METALOG} ${METALOG}.* 156 1.67 apb .else # MKUPDATE 157 1.67 apb clean_METALOG: .PHONY ${METALOG}.sanitised 158 1.67 apb mv ${METALOG}.sanitised ${METALOG} 159 1.81 uebayasi .if defined(RCSMETALOG) 160 1.82 uebayasi [ -f ${METALOG}.sanitised,v ] && mv ${METALOG}.sanitised,v ${METALOG},v 161 1.81 uebayasi .endif 162 1.67 apb rm -f ${METALOG}.* 163 1.81 uebayasi .if defined(RCSMETALOG) 164 1.82 uebayasi [ -f ${METALOG},v ] && mv ${METALOG},v ${METALOG}.sanitised,v 165 1.81 uebayasi .endif 166 1.67 apb .endif # MKUPDATE 167 1.67 apb .endif # MKUNPRIVED 168 1.67 apb 169 1.67 apb # 170 1.67 apb # FILE LIST TARGETS 171 1.67 apb # 172 1.67 apb 173 1.67 apb # This target has debugging value only, really. 174 1.67 apb makeflist: .PHONY .PRECIOUS check_DESTDIR 175 1.109 lukem ${_MKMSG_EXECUTE} "makeflist" 176 1.67 apb ${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS} 177 1.67 apb 178 1.67 apb checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG 179 1.109 lukem ${_MKMSG_EXECUTE} "checkflist" 180 1.67 apb ${SETSCMD} ${.CURDIR}/checkflist \ 181 1.67 apb ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv} 182 1.67 apb 183 1.67 apb checkflist-x11: .PHONY check_DESTDIR 184 1.109 lukem ${_MKMSG_EXECUTE} "checkflist -x" 185 1.67 apb ${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS} 186 1.49 apb 187 1.49 apb .if defined(DESTDIR) && ${DESTDIR} != "" 188 1.49 apb checkflist_if_DESTDIR: checkflist 189 1.49 apb .else 190 1.49 apb checkflist_if_DESTDIR: 191 1.49 apb .endif 192 1.43 lukem 193 1.67 apb # 194 1.67 apb # SET BUILDING TARGETS 195 1.67 apb # 196 1.43 lukem 197 1.67 apb TARDIR= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 198 1.67 apb SOURCETARDIR= ${RELEASEDIR}/source/sets 199 1.1 thorpej 200 1.58 apb # If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be 201 1.58 apb # made in series, even if make's "-j" flag requests multiple parallel 202 1.58 apb # jobs. This is useful on systems that exhibit poor performance when 203 1.58 apb # running multiple parallel disk-intensive operations. The default is 204 1.58 apb # MAKETARS_SERIAL=NO, which will obey the "-j" flag passed to the make 205 1.58 apb # command. 206 1.58 apb # 207 1.58 apb MAKETARS_SERIAL?= NO 208 1.58 apb .if empty(MAKETARS_SERIAL:M[Yy][Ee][Ss]) 209 1.58 apb _MAKETARS_WAIT= # empty 210 1.58 apb .else 211 1.58 apb _MAKETARS_WAIT= .WAIT 212 1.58 apb .endif 213 1.58 apb 214 1.49 apb maketars: .PRECIOUS .PHONY check_DESTDIR check_RELEASEDIR \ 215 1.49 apb sanitise_METALOG checkflist_if_DESTDIR .WAIT \ 216 1.58 apb maketarsetup .WAIT \ 217 1.58 apb ${MAKETARSETS:@.TARS.@${_MAKETARS_WAIT} do-${.TARS.}@} 218 1.33 jmc @true 219 1.33 jmc 220 1.43 lukem maketarsetup: .EXEC 221 1.23 veego .if defined(DESTDIR) && ${DESTDIR} != "" 222 1.109 lukem ${_MKMSG_EXECUTE} "checkflist" 223 1.96 uebayasi cd ${.CURDIR}; ${MAKE} checkflist 224 1.16 lukem .endif 225 1.43 lukem mkdir -p ${TARDIR} 226 1.70 snj for i in MD5 SHA512; do \ 227 1.43 lukem rm -f ${TARDIR}/$$i ${TARDIR}/$$i.tmp; \ 228 1.43 lukem done 229 1.43 lukem 230 1.67 apb makesetfiles: .PHONY sanitise_METALOG 231 1.43 lukem ${_MKMSG_CREATE} "set lists" 232 1.67 apb ${SETSCMD} ./maketars -S -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 233 1.67 apb ${METALOG.unpriv} \ 234 1.43 lukem -N ${NETBSDSRCDIR}/etc ${MAKEFLIST_FLAGS} -t ${TARDIR} 235 1.43 lukem 236 1.33 jmc .for tar in ${MAKETARSETS} 237 1.55 apb do-${tar}: .PHONY sanitise_METALOG 238 1.104 martin ${_MKMSG_CREATE} "${tar}.${TAR_SUFF}" 239 1.57 lukem ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 240 1.67 apb ${METALOG.unpriv} \ 241 1.43 lukem -N ${NETBSDSRCDIR}/etc -t ${TARDIR} ${tar} \ 242 1.104 martin || { rm -f ${TARDIR}/${tar}.${TAR_SUFF}; false; } 243 1.33 jmc .endfor 244 1.1 thorpej 245 1.43 lukem 246 1.41 lukem makesrctars: .PRECIOUS .PHONY check_RELEASEDIR 247 1.57 lukem ${_MKMSG_CREATE} "source tar files" 248 1.43 lukem mkdir -p ${SOURCETARDIR} 249 1.45 lukem ${SETSCMD} ./makesrctars ${MAKESRCTARS_FLAGS} \ 250 1.108 lukem ${MAKESRCTARS_X11_FLAGS} \ 251 1.45 lukem ${NETBSDSRCDIR} ${SOURCETARDIR} 252 1.43 lukem 253 1.25 lukem 254 1.41 lukem makesums: .PRECIOUS .PHONY check_RELEASEDIR .WAIT \ 255 1.41 lukem ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@} 256 1.110 christos ${UMASK} && for i in MD5 SHA512; do \ 257 1.43 lukem mv ${TARDIR}/$$i.tmp ${TARDIR}/$$i; \ 258 1.43 lukem done 259 1.33 jmc 260 1.33 jmc .for tar in ${MAKETARSETS} 261 1.39 jmc do-sum-${tar}: .PHONY do-${tar} 262 1.57 lukem ${_MKMSG_CREATE} "${tar} checksums" 263 1.104 martin ${MAKESUMS} -t ${TARDIR} ${tar}.${TAR_SUFF} 264 1.110 christos ${UMASK} && for i in MD5 SHA512; do \ 265 1.43 lukem ${TOOL_CAT} ${TARDIR}/$$i >> ${TARDIR}/$$i.tmp; \ 266 1.35 jmc done 267 1.33 jmc .endfor 268 1.37 jmc .ORDER: ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@} 269 1.18 lukem 270 1.43 lukem 271 1.49 apb installsets: .PHONY check_DESTDIR sanitise_METALOG 272 1.18 lukem .if !defined(INSTALLDIR) 273 1.18 lukem @echo "setenv INSTALLDIR before doing that!" 274 1.18 lukem @false 275 1.18 lukem .endif 276 1.109 lukem ${_MKMSG_EXECUTE} "maketars for installsets" 277 1.57 lukem ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 278 1.67 apb ${METALOG.unpriv} -N ${NETBSDSRCDIR}/etc \ 279 1.49 apb ${MAKEFLIST_FLAGS} -i ${INSTALLDIR} ${INSTALLSETS} 280 1.49 apb 281 1.49 apb # Should we ignore errors like extra or missing files in the flists? 282 1.49 apb SLOPPY_FLIST?= NO 283 1.49 apb .if !empty(SLOPPY_FLIST:M[Yy][Ee][Ss]) 284 1.49 apb CHECKFLIST_FLAGS+= -e -m 285 1.49 apb REGPKG.sloppy= -m 286 1.49 apb .endif 287 1.1 thorpej 288 1.49 apb .if ${MAKEVERBOSE} == 0 289 1.49 apb REGPKG.verbose?= -q 290 1.49 apb .elif ${MAKEVERBOSE} == 1 291 1.49 apb REGPKG.verbose?= 292 1.65 apb .else # MAKEVERBOSE >= 2 293 1.49 apb REGPKG.verbose?= -v 294 1.49 apb .endif 295 1.49 apb REGPKG.force?= # -f, or empty 296 1.49 apb REGPKG.cache?= -c # -c, or empty 297 1.49 apb REGPKG.update:= ${MKUPDATE:tl:Nno:C/..*/-u/} 298 1.49 apb SYSPKGSETS?= all 299 1.49 apb makesyspkgs: .PHONY check_DESTDIR check_RELEASEDIR \ 300 1.49 apb sanitise_METALOG checkflist_if_DESTDIR 301 1.109 lukem ${_MKMSG_EXECUTE} "regpkgset for makesyspkgs" 302 1.59 matt mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs 303 1.49 apb ${SETSCMD} ${.CURDIR}/regpkgset \ 304 1.49 apb ${REGPKG.verbose} ${REGPKG.force} ${REGPKG.sloppy} \ 305 1.49 apb ${REGPKG.cache} ${REGPKG.update} \ 306 1.67 apb -d ${DESTDIR:S,^$,/,} ${METALOG.unpriv} \ 307 1.49 apb -N ${NETBSDSRCDIR}/etc \ 308 1.59 matt -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs ${SYSPKGSETS} 309 1.49 apb 310 1.49 apb makesyspkgsums: .PHONY check_RELEASEDIR 311 1.109 lukem ${_MKMSG_CREATE} "syspkgs checksums" 312 1.59 matt ${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs 313 1.43 lukem 314 1.50 apb # Update the "deps" file. 315 1.50 apb # XXX: Why is "deps" checked in to the source tree, instead of 316 1.50 apb # just being created as necessary? 317 1.50 apb makedeps: .PHONY 318 1.109 lukem ${_MKMSG_CREATE} "syspkgs checksums" 319 1.50 apb ${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps 320 1.50 apb 321 1.98 apb # Sort the lists files. 322 1.98 apb # 323 1.98 apb # The tricky stuff with awk and sort -k options is to ensure that the 324 1.98 apb # heading remains undisturbed, and on non-heading lines anything before 325 1.98 apb # the first "." is ignored, so that "./dir/file" and "#./dir/file" are 326 1.98 apb # sorted together. 327 1.98 apb # 328 1.89 apb sortlists: .PHONY 329 1.110 christos ${UMASK} && \ 330 1.95 apb find ${.CURDIR}/lists \! \( -name CVS -prune \) \! -name .#\* \ 331 1.95 apb -type f -print \ 332 1.89 apb | while read f ; do \ 333 1.89 apb ${_MKSHMSG} "sorting $${f#${.CURDIR}/}" ; \ 334 1.98 apb awk 'BEGIN { inheader = 1 } \ 335 1.98 apb /^#*\.\// { inheader = 0 } \ 336 1.98 apb // { tag = (inheader ? NR : 999999); \ 337 1.98 apb print tag "." $$0 }' \ 338 1.98 apb <"$$f" \ 339 1.98 apb | sort -t . -k 1n,2 -k 3 \ 340 1.98 apb | cut -d . -f 2- \ 341 1.98 apb | cat -s >"$$f".tmp; \ 342 1.90 apb if cmp "$$f" "$$f".tmp >/dev/null; then \ 343 1.90 apb : "$$f is unchanged" ; \ 344 1.90 apb rm "$$f".tmp ; \ 345 1.90 apb else \ 346 1.90 apb mv "$$f".tmp "$$f" ; \ 347 1.90 apb fi ; \ 348 1.89 apb done 349 1.89 apb 350 1.1 thorpej # 351 1.1 thorpej # MAIN ENTRY POINTS 352 1.1 thorpej # 353 1.1 thorpej 354 1.49 apb syspkgs: .PHONY makesyspkgs .WAIT makesyspkgsums 355 1.49 apb @true 356 1.49 apb 357 1.41 lukem sets: .PHONY maketars .WAIT makesums 358 1.25 lukem @true 359 1.25 lukem 360 1.41 lukem sourcesets: .PHONY makesrctars 361 1.1 thorpej @true 362 1.8 lukem 363 1.91 christos .include <bsd.files.mk> 364