xref: /freebsd/release/Makefile (revision 55af5cf12371af2fb3ad725dd84a0ba2a086964d)
197d92980SPeter Wemm# $FreeBSD$
20202c140SRodney W. Grimes#
312ad0bb1SNathan Whitehorn# Makefile for building releases and release media.
4bd668f6fSPoul-Henning Kamp#
512ad0bb1SNathan Whitehorn# User-driven targets:
68cec99b6SGlen Barber#  cdrom: Builds release CD-ROM media (disc1.iso)
75d27274aSGlen Barber#  dvdrom: Builds release DVD-ROM media (dvd1.iso)
83c334738SGlen Barber#  memstick: Builds memory stick image (memstick.img)
9a9da1707SGlen Barber#  mini-memstick: Builds minimal memory stick image (mini-memstick.img)
1012ad0bb1SNathan Whitehorn#  ftp: Sets up FTP distribution area (ftp)
1112ad0bb1SNathan Whitehorn#  release: Build all media and FTP distribution area
12299a8b95SNathan Whitehorn#  install: Copies all release media into ${DESTDIR}
13bd668f6fSPoul-Henning Kamp#
1412ad0bb1SNathan Whitehorn# Variables affecting the build process:
1512ad0bb1SNathan Whitehorn#  WORLDDIR: location of src tree -- must have built world and default kernel
1612ad0bb1SNathan Whitehorn#            (by default, the directory above this one)
1712ad0bb1SNathan Whitehorn#  PORTSDIR: location of ports tree to distribute (default: /usr/ports)
1812ad0bb1SNathan Whitehorn#  DOCDIR:   location of doc tree (default: /usr/doc)
199d22cb2eSHiroki Sato#  NOPKG:    if set, do not distribute third-party packages
2012ad0bb1SNathan Whitehorn#  NOPORTS:  if set, do not distribute ports tree
2112ad0bb1SNathan Whitehorn#  NOSRC:    if set, do not distribute source tree
2212ad0bb1SNathan Whitehorn#  NODOC:    if set, do not generate release documentation
23f7f650c7SGlen Barber#  WITH_DVD: if set, generate dvd1.iso
24*55af5cf1SGlen Barber#  WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1)
25cbc0e08aSGlen Barber#		(uncompressed images are not removed)
2612ad0bb1SNathan Whitehorn#  TARGET/TARGET_ARCH: architecture of built release
27b03ddec9SJohn Baldwin#
28ab0e9cdcSPoul-Henning Kamp
2912ad0bb1SNathan WhitehornWORLDDIR?=	${.CURDIR}/..
3012ad0bb1SNathan WhitehornPORTSDIR?=	/usr/ports
3112ad0bb1SNathan WhitehornDOCDIR?=	/usr/doc
3212ad0bb1SNathan WhitehornRELNOTES_LANG?= en_US.ISO8859-1
33fff8eb57SJohn Baldwin
34464485c8SHiroki Sato.if !defined(TARGET) || empty(TARGET)
35464485c8SHiroki SatoTARGET=		${MACHINE}
36464485c8SHiroki Sato.endif
37464485c8SHiroki Sato.if !defined(TARGET_ARCH) || empty(TARGET_ARCH)
380bd47e83SNathan Whitehorn.if ${TARGET} == ${MACHINE}
39464485c8SHiroki SatoTARGET_ARCH=	${MACHINE_ARCH}
408f1f55e9SRuslan Ermilov.else
41464485c8SHiroki SatoTARGET_ARCH=	${TARGET}
42464485c8SHiroki Sato.endif
438f1f55e9SRuslan Ermilov.endif
4412ad0bb1SNathan WhitehornIMAKE=		${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
45876acefaSHiroki SatoDISTDIR=	dist
468f1f55e9SRuslan Ermilov
47de17cbccSHiroki Sato# Define OSRELEASE by using newvars.sh
48de17cbccSHiroki Sato.if !defined(OSRELEASE) || empty(OSRELEASE)
49de17cbccSHiroki Sato.for _V in TYPE BRANCH REVISION
50de17cbccSHiroki Sato${_V}!=	eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V}
51de17cbccSHiroki Sato.endfor
52de17cbccSHiroki Sato.for _V in ${TARGET_ARCH}
53de17cbccSHiroki Sato.if !empty(TARGET:M${_V})
54de17cbccSHiroki SatoOSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}
55de17cbccSHiroki Sato.else
56de17cbccSHiroki SatoOSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH}
57de17cbccSHiroki Sato.endif
58de17cbccSHiroki Sato.endfor
59de17cbccSHiroki Sato.endif
60de17cbccSHiroki Sato
6112ad0bb1SNathan Whitehorn.if !exists(${DOCDIR})
6212ad0bb1SNathan WhitehornNODOC= true
6312ad0bb1SNathan Whitehorn.endif
6412ad0bb1SNathan Whitehorn.if !exists(${PORTSDIR})
6512ad0bb1SNathan WhitehornNOPORTS= true
66dd1a1b3dSJoerg Wunsch.endif
67dd1a1b3dSJoerg Wunsch
6812ad0bb1SNathan WhitehornEXTRA_PACKAGES=
696daa108fSRuslan Ermilov.if !defined(NOPORTS)
7012ad0bb1SNathan WhitehornEXTRA_PACKAGES+= ports.txz
716daa108fSRuslan Ermilov.endif
724731faa3SJordan K. Hubbard.if !defined(NOSRC)
7312ad0bb1SNathan WhitehornEXTRA_PACKAGES+= src.txz
742e3a1557SKen Smith.endif
75a1b193b5SJohn Baldwin.if !defined(NODOC)
7612ad0bb1SNathan WhitehornEXTRA_PACKAGES+= reldoc
77b2200964SJohn Baldwin.endif
78b2200964SJohn Baldwin
7912ad0bb1SNathan WhitehornRELEASE_TARGETS= ftp
80876acefaSHiroki SatoIMAGES=
8112ad0bb1SNathan Whitehorn.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh)
8212ad0bb1SNathan WhitehornRELEASE_TARGETS+= cdrom
838cec99b6SGlen BarberIMAGES+=	disc1.iso bootonly.iso
84d8824524SGlen Barber. if defined(WITH_DVD) && !empty(WITH_DVD)
85dc244562SGlen BarberRELEASE_TARGETS+= dvdrom
86dc244562SGlen BarberIMAGES+=	dvd1.iso
87dc244562SGlen Barber. endif
886daa108fSRuslan Ermilov.endif
8912ad0bb1SNathan Whitehorn.if exists(${.CURDIR}/${TARGET}/make-memstick.sh)
903c334738SGlen BarberRELEASE_TARGETS+= memstick.img
91a9da1707SGlen BarberRELEASE_TARGETS+= mini-memstick.img
923c334738SGlen BarberIMAGES+=	memstick.img
93a9da1707SGlen BarberIMAGES+=	mini-memstick.img
94e738d1eaSJohn Baldwin.endif
95e738d1eaSJohn Baldwin
9646b13263SHiroki SatoCLEANFILES=	packagesystem *.txz MANIFEST system ${IMAGES}
970c535991SGlen Barber.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
980c535991SGlen Barber. for I in ${IMAGES}
99*55af5cf1SGlen BarberCLEANFILES+=	${I}.xz
1000c535991SGlen Barber. endfor
1010c535991SGlen Barber.endif
10246b13263SHiroki SatoCLEANDIRS=	dist ftp release bootonly dvd
10346b13263SHiroki Satobeforeclean:
10446b13263SHiroki Sato	chflags -R noschg .
1058eb4e096SRuslan Ermilov.include <bsd.obj.mk>
10646b13263SHiroki Satoclean: beforeclean
10712ad0bb1SNathan Whitehorn
10812ad0bb1SNathan Whitehornbase.txz:
109876acefaSHiroki Sato	mkdir -p ${DISTDIR}
110876acefaSHiroki Sato	cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR}
11112ad0bb1SNathan Whitehorn# Set up mergemaster root database
112672d7ddbSSean Bruno	sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \
113876acefaSHiroki Sato	    "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base"
114e9120a25SGlen Barber	etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \
115d6d73d47SJohn Hay	    -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate"
116bfc3bab8SNathan Whitehorn# Package all components
117876acefaSHiroki Sato	cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR}
118876acefaSHiroki Sato	mv ${DISTDIR}/*.txz .
11912ad0bb1SNathan Whitehorn
12012ad0bb1SNathan Whitehornkernel.txz:
121876acefaSHiroki Sato	mkdir -p ${DISTDIR}
122876acefaSHiroki Sato	cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR}
123876acefaSHiroki Sato	mv ${DISTDIR}/kernel*.txz .
12412ad0bb1SNathan Whitehorn
12512ad0bb1SNathan Whitehornsrc.txz:
126876acefaSHiroki Sato	mkdir -p ${DISTDIR}/usr
12712ad0bb1SNathan Whitehorn	ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
1289f5907dbSGlen Barber	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn --exclude .zfs \
12923659c9dSGlen Barber	    --exclude .git --exclude @ --exclude usr/src/release/dist usr/src
13012ad0bb1SNathan Whitehorn
13112ad0bb1SNathan Whitehornports.txz:
132876acefaSHiroki Sato	mkdir -p ${DISTDIR}/usr
13312ad0bb1SNathan Whitehorn	ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
13412ad0bb1SNathan Whitehorn	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \
13523659c9dSGlen Barber	    --exclude .git --exclude .svn \
13612ad0bb1SNathan Whitehorn	    --exclude usr/ports/distfiles --exclude usr/ports/packages \
13712ad0bb1SNathan Whitehorn	    --exclude 'usr/ports/INDEX*' --exclude work usr/ports
13812ad0bb1SNathan Whitehorn
13912ad0bb1SNathan Whitehornreldoc:
14012ad0bb1SNathan Whitehorn	cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \
14112ad0bb1SNathan Whitehorn	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc
142876acefaSHiroki Sato	mkdir -p reldoc
14312ad0bb1SNathan Whitehorn.for i in hardware readme relnotes errata
14453089271STijl Coosemans	ln -f rdoc/${RELNOTES_LANG}/${i}/article.txt reldoc/${i:tu}.TXT
14553089271STijl Coosemans	ln -f rdoc/${RELNOTES_LANG}/${i}/article.html reldoc/${i:tu}.HTM
14612ad0bb1SNathan Whitehorn.endfor
147876acefaSHiroki Sato	cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc
14812ad0bb1SNathan Whitehorn
14912ad0bb1SNathan Whitehornsystem: packagesystem
15012ad0bb1SNathan Whitehorn# Install system
151876acefaSHiroki Sato	mkdir -p release
1526e352319SNathan Whitehorn	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
15358ddb0a6SGlen Barber		DESTDIR=${.OBJDIR}/release WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 \
154b1e3e965SGlen Barber		WITHOUT_PROFILE=1 WITHOUT_SENDMAIL=1 WITHOUT_ATF=1 WITHOUT_LIB32=1
15512ad0bb1SNathan Whitehorn# Copy distfiles
156876acefaSHiroki Sato	mkdir -p release/usr/freebsd-dist
157876acefaSHiroki Sato	cp *.txz MANIFEST release/usr/freebsd-dist
15812ad0bb1SNathan Whitehorn# Copy documentation, if generated
15912ad0bb1SNathan Whitehorn.if !defined(NODOC)
160876acefaSHiroki Sato	cp reldoc/* release
16112ad0bb1SNathan Whitehorn.endif
16212ad0bb1SNathan Whitehorn# Set up installation environment
163de17cbccSHiroki Sato	ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
164876acefaSHiroki Sato	echo sendmail_enable=\"NONE\" > release/etc/rc.conf
165876acefaSHiroki Sato	echo hostid_enable=\"NO\" >> release/etc/rc.conf
166876acefaSHiroki Sato	cp ${.CURDIR}/rc.local release/etc
167876acefaSHiroki Sato	touch ${.TARGET}
16812ad0bb1SNathan Whitehorn
16946c413feSNathan Whitehornbootonly: packagesystem
17046c413feSNathan Whitehorn# Install system
171876acefaSHiroki Sato	mkdir -p bootonly
17246c413feSNathan Whitehorn	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
17346c413feSNathan Whitehorn	    DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \
17456b72efeSDag-Erling Smørgrav	    WITHOUT_GAMES=1 WITHOUT_GROFF=1 \
17546c413feSNathan Whitehorn	    WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \
17601dae98eSNathan Whitehorn	    WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_PROFILE=1 \
17701dae98eSNathan Whitehorn	    WITHOUT_INSTALLIB=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 \
17801dae98eSNathan Whitehorn	    WITHOUT_KERNEL_SYMBOLS=1
17946c413feSNathan Whitehorn# Copy manifest only (no distfiles) to get checksums
180876acefaSHiroki Sato	mkdir -p bootonly/usr/freebsd-dist
181876acefaSHiroki Sato	cp MANIFEST bootonly/usr/freebsd-dist
18246c413feSNathan Whitehorn# Copy documentation, if generated
18346c413feSNathan Whitehorn.if !defined(NODOC)
184876acefaSHiroki Sato	cp reldoc/* bootonly
18546c413feSNathan Whitehorn.endif
18646c413feSNathan Whitehorn# Set up installation environment
187de17cbccSHiroki Sato	ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
188876acefaSHiroki Sato	echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf
189876acefaSHiroki Sato	echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf
190876acefaSHiroki Sato	cp ${.CURDIR}/rc.local bootonly/etc
19146c413feSNathan Whitehorn
192dc244562SGlen Barberdvd:
193dc244562SGlen Barber# Install system
194dc244562SGlen Barber	mkdir -p ${.TARGET}
195dc244562SGlen Barber	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
1962b471d3aSGlen Barber		DESTDIR=${.OBJDIR}/${.TARGET} WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1
197dc244562SGlen Barber# Copy distfiles
198dc244562SGlen Barber	mkdir -p ${.TARGET}/usr/freebsd-dist
199dc244562SGlen Barber	cp *.txz MANIFEST ${.TARGET}/usr/freebsd-dist
200dc244562SGlen Barber# Copy documentation, if generated
201dc244562SGlen Barber.if !defined(NODOC)
202dc244562SGlen Barber	cp reldoc/* ${.TARGET}
203dc244562SGlen Barber.endif
204dc244562SGlen Barber# Set up installation environment
205dc244562SGlen Barber	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
206dc244562SGlen Barber	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
207dc244562SGlen Barber	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
208dc244562SGlen Barber	cp ${.CURDIR}/rc.local ${.TARGET}/etc
209dc244562SGlen Barber	touch ${.TARGET}
210dc244562SGlen Barber
2118cec99b6SGlen Barberrelease.iso: disc1.iso
2128cec99b6SGlen Barberdisc1.iso: system
213876acefaSHiroki Sato	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} release
21412ad0bb1SNathan Whitehorn
215dc244562SGlen Barberdvd1.iso: dvd pkg-stage
216dc244562SGlen Barber	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} dvd
217dc244562SGlen Barber
21846c413feSNathan Whitehornbootonly.iso: bootonly
219876acefaSHiroki Sato	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} bootonly
22046c413feSNathan Whitehorn
221cb95a96bSGlen Barbermemstick: memstick.img
2223c334738SGlen Barbermemstick.img: system
223876acefaSHiroki Sato	sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET}
22412ad0bb1SNathan Whitehorn
225a9da1707SGlen Barbermini-memstick: mini-memstick.img
226a9da1707SGlen Barbermini-memstick.img: system
227a9da1707SGlen Barber	sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
228a9da1707SGlen Barber
22912ad0bb1SNathan Whitehornpackagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
230876acefaSHiroki Sato	sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST
231299a8b95SNathan Whitehorn	touch ${.TARGET}
23212ad0bb1SNathan Whitehorn
233dc244562SGlen Barberpkg-stage:
2346f50c4eaSGlen Barber.if !defined(NOPKG)
2356f50c4eaSGlen Barber	env REPOS_DIR=${.CURDIR}/pkg_repos/ \
2366f50c4eaSGlen Barber		sh ${.CURDIR}/scripts/pkg-stage.sh
2370d0e89b7SGlen Barber	mkdir -p ${.OBJDIR}/dvd/packages/repos/
2380d0e89b7SGlen Barber	cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \
2390d0e89b7SGlen Barber		${.OBJDIR}/dvd/packages/repos/
240dc244562SGlen Barber.endif
2410d0e89b7SGlen Barber	touch ${.TARGET}
242dc244562SGlen Barber
2438cec99b6SGlen Barbercdrom: disc1.iso bootonly.iso
244dc244562SGlen Barberdvdrom: dvd1.iso
24512ad0bb1SNathan Whitehornftp: packagesystem
246299a8b95SNathan Whitehorn	rm -rf ftp
247876acefaSHiroki Sato	mkdir -p ftp
248299a8b95SNathan Whitehorn	cp *.txz MANIFEST ftp
24912ad0bb1SNathan Whitehorn
2500bd47e83SNathan Whitehornrelease:
2510bd47e83SNathan Whitehorn	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
2520bd47e83SNathan Whitehorn	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
25312ad0bb1SNathan Whitehorn
254299a8b95SNathan Whitehorninstall:
255876acefaSHiroki Sato.if defined(DESTDIR) && !empty(DESTDIR)
256876acefaSHiroki Sato	mkdir -p ${DESTDIR}
257876acefaSHiroki Sato.endif
258de17cbccSHiroki Sato	cp -a ftp ${DESTDIR}/
259de17cbccSHiroki Sato.for I in ${IMAGES}
260de17cbccSHiroki Sato	cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
261510f3303SGlen Barber. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
262*55af5cf1SGlen Barber	xz -k ${DESTDIR}/${OSRELEASE}-${I}
263cbc0e08aSGlen Barber. endif
264de17cbccSHiroki Sato.endfor
265de17cbccSHiroki Sato	cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
266de17cbccSHiroki Sato	cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5
267