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