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