xref: /freebsd/stand/loader.mk (revision 358752abdf1c44d15e99bc2709b0256a358fd2a9)
1ca987d46SWarner Losh.PATH: ${LDRSRC} ${BOOTSRC}/libsa
2ca987d46SWarner Losh
3ca987d46SWarner LoshCFLAGS+=-I${LDRSRC}
4ca987d46SWarner Losh
5ca987d46SWarner LoshSRCS+=	boot.c commands.c console.c devopen.c interp.c
6ca987d46SWarner LoshSRCS+=	interp_backslash.c interp_parse.c ls.c misc.c
75d1531d9SWarner LoshSRCS+=	modinfo.c
8c8dfc327SColin PercivalSRCS+=	module.c nvstore.c pnglite.c tslog.c
9ca987d46SWarner Losh
103630506bSToomas SoomeCFLAGS.module.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite
113630506bSToomas Soome
12a3479cfdSToomas Soome.PATH: ${SRCTOP}/contrib/pnglite
13a3479cfdSToomas SoomeCFLAGS.pnglite.c+= -I${SRCTOP}/contrib/pnglite
14a3479cfdSToomas SoomeCFLAGS.pnglite.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
15a3479cfdSToomas Soome
16ca987d46SWarner Losh.if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64"
17ca987d46SWarner LoshSRCS+=	load_elf32.c load_elf32_obj.c reloc_elf32.c
18ca987d46SWarner LoshSRCS+=	load_elf64.c load_elf64_obj.c reloc_elf64.c
19ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "aarch64"
20ca987d46SWarner LoshSRCS+=	load_elf64.c reloc_elf64.c
21ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "arm"
22ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
23ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "powerpc"
24ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
25ca987d46SWarner LoshSRCS+=	load_elf64.c reloc_elf64.c
26d3e1307bSJustin HibbitsSRCS+=	metadata.c
272192efc0SMitchell Horne.elif ${MACHINE_CPUARCH} == "riscv"
282192efc0SMitchell HorneSRCS+=	load_elf64.c reloc_elf64.c
292192efc0SMitchell HorneSRCS+=	metadata.c
30ca987d46SWarner Losh.endif
31ca987d46SWarner Losh
32*358752abSWarner Losh#
33*358752abSWarner Losh# LOADER_*_SUPPORT variables are used to subset the boot loader in the various
34*358752abSWarner Losh# configurations each platform supports. These are typically used to omit broken
35*358752abSWarner Losh# options, or to size optimize for space constrained instances. These are set in
36*358752abSWarner Losh# loader Makefiles (which include loader.mk) to control which subset of features
37*358752abSWarner Losh# are enabled. These cannot generally be set in src.conf since that would affect
38*358752abSWarner Losh# all loaders, but also not all loaders are setup for overrides like that and
39*358752abSWarner Losh# not all combinations of the following have been tested or even work. Sometimes
40*358752abSWarner Losh# non-default values won't work due to buggy support for that component being
41*358752abSWarner Losh# optional.
42*358752abSWarner Losh#
43*358752abSWarner Losh# LOADER_BZIP2_SUPPORT	Add support for bzip2 compressed files
44*358752abSWarner Losh# LOADER_CD9660_SUPPORT	Add support for iso9660 filesystems
45*358752abSWarner Losh# LOADER_DISK_SUPPORT	Adds support for disks and mounting filesystems on it
46*358752abSWarner Losh# LOADER_EXT2FS_SUPPORT	Add support for ext2 Linux filesystems
47*358752abSWarner Losh# LOADER_GPT_SUPPORT	Add support for GPT partitions
48*358752abSWarner Losh# LOADER_GZIP_SUPPORT	Add support for gzip compressed files
49*358752abSWarner Losh# LOADER_INSTALL_SUPPORT Add support for booting off of installl ISOs
50*358752abSWarner Losh# LOADER_MBR_SUPPORT	Add support for MBR partitions
51*358752abSWarner Losh# LOADER_MSDOS_SUPPORT	Add support for FAT filesystems
52*358752abSWarner Losh# LOADER_NET_SUPPORT	Adds networking support (useless w/o net drivers sometimes)
53*358752abSWarner Losh# LOADER_NFS_SUPPORT	Add NFS support
54*358752abSWarner Losh# LOADER_TFTP_SUPPORT	Add TFTP support
55*358752abSWarner Losh# LOADER_UFS_SUPPORT	Add support for UFS filesystems
56*358752abSWarner Losh# LOADER_ZFS_SUPPORT	Add support for ZFS filesystems
57*358752abSWarner Losh#
58*358752abSWarner Losh
59ca987d46SWarner Losh.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
6027bae615SToomas SoomeCFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
614914ee11SToomas SoomeSRCS+=	disk.c part.c vdisk.c
62ca987d46SWarner Losh.endif
63ca987d46SWarner Losh
64ca987d46SWarner Losh.if ${LOADER_NET_SUPPORT:Uno} == "yes"
65ca987d46SWarner LoshSRCS+= dev_net.c
66ca987d46SWarner Losh.endif
67ca987d46SWarner Losh
68ca987d46SWarner Losh.if defined(HAVE_BCACHE)
69ca987d46SWarner LoshSRCS+=  bcache.c
70ca987d46SWarner Losh.endif
71ca987d46SWarner Losh
72ca987d46SWarner Losh.if defined(MD_IMAGE_SIZE)
73ca987d46SWarner LoshCFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE}
74ca987d46SWarner LoshSRCS+=	md.c
75ca987d46SWarner Losh.else
76ca987d46SWarner LoshCLEANFILES+=	md.o
77ca987d46SWarner Losh.endif
78ca987d46SWarner Losh
79c44b5e09SGordon Bergling# Machine-independent ISA PnP
80ca987d46SWarner Losh.if defined(HAVE_ISABUS)
81ca987d46SWarner LoshSRCS+=	isapnp.c
82ca987d46SWarner Losh.endif
83ca987d46SWarner Losh.if defined(HAVE_PNP)
84ca987d46SWarner LoshSRCS+=	pnp.c
85ca987d46SWarner Losh.endif
86ca987d46SWarner Losh
879d45c24cSWarner Losh.if ${LOADER_INTERP} == "lua"
887cafeaa1SWarner LoshSRCS+=	interp_lua.c
897cafeaa1SWarner Losh.include "${BOOTSRC}/lua.mk"
907cafeaa1SWarner LoshLDR_INTERP=	${LIBLUA}
917cafeaa1SWarner LoshLDR_INTERP32=	${LIBLUA32}
92506f3640SKyle EvansCFLAGS.interp_lua.c= -DLUA_PATH=\"${LUAPATH}\" -I${FLUASRC}/modules
939d45c24cSWarner Losh.elif ${LOADER_INTERP} == "4th"
94ca987d46SWarner LoshSRCS+=	interp_forth.c
95ca987d46SWarner Losh.include "${BOOTSRC}/ficl.mk"
967cafeaa1SWarner LoshLDR_INTERP=	${LIBFICL}
977cafeaa1SWarner LoshLDR_INTERP32=	${LIBFICL32}
989d45c24cSWarner Losh.elif ${LOADER_INTERP} == "simp"
9979a6a17aSWarner LoshSRCS+=	interp_simple.c
1009d45c24cSWarner Losh.else
1019d45c24cSWarner Losh.error Unknown interpreter ${LOADER_INTERP}
102ca987d46SWarner Losh.endif
103ca987d46SWarner Losh
104eda28febSEric van Gyzen.include "${BOOTSRC}/veriexec.mk"
105b0fefb25SMarcin Wojtas
106ca987d46SWarner Losh.if defined(BOOT_PROMPT_123)
107ca987d46SWarner LoshCFLAGS+=	-DBOOT_PROMPT_123
108ca987d46SWarner Losh.endif
109ca987d46SWarner Losh
110ca987d46SWarner Losh.if defined(LOADER_INSTALL_SUPPORT)
111ca987d46SWarner LoshSRCS+=	install.c
112ca987d46SWarner Losh.endif
113ca987d46SWarner Losh
1144927bbceSWarner Losh# Filesystem support
1154927bbceSWarner Losh.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
1164927bbceSWarner LoshCFLAGS+=	-DLOADER_CD9660_SUPPORT
1174927bbceSWarner Losh.endif
1184927bbceSWarner Losh.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
1194927bbceSWarner LoshCFLAGS+=	-DLOADER_EXT2FS_SUPPORT
1204927bbceSWarner Losh.endif
1214927bbceSWarner Losh.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
1224927bbceSWarner LoshCFLAGS+=	-DLOADER_MSDOS_SUPPORT
1234927bbceSWarner Losh.endif
1244927bbceSWarner Losh.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
1254927bbceSWarner LoshCFLAGS+=	-DLOADER_UFS_SUPPORT
1264927bbceSWarner Losh.endif
1274927bbceSWarner Losh
1284927bbceSWarner Losh# Compression
1294927bbceSWarner Losh.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
1304927bbceSWarner LoshCFLAGS+=	-DLOADER_GZIP_SUPPORT
1314927bbceSWarner Losh.endif
1324927bbceSWarner Losh.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
1334927bbceSWarner LoshCFLAGS+=	-DLOADER_BZIP2_SUPPORT
1344927bbceSWarner Losh.endif
1354927bbceSWarner Losh
1364927bbceSWarner Losh# Network related things
1374927bbceSWarner Losh.if ${LOADER_NET_SUPPORT:Uno} == "yes"
1384927bbceSWarner LoshCFLAGS+=	-DLOADER_NET_SUPPORT
1394927bbceSWarner Losh.endif
1404927bbceSWarner Losh.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
1414927bbceSWarner LoshCFLAGS+=	-DLOADER_NFS_SUPPORT
1424927bbceSWarner Losh.endif
1434927bbceSWarner Losh.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
1444927bbceSWarner LoshCFLAGS+=	-DLOADER_TFTP_SUPPORT
1454927bbceSWarner Losh.endif
1464927bbceSWarner Losh
1478701bb8fSWarner Losh# Partition support
1484927bbceSWarner Losh.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
1494927bbceSWarner LoshCFLAGS+= -DLOADER_GPT_SUPPORT
1504927bbceSWarner Losh.endif
1514927bbceSWarner Losh.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
1524927bbceSWarner LoshCFLAGS+= -DLOADER_MBR_SUPPORT
1534927bbceSWarner Losh.endif
1544927bbceSWarner Losh
155060679efSWarner Losh.if ${HAVE_ZFS:Uno} == "yes"
156ca987d46SWarner LoshCFLAGS+=	-DLOADER_ZFS_SUPPORT
157ca987d46SWarner LoshCFLAGS+=	-I${ZFSSRC}
158ca987d46SWarner LoshCFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
1593830659eSToomas SoomeCFLAGS+=	-I${SYSDIR}/cddl/contrib/opensolaris/uts/common
1604784aef9SWarner LoshSRCS+=		zfs_cmd.c
161ca987d46SWarner Losh.endif
162ca987d46SWarner Losh
16376a8f5b0SWarner LoshLIBFICL=	${BOOTOBJ}/ficl/libficl.a
16476a8f5b0SWarner Losh.if ${MACHINE} == "i386"
16576a8f5b0SWarner LoshLIBFICL32=	${LIBFICL}
16676a8f5b0SWarner Losh.else
16776a8f5b0SWarner LoshLIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
16876a8f5b0SWarner Losh.endif
1697cafeaa1SWarner Losh
1707cafeaa1SWarner LoshLIBLUA=		${BOOTOBJ}/liblua/liblua.a
1717cafeaa1SWarner Losh.if ${MACHINE} == "i386"
172cc8ea7cfSKyle EvansLIBLUA32=	${LIBLUA}
1737cafeaa1SWarner Losh.else
1747cafeaa1SWarner LoshLIBLUA32=	${BOOTOBJ}/liblua32/liblua.a
17576a8f5b0SWarner Losh.endif
17676a8f5b0SWarner Losh
177ca987d46SWarner LoshCLEANFILES+=	vers.c
178ca987d46SWarner LoshVERSION_FILE?=	${.CURDIR}/version
179ca987d46SWarner Losh.if ${MK_REPRODUCIBLE_BUILD} != no
180ca987d46SWarner LoshREPRO_FLAG=	-r
181ca987d46SWarner Losh.endif
182ca987d46SWarner Loshvers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
183ca987d46SWarner Losh	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
184ca987d46SWarner Losh	    ${NEWVERSWHAT}
185ca987d46SWarner Losh
186f871c5d9SWarner Losh.if ${MK_LOADER_VERBOSE} != "no"
187f871c5d9SWarner LoshCFLAGS+=	-DELF_VERBOSE
188f871c5d9SWarner Losh.endif
189f871c5d9SWarner Losh
19088599604SMitchell Horne# Each loader variant defines their own help filename. Optional or
19188599604SMitchell Horne# build-specific commands are included by augmenting HELP_FILES.
19288599604SMitchell Horne.if !defined(HELP_FILENAME)
19388599604SMitchell Horne.error Define HELP_FILENAME before including loader.mk
19488599604SMitchell Horne.endif
19588599604SMitchell Horne
19625c2f4cbSWarner LoshHELP_FILES+=	${LDRSRC}/help.common
19725c2f4cbSWarner Losh
19888599604SMitchell HorneCFLAGS+=	-DHELP_FILENAME=\"${HELP_FILENAME}\"
199e32fecd0SEd Maste.if ${INSTALL_LOADER_HELP_FILE:Uyes} == "yes"
20088599604SMitchell HorneCLEANFILES+=	${HELP_FILENAME}
20188599604SMitchell HorneFILES+=		${HELP_FILENAME}
202e32fecd0SEd Maste.endif
203ca987d46SWarner Losh
20488599604SMitchell Horne${HELP_FILENAME}: ${HELP_FILES}
205ca987d46SWarner Losh	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
206