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