Makefile revision 1.84
1# $NetBSD: Makefile,v 1.84 2011/08/09 15:02:30 jmcneill 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 sort ${METALOG} | \ 128 ${TOOL_MTREE} -CSM -k all -N ${NETBSDSRCDIR}/etc \ 129 >${METALOG}.new 130 mv ${METALOG}.new ${METALOG}.sanitised 131.if defined(RCSMETALOG) 132 . ./metalog.subr; \ 133 xrcs_descr="build distribution METALOG"; \ 134 xrcs_msg="$$(date)"; \ 135 xrcs_cur=${METALOG}.sanitised; \ 136 xrcs update 137.endif 138.if ${MKUPDATE} == "no" || !exists(${METALOG}) 139clean_METALOG: .PHONY 140 rm -f ${METALOG} ${METALOG}.* 141.else # MKUPDATE 142clean_METALOG: .PHONY ${METALOG}.sanitised 143 mv ${METALOG}.sanitised ${METALOG} 144.if defined(RCSMETALOG) 145 [ -f ${METALOG}.sanitised,v ] && mv ${METALOG}.sanitised,v ${METALOG},v 146.endif 147 rm -f ${METALOG}.* 148.if defined(RCSMETALOG) 149 [ -f ${METALOG},v ] && mv ${METALOG},v ${METALOG}.sanitised,v 150.endif 151.endif # MKUPDATE 152.endif # MKUNPRIVED 153 154# 155# FILE LIST TARGETS 156# 157 158# This target has debugging value only, really. 159makeflist: .PHONY .PRECIOUS check_DESTDIR 160 ${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS} 161 162checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG 163 ${SETSCMD} ${.CURDIR}/checkflist \ 164 ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv} 165 166checkflist-x11: .PHONY check_DESTDIR 167 ${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS} 168 169checkflist-extsrc: .PHONY check_DESTDIR 170 ${SETSCMD} ./checkflist -y ${CHECKFLIST_FLAGS} 171 172.if defined(DESTDIR) && ${DESTDIR} != "" 173checkflist_if_DESTDIR: checkflist 174.else 175checkflist_if_DESTDIR: 176.endif 177 178# 179# SET BUILDING TARGETS 180# 181 182TARDIR= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 183SOURCETARDIR= ${RELEASEDIR}/source/sets 184 185# If MAKETARS_SERIAL is set to "YES" or "yes", then the tar sets will be 186# made in series, even if make's "-j" flag requests multiple parallel 187# jobs. This is useful on systems that exhibit poor performance when 188# running multiple parallel disk-intensive operations. The default is 189# MAKETARS_SERIAL=NO, which will obey the "-j" flag passed to the make 190# command. 191# 192MAKETARS_SERIAL?= NO 193.if empty(MAKETARS_SERIAL:M[Yy][Ee][Ss]) 194_MAKETARS_WAIT= # empty 195.else 196_MAKETARS_WAIT= .WAIT 197.endif 198 199maketars: .PRECIOUS .PHONY check_DESTDIR check_RELEASEDIR \ 200 sanitise_METALOG checkflist_if_DESTDIR .WAIT \ 201 maketarsetup .WAIT \ 202 ${MAKETARSETS:@.TARS.@${_MAKETARS_WAIT} do-${.TARS.}@} 203 @true 204 205maketarsetup: .EXEC 206.if defined(DESTDIR) && ${DESTDIR} != "" 207 ${_MKMSG} "execute checkflist" 208 ${MAKE} checkflist 209.endif 210 mkdir -p ${TARDIR} 211 for i in MD5 SHA512; do \ 212 rm -f ${TARDIR}/$$i ${TARDIR}/$$i.tmp; \ 213 done 214 215makesetfiles: .PHONY sanitise_METALOG 216 ${_MKMSG_CREATE} "set lists" 217 ${SETSCMD} ./maketars -S -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 218 ${METALOG.unpriv} \ 219 -N ${NETBSDSRCDIR}/etc ${MAKEFLIST_FLAGS} -t ${TARDIR} 220 221.for tar in ${MAKETARSETS} 222do-${tar}: .PHONY sanitise_METALOG 223 ${_MKMSG_CREATE} "${tar}.tgz" 224 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 225 ${METALOG.unpriv} \ 226 -N ${NETBSDSRCDIR}/etc -t ${TARDIR} ${tar} \ 227 || { rm -f ${TARDIR}/${tar}.tgz; false; } 228.endfor 229 230 231makesrctars: .PRECIOUS .PHONY check_RELEASEDIR 232 ${_MKMSG_CREATE} "source tar files" 233 mkdir -p ${SOURCETARDIR} 234 ${SETSCMD} ./makesrctars ${MAKESRCTARS_FLAGS} \ 235 ${MAKESRCTARS_X11_FLAGS} ${MAKESRCTARS_EXTSRC_FLAGS} \ 236 ${NETBSDSRCDIR} ${SOURCETARDIR} 237 238 239makesums: .PRECIOUS .PHONY check_RELEASEDIR .WAIT \ 240 ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@} 241 for i in MD5 SHA512; do \ 242 mv ${TARDIR}/$$i.tmp ${TARDIR}/$$i; \ 243 done 244 245.for tar in ${MAKETARSETS} 246do-sum-${tar}: .PHONY do-${tar} 247 ${_MKMSG_CREATE} "${tar} checksums" 248 ${MAKESUMS} -t ${TARDIR} ${tar}.tgz 249 for i in MD5 SHA512; do \ 250 ${TOOL_CAT} ${TARDIR}/$$i >> ${TARDIR}/$$i.tmp; \ 251 done 252.endfor 253.ORDER: ${MAKETARSETS:@.TARS.@do-sum-${.TARS.}@} 254 255 256installsets: .PHONY check_DESTDIR sanitise_METALOG 257.if !defined(INSTALLDIR) 258 @echo "setenv INSTALLDIR before doing that!" 259 @false 260.endif 261 ${SETSCMD} ./maketars -d ${DESTDIR:S,^$,/,} ${MAKETARS_FLAGS} \ 262 ${METALOG.unpriv} -N ${NETBSDSRCDIR}/etc \ 263 ${MAKEFLIST_FLAGS} -i ${INSTALLDIR} ${INSTALLSETS} 264 265# Should we ignore errors like extra or missing files in the flists? 266SLOPPY_FLIST?= NO 267.if !empty(SLOPPY_FLIST:M[Yy][Ee][Ss]) 268CHECKFLIST_FLAGS+= -e -m 269REGPKG.sloppy= -m 270.endif 271 272.if ${MAKEVERBOSE} == 0 273REGPKG.verbose?= -q 274.elif ${MAKEVERBOSE} == 1 275REGPKG.verbose?= 276.else # MAKEVERBOSE >= 2 277REGPKG.verbose?= -v 278.endif 279REGPKG.force?= # -f, or empty 280REGPKG.cache?= -c # -c, or empty 281REGPKG.update:= ${MKUPDATE:tl:Nno:C/..*/-u/} 282SYSPKGSETS?= all 283makesyspkgs: .PHONY check_DESTDIR check_RELEASEDIR \ 284 sanitise_METALOG checkflist_if_DESTDIR 285 mkdir -p ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs 286 ${SETSCMD} ${.CURDIR}/regpkgset \ 287 ${REGPKG.verbose} ${REGPKG.force} ${REGPKG.sloppy} \ 288 ${REGPKG.cache} ${REGPKG.update} \ 289 -d ${DESTDIR:S,^$,/,} ${METALOG.unpriv} \ 290 -N ${NETBSDSRCDIR}/etc \ 291 -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs ${SYSPKGSETS} 292 293makesyspkgsums: .PHONY check_RELEASEDIR 294 ${MAKESUMS} -t ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/syspkgs 295 296# Update the "deps" file. 297# XXX: Why is "deps" checked in to the source tree, instead of 298# just being created as necessary? 299makedeps: .PHONY 300 ${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps 301 302# 303# MAIN ENTRY POINTS 304# 305 306syspkgs: .PHONY makesyspkgs .WAIT makesyspkgsums 307 @true 308 309sets: .PHONY maketars .WAIT makesums 310 @true 311 312sourcesets: .PHONY makesrctars 313 @true 314 315.include <bsd.sys.mk> 316