xref: /freebsd/stand/loader.mk (revision d3e5082ce4dcb154cbf50cba05d8f1dbbd55a5fc)
1.PATH: ${LDRSRC} ${BOOTSRC}/libsa
2
3CFLAGS+=-I${LDRSRC}
4
5SRCS+=	boot.c commands.c console.c devopen.c interp.c
6SRCS+=	interp_backslash.c interp_parse.c ls.c misc.c
7SRCS+=	modinfo.c
8SRCS+=	module.c nvstore.c pnglite.c tslog.c
9
10CFLAGS.module.c += -I$(SRCTOP)/sys/teken -I${SRCTOP}/contrib/pnglite
11
12.PATH: ${SRCTOP}/contrib/pnglite
13CFLAGS.pnglite.c+= -I${SRCTOP}/contrib/pnglite
14CFLAGS.pnglite.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
15
16.if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64"
17SRCS+=	load_elf32.c load_elf32_obj.c reloc_elf32.c
18SRCS+=	load_elf64.c load_elf64_obj.c reloc_elf64.c
19.elif ${MACHINE_CPUARCH} == "aarch64"
20SRCS+=	load_elf64.c reloc_elf64.c
21.elif ${MACHINE_CPUARCH} == "arm"
22SRCS+=	load_elf32.c reloc_elf32.c
23.elif ${MACHINE_CPUARCH} == "powerpc"
24SRCS+=	load_elf32.c reloc_elf32.c
25SRCS+=	load_elf64.c reloc_elf64.c
26SRCS+=	metadata.c
27.elif ${MACHINE_CPUARCH} == "riscv"
28SRCS+=	load_elf64.c reloc_elf64.c
29SRCS+=	metadata.c
30.endif
31
32#
33# LOADER_*_SUPPORT variables are used to subset the boot loader in the various
34# configurations each platform supports. These are typically used to omit broken
35# options, or to size optimize for space constrained instances. These are set in
36# loader Makefiles (which include loader.mk) to control which subset of features
37# are enabled. These cannot generally be set in src.conf since that would affect
38# all loaders, but also not all loaders are setup for overrides like that and
39# not all combinations of the following have been tested or even work. Sometimes
40# non-default values won't work due to buggy support for that component being
41# optional.
42#
43# LOADER_BZIP2_SUPPORT	Add support for bzip2 compressed files
44# LOADER_CD9660_SUPPORT	Add support for iso9660 filesystems
45# LOADER_DISK_SUPPORT	Adds support for disks and mounting filesystems on it
46# LOADER_EXT2FS_SUPPORT	Add support for ext2 Linux filesystems
47# LOADER_GPT_SUPPORT	Add support for GPT partitions
48# LOADER_GZIP_SUPPORT	Add support for gzip compressed files
49# LOADER_INSTALL_SUPPORT Add support for booting off of installl ISOs
50# LOADER_MBR_SUPPORT	Add support for MBR partitions
51# LOADER_MD_SUPPORT	Add support for Memory disks
52# LOADER_MSDOS_SUPPORT	Add support for FAT filesystems
53# LOADER_NET_SUPPORT	Adds networking support (useless w/o net drivers sometimes)
54# LOADER_NFS_SUPPORT	Add NFS support
55# LOADER_TFTP_SUPPORT	Add TFTP support
56# LOADER_UFS_SUPPORT	Add support for UFS filesystems
57# LOADER_XZ_SUPPORT	Add support for xz compressed files
58# LOADER_ZFS_SUPPORT	Add support for ZFS filesystems
59#
60
61.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
62CFLAGS.part.c+= ${ZLIB_CFLAGS}
63SRCS+=	disk.c part.c vdisk.c
64.endif
65
66.if ${LOADER_NET_SUPPORT:Uno} == "yes"
67SRCS+= dev_net.c
68.endif
69
70.if defined(HAVE_BCACHE)
71SRCS+=  bcache.c
72.endif
73
74.if ${LOADER_MD_SUPPORT:Uno} == "yes"
75.if defined(MD_IMAGE_SIZE)
76CFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE}
77.endif
78SRCS+=	md.c
79CLEANFILES+=	md.o
80.endif
81
82# Machine-independent ISA PnP
83.if defined(HAVE_ISABUS)
84SRCS+=	isapnp.c
85.endif
86.if defined(HAVE_PNP)
87SRCS+=	pnp.c
88.endif
89
90.if ${LOADER_INTERP} == "lua"
91SRCS+=	interp_lua.c
92.include "${BOOTSRC}/lua.mk"
93LDR_INTERP=	${LIBLUA}
94LDR_INTERP32=	${LIBLUA32}
95CFLAGS.interp_lua.c= -DLUA_PATH=\"${LUAPATH}\" -I${FLUASRC}/lfs
96.elif ${LOADER_INTERP} == "4th"
97SRCS+=	interp_forth.c
98.include "${BOOTSRC}/ficl.mk"
99LDR_INTERP=	${LIBFICL}
100LDR_INTERP32=	${LIBFICL32}
101.elif ${LOADER_INTERP} == "simp"
102SRCS+=	interp_simple.c
103.else
104.error Unknown interpreter ${LOADER_INTERP}
105.endif
106
107.if defined(BOOT_PROMPT_123)
108CFLAGS+=	-DBOOT_PROMPT_123
109.endif
110
111.if defined(LOADER_INSTALL_SUPPORT)
112SRCS+=	install.c
113.endif
114
115# Filesystem support
116.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
117CFLAGS+=	-DLOADER_CD9660_SUPPORT
118.endif
119.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
120CFLAGS+=	-DLOADER_EXT2FS_SUPPORT
121.endif
122.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
123CFLAGS+=	-DLOADER_MSDOS_SUPPORT
124.endif
125.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
126CFLAGS+=	-DLOADER_UFS_SUPPORT
127.endif
128
129# Compression
130.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
131CFLAGS+=	-DLOADER_GZIP_SUPPORT
132.endif
133.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
134CFLAGS+=	-DLOADER_BZIP2_SUPPORT
135.endif
136.if ${LOADER_XZ_SUPPORT:Uno} == "yes"
137CFLAGS+=	-DLOADER_XZ_SUPPORT
138.endif
139
140# Network related things (LOADER_NET_SUPPORT itself: see defs.mk)
141.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
142CFLAGS+=	-DLOADER_NFS_SUPPORT
143.endif
144.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
145CFLAGS+=	-DLOADER_TFTP_SUPPORT
146.endif
147
148# Partition support
149.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
150CFLAGS+= -DLOADER_GPT_SUPPORT
151.endif
152.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
153CFLAGS+= -DLOADER_MBR_SUPPORT
154.endif
155
156.if ${HAVE_ZFS:Uno} == "yes"
157CFLAGS+=	-DLOADER_ZFS_SUPPORT
158CFLAGS+=	-I${SAZFSSRC}
159CFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
160CFLAGS+=	-I${SYSDIR}/cddl/contrib/opensolaris/uts/common
161SRCS+=		zfs_cmd.c
162.endif
163
164LIBFICL=	${BOOTOBJ}/ficl/libficl.a
165.if ${MACHINE} == "i386"
166LIBFICL32=	${LIBFICL}
167.else
168LIBFICL32=	${BOOTOBJ}/${"${LOADER}" == "loader_ia32":?efi/ficl32efi:ficl32}/libficl.a
169.endif
170
171LIBLUA=		${BOOTOBJ}/liblua/liblua.a
172.if ${MACHINE} == "i386"
173LIBLUA32=	${LIBLUA}
174.else
175LIBLUA32=	${BOOTOBJ}/${"${LOADER}" == "loader_ia32":?efi/liblua32efi:liblua32}/liblua.a
176.endif
177
178CLEANFILES+=	vers.c
179VERSION_FILE?=	${.CURDIR}/version
180.if ${MK_REPRODUCIBLE_BUILD} != no
181REPRO_FLAG=	-r
182.endif
183vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
184	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
185	    ${NEWVERSWHAT}
186
187.if ${MK_LOADER_VERBOSE} != "no"
188CFLAGS+=	-DELF_VERBOSE
189.endif
190
191# Each loader variant defines their own help filename. Optional or
192# build-specific commands are included by augmenting HELP_FILES.
193.if !defined(HELP_FILENAME)
194.error Define HELP_FILENAME before including loader.mk
195.endif
196
197HELP_FILES+=	${LDRSRC}/help.common
198
199CFLAGS+=	-DHELP_FILENAME=\"${HELP_FILENAME}\"
200.if ${INSTALL_LOADER_HELP_FILE:Uyes} == "yes"
201CLEANFILES+=	${HELP_FILENAME}
202FILES+=		${HELP_FILENAME}
203.endif
204
205${HELP_FILENAME}: ${HELP_FILES}
206	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
207