1# $NetBSD: Makefile,v 1.5 2001/01/17 02:07:25 tv Exp $ 2# 3# Consult "*.conf" for the configuration variables; this Makefile is typically 4# not edited for basic configuration changes. 5############################################################################## 6 7all: 8 9.if exists(site.conf) 10.include "site.conf" 11.endif 12 13.if !defined(RELEASE) 14.BEGIN: 15 @echo "Please set RELEASE in the environment or in site.conf to the basename" 16 @echo "of the release configuration file to use. For example:" 17 @echo "> ${MAKE} RELEASE=foo" 18 @echo "will use the configuration file foo.conf." 19 @false 20.endif 21 22.if exists(${RELEASE}.conf) 23.include "${RELEASE}.conf" 24.elif !target(.BEGIN) 25.BEGIN: 26 @echo "Error: File does not exist: ${RELEASE}.conf" 27 @false 28.endif 29 30CD_RELEASE?= 31RELEASENAME= NetBSD-${CD_RELEASE} 32MKISOFS_ARGS= -f -A "NetBSD ${CD_RELEASE}" \ 33 -hide-rr-moved -m Split -m cdrom 34# -hide-list ${.CURDIR}/hide-iso.lst 35 36ALL_PORTS= 37.for image in ${CD_IMAGES} 38BASE_PORTS.${image}?= 39ALL_PORTS:= ${ALL_PORTS} ${BASE_PORTS.${image}} 40.endfor 41 42.if exists(${RELEASENAME}.mk) 43.include "${RELEASENAME}.mk" 44.elif !target(.BEGIN) 45.if !empty(CD_RELEASE) 46.BEGIN: 47 @echo "Error: File does not exist: ${RELEASENAME}.mk" 48 @echo "(specified by variable CD_RELEASE in ${RELEASE}.conf)" 49 @false 50.else 51.BEGIN: 52 @echo "Error: CD_RELEASE not set in ${RELEASE}.conf" 53 @false 54.endif 55.endif 56 57SUBDIR= 58 59.if !empty(ALL_PORTS:Mmacppc) 60SUBDIR+= macppc_installboot 61.endif 62 63.if !empty(SUBDIR) 64.include <bsd.subdir.mk> 65.endif 66 67.include <bsd.obj.mk> 68 69##### Default paths for programs ##### 70 71MKISOFS?= /usr/pkg/bin/mkisofs 72MKSUNBOOTCD?= /usr/src/distrib/utils/mksunbootcd/mksunbootcd 73RSYNC?= /usr/pkg/bin/rsync 74ALPHA_IBOOT?= /sys/arch/alpha/stand/installboot/installboot 75PMAX_IBOOT?= /sys/arch/pmax/stand/installboot/installboot 76VAX_IBOOT?= /sys/arch/vax/stand/installboot/installboot 77.if !empty(ALL_PORTS:Mmacppc) 78MACPPC_IBOOTDIR!= cd ${.CURDIR}/macppc_installboot && ${MAKE} print-objdir 79.endif 80 81RSYNC_SITE?= rsync://rsync.netbsd.org/NetBSD/ 82RSYNC_ARGS?= -va --delete 83RSYNC_EXCLUDE+= --exclude=/* --exclude=Split --exclude=cdrom 84 85DISTDIR?= ${.OBJDIR}/download 86STAGEDIR?= ${.OBJDIR}/staging 87IMAGEDIR?= ${.OBJDIR} 88EXTFILEDIR?= ${.OBJDIR}/extfiles 89EASTER_EGG?= /dev/null 90 91RELEASE_SUBDIR?=${RELEASENAME} 92 93##### MACHINE_ARCH for possible shared sets for each port ##### 94 95MACHINE_ARCH.amiga= m68k 96MACHINE_ARCH.amigappc= powerpc 97MACHINE_ARCH.arc= mipsel 98MACHINE_ARCH.atari= m68k 99MACHINE_ARCH.bebox= powerpc 100MACHINE_ARCH.cobalt= mipsel 101MACHINE_ARCH.hp300= m68k 102MACHINE_ARCH.hpcmips= mipsel 103MACHINE_ARCH.luna68k= m68k 104MACHINE_ARCH.mac68k= m68k 105MACHINE_ARCH.macppc= powerpc 106MACHINE_ARCH.mipsco= mipseb 107MACHINE_ARCH.mvme68k= m68k 108MACHINE_ARCH.news68k= m68k 109MACHINE_ARCH.newsmips= mipseb 110MACHINE_ARCH.next68k= m68k 111MACHINE_ARCH.ofppc= powerpc 112MACHINE_ARCH.pmax= mipsel 113MACHINE_ARCH.prep= powerpc 114MACHINE_ARCH.sgimips= mipseb 115MACHINE_ARCH.sun3= m68k 116MACHINE_ARCH.sun3x= m68k 117MACHINE_ARCH.x68k= m68k 118 119##### Fetched directories from FTP server ##### 120 121.if defined(ALL_PORTS) && !empty(ALL_PORTS) 122RSYNC_INCLUDE+= --include "/${RELEASENAME}/" \ 123 --include "/${RELEASENAME}/shared/" 124RSYNC_EXCLUDE+= --exclude "/${RELEASENAME}/[a-z]*" \ 125 --exclude "/${RELEASENAME}/shared/[a-z]*/" 126.endif 127 128.for port in ${ALL_PORTS} 129RSYNC_INCLUDE+= --include "/${RELEASENAME}/${port}/" 130.if defined(MACHINE_ARCH.${port}) 131RSYNC_INCLUDE+= --include "/${RELEASENAME}/${MACHINE_ARCH.${port}}/" \ 132 --include "/${RELEASENAME}/shared/${MACHINE_ARCH.${port}}/" 133.endif 134.endfor 135 136##### Boot info and additional options for various platforms ##### 137 138.if defined(PUBLISHER) 139MKISOFS_ARGS+= -P "${PUBLISHER}" 140.endif 141 142.if defined(PREPARER) 143MKISOFS_ARGS+= -p "${PREPARER}" 144.endif 145 146.for image in ${CD_IMAGES} 147ports:=${BASE_PORTS.${image}} 148 149.if !defined(VOLID.${image}) && !target(.BEGIN) 150.BEGIN: 151 @echo "Error: VOLID.${image} not set in ${RELEASE}.conf" 152 @false 153.endif 154 155MKISOFS_ARGS.${image}= -V "${VOLID.${image}}" 156 157.if defined(ABSTRACT.${image}) 158MKISOFS_ARGS.${image}+= -abstract ${ABSTRACT.${image}} 159.endif 160 161# Options specified in release config file 162 163EXTFILES?= 164INTFILES.${image}?= 165INTDIRS.${image}?= 166ADDFILES.${image}?= 167 168.for port in ${ports} 169EXTFILES+= ${EXTFILES.${port}} 170INTFILES.${image}+= ${INTFILES.${port}} 171INTDIRS.${image}+= ${INTDIRS.${port}} 172ADDFILES.${image}+= ${ADDFILES.${port}} 173MKISOFS_ARGS.${image}+= ${MKISOFS_ARGS.${port}} 174.endfor 175 176# i386 177 178.if !empty(ports:Mi386) 179MKISOFS_ARGS.${image}+= -b ${BOOTFILE.i386} -c boot.catalog 180.endif 181 182# Mac (mac68k, macppc) 183 184.if !empty(ports:Mmacppc) 185MKISOFS_ARGS.${image}+= -hfs -part -hide-hfs-list ${.CURDIR}/hide-hfs.lst \ 186 --macbin -map ${.CURDIR}/hfsmap.lst \ 187 -boot-hfs-file ${MACPPC_IBOOTDIR}/macppcboot.raw 188.elif defined(USE_APPLE_ISO) || !empty(ports:Mmac68k) 189MKISOFS_ARGS.${image}+= -apple --macbin -map ${.CURDIR}/hfsmap.lst 190.endif 191 192# Sun (sparc, sparc64, sun3) 193 194SUN_BOOT_ARGS.${image}:= 195.if !empty(ports:Msparc*) || !empty(ports:Msun3*) 196SUN_BOOT.123:= /dev/null 197SUN_BOOT.4:= /dev/null 198SUN_BOOT.5:= /dev/null 199 200.if !empty(ports:Msparc) 201SUN_BOOT.123:= ${BOOTFILE.sparc} 202.endif 203 204.if !empty(ports:Msun3) 205.if !defined(BOOTFILE.sun3x) 206# NetBSD >= 1.4; sun3 and sun3x are the same 207SUN_BOOT.5:= ${BOOTFILE.sun3} 208.endif 209SUN_BOOT.4:= ${BOOTFILE.sun3} 210.endif 211 212.if !empty(ports:Msun3x) && defined(BOOTFILE.sun3x) 213# NetBSD < 1.4; sun3 and sun3x are separate 214SUN_BOOT.5:= ${BOOTFILE.sun3x} 215.endif 216 217.if !empty(ports:Msparc64) 218.if (${SUN_BOOT.5} != "/dev/null") 219# add warning 220SUN_BOOT.5:= ${SUN_BOOT.5} ${BOOTFILE.sparc64} 221.else 222SUN_BOOT.5:= ${BOOTFILE.sparc64} 223.endif 224.endif 225 226SUN_BOOT_ARGS.${image}:= ${SUN_BOOT.123} ${SUN_BOOT.123} ${SUN_BOOT.123} ${SUN_BOOT.4} ${SUN_BOOT.5} 227 228.if empty(SUN_BOOT_ARGS.${image}:N/dev/null) 229SUN_BOOT_ARGS.${image}:= 230.endif 231.endif 232 233.endfor 234 235##### Additional options for host OS's ##### 236 237# (USE_APPLE_ISO is tested above) 238 239.if defined(USE_ROCK_RIDGE) 240MKISOFS_ARGS+= -r 241.endif 242 243.if defined(USE_LONG_NAMES) 244MKISOFS_ARGS+= -l 245.endif 246 247.if defined(USE_TRANS_TBL) 248MKISOFS_ARGS+= -T 249.endif 250 251.if defined(USE_JOLIET) 252MKISOFS_ARGS+= -J -hide-joliet-list ${.CURDIR}/hide-jol.lst 253.if defined(USE_TRANS_TBL) 254MKISOFS_ARGS+= -hide-joliet-trans-tbl 255.endif 256.endif 257 258##### File extract rule ##### 259 260USE-FILE: .USE 261 @if [ ! -r $@ ]; then case $> in \ 262 /*,link) \ 263 echo "ln -sf ${>:S/,link$//} $@"; \ 264 ln -sf ${>:S/,link$//} $@;; \ 265 *,link) \ 266 echo "ln -sf `pwd -P`/${>:S/,link$//} $@"; \ 267 ln -sf `pwd -P`/${>:S/,link$//} $@;; \ 268 *.tgz,*) \ 269 echo "Extracting: $> --> $@..."; \ 270 tar --fast-read -xzOf ${>:C/,.*$//} ${>:C/^.*,//} >$@;; \ 271 *.gz) echo "gunzip -c <$> >$@"; gunzip -c <$> >$@;; \ 272 *) echo "Unknown archive method for $@"; false;; \ 273 esac; else true; fi 274 275##### Makefile rules ##### 276 277.for image in ${CD_IMAGES} 278all: ${IMAGEDIR}/${image}.iso 279 280stage-${image}: 281 mkdir -p ${STAGEDIR}/${image} ${EXTFILEDIR} 282.if defined(BASE_PORTS.${image}) && !empty(BASE_PORTS.${image}) 283.if !empty(RELEASE_SUBDIR) 284 mkdir -p ${STAGEDIR}/${image}/${RELEASE_SUBDIR} 285.endif 286.for dir in ${INTDIRS.${image}} 287 mkdir -p ${STAGEDIR}/${image}/${dir} 288.endfor 289.for arch in ${BASE_PORTS.${image}} 290 ln -sf `cd ${DISTDIR} && pwd -P`/${RELEASENAME}/${arch} ${STAGEDIR}/${image}/${RELEASE_SUBDIR}/ 291.endfor 292.endif 293 294extfileprep: 295.for file in ${EXTFILES} 296extfileprep: ${EXTFILEDIR}/${file:C/:.*$//} 297${EXTFILEDIR}/${file:C/:.*$//}: ${DISTDIR}/${RELEASENAME}/${file:C/^.*://} USE-FILE 298${DISTDIR}/${RELEASENAME}/${file:C/^.*://}: .PHONY 299.endfor 300 301fileprep-${image}: 302.for file in ${INTFILES.${image}} 303fileprep-${image}: ${STAGEDIR}/${image}/${file:C/:.*$//} 304${STAGEDIR}/${image}/${file:C/:.*$//}: ${DISTDIR}/${RELEASENAME}/${file:C/^.*://} USE-FILE 305${DISTDIR}/${RELEASENAME}/${file:C/^.*://}: .PHONY 306.endfor 307.for file in ${ADDFILES.${image}} 308fileprep-${image}: ${STAGEDIR}/${image}/${file:C/:.*$//} 309${STAGEDIR}/${image}/${file:C/:.*$//}: ${file:C/^.*://} USE-FILE 310${file:C/^.*://}: .PHONY 311.endfor 312 313# Size the CD image. This is done via the following formula: 314# 1. Size the image produced by mkisofs. 315# 2. Add images added by mksunbootcd by rounding to a 320k boundary and 316# adding each Sun image rounded to a 320k boundary. 317# 3. Add 64k if macppc is included (ofwboot munged to one 64k block). 318# 4. Add bootfile sizes rounded up to 512 bytes for pmax and vax. 319# 5. Round up to a 32k boundary, then add another 32k for TAO padding. 320 321.if !empty(BASE_PORTS.${image}:Mmacppc) 322size-${image}: all-macppc_installboot 323.endif 324 325size-${image}: stage-${image} extfileprep fileprep-${image} 326 @size=$$((`cd ${STAGEDIR}/${image} && ${MKISOFS} ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} -print-size . 2>&1 | tee /dev/stderr | sed '/=/!d;s/^[^=]*=//'` * 2048)) && \ 327 if [ "${SUN_BOOT_ARGS.${image}}" != "" ]; then \ 328 size=$$(($$(($$size + 327679)) / 327680 * 327680)) && \ 329 bootfiles=`for f in ${SUN_BOOT_ARGS.${image}:N/dev/null:O}; do echo $$f; done | uniq` && \ 330 for f in $$bootfiles; do \ 331 bfsize=`ls -l $$f | awk '{print $$5}'` && \ 332 size=$$(($$size + $$(($$(($$bfsize + 327679)) / 327680 * 327680)))); \ 333 done; \ 334 fi && \ 335 if [ "${BASE_PORTS.${image}:Mmacppc}" != "" ]; then \ 336 size=$$(($$size + 65536)); \ 337 fi && \ 338 if [ "${BASE_PORTS.${image}:Mpmax}" != "" ]; then \ 339 size=$$(($$size + $$(($$((`ls -l ${BOOTFILE.pmax} | awk '{print $$5}'` + 511)) / 512 * 512)))); \ 340 fi && \ 341 if [ "${BASE_PORTS.${image}:Mvax}" != "" ]; then \ 342 size=$$(($$size + $$(($$((`ls -l ${BOOTFILE.vax} | awk '{print $$5}'` + 511)) / 512 * 512)))); \ 343 fi && \ 344 size=$$(($$(($$size + 16383)) / 16384 * 16384 + 32768)) && \ 345 sizek=$$(($$size / 1024)) && \ 346 echo "Projected size of ${image}.iso: $$size bytes ($${sizek}K)." && \ 347 if [ $$sizek -gt 666000 ]; then echo "Image too large for 74-minute CD!"; false; fi 348 349# Actually build the image with all the bootstrap goo.... 350 351${IMAGEDIR}/${image}.iso: fetch size-${image} 352.if defined(LOG_MKISOFS) 353 cd ${STAGEDIR}/${image} && ${MKISOFS} -o $@ ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} -v -v . >${IMAGEDIR}/${image}.iso.log 2>&1 354.else 355 cd ${STAGEDIR}/${image} && ${MKISOFS} -o $@ ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} . 356.endif 357.if !empty(SUN_BOOT_ARGS.${image}) 358 ${MKSUNBOOTCD} -c 640 $@ ${SUN_BOOT_ARGS.${image}} 359.endif 360.if !empty(BASE_PORTS.${image}:Mmacppc) 361 @blknum=$$((`ls -l $@ | awk '{print $$5}'` / 512)) && \ 362 ${MACPPC_IBOOTDIR}/macppc_installboot $@ $$blknum 756 363 dd if=${EXTFILEDIR}/macppc.ofwboot bs=64k count=1 conv=sync >>$@ 2>/dev/null 364.endif 365.if !empty(BASE_PORTS.${image}:Mpmax) 366 ${PMAX_IBOOT} -sa $@ ${BOOTFILE.pmax} 367.endif 368.if !empty(BASE_PORTS.${image}:Mvax) 369 ${VAX_IBOOT} -sa $@ ${BOOTFILE.vax} 370.endif 371.if !empty(BASE_PORTS.${image}:Malpha) 372 ${ALPHA_IBOOT} -s $@ ${BOOTFILE.alpha} 373.endif 374 @echo Rounding up to 32k boundary and padding 32k.... 375 @size=`ls -l $@ | awk '{print $$5}'` && \ 376 newsize=$$(($$(($$size + 32767)) / 32768 * 32768)) && \ 377 dd if=/dev/zero bs=512 count=$$(($$(($$newsize - $$size)) / 512)) >>$@ 2>/dev/null 378 dd if=${EASTER_EGG} bs=32768 count=1 conv=sync >>$@ 2>/dev/null 379 380.endfor 381 382fetch: 383.if !defined(NO_FETCH) 384 @mkdir -p ${DISTDIR} 385 @echo Fetching distributions.... 386 @${RSYNC} ${RSYNC_INCLUDE} ${RSYNC_ARGS} ${RSYNC_EXCLUDE} ${RSYNC_SITE} ${DISTDIR} 387.endif 388 389clean: cleanstagedir cleanimages 390cleandir distclean: cleandistdir 391 392cleanimages: 393.for image in ${CD_IMAGES} 394 -rm -f ${IMAGEDIR}/${image}.iso ${IMAGEDIR}/${image}.iso.log 395.endfor 396 397cleanstagedir: 398 -rm -rf ${STAGEDIR} ${EXTFILEDIR} 399 400cleandistdir: 401 -rm -rf ${DISTDIR} 402