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