drm - Fix deadlock in ttm pager
[dragonfly.git] / nrelease / Makefile
CommitLineData
9b29c40a
MD
1#########################################################################
2# ENHANCEMENTS #
3#########################################################################
4
f4ec1279 5# New method e.g. 'make gui release'. A series of enhancement
9b29c40a
MD
6# targes may be specified which set make variables which enhance
7# the build in various ways.
8#
1a8bb5eb
MD
9# img is now the default (produces both the .iso and .img)
10#
88821fa4 11gui installer img nopkgs:
9b29c40a 12
9b29c40a
MD
13#########################################################################
14# SETUP #
15#########################################################################
16
bd0ab7aa 17DPORTS_PATH?= /usr/dports
3fff415b
SW
18ISODIR?= /usr/release
19ISOROOT?= ${ISODIR}/root
20OBJSYS= ${.OBJDIR}/../sys
fe70af21 21GITHOST?= git.dragonflybsd.org
3fff415b 22
5cb6cda9 23MAKE_JOBS?= $$(sysctl -n hw.ncpu)
bfe20b28 24
702a95cc
SS
25# XXX makeshift fix to build the right kernel for the (target) architecture
26# We should configure this in the platform files somehow
27.if ${MACHINE_ARCH} == "i386"
91856cf5 28KERNCONF ?= GENERIC
702a95cc 29.else
91856cf5 30KERNCONF ?= X86_64_GENERIC
702a95cc 31.endif
6ca9a59c 32
c36c5990 33CHROOT_CMD?= /usr/sbin/chroot ${ISOROOT} sh -c
cc55a235 34
8abe78a1 35# User may specify extra packages in addition to the defaults
95b64753 36#
c36c5990 37DPORTS_EXTRA_PACKAGES?=
8abe78a1 38
c36c5990
SW
39# dports packages to be built and installed on the release ISO
40#
41# MISSING: csup
8abe78a1 42#
c36c5990 43DPORTS_PACKAGES?= devel/git \
0e561611 44 dns/bind-tools \
c36c5990 45 net/isc-dhcp42-server \
8abe78a1 46 sysutils/cdrtools \
44c4f44a 47 ${DPORTS_EXTRA_PACKAGES}
fbc26094 48
c36c5990 49# dports options to use when building packages
fbc26094 50#
c36c5990 51DPORTS_OPTIONS+= -DBATCH
fbc26094 52.if !make(gui)
c36c5990 53DPORTS_OPTIONS.devel_git+= -DWITHOUT_CONTRIB -DWITHOUT_PERL
fbc26094 54.endif
8188de86
MD
55
56# Specify which root skeletons are required, and let the user include
e2dbfa0b 57# their own. They are copied into ISODIR during the `customizeiso'
8188de86
MD
58# target; each overwrites the last.
59#
8f51ac0b 60REQ_ROOTSKELS= ${.CURDIR}/root
cc224c64
JS
61ROOTSKELS?= ${REQ_ROOTSKELS}
62
c36c5990 63.if make(notyet)
c843f8b0
MD
64# LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
65# chat/pidgin textproc/enchant dependency is broken
66# x11/rxvt-unicode broken configure
67# net/nmap tries to access openssl/md2.h which does not
68# exist.
69# sysutils/idesk dying on link __sync_fetch_and_add_4
70#
3f279b9e 71ISOFILE?= ${ISODIR}/dfly-gui.iso
b9c3e754 72IMGFILE?= ${ISODIR}/dfly-gui.img
88821fa4 73
0e176309
MD
74# NOTE: order important, do not sort package list
75#
76# Apps we want in the gui build but which have problems building:
77# chat/xchat link error on x86-64, something about ___progname
78#
79#
88821fa4 80.if !make(nopkgs)
0e176309 81PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-libs \
0936984e 82 meta-pkgs/modular-xorg-fonts \
0e176309
MD
83 meta-pkgs/modular-xorg-apps \
84 meta-pkgs/modular-xorg-drivers \
85 x11/libXinerama \
fbc26094 86 wm/fluxbox \
0936984e 87 wm/fvwm \
30e27f66 88 www/firefox \
fbc26094
SW
89 print/xpdf \
90 shells/zsh \
91 editors/emacs \
92 editors/vim \
fbc26094 93 chat/irssi \
0936984e 94 x11/modular-xorg-server \
fbc26094
SW
95 x11/eterm \
96 lang/perl5 \
97 editors/nano \
98 shells/bash \
99 devel/exctags \
100 archivers/zip \
101 security/sudo \
102 www/links-gui \
fbc26094
SW
103 net/wget \
104 fonts/terminus-font \
105 net/rsync \
0936984e 106 time/asclock \
1f8639a7
SW
107 misc/screen \
108 devel/scmgit-gitk
88821fa4
MD
109.endif
110
3f279b9e
SW
111ROOTSKELS+= ${.CURDIR}/gui
112.endif
113
3f279b9e 114ISOFILE ?= ${ISODIR}/dfly.iso
b9c3e754
MN
115IMGFILE ?= ${ISODIR}/dfly.img
116
60b68cbb 117IMGMNT ?= ${ISODIR}/mnt
a2f841ed
MD
118
119# USB umass now probes starting at da8, so the usb stick is
120# probably sitting on da8.
121#
9a122c9a 122IMGUSBDEV ?= da8
3f279b9e 123
5b22b655
MD
124# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
125# the additional '/nrelease' manually, as a safety measure.
126#
127NRLOBJDIR?= /usr/obj
128
8188de86
MD
129#########################################################################
130# BASE ISO TARGETS #
131#########################################################################
132
7ebbae99 133release: check clean buildworld1 buildkernel1 \
31d5c88c 134 buildiso srcs customizeiso mkiso mkimg
8188de86 135
7ebbae99 136quickrel: check clean buildworld2 buildkernel2 \
31d5c88c 137 buildiso srcs customizeiso mkiso mkimg
2e3f8f38 138
03e2a3c5 139realquickrel: check clean \
31d5c88c 140 buildiso srcs customizeiso mkiso mkimg
6ca9a59c 141
31d5c88c 142restartpkgs: check customizeiso mkiso mkimg
5af45f85 143
9b29c40a
MD
144quick: quickrel
145
146realquick: realquickrel
147
5af45f85 148
9b29c40a
MD
149#########################################################################
150# CORE SUPPORT TARGETS #
151#########################################################################
152
d2582113 153check:
c36c5990 154.if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
0936984e
MD
155 @echo
156 @echo "Your machine does not have cdrtools installed. You can install it with:"
218b6b69 157 @echo " pkg install cdrtools"
0936984e 158.endif
aa3eeb12
SW
159 @if [ ! -d ${DPORTS_PATH} ]; then \
160 echo "${DPORTS_PATH} does not exist."; \
161 echo ""; \
162 echo "Please set DPORTS_PATH to the dports tree that shall be used for"; \
163 echo "package building. The default is /usr/dports. See the Makefile in"; \
164 echo "/usr if you are unfamiliar with dports."; \
165 /usr/bin/false; \
166 fi
c36c5990 167.if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
3da8e88f 168 @/usr/bin/false
fbc26094 169.endif
aa3eeb12 170 @echo "Using ${DPORTS_PATH} as the dports tree."
2e3f8f38 171
588a679c 172buildworld1 buildworld2:
3fff415b
SW
173 cd ${.CURDIR}/..; \
174 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
175 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
6ca9a59c 176
588a679c
SS
177buildkernel1 buildkernel2:
178 cd ${.CURDIR}/..; \
588a679c 179 for kernconf in ${KERNCONF}; do \
448b21e7 180 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
3fff415b 181 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
ee7f6ff2 182 KERNCONF=$${kernconf}; \
588a679c 183 done
6ca9a59c 184
5b22b655
MD
185# note that we do not want to mess with any /usr/obj directories not related
186# to buildworld, buildkernel, or nrelease, so we must supply the proper
187# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
188# buildkernel mechanism.
189#
2b43b38c 190# Unconditionally clean out ${ISOROOT} so a previous img build
92b0ebb9
MD
191# does not blow up a future quick iso build
192#
fe70af21
MD
193# We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
194# We leave the kernel's debug variables intact.
195#
6ca9a59c 196buildiso:
92b0ebb9
MD
197 -rm -rf ${ISOROOT}
198 -chflags -R noschg ${ISOROOT}
199 rm -rf ${ISOROOT}
200 mkdir -p ${ISOROOT}
5b22b655 201 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
f4ec1279 202 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
ab64cf06
SS
203 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
204 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
21aa02d0 205 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
588a679c 206 cd ${.CURDIR}/..; \
588a679c 207 for kernconf in ${KERNCONF}; do \
1c9d98d0 208 make DESTDIR=${ISOROOT} reinstallkernel KERNCONF=$${kernconf}; \
588a679c 209 done
91856cf5 210 rm -rf ${ISOROOT}/boot/kernel.old
1c9d98d0 211 ln -sf kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
9e5f57ba 212 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
6ca9a59c
MD
213 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
214 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
8188de86 215
fe70af21
MD
216# The GUI build includes the pkgsrc tree (~1G+) while the nominal release
217# build does not.
218#
219# The GUI build includes full sources while the nominal release build
220# only includes kernel sources (~27MB).
19d86faa 221#
e2dbfa0b
TN
222srcs:
223.if !defined(WITHOUT_SRCS)
c36c5990 224.if make(notyet)
3342e40a
MD
225 rm -f ${ISOROOT}/usr/src-sys.tgz
226 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
227 cd ${ISOROOT}/usr && make pkgsrc-create-repo GITHOST=${GITHOST}
c59cfa66
SW
228 # NOTE: Adding the git gc --aggressive helps by significantly
229 # reducing the disk space required.
230 #
231 cd ${ISOROOT}/usr/pkgsrc && git gc --aggressive
3342e40a 232 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST}
c19c746b 233.else
e2dbfa0b 234 rm -f ${ISOROOT}/usr/src-sys.tgz
fe70af21 235 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
cacf78aa 236 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
fe70af21
MD
237 -cf - ./Makefile ./Makefile.inc1 ./sys | \
238 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
c19c746b 239.endif
66b79064 240.endif
19d86faa 241
5af45f85
MD
242# Customize the ISO by copying rootskels in reverse priority order,
243# building packages, and doing other post-install tasks.
244#
8188de86 245customizeiso:
5af45f85 246 # Copy the rootskels. Allow sources to be owned by someone other
3cf4b4a1 247 # than root (as is common when checked out via git).
5af45f85 248 #
8188de86
MD
249.for ROOTSKEL in ${ROOTSKELS}
250 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
5af45f85
MD
251 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
252 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
8188de86 253.endfor
7249926b 254 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
4fba3387
CP
255.for UPGRADE_ITEM in Makefile \
256 etc.${MACHINE_ARCH} \
4fba3387
CP
257 rc.d/Makefile \
258 periodic/Makefile \
259 periodic/daily/Makefile \
260 periodic/security/Makefile \
261 periodic/weekly/Makefile \
262 periodic/monthly/Makefile
263 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
20585f87 264.endfor
8abe78a1 265 #
c36c5990
SW
266 # Setup some things & mount dports tree. Use defensive umounts and
267 # rm -rf's to allow restarts. Allow /usr/dports to be read-only.
8abe78a1 268 #
1c9d98d0 269 cp /etc/resolv.conf ${ISOROOT}/etc
17f97226 270 ${CHROOT_CMD} "ldconfig -elf /lib /usr/lib /usr/lib/gcc* /usr/lib/compat"
5e885f07 271 -@umount ${ISOROOT}/usr/distfiles
2f36664e 272 -@umount ${ISOROOT}/usr/dports
45e80934 273 -@umount ${ISOROOT}/dev
2f36664e 274 rm -rf ${ISOROOT}/usr/obj/dports
8abe78a1 275 #
c36c5990
SW
276 # Mount /usr/dports, make sure /usr/distfiles is writable.
277 # Make /usr/dports read-only for safety, else a failed umount and
1eeae16f 278 # our rm -rf will do bad things.
8abe78a1 279 #
2f36664e 280 mkdir -p ${ISOROOT}/usr/dports
5e885f07 281 mkdir -p ${ISOROOT}/usr/distfiles
2f36664e 282 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
0c5de895 283 mount_null /dev ${ISOROOT}/dev
c36c5990
SW
284 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \
285 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
8abe78a1
MD
286 #
287 # Build and install packages, skip packages already installed
288 #
2f36664e 289.for PKG in ${DPORTS_PACKAGES}
c36c5990 290 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install"
2f36664e
SW
291.endfor
292.for PKG in ${DPORTS_PACKAGES}
c36c5990 293 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
8188de86 294.endfor
8abe78a1 295 #
31d5c88c 296 # Remove packages which nothing depends on, add a whatis database
c36c5990 297 # for dports manual pages, create an initial locate database and
31d5c88c 298 # clean up
8abe78a1 299 #
2f36664e 300 ${CHROOT_CMD} "yes | pkg autoremove"
c36c5990 301 ${CHROOT_CMD} "makewhatis /usr/local/man"
5e885f07 302 -umount ${ISOROOT}/usr/distfiles
2f36664e 303 umount ${ISOROOT}/usr/dports
5e885f07 304 rm -rf ${ISOROOT}/usr/dports
2f36664e 305 rm -rf ${ISOROOT}/usr/obj/dports
5e885f07 306 rm -rf ${ISOROOT}/usr/distfiles
fbc26094 307 rm -f ${ISOROOT}/etc/resolv.conf
2f36664e 308 #
2f36664e
SW
309 # Finally, update the locate(8) database
310 #
31d5c88c
SW
311 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
312 umount ${ISOROOT}/dev
c843f8b0 313 #
44c4f44a 314 # Recopy files that dports may have updated in /etc into /etc.hdd
d68fa6c5
MD
315 #
316 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
317 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
318
6ca9a59c 319mkiso:
c36c5990 320 ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
74ec6a9d 321 -R -J -o ${ISOFILE} \
64bba8c7 322 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
b9c3e754
MN
323
324mkimg:
60b68cbb 325 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
9a122c9a
MD
326 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
327 vnconfig -u `cat ${ISODIR}/vn.which`; fi
fe70af21
MD
328.ifdef IMGSIZE
329 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
330 rm -f ${IMGFILE}
331 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
332.else
3342e40a
MD
333 @echo "STEP: Determine required image size in 1GB steps"
334 @echo " Leave ~600MB of unused space"
60b68cbb 335 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
3342e40a 336 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
fe70af21 337 cut -f1 -d.`; \
c843f8b0 338 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
fe70af21
MD
339 rm -f ${IMGFILE}; \
340 truncate -s $${sz}M ${IMGFILE};
341.endif
9a122c9a
MD
342 fdisk -IB -p ${IMGFILE}
343 @echo "STEP: determine free vn device"
344 vnconfig -l | grep "not in use" | head -n 1 | \
345 cut -f 1 -d: > ${ISODIR}/vn.which
346 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
347 @echo "STEP: write standard disklabel"
348 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
349 @echo "STEP: read disklabel back"
350 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
351 @echo "STEP: determine number of sectors of whole disk"
60b68cbb 352 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
9a122c9a
MD
353 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
354 @echo "STEP: write modified disklabel back"
355 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
356 rm ${IMGFILE}.label
357 @echo "STEP: write bootsector"
358 disklabel -B `cat ${ISODIR}/vn.which`s1
359 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
360 newfs /dev/`cat ${ISODIR}/vn.which`s1a
361 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
362 cpdup ${ISOROOT} ${IMGMNT}
363 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
e36bedaf 364 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
3342e40a
MD
365 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
366 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
367 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
368 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
9a122c9a
MD
369 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
370 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
371 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
372 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
373 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
374 @echo "STEP: cleanup"
375 df ${IMGMNT}
836f3129
MD
376 sync
377 sleep 1
9a122c9a
MD
378 umount ${IMGMNT}
379 vnconfig -u `cat ${ISODIR}/vn.which`
380 rm -f ${ISODIR}/vn.which
60b68cbb 381 rmdir ${IMGMNT}
9a122c9a 382 @echo "STEP: done"
b9c3e754 383
6ca9a59c 384clean:
836f3129
MD
385 sync
386 sleep 1
5e885f07 387 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
2f36664e 388 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1
9a122c9a
MD
389 -umount ${ISOROOT}/dev > /dev/null 2>&1
390 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
391 vnconfig -u `cat ${ISODIR}/vn.which`; fi
6ca9a59c 392 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
c19c746b
MD
393 rm -rf ${ISOROOT}
394 rm -rf ${NRLOBJDIR}/nrelease
9a122c9a 395 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
6ca9a59c
MD
396
397realclean: clean
3ebedc5e 398 rm -rf ${OBJSYS}/${KERNCONF}
c19c746b
MD
399 rm -rf ${ISODIR}/packages
400 rm -rf ${ISODIR}/distfiles
6ca9a59c 401
e2dbfa0b 402help all:
5af45f85
MD
403 @echo "make [gui] release - complete build from scratch"
404 @echo "make [gui] quick - attempt to do an incremental rebuild"
405 @echo "make [gui] realquick - attempt to restart after world & kernel"
406 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
8abe78a1 407 @echo ""
c36c5990 408 @echo "DPORTS_EXTRA_PACKAGES may be used to add additional pkgs"
fe70af21
MD
409 @echo "GITHOST may be used to override git.dragonflybsd.org"
410 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
588a679c 411
e2dbfa0b
TN
412.PHONY: release quickrel realquickrel
413.PHONY: installer
9b29c40a 414.PHONY: quick realquick
e2dbfa0b 415.PHONY: check buildworld1 buildworld2
31d5c88c 416.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
796fd273 417.PHONY: clean realclean help all srcs
cc224c64 418
6ca9a59c 419.include <bsd.prog.mk>