xref: /freebsd/stand/loader.mk (revision 3830659e99640001c09d26dfc0e1bbd77d919a62)
1ca987d46SWarner Losh# $FreeBSD$
2ca987d46SWarner Losh
3ca987d46SWarner Losh.PATH: ${LDRSRC} ${BOOTSRC}/libsa
4ca987d46SWarner Losh
5ca987d46SWarner LoshCFLAGS+=-I${LDRSRC}
6ca987d46SWarner Losh
7ca987d46SWarner LoshSRCS+=	boot.c commands.c console.c devopen.c interp.c
8ca987d46SWarner LoshSRCS+=	interp_backslash.c interp_parse.c ls.c misc.c
9ca987d46SWarner LoshSRCS+=	module.c
10ca987d46SWarner Losh
11ca987d46SWarner Losh.if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64"
12ca987d46SWarner LoshSRCS+=	load_elf32.c load_elf32_obj.c reloc_elf32.c
13ca987d46SWarner LoshSRCS+=	load_elf64.c load_elf64_obj.c reloc_elf64.c
14ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "aarch64"
15ca987d46SWarner LoshSRCS+=	load_elf64.c reloc_elf64.c
16ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "arm"
17ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
18ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "powerpc"
19ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
20ca987d46SWarner LoshSRCS+=	load_elf64.c reloc_elf64.c
21d3e1307bSJustin HibbitsSRCS+=	metadata.c
22ca987d46SWarner Losh.elif ${MACHINE_ARCH:Mmips64*} != ""
23ca987d46SWarner LoshSRCS+= load_elf64.c reloc_elf64.c
24d3e1307bSJustin HibbitsSRCS+=	metadata.c
25ca987d46SWarner Losh.elif ${MACHINE} == "mips"
26ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
27d3e1307bSJustin HibbitsSRCS+=	metadata.c
28ca987d46SWarner Losh.endif
29ca987d46SWarner Losh
30ca987d46SWarner Losh.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
3127bae615SToomas SoomeCFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
324914ee11SToomas SoomeSRCS+=	disk.c part.c vdisk.c
33ca987d46SWarner Losh.endif
34ca987d46SWarner Losh
35ca987d46SWarner Losh.if ${LOADER_NET_SUPPORT:Uno} == "yes"
36ca987d46SWarner LoshSRCS+= dev_net.c
37ca987d46SWarner Losh.endif
38ca987d46SWarner Losh
39ca987d46SWarner Losh.if defined(HAVE_BCACHE)
40ca987d46SWarner LoshSRCS+=  bcache.c
41ca987d46SWarner Losh.endif
42ca987d46SWarner Losh
43ca987d46SWarner Losh.if defined(MD_IMAGE_SIZE)
44ca987d46SWarner LoshCFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE}
45ca987d46SWarner LoshSRCS+=	md.c
46ca987d46SWarner Losh.else
47ca987d46SWarner LoshCLEANFILES+=	md.o
48ca987d46SWarner Losh.endif
49ca987d46SWarner Losh
50ca987d46SWarner Losh# Machine-independant ISA PnP
51ca987d46SWarner Losh.if defined(HAVE_ISABUS)
52ca987d46SWarner LoshSRCS+=	isapnp.c
53ca987d46SWarner Losh.endif
54ca987d46SWarner Losh.if defined(HAVE_PNP)
55ca987d46SWarner LoshSRCS+=	pnp.c
56ca987d46SWarner Losh.endif
57ca987d46SWarner Losh
589d45c24cSWarner Losh.if ${LOADER_INTERP} == "lua"
597cafeaa1SWarner LoshSRCS+=	interp_lua.c
607cafeaa1SWarner Losh.include "${BOOTSRC}/lua.mk"
617cafeaa1SWarner LoshLDR_INTERP=	${LIBLUA}
627cafeaa1SWarner LoshLDR_INTERP32=	${LIBLUA32}
63506f3640SKyle EvansCFLAGS.interp_lua.c= -DLUA_PATH=\"${LUAPATH}\" -I${FLUASRC}/modules
649d45c24cSWarner Losh.elif ${LOADER_INTERP} == "4th"
65ca987d46SWarner LoshSRCS+=	interp_forth.c
66ca987d46SWarner Losh.include "${BOOTSRC}/ficl.mk"
677cafeaa1SWarner LoshLDR_INTERP=	${LIBFICL}
687cafeaa1SWarner LoshLDR_INTERP32=	${LIBFICL32}
699d45c24cSWarner Losh.elif ${LOADER_INTERP} == "simp"
7079a6a17aSWarner LoshSRCS+=	interp_simple.c
719d45c24cSWarner Losh.else
729d45c24cSWarner Losh.error Unknown interpreter ${LOADER_INTERP}
73ca987d46SWarner Losh.endif
74ca987d46SWarner Losh
758df8b2d3SSimon J. Gerraty.if ${MK_LOADER_VERIEXEC} != "no"
768df8b2d3SSimon J. GerratyCFLAGS+= -DLOADER_VERIEXEC -I${SRCTOP}/lib/libsecureboot/h
77afc571b1SSimon J. Gerraty.if ${MK_LOADER_VERIEXEC_VECTX} != "no"
78afc571b1SSimon J. GerratyCFLAGS+= -DLOADER_VERIEXEC_VECTX
79afc571b1SSimon J. Gerraty.endif
808df8b2d3SSimon J. Gerraty.endif
818df8b2d3SSimon J. Gerraty
82b0fefb25SMarcin Wojtas.if ${MK_LOADER_VERIEXEC_PASS_MANIFEST} != "no"
83b0fefb25SMarcin WojtasCFLAGS+= -DLOADER_VERIEXEC_PASS_MANIFEST -I${SRCTOP}/lib/libsecureboot/h
84b0fefb25SMarcin Wojtas.endif
85b0fefb25SMarcin Wojtas
86ca987d46SWarner Losh.if defined(BOOT_PROMPT_123)
87ca987d46SWarner LoshCFLAGS+=	-DBOOT_PROMPT_123
88ca987d46SWarner Losh.endif
89ca987d46SWarner Losh
90ca987d46SWarner Losh.if defined(LOADER_INSTALL_SUPPORT)
91ca987d46SWarner LoshSRCS+=	install.c
92ca987d46SWarner Losh.endif
93ca987d46SWarner Losh
944927bbceSWarner Losh# Filesystem support
954927bbceSWarner Losh.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
964927bbceSWarner LoshCFLAGS+=	-DLOADER_CD9660_SUPPORT
974927bbceSWarner Losh.endif
984927bbceSWarner Losh.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
994927bbceSWarner LoshCFLAGS+=	-DLOADER_EXT2FS_SUPPORT
1004927bbceSWarner Losh.endif
1014927bbceSWarner Losh.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
1024927bbceSWarner LoshCFLAGS+=	-DLOADER_MSDOS_SUPPORT
1034927bbceSWarner Losh.endif
1044927bbceSWarner Losh.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
1054927bbceSWarner LoshCFLAGS+=	-DLOADER_UFS_SUPPORT
1064927bbceSWarner Losh.endif
1074927bbceSWarner Losh
1084927bbceSWarner Losh# Compression
1094927bbceSWarner Losh.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
1104927bbceSWarner LoshCFLAGS+=	-DLOADER_GZIP_SUPPORT
1114927bbceSWarner Losh.endif
1124927bbceSWarner Losh.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
1134927bbceSWarner LoshCFLAGS+=	-DLOADER_BZIP2_SUPPORT
1144927bbceSWarner Losh.endif
1154927bbceSWarner Losh
1164927bbceSWarner Losh# Network related things
1174927bbceSWarner Losh.if ${LOADER_NET_SUPPORT:Uno} == "yes"
1184927bbceSWarner LoshCFLAGS+=	-DLOADER_NET_SUPPORT
1194927bbceSWarner Losh.endif
1204927bbceSWarner Losh.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
1214927bbceSWarner LoshCFLAGS+=	-DLOADER_NFS_SUPPORT
1224927bbceSWarner Losh.endif
1234927bbceSWarner Losh.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
1244927bbceSWarner LoshCFLAGS+=	-DLOADER_TFTP_SUPPORT
1254927bbceSWarner Losh.endif
1264927bbceSWarner Losh
1278701bb8fSWarner Losh# Partition support
1284927bbceSWarner Losh.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
1294927bbceSWarner LoshCFLAGS+= -DLOADER_GPT_SUPPORT
1304927bbceSWarner Losh.endif
1314927bbceSWarner Losh.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
1324927bbceSWarner LoshCFLAGS+= -DLOADER_MBR_SUPPORT
1334927bbceSWarner Losh.endif
1344927bbceSWarner Losh
135060679efSWarner Losh.if ${HAVE_ZFS:Uno} == "yes"
136ca987d46SWarner LoshCFLAGS+=	-DLOADER_ZFS_SUPPORT
137ca987d46SWarner LoshCFLAGS+=	-I${ZFSSRC}
138ca987d46SWarner LoshCFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
139*3830659eSToomas SoomeCFLAGS+=	-I${SYSDIR}/cddl/contrib/opensolaris/uts/common
1404784aef9SWarner LoshSRCS+=		zfs_cmd.c
141ca987d46SWarner Losh.endif
142ca987d46SWarner Losh
14376a8f5b0SWarner LoshLIBFICL=	${BOOTOBJ}/ficl/libficl.a
14476a8f5b0SWarner Losh.if ${MACHINE} == "i386"
14576a8f5b0SWarner LoshLIBFICL32=	${LIBFICL}
14676a8f5b0SWarner Losh.else
14776a8f5b0SWarner LoshLIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
14876a8f5b0SWarner Losh.endif
1497cafeaa1SWarner Losh
1507cafeaa1SWarner LoshLIBLUA=		${BOOTOBJ}/liblua/liblua.a
1517cafeaa1SWarner Losh.if ${MACHINE} == "i386"
152cc8ea7cfSKyle EvansLIBLUA32=	${LIBLUA}
1537cafeaa1SWarner Losh.else
1547cafeaa1SWarner LoshLIBLUA32=	${BOOTOBJ}/liblua32/liblua.a
15576a8f5b0SWarner Losh.endif
15676a8f5b0SWarner Losh
157ca987d46SWarner LoshCLEANFILES+=	vers.c
158ca987d46SWarner LoshVERSION_FILE?=	${.CURDIR}/version
159ca987d46SWarner Losh.if ${MK_REPRODUCIBLE_BUILD} != no
160ca987d46SWarner LoshREPRO_FLAG=	-r
161ca987d46SWarner Losh.endif
162ca987d46SWarner Loshvers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
163ca987d46SWarner Losh	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
164ca987d46SWarner Losh	    ${NEWVERSWHAT}
165ca987d46SWarner Losh
166f871c5d9SWarner Losh.if ${MK_LOADER_VERBOSE} != "no"
167f871c5d9SWarner LoshCFLAGS+=	-DELF_VERBOSE
168f871c5d9SWarner Losh.endif
169f871c5d9SWarner Losh
170ca987d46SWarner Losh.if !empty(HELP_FILES)
17125c2f4cbSWarner LoshHELP_FILES+=	${LDRSRC}/help.common
17225c2f4cbSWarner Losh
173ca987d46SWarner LoshCLEANFILES+=	loader.help
174ca987d46SWarner LoshFILES+=		loader.help
175ca987d46SWarner Losh
176ca987d46SWarner Loshloader.help: ${HELP_FILES}
177ca987d46SWarner Losh	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
178ca987d46SWarner Losh.endif
179