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