xref: /freebsd/release/Makefile (revision 2a664c03e55254b0f3b32dcdfc78179c0a57a8d2)
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=	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
56IMAGES=
57.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh)
58RELEASE_TARGETS+= cdrom
59IMAGES+=	release.iso bootonly.iso
60.endif
61.if exists(${.CURDIR}/${TARGET}/make-memstick.sh)
62RELEASE_TARGETS+= memstick
63IMAGES+=	memstick
64.endif
65
66.include <bsd.obj.mk>
67
68base.txz:
69	mkdir -p ${DISTDIR}
70	cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR}
71# Set up mergemaster root database
72	sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \
73	    "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base"
74# Package all components
75	cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR}
76	mv ${DISTDIR}/*.txz .
77
78kernel.txz:
79	mkdir -p ${DISTDIR}
80	cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR}
81	mv ${DISTDIR}/kernel*.txz .
82
83src.txz:
84	mkdir -p ${DISTDIR}/usr
85	ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
86	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn \
87	    --exclude CVS --exclude @ --exclude usr/src/release/dist usr/src
88
89ports.txz:
90	mkdir -p ${DISTDIR}/usr
91	ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
92	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \
93	    --exclude CVS --exclude .svn \
94	    --exclude usr/ports/distfiles --exclude usr/ports/packages \
95	    --exclude 'usr/ports/INDEX*' --exclude work usr/ports
96
97reldoc:
98	cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \
99	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc
100	mkdir -p reldoc
101.for i in hardware readme relnotes errata
102	ln -f rdoc/${RELNOTES_LANG}/${i}/article.txt reldoc/${i:U}.TXT
103	ln -f rdoc/${RELNOTES_LANG}/${i}/article.html reldoc/${i:U}.HTM
104.endfor
105	cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc
106
107system: packagesystem
108# Install system
109	mkdir -p release
110	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
111	    DESTDIR=${.OBJDIR}/release WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1
112# Copy distfiles
113	mkdir -p release/usr/freebsd-dist
114	cp *.txz MANIFEST release/usr/freebsd-dist
115# Copy documentation, if generated
116.if !defined(NODOC)
117	cp reldoc/* release
118.endif
119# Set up installation environment
120	ln -s /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
121	echo sendmail_enable=\"NONE\" > release/etc/rc.conf
122	echo hostid_enable=\"NO\" >> release/etc/rc.conf
123	cp ${.CURDIR}/rc.local release/etc
124	touch ${.TARGET}
125
126bootonly: packagesystem
127# Install system
128	mkdir -p bootonly
129	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
130	    DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \
131	    WITHOUT_BIND_DNSSEC=1 WITHOUT_BIND_ETC=1 WITHOUT_BIND_MTREE=1 \
132	    WITHOUT_BIND_NAMED=1 WITHOUT_GAMES=1 WITHOUT_GROFF=1 \
133	    WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \
134	    WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_PROFILE=1 \
135	    WITHOUT_INSTALLIB=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 \
136	    WITHOUT_KERNEL_SYMBOLS=1
137# Copy manifest only (no distfiles) to get checksums
138	mkdir -p bootonly/usr/freebsd-dist
139	cp MANIFEST bootonly/usr/freebsd-dist
140# Copy documentation, if generated
141.if !defined(NODOC)
142	cp reldoc/* bootonly
143.endif
144# Set up installation environment
145	ln -s /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
146	echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf
147	echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf
148	cp ${.CURDIR}/rc.local bootonly/etc
149
150release.iso: system
151	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} release
152
153bootonly.iso: bootonly
154	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} bootonly
155
156memstick: system
157	sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET}
158
159packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
160	sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST
161	touch ${.TARGET}
162
163cdrom: release.iso bootonly.iso
164ftp: packagesystem
165	rm -rf ftp
166	mkdir -p ftp
167	cp *.txz MANIFEST ftp
168
169release:
170	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
171	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
172
173clean:
174	chflags -R noschg .
175	rm -rf dist ftp
176	rm -f packagesystem
177	rm -f *.txz MANIFEST
178	rm -f system
179	rm -rf release bootonly
180	rm -f release.iso bootonly.iso memstick
181
182install:
183.if defined(DESTDIR) && !empty(DESTDIR)
184	mkdir -p ${DESTDIR}
185.endif
186	cp -a ${IMAGES} ftp ${DESTDIR}/
187