summaryrefslogtreecommitdiff
path: root/distrib/cdrom/Makefile
blob: c9b289641793367c490d9ac907fa8cf173237036 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# $NetBSD: Makefile,v 1.20 2003/07/26 17:06:38 salo Exp $
#
# Consult "*.conf" for the configuration variables; this Makefile is typically
# not edited for basic configuration changes.
##############################################################################

all:

.if exists(site.conf)
.include "site.conf"
.endif

.if !defined(RELEASE)
.BEGIN:
	@echo "Please set RELEASE in the environment or in site.conf to the basename"
	@echo "of the release configuration file to use.  For example:"
	@echo "> ${MAKE} RELEASE=foo"
	@echo "will use the configuration file foo.conf."
	@false
.endif

.if exists(${RELEASE}.conf)
.include "${RELEASE}.conf"
.elif !target(.BEGIN)
.BEGIN:
	@echo "Error: File does not exist: ${RELEASE}.conf"
	@false
.endif

CD_RELEASE?=
CD_SIZE?=		650000
RELEASENAME?=		NetBSD-${CD_RELEASE}
MKISOFS_ARGS=		-A "NetBSD ${CD_RELEASE}" \
			-hide-rr-moved -m Split -m cdrom
#			-hide-list ${.CURDIR}/hide-iso.lst

ALL_PORTS=
.for image in ${CD_IMAGES}
BASE_PORTS.${image}?=
ALL_PORTS:=		${ALL_PORTS} ${BASE_PORTS.${image}}
.endfor

.if exists(${RELEASENAME}.mk)
.include "${RELEASENAME}.mk"
.elif !target(.BEGIN)
.if !empty(CD_RELEASE)
.BEGIN:
	@echo "Error: File does not exist: ${RELEASENAME}.mk"
	@echo "(specified by variable CD_RELEASE in ${RELEASE}.conf)"
	@false
.else
.BEGIN:
	@echo "Error: CD_RELEASE not set in ${RELEASE}.conf"
	@false
.endif
.endif

SUBDIR=

.if !empty(ALL_PORTS:Mmacppc)
SUBDIR+=	macppc_installboot
.endif

.if !empty(SUBDIR)
.include <bsd.subdir.mk>
.endif

.include <bsd.obj.mk>
.include <bsd.own.mk>

##### Default paths for programs #####

MKISOFS?=	/usr/pkg/bin/mkisofs
RSYNC?=		/usr/pkg/bin/rsync
ALPHA_IBOOT?=	${TOOL_INSTALLBOOT} -m alpha -o sunsum,append
PMAX_IBOOT?=	${TOOL_INSTALLBOOT} -m pmax -o sunsum,append
VAX_IBOOT?=	${TOLL_INSTALLBOOT} -m vax -o sunsum,append
.if !empty(ALL_PORTS:Mmacppc)
MACPPC_IBOOTDIR!= cd ${.CURDIR}/macppc_installboot && ${PRINTOBJDIR}
.endif

RSYNC_SITE?=	rsync://rsync.NetBSD.org/NetBSD/${RELEASENAME}/
RSYNC_ARGS?=	-va --delete
RSYNC_EXCLUDE+=	--exclude=/* --exclude=Split --exclude=cdrom

DISTRIBDIR?=	${.OBJDIR}/download
STAGEDIR?=	${.OBJDIR}/staging
IMAGEDIR?=	${.OBJDIR}
EXTFILEDIR?=	${.OBJDIR}/extfiles
EASTER_EGG?=	/dev/null

##### MACHINE_ARCH for possible shared sets for each (shared) port #####

MACHINE_ARCH.acorn26=	arm
MACHINE_ARCH.acorn32=	arm
MACHINE_ARCH.algor=	mipsel
MACHINE_ARCH.amiga=	m68k
MACHINE_ARCH.amigappc=	powerpc
MACHINE_ARCH.arc=	mipsel
MACHINE_ARCH.atari=	m68k
MACHINE_ARCH.bebox=	powerpc
MACHINE_ARCH.cats=	arm
MACHINE_ARCH.cesfic=	m68k
MACHINE_ARCH.cobalt=	mipsel
MACHINE_ARCH.dreamcast=	sh3el
MACHINE_ARCH.evbarm=	arm
MACHINE_ARCH.evbmips=	mipsel
MACHINE_ARCH.evbppc=	powerpc
MACHINE_ARCH.evbsh3=	sh3eb
MACHINE_ARCH.hp300=	m68k
MACHINE_ARCH.hpcarm=	arm
MACHINE_ARCH.hpcmips=	mipsel
MACHINE_ARCH.hpcsh=	sh3el
MACHINE_ARCH.luna68k=	m68k
MACHINE_ARCH.mac68k=	m68k
MACHINE_ARCH.macppc=	powerpc
MACHINE_ARCH.mipsco=	mipseb
MACHINE_ARCH.mmeye=	sh3eb
MACHINE_ARCH.mvme68k=	m68k
MACHINE_ARCH.netwinder=	arm
MACHINE_ARCH.news68k=	m68k
MACHINE_ARCH.newsmips=	mipseb
MACHINE_ARCH.next68k=	m68k
MACHINE_ARCH.ofppc=	powerpc
MACHINE_ARCH.playstation2=mipsel
MACHINE_ARCH.pmax=	mipsel
MACHINE_ARCH.prep=	powerpc
MACHINE_ARCH.sandpoint=	powerpc
MACHINE_ARCH.sbmips=	mipseb
MACHINE_ARCH.sgimips=	mipseb
MACHINE_ARCH.shark=	arm
MACHINE_ARCH.sun3=	m68k
MACHINE_ARCH.x68k=	m68k

##### Fetched directories from FTP server #####

.if defined(ALL_PORTS) && !empty(ALL_PORTS)
RSYNC_INCLUDE+=		--include "/shared/"
RSYNC_EXCLUDE+=		--exclude "/[a-z]*" \
			--exclude "/shared/[a-z]*/"
.endif

RSYNC_ARCHS=
.for port in ${ALL_PORTS:O:u}			# {
RSYNC_INCLUDE+=		--include "/${port}/"
.if defined(MACHINE_ARCH.${port})
RSYNC_ARCHS+=		${MACHINE_ARCH.${port}}
.endif
.endfor						# }
.for arch in ${RSYNC_ARCHS:O:u}
RSYNC_INCLUDE+=		--include "/shared/${arch}/"
.endfor

##### Boot info and additional options for various platforms #####

.if defined(PUBLISHER)
MKISOFS_ARGS+=		-P "${PUBLISHER}"
.endif

.if defined(PREPARER)
MKISOFS_ARGS+=		-p "${PREPARER}"
.endif


##### Per image settings #####

.for image in ${CD_IMAGES}			# {
ports:=${BASE_PORTS.${image}}

.if !defined(VOLID.${image}) && !target(.BEGIN)
.BEGIN:
	@echo "Error: VOLID.${image} not set in ${RELEASE}.conf"
	@false
.endif

MKISOFS_ARGS.${image}=	-V "${VOLID.${image}}"

pathlist.${image}:=${STAGEDIR}/${image}.pathlist
contents.${image}:=${IMAGEDIR}/${image}.contents

MKISOFS_ARGS.${image}+=	-graft-points -path-list ${pathlist.${image}}

.if defined(ABSTRACT.${image})
MKISOFS_ARGS.${image}+=	-abstract ${ABSTRACT.${image}}
.endif

# Options specified in release config file

EXTFILES?=
INTFILES.${image}?=
INTDIRS.${image}?=
ADDFILES.${image}?=

bports=			shared/ALL
.for port in ${ports}					# {
EXTFILES+=		${EXTFILES.${port}}
INTFILES.${image}+=	${INTFILES.${port}}
INTDIRS.${image}+=	${INTDIRS.${port}}
ADDFILES.${image}+=	${ADDFILES.${port}}
MKISOFS_ARGS.${image}+=	${MKISOFS_ARGS.${port}}
# add shared/ALL and shared/${MACHINE_ARCH} to BASE_PORTS.${image}
bports+=		${port}
.if defined(MACHINE_ARCH.${port})
bports+=		shared/${MACHINE_ARCH.${port}}
.endif
.endfor							# }
BASE_PORTS.${image}:=	${bports:O:u}


# i386

.if !empty(ports:Mi386)
MKISOFS_ARGS.${image}+=	-b ${BOOTFILE.i386} -c boot.catalog
.endif

# Mac (mac68k, macppc)

.if !empty(ports:Mmacppc)
MKISOFS_ARGS.${image}+=	-hfs -part -hide-hfs-list ${.CURDIR}/hide-hfs.lst \
	--macbin -map ${.CURDIR}/hfsmap.lst \
	-boot-hfs-file ${MACPPC_IBOOTDIR}/macppcboot.raw
.elif defined(USE_APPLE_ISO) || !empty(ports:Mmac68k)
MKISOFS_ARGS.${image}+=	-apple --macbin -map ${.CURDIR}/hfsmap.lst
.endif

# Sun (sparc, sparc64, sun3)

SUN_BOOT_ARGS.${image}:=
.if !empty(ports:Msparc*) || !empty(ports:Msun3*)	# {
SUN_BOOT.123:=	-
SUN_BOOT.4:=	-
SUN_BOOT.5:=	-

.if !empty(ports:Msparc)
SUN_BOOT.123:=	${BOOTFILE.sparc}
.endif

.if !empty(ports:Msun3)					# {
.if !defined(BOOTFILE.sun3x)
# NetBSD >= 1.4; sun3 and sun3x are the same
SUN_BOOT.5:=	${BOOTFILE.sun3}
.endif
SUN_BOOT.4:=	${BOOTFILE.sun3}
.endif							# }

.if !empty(ports:Msun3x) && defined(BOOTFILE.sun3x)
# NetBSD < 1.4; sun3 and sun3x are separate
SUN_BOOT.5:=	${BOOTFILE.sun3x}
.endif

.if !empty(ports:Msparc64)				# {
.if (${SUN_BOOT.5} != "-")
# add warning
SUN_BOOT.5:=	${SUN_BOOT.5} ${BOOTFILE.sparc64}
.else
SUN_BOOT.5:=	${BOOTFILE.sparc64}
.endif
.endif							# }

SUN_BOOT_ARGS.${image}:= ${SUN_BOOT.123} ${SUN_BOOT.123} ${SUN_BOOT.123} ${SUN_BOOT.4} ${SUN_BOOT.5}

.if empty(SUN_BOOT_ARGS.${image}:N/dev/null)
SUN_BOOT_ARGS.${image}:=
.endif
.endif							# }

.endfor		# image in ${CD_IMAGES}		# }

##### Additional options for host OS's #####

# (USE_APPLE_ISO is tested above)

.if defined(USE_ROCK_RIDGE)
MKISOFS_ARGS+=		-r
.endif

.if defined(USE_LONG_NAMES)
MKISOFS_ARGS+=		-l
.endif

.if defined(USE_TRANS_TBL)
MKISOFS_ARGS+=		-T
.endif

.if defined(USE_JOLIET)
MKISOFS_ARGS+=		-J -hide-joliet-list ${.CURDIR}/hide-jol.lst
.if defined(USE_TRANS_TBL)
MKISOFS_ARGS+=		-hide-joliet-trans-tbl
.endif
.endif

##### File extract rule #####

USE-FILE: .USE
	@if [ ! -r $@ ]; then case $> in \
		/*,link) \
			echo "cp ${>:S/,link$//} $@"; \
			cp ${>:S/,link$//} $@;; \
		*,link) \
			echo "cp `pwd -P`/${>:S/,link$//} $@"; \
			cp `pwd -P`/${>:S/,link$//} $@;; \
		*.tgz,*) \
			echo "Extracting: $> --> $@..."; \
			tar --fast-read -xzf ${>:C/,.*$//} ${>:C/^.*,//} ; \
			cp ${>:C/^.*,//} $@; rm -rf ${>:C/^.*,//} ;; \
		*.gz) echo "gunzip -c <$> >$@"; gunzip -c <$> >$@;; \
		*) echo "Unknown archive method for $@"; false;; \
	esac; else true; fi

##### Makefile rules #####

.for image in ${CD_IMAGES}			# {
all: ${IMAGEDIR}/${image}.iso

stage-${image}:
	mkdir -p ${STAGEDIR}/${image} ${EXTFILEDIR}
	rm -f ${pathlist.${image}} ${contents.${image}}
.if defined(BASE_PORTS.${image}) && !empty(BASE_PORTS.${image})
.for dir in ${INTDIRS.${image}}
	mkdir -p ${STAGEDIR}/${image}/${dir}
.endfor
.for arch in ${BASE_PORTS.${image}}
	@echo "${arch}=${DISTRIBDIR}/${arch}" >> ${pathlist.${image}}
	@echo "${arch}" >> ${contents.${image}}
.endfor
.endif

extfileprep:
.for file in ${EXTFILES}			# {
extfileprep: ${EXTFILEDIR}/${file:C/:.*$//}
${EXTFILEDIR}/${file:C/:.*$//}: ${DISTRIBDIR}/${file:C/^.*://} USE-FILE
${DISTRIBDIR}/${file:C/^.*://}: .PHONY
.endfor						# }

fileprep-${image}:
.for file in ${INTFILES.${image}}		# {
fileprep-${image}: ${STAGEDIR}/${image}/${file:C/:.*$//}
${STAGEDIR}/${image}/${file:C/:.*$//}: ${DISTRIBDIR}/${file:C/^.*://} USE-FILE
${DISTRIBDIR}/${file:C/^.*://}: .PHONY
.endfor						# }
.for file in ${ADDFILES.${image}}		# {
fileprep-${image}: ${STAGEDIR}/${image}/${file:C/:.*$//}
${STAGEDIR}/${image}/${file:C/:.*$//}: ${file:C/^.*://} USE-FILE
${file:C/^.*://}: .PHONY
.endfor						# }

# Size the CD image.  This is done via the following formula:
# 1. Size the image produced by mkisofs.
# 2. Add images added by distrib/common/sunbootcd.sh by rounding to a 320k
#    boundary and adding each Sun image rounded to a 320k boundary.
# 3. Add 64k if macppc is included (ofwboot munged to one 64k block).
# 4. Add bootfile sizes rounded up to 512 bytes for pmax and vax.
# 5. Round up to a 32k boundary, then add another 32k for TAO padding.

.if !empty(BASE_PORTS.${image}:Mmacppc)
size-${image}: all-macppc_installboot
.endif

size-${image}: stage-${image} extfileprep fileprep-${image}
	@size=$$((`cd ${STAGEDIR}/${image} && ${MKISOFS} ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} -print-size . 2>&1 | tee /dev/stderr | sed '/=/!d;s/^[^=]*=//'` * 2048)) && \
	if [ "${SUN_BOOT_ARGS.${image}}" != "" ]; then \
		size=$$(($$(($$size + 327679)) / 327680 * 327680)) && \
		bootfiles=`for f in ${SUN_BOOT_ARGS.${image}:N-:O}; do echo $$f; done | uniq` && \
		for f in $$bootfiles; do \
			bfsize=`ls -l $$f | awk '{print $$5}'` && \
			size=$$(($$size + $$(($$(($$bfsize + 327679)) / 327680 * 327680)))); \
		done; \
	fi && \
	if [ "${BASE_PORTS.${image}:Mmacppc}" != "" ]; then \
		size=$$(($$size + 65536)); \
	fi && \
	if [ "${BASE_PORTS.${image}:Mpmax}" != "" ]; then \
		size=$$(($$size + $$(($$((`ls -l ${BOOTFILE.pmax} | awk '{print $$5}'` + 511)) / 512 * 512)))); \
	fi && \
	if [ "${BASE_PORTS.${image}:Mvax}" != "" ]; then \
		size=$$(($$size + $$(($$((`ls -l ${BOOTFILE.vax} | awk '{print $$5}'` + 511)) / 512 * 512)))); \
	fi && \
	size=$$(($$(($$size + 16383)) / 16384 * 16384 + 32768)) && \
	sizek=$$(($$size / 1024)) && \
	echo "Projected size of ${image}.iso: $$size bytes ($${sizek}K)." && \
	if [ $$sizek -gt ${CD_SIZE} ]; then echo "Image too large for ${CD_SIZE} KB CD!"; false; fi

# Actually build the image with all the bootstrap goo....

${IMAGEDIR}/${image}.iso: size-${image}
	@sort -o ${contents.${image}} ${contents.${image}}
.if defined(LOG_MKISOFS)
	cd ${STAGEDIR}/${image} && ${MKISOFS} -o $@ ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} -v -v . >${IMAGEDIR}/${image}.iso.log 2>&1
.else
	cd ${STAGEDIR}/${image} && ${MKISOFS} -o $@ ${MKISOFS_ARGS} ${MKISOFS_ARGS.${image}} .
.endif
.if !empty(SUN_BOOT_ARGS.${image})
	SUNLABEL=${TOOL_SUNLABEL:Q} \
	    ${HOST_SH} ${NETBSDSRCDIR}/distrib/common/sunbootcd.sh \
	    ${.TARGET} ${SUN_BOOT_ARGS.${image}}
.endif
.if !empty(BASE_PORTS.${image}:Mmacppc)
	@blknum=$$((`ls -l $@ | awk '{print $$5}'` / 512)) && \
	${MACPPC_IBOOTDIR}/macppc_installboot $@ $$blknum 756
	dd if=${EXTFILEDIR}/macppc.ofwboot bs=64k count=1 conv=sync >>$@ 2>/dev/null
.endif
.if !empty(BASE_PORTS.${image}:Mpmax)
	${PMAX_IBOOT} $@ ${BOOTFILE.pmax}
.endif
.if !empty(BASE_PORTS.${image}:Mvax)
	${VAX_IBOOT} $@ ${BOOTFILE.vax}
.endif
.if !empty(BASE_PORTS.${image}:Malpha)
	${ALPHA_IBOOT} $@ ${BOOTFILE.alpha}
.endif
	@echo Rounding up to 32k boundary and padding 32k....
	@size=`ls -l $@ | awk '{print $$5}'` && \
	newsize=$$(($$(($$size + 32767)) / 32768 * 32768)) && \
	dd if=/dev/zero bs=512 count=$$(($$(($$newsize - $$size)) / 512)) >>$@ 2>/dev/null
	dd if=${EASTER_EGG} bs=32768 count=1 conv=sync >>$@ 2>/dev/null

.endfor		# image in ${CD_IMAGES}		# }

fetch:
	@mkdir -p ${DISTRIBDIR}
	@echo Fetching distributions....
	${RSYNC} ${RSYNC_INCLUDE} ${RSYNC_ARGS} ${RSYNC_EXCLUDE} ${RSYNC_SITE}/ ${DISTRIBDIR}/

clean: cleanstagedir cleanimages
cleandir distclean: cleandistribdir

cleanimages:
.for image in ${CD_IMAGES}
	-rm -f ${IMAGEDIR}/${image}.iso ${IMAGEDIR}/${image}.iso.log \
		${contents.${image}}
.endfor

cleanstagedir:
	-rm -rf ${STAGEDIR} ${EXTFILEDIR}

cleandistribdir:
	-rm -rf ${DISTRIBDIR}