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