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 2455af5cf1SGlen 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 333b485e46SGlen BarberXZCMD?= /usr/bin/xz 34fff8eb57SJohn Baldwin 35464485c8SHiroki Sato.if !defined(TARGET) || empty(TARGET) 36464485c8SHiroki SatoTARGET= ${MACHINE} 37464485c8SHiroki Sato.endif 38464485c8SHiroki Sato.if !defined(TARGET_ARCH) || empty(TARGET_ARCH) 390bd47e83SNathan Whitehorn.if ${TARGET} == ${MACHINE} 40464485c8SHiroki SatoTARGET_ARCH= ${MACHINE_ARCH} 418f1f55e9SRuslan Ermilov.else 42464485c8SHiroki SatoTARGET_ARCH= ${TARGET} 43464485c8SHiroki Sato.endif 448f1f55e9SRuslan Ermilov.endif 4512ad0bb1SNathan WhitehornIMAKE= ${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} 46876acefaSHiroki SatoDISTDIR= dist 478f1f55e9SRuslan Ermilov 48de17cbccSHiroki Sato# Define OSRELEASE by using newvars.sh 49de17cbccSHiroki Sato.if !defined(OSRELEASE) || empty(OSRELEASE) 50de17cbccSHiroki Sato.for _V in TYPE BRANCH REVISION 51de17cbccSHiroki Sato${_V}!= eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V} 52de17cbccSHiroki Sato.endfor 53de17cbccSHiroki Sato.for _V in ${TARGET_ARCH} 54de17cbccSHiroki Sato.if !empty(TARGET:M${_V}) 55de17cbccSHiroki SatoOSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET} 56de17cbccSHiroki Sato.else 57de17cbccSHiroki SatoOSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH} 58de17cbccSHiroki Sato.endif 59de17cbccSHiroki Sato.endfor 60de17cbccSHiroki Sato.endif 61de17cbccSHiroki Sato 6212ad0bb1SNathan Whitehorn.if !exists(${DOCDIR}) 6312ad0bb1SNathan WhitehornNODOC= true 6412ad0bb1SNathan Whitehorn.endif 6512ad0bb1SNathan Whitehorn.if !exists(${PORTSDIR}) 6612ad0bb1SNathan WhitehornNOPORTS= true 67dd1a1b3dSJoerg Wunsch.endif 68dd1a1b3dSJoerg Wunsch 6912ad0bb1SNathan WhitehornEXTRA_PACKAGES= 706daa108fSRuslan Ermilov.if !defined(NOPORTS) 7112ad0bb1SNathan WhitehornEXTRA_PACKAGES+= ports.txz 726daa108fSRuslan Ermilov.endif 734731faa3SJordan K. Hubbard.if !defined(NOSRC) 7412ad0bb1SNathan WhitehornEXTRA_PACKAGES+= src.txz 752e3a1557SKen Smith.endif 76a1b193b5SJohn Baldwin.if !defined(NODOC) 7712ad0bb1SNathan WhitehornEXTRA_PACKAGES+= reldoc 78b2200964SJohn Baldwin.endif 79b2200964SJohn Baldwin 8012ad0bb1SNathan WhitehornRELEASE_TARGETS= ftp 81876acefaSHiroki SatoIMAGES= 8212ad0bb1SNathan Whitehorn.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh) 8312ad0bb1SNathan WhitehornRELEASE_TARGETS+= cdrom 848cec99b6SGlen BarberIMAGES+= disc1.iso bootonly.iso 85d8824524SGlen Barber. if defined(WITH_DVD) && !empty(WITH_DVD) 86dc244562SGlen BarberRELEASE_TARGETS+= dvdrom 87dc244562SGlen BarberIMAGES+= dvd1.iso 88dc244562SGlen Barber. endif 896daa108fSRuslan Ermilov.endif 9012ad0bb1SNathan Whitehorn.if exists(${.CURDIR}/${TARGET}/make-memstick.sh) 913c334738SGlen BarberRELEASE_TARGETS+= memstick.img 92a9da1707SGlen BarberRELEASE_TARGETS+= mini-memstick.img 933c334738SGlen BarberIMAGES+= memstick.img 94a9da1707SGlen BarberIMAGES+= mini-memstick.img 95e738d1eaSJohn Baldwin.endif 96e738d1eaSJohn Baldwin 9746b13263SHiroki SatoCLEANFILES= packagesystem *.txz MANIFEST system ${IMAGES} 980c535991SGlen Barber.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) 990c535991SGlen Barber. for I in ${IMAGES} 10055af5cf1SGlen BarberCLEANFILES+= ${I}.xz 1010c535991SGlen Barber. endfor 1020c535991SGlen Barber.endif 103cd15d7f3SGlen Barber.if defined(WITH_DVD) && !empty(WITH_DVD) 104cd15d7f3SGlen BarberCLEANFILES+= pkg-stage 105cd15d7f3SGlen Barber.endif 10646b13263SHiroki SatoCLEANDIRS= dist ftp release bootonly dvd 10746b13263SHiroki Satobeforeclean: 10846b13263SHiroki Sato chflags -R noschg . 1098eb4e096SRuslan Ermilov.include <bsd.obj.mk> 11046b13263SHiroki Satoclean: beforeclean 11112ad0bb1SNathan Whitehorn 11212ad0bb1SNathan Whitehornbase.txz: 113876acefaSHiroki Sato mkdir -p ${DISTDIR} 114876acefaSHiroki Sato cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR} 11512ad0bb1SNathan Whitehorn# Set up mergemaster root database 116672d7ddbSSean Bruno sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \ 117876acefaSHiroki Sato "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base" 118e9120a25SGlen Barber etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \ 119d6d73d47SJohn Hay -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate" 120bfc3bab8SNathan Whitehorn# Package all components 121876acefaSHiroki Sato cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR} 122876acefaSHiroki Sato mv ${DISTDIR}/*.txz . 12312ad0bb1SNathan Whitehorn 12412ad0bb1SNathan Whitehornkernel.txz: 125876acefaSHiroki Sato mkdir -p ${DISTDIR} 126876acefaSHiroki Sato cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR} 127876acefaSHiroki Sato mv ${DISTDIR}/kernel*.txz . 12812ad0bb1SNathan Whitehorn 12912ad0bb1SNathan Whitehornsrc.txz: 130876acefaSHiroki Sato mkdir -p ${DISTDIR}/usr 13112ad0bb1SNathan Whitehorn ln -fs ${WORLDDIR} ${DISTDIR}/usr/src 1329f5907dbSGlen Barber cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn --exclude .zfs \ 13323659c9dSGlen Barber --exclude .git --exclude @ --exclude usr/src/release/dist usr/src 13412ad0bb1SNathan Whitehorn 13512ad0bb1SNathan Whitehornports.txz: 136876acefaSHiroki Sato mkdir -p ${DISTDIR}/usr 13712ad0bb1SNathan Whitehorn ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports 13812ad0bb1SNathan Whitehorn cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \ 13923659c9dSGlen Barber --exclude .git --exclude .svn \ 14012ad0bb1SNathan Whitehorn --exclude usr/ports/distfiles --exclude usr/ports/packages \ 14112ad0bb1SNathan Whitehorn --exclude 'usr/ports/INDEX*' --exclude work usr/ports 14212ad0bb1SNathan Whitehorn 14312ad0bb1SNathan Whitehornreldoc: 14412ad0bb1SNathan Whitehorn cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \ 14512ad0bb1SNathan Whitehorn INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc 146876acefaSHiroki Sato mkdir -p reldoc 14712ad0bb1SNathan Whitehorn.for i in hardware readme relnotes errata 14853089271STijl Coosemans ln -f rdoc/${RELNOTES_LANG}/${i}/article.txt reldoc/${i:tu}.TXT 14953089271STijl Coosemans ln -f rdoc/${RELNOTES_LANG}/${i}/article.html reldoc/${i:tu}.HTM 15012ad0bb1SNathan Whitehorn.endfor 151876acefaSHiroki Sato cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc 15212ad0bb1SNathan Whitehorn 15312ad0bb1SNathan Whitehornsystem: packagesystem 15412ad0bb1SNathan Whitehorn# Install system 155876acefaSHiroki Sato mkdir -p release 1566e352319SNathan Whitehorn cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 157ba7bd912SGlen Barber DESTDIR=${.OBJDIR}/release MK_RESCUE=no MK_KERNEL_SYMBOLS=no \ 158*ffc6fb79SGlen Barber MK_PROFILE=no MK_SENDMAIL=no MK_TESTS=no MK_LIB32=no \ 159*ffc6fb79SGlen Barber MK_DEBUG_FILES=no 16012ad0bb1SNathan Whitehorn# Copy distfiles 161876acefaSHiroki Sato mkdir -p release/usr/freebsd-dist 162*ffc6fb79SGlen Barber for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \ 163*ffc6fb79SGlen Barber do cp $${dist} release/usr/freebsd-dist; \ 164*ffc6fb79SGlen Barber done 16512ad0bb1SNathan Whitehorn# Copy documentation, if generated 16612ad0bb1SNathan Whitehorn.if !defined(NODOC) 167876acefaSHiroki Sato cp reldoc/* release 16812ad0bb1SNathan Whitehorn.endif 16912ad0bb1SNathan Whitehorn# Set up installation environment 170de17cbccSHiroki Sato ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf 171876acefaSHiroki Sato echo sendmail_enable=\"NONE\" > release/etc/rc.conf 172876acefaSHiroki Sato echo hostid_enable=\"NO\" >> release/etc/rc.conf 17373e46dbaSGlen Barber echo debug.witness.trace=0 >> release/etc/sysctl.conf 174876acefaSHiroki Sato cp ${.CURDIR}/rc.local release/etc 175876acefaSHiroki Sato touch ${.TARGET} 17612ad0bb1SNathan Whitehorn 17746c413feSNathan Whitehornbootonly: packagesystem 17846c413feSNathan Whitehorn# Install system 179876acefaSHiroki Sato mkdir -p bootonly 18046c413feSNathan Whitehorn cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 181ba7bd912SGlen Barber DESTDIR=${.OBJDIR}/bootonly MK_AMD=no MK_AT=no \ 182ba7bd912SGlen Barber MK_GAMES=no MK_GROFF=no \ 183ba7bd912SGlen Barber MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \ 184ba7bd912SGlen Barber MK_NCP=no MK_TOOLCHAIN=no MK_PROFILE=no \ 185ba7bd912SGlen Barber MK_INSTALLIB=no MK_RESCUE=no MK_DICT=no \ 186*ffc6fb79SGlen Barber MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no 18746c413feSNathan Whitehorn# Copy manifest only (no distfiles) to get checksums 188876acefaSHiroki Sato mkdir -p bootonly/usr/freebsd-dist 189876acefaSHiroki Sato cp MANIFEST bootonly/usr/freebsd-dist 19046c413feSNathan Whitehorn# Copy documentation, if generated 19146c413feSNathan Whitehorn.if !defined(NODOC) 192876acefaSHiroki Sato cp reldoc/* bootonly 19346c413feSNathan Whitehorn.endif 19446c413feSNathan Whitehorn# Set up installation environment 195de17cbccSHiroki Sato ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf 196876acefaSHiroki Sato echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf 197876acefaSHiroki Sato echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf 19873e46dbaSGlen Barber echo debug.witness.trace=0 >> bootonly/etc/sysctl.conf 199876acefaSHiroki Sato cp ${.CURDIR}/rc.local bootonly/etc 20046c413feSNathan Whitehorn 201dc244562SGlen Barberdvd: 202dc244562SGlen Barber# Install system 203dc244562SGlen Barber mkdir -p ${.TARGET} 204dc244562SGlen Barber cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 205ba7bd912SGlen Barber DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \ 206*ffc6fb79SGlen Barber MK_TESTS=no MK_DEBUG_FILES=no 207dc244562SGlen Barber# Copy distfiles 208dc244562SGlen Barber mkdir -p ${.TARGET}/usr/freebsd-dist 209*ffc6fb79SGlen Barber for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \ 210*ffc6fb79SGlen Barber do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ 211*ffc6fb79SGlen Barber done 212dc244562SGlen Barber# Copy documentation, if generated 213dc244562SGlen Barber.if !defined(NODOC) 214dc244562SGlen Barber cp reldoc/* ${.TARGET} 215dc244562SGlen Barber.endif 216dc244562SGlen Barber# Set up installation environment 217dc244562SGlen Barber ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf 218dc244562SGlen Barber echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf 219dc244562SGlen Barber echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf 22073e46dbaSGlen Barber echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf 221dc244562SGlen Barber cp ${.CURDIR}/rc.local ${.TARGET}/etc 222dc244562SGlen Barber touch ${.TARGET} 223dc244562SGlen Barber 2248cec99b6SGlen Barberrelease.iso: disc1.iso 2258cec99b6SGlen Barberdisc1.iso: system 226876acefaSHiroki Sato sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} release 22712ad0bb1SNathan Whitehorn 228dc244562SGlen Barberdvd1.iso: dvd pkg-stage 229dc244562SGlen Barber sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} dvd 230dc244562SGlen Barber 23146c413feSNathan Whitehornbootonly.iso: bootonly 232876acefaSHiroki Sato sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} bootonly 23346c413feSNathan Whitehorn 234cb95a96bSGlen Barbermemstick: memstick.img 2353c334738SGlen Barbermemstick.img: system 236876acefaSHiroki Sato sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET} 23712ad0bb1SNathan Whitehorn 238a9da1707SGlen Barbermini-memstick: mini-memstick.img 239a9da1707SGlen Barbermini-memstick.img: system 240a9da1707SGlen Barber sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET} 241a9da1707SGlen Barber 24212ad0bb1SNathan Whitehornpackagesystem: base.txz kernel.txz ${EXTRA_PACKAGES} 243876acefaSHiroki Sato sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST 244299a8b95SNathan Whitehorn touch ${.TARGET} 24512ad0bb1SNathan Whitehorn 246dc244562SGlen Barberpkg-stage: 2476f50c4eaSGlen Barber.if !defined(NOPKG) 2486f50c4eaSGlen Barber env REPOS_DIR=${.CURDIR}/pkg_repos/ \ 2496f50c4eaSGlen Barber sh ${.CURDIR}/scripts/pkg-stage.sh 2500d0e89b7SGlen Barber mkdir -p ${.OBJDIR}/dvd/packages/repos/ 2510d0e89b7SGlen Barber cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \ 2520d0e89b7SGlen Barber ${.OBJDIR}/dvd/packages/repos/ 253dc244562SGlen Barber.endif 2540d0e89b7SGlen Barber touch ${.TARGET} 255dc244562SGlen Barber 2568cec99b6SGlen Barbercdrom: disc1.iso bootonly.iso 257dc244562SGlen Barberdvdrom: dvd1.iso 25812ad0bb1SNathan Whitehornftp: packagesystem 259299a8b95SNathan Whitehorn rm -rf ftp 260876acefaSHiroki Sato mkdir -p ftp 261299a8b95SNathan Whitehorn cp *.txz MANIFEST ftp 26212ad0bb1SNathan Whitehorn 2630bd47e83SNathan Whitehornrelease: 2640bd47e83SNathan Whitehorn ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj 2650bd47e83SNathan Whitehorn ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} 26612ad0bb1SNathan Whitehorn 267299a8b95SNathan Whitehorninstall: 268876acefaSHiroki Sato.if defined(DESTDIR) && !empty(DESTDIR) 269876acefaSHiroki Sato mkdir -p ${DESTDIR} 270876acefaSHiroki Sato.endif 271de17cbccSHiroki Sato cp -a ftp ${DESTDIR}/ 272de17cbccSHiroki Sato.for I in ${IMAGES} 273de17cbccSHiroki Sato cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I} 274510f3303SGlen Barber. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) 2753b485e46SGlen Barber ${XZCMD} -k ${DESTDIR}/${OSRELEASE}-${I} 276cbc0e08aSGlen Barber. endif 277de17cbccSHiroki Sato.endfor 278de17cbccSHiroki Sato cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 279de17cbccSHiroki Sato cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5 280