Home | History | Annotate | Line # | Download | only in sets
Makefile revision 1.88
      1 #	$NetBSD: Makefile,v 1.88 2013/02/21 14:08:50 christos 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 .if ${USE_PIGZGZIP} != "no"
     19 COMPRESS_PROGRAM=${TOOL_PIGZ:Q}
     20 .else
     21 COMPRESS_PROGRAM=gzip
     22 .endif
     23 
     24 SETSENV=	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}
     39 SETSCMD=	cd ${.CURDIR} && \
     40 		${SETSENV} \
     41 		${HOST_SH}
     42 
     43 MAKETARS_FLAGS=
     44 .if ${MKX11} != "no"
     45 MAKESRCTARS_X11_FLAGS=	-x ${X11SRCDIR}
     46 .endif
     47 .if ${MKEXTSRC} != "no"
     48 MAKESRCTARS_EXTSRC_FLAGS=	-y ${EXTSRCSRCDIR}
     49 .endif
     50 .if ${MKX11} != "no"
     51 MAKEFLIST_X11_FLAGS=	,x
     52 .endif
     53 .if ${MKEXTSRC} != "no"
     54 MAKEFLIST_EXTSRC_FLAGS=	,ext
     55 .endif
     56 MAKEFLIST_FLAGS=	-L base${MAKEFLIST_X11_FLAGS}${MAKEFLIST_EXTSRC_FLAGS}
     57 MAKESRCTARS_FLAGS= 	-N ${NETBSDSRCDIR}/etc
     58 
     59 .if ${MAKEVERBOSE} < 2
     60 MAKETARS_FLAGS+=	-q
     61 MAKESRCTARS_FLAGS+= 	-q
     62 .endif
     63 
     64 .if !defined(MAKETARSETS)
     65 MAKETARSETS!= ${SETSCMD} ./makeflist -l ${MAKEFLIST_FLAGS}
     66 .endif
     67 
     68 print_have_gcc: .PHONY
     69 	@echo ${HAVE_GCC}
     70 
     71 print_machine: .PHONY
     72 	@echo ${MACHINE}
     73 
     74 print_machine_arch: .PHONY
     75 	@echo ${MACHINE_ARCH}
     76 
     77 print_machine_cpu: .PHONY
     78 	@echo ${MACHINE_CPU}
     79 
     80 print_object_fmt: .PHONY
     81 	@echo ${OBJECT_FMT}
     82 
     83 print_toolchain_missing: .PHONY
     84 	@echo "${TOOLCHAIN_MISSING}"
     85 
     86 print_mkvars \
     87 print_set_lists_base print_set_lists_x print_set_lists_ext \
     88 list_set_lists_base list_set_lists_x list_set_lists_ext \
     89 list_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"
    118 METALOG.unpriv=
    119 sanitise_METALOG: .PHONY
    120 	@true
    121 clean_METALOG: .PHONY
    122 	@true
    123 .else	# MKUNPRIVED
    124 METALOG.unpriv= -M ${METALOG}.sanitised
    125 sanitise_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})
    147 clean_METALOG: .PHONY
    148 	rm -f ${METALOG} ${METALOG}.*
    149 .else	# MKUPDATE
    150 clean_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.
    167 makeflist: .PHONY .PRECIOUS check_DESTDIR
    168 	${SETSCMD} ./makeflist ${MAKEFLIST_FLAGS}
    169 
    170 checkflist: .PRECIOUS .PHONY check_DESTDIR sanitise_METALOG
    171 	${SETSCMD} ${.CURDIR}/checkflist \
    172 	    ${MAKEFLIST_FLAGS} ${CHECKFLIST_FLAGS} ${METALOG.unpriv}
    173 
    174 checkflist-x11: .PHONY check_DESTDIR
    175 	${SETSCMD} ./checkflist -x ${CHECKFLIST_FLAGS}
    176 
    177 checkflist-extsrc: .PHONY check_DESTDIR
    178 	${SETSCMD} ./checkflist -y ${CHECKFLIST_FLAGS}
    179 
    180 .if defined(DESTDIR) && ${DESTDIR} != ""
    181 checkflist_if_DESTDIR: checkflist
    182 .else
    183 checkflist_if_DESTDIR:
    184 .endif
    185 
    186 #
    187 # SET BUILDING TARGETS
    188 #
    189 
    190 TARDIR=		${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
    191 SOURCETARDIR=	${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 #
    200 MAKETARS_SERIAL?= NO
    201 .if empty(MAKETARS_SERIAL:M[Yy][Ee][Ss])
    202 _MAKETARS_WAIT= # empty
    203 .else
    204 _MAKETARS_WAIT= .WAIT
    205 .endif
    206 
    207 maketars: .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 
    213 maketarsetup: .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 
    223 makesetfiles: .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}
    230 do-${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 
    239 makesrctars: .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 
    247 makesums: .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}
    254 do-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 
    264 installsets: .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?
    274 SLOPPY_FLIST?= NO
    275 .if !empty(SLOPPY_FLIST:M[Yy][Ee][Ss])
    276 CHECKFLIST_FLAGS+=	-e -m
    277 REGPKG.sloppy=		-m
    278 .endif
    279 
    280 .if ${MAKEVERBOSE} == 0
    281 REGPKG.verbose?= -q
    282 .elif ${MAKEVERBOSE} == 1
    283 REGPKG.verbose?=
    284 .else	# MAKEVERBOSE >= 2
    285 REGPKG.verbose?= -v
    286 .endif
    287 REGPKG.force?=		# -f, or empty
    288 REGPKG.cache?= -c	# -c, or empty
    289 REGPKG.update:= ${MKUPDATE:tl:Nno:C/..*/-u/}
    290 SYSPKGSETS?= all
    291 makesyspkgs: .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 
    301 makesyspkgsums: .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?
    307 makedeps: .PHONY
    308 	${SETSCMD} ./syspkgdeps all >${.CURDIR}/deps
    309 
    310 #
    311 # MAIN ENTRY POINTS
    312 #
    313 
    314 syspkgs: .PHONY makesyspkgs .WAIT makesyspkgsums
    315 	@true
    316 
    317 sets: .PHONY maketars .WAIT makesums
    318 	@true
    319 
    320 sourcesets: .PHONY makesrctars
    321 	@true
    322 
    323 .include <bsd.sys.mk>
    324