Build the installer as part of normal build-/installworld if WANT_INSTALLER
[dragonfly.git] / nrelease / Makefile
1 # $DragonFly: src/nrelease/Makefile,v 1.84 2008/07/09 07:21:03 swildner Exp $
2 #
3
4 #########################################################################
5 #                               ENHANCEMENTS                            #
6 #########################################################################
7
8 # These targets are now obsolete and should not be used 
9 #
10 installer_release: warning release
11 installer_quickrel: warning quickrel
12 installer_realquickrel: warning realquickrel
13 installer_fetch: warning fetch
14
15 .if make(installer_release) || make(installer_quickrel) || make(installer_realquickrel) || make(installer_fetch)
16 WITH_INSTALLER=
17 .endif
18
19 # New method e.g. 'make installer fetch'.  A series of enhancement
20 # targes may be specified which set make variables which enhance
21 # the build in various ways.
22 #
23 gui installer:
24
25 warning:
26         @echo "WARNING: The installer_* targets are now obsolete, please"
27         @echo "use 'make installer blah' instead of 'make installer_blah'"
28         @echo ""
29         @echo "will continue in 10 seconds"
30         @sleep 10
31
32 .if make(gui)
33 WITH_GUI=
34 .endif
35 .if make(installer)
36 WITH_INSTALLER=
37 .endif
38
39 #########################################################################
40 #                                SETUP                                  #
41 #########################################################################
42
43 ISODIR ?= /usr/release
44 ISOROOT ?= ${ISODIR}/root
45 OBJSYS= ${.OBJDIR}/../sys
46 KERNCONF ?= GENERIC VKERNEL
47
48 PKGSRC_PREFIX?=         /usr/pkg
49 PKGBIN_PKG_ADD?=        ${PKGSRC_PREFIX}/sbin/pkg_add
50 PKGBIN_PKG_DELETE?=     ${PKGSRC_PREFIX}/sbin/pkg_delete
51 PKGBIN_PKG_ADMIN?=      ${PKGSRC_PREFIX}/sbin/pkg_admin
52 PKGBIN_MKISOFS?=        ${PKGSRC_PREFIX}/bin/mkisofs
53 PKGSRC_PKG_PATH?=       ${ISODIR}/packages
54 PKGSRC_DB?=             /var/db/pkg
55 PKGSRC_BOOTSTRAP_URL?=  http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
56
57 ENVCMD?=        env
58 TAR?=   tar
59
60 PKGSRC_CDRECORD?=       cdrtools-ossdvd-2.01.1.36nb2.tgz
61 PKGSRC_BOOTSTRAP_KIT?=  bootstrap-kit-20080211
62 CVSUP_BOOTSTRAP_KIT?=   cvsup-bootstrap-20070716
63
64 # Default packages to be installed on the release ISO.
65 #
66 PKGSRC_PACKAGES?=       cdrtools-ossdvd-2.01.1.36nb2.tgz
67
68 # Even though buildiso wipes the packages, our check target has to run
69 # first and old packages (listed as they appear in pkg_info) must be
70 # cleaned out in order for the pkg_add -n test we use in the check target
71 # to operate properly.
72 #
73 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 cdrecord-2.00.3nb2 \
74                       bootstrap-kit-20070205
75
76 # Specify which root skeletons are required, and let the user include
77 # their own.  They are copied into ISODIR during the `pkgcustomizeiso'
78 # target; each overwrites the last.
79 #
80 REQ_ROOTSKELS= ${.CURDIR}/root
81 ROOTSKELS?=     ${REQ_ROOTSKELS}
82
83 .if defined(WITH_GUI)
84 ISOFILE?=               ${ISODIR}/dfly-gui.iso
85 PKGSRC_PACKAGES+=       modular-xorg-apps \
86                         modular-xorg-drivers \
87                         modular-xorg-fonts \
88                         modular-xorg-libs \
89                         fluxbox
90 ROOTSKELS+=             ${.CURDIR}/gui
91 .endif
92
93 .if defined(WITH_INSTALLER)
94 ROOTSKELS+=             ${.CURDIR}/installer
95 .endif
96
97 ISOFILE ?= ${ISODIR}/dfly.iso
98
99 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
100 # the additional '/nrelease' manually, as a safety measure.
101 #
102 NRLOBJDIR?= /usr/obj
103
104 WORLD_CCVER ?= ${CCVER}
105 KERNEL_CCVER ?= ${CCVER}
106
107 #########################################################################
108 #                               BASE ISO TARGETS                        #
109 #########################################################################
110
111 release:        check clean buildworld1 buildkernel1 \
112                 buildiso syssrcs customizeiso mklocatedb mkiso
113
114 quickrel:       check clean buildworld2 buildkernel2 \
115                 buildiso syssrcs customizeiso mklocatedb mkiso
116
117 realquickrel:   check clean buildiso syssrcs customizeiso mklocatedb mkiso
118
119 quick:          quickrel
120
121 realquick:      realquickrel
122
123 #########################################################################
124 #                          CORE SUPPORT TARGETS                         #
125 #########################################################################
126
127 check:
128 .if !exists(${PKGBIN_PKG_ADD})
129         @echo "Unable to find ${PKGBIN_PKG_ADD}.  You can use the following"
130         @echo "command to bootstrap pkgsrc:"
131         @echo "    make pkgsrc_bootstrap"
132         @exit 1
133 .endif
134 .for PKG in ${OLD_PKGSRC_PACKAGES}
135         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_DELETE} -K ${ISOROOT}${PKGSRC_DB} ${PKG} > /dev/null 2>&1 || exit 0
136 .endfor
137 .for PKG in ${PKGSRC_PACKAGES}
138         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
139                 (echo "Unable to find ${PKG}, use the following command to fetch required packages:"; echo "    make [installer] fetch"; exit 1)
140 .endfor
141 .if !exists(${PKGBIN_MKISOFS})
142         @echo "mkisofs is not installed.  It is part of the cdrecord package."
143         @echo "You can install it with:"
144         @echo "    make pkgsrc_cdrecord"
145         @exit 1
146 .endif
147 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
148         @echo "The pkgsrc bootstrap kit is not installed.  You can install it with:"
149         @echo "    make [installer] fetch"
150         @exit 1
151 .endif
152 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
153         @echo "The cvsup bootstrap kit is not installed.  You can install it with:"
154         @echo "    make [installer] fetch"
155         @exit 1
156 .endif
157
158 buildworld1 buildworld2:
159         cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make ${WITH_INSTALLER:C/^/-DWANT_INSTALLER/} ${.TARGET:C/build(.*)2/quick\1/:C/1//}
160
161 buildkernel1 buildkernel2:
162         cd ${.CURDIR}/..; \
163         first=; \
164         for kernconf in ${KERNCONF}; do \
165                 CCVER=${KERNEL_CCVER} make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
166                         KERNCONF=$${kernconf} \
167                         $${first:+-DNO_MODULES}; \
168                 first=done; \
169         done
170
171 # note that we do not want to mess with any /usr/obj directories not related
172 # to buildworld, buildkernel, or nrelease, so we must supply the proper
173 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 
174 # buildkernel mechanism.
175 #
176 buildiso:
177         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
178         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
179         ( cd ${.CURDIR}/..; make ${WITH_INSTALLER:C/^/-DWANT_INSTALLER/} DESTDIR=${ISOROOT} installworld )
180         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
181                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
182         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
183         cd ${.CURDIR}/..; \
184         first=; \
185         for kernconf in ${KERNCONF}; do \
186                 make DESTDIR=${ISOROOT} \
187                         installkernel KERNCONF=$${kernconf} \
188                         $${first:+DESTKERNNAME=kernel.$${kernconf}} \
189                         $${first:+-DNO_MODULES}; \
190                 first=done; \
191         done
192         ln -s kernel ${ISOROOT}/kernel.BOOTP
193         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
194         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
195         dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
196
197 # Include kernel sources on the release CD (~14MB)
198 #
199 syssrcs:
200 .if !defined(WITHOUT_SRCS)
201         ( cd ${.CURDIR}/../..; tar --exclude CVS -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
202 .endif
203
204 customizeiso:
205         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
206 .for ROOTSKEL in ${ROOTSKELS}
207         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
208 .endfor
209         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
210         cd ${ISOROOT}; tar xvzpf ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz
211         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
212         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
213         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
214         rm -rf `find ${ISOROOT} -type d -name CVS -print`
215         rm -rf ${ISOROOT}/usr/local/share/pristine
216         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
217 .for UPGRADE_ITEM in Makefile                   \
218                      etc.${MACHINE_ARCH}        \
219                      isdn/Makefile              \
220                      rc.d/Makefile              \
221                      periodic/Makefile          \
222                      periodic/daily/Makefile    \
223                      periodic/security/Makefile \
224                      periodic/weekly/Makefile   \
225                      periodic/monthly/Makefile
226         cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
227 .endfor
228 .for PKG in ${PKGSRC_PACKAGES}
229         ${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -I ${PKG}
230 .endfor
231         find ${ISOROOT}${PKGSRC_DB} -name +CONTENTS -type f -exec sed -i '' -e 's,${ISOROOT},,' -- {} \;
232         ${PKGBIN_PKG_ADMIN} -K ${ISOROOT}${PKGSRC_DB} rebuild
233 .if defined(WITH_GUI)
234 .for FONT in 75dpi 100dpi misc Type1 TTF
235         chroot ${ISOROOT} /usr/pkg/bin/mkfontdir /usr/pkg/lib/X11/fonts/${FONT}
236 .endfor
237 .endif
238
239 mklocatedb:
240         ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
241                 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
242                 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
243                 /usr/libexec/locate.mklocatedb \
244                 -presort >${ISOROOT}/var/db/locate.database )
245
246 mkiso:
247         ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
248                 -R -J -V DragonFly -o ${ISOFILE} . )
249
250 clean:
251         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
252         if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
253         if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
254
255 realclean:      clean
256         rm -rf ${OBJSYS}/${KERNCONF}
257         # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
258         # override location.
259         if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
260
261 fetch:
262         @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
263 .for PKG in ${PKGSRC_PACKAGES}
264         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
265         (cd ${PKGSRC_PKG_PATH}; echo "Fetching ${PKGSRC_BOOTSTRAP_URL}/${PKG}"; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKG})
266 .endfor
267 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
268         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
269 .endif
270 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
271         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
272 .endif
273
274 pkgsrc_bootstrap:
275         mkdir -p ${PKGSRC_PKG_PATH}
276 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
277         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
278 .endif
279         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
280         (cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
281
282 pkgsrc_cdrecord:
283 .if !exists (${PKGBIN_MKISOFS})
284         ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
285 .endif
286
287
288 .PHONY: all release installer_release quickrel installer_quickrel realquickrel
289 .PHONY: installer_fetch installer
290 .PHONY: quick realquick
291 .PHONY: installer_realquickrel check buildworld1 buildworld2
292 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso
293 .PHONY: clean realclean fetch
294
295 .include <bsd.prog.mk>