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