# $NetBSD: Makefile.bootimage,v 1.46 2025/04/26 03:01:39 pgoyette Exp $
#
# Copyright (c) 2009, 2010, 2011 Izumi Tsutsui. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Makefile to create a bootable FS image for USB flash or emulators
#
#
# Required variables:
# RELEASEDIR
# Should be defined in nbmake-${MACHINE}
# IMGBASE
# Basename of the image
#
# Optional variables:
# USE_MBR
# set yes if target disk image requires MBR partition
# (default: no)
# USE_GPT
# set yes if target disk image requires GPT partition
# (default: no)
# USE_GPTMBR
# set yes if target disk image requires GPT partition
# with hybrid MBR boot code
# (default: no; valid only if USE_GPT=yes)
# MBR_BOOTCODE
# optional MBR bootcode which should be installed by fdisk(8)
# (default: empty)
# - specified MBR_BOOTCODE must exist in ${DESTDIR}/usr/mdec
# - if MBR_BOOTCODE is not specified,
# MBR_DEFAULT_BOOTCODE (default: mbr) will be used
# if the target ${MACHINE} has the one in /usr/mdec
# USE_SUNLABEL
# set yes if target disk image requires Sun's label
# (default: no)
# INSTALLBOOT_AFTER_DISKLABEL
# set yes if the target ${MACHINE} requires disklabel
# to run installboot(8), like hp300 and vax
# (default: empty)
# IMAGEMB
# target image size in MB
# (default: 2048)
# SWAPMB
# swap size in target image in MB
# (default: 128)
# EFIMB
# EFI partition size in target image in MB
# (default: 128)
# FATMB
# FAT partition size in target image in MB
# (default: 0)
# GPTSECTORS
# Size of a region reserved for the secondary GPT table/entry
# at the end of the target image in sectors
# (default: 2048 if USE_GPT=yes, otherwise 0)
# KERN_SET
# kernel set name which should be extracted into image
# (default: kern-GENERIC)
# SETS
# binary sets that should be extracted into image
# (default: modules base etc comp games gpufw man manhtml misc
# rescue tests text xbase xcomp xetc xfont xserver)
# SETS_DIR
# directory path where binary sets are stored
# (default: ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets)
# IMGFILE_EXTRA
# list of additional files to be copied into images,
# containing one or more tuples of the form:
# FILE TARGETPATH
# for installation image etc.
# (default: empty)
# IMGDIR_EXTRA
# list of additional directories to be copied into images,
# containing one or more tuples of the form:
# DIR TARGETPATH
# for installation image etc.
# (default: empty)
# XXX: currently permissions in IMGDIR_EXTRA are not handled
# IMGDIR_EXCLUDE
# pax(1) options to exclude files which should not copied
# into TARGETPATH in IMGDIR_EXTRA
# (default: empty)
# FSTAB_IN
# template file of /etc/fstab
# (default: ${DISTRIBDIR}/common/bootimage/fstab.in)
# SPEC_IN
# default files of spec file for makefs(8)
# (default: ${DISTRIBDIR}/common/bootimage/spec.in)
# SPEC_EXTRA
# additional files of spec file for makefs(8)
# (default: empty)
# IMGMAKEFSOPTIONS
# options passed to makefs(8) to create root file system
# (default: -o bsize=16384,fsize=2048,density=8192)
# IMGFFSVERSION
# version of FFS created by makefs(8)
# (default: 1)
# INSTALLBOOTOPTIONS
# options passed to installboot(8), e.g., -o console=com0
# (default: empty)
# PRIMARY_BOOT
# primary boot loader that should be installed into
# the target image via installboot(8)
# (default: empty)
# SECONDARY_BOOT
# secondary bootloader that should be put into the target image
# (default: empty)
# SECONDARY_BOOT_ARG
# extra arguments that should be passed to installboot(8)
# to specify the secondary bootloader
# (default: empty)
# DISKPROTO_IN
# template file of disklabel -R
# (default: ${DISTRIBDIR}/common/bootimage/diskproto.in
# or ${DISTRIBDIR}/common/bootimage/diskproto.mbr.in)
# EFIBOOT
# EFI bootloader
# (default: empty)
# MBRFAT
# MBR partition type value for FAT
# (default: 6 ("16-bit FAT, more than 32M"))
# FATMAKEFSOPTIONS
# options passed to makefs(8) to create a FAT partition
# (default: -o fat_type=16)
# FATFILES
# list of additional files to be copied into FAT partition
# (default: empty)
# IMAGEHOSTNAME
# if set, sets the default hostname in rc.conf (default: empty)
#
include <bsd.own.mk> #
include <bsd.endian.mk> # for TARGET_ENDIANNESS
include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"