Home | History | Annotate | Line # | Download | only in bootimage
      1  1.50   tsutsui #	$NetBSD: Makefile.bootimage,v 1.50 2026/01/18 00:07:36 tsutsui Exp $
      2   1.1   tsutsui #
      3   1.1   tsutsui # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
      4   1.1   tsutsui #
      5   1.1   tsutsui # Redistribution and use in source and binary forms, with or without
      6   1.1   tsutsui # modification, are permitted provided that the following conditions
      7   1.1   tsutsui # are met:
      8   1.1   tsutsui # 1. Redistributions of source code must retain the above copyright
      9   1.1   tsutsui #    notice, this list of conditions and the following disclaimer.
     10   1.1   tsutsui # 2. Redistributions in binary form must reproduce the above copyright
     11   1.1   tsutsui #    notice, this list of conditions and the following disclaimer in the
     12   1.1   tsutsui #    documentation and/or other materials provided with the distribution.
     13   1.1   tsutsui #
     14   1.1   tsutsui # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     15   1.1   tsutsui # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     16   1.1   tsutsui # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     17   1.1   tsutsui # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     18   1.1   tsutsui # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     19   1.1   tsutsui # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     20   1.1   tsutsui # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     21   1.1   tsutsui # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22   1.1   tsutsui # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     23   1.1   tsutsui # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24   1.1   tsutsui 
     25   1.1   tsutsui #
     26   1.1   tsutsui # Makefile to create a bootable FS image for USB flash or emulators
     27   1.1   tsutsui #
     28   1.1   tsutsui 
     29   1.1   tsutsui #
     30   1.1   tsutsui # Required variables:
     31   1.1   tsutsui #	RELEASEDIR
     32   1.1   tsutsui #		Should be defined in nbmake-${MACHINE}
     33   1.1   tsutsui #	IMGBASE
     34   1.1   tsutsui #		Basename of the image
     35   1.1   tsutsui #
     36   1.1   tsutsui # Optional variables:
     37   1.1   tsutsui #	USE_MBR
     38   1.1   tsutsui #		set yes if target disk image requires MBR partition
     39   1.6   tsutsui #		(default: no)
     40  1.23     joerg #	USE_GPT
     41  1.23     joerg #		set yes if target disk image requires GPT partition
     42  1.23     joerg #		(default: no)
     43  1.31   tsutsui #	USE_GPTMBR
     44  1.31   tsutsui #		set yes if target disk image requires GPT partition
     45  1.31   tsutsui #		with hybrid MBR boot code
     46  1.31   tsutsui #		(default: no; valid only if USE_GPT=yes)
     47  1.50   tsutsui #	USE_MDBOOTPART
     48  1.50   tsutsui #		set yes if target disk image requires port specific
     49  1.50   tsutsui #		boot partition
     50  1.50   tsutsui #		(default: no; if yes target rules of WORKMDBOOTPART should
     51  1.50   tsutsui #		 be defined in MD liveimage/Makefiles)
     52   1.5   tsutsui #	MBR_BOOTCODE
     53   1.5   tsutsui #		optional MBR bootcode which should be installed by fdisk(8)
     54   1.5   tsutsui #		(default: empty)
     55   1.5   tsutsui #		- specified MBR_BOOTCODE must exist in ${DESTDIR}/usr/mdec
     56   1.5   tsutsui #		- if MBR_BOOTCODE is not specified,
     57   1.5   tsutsui #		  MBR_DEFAULT_BOOTCODE (default: mbr) will be used
     58   1.5   tsutsui #		  if the target ${MACHINE} has the one in /usr/mdec
     59   1.1   tsutsui #	USE_SUNLABEL
     60   1.1   tsutsui #		set yes if target disk image requires Sun's label
     61   1.1   tsutsui #		(default: no)
     62  1.43   tsutsui #	INSTALLBOOT_AFTER_DISKLABEL
     63   1.1   tsutsui #		set yes if the target ${MACHINE} requires disklabel
     64  1.43   tsutsui #		to run installboot(8), like hp300 and vax
     65   1.1   tsutsui #		(default: empty)
     66   1.1   tsutsui #	IMAGEMB
     67   1.1   tsutsui #		target image size in MB
     68   1.1   tsutsui #		(default: 2048)
     69   1.1   tsutsui #	SWAPMB
     70   1.1   tsutsui #		swap size in target image in MB
     71   1.1   tsutsui #		(default: 128)
     72  1.23     joerg #	EFIMB
     73  1.23     joerg #		EFI partition size in target image in MB
     74  1.23     joerg #		(default: 128)
     75  1.24   tsutsui #	FATMB
     76  1.24   tsutsui #		FAT partition size in target image in MB
     77  1.24   tsutsui #		(default: 0)
     78  1.50   tsutsui #	MDBOOTPARTMB
     79  1.50   tsutsui #		port specific boot partition size in target image in MB
     80  1.50   tsutsui #		(default: 0)
     81  1.31   tsutsui #	GPTSECTORS
     82  1.31   tsutsui #		Size of a region reserved for the secondary GPT table/entry
     83  1.31   tsutsui #		at the end of the target image in sectors
     84  1.31   tsutsui #		(default: 2048 if USE_GPT=yes, otherwise 0)
     85   1.1   tsutsui #	KERN_SET
     86   1.1   tsutsui #		kernel set name which should be extracted into image
     87   1.1   tsutsui #		(default: kern-GENERIC)
     88   1.1   tsutsui #	SETS
     89   1.1   tsutsui #		binary sets that should be extracted into image
     90  1.34       nia #		(default: modules base etc comp games gpufw man manhtml misc
     91  1.29      maya #		          rescue tests text xbase xcomp xetc xfont xserver)
     92   1.1   tsutsui #	SETS_DIR
     93   1.1   tsutsui #		directory path where binary sets are stored
     94   1.1   tsutsui #		(default: ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets)
     95   1.1   tsutsui #	IMGFILE_EXTRA
     96   1.1   tsutsui #		list of additional files to be copied into images,
     97   1.1   tsutsui #		containing one or more tuples of the form:
     98   1.1   tsutsui #			FILE	TARGETPATH
     99   1.1   tsutsui #		for installation image etc.
    100   1.1   tsutsui #		(default: empty)
    101   1.1   tsutsui #	IMGDIR_EXTRA
    102   1.1   tsutsui #		list of additional directories to be copied into images,
    103   1.1   tsutsui #		containing one or more tuples of the form:
    104   1.1   tsutsui #			DIR	TARGETPATH
    105   1.1   tsutsui #		for installation image etc.
    106   1.1   tsutsui #		(default: empty)
    107   1.6   tsutsui #		XXX: currently permissions in IMGDIR_EXTRA are not handled
    108   1.1   tsutsui #	IMGDIR_EXCLUDE
    109   1.1   tsutsui #		pax(1) options to exclude files which should not copied
    110   1.1   tsutsui #		into TARGETPATH in IMGDIR_EXTRA
    111   1.1   tsutsui #		(default: empty)
    112   1.1   tsutsui #	FSTAB_IN
    113   1.1   tsutsui #		template file of /etc/fstab
    114   1.1   tsutsui #		(default: ${DISTRIBDIR}/common/bootimage/fstab.in)
    115   1.1   tsutsui #	SPEC_IN
    116   1.1   tsutsui #		default files of spec file for makefs(8)
    117   1.1   tsutsui #		(default: ${DISTRIBDIR}/common/bootimage/spec.in)
    118   1.1   tsutsui #	SPEC_EXTRA
    119   1.1   tsutsui #		additional files of spec file for makefs(8)
    120   1.1   tsutsui #		(default: empty)
    121   1.1   tsutsui #	IMGMAKEFSOPTIONS
    122   1.1   tsutsui #		options passed to makefs(8) to create root file system
    123   1.1   tsutsui #		(default: -o bsize=16384,fsize=2048,density=8192)
    124  1.45   tsutsui #	IMGFFSVERSION
    125  1.45   tsutsui #		version of FFS created by makefs(8)
    126  1.45   tsutsui #		(default: 1)
    127   1.5   tsutsui #	INSTALLBOOTOPTIONS
    128   1.5   tsutsui #		options passed to installboot(8), e.g., -o console=com0
    129   1.5   tsutsui #		(default: empty)
    130   1.1   tsutsui #	PRIMARY_BOOT
    131   1.1   tsutsui #		primary boot loader that should be installed into
    132   1.1   tsutsui #		the target image via installboot(8)
    133   1.1   tsutsui #		(default: empty)
    134   1.1   tsutsui #	SECONDARY_BOOT
    135   1.1   tsutsui #		secondary bootloader that should be put into the target image
    136   1.1   tsutsui #		(default: empty)
    137   1.1   tsutsui #	SECONDARY_BOOT_ARG
    138   1.1   tsutsui #		extra arguments that should be passed to installboot(8)
    139   1.1   tsutsui #		to specify the secondary bootloader
    140   1.1   tsutsui #		(default: empty)
    141   1.1   tsutsui #	DISKPROTO_IN
    142   1.1   tsutsui #		template file of disklabel -R
    143   1.1   tsutsui #		(default: ${DISTRIBDIR}/common/bootimage/diskproto.in
    144   1.1   tsutsui #		       or ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in)
    145  1.23     joerg #	EFIBOOT
    146  1.23     joerg #		EFI bootloader
    147  1.23     joerg #		(default: empty)
    148  1.24   tsutsui #	MBRFAT
    149  1.24   tsutsui #		MBR partition type value for FAT
    150  1.24   tsutsui #		(default: 6 ("16-bit FAT, more than 32M"))
    151  1.24   tsutsui #	FATMAKEFSOPTIONS
    152  1.24   tsutsui #		options passed to makefs(8) to create a FAT partition
    153  1.24   tsutsui #		(default: -o fat_type=16)
    154  1.24   tsutsui #	FATFILES
    155  1.24   tsutsui #		list of additional files to be copied into FAT partition
    156  1.24   tsutsui #		(default: empty)
    157  1.26  jmcneill #	IMAGEHOSTNAME
    158  1.26  jmcneill #		if set, sets the default hostname in rc.conf (default: empty)
    159   1.1   tsutsui #
    160   1.1   tsutsui 
    161   1.1   tsutsui .include <bsd.own.mk> 		#
    162   1.1   tsutsui .include <bsd.endian.mk>	# for TARGET_ENDIANNESS
    163   1.1   tsutsui 
    164   1.1   tsutsui .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
    165   1.1   tsutsui 
    166  1.13  christos .if ${MKREPRO_TIMESTAMP:Uno} != "no"
    167  1.13  christos MAKEFS_TIMESTAMP=-T "${MKREPRO_TIMESTAMP}"
    168  1.23     joerg GPT_TIMESTAMP=-T "${MKREPRO_TIMESTAMP}"
    169  1.15  christos PAX_TIMESTAMP=--timestamp "${MKREPRO_TIMESTAMP}"
    170  1.15  christos .endif
    171  1.12  christos 
    172   1.1   tsutsui .if empty(IMGBASE)
    173   1.1   tsutsui .BEGIN:
    174   1.1   tsutsui 	@echo "Error: IMGBASE is not set"
    175   1.1   tsutsui 	@false
    176   1.1   tsutsui .endif
    177   1.1   tsutsui 
    178   1.1   tsutsui # should be defined elsewhere? 
    179   1.1   tsutsui CAT?=		cat
    180   1.1   tsutsui CHMOD?=		chmod
    181   1.1   tsutsui DD?=		dd
    182   1.1   tsutsui MKDIR?=		mkdir -p
    183   1.1   tsutsui RM?=		rm
    184   1.1   tsutsui 
    185  1.36  christos MAKESPEC=	${HOST_SH} ${NETBSDSRCDIR}/etc/makespec
    186  1.36  christos 
    187   1.1   tsutsui #
    188   1.1   tsutsui # common definitions for image
    189   1.1   tsutsui #
    190   1.1   tsutsui USE_MBR?=	no
    191  1.23     joerg USE_GPT?=	no
    192  1.25  jmcneill USE_GPTMBR?=	no
    193  1.50   tsutsui USE_MDBOOTPART?= no
    194   1.1   tsutsui USE_SUNLABEL?=	no
    195   1.1   tsutsui INSTALLBOOT_AFTER_DISKLABEL?=	no
    196   1.1   tsutsui 
    197   1.1   tsutsui #
    198   1.1   tsutsui # size parameters for image
    199   1.1   tsutsui #
    200   1.1   tsutsui IMAGEMB?=	2048		# 2048MB
    201   1.1   tsutsui SWAPMB?=	128		# 128MB
    202  1.23     joerg .if ${USE_GPT} == "no"
    203  1.23     joerg EFIMB?=		0
    204  1.23     joerg GPTSECTORS=	0
    205  1.23     joerg .else
    206  1.23     joerg EFIMB?=		128		# 128MB
    207  1.23     joerg GPTSECTORS=	2048
    208  1.23     joerg .endif
    209  1.24   tsutsui FATMB?=		0
    210  1.50   tsutsui MDBOOTPARTMB?=	0
    211   1.1   tsutsui 
    212   1.3   tsutsui # XXX: SWAPMB could be zero and expr(1) returns exit status 1 in that case
    213   1.1   tsutsui IMAGESECTORS!=	expr ${IMAGEMB} \* 1024 \* 1024 / 512
    214   1.3   tsutsui SWAPSECTORS!=	expr ${SWAPMB} \* 1024 \* 1024 / 512 || true
    215  1.23     joerg EFISECTORS!=	expr ${EFIMB} \* 1024 \* 1024 / 512 || true
    216  1.24   tsutsui FATSECTORS!=	expr ${FATMB} \* 1024 \* 1024 / 512 || true
    217   1.1   tsutsui 
    218  1.50   tsutsui .if ${USE_MDBOOTPART} != "no"
    219  1.50   tsutsui MDBOOTPARTSECTORS!=	expr ${MDBOOTPARTMB} \* 1024 \* 1024 / 512 || true
    220  1.50   tsutsui .else
    221  1.50   tsutsui MDBOOTPARTSECTORS=	0
    222  1.50   tsutsui .endif
    223  1.50   tsutsui 
    224  1.23     joerg .if ${USE_MBR} == "no" && ${USE_GPT} == "no"
    225   1.1   tsutsui LABELSECTORS?=	0
    226   1.1   tsutsui .else
    227   1.1   tsutsui #LABELSECTORS?=	63	# historical
    228   1.1   tsutsui #LABELSECTORS?=	32	# 16KB aligned
    229   1.1   tsutsui LABELSECTORS?=	2048	# 1MB aligned for modern flash devices
    230   1.1   tsutsui .endif
    231   1.1   tsutsui 
    232  1.50   tsutsui .if ${USE_MDBOOTPART} != "no"
    233  1.50   tsutsui MDBOOTPARTOFFSET!=	expr ${LABELSECTORS} + ${EFISECTORS} + ${FATSECTORS} \
    234  1.50   tsutsui 			    || test $$? -eq 1 || exit 1
    235  1.50   tsutsui .else
    236  1.50   tsutsui MDBOOTPARTOFFSET=	0
    237  1.50   tsutsui .endif
    238  1.50   tsutsui 
    239  1.23     joerg FSSECTORS!=	expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS} \
    240  1.50   tsutsui 		    - ${EFISECTORS} - ${GPTSECTORS} - ${FATSECTORS} \
    241  1.50   tsutsui 		    - ${MDBOOTPARTSECTORS} || test $$? -eq 1 || exit 1
    242  1.30       mrg FSSIZE!=	expr ${FSSECTORS} \* 512 || test $$? -eq 1 || exit 1
    243   1.1   tsutsui 
    244   1.1   tsutsui # parameters for disklabel and MBR
    245   1.1   tsutsui HEADS=		64
    246   1.1   tsutsui SECTORS=	32
    247   1.1   tsutsui CYLINDERS!=	expr ${IMAGESECTORS} / \( ${HEADS} \* ${SECTORS} \)
    248   1.1   tsutsui SECPERCYLINDERS!= expr ${HEADS} \* ${SECTORS}
    249   1.1   tsutsui MBRHEADS=	255
    250   1.1   tsutsui MBRSECTORS=	63
    251   1.1   tsutsui MBRCYLINDERS!=	expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \)
    252   1.1   tsutsui MBRNETBSD=	169
    253  1.24   tsutsui MBRFAT?=	6	# 16-bit FAT, more than 32M
    254   1.1   tsutsui 
    255  1.24   tsutsui BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} \
    256  1.50   tsutsui 		    - ${EFISECTORS} - ${GPTSECTORS} - ${FATSECTORS} \
    257  1.50   tsutsui 		    - ${MDBOOTPARTSECTORS}
    258  1.50   tsutsui FSOFFSET!=	expr ${LABELSECTORS} + ${EFISECTORS} + ${FATSECTORS} \
    259  1.50   tsutsui 		    + ${MDBOOTPARTSECTORS} || test $$? -eq 1 || exit 1
    260  1.24   tsutsui SWAPOFFSET!=	expr ${LABELSECTORS} + ${FSSECTORS} \
    261  1.50   tsutsui 		    + ${EFISECTORS} + ${FATSECTORS} \
    262  1.50   tsutsui 		    + ${MDBOOTPARTSECTORS} || test $$? -eq 1 || exit 1
    263  1.24   tsutsui FATOFFSET=	${LABELSECTORS}
    264   1.1   tsutsui 
    265  1.47   tsutsui # helper script for sunlabel
    266  1.47   tsutsui DISKPROTO2SUNLABEL?=	${DISTRIBDIR}/common/bootimage/diskproto2sunlabel.awk
    267   1.1   tsutsui 
    268  1.23     joerg .if ${USE_GPT} != "no"
    269  1.33  christos BOOTDISK_UUID=`${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKMBR} show -i 2 | ${TOOL_AWK} '/^GUID/ {print $$2}'`
    270  1.33  christos SWAPDISK_UUID=`${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKMBR} show -i 3 | ${TOOL_AWK} '/^GUID/ {print $$2}'`
    271  1.23     joerg .endif
    272   1.1   tsutsui 
    273   1.1   tsutsui #
    274   1.1   tsutsui # definitions to create root fs
    275   1.1   tsutsui #
    276  1.42      jmmv SETS_DEFAULT=	modules base etc comp games gpufw man misc rescue text
    277  1.42      jmmv .if ${MKATF} != "no"
    278  1.42      jmmv SETS_DEFAULT+=	tests
    279  1.42      jmmv .endif
    280  1.34       nia .if ${MKCOMPAT} != "no"
    281  1.34       nia SETS_DEFAULT+=	base32
    282  1.34       nia .endif
    283  1.35       nia .if ${MKCOMPAT} != "no" && \
    284  1.35       nia     (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el")
    285  1.35       nia SETS_DEFAULT+=	base64
    286  1.35       nia .endif
    287  1.34       nia .if ${MKHTML} != "no"
    288  1.34       nia SETS_DEFAULT+=	manhtml
    289  1.34       nia .endif
    290   1.1   tsutsui .if ${MKX11} != "no"
    291   1.1   tsutsui SETS_DEFAULT+=	xbase xcomp xetc xfont xserver
    292   1.1   tsutsui .endif
    293   1.1   tsutsui 
    294   1.1   tsutsui KERN_SET?=	kern-GENERIC
    295   1.1   tsutsui SETS?=		${SETS_DEFAULT}
    296   1.1   tsutsui IMG_SETS=	${KERN_SET} ${SETS}
    297   1.1   tsutsui SETS_DIR?=	${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
    298   1.1   tsutsui 
    299   1.1   tsutsui FSTAB_IN?=	${DISTRIBDIR}/common/bootimage/fstab.in
    300  1.46  pgoyette .if ${KERNEL_DIR:Uno} == "yes"
    301  1.46  pgoyette SPEC_IN?=	${DISTRIBDIR}/common/bootimage/spec-dir.in
    302  1.46  pgoyette .else
    303   1.1   tsutsui SPEC_IN?=	${DISTRIBDIR}/common/bootimage/spec.in
    304  1.46  pgoyette .endif
    305   1.1   tsutsui 
    306   1.1   tsutsui IMGMAKEFSOPTIONS?=	-o bsize=16384,fsize=2048,density=8192
    307  1.45   tsutsui IMGFFSVERSION?=		1
    308  1.24   tsutsui FATMAKEFSOPTIONS?=	-o fat_type=16
    309   1.1   tsutsui 
    310   1.1   tsutsui WORKDIR?=       work
    311   1.1   tsutsui WORKSPEC?=      work.spec
    312   1.1   tsutsui WORKFSTAB?=	work.fstab
    313   1.1   tsutsui WORKRCCONF?=	work.rc.conf
    314   1.1   tsutsui WORKFS?=        work.rootfs
    315   1.1   tsutsui TARGETFS?=      imgroot.fs
    316  1.19   aymeric COMPRESS_PROGRAM=${"${USE_XZ_SETS:Uno}"!="no":?${TOOL_XZ}:${TOOL_GZIP}}
    317  1.18    martin TAR_SUFF=	${"${USE_XZ_SETS:Uno}"!="no":?tar.xz:tgz}
    318   1.1   tsutsui 
    319   1.1   tsutsui CLEANFILES+=	${WORKSPEC} ${WORKFSTAB} ${WORKRCCONF} ${WORKFS}
    320   1.1   tsutsui CLEANFILES+=	${TARGETFS}
    321   1.1   tsutsui 
    322   1.1   tsutsui #
    323  1.23     joerg # definitions to create image
    324  1.23     joerg #
    325  1.23     joerg .if ${SWAPSECTORS} == 0
    326  1.23     joerg .  if ${USE_MBR} != "no"
    327  1.23     joerg DISKPROTO_IN?=	${DISTRIBDIR}/common/bootimage/diskproto.noswap.mbr.in
    328  1.23     joerg .  else
    329  1.23     joerg DISKPROTO_IN?=	${DISTRIBDIR}/common/bootimage/diskproto.noswap.in
    330  1.23     joerg .  endif
    331  1.23     joerg .else
    332  1.23     joerg .  if ${USE_MBR} != "no"
    333  1.23     joerg DISKPROTO_IN?=	${DISTRIBDIR}/common/bootimage/diskproto.mbr.in
    334  1.23     joerg .  else
    335  1.23     joerg DISKPROTO_IN?=	${DISTRIBDIR}/common/bootimage/diskproto.in
    336  1.23     joerg .  endif
    337  1.23     joerg .endif
    338  1.23     joerg 
    339  1.23     joerg MBR_DEFAULT_BOOTCODE?=	mbr
    340  1.23     joerg 
    341  1.23     joerg WORKMBR?=	work.mbr
    342  1.23     joerg WORKMBRTRUNC?=	work.mbr.truncated
    343  1.23     joerg WORKSWAP?=	work.swap
    344  1.23     joerg WORKEFI?=	work.efi
    345  1.23     joerg WORKGPT?=	work.gpt
    346  1.23     joerg WORKLABEL?=	work.diskproto
    347  1.23     joerg WORKIMG?=	work.img
    348  1.23     joerg EFIWORKDIR?=	work.efidir
    349  1.24   tsutsui WORKFAT?=	work.fat
    350  1.24   tsutsui WORKFATDIR?=	work.fatdir
    351  1.50   tsutsui WORKMDBOOTPART?= work.mdbootpart
    352  1.50   tsutsui WORKMDBOOTPARTDIR?= work.mdbootpartdir
    353  1.23     joerg 
    354  1.23     joerg .if ${USE_GPT} != "no"
    355  1.23     joerg ${WORKFSTAB}: ${WORKMBR}
    356  1.27   tsutsui 
    357  1.27   tsutsui .BEGIN:
    358  1.27   tsutsui 	@if [ -f ${WORKMBR} ]; then			 		\
    359  1.27   tsutsui 		st_size=`${TOOL_STAT} -f %z ${WORKMBR}`;		\
    360  1.27   tsutsui 		if [ "$$st_size" -ne "$$((${IMAGESECTORS} * 512))" ]; then \
    361  1.27   tsutsui 			echo Removing stale ${WORKMBR} ...;		\
    362  1.27   tsutsui 			rm -f ${WORKMBR};				\
    363  1.27   tsutsui 		fi							\
    364  1.27   tsutsui 	fi
    365  1.23     joerg .endif
    366  1.23     joerg 
    367  1.23     joerg ${WORKFSTAB}:
    368  1.23     joerg 	@echo Preparing /etc/fstab ...
    369  1.23     joerg .if ${USE_GPT} != "no"
    370  1.23     joerg .  if ${SWAPSECTORS} != 0
    371  1.23     joerg 	${TOOL_SED}							\
    372  1.41    martin 	    -e "s/ROOT.a/NAME=NBImgRoot/"				\
    373  1.41    martin 	    -e "s/ROOT.b/NAME=NBImgSwap/"				\
    374  1.23     joerg 	    < ${FSTAB_IN} > ${WORKFSTAB}
    375  1.23     joerg .  else
    376  1.23     joerg 	${TOOL_SED}							\
    377  1.41    martin 	    -e "s/ROOT.a/NAME=NBImgRoot/"				\
    378  1.23     joerg 	    -e "/ROOT.b/d"						\
    379  1.23     joerg 	    < ${FSTAB_IN} > ${WORKFSTAB}
    380  1.23     joerg .  endif
    381  1.23     joerg .else
    382  1.23     joerg .  if ${SWAPSECTORS} != 0
    383  1.23     joerg 	${TOOL_SED} < ${FSTAB_IN} > ${WORKFSTAB}
    384  1.23     joerg .  else
    385  1.23     joerg 	${TOOL_SED}							\
    386  1.23     joerg 	    -e "/ROOT.b/d"						\
    387  1.23     joerg 	    < ${FSTAB_IN} > ${WORKFSTAB}
    388  1.23     joerg .  endif
    389  1.23     joerg .endif
    390  1.23     joerg 
    391  1.23     joerg #
    392   1.1   tsutsui # create root file system for the image
    393   1.1   tsutsui #
    394  1.23     joerg ${TARGETFS}: prepare_md_post ${WORKFSTAB}
    395  1.36  christos 	@${RM} -f ${WORKSPEC}
    396   1.1   tsutsui 	@if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then 		\
    397   1.1   tsutsui 		echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
    398   1.1   tsutsui 		false; 							\
    399   1.1   tsutsui 	fi;
    400  1.14  christos 	@${MKDIR} ${MKDIRPERM} ${WORKDIR}
    401   1.1   tsutsui .for set in ${IMG_SETS}
    402  1.18    martin 	@if [ ! -f ${SETS_DIR}/${set}.${TAR_SUFF} ]; then 		\
    403  1.18    martin 		echo "Missing ${SETS_DIR}/${set}.${TAR_SUFF}, aborting";\
    404   1.1   tsutsui 		false; 							\
    405   1.1   tsutsui 	fi
    406  1.18    martin 	@echo Extracting ${set}.${TAR_SUFF} ...
    407  1.19   aymeric 	@(cd ${WORKDIR}; ${TOOL_PAX} ${PAX_TIMESTAMP} -rn \
    408  1.19   aymeric 		--use-compress-program=${COMPRESS_PROGRAM:Q} \
    409  1.19   aymeric 		-f ${SETS_DIR}/${set}.${TAR_SUFF} .)
    410   1.1   tsutsui .endfor
    411   1.1   tsutsui .if defined(SECONDARY_BOOT)
    412   1.1   tsutsui 	@echo Copying secondary boot...
    413  1.21   tsutsui 	${INSTALL} ${COPY} -m 0444 ${WORKDIR}/usr/mdec/${SECONDARY_BOOT} ${WORKDIR}
    414   1.1   tsutsui .endif
    415  1.14  christos 	${INSTALL} ${COPY} -m 0644 ${WORKFSTAB} ${WORKDIR}/etc/fstab
    416   1.1   tsutsui 	@echo Setting rc_configured=YES in /etc/rc.conf ...
    417   1.1   tsutsui 	${TOOL_SED} "s/rc_configured=NO/rc_configured=YES/"		\
    418   1.1   tsutsui 	    < ${WORKDIR}/etc/rc.conf > ${WORKRCCONF}
    419  1.26  jmcneill .if defined(IMAGEHOSTNAME)
    420  1.26  jmcneill 	@echo Setting hostname=${IMAGEHOSTNAME} in /etc/rc.conf ...
    421  1.26  jmcneill 	echo "hostname=${IMAGEHOSTNAME}" >> ${WORKRCCONF}
    422  1.26  jmcneill .endif
    423  1.26  jmcneill .if ${SWAPSECTORS} == 0
    424  1.26  jmcneill 	@echo Setting no_swap=YES in /etc/rc.conf ...
    425  1.26  jmcneill 	echo "no_swap=YES" >> ${WORKRCCONF}
    426  1.26  jmcneill 	@echo Setting savecore=NO in /etc/rc.conf ...
    427  1.26  jmcneill 	echo "savecore=NO" >> ${WORKRCCONF}
    428  1.26  jmcneill .endif
    429  1.28  jmcneill .if defined(RC_CONF_EXTRA)
    430  1.28  jmcneill 	@echo Adding contents of ${RC_CONF_EXTRA} to /etc/rc.conf ...
    431  1.28  jmcneill 	cat ${RC_CONF_EXTRA} >> ${WORKRCCONF}
    432  1.28  jmcneill .endif
    433  1.14  christos 	${INSTALL} ${COPY} -m 0644 ${WORKRCCONF} ${WORKDIR}/etc/rc.conf
    434   1.1   tsutsui .if defined(IMGDIR_EXTRA)
    435   1.1   tsutsui 	@echo Copying extra dirs...
    436   1.1   tsutsui .for _SRCDIR _TARGET in ${IMGDIR_EXTRA}
    437   1.1   tsutsui 	@if [ ! -d ${_SRCDIR} ]; then 					\
    438   1.1   tsutsui 		echo "${_SRCDIR} is not directory, aborting";		\
    439   1.1   tsutsui 		false; 							\
    440   1.1   tsutsui 	fi
    441  1.14  christos 	${MKDIR} ${MKDIRPERM} ${WORKDIR}/${_TARGET}
    442   1.1   tsutsui 	(cd ${_SRCDIR} ;						\
    443  1.21   tsutsui 	    ${TOOL_PAX} ${PAX_TIMESTAMP} -rw -pe -v			\
    444   1.1   tsutsui 	    ${IMGDIR_EXCLUDE}						\
    445   1.1   tsutsui 	    . ${.OBJDIR}/${WORKDIR}/${_TARGET} )
    446   1.1   tsutsui .endfor
    447   1.1   tsutsui .endif
    448   1.1   tsutsui .if defined(IMGFILE_EXTRA)
    449   1.1   tsutsui 	@echo Copying extra files...
    450   1.1   tsutsui .for _SRC _TARGET in ${IMGFILE_EXTRA}
    451   1.1   tsutsui 	@if [ ! -f ${_SRC} ]; then 					\
    452   1.1   tsutsui 		echo "${_SRC} in IMGFILE_EXTRA not found, aborting";	\
    453   1.1   tsutsui 		false; 							\
    454   1.1   tsutsui 	fi
    455   1.1   tsutsui 	@if [ -f ${_SRC} ]; then 					\
    456  1.21   tsutsui 		echo ${INSTALL} ${COPY} -m 0644 ${_SRC} ${WORKDIR}/${_TARGET}; \
    457  1.21   tsutsui 		${INSTALL} ${COPY} -m 0644 ${_SRC} ${WORKDIR}/${_TARGET}; \
    458  1.36  christos 		echo "./${_TARGET} type=file uname=root gname=wheel mode=0555" >> ${WORKSPEC}; \
    459   1.1   tsutsui 	fi
    460   1.1   tsutsui .endfor
    461   1.1   tsutsui .endif
    462   1.1   tsutsui 	@echo Preparing spec files for makefs...
    463   1.1   tsutsui 	cat ${WORKDIR}/etc/mtree/* |					\
    464   1.1   tsutsui 	    ${TOOL_SED} -e 's/ size=[0-9]*//' > ${WORKSPEC}
    465  1.10       snj 	${HOST_SH} ${WORKDIR}/dev/MAKEDEV -s all ipty |			\
    466   1.1   tsutsui 	    ${TOOL_SED} -e '/^\. type=dir/d' -e 's,^\.,./dev,' >> ${WORKSPEC}
    467   1.1   tsutsui 	cat ${SPEC_IN} >> ${WORKSPEC}
    468   1.1   tsutsui .if defined(SECONDARY_BOOT)
    469   1.1   tsutsui 	echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \
    470   1.1   tsutsui 	    >> ${WORKSPEC}
    471   1.1   tsutsui .endif
    472   1.1   tsutsui .if defined(SPEC_EXTRA)
    473   1.1   tsutsui 	cat ${SPEC_EXTRA} >> ${WORKSPEC}
    474   1.1   tsutsui .endif
    475  1.37  christos 	for i in ${WORKDIR}/netbsd.*; do \
    476  1.37  christos 	    if [ -e $$i ]; then \
    477  1.37  christos 		echo "./$$(basename $$i) type=file uname=root gname=wheel mode=0444" >> ${WORKSPEC}; \
    478  1.37  christos 	    fi; \
    479  1.37  christos 	done
    480  1.37  christos 	if [ -d ${WORKDIR}/${RELEASEMACHINEDIR} ]; then \
    481  1.37  christos 	    ${MAKESPEC} -d ${WORKDIR} ${RELEASEMACHINEDIR} >> ${WORKSPEC}; \
    482  1.36  christos 	fi
    483   1.4       riz 	@echo Creating rootfs...
    484   1.1   tsutsui 	# XXX /var/spool/ftp/hidden is unreadable
    485   1.1   tsutsui 	${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden
    486   1.1   tsutsui 	${TOOL_MAKEFS} -M ${FSSIZE} -m ${FSSIZE}			\
    487   1.1   tsutsui 	    -B ${TARGET_ENDIANNESS}					\
    488  1.36  christos 	    -xx -F ${WORKSPEC} -N ${WORKDIR}/etc			\
    489  1.13  christos 	    ${MAKEFS_TIMESTAMP}						\
    490  1.45   tsutsui 	    -t ffs							\
    491   1.1   tsutsui 	    ${IMGMAKEFSOPTIONS}						\
    492  1.45   tsutsui 	    -o version=${IMGFFSVERSION}					\
    493   1.1   tsutsui 	    ${WORKFS} ${WORKDIR}
    494   1.1   tsutsui .if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} == "no"
    495   1.5   tsutsui 	${TOOL_INSTALLBOOT} -v -m ${MACHINE} ${INSTALLBOOTOPTIONS} ${WORKFS} \
    496   1.1   tsutsui 	    ${WORKDIR}/usr/mdec/${PRIMARY_BOOT} ${SECONDARY_BOOT_ARG}
    497   1.1   tsutsui .endif
    498   1.1   tsutsui 	@echo done.
    499   1.1   tsutsui 	mv ${WORKFS} ${.TARGET}
    500   1.1   tsutsui 
    501  1.23     joerg TARGET_BLOCKS=
    502  1.23     joerg .if ${USE_MBR} != "no" || ${USE_GPT} != "no"
    503  1.23     joerg TARGET_BLOCKS+=	${WORKMBRTRUNC}
    504  1.23     joerg .endif
    505  1.23     joerg .if ${USE_GPT} != "no"
    506  1.23     joerg TARGET_BLOCKS+=	${WORKEFI}
    507  1.23     joerg .endif
    508  1.24   tsutsui .if ${FATSECTORS} != 0
    509  1.24   tsutsui TARGET_BLOCKS+=	${WORKFAT}
    510  1.24   tsutsui .endif
    511  1.50   tsutsui .if ${USE_MDBOOTPART} != "no"
    512  1.50   tsutsui TARGET_BLOCKS+=	${WORKMDBOOTPART}
    513  1.50   tsutsui .endif
    514  1.23     joerg TARGET_BLOCKS+=	 ${TARGETFS}
    515  1.23     joerg .if ${SWAPSECTORS} != 0
    516  1.23     joerg TARGET_BLOCKS+=	${WORKSWAP}
    517  1.23     joerg .endif
    518  1.23     joerg .if ${USE_GPT} != "no"
    519  1.23     joerg TARGET_BLOCKS+=	${WORKGPT}
    520   1.1   tsutsui .endif
    521   1.1   tsutsui 
    522  1.23     joerg CLEANFILES+=	${WORKMBR} ${WORKMBRTRUNC} ${WORKSWAP}
    523  1.23     joerg CLEANFILES+=	${WORKEFI} ${WORKGPT}
    524  1.24   tsutsui CLEANFILES+=	${WORKFAT}
    525  1.50   tsutsui CLEANFILES+=	${WORKMDBOOTPART}
    526  1.23     joerg CLEANFILES+=	${WORKLABEL}.tmp ${WORKLABEL}
    527  1.23     joerg CLEANFILES+=	${WORKIMG} ${IMGBASE}.img
    528   1.5   tsutsui 
    529  1.23     joerg ${WORKSWAP}:
    530  1.23     joerg .if ${SWAPSECTORS} == 0
    531  1.23     joerg 	printf "" > ${WORKSWAP}
    532  1.23     joerg .else
    533  1.23     joerg 	${DD} if=/dev/zero of=${WORKSWAP} seek=$$((${SWAPSECTORS} - 1)) count=1
    534  1.23     joerg .endif
    535   1.1   tsutsui 
    536  1.23     joerg ${WORKMBRTRUNC}: ${WORKMBR}
    537  1.23     joerg 	${DD} if=${WORKMBR} count=${LABELSECTORS} of=${WORKMBRTRUNC}
    538   1.1   tsutsui 
    539   1.1   tsutsui ${WORKLABEL}:
    540   1.1   tsutsui 	${TOOL_SED}							\
    541   1.1   tsutsui 	    -e "s/@@SECTORS@@/${SECTORS}/"				\
    542   1.1   tsutsui 	    -e "s/@@HEADS@@/${HEADS}/"					\
    543   1.1   tsutsui 	    -e "s/@@SECPERCYLINDERS@@/${SECPERCYLINDERS}/"		\
    544   1.1   tsutsui 	    -e "s/@@CYLINDERS@@/${CYLINDERS}/"				\
    545   1.1   tsutsui 	    -e "s/@@IMAGESECTORS@@/${IMAGESECTORS}/"			\
    546   1.1   tsutsui 	    -e "s/@@FSSECTORS@@/${FSSECTORS}/"				\
    547   1.1   tsutsui 	    -e "s/@@FSOFFSET@@/${FSOFFSET}/"				\
    548   1.1   tsutsui 	    -e "s/@@SWAPSECTORS@@/${SWAPSECTORS}/"			\
    549   1.1   tsutsui 	    -e "s/@@SWAPOFFSET@@/${SWAPOFFSET}/"			\
    550   1.1   tsutsui 	    -e "s/@@BSDPARTSECTORS@@/${BSDPARTSECTORS}/"		\
    551  1.24   tsutsui 	    -e "s/@@FATSECTORS@@/${FATSECTORS}/"			\
    552  1.24   tsutsui 	    -e "s/@@FATOFFSET@@/${FATOFFSET}/"				\
    553  1.50   tsutsui 	    -e "s/@@MDBOOTPARTSECTORS@@/${MDBOOTPARTSECTORS}/"		\
    554  1.50   tsutsui 	    -e "s/@@MDBOOTPARTOFFSET@@/${MDBOOTPARTOFFSET}/"		\
    555   1.1   tsutsui 	    < ${DISKPROTO_IN} > ${WORKLABEL}.tmp
    556   1.1   tsutsui 	mv ${WORKLABEL}.tmp ${WORKLABEL}
    557   1.1   tsutsui 
    558  1.23     joerg ${WORKEFI}: ${TARGETFS}
    559  1.23     joerg 	@echo create EFI system partition...
    560  1.23     joerg 	@${MKDIR} ${MKDIRPERM} ${EFIWORKDIR}/EFI/boot
    561  1.23     joerg .for f in ${EFIBOOT}
    562  1.23     joerg 	${INSTALL} ${COPY} -m 0644 ${f} ${EFIWORKDIR}/EFI/boot/`basename ${f}`
    563  1.23     joerg .endfor
    564  1.23     joerg 	${RM} -f ${WORKEFI}
    565  1.23     joerg 	${TOOL_MAKEFS} -M ${EFIMB}m -m ${EFIMB}m			\
    566  1.23     joerg 	    ${MAKEFS_TIMESTAMP}						\
    567  1.23     joerg 	    -t msdos -o F=32,c=1					\
    568  1.23     joerg 	    ${WORKEFI} ${EFIWORKDIR}
    569  1.23     joerg 
    570  1.49   tsutsui .if defined(FATFILES)
    571  1.48   tsutsui ${FATFILES}: ${TARGETFS}
    572  1.48   tsutsui 	# Some MD ${FATFILES} (bootloaders etc.) are assumed extracted
    573  1.48   tsutsui 	# to ${WORKDIR} from binary sets during ${TARGETFS} image build
    574  1.49   tsutsui .endif
    575  1.48   tsutsui 
    576  1.48   tsutsui ${WORKFAT}: ${FATFILES}
    577  1.24   tsutsui 	@echo create FAT partition for bootstrap files...
    578  1.24   tsutsui 	@${MKDIR} ${MKDIRPERM} ${WORKFATDIR}
    579  1.24   tsutsui .if defined(FATFILES)
    580  1.24   tsutsui 	@echo Copying files for FAT partition...
    581  1.24   tsutsui .for f in ${FATFILES}
    582  1.24   tsutsui 	@if [ ! -f ${f} ]; then 					\
    583  1.24   tsutsui 		echo "${f} in FATFILES not found, aborting";		\
    584  1.24   tsutsui 		false; 							\
    585  1.24   tsutsui 	fi
    586  1.24   tsutsui 	${INSTALL} ${COPY} -m 0644 ${f} ${WORKFATDIR}
    587  1.24   tsutsui .endfor
    588  1.24   tsutsui .endif
    589  1.24   tsutsui 	${RM} -f ${WORKFAT}
    590  1.24   tsutsui 	${TOOL_MAKEFS} -M ${FATMB}m -m ${FATMB}m			\
    591  1.24   tsutsui 	    ${MAKEFS_TIMESTAMP}						\
    592  1.24   tsutsui 	    -t msdos							\
    593  1.24   tsutsui 	    ${FATMAKEFSOPTIONS}						\
    594  1.24   tsutsui 	    ${WORKFAT} ${WORKFATDIR}
    595  1.24   tsutsui 
    596  1.23     joerg ${WORKMBR}:
    597  1.23     joerg .if ${USE_GPT} != "no"
    598  1.23     joerg 	@echo creating GPT header and partition entries...
    599  1.23     joerg 	${RM} -f ${WORKMBR}
    600  1.23     joerg 	${DD} if=/dev/zero of=${WORKMBR} seek=$$((${IMAGESECTORS} - 1)) count=1
    601  1.33  christos 	${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKMBR} create
    602  1.33  christos 	${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKMBR} add -a 1m -s ${EFISECTORS} -t efi -l "EFI system"
    603  1.40    martin 	${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKMBR} add -a 1m -s ${FSSECTORS} -t ffs -l "NBImgRoot"
    604  1.23     joerg .  if ${SWAPSECTORS} != 0
    605  1.41    martin 	${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKMBR} add -a 1m -s ${SWAPSECTORS} -t swap -l "NBImgSwap"
    606  1.23     joerg .  endif
    607  1.23     joerg .elif ${USE_MBR} != "no"
    608   1.1   tsutsui 	@echo creating MBR labels...
    609   1.1   tsutsui 	${DD} if=/dev/zero of=${WORKMBR} seek=$$((${IMAGESECTORS} - 1)) count=1
    610  1.24   tsutsui .  if ${FATSECTORS} != 0
    611  1.24   tsutsui 	# create BSD partition
    612  1.24   tsutsui 	${TOOL_FDISK} -f -i -u \
    613  1.24   tsutsui 	    -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS}		\
    614  1.24   tsutsui 	    -1 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS}		\
    615  1.24   tsutsui 	    -F ${WORKMBR}
    616  1.24   tsutsui 	# create FAT partition
    617  1.24   tsutsui 	${TOOL_FDISK} -f -u \
    618  1.24   tsutsui 	    -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS}		\
    619  1.24   tsutsui 	    -0 -s ${MBRFAT}/${FATOFFSET}/${FATSECTORS}			\
    620  1.24   tsutsui 	    -F ${WORKMBR}
    621  1.24   tsutsui .  else
    622  1.24   tsutsui 	# create BSD partition
    623   1.5   tsutsui 	${TOOL_FDISK} -f -i -u \
    624   1.1   tsutsui 	    -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS}		\
    625   1.1   tsutsui 	    -0 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS}		\
    626   1.1   tsutsui 	    -F ${WORKMBR}
    627  1.24   tsutsui .  endif
    628  1.23     joerg .  if empty(MBR_BOOTCODE)
    629   1.5   tsutsui 	@if [ -f ${WORKDIR}/usr/mdec/${MBR_DEFAULT_BOOTCODE} ]; then 	\
    630   1.5   tsutsui 		echo ${TOOL_FDISK} -f					\
    631   1.5   tsutsui 		    -i -c ${WORKDIR}/usr/mdec/${MBR_DEFAULT_BOOTCODE}	\
    632   1.5   tsutsui 		    -F ${WORKMBR};					\
    633   1.5   tsutsui 		${TOOL_FDISK} -f					\
    634   1.5   tsutsui 		    -i -c ${WORKDIR}/usr/mdec/${MBR_DEFAULT_BOOTCODE}	\
    635   1.5   tsutsui 		    -F ${WORKMBR};					\
    636   1.5   tsutsui 	fi
    637  1.23     joerg .  else
    638   1.5   tsutsui 	@if [ ! -f ${WORKDIR}/usr/mdec/${MBR_BOOTCODE} ]; then 		\
    639   1.5   tsutsui 		echo "${MBR_BOOTCODE} is not found in DESTDIR/usr/mdec, aborting"; \
    640   1.5   tsutsui 		false; 							\
    641   1.5   tsutsui 	fi
    642   1.5   tsutsui 	${TOOL_FDISK} -f -i -c ${WORKDIR}/usr/mdec/${MBR_BOOTCODE}	\
    643   1.5   tsutsui 	    -F ${WORKMBR}
    644  1.23     joerg .  endif
    645   1.5   tsutsui .endif
    646  1.23     joerg 
    647  1.23     joerg ${WORKGPT}: ${WORKMBR}
    648  1.23     joerg 	@echo create GPT image...
    649  1.32   tsutsui 	${DD} if=${WORKMBR} of=${WORKGPT} \
    650  1.32   tsutsui 	    skip=$$((${IMAGESECTORS} - ${GPTSECTORS})) count=${GPTSECTORS}
    651  1.23     joerg 
    652  1.23     joerg .if ${USE_GPT} == "no"
    653  1.23     joerg ${IMGBASE}.img:	${WORKLABEL}
    654   1.1   tsutsui .endif
    655  1.23     joerg 
    656  1.23     joerg ${IMGBASE}.img:	${TARGET_BLOCKS}
    657  1.23     joerg 	${CAT} ${TARGET_BLOCKS} > ${WORKIMG}
    658  1.23     joerg .if ${USE_GPT} != "no"
    659  1.25  jmcneill .if ${USE_GPTMBR} != "no"
    660  1.33  christos 	${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKIMG} biosboot -i 2		\
    661  1.23     joerg 	    -c ${.OBJDIR}/${WORKDIR}/usr/mdec/gptmbr.bin
    662  1.25  jmcneill .endif
    663  1.33  christos 	${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKIMG} set -a bootme -i 2
    664  1.23     joerg .endif	# USE_GPT != "no"
    665   1.1   tsutsui .if ${USE_SUNLABEL} != "no"
    666   1.1   tsutsui 	@echo Creating sun disklabel...
    667  1.47   tsutsui 	${TOOL_AWK} -f ${DISKPROTO2SUNLABEL} < ${WORKLABEL} | \
    668   1.1   tsutsui 	    ${TOOL_SUNLABEL} -nq ${WORKIMG}
    669   1.1   tsutsui .endif
    670  1.23     joerg .if ${USE_GPT} == "no"
    671   1.1   tsutsui 	${TOOL_DISKLABEL} -R -F ${WORKIMG} ${WORKLABEL}
    672   1.1   tsutsui .if !empty(PRIMARY_BOOT) && ${INSTALLBOOT_AFTER_DISKLABEL} != "no"
    673  1.11  riastrad 	${TOOL_INSTALLBOOT} -v -m ${MACHINE} ${INSTALLBOOTOPTIONS} ${WORKIMG} \
    674   1.1   tsutsui 	    ${WORKDIR}/usr/mdec/${PRIMARY_BOOT}
    675   1.1   tsutsui .endif
    676  1.23     joerg .endif
    677   1.1   tsutsui 	mv ${WORKIMG} ${.TARGET}
    678   1.1   tsutsui 
    679   1.1   tsutsui CLEANFILES+=	${IMGBASE}.img.gz ${IMGBASE}.img.gz.tmp
    680   1.1   tsutsui 
    681   1.1   tsutsui ${IMGBASE}.img.gz:	${IMGBASE}.img
    682   1.9       apb 	${TOOL_GZIP_N} -9c ${IMGBASE}.img > ${.TARGET}.tmp
    683   1.1   tsutsui 	mv ${.TARGET}.tmp ${.TARGET}
    684   1.1   tsutsui 
    685   1.1   tsutsui clean:
    686   1.1   tsutsui 	@if [ -d ${WORKDIR}/var/spool/ftp/hidden ]; then 		\
    687   1.1   tsutsui 		${CHMOD} +r ${WORKDIR}/var/spool/ftp/hidden;		\
    688   1.1   tsutsui 	fi	# XXX
    689   1.1   tsutsui 	${RM} -fr ${WORKDIR}
    690  1.23     joerg 	${RM} -fr ${EFIWORKDIR}
    691  1.24   tsutsui 	${RM} -fr ${WORKFATDIR}
    692  1.50   tsutsui 	${RM} -fr ${WORKMDBOOTPARTDIR}
    693   1.1   tsutsui 
    694   1.1   tsutsui prepare_md_post: .PHONY
    695   1.1   tsutsui image_md_post: .PHONY
    696   1.1   tsutsui image_md_pre: .PHONY
    697   1.1   tsutsui 
    698   1.1   tsutsui .include <bsd.prog.mk>
    699