1# $NetBSD: Makefile,v 1.49 2009/12/05 16:29:10 pooka Exp $ 2# 3# Consult "*.conf" for the configuration variables; this Makefile is typically 4# not edited for basic configuration changes. 5############################################################################## 6 7all: cdimages 8 9.include <bsd.own.mk> 10 11.if exists(site.conf) 12.include "site.conf" 13.endif 14 15.if !defined(RELEASE) 16.BEGIN: 17 @echo "Please set RELEASE in the environment or in site.conf to the basename" 18 @echo "of the release configuration file to use. For example:" 19 @echo "> ${MAKE} RELEASE=foo" 20 @echo "will use the configuration file foo.conf." 21 @false 22.endif 23 24.if exists(${RELEASE}.conf) 25.include "${RELEASE}.conf" 26.elif !target(.BEGIN) 27.BEGIN: 28 @echo "Error: File does not exist: ${RELEASE}.conf" 29 @false 30.endif 31 32CD_RELEASE?= 33CD_SIZE?= 650000 34RELEASENAME?= NetBSD-${CD_RELEASE} 35MKISOFS_ARGS= -A "NetBSD ${CD_RELEASE}" \ 36 -hide-rr-moved -m Split -m cdrom 37# -hide-list ${.CURDIR}/hide-iso.lst 38 39ALL_PORTS= 40.for image in ${CD_IMAGES} 41BASE_PORTS.${image}?= 42ALL_PORTS:= ${ALL_PORTS} ${BASE_PORTS.${image}} 43.endfor 44 45.if exists(${RELEASENAME}.mk) 46.include "${RELEASENAME}.mk" 47.elif !target(.BEGIN) 48.if !empty(CD_RELEASE) 49.BEGIN: 50 @echo "Error: File does not exist: ${RELEASENAME}.mk" 51 @echo "(specified by variable CD_RELEASE in ${RELEASE}.conf)" 52 @false 53.else 54.BEGIN: 55 @echo "Error: CD_RELEASE not set in ${RELEASE}.conf" 56 @false 57.endif 58.endif 59 60SUBDIR= 61 62.if !empty(ALL_PORTS:Mmacppc) 63SUBDIR+= macppc_installboot 64.endif 65 66.if !empty(SUBDIR) 67.include <bsd.subdir.mk> 68.endif 69 70.include <bsd.obj.mk> 71.include <bsd.own.mk> 72 73##### Default paths for programs ##### 74 75MKISOFS?= /usr/local/bin/mkisofs 76RSYNC?= /usr/pkg/bin/rsync 77ALPHA_IBOOT?= ${TOOL_INSTALLBOOT} -m alpha -o sunsum,append 78PMAX_IBOOT?= ${TOOL_INSTALLBOOT} -m pmax -o sunsum,append 79VAX_IBOOT?= ${TOOL_INSTALLBOOT} -m vax -o sunsum,append 80.if !empty(ALL_PORTS:Mmacppc) 81MACPPC_IBOOTDIR!= cd ${.CURDIR}/macppc_installboot && ${PRINTOBJDIR} 82.endif 83.if !empty(ALL_PORTS:Msgimips) 84SGIMIPS_SGIVOL?= ${TOOLDIR}/bin/nbsgivol 85.endif 86 87check_mkisofs: 88.if !exists(${MKISOFS}) 89 @echo "Error: File does not exist: ${MKISOFS}" 90 @echo "Please build and install mkisofs(8) utility and set MKISOFS in the environment" 91 @echo "or in site.conf to create image." 92 @false 93.endif 94 95check_rsync: 96.if !exists(${RSYNC}) 97 @echo "Error: File does not exist: ${RSYNC}" 98 @echo "Please build and install rsync(1) utility and set RSYNC in the environment" 99 @echo "or in site.conf to fetch release binaries." 100 @false 101.endif 102 103##### rsync settings ##### 104 105# rsync host; check mirrors on http://www.NetBSD.org/mirrors/#rsync 106# (note not all rsync mirrors provide NetBSD-daily) 107RSYNC_HOST?= rsync.NetBSD.org 108 109# extra path for rsync mirrors ("/pub", "/netbsd" etc.) 110RSYNC_PATH_PREFIX?= 111 112.if !target(.BEGIN) 113.if ${RELEASE} == "current" 114# daily date dir name 115BRANCH?= HEAD 116#DAILY_DIR?= yyyymmddhhmmZ 117RSYNC_PATH?= ${RSYNC_PATH_PREFIX}/NetBSD-daily/${BRANCH}/${DAILY_DIR} 118.else 119# extra suffix on pre-release ("_BETA2", "_RC5" etc.) 120RELEASE_SUFFIX?= 121RSYNC_PATH?= ${RSYNC_PATH_PREFIX}/NetBSD/${RELEASENAME}${RELEASE_SUFFIX} 122 123# alternative for NetBSD-daily sets of stable branches 124#DAILY_DIR?= yyyymmddhhmmZ 125#BRANCH?= netbsd-4 126#RSYNC_PATH?= ${RSYNC_PATH_PREFIX}/NetBSD-daily/${BRANCH}/${DAILY_DIR} 127.endif 128.endif 129 130RSYNC_SITE?= rsync://${RSYNC_HOST}${RSYNC_PATH} 131RSYNC_ARGS?= -va --delete 132RSYNC_EXCLUDE+= --exclude=/* --exclude=Split --exclude=cdrom 133 134DOWNLOADDIR?= ${.OBJDIR}/download 135DISTRIBDIR?= ${DOWNLOADDIR} 136STAGEDIR?= ${.OBJDIR}/staging 137IMAGEDIR?= ${.OBJDIR} 138EXTFILEDIR?= ${.OBJDIR}/extfiles 139EASTER_EGG?= /dev/null 140 141##### MACHINE_ARCH for possible shared sets for each (shared) port ##### 142 143MACHINE_ARCH.acorn26= arm 144MACHINE_ARCH.acorn32= arm 145MACHINE_ARCH.algor= mipsel 146MACHINE_ARCH.amiga= m68k 147MACHINE_ARCH.amigappc= powerpc 148MACHINE_ARCH.arc= mipsel 149MACHINE_ARCH.atari= m68k 150MACHINE_ARCH.bebox= powerpc 151MACHINE_ARCH.cats= arm 152MACHINE_ARCH.cesfic= m68k 153MACHINE_ARCH.cobalt= mipsel 154MACHINE_ARCH.dreamcast= sh3el 155MACHINE_ARCH.evbarm= arm 156MACHINE_ARCH.evbmips= mipsel 157MACHINE_ARCH.evbppc= powerpc 158MACHINE_ARCH.evbsh3= sh3eb 159MACHINE_ARCH.hp300= m68k 160MACHINE_ARCH.hpcarm= arm 161MACHINE_ARCH.hpcmips= mipsel 162MACHINE_ARCH.hpcsh= sh3el 163MACHINE_ARCH.iyonix= arm 164MACHINE_ARCH.luna68k= m68k 165MACHINE_ARCH.mac68k= m68k 166MACHINE_ARCH.macppc= powerpc 167MACHINE_ARCH.mipsco= mipseb 168MACHINE_ARCH.mmeye= sh3eb 169MACHINE_ARCH.mvme68k= m68k 170MACHINE_ARCH.netwinder= arm 171MACHINE_ARCH.news68k= m68k 172MACHINE_ARCH.newsmips= mipseb 173MACHINE_ARCH.next68k= m68k 174MACHINE_ARCH.ofppc= powerpc 175MACHINE_ARCH.pmax= mipsel 176MACHINE_ARCH.prep= powerpc 177MACHINE_ARCH.sandpoint= powerpc 178MACHINE_ARCH.sbmips= mipseb 179MACHINE_ARCH.sgimips= mipseb 180MACHINE_ARCH.shark= arm 181MACHINE_ARCH.sun3= m68k 182MACHINE_ARCH.x68k= m68k 183 184##### Fetched directories from FTP server ##### 185 186.if defined(ALL_PORTS) && !empty(ALL_PORTS) 187RSYNC_INCLUDE+= --include "/shared" 188RSYNC_EXCLUDE+= --exclude "/[a-z]*" \ 189 --exclude "/shared/[a-z]*" 190.endif 191 192RSYNC_ARCHS= 193.for port in ${ALL_PORTS:O:u} # { 194RSYNC_INCLUDE+= --include "/${port}" 195.if defined(MACHINE_ARCH.${port}) 196RSYNC_ARCHS+= ${MACHINE_ARCH.${port}} 197.endif 198.endfor # } 199.for arch in ${RSYNC_ARCHS:O:u} 200RSYNC_INCLUDE+= --include "/shared/${arch}" 201.endfor 202 203##### Boot info and additional options for various platforms ##### 204 205.if defined(PUBLISHER) 206MKISOFS_ARGS+= -publisher "${PUBLISHER}" 207.endif 208 209.if defined(PREPARER) 210MKISOFS_ARGS+= -p "${PREPARER}" 211.endif 212 213 214##### Per image settings ##### 215 216.for image in ${CD_IMAGES} # { 217ports:=${BASE_PORTS.${image}} 218 219.if !defined(VOLID.${image}) && !target(.BEGIN) 220.BEGIN: 221 @echo "Error: VOLID.${image} not set in ${RELEASE}.conf" 222 @false 223.endif 224 225MKISOFS_ARGS.${image}= -V "${VOLID.${image}}" 226 227pathlist.${image}:=${STAGEDIR}/${image}.pathlist 228contents.${image}:=${IMAGEDIR}/${image}.contents 229 230MKISOFS_ARGS.${image}+= -graft-points -path-list ${pathlist.${image}} 231 232.if defined(ABSTRACT.${image}) 233MKISOFS_ARGS.${image}+= -abstract ${ABSTRACT.${image}} 234.endif 235 236# Options specified in release config file 237 238EXTFILES?= 239INTFILES.${image}?= 240INTDIRS.${image}?= 241ADDFILES.${image}?= 242 243bports= # empty first 244# For a source only cd just ignore the shared/ALL directory 245.if ${ports} != "source" && exists(${DISTRIBDIR}/shared/ALL) 246bports+= shared/ALL 247.endif 248.for port in ${ports} # { 249EXTFILES+= ${EXTFILES.${port}} 250INTFILES.${image}+= ${INTFILES.${port}} 251INTDIRS.${image}+= ${INTDIRS.${port}} 252ADDFILES.${image}+= ${ADDFILES.${port}} 253MKISOFS_ARGS.${image}+= ${MKISOFS_ARGS.${port}} 254# add shared/ALL and shared/${MACHINE_ARCH} to BASE_PORTS.${image} 255bports+= ${port} 256.if defined(MACHINE_ARCH.${port}) && \ 257 exists(${DISTRIBDIR}/shared/${MACHINE_ARCH.${port}}) 258bports+= shared/${MACHINE_ARCH.${port}} 259.endif 260.endfor # } 261BASE_PORTS.${image}:= ${bports:O:u} 262 263 264# i386 265 266.if !empty(ports:Mi386) 267.if empty(INTFILES.i386:Mbootxx_cd9660) 268# non-emulation boot 269MKISOFS_ARGS.${image}+= -b ${BOOTFILE.i386} -c boot.catalog -no-emul-boot 270.else 271#2.88MB emulation boot 272MKISOFS_ARGS.${image}+= -b ${BOOTFILE.i386} -c boot.catalog 273.endif 274.endif 275 276# amd64 277 278.if !empty(ports:Mamd64) 279.if empty(INTFILES.amd64:Mbootxx_cd9660) 280# non-emulation boot 281MKISOFS_ARGS.${image}+= -b ${BOOTFILE.amd64} -c boot.catalog -no-emul-boot 282.else 283#2.88MB emulation boot 284MKISOFS_ARGS.${image}+= -b ${BOOTFILE.amd64} -c boot.catalog 285.endif 286.endif 287 288# Mac (mac68k, macppc) 289 290.if !empty(ports:Mmacppc) 291BOOTHFS= boothfs 292MKISOFS_ARGS.${image}+= -hfs -part -hide-hfs-list ${.CURDIR}/hide-hfs.lst \ 293 --macbin -map ${.CURDIR}/hfsmap.lst \ 294 -boot-hfs-file ${.OBJDIR}/${BOOTHFS} 295UUDECODE_FILES= ${BOOTHFS} 296.include <bsd.files.mk> 297.elif defined(USE_APPLE_ISO) || !empty(ports:Mmac68k) 298MKISOFS_ARGS.${image}+= -apple --macbin -map ${.CURDIR}/hfsmap.lst 299.endif 300 301# Sun (sparc, sparc64, sun3) 302 303SUN_BOOT_ARGS.${image}:= 304.if !empty(ports:Msparc*) || !empty(ports:Msun3*) # { 305SUN_BOOT.123:= - 306SUN_BOOT.4:= - 307SUN_BOOT.5:= - 308 309.if !empty(ports:Msparc) 310SUN_BOOT.123:= ${BOOTFILE.sparc} 311.endif 312 313.if !empty(ports:Msun3) # { 314.if !defined(BOOTFILE.sun3x) 315# NetBSD >= 1.4; sun3 and sun3x are the same 316SUN_BOOT.5:= ${BOOTFILE.sun3} 317.endif 318SUN_BOOT.4:= ${BOOTFILE.sun3} 319.endif # } 320 321.if !empty(ports:Msun3x) && defined(BOOTFILE.sun3x) 322# NetBSD < 1.4; sun3 and sun3x are separate 323SUN_BOOT.5:= ${BOOTFILE.sun3x} 324.endif 325 326.if !empty(ports:Msparc64) # { 327.if (${SUN_BOOT.5} != "-") 328# add warning 329SUN_BOOT.5:= ${SUN_BOOT.5} ${BOOTFILE.sparc64} 330.else 331SUN_BOOT.5:= ${BOOTFILE.sparc64} 332.endif 333.endif # } 334 335SUN_BOOT_ARGS.${image}:= ${SUN_BOOT.123} ${SUN_BOOT.123} ${SUN_BOOT.123} ${SUN_BOOT.4} ${SUN_BOOT.5} 336 337.if empty(SUN_BOOT_ARGS.${image}:N/dev/null) 338SUN_BOOT_ARGS.${image}:= 339.endif 340.endif # } 341 342.endfor # image in ${CD_IMAGES} # } 343 344##### Additional options for host OS's ##### 345 346# (USE_APPLE_ISO is tested above) 347 348.if defined(USE_ROCK_RIDGE) 349MKISOFS_ARGS+= -r 350.endif 351 352.if defined(USE_LONG_NAMES) 353MKISOFS_ARGS+= -l 354.endif 355 356.if defined(USE_TRANS_TBL) 357MKISOFS_ARGS+= -T 358.endif 359 360.if defined(USE_JOLIET) 361MKISOFS_ARGS+= -J -hide-joliet-list ${.CURDIR}/hide-jol.lst 362.if defined(USE_TRANS_TBL) 363MKISOFS_ARGS+= -hide-joliet-trans-tbl 364.endif 365.endif 366 367##### File extract rule ##### 368 369USE-FILE: .USE 370 @if [ ! -r $@ ]; then case $> in \ 371 /*,link) \ 372 echo "cp ${>:S/,link$//} $@"; \ 373 cp ${>:S/,link$//} $@;; \ 374 *,link) \ 375 echo "cp `pwd -P`/${>:S/,link$//} $@"; \ 376 cp `pwd -P`/${>:S/,link$//} $@;; \ 377 *.tgz,*) \ 378 echo "Extracting: $> --> $@..."; \ 379 ${TOOL_PAX} -rnz -f ${>:C/,.*$//} ${>:C/^.*,//} ; \ 380 cp ${>:C/^.*,//} $@; rm -rf ${>:C/^.*,//} ;; \ 381 *.gz) echo "gunzip -c <$> >$@"; gunzip -c <$> >$@;; \ 382 *) echo "Unknown archive method for $@"; false;; \ 383 esac; else true; fi 384 385##### Makefile rules ##### 386 387.for image in ${CD_IMAGES} # { 388cdimages: ${IMAGEDIR}/${image}.iso 389 390stage-${image}: 391 mkdir -p ${STAGEDIR}/${image} ${EXTFILEDIR} 392 rm -f ${pathlist.${image}} ${contents.${image}} 393.if defined(BASE_PORTS.${image}) && !empty(BASE_PORTS.${image}) 394.for dir in ${INTDIRS.${image}} 395 mkdir -p ${STAGEDIR}/${image}/${dir} 396.endfor 397.for arch in ${BASE_PORTS.${image}} 398 @echo "${arch}=${DISTRIBDIR}/${arch}" >> ${pathlist.${image}} 399 @echo "${arch}" >> ${contents.${image}} 400.endfor 401.endif 402 403extfileprep: 404.for file in ${EXTFILES} # { 405extfileprep: ${EXTFILEDIR}/${file:C/:.*$//} 406${EXTFILEDIR}/${file:C/:.*$//}: ${DISTRIBDIR}/${file:C/^.*://} USE-FILE 407${DISTRIBDIR}/${file:C/^.*://}: .PHONY 408.endfor # } 409 410fileprep-${image}: 411.for file in ${INTFILES.${image}} # { 412fileprep-${image}: ${STAGEDIR}/${image}/${file:C/:.*$//} 413${STAGEDIR}/${image}/${file:C/:.*$//}: ${DISTRIBDIR}/${file:C/^.*://} USE-FILE 414${DISTRIBDIR}/${file:C/^.*://}: .PHONY 415.endfor # } 416.for file in ${ADDFILES.${image}} # { 417fileprep-${image}: ${STAGEDIR}/${image}/${file:C/:.*$//} 418${STAGEDIR}/${image}/${file:C/:.*$//}: ${file:C/^.*://} USE-FILE 419${file:C/^.*://}: .PHONY 420.endfor # } 421 422.if !empty(BASE_PORTS.${image}:Mmacppc) 423fileprep-${image}: ${BOOTHFS} 424.endif 425 426# Size the CD image. This is done via the following formula: 427# 1. Size the image produced by mkisofs. 428# 2. Add images added by distrib/common/sunbootcd.sh by rounding to a 320k 429# boundary and adding each Sun image rounded to a 320k boundary. 430# 3. Add bootfile sizes rounded up to 512 bytes for pmax and vax. 431# 4. Round up to a 32k boundary, then add another 32k for TAO padding. 432 433SGIVOLHDR.size= 4096 434 435size-${image}: stage-${image} extfileprep fileprep-${image} check_mkisofs 436 @size=$$((`cd ${STAGEDIR}/${image} && \ 437 ${MKISOFS} ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} \ 438 -print-size . 2>&1 \ 439 | tee /dev/stderr \ 440 | ${TOOL_SED} '/=/!d;s/^[^=]*=//'` * 2048)) && \ 441 if [ "${SUN_BOOT_ARGS.${image}}" != "" ]; then \ 442 size=$$(($$(($$size + 327679)) / 327680 * 327680)) && \ 443 bootfiles=`for f in ${SUN_BOOT_ARGS.${image}:N-:O}; do echo $$f; done | uniq` && \ 444 for f in $$bootfiles; do \ 445 bfsize=$$(${TOOL_STAT} -f '%z' $$f) && \ 446 size=$$(($$size + $$(($$(($$bfsize + 327679)) / 327680 * 327680)))); \ 447 done; \ 448 fi && \ 449 if [ "${BASE_PORTS.${image}:Mpmax}" != "" ]; then \ 450 size=$$(($$size + $$(($$(($$(${TOOL_STAT} -f '%z' ${BOOTFILE.pmax}) + 511)) / 512 * 512)))); \ 451 fi && \ 452 if [ "${BASE_PORTS.${image}:Mvax}" != "" ]; then \ 453 size=$$(($$size + $$(($$(($$(${TOOL_STAT} -f '%z' ${BOOTFILE.vax}) + 511)) / 512 * 512)))); \ 454 fi && \ 455 if [ "${BASE_PORTS.${image}:Msgimips}" != "" -a \ 456 "${EXTFILES.sgimips}" != "" ]; then \ 457 size=$$(($$size + ${SGIVOLHDR.size} * 512)); \ 458 fi && \ 459 size=$$(($$(($$size + 16383)) / 16384 * 16384 + 32768)) && \ 460 sizek=$$(($$size / 1024)) && \ 461 echo "Projected size of ${image}.iso: $$size bytes ($${sizek}K)." && \ 462 if [ $$sizek -gt ${CD_SIZE} ]; then echo "Image too large for ${CD_SIZE} KB CD!"; false; fi 463 464# Actually build the image with all the bootstrap goo.... 465 466.if !empty(BASE_PORTS.${image}:Mmacppc) 467${IMAGEDIR}/${image}.iso: all-macppc_installboot 468.endif 469 470${IMAGEDIR}/${image}.iso: size-${image} check_mkisofs 471 @sort -o ${contents.${image}} ${contents.${image}} 472.if defined(LOG_MKISOFS) 473 cd ${STAGEDIR}/${image} && ${MKISOFS} -o $@ ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} -v -v . >${IMAGEDIR}/${image}.iso.log 2>&1 474.else 475 cd ${STAGEDIR}/${image} && ${MKISOFS} -o $@ ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} . 476.endif 477.if !empty(SUN_BOOT_ARGS.${image}) 478 SUNLABEL=${TOOL_SUNLABEL:Q} \ 479 ${HOST_SH} ${NETBSDSRCDIR}/distrib/common/sunbootcd.sh \ 480 ${.TARGET} ${SUN_BOOT_ARGS.${image}} 481.endif 482.if !empty(BASE_PORTS.${image}:Mmacppc) 483 ${MACPPC_IBOOTDIR}/macppc_installboot \ 484 $@ ${EXTFILEDIR}/macppc.bootxx /ofwboot 485.endif 486.if !empty(BASE_PORTS.${image}:Mpmax) 487 ${PMAX_IBOOT} $@ ${BOOTFILE.pmax} 488.endif 489.if !empty(BASE_PORTS.${image}:Mvax) 490 ${VAX_IBOOT} $@ ${BOOTFILE.vax} 491.endif 492.if !empty(BASE_PORTS.${image}:Malpha) 493 ${ALPHA_IBOOT} $@ ${BOOTFILE.alpha} 494.endif 495.if !empty(BASE_PORTS.${image}:Msgimips) && defined(EXTFILES.sgimips) 496 @echo "Prepending SGI volume header" 497 mv $@ $@.raw 498 dd if=/dev/zero of=$@.tmp bs=512 count=${SGIVOLHDR.size} 499 dd if=$@.raw of=$@.tmp bs=512 seek=${SGIVOLHDR.size} 500 ${SGIMIPS_SGIVOL} -f -i -h ${SGIVOLHDR.size} $@.tmp 501 ${SGIMIPS_SGIVOL} -f -w aoutboot ${STAGEDIR}/${image}/aoutboot $@.tmp 502 ${SGIMIPS_SGIVOL} -f -w ip2xboot ${STAGEDIR}/${image}/ip2xboot $@.tmp 503 ${SGIMIPS_SGIVOL} -f -w ip3xboot ${STAGEDIR}/${image}/ip3xboot $@.tmp 504 mv $@.tmp $@ 505 rm -f $@.raw $@.tmp 506.endif 507 @echo Rounding up to 32k boundary and padding 32k.... 508 @size=$$(${TOOL_STAT} -f '%z' $@); \ 509 pad=$$(( 32768 - ( $$size & 32767 ) )); \ 510 [ $$pad = 32768 ] || \ 511 dd if=/dev/zero bs=1 count=$$pad >>$@ 2>/dev/null 512 513.endfor # image in ${CD_IMAGES} # } 514 515fetch: check_rsync 516 @mkdir -p ${DISTRIBDIR} 517 @echo Fetching distributions.... 518 ${RSYNC} ${RSYNC_INCLUDE} ${RSYNC_ARGS} ${RSYNC_EXCLUDE} ${RSYNC_SITE}/ ${DISTRIBDIR}/ 519 520clean: cleanstagedir cleanimages 521cleandir distclean: cleandownloaddir 522 523cleanimages: 524.for image in ${CD_IMAGES} 525 -rm -f ${IMAGEDIR}/${image}.iso ${IMAGEDIR}/${image}.iso.log \ 526 ${contents.${image}} 527.endfor 528 529cleanstagedir: 530 -rm -rf ${STAGEDIR} ${EXTFILEDIR} 531 532cleandownloaddir: 533 -rm -rf ${DOWNLOADDIR} 534