Merge branch 'vendor/NCURSES'
[dragonfly.git] / nrelease / Makefile
1 # $DragonFly: src/nrelease/Makefile,v 1.90 2008/09/01 21:20:30 swildner Exp $
2 #
3
4 #########################################################################
5 #                               ENHANCEMENTS                            #
6 #########################################################################
7
8 # New method e.g. 'make gui release'.  A series of enhancement
9 # targes may be specified which set make variables which enhance
10 # the build in various ways.
11 #
12 gui installer img:
13
14 #########################################################################
15 #                                SETUP                                  #
16 #########################################################################
17
18 ISODIR?=        /usr/release
19 ISOROOT?=       ${ISODIR}/root
20 OBJSYS=         ${.OBJDIR}/../sys
21
22 MAKE_JOBS?=     $$(sysctl -n hw.ncpu)
23
24 # temporary until everybody has converted to x86_64
25 .if ${MACHINE_ARCH} == "amd64"
26 MACHINE_ARCH=   x86_64
27 .makeenv MACHINE_ARCH
28 .endif
29
30 .if make(gui)
31 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
32 .else
33 # XXX makeshift fix to build the right kernel for the (target) architecture
34 # We should configure this in the platform files somehow
35 .if ${MACHINE_ARCH} == "i386"
36 KERNCONF ?= GENERIC VKERNEL
37 .else
38 KERNCONF ?= X86_64_GENERIC
39 .endif
40 .endif
41
42 PKGSRC_PREFIX?=         /usr/pkg
43 PKGBIN_PKG_ADD?=        ${PKGSRC_PREFIX}/sbin/pkg_add
44 PKGBIN_PKG_DELETE?=     ${PKGSRC_PREFIX}/sbin/pkg_delete
45 PKGBIN_PKG_ADMIN?=      ${PKGSRC_PREFIX}/sbin/pkg_admin
46 PKGBIN_MKISOFS?=        ${PKGSRC_PREFIX}/bin/mkisofs
47 PKGSRC_PKG_PATH?=       ${ISODIR}/packages
48 PKGSRC_BOOTSTRAP_URL?=  http://avalon.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
49 CVSUP_BOOTSTRAP_KIT?=   cvsup-bootstrap-20070716
50
51 # We use env -i in the chroot, so that environment variables won't
52 # disturb any (pkgsrc) build.  This has happened for TARGET_ARCH,
53 # which is used by gmake in completely different context.
54 #
55 CHROOT_CMD?=            env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
56
57 # User may specify extra packages in addition to the defaults
58 #
59 PKGSRC_EXTRA_PACKAGES?=
60
61 # Pkgsrc packages to be built and installed on the release ISO
62 #
63 PKGSRC_PACKAGES?=       pkgtools/pkg_leaves \
64                         pkgtools/pkg_tarup \
65                         pkgtools/pkgin \
66                         devel/scmgit \
67                         net/isc-dhcp4 \
68                         net/isc-dhcpd4 \
69                         sysutils/cdrtools \
70                         ${PKGSRC_EXTRA_PACKAGES}
71
72 # pkgsrc options to use when building packages
73 #
74 PKGSRC_OPTIONS+=        MAKE_JOBS=${MAKE_JOBS}
75 PKGSRC_OPTIONS+=        WRKOBJDIR=/usr/pkgobj
76 PKGSRC_OPTIONS+=        PKG_DEFAULT_OPTIONS='dri inet6'
77 .if !make(gui)
78 PKGSRC_OPTIONS+=        PKG_OPTIONS.scmgit=-scmgit-gui
79 .endif
80
81 # Even though buildiso wipes the packages, our check target has to run
82 # first and old packages (listed as they appear in pkg_info) must be
83 # cleaned out in order for the pkg_add -n test we use in the check target
84 # to operate properly.
85 #
86 OLD_PKGSRC_PACKAGES?=   cdrtools-2.01.01.27nb1 \
87                         cdrecord-2.00.3nb2 \
88                         bootstrap-kit-20070205 \
89                         dfuibe_installer-1.1.6 \
90                         gettext-lib-0.14.5 \
91                         dfuibe_installer-1.1.7nb1 \
92                         dfuife_curses-1.5 \
93                         gettext-lib-0.14.6 \
94                         gettext-tools-0.14.6nb1 \
95                         libaura-3.1 \
96                         libdfui-4.2 \
97                         libinstaller-5.1 \
98                         bootstrap-kit-20080211 \
99                         cdrtools-ossdvd-2.01.1.36nb2 \
100                         isc-dhcp-base-4.0.0 \
101                         isc-dhcp-server-4.0.0
102
103 # Specify which root skeletons are required, and let the user include
104 # their own.  They are copied into ISODIR during the `customizeiso'
105 # target; each overwrites the last.
106 #
107 REQ_ROOTSKELS=  ${.CURDIR}/root
108 ROOTSKELS?=     ${REQ_ROOTSKELS}
109
110 .if make(gui)
111 ISOFILE?=               ${ISODIR}/dfly-gui.iso
112 IMGFILE?=               ${ISODIR}/dfly-gui.img
113 PKGSRC_PACKAGES+=       meta-pkgs/modular-xorg-apps \
114                         meta-pkgs/modular-xorg-drivers \
115                         meta-pkgs/modular-xorg-fonts \
116                         meta-pkgs/modular-xorg-libs \
117                         wm/fluxbox \
118                         wm/fvwm \
119                         www/firefox \
120                         print/xpdf \
121                         shells/zsh \
122                         editors/emacs \
123                         editors/vim \
124                         chat/pidgin \
125                         chat/irssi \
126                         chat/xchat \
127                         x11/modular-xorg-server \
128                         x11/rxvt-unicode \
129                         x11/eterm \
130                         lang/perl5 \
131                         editors/nano \
132                         shells/bash \
133                         devel/exctags \
134                         archivers/zip \
135                         security/sudo \
136                         www/links-gui \
137                         net/nmap \
138                         net/wget \
139                         fonts/terminus-font \
140                         net/rsync \
141                         sysutils/idesk \
142                         time/asclock \
143                         misc/screen
144 ROOTSKELS+=             ${.CURDIR}/gui
145 .endif
146
147 ISOFILE ?= ${ISODIR}/dfly.iso
148 IMGFILE ?= ${ISODIR}/dfly.img
149
150 IMGMNT ?= ${ISODIR}/mnt
151
152 # USB umass now probes starting at da8, so the usb stick is
153 # probably sitting on da8.
154 #
155 IMGUSBDEV ?= da8
156
157 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
158 # the additional '/nrelease' manually, as a safety measure.
159 #
160 NRLOBJDIR?= /usr/obj
161
162 #########################################################################
163 #                               BASE ISO TARGETS                        #
164 #########################################################################
165
166 release:        check clean buildworld1 buildkernel1 \
167                 buildiso srcs customizeiso mklocatedb \
168                 mkiso mkimg
169
170 quickrel:       check clean buildworld2 buildkernel2 \
171                 buildiso srcs customizeiso mklocatedb \
172                 mkiso mkimg
173
174 realquickrel:   check clean \
175                 buildiso srcs customizeiso mklocatedb \
176                 mkiso mkimg
177
178 restartpkgs:    check customizeiso mklocatedb mkiso mkimg
179
180 quick:          quickrel
181
182 realquick:      realquickrel
183
184
185 #########################################################################
186 #                          CORE SUPPORT TARGETS                         #
187 #########################################################################
188
189 check:
190 .if !exists(${PKGBIN_PKG_ADMIN})
191         @echo "You never bootstrapped pkgsrc on your machine.  You can install it with:"
192         @echo "    make pkgsrc_bootstrap"
193 .endif
194 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
195         @echo "The cvsup bootstrap kit is not installed.  You can install it with:"
196         @echo "    make fetch"
197 .endif
198 .if !exists (${PKGBIN_MKISOFS})
199         @echo
200         @echo "Your machine does not have cdrtools installed.  You can install it with:"
201         @echo "    make pkgsrc_cdrecord"
202 .endif
203 .if !defined(PKGSRC_PATH)
204         @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
205         @echo "package building.  For example /usr/pkgsrc.  See the Makefile"
206         @echo "in /usr if you are unfamiliar with pkgsrc."
207 .endif
208 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
209         @exit 1
210 .endif
211 .if !exists (${PKGBIN_MKISOFS})
212         @exit 1
213 .endif
214 .if !defined(PKGSRC_PATH)
215         @exit 1
216 .endif
217
218 buildworld1 buildworld2:
219         cd ${.CURDIR}/..; \
220         ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
221                 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
222
223 buildkernel1 buildkernel2:
224 .if make(gui)
225         cd ${.CURDIR}/..; \
226         for kernconf in ${KERNCONF}; do \
227                 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
228                         make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
229                         KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
230         done
231 .else
232         cd ${.CURDIR}/..; \
233         first=; \
234         for kernconf in ${KERNCONF}; do \
235                 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
236                         make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
237                         KERNCONF=$${kernconf} \
238                         $${first:+-DNO_MODULES}; \
239                 first=done; \
240         done
241 .endif
242
243 # note that we do not want to mess with any /usr/obj directories not related
244 # to buildworld, buildkernel, or nrelease, so we must supply the proper
245 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 
246 # buildkernel mechanism.
247 #
248 buildiso:
249         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
250         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
251         ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
252         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
253                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
254         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
255 .if make(gui)
256         if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
257         cd ${.CURDIR}/..; \
258         make installkernel DESTDIR=${ISOROOT} \
259         KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
260         cd ${.CURDIR}/..; \
261         make installkernel DESTDIR=${ISOROOT} \
262         KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
263         cd ${.CURDIR}/..; \
264         make installkernel DESTDIR=${ISOROOT}/kernel.smp \
265         KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
266         cd ${.CURDIR}/..; \
267         make installkernel DESTDIR=${ISOROOT}/kernel.smp \
268         KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
269                 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
270 .else
271         cd ${.CURDIR}/..; \
272         first=; \
273         for kernconf in ${KERNCONF}; do \
274                 make DESTDIR=${ISOROOT} \
275                         installkernel KERNCONF=$${kernconf} \
276                         $${first:+DESTKERNNAME=kernel.$${kernconf}} \
277                         $${first:+-DNO_MODULES}; \
278                 first=done; \
279         done
280 .endif
281         ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
282         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
283         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
284         dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
285
286 # Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
287 # Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
288 #
289 srcs:
290 .if !defined(WITHOUT_SRCS)
291         rm -f ${ISOROOT}/usr/pkgsrc-git.tgz
292         rm -f ${ISOROOT}/usr/pkgsrc
293         mkdir -p ${ISOROOT}/usr/pkgsrc
294         cd ${ISOROOT}/usr/pkgsrc && git init
295         cd ${ISOROOT}/usr/pkgsrc && \
296                 git remote add origin git://git.dragonflybsd.org/pkgsrc.git
297         cd ${ISOROOT}/usr/pkgsrc && git fetch origin
298         cd ${ISOROOT}/usr/pkgsrc && git branch vendor origin/vendor
299         cd ${ISOROOT}/usr/pkgsrc && git gc
300 .if make(gui)
301         rm -f ${ISOROOT}/usr/src-git.tgz
302         rm -rf ${ISOROOT}/usr/src
303         mkdir -p ${ISOROOT}/usr/src
304         cd ${ISOROOT}/usr/src && git init
305         cd ${ISOROOT}/usr/src && \
306                 git remote add origin git://git.dragonflybsd.org/dragonfly.git
307         cd ${ISOROOT}/usr/src && git fetch origin
308         cd ${ISOROOT}/usr/src && git branch master origin/master
309         cd ${ISOROOT}/usr/src && git gc
310 .else
311         rm -f ${ISOROOT}/usr/src-sys.tgz
312         cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
313                 -czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
314 .endif
315 .endif
316
317 # Customize the ISO by copying rootskels in reverse priority order,
318 # building packages, and doing other post-install tasks.
319 #
320 customizeiso:
321         # Copy the rootskels.  Allow sources to be owned by someone other
322         # then root (as is common when checked out via git).
323         #
324 .for ROOTSKEL in ${ROOTSKELS}
325         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
326         @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
327         @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
328 .endfor
329         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
330         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
331         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
332         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
333 .for UPGRADE_ITEM in Makefile                   \
334                      etc.${MACHINE_ARCH}        \
335                      isdn/Makefile              \
336                      rc.d/Makefile              \
337                      periodic/Makefile          \
338                      periodic/daily/Makefile    \
339                      periodic/security/Makefile \
340                      periodic/weekly/Makefile   \
341                      periodic/monthly/Makefile
342         cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
343 .endfor
344         #
345         # Setup some things & mount pkgsrc tree.  Use defensive umounts and
346         # rm -rf's to allow restarts.  Allow /usr/pkgsrc to be read-only.
347         #
348         # If we did not get past the bootstrap we clean out the entire
349         # /usr/pkg infrastructure.  Otherwise we attempt to pick up where
350         # we left off.
351         #
352         cp -p /etc/resolv.conf ${ISOROOT}/etc
353         ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
354         -@umount ${ISOROOT}/usr/pkgsrc/distfiles
355         -@umount ${ISOROOT}/usr/pkgsrc
356         -@umount ${ISOROOT}/dev
357         mkdir -p ${ISODIR}/distfiles
358         rm -rf ${ISOROOT}/usr/pkgobj
359         #
360         # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
361         # Make /usr/pkgsrc read-only for safety, else a failed umount and
362         # our rm -rf will do bad things.
363         #
364         mkdir -p ${ISOROOT}/usr/pkgobj
365         mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
366         mkdir -p ${ISOROOT}/usr/pkgsrc
367         mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
368         mount_null /dev ${ISOROOT}/dev
369         cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
370             || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
371         #
372         # Bootstrap, if not already installed, and add licenses needed
373         # for the gui release
374         #
375         test -e ${ISODIR}/.didbootstrap || \
376             rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
377                     ${ISOROOT}/var/db/pkg.refcount
378         test -e ${ISODIR}/.didbootstrap || \
379             ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap;    \
380                 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
381 .if make(gui)
382         test -e ${ISODIR}/.didbootstrap || \
383             echo ".ifdef BSD_PKG_MK     # added by nrelease" \
384                 >> ${ISOROOT}/usr/pkg/etc/mk.conf
385         test -e ${ISODIR}/.didbootstrap || \
386             echo "ACCEPTABLE_LICENSES+=openmotif-license" \
387                 >> ${ISOROOT}/usr/pkg/etc/mk.conf
388         test -e ${ISODIR}/.didbootstrap || \
389             echo "ACCEPTABLE_LICENSES+=vim-license" \
390                 >> ${ISOROOT}/usr/pkg/etc/mk.conf
391         test -e ${ISODIR}/.didbootstrap || \
392             echo ".endif                        # added by nrelease" \
393                 >> ${ISOROOT}/usr/pkg/etc/mk.conf
394 .endif
395         test -e ${ISODIR}/.didbootstrap || sync
396         test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
397         #
398         # Build and install packages, skip packages already installed
399         #
400 .for PKG in ${PKGSRC_PACKAGES}
401         ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
402             (bmake check > /dev/null 2>&1 || \
403             bmake ${PKGSRC_OPTIONS} clean build install)"
404 .endfor
405         #
406         # Remove packages which nothing depends on and clean up
407         #
408         ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
409         -umount ${ISOROOT}/usr/pkgsrc/distfiles
410         umount ${ISOROOT}/dev
411         umount ${ISOROOT}/usr/pkgsrc
412         rm -rf ${ISOROOT}/usr/pkgobj
413         rm -f ${ISOROOT}/etc/resolv.conf
414         makewhatis ${ISOROOT}/usr/local/man
415         makewhatis ${ISOROOT}/usr/pkg/man
416
417 # So locate works
418 #
419 mklocatedb:
420         ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
421                 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
422                 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
423                 /usr/libexec/locate.mklocatedb \
424                 -presort >${ISOROOT}/var/db/locate.database )
425
426 mkiso:
427         ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
428                 -R -J -o ${ISOFILE} \
429                 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
430
431
432 mkimg:
433 .if make(img)
434         if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
435         -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT};           \
436             vnconfig -u `cat ${ISODIR}/vn.which`; fi
437         @echo "STEP: determine required image size"
438         sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`;                  \
439             sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
440             dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};
441         fdisk -IB -p ${IMGFILE}
442         @echo "STEP: determine free vn device"
443         vnconfig -l | grep "not in use" | head -n 1 |                   \
444             cut -f 1 -d: > ${ISODIR}/vn.which
445         vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
446         @echo "STEP: write standard disklabel"
447         disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
448         @echo "STEP: read disklabel back"
449         disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
450         @echo "STEP: determine number of sectors of whole disk"
451         secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`;                \
452             echo "  a:  $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
453         @echo "STEP: write modified disklabel back"
454         disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
455         rm ${IMGFILE}.label
456         @echo "STEP: write bootsector"
457         disklabel -B `cat ${ISODIR}/vn.which`s1
458         boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
459         newfs /dev/`cat ${ISODIR}/vn.which`s1a
460         mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
461         cpdup ${ISOROOT} ${IMGMNT}
462         @echo "STEP: fixup ${IMGMNT}/etc/fstab"
463         echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 0" > ${IMGMNT}/etc/fstab
464         echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
465         @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
466         -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
467         echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
468         mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
469         @echo "STEP: cleanup"
470         df ${IMGMNT}
471         umount ${IMGMNT}
472         vnconfig -u `cat ${ISODIR}/vn.which`
473         rm -f ${ISODIR}/vn.which
474         rmdir ${IMGMNT}
475         @echo "STEP: done"
476 .endif
477
478 clean:
479         -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
480         -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
481         -umount ${ISOROOT}/dev > /dev/null 2>&1
482         -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT};           \
483             vnconfig -u `cat ${ISODIR}/vn.which`; fi
484         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
485         rm -rf ${ISOROOT}
486         rm -rf ${NRLOBJDIR}/nrelease
487         rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
488
489 realclean:      clean
490         rm -rf ${OBJSYS}/${KERNCONF}
491         #
492         # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
493         # override location.
494         #
495         rm -rf ${ISODIR}/packages
496         rm -rf ${ISODIR}/distfiles
497
498 fetch:
499         @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
500 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
501         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
502 .endif
503
504 pkgsrc_bootstrap:
505 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
506         mkdir -p /usr/release/bootstrap
507         (cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
508 .endif
509
510 pkgsrc_cdrecord:
511 .if !exists (${PKGBIN_MKISOFS})
512         (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
513 .endif
514
515 help all:
516         @echo "make [gui] release   - complete build from scratch"
517         @echo "make [gui] quick     - attempt to do an incremental rebuild"
518         @echo "make [gui] realquick - attempt to restart after world & kernel"
519         @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
520         @echo ""
521         @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
522
523 .PHONY: release quickrel realquickrel
524 .PHONY: installer
525 .PHONY: quick realquick
526 .PHONY: check buildworld1 buildworld2
527 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
528 .PHONY: clean realclean fetch help all srcs
529
530 .include <bsd.prog.mk>