Makefile revision 259400
112891Swpaul# $FreeBSD: head/release/Makefile 259400 2013-12-14 22:41:17Z gjb $
212891Swpaul#
312891Swpaul# Makefile for building releases and release media.
412891Swpaul# 
512891Swpaul# User-driven targets:
612891Swpaul#  cdrom: Builds release CD-ROM media (disc1.iso)
712891Swpaul#  dvdrom: Builds release DVD-ROM media (dvd1.iso)
812891Swpaul#  memstick: Builds memory stick image (memstick.img)
912891Swpaul#  mini-memstick: Builds minimal memory stick image (mini-memstick.img)
1012891Swpaul#  ftp: Sets up FTP distribution area (ftp)
1112891Swpaul#  release: Build all media and FTP distribution area
1212891Swpaul#  install: Copies all release media into ${DESTDIR}
1312891Swpaul#
1412891Swpaul# Variables affecting the build process:
1512891Swpaul#  WORLDDIR: location of src tree -- must have built world and default kernel
1612891Swpaul#            (by default, the directory above this one) 
1712891Swpaul#  PORTSDIR: location of ports tree to distribute (default: /usr/ports)
1812891Swpaul#  DOCDIR:   location of doc tree (default: /usr/doc)
1912891Swpaul#  NOPKG:    if set, do not distribute third-party packages
2012891Swpaul#  NOPORTS:  if set, do not distribute ports tree
2112891Swpaul#  NOSRC:    if set, do not distribute source tree
2212891Swpaul#  NODOC:    if set, do not generate release documentation
2312891Swpaul#  WITH_DVD: if set, generate dvd1.iso
2412891Swpaul#  TARGET/TARGET_ARCH: architecture of built release 
2512891Swpaul#
2612891Swpaul
2712891SwpaulWORLDDIR?=	${.CURDIR}/..
2812891SwpaulPORTSDIR?=	/usr/ports
2912891SwpaulDOCDIR?=	/usr/doc
3012891SwpaulRELNOTES_LANG?= en_US.ISO8859-1
3112891Swpaul
3212891Swpaul.if !defined(TARGET) || empty(TARGET)
3312891SwpaulTARGET=		${MACHINE}
3430827Scharnier.endif
3530827Scharnier.if !defined(TARGET_ARCH) || empty(TARGET_ARCH)
3650479Speter.if ${TARGET} == ${MACHINE}
3730827ScharnierTARGET_ARCH=	${MACHINE_ARCH}
3830827Scharnier.else
3920818SwpaulTARGET_ARCH=	${TARGET}
4012891Swpaul.endif
4130827Scharnier.endif
4230827ScharnierIMAKE=		${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
4312891SwpaulDISTDIR=	dist
4412891Swpaul
4512891Swpaul# Define OSRELEASE by using newvars.sh
4612891Swpaul.if !defined(OSRELEASE) || empty(OSRELEASE)
4712891Swpaul.for _V in TYPE BRANCH REVISION
4812891Swpaul${_V}!=	eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V}
4912891Swpaul.endfor
5012997Swpaul.for _V in ${TARGET_ARCH}
5112891Swpaul.if !empty(TARGET:M${_V})
5212891SwpaulOSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}
5312891Swpaul.else
5428042SwpaulOSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH}
5528042Swpaul.endif
5628042Swpaul.endfor
5728042Swpaul.endif
5828042Swpaul
5946186Swpaul.if !exists(${DOCDIR})
6046186SwpaulNODOC= true
6146186Swpaul.endif
6246186Swpaul.if !exists(${PORTSDIR})
6346186SwpaulNOPORTS= true
6446186Swpaul.endif
6546186Swpaul
6646186SwpaulEXTRA_PACKAGES= 
6746186Swpaul.if !defined(NOPORTS)
6846186SwpaulEXTRA_PACKAGES+= ports.txz
6946186Swpaul.endif
7014262Swpaul.if !defined(NOSRC)
7114262SwpaulEXTRA_PACKAGES+= src.txz
7214262Swpaul.endif
7314262Swpaul.if !defined(NODOC)
7412891SwpaulEXTRA_PACKAGES+= reldoc
7512891Swpaul.endif
7612891Swpaul
7712891SwpaulRELEASE_TARGETS= ftp
7812891SwpaulIMAGES=
7912891Swpaul.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh)
8019161SwpaulRELEASE_TARGETS+= cdrom
8119161SwpaulIMAGES+=	disc1.iso bootonly.iso
8219161Swpaul. if defined(WITH_DVD) && !empty(WITH_DVD)
8312891SwpaulRELEASE_TARGETS+= dvdrom
8419161SwpaulIMAGES+=	dvd1.iso
8512891Swpaul. endif
8612891Swpaul.endif
8712891Swpaul.if exists(${.CURDIR}/${TARGET}/make-memstick.sh)
8812891SwpaulRELEASE_TARGETS+= memstick.img
8912891SwpaulRELEASE_TARGETS+= mini-memstick.img
9012891SwpaulIMAGES+=	memstick.img
9112891SwpaulIMAGES+=	mini-memstick.img
9212891Swpaul.endif
9312891Swpaul
9412891SwpaulCLEANFILES=	packagesystem *.txz MANIFEST system ${IMAGES}
9512891SwpaulCLEANDIRS=	dist ftp release bootonly dvd
9612891Swpaulbeforeclean:
9719161Swpaul	chflags -R noschg .
9819161Swpaul.include <bsd.obj.mk>
9919161Swpaulclean: beforeclean
10012891Swpaul
10119161Swpaulbase.txz:
10212891Swpaul	mkdir -p ${DISTDIR}
10312891Swpaul	cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR}
10412891Swpaul# Set up mergemaster root database
10512891Swpaul	sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \
10612891Swpaul	    "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base"
10712891Swpaul# Package all components
10812891Swpaul	cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR}
10912891Swpaul	mv ${DISTDIR}/*.txz .
11012891Swpaul
11112891Swpaulkernel.txz:
11212891Swpaul	mkdir -p ${DISTDIR}
11312891Swpaul	cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR}
11412891Swpaul	mv ${DISTDIR}/kernel*.txz .
11512891Swpaul
11612891Swpaulsrc.txz:
11712891Swpaul	mkdir -p ${DISTDIR}/usr
11812891Swpaul	ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
11919161Swpaul	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn --exclude .zfs \
12019161Swpaul	    --exclude CVS --exclude @ --exclude usr/src/release/dist usr/src
12119161Swpaul
12212891Swpaulports.txz:
12319161Swpaul	mkdir -p ${DISTDIR}/usr
12412891Swpaul	ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
12512891Swpaul	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \
12612891Swpaul	    --exclude CVS --exclude .svn \
12712891Swpaul	    --exclude usr/ports/distfiles --exclude usr/ports/packages \
12812891Swpaul	    --exclude 'usr/ports/INDEX*' --exclude work usr/ports
12912891Swpaul
13012891Swpaulreldoc:
13112891Swpaul	cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \
13212891Swpaul	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc
13312891Swpaul	mkdir -p reldoc
13412891Swpaul.for i in hardware readme relnotes errata
13512891Swpaul	ln -f rdoc/${RELNOTES_LANG}/${i}/article.txt reldoc/${i:tu}.TXT
13612891Swpaul	ln -f rdoc/${RELNOTES_LANG}/${i}/article.html reldoc/${i:tu}.HTM
13712891Swpaul.endfor
13812891Swpaul	cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc
13914304Swpaul
14014304Swpaulsystem: packagesystem
14119161Swpaul# Install system
14219161Swpaul	mkdir -p release
14319161Swpaul	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
14419161Swpaul		DESTDIR=${.OBJDIR}/release WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 \
14512891Swpaul		WITHOUT_PROFILE=1 WITHOUT_SENDMAIL=1 WITHOUT_ATF=1 WITHOUT_LIB32=1
14619161Swpaul# Copy distfiles
14712891Swpaul	mkdir -p release/usr/freebsd-dist
14812891Swpaul	cp *.txz MANIFEST release/usr/freebsd-dist
14912891Swpaul# Copy documentation, if generated
15012891Swpaul.if !defined(NODOC)
15112891Swpaul	cp reldoc/* release
15212891Swpaul.endif
15312891Swpaul# Set up installation environment
15412891Swpaul	ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
15512891Swpaul	echo sendmail_enable=\"NONE\" > release/etc/rc.conf
15633250Swpaul	echo hostid_enable=\"NO\" >> release/etc/rc.conf
15720818Swpaul	cp ${.CURDIR}/rc.local release/etc
15820818Swpaul	touch ${.TARGET}
15912891Swpaul
16012891Swpaulbootonly: packagesystem
16120818Swpaul# Install system
16220818Swpaul	mkdir -p bootonly
16312891Swpaul	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
16412891Swpaul	    DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \
16512891Swpaul	    WITHOUT_GAMES=1 WITHOUT_GROFF=1 \
16612891Swpaul	    WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \
16719161Swpaul	    WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_PROFILE=1 \
16819161Swpaul	    WITHOUT_INSTALLIB=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 \
16919161Swpaul	    WITHOUT_KERNEL_SYMBOLS=1
17019161Swpaul# Copy manifest only (no distfiles) to get checksums
17119161Swpaul	mkdir -p bootonly/usr/freebsd-dist
17212891Swpaul	cp MANIFEST bootonly/usr/freebsd-dist
17319161Swpaul# Copy documentation, if generated
17427589Swpaul.if !defined(NODOC)
17520818Swpaul	cp reldoc/* bootonly
17620818Swpaul.endif
17727589Swpaul# Set up installation environment
17827589Swpaul	ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
17912891Swpaul	echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf
18012891Swpaul	echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf
18130827Scharnier	cp ${.CURDIR}/rc.local bootonly/etc
18212891Swpaul
18312891Swpauldvd:
18427589Swpaul# Install system
18512891Swpaul	mkdir -p ${.TARGET}
18627589Swpaul	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
18712891Swpaul		DESTDIR=${.OBJDIR}/${.TARGET} WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1
18820818Swpaul# Copy distfiles
18920818Swpaul	mkdir -p ${.TARGET}/usr/freebsd-dist
19012891Swpaul	cp *.txz MANIFEST ${.TARGET}/usr/freebsd-dist
19112891Swpaul# Copy documentation, if generated
19212891Swpaul.if !defined(NODOC)
19312891Swpaul	cp reldoc/* ${.TARGET}
19412891Swpaul.endif
19512891Swpaul# Set up installation environment
19612891Swpaul	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
19712891Swpaul	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
19812891Swpaul	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
19912891Swpaul	cp ${.CURDIR}/rc.local ${.TARGET}/etc
20014304Swpaul	touch ${.TARGET}
20114304Swpaul
20219161Swpaulrelease.iso: disc1.iso
20319161Swpauldisc1.iso: system
20419161Swpaul	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} release
20519161Swpaul
20612891Swpauldvd1.iso: dvd pkg-stage
20719161Swpaul	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} dvd
20812891Swpaul
20912891Swpaulbootonly.iso: bootonly
21012891Swpaul	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} bootonly
21112891Swpaul
21212891Swpaulmemstick: memstick.img
21312891Swpaulmemstick.img: system
21412891Swpaul	sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET}
21512891Swpaul
21612891Swpaulmini-memstick: mini-memstick.img
21733250Swpaulmini-memstick.img: system
21812891Swpaul	sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
21912891Swpaul
22012891Swpaulpackagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
22112891Swpaul	sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST
22220818Swpaul	touch ${.TARGET}
22312891Swpaul
22412891Swpaulpkg-stage:
22512891Swpaul.if !defined(NOPKG) && exists(${.CURDIR}/${TARGET}/pkg-stage.conf)
22612891Swpaul	sh ${.CURDIR}/scripts/pkg-stage.sh ${.CURDIR}/${TARGET}/pkg-stage.conf \
22712891Swpaul		${REVISION}
22812891Swpaul.endif
22912891Swpaul
23012891Swpaulcdrom: disc1.iso bootonly.iso
23112891Swpauldvdrom: dvd1.iso
23214304Swpaulftp: packagesystem
23314304Swpaul	rm -rf ftp
23415426Swpaul	mkdir -p ftp
23519161Swpaul	cp *.txz MANIFEST ftp
23619161Swpaul
23719161Swpaulrelease:
23812891Swpaul	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
23919161Swpaul	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
24012891Swpaul
24112891Swpaulinstall:
24212891Swpaul.if defined(DESTDIR) && !empty(DESTDIR)
24312891Swpaul	mkdir -p ${DESTDIR}
24412891Swpaul.endif
24512891Swpaul	cp -a ftp ${DESTDIR}/
24612891Swpaul.for I in ${IMAGES}
24712891Swpaul	cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
24812891Swpaul.endfor
24920818Swpaul	cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
25012891Swpaul	cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5
25112891Swpaul