xref: /freebsd/release/Makefile (revision 6e352319b6ff97a20b53d13a6df76b71dd12afc9)
1# $FreeBSD$
2#
3# Makefile for building releases and release media.
4#
5# User-driven targets:
6#  cdrom: Builds release CD-ROM media (release.iso)
7#  memstick: Builds memory stick image (memstick)
8#  ftp: Sets up FTP distribution area (ftp)
9#  release: Build all media and FTP distribution area
10#  install: Copies all release media into ${DESTDIR}
11#
12# Variables affecting the build process:
13#  WORLDDIR: location of src tree -- must have built world and default kernel
14#            (by default, the directory above this one)
15#  PORTSDIR: location of ports tree to distribute (default: /usr/ports)
16#  DOCDIR:   location of doc tree (default: /usr/doc)
17#  NOPORTS:  if set, do not distribute ports tree
18#  NOSRC:    if set, do not distribute source tree
19#  NODOC:    if set, do not generate release documentation
20#  TARGET/TARGET_ARCH: architecture of built release
21#
22
23WORLDDIR?=	${.CURDIR}/..
24PORTSDIR?=	/usr/ports
25DOCDIR?=	/usr/doc
26RELNOTES_LANG?= en_US.ISO8859-1
27
28TARGET?=	${MACHINE}
29.if ${TARGET} == ${MACHINE}
30TARGET_ARCH?=	${MACHINE_ARCH}
31.else
32TARGET_ARCH?=	${TARGET}
33.endif
34IMAKE=		${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
35DISTDIR=	${.OBJDIR}/dist
36
37.if !exists(${DOCDIR})
38NODOC= true
39.endif
40.if !exists(${PORTSDIR})
41NOPORTS= true
42.endif
43
44EXTRA_PACKAGES=
45.if !defined(NOPORTS)
46EXTRA_PACKAGES+= ports.txz
47.endif
48.if !defined(NOSRC)
49EXTRA_PACKAGES+= src.txz
50.endif
51.if !defined(NODOC)
52EXTRA_PACKAGES+= reldoc
53.endif
54
55RELEASE_TARGETS= ftp
56.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh)
57RELEASE_TARGETS+= cdrom
58.endif
59.if exists(${.CURDIR}/${TARGET}/make-memstick.sh)
60RELEASE_TARGETS+= memstick
61.endif
62
63.include <bsd.obj.mk>
64
65base.txz:
66	-mkdir ${DISTDIR}
67	cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${DISTDIR}
68# Set up mergemaster root database
69	sh ${.CURDIR}/scripts/mm-mtree.sh -F \
70	    "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${DISTDIR}/base"
71# Merge handbook, etc. from doc tree into src tree doc distribution
72.if !defined(NODOC)
73	cd ${DOCDIR} && ${IMAKE} all install \
74	    DOCDIR=${DISTDIR}/doc/usr/share/doc 'FORMATS=html html-split txt' \
75	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES
76.endif
77	cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${DISTDIR}
78	mv ${DISTDIR}/*.txz ${.OBJDIR}
79
80kernel.txz:
81	-mkdir ${DISTDIR}
82	cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${DISTDIR}
83	mv ${DISTDIR}/kernel.txz ${.OBJDIR}
84
85src.txz:
86	-mkdir -p ${DISTDIR}/usr
87	ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
88	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn \
89	    --exclude CVS usr/src
90
91ports.txz:
92	-mkdir -p ${DISTDIR}/usr
93	ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
94	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \
95	    --exclude usr/ports/distfiles --exclude usr/ports/packages \
96	    --exclude 'usr/ports/INDEX*' --exclude work usr/ports
97
98reldoc:
99	cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \
100	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc
101	-mkdir ${.OBJDIR}/reldoc
102.for i in hardware readme relnotes errata
103	ln -f ${.OBJDIR}/rdoc/${RELNOTES_LANG}/${i}/article.txt \
104	    ${.OBJDIR}/reldoc/${i:U}.TXT
105	ln -f ${.OBJDIR}/rdoc/${RELNOTES_LANG}/${i}/article.html \
106	    ${.OBJDIR}/reldoc/${i:U}.HTM
107.endfor
108	cp ${.OBJDIR}/rdoc/${RELNOTES_LANG}/readme/docbook.css ${.OBJDIR}/reldoc
109
110system: packagesystem
111# Install system
112	-mkdir ${.OBJDIR}/release
113	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
114	    DESTDIR=${.OBJDIR}/release WITHOUT_RESCUE=1
115	-rm ${.OBJDIR}/release/boot/kernel/*.symbols
116# Copy distfiles
117	mkdir ${.OBJDIR}/release/usr/freebsd-dist
118	cp ${.OBJDIR}/*.txz ${.OBJDIR}/MANIFEST \
119	    ${.OBJDIR}/release/usr/freebsd-dist
120# Copy documentation, if generated
121.if !defined(NODOC)
122	cp ${.OBJDIR}/reldoc/* ${.OBJDIR}/release
123.endif
124# Set up installation environment
125	ln -s /tmp/bsdinstall_etc/resolv.conf ${.OBJDIR}/release/etc/resolv.conf
126	echo sendmail_enable=\"NONE\" > ${.OBJDIR}/release/etc/rc.conf
127	echo hostid_enable=\"NO\" >> ${.OBJDIR}/release/etc/rc.conf
128	cp ${.CURDIR}/rc.local ${.OBJDIR}/release/etc
129	touch ${.OBJDIR}/${.TARGET}
130
131bootonly: packagesystem
132# Install system
133	mkdir ${.OBJDIR}/bootonly
134	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
135	    DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \
136	    WITHOUT_BIND_DNSSEC=1 WITHOUT_BIND_ETC=1 WITHOUT_BIND_MTREE=1 \
137	    WITHOUT_BIND_NAMED=1 WITHOUT_GAMES=1 WITHOUT_GROFF=1 \
138	    WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \
139	    WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1
140	-rm ${.OBJDIR}/bootonly/boot/kernel/*.symbols
141# Copy manifest only (no distfiles) to get checksums
142	mkdir ${.OBJDIR}/bootonly/usr/freebsd-dist
143	cp ${.OBJDIR}/MANIFEST ${.OBJDIR}/bootonly/usr/freebsd-dist
144# Copy documentation, if generated
145.if !defined(NODOC)
146	cp ${.OBJDIR}/reldoc/* ${.OBJDIR}/bootonly
147.endif
148# Set up installation environment
149	ln -s /tmp/bsdinstall_etc/resolv.conf ${.OBJDIR}/bootonly/etc/resolv.conf
150	echo sendmail_enable=\"NONE\" > ${.OBJDIR}/bootonly/etc/rc.conf
151	echo hostid_enable=\"NO\" >> ${.OBJDIR}/bootonly/etc/rc.conf
152	cp ${.CURDIR}/rc.local ${.OBJDIR}/bootonly/etc
153
154release.iso: system
155	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/release.iso ${.OBJDIR}/release
156
157bootonly.iso: bootonly
158	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/bootonly.iso ${.OBJDIR}/bootonly
159
160memstick: system
161	sh ${.CURDIR}/${TARGET}/make-memstick.sh ${.OBJDIR}/release ${.OBJDIR}/memstick
162
163packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
164	sh ${.CURDIR}/scripts/make-manifest.sh ${.OBJDIR}/*.txz > ${.OBJDIR}/MANIFEST
165	touch ${.TARGET}
166
167cdrom: release.iso bootonly.iso
168ftp: packagesystem
169	rm -rf ftp
170	mkdir ftp
171	cp *.txz MANIFEST ftp
172
173release:
174	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
175	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
176
177clean:
178	chflags -R noschg ${.OBJDIR}
179	rm -rf dist ftp
180	rm -f packagesystem
181	rm -f *.txz MANIFEST
182	rm -f system
183	rm -rf release bootonly
184	rm -f release.iso bootonly.iso memstick
185
186install:
187	-mkdir ${DESTDIR}
188	cp -a *.iso memstick ftp ${DESTDIR}/
189
190