1# $NetBSD: Makefile,v 1.90 2013/10/30 15:17:01 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. METALOG.sanitised is sorted, and 105# has duplicates merged. This is used near the end of a build, after 106# build products have been installed in DESTDIR and corresponding lines 107# have been added to METALOG, but before METALOG.sanitised is used in 108# the creation of sets in RELEASEDIR. 109# 110# The clean_METALOG either deletes METALOG or replaces METALOG with 111# a sanitised version of itself, depending on the MKUPDATE flag, and 112# deletes old METALOG.* files. This is intended to be used at the start 113# of a build, to ensure that repeated MKUPDATE builds do not cause 114# unbounded growth of METALOG. 115# 116 117.if ${MKUNPRIVED} == "no" 118METALOG.unpriv= 119sanitise_METALOG: .PHONY 120 @true 121clean_METALOG: .PHONY 122 @true 123.else # MKUNPRIVED 124METALOG.unpriv= -M ${METALOG}.sanitised 125sanitise_METALOG: .PHONY ${METALOG}.sanitised 126${METALOG}.sanitised: ${METALOG} 127# We keep only the last entry for update builds, but for clean builds we 128# want to make sure we install files only once. 129.if ${MKUPDATE} != "no" 130 ${TOOL_AWK} \ 131 '{ a[$$1] = $$0; } END { for (f in a) print a[f]; }' ${METALOG} | \ 132 sort | ${TOOL_MTREE} -CSM -k all -N ${NETBSDSRCDIR}/etc \ 133 >${METALOG}.new 134.else 135 sort ${METALOG} | ${TOOL_MTREE} -CSM -k all -N ${NETBSDSRCDIR}/etc \ 136 >${METALOG}.new 137.endif 138 mv ${METALOG}.new ${METALOG}.sanitised 139.if defined(RCSMETALOG) 140 . ./metalog.subr; \ 141 xrcs_descr="build distribution METALOG"; \ 142 xrcs_msg="$$(date)"; \ 143 xrcs_cur=${METALOG}.sanitised; \ 144 xrcs update 145.endif 146.if ${MKUPDATE} == "no" || !exists(${METALOG}) 147clean_METALOG: .PHONY 148 rm -f ${METALOG} ${METALOG}.* 149.else # MKUPDATE 150clean_METALOG: .PHONY ${METALOG}.sanitised 151 mv ${METALOG}.sanitised ${METALOG} 152.if defined(RCSMETALOG) 153 [ -f ${METALOG}.sanitised,v ] && mv ${METALOG}.sanitised,v ${METALOG},v 154.endif 155 rm -f ${METALOG}.* 156.if defined(RCSMETALOG) 157 [ -f ${METALOG},v ] && mv ${METALOG},v ${METALOG}.sanitised,v 158.endif 159.endif # MKUPDATE 160.endif # MKUNPRIVED 161 162# 163# FILE LIST TARGETS 164# 165 166# This target has debugging value only, really. 167makeflist: .PHONY .PRECIOUS check_DESTDIR 168 ${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS} 169 170checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG 171 ${SETSCMD} ${.CURDIR}/checkflist \ 172 ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv} 173 174checkflist-x11: .PHONY check_DESTDIR 175 ${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS} 176 177checkflist-extsrc: .PHONY check_DESTDIR 178 ${SETSCMD} ./checkflist -y ${CHECKFLIST_FLAGS} 179 180.if defined(DESTDIR) && ${DESTDIR} != "" 181checkflist_if_DESTDIR: checkflist 182.else 183checkflist_if_DESTDIR: 184.endif 185 186# 187# SET BUILDING TARGETS 188# 189 190TARDIR= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 191SOURCETARDIR= ${RELEASEDIR}/source/sets 192 193# If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be 194# made in series, even if make's "-j" flag requests multiple parallel 195# jobs. This is useful on systems that exhibit poor performance when 196# running multiple parallel disk-intensive operations. The default is 197# MAKETARS_SERIAL=NO, which will obey the "-j" flag passed to the make 198# command. 199# 200MAKETARS_SERIAL?= NO 201.if empty(MAKETARS_SERIAL:M[Yy][Ee][Ss]) 202_MAKETARS_WAIT= # empty 203.else 204_MAKETARS_WAIT= .WAIT 205.endif 206 207maketars: .PRECIOUS .PHONY check_DESTDIR check_RELEASEDIR \ 208 sanitise_METALOG checkflist_if_DESTDIR .WAIT \ 209 maketarsetup .WAIT \ 210 ${MAKETARSETS:@.TARS.@${_MAKETARS_WAIT} do-${.TARS.}@} 211 @true 212 213maketarsetup: .EXEC 214.if defined(DESTDIR) && ${DESTDIR} != "" 215 ${_MKMSG} "execute checkflist" 216 ${MAKE} checkflist 217.endif 218 mkdir -p ${TARDIR} 219 for i in MD5 SHA512; do \ 220 rm -f ${TARDIR}/$$i ${TARDIR}/$$i.tmp; \ 221 done 222 223makesetfiles: .PHONY sanitise_METALOG 224 ${_MKMSG_CREATE} "set lists" 225 ${SETSCMD} ./maketars -S -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 226 ${METALOG.unpriv} \ 227 -N ${NETBSDSRCDIR}/etc ${MAKEFLIST_FLAGS} -t ${TARDIR} 228 229.for tar in ${MAKETARSETS} 230do-${tar}: .PHONY sanitise_METALOG 231 ${_MKMSG_CREATE} "${tar}.tgz" 232 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 233 ${METALOG.unpriv} \ 234 -N ${NETBSDSRCDIR}/etc -t ${TARDIR} ${tar} \ 235 || { rm -f ${TARDIR}/${tar}.tgz; false; } 236.endfor 237 238 239makesrctars: .PRECIOUS .PHONY check_RELEASEDIR 240 ${_MKMSG_CREATE} "source tar files" 241 mkdir -p ${SOURCETARDIR} 242 ${SETSCMD} ./makesrctars ${MAKESRCTARS_FLAGS} \ 243 ${MAKESRCTARS_X11_FLAGS} ${MAKESRCTARS_EXTSRC_FLAGS} \ 244 ${NETBSDSRCDIR} ${SOURCETARDIR} 245 246 247makesums: .PRECIOUS .PHONY check_RELEASEDIR .WAIT \ 248 ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@} 249 for i in MD5 SHA512; do \ 250 mv ${TARDIR}/$$i.tmp ${TARDIR}/$$i; \ 251 done 252 253.for tar in ${MAKETARSETS} 254do-sum-${tar}: .PHONY do-${tar} 255 ${_MKMSG_CREATE} "${tar} checksums" 256 ${MAKESUMS} -t ${TARDIR} ${tar}.tgz 257 for i in MD5 SHA512; do \ 258 ${TOOL_CAT} ${TARDIR}/$$i >> ${TARDIR}/$$i.tmp; \ 259 done 260.endfor 261.ORDER: ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@} 262 263 264installsets: .PHONY check_DESTDIR sanitise_METALOG 265.if !defined(INSTALLDIR) 266 @echo "setenv INSTALLDIR before doing that!" 267 @false 268.endif 269 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 270 ${METALOG.unpriv} -N ${NETBSDSRCDIR}/etc \ 271 ${MAKEFLIST_FLAGS} -i ${INSTALLDIR} ${INSTALLSETS} 272 273# Should we ignore errors like extra or missing files in the flists? 274SLOPPY_FLIST?= NO 275.if !empty(SLOPPY_FLIST:M[Yy][Ee][Ss]) 276CHECKFLIST_FLAGS+= -e -m 277REGPKG.sloppy= -m 278.endif 279 280.if ${MAKEVERBOSE} == 0 281REGPKG.verbose?= -q 282.elif ${MAKEVERBOSE} == 1 283REGPKG.verbose?= 284.else # MAKEVERBOSE >= 2 285REGPKG.verbose?= -v 286.endif 287REGPKG.force?= # -f, or empty 288REGPKG.cache?= -c # -c, or empty 289REGPKG.update:= ${MKUPDATE:tl:Nno:C/..*/-u/} 290SYSPKGSETS?= all 291makesyspkgs: .PHONY check_DESTDIR check_RELEASEDIR \ 292 sanitise_METALOG checkflist_if_DESTDIR 293 mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs 294 ${SETSCMD} ${.CURDIR}/regpkgset \ 295 ${REGPKG.verbose} ${REGPKG.force} ${REGPKG.sloppy} \ 296 ${REGPKG.cache} ${REGPKG.update} \ 297 -d ${DESTDIR:S,^$,/,} ${METALOG.unpriv} \ 298 -N ${NETBSDSRCDIR}/etc \ 299 -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs ${SYSPKGSETS} 300 301makesyspkgsums: .PHONY check_RELEASEDIR 302 ${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs 303 304# Update the "deps" file. 305# XXX: Why is "deps" checked in to the source tree, instead of 306# just being created as necessary? 307makedeps: .PHONY 308 ${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps 309 310# Sort the lists files 311sortlists: .PHONY 312 find ${.CURDIR}/lists \! \( -name CVS -prune \) -type f -print \ 313 | while read f ; do \ 314 ${_MKSHMSG} "sorting $${f#${.CURDIR}/}" ; \ 315 { grep '^#' "$$f" ; \ 316 grep -v '^#' "$$f" | sort ; \ 317 } >"$$f".tmp; \ 318 if cmp "$$f" "$$f".tmp >/dev/null; then \ 319 : "$$f is unchanged" ; \ 320 rm "$$f".tmp ; \ 321 else \ 322 mv "$$f".tmp "$$f" ; \ 323 fi ; \ 324 done 325 326# 327# MAIN ENTRY POINTS 328# 329 330syspkgs: .PHONY makesyspkgs .WAIT makesyspkgsums 331 @true 332 333sets: .PHONY maketars .WAIT makesums 334 @true 335 336sourcesets: .PHONY makesrctars 337 @true 338 339.include <bsd.sys.mk> 340