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