xref: /freebsd/stand/loader.mk (revision f871c5d99d1efb11136a7f39b640e25afa971df9)
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_CPUARCH} == "sparc64"
23ca987d46SWarner LoshSRCS+=	load_elf64.c reloc_elf64.c
24d3e1307bSJustin HibbitsSRCS+=	metadata.c
25ca987d46SWarner Losh.elif ${MACHINE_ARCH:Mmips64*} != ""
26ca987d46SWarner LoshSRCS+= load_elf64.c reloc_elf64.c
27d3e1307bSJustin HibbitsSRCS+=	metadata.c
28ca987d46SWarner Losh.elif ${MACHINE} == "mips"
29ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
30d3e1307bSJustin HibbitsSRCS+=	metadata.c
31ca987d46SWarner Losh.endif
32ca987d46SWarner Losh
33ca987d46SWarner Losh.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
34ca987d46SWarner LoshSRCS+=	disk.c part.c
35ca987d46SWarner Losh.endif
36ca987d46SWarner Losh
37ca987d46SWarner Losh.if ${LOADER_NET_SUPPORT:Uno} == "yes"
38ca987d46SWarner LoshSRCS+= dev_net.c
39ca987d46SWarner Losh.endif
40ca987d46SWarner Losh
41ca987d46SWarner Losh.if defined(HAVE_BCACHE)
42ca987d46SWarner LoshSRCS+=  bcache.c
43ca987d46SWarner Losh.endif
44ca987d46SWarner Losh
45ca987d46SWarner Losh.if defined(MD_IMAGE_SIZE)
46ca987d46SWarner LoshCFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE}
47ca987d46SWarner LoshSRCS+=	md.c
48ca987d46SWarner Losh.else
49ca987d46SWarner LoshCLEANFILES+=	md.o
50ca987d46SWarner Losh.endif
51ca987d46SWarner Losh
52ca987d46SWarner Losh# Machine-independant ISA PnP
53ca987d46SWarner Losh.if defined(HAVE_ISABUS)
54ca987d46SWarner LoshSRCS+=	isapnp.c
55ca987d46SWarner Losh.endif
56ca987d46SWarner Losh.if defined(HAVE_PNP)
57ca987d46SWarner LoshSRCS+=	pnp.c
58ca987d46SWarner Losh.endif
59ca987d46SWarner Losh
609d45c24cSWarner Losh.if ${LOADER_INTERP} == "lua"
617cafeaa1SWarner LoshSRCS+=	interp_lua.c
627cafeaa1SWarner Losh.include "${BOOTSRC}/lua.mk"
637cafeaa1SWarner LoshLDR_INTERP=	${LIBLUA}
647cafeaa1SWarner LoshLDR_INTERP32=	${LIBLUA32}
659d45c24cSWarner Losh.elif ${LOADER_INTERP} == "4th"
66ca987d46SWarner LoshSRCS+=	interp_forth.c
67ca987d46SWarner Losh.include "${BOOTSRC}/ficl.mk"
687cafeaa1SWarner LoshLDR_INTERP=	${LIBFICL}
697cafeaa1SWarner LoshLDR_INTERP32=	${LIBFICL32}
709d45c24cSWarner Losh.elif ${LOADER_INTERP} == "simp"
7179a6a17aSWarner LoshSRCS+=	interp_simple.c
729d45c24cSWarner Losh.else
739d45c24cSWarner Losh.error Unknown interpreter ${LOADER_INTERP}
74ca987d46SWarner Losh.endif
75ca987d46SWarner Losh
76ca987d46SWarner Losh.if defined(BOOT_PROMPT_123)
77ca987d46SWarner LoshCFLAGS+=	-DBOOT_PROMPT_123
78ca987d46SWarner Losh.endif
79ca987d46SWarner Losh
80ca987d46SWarner Losh.if defined(LOADER_INSTALL_SUPPORT)
81ca987d46SWarner LoshSRCS+=	install.c
82ca987d46SWarner Losh.endif
83ca987d46SWarner Losh
844927bbceSWarner Losh# Filesystem support
854927bbceSWarner Losh.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
864927bbceSWarner LoshCFLAGS+=	-DLOADER_CD9660_SUPPORT
874927bbceSWarner Losh.endif
884927bbceSWarner Losh.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
894927bbceSWarner LoshCFLAGS+=	-DLOADER_EXT2FS_SUPPORT
904927bbceSWarner Losh.endif
914927bbceSWarner Losh.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
924927bbceSWarner LoshCFLAGS+=	-DLOADER_MSDOS_SUPPORT
934927bbceSWarner Losh.endif
944927bbceSWarner Losh.if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes"
954927bbceSWarner LoshCFLAGS+=	-DLOADER_NANDFS_SUPPORT
964927bbceSWarner Losh.endif
974927bbceSWarner Losh.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
984927bbceSWarner LoshCFLAGS+=	-DLOADER_UFS_SUPPORT
994927bbceSWarner Losh.endif
1004927bbceSWarner Losh
1014927bbceSWarner Losh# Compression
1024927bbceSWarner Losh.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
1034927bbceSWarner LoshCFLAGS+=	-DLOADER_GZIP_SUPPORT
1044927bbceSWarner Losh.endif
1054927bbceSWarner Losh.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
1064927bbceSWarner LoshCFLAGS+=	-DLOADER_BZIP2_SUPPORT
1074927bbceSWarner Losh.endif
1084927bbceSWarner Losh
1094927bbceSWarner Losh# Network related things
1104927bbceSWarner Losh.if ${LOADER_NET_SUPPORT:Uno} == "yes"
1114927bbceSWarner LoshCFLAGS+=	-DLOADER_NET_SUPPORT
1124927bbceSWarner Losh.endif
1134927bbceSWarner Losh.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
1144927bbceSWarner LoshCFLAGS+=	-DLOADER_NFS_SUPPORT
1154927bbceSWarner Losh.endif
1164927bbceSWarner Losh.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
1174927bbceSWarner LoshCFLAGS+=	-DLOADER_TFTP_SUPPORT
1184927bbceSWarner Losh.endif
1194927bbceSWarner Losh
1208701bb8fSWarner Losh# Partition support
1214927bbceSWarner Losh.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
1224927bbceSWarner LoshCFLAGS+= -DLOADER_GPT_SUPPORT
1234927bbceSWarner Losh.endif
1244927bbceSWarner Losh.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
1254927bbceSWarner LoshCFLAGS+= -DLOADER_MBR_SUPPORT
1264927bbceSWarner Losh.endif
1274927bbceSWarner Losh
128060679efSWarner Losh.if ${HAVE_ZFS:Uno} == "yes"
129ca987d46SWarner LoshCFLAGS+=	-DLOADER_ZFS_SUPPORT
130ca987d46SWarner LoshCFLAGS+=	-I${ZFSSRC}
131ca987d46SWarner LoshCFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
1324784aef9SWarner LoshSRCS+=		zfs_cmd.c
133ca987d46SWarner Losh.endif
134ca987d46SWarner Losh
13576a8f5b0SWarner LoshLIBFICL=	${BOOTOBJ}/ficl/libficl.a
13676a8f5b0SWarner Losh.if ${MACHINE} == "i386"
13776a8f5b0SWarner LoshLIBFICL32=	${LIBFICL}
13876a8f5b0SWarner Losh.else
13976a8f5b0SWarner LoshLIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
14076a8f5b0SWarner Losh.endif
1417cafeaa1SWarner Losh
1427cafeaa1SWarner LoshLIBLUA=		${BOOTOBJ}/liblua/liblua.a
1437cafeaa1SWarner Losh.if ${MACHINE} == "i386"
144cc8ea7cfSKyle EvansLIBLUA32=	${LIBLUA}
1457cafeaa1SWarner Losh.else
1467cafeaa1SWarner LoshLIBLUA32=	${BOOTOBJ}/liblua32/liblua.a
14776a8f5b0SWarner Losh.endif
14876a8f5b0SWarner Losh
149ca987d46SWarner LoshCLEANFILES+=	vers.c
150ca987d46SWarner LoshVERSION_FILE?=	${.CURDIR}/version
151ca987d46SWarner Losh.if ${MK_REPRODUCIBLE_BUILD} != no
152ca987d46SWarner LoshREPRO_FLAG=	-r
153ca987d46SWarner Losh.endif
154ca987d46SWarner Loshvers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
155ca987d46SWarner Losh	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
156ca987d46SWarner Losh	    ${NEWVERSWHAT}
157ca987d46SWarner Losh
158*f871c5d9SWarner Losh.if ${MK_LOADER_VERBOSE} != "no"
159*f871c5d9SWarner LoshCFLAGS+=	-DELF_VERBOSE
160*f871c5d9SWarner Losh.endif
161*f871c5d9SWarner Losh
162ca987d46SWarner Losh.if !empty(HELP_FILES)
16325c2f4cbSWarner LoshHELP_FILES+=	${LDRSRC}/help.common
16425c2f4cbSWarner Losh
165ca987d46SWarner LoshCLEANFILES+=	loader.help
166ca987d46SWarner LoshFILES+=		loader.help
167ca987d46SWarner Losh
168ca987d46SWarner Loshloader.help: ${HELP_FILES}
169ca987d46SWarner Losh	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
170ca987d46SWarner Losh.endif
171