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