1#	$NetBSD: Makefile.installimage,v 1.11 2024/04/25 11:56:51 nia Exp $
2#
3# Common Makefile to create a bootable installation image for USB flash etc.
4#
5
6#
7# Required variables:
8#	INSTIMGBASE
9#		Basename of the liveimage
10#
11# Optional variables:
12#	INSTIMAGEMB
13#		target image size in MB
14#		(if empty default IMAGEMB in Makefile.bootimage is used)
15#
16# See Makefile.bootimage for other variables.
17#
18
19.if !target(check_INSTIMGBASE)
20check_INSTIMGBASE: .PHONY .NOTMAIN
21.if !defined(INSTIMGBASE)
22	@echo "Error: INSTIMGBASE is not set"
23	@false
24.else
25	@true
26.endif
27.endif
28
29.if defined(INSTIMAGEMB)
30IMAGEMB=	${INSTIMAGEMB}
31.endif
32SWAPMB=		0			# no swap
33
34KERN_SET?=	kern-GENERIC
35SETS?=		gpufw modules base etc
36
37FSTAB_IN?=	${NETBSDSRCDIR}/distrib/common/bootimage/fstab.install.in
38
39USE_MBR?=	no
40
41.if ${USE_MBR} != "no"
42DISKPROTO_IN?=	${NETBSDSRCDIR}/distrib/common/bootimage/diskproto.noswap.mbr.in
43.else
44DISKPROTO_IN?=	${NETBSDSRCDIR}/distrib/common/bootimage/diskproto.noswap.in
45.endif
46
47# XXX: no permission info for makefs(8)
48IMGDIR_EXTRA=	${RELEASEDIR}/${RELEASEMACHINEDIR}	${RELEASEMACHINEDIR}
49IMGDIR_EXCLUDE+= 	-s ',./installation/floppy/.*,,gp'
50IMGDIR_EXCLUDE+= 	-s ',./installation/cdrom.*,,gp'
51IMGDIR_EXCLUDE+=	-s ',./installation/liveimage.*,,gp'
52IMGDIR_EXCLUDE+=	-s ',./installation/installimage.*,,gp'
53.if defined(MD_IMGDIR_EXCLUDE)
54IMGDIR_EXCLUDE+=	${MD_IMGDIR_EXCLUDE}
55.endif
56
57IMGBASE=        ${INSTIMGBASE}
58
59.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"
60
61# INSTIMG_RELEASEDIR specifies where to install ${INSTIMGBASE}.img.gz.
62# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
63# but also set default here for manual builds.
64INSTIMG_RELEASEDIR?=	${RELEASEMACHINEDIR}/installation/installimage
65
66# should be defined elsewhere? 
67MKDIR?=		mkdir -p
68
69install_image: check_INSTIMGBASE check_RELEASEDIR ${IMGBASE}.img.gz
70	${MKDIR} ${MKDIRPERM} ${INSTIMG_RELEASEDIR}
71	${RELEASE_INSTALL} ${IMGBASE}.img.gz ${INSTIMG_RELEASEDIR}
72	# note ${MAKESUM} will be calculated in src/etc/Makefile
73
74release:
75
76