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