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