]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - release/Makefile
MFC r259729:
[FreeBSD/stable/9.git] / release / Makefile
1 # $FreeBSD$
2 #
3 # Makefile for building releases and release media.
4
5 # User-driven targets:
6 #  cdrom: Builds release CD-ROM media (disc1.iso)
7 #  dvdrom: Builds release DVD-ROM media (dvd1.iso)
8 #  memstick: Builds memory stick image (memstick.img)
9 #  mini-memstick: Builds minimal memory stick image (mini-memstick.img)
10 #  ftp: Sets up FTP distribution area (ftp)
11 #  release: Build all media and FTP distribution area
12 #  install: Copies all release media into ${DESTDIR}
13 #
14 # Variables affecting the build process:
15 #  WORLDDIR: location of src tree -- must have built world and default kernel
16 #            (by default, the directory above this one) 
17 #  PORTSDIR: location of ports tree to distribute (default: /usr/ports)
18 #  DOCDIR:   location of doc tree (default: /usr/doc)
19 #  NOPORTS:  if set, do not distribute ports tree
20 #  NOSRC:    if set, do not distribute source tree
21 #  NODOC:    if set, do not generate release documentation
22 #  WITH_DVD: if set, generate dvd1.iso
23 #  TARGET/TARGET_ARCH: architecture of built release 
24 #
25
26 WORLDDIR?=      ${.CURDIR}/..
27 PORTSDIR?=      /usr/ports
28 DOCDIR?=        /usr/doc
29 RELNOTES_LANG?= en_US.ISO8859-1
30
31 .if !defined(TARGET) || empty(TARGET)
32 TARGET=         ${MACHINE}
33 .endif
34 .if !defined(TARGET_ARCH) || empty(TARGET_ARCH)
35 .if ${TARGET} == ${MACHINE}
36 TARGET_ARCH=    ${MACHINE_ARCH}
37 .else
38 TARGET_ARCH=    ${TARGET}
39 .endif
40 .endif
41 IMAKE=          ${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
42 DISTDIR=        dist
43
44 # Define OSRELEASE by using newvars.sh
45 .if !defined(OSRELEASE) || empty(OSRELEASE)
46 .for _V in TYPE BRANCH REVISION
47 ${_V}!= eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V}
48 .endfor
49 .for _V in ${TARGET_ARCH}
50 .if !empty(TARGET:M${_V})
51 OSRELEASE=      ${TYPE}-${REVISION}-${BRANCH}-${TARGET}
52 .else
53 OSRELEASE=      ${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH}
54 .endif
55 .endfor
56 .endif
57
58 .if !exists(${DOCDIR})
59 NODOC= true
60 .endif
61 .if !exists(${PORTSDIR})
62 NOPORTS= true
63 .endif
64
65 EXTRA_PACKAGES= 
66 .if !defined(NOPORTS)
67 EXTRA_PACKAGES+= ports.txz
68 .endif
69 .if !defined(NOSRC)
70 EXTRA_PACKAGES+= src.txz
71 .endif
72 .if !defined(NODOC)
73 EXTRA_PACKAGES+= reldoc
74 .endif
75
76 RELEASE_TARGETS= ftp
77 IMAGES=
78 .if exists(${.CURDIR}/${TARGET}/mkisoimages.sh)
79 RELEASE_TARGETS+= cdrom
80 IMAGES+=        disc1.iso bootonly.iso
81 . if defined(WITH_DVD) && !empty(WITH_DVD)
82 RELEASE_TARGETS+= dvdrom
83 IMAGES+=        dvd1.iso
84 . endif
85 .endif
86 .if exists(${.CURDIR}/${TARGET}/make-memstick.sh)
87 RELEASE_TARGETS+= memstick.img
88 RELEASE_TARGETS+= mini-memstick.img
89 IMAGES+=        memstick.img
90 IMAGES+=        mini-memstick.img
91 .endif
92
93 CLEANFILES=     packagesystem *.txz MANIFEST system ${IMAGES}
94 CLEANDIRS=      dist ftp release bootonly dvd
95 beforeclean:
96         chflags -R noschg .
97 .include <bsd.obj.mk>
98 clean: beforeclean
99
100 base.txz:
101         mkdir -p ${DISTDIR}
102         cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR}
103 # Set up mergemaster root database
104         sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \
105             "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base"
106         etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \
107             -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate"
108 # Package all components
109         cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR}
110         mv ${DISTDIR}/*.txz .
111
112 kernel.txz:
113         mkdir -p ${DISTDIR}
114         cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR}
115         mv ${DISTDIR}/kernel*.txz .
116
117 src.txz:
118         mkdir -p ${DISTDIR}/usr
119         ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
120         cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn --exclude .zfs \
121             --exclude CVS --exclude @ --exclude usr/src/release/dist usr/src
122
123 ports.txz:
124         mkdir -p ${DISTDIR}/usr
125         ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
126         cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \
127             --exclude CVS --exclude .svn \
128             --exclude usr/ports/distfiles --exclude usr/ports/packages \
129             --exclude 'usr/ports/INDEX*' --exclude work usr/ports
130
131 reldoc:
132         cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \
133             INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc
134         mkdir -p reldoc
135 .for i in hardware readme relnotes errata
136         ln -f rdoc/${RELNOTES_LANG}/${i}/article.txt reldoc/${i:U}.TXT
137         ln -f rdoc/${RELNOTES_LANG}/${i}/article.html reldoc/${i:U}.HTM
138 .endfor
139         cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc
140
141 system: packagesystem
142 # Install system
143         mkdir -p release
144         cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
145                 DESTDIR=${.OBJDIR}/release WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 \
146                 WITHOUT_PROFILE=1
147 # Copy distfiles
148         mkdir -p release/usr/freebsd-dist
149         cp *.txz MANIFEST release/usr/freebsd-dist
150 # Copy documentation, if generated
151 .if !defined(NODOC)
152         cp reldoc/* release
153 .endif
154 # Set up installation environment
155         ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
156         echo sendmail_enable=\"NONE\" > release/etc/rc.conf
157         echo hostid_enable=\"NO\" >> release/etc/rc.conf
158         cp ${.CURDIR}/rc.local release/etc
159         touch ${.TARGET}
160
161 bootonly: packagesystem
162 # Install system
163         mkdir -p bootonly
164         cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
165             DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \
166             WITHOUT_BIND_DNSSEC=1 WITHOUT_BIND_ETC=1 WITHOUT_BIND_MTREE=1 \
167             WITHOUT_BIND_NAMED=1 WITHOUT_GAMES=1 WITHOUT_GROFF=1 \
168             WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \
169             WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_PROFILE=1 \
170             WITHOUT_INSTALLIB=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 \
171             WITHOUT_KERNEL_SYMBOLS=1
172 # Copy manifest only (no distfiles) to get checksums
173         mkdir -p bootonly/usr/freebsd-dist
174         cp MANIFEST bootonly/usr/freebsd-dist
175 # Copy documentation, if generated
176 .if !defined(NODOC)
177         cp reldoc/* bootonly
178 .endif
179 # Set up installation environment
180         ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
181         echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf
182         echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf
183         cp ${.CURDIR}/rc.local bootonly/etc
184
185 dvd:
186 # Install system
187         mkdir -p ${.TARGET}
188         cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
189                 DESTDIR=${.OBJDIR}/${.TARGET} WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1
190 # Copy distfiles
191         mkdir -p ${.TARGET}/usr/freebsd-dist
192         cp *.txz MANIFEST ${.TARGET}/usr/freebsd-dist
193 # Copy documentation, if generated
194 .if !defined(NODOC)
195         cp reldoc/* ${.TARGET}
196 .endif
197 # Set up installation environment
198         ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
199         echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
200         echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
201         cp ${.CURDIR}/rc.local ${.TARGET}/etc
202         touch ${.TARGET}
203
204 release/cdrom.inf: system
205         echo "CD_VERSION = ${REVISION}-${BRANCH}" > ${.TARGET}
206         echo "CD_VOLUME = 1" >> ${.TARGET}
207
208 release.iso: disc1.iso
209 disc1.iso: system release/cdrom.inf
210         sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} release
211
212 dvd1.iso: dvd pkg-stage
213         sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} dvd
214
215 bootonly/cdrom.inf: bootonly
216         echo "CD_VERSION = ${REVISION}-${BRANCH}" > ${.TARGET}
217         echo "CD_VOLUME = 1" >> ${.TARGET}
218
219 bootonly.iso: bootonly bootonly/cdrom.inf
220         sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} bootonly
221
222 memstick: memstick.img
223 memstick.img: system
224         sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET}
225
226 mini-memstick: mini-memstick.img
227 mini-memstick.img: system
228         sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
229
230 packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
231         sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST
232         touch ${.TARGET}
233
234 pkg-stage:
235 .if(exists(${.CURDIR}/${TARGET}/pkg-stage.conf))
236         sh ${.CURDIR}/scripts/pkg-stage.sh ${.CURDIR}/${TARGET}/pkg-stage.conf \
237                 ${REVISION}
238 .endif
239
240 cdrom: disc1.iso bootonly.iso
241 dvdrom: dvd1.iso
242 ftp: packagesystem
243         rm -rf ftp
244         mkdir -p ftp
245         cp *.txz MANIFEST ftp
246
247 release:
248         ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
249         ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
250
251 install:
252 .if defined(DESTDIR) && !empty(DESTDIR)
253         mkdir -p ${DESTDIR}
254 .endif
255         cp -a ftp ${DESTDIR}/
256 .for I in ${IMAGES}
257         cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
258 .endfor
259         cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
260         cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5