xref: /freebsd/stand/loader.mk (revision d3e1307bf5e7d621226f2f08bed822908d1b78a4)
1ca987d46SWarner Losh# $FreeBSD$
2ca987d46SWarner Losh
3ca987d46SWarner Losh.include "defs.mk"
4ca987d46SWarner Losh
5ca987d46SWarner Losh.PATH: ${LDRSRC} ${BOOTSRC}/libsa
6ca987d46SWarner Losh
7ca987d46SWarner LoshCFLAGS+=-I${LDRSRC}
8ca987d46SWarner Losh
9ca987d46SWarner LoshSRCS+=	boot.c commands.c console.c devopen.c interp.c
10ca987d46SWarner LoshSRCS+=	interp_backslash.c interp_parse.c ls.c misc.c
11ca987d46SWarner LoshSRCS+=	module.c
12ca987d46SWarner Losh
13ca987d46SWarner Losh.if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64"
14ca987d46SWarner LoshSRCS+=	load_elf32.c load_elf32_obj.c reloc_elf32.c
15ca987d46SWarner LoshSRCS+=	load_elf64.c load_elf64_obj.c reloc_elf64.c
16ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "aarch64"
17ca987d46SWarner LoshSRCS+=	load_elf64.c reloc_elf64.c
18ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "arm"
19ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
20ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "powerpc"
21ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
22ca987d46SWarner LoshSRCS+=	load_elf64.c reloc_elf64.c
23*d3e1307bSJustin HibbitsSRCS+=	metadata.c
24ca987d46SWarner Losh.elif ${MACHINE_CPUARCH} == "sparc64"
25ca987d46SWarner LoshSRCS+=	load_elf64.c reloc_elf64.c
26*d3e1307bSJustin HibbitsSRCS+=	metadata.c
27ca987d46SWarner Losh.elif ${MACHINE_ARCH:Mmips64*} != ""
28ca987d46SWarner LoshSRCS+= load_elf64.c reloc_elf64.c
29*d3e1307bSJustin HibbitsSRCS+=	metadata.c
30ca987d46SWarner Losh.elif ${MACHINE} == "mips"
31ca987d46SWarner LoshSRCS+=	load_elf32.c reloc_elf32.c
32*d3e1307bSJustin HibbitsSRCS+=	metadata.c
33ca987d46SWarner Losh.endif
34ca987d46SWarner Losh
35ca987d46SWarner Losh.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
36ca987d46SWarner LoshSRCS+=	disk.c part.c
37ca987d46SWarner Losh.endif
38ca987d46SWarner Losh
39ca987d46SWarner Losh.if ${LOADER_NET_SUPPORT:Uno} == "yes"
40ca987d46SWarner LoshSRCS+= dev_net.c
41ca987d46SWarner Losh.endif
42ca987d46SWarner Losh
43ca987d46SWarner Losh.if defined(HAVE_BCACHE)
44ca987d46SWarner LoshSRCS+=  bcache.c
45ca987d46SWarner Losh.endif
46ca987d46SWarner Losh
47ca987d46SWarner Losh.if defined(MD_IMAGE_SIZE)
48ca987d46SWarner LoshCFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE}
49ca987d46SWarner LoshSRCS+=	md.c
50ca987d46SWarner Losh.else
51ca987d46SWarner LoshCLEANFILES+=	md.o
52ca987d46SWarner Losh.endif
53ca987d46SWarner Losh
54ca987d46SWarner Losh# Machine-independant ISA PnP
55ca987d46SWarner Losh.if defined(HAVE_ISABUS)
56ca987d46SWarner LoshSRCS+=	isapnp.c
57ca987d46SWarner Losh.endif
58ca987d46SWarner Losh.if defined(HAVE_PNP)
59ca987d46SWarner LoshSRCS+=	pnp.c
60ca987d46SWarner Losh.endif
61ca987d46SWarner Losh
62ca987d46SWarner Losh# Forth interpreter
637cafeaa1SWarner Losh.if ${MK_LOADER_LUA} != "no"
647cafeaa1SWarner LoshSRCS+=	interp_lua.c
657cafeaa1SWarner Losh.include "${BOOTSRC}/lua.mk"
667cafeaa1SWarner LoshLDR_INTERP=	${LIBLUA}
677cafeaa1SWarner LoshLDR_INTERP32=	${LIBLUA32}
687cafeaa1SWarner Losh.elif ${MK_FORTH} != "no"
69ca987d46SWarner LoshSRCS+=	interp_forth.c
70ca987d46SWarner Losh.include "${BOOTSRC}/ficl.mk"
717cafeaa1SWarner LoshLDR_INTERP=	${LIBFICL}
727cafeaa1SWarner LoshLDR_INTERP32=	${LIBFICL32}
7379a6a17aSWarner Losh.else
7479a6a17aSWarner LoshSRCS+=	interp_simple.c
75ca987d46SWarner Losh.endif
76ca987d46SWarner Losh
77ca987d46SWarner Losh.if defined(BOOT_PROMPT_123)
78ca987d46SWarner LoshCFLAGS+=	-DBOOT_PROMPT_123
79ca987d46SWarner Losh.endif
80ca987d46SWarner Losh
81ca987d46SWarner Losh.if defined(LOADER_INSTALL_SUPPORT)
82ca987d46SWarner LoshSRCS+=	install.c
83ca987d46SWarner Losh.endif
84ca987d46SWarner Losh
854927bbceSWarner Losh# Filesystem support
864927bbceSWarner Losh.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
874927bbceSWarner LoshCFLAGS+=	-DLOADER_CD9660_SUPPORT
884927bbceSWarner Losh.endif
894927bbceSWarner Losh.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
904927bbceSWarner LoshCFLAGS+=	-DLOADER_EXT2FS_SUPPORT
914927bbceSWarner Losh.endif
924927bbceSWarner Losh.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
934927bbceSWarner LoshCFLAGS+=	-DLOADER_MSDOS_SUPPORT
944927bbceSWarner Losh.endif
954927bbceSWarner Losh.if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes"
964927bbceSWarner LoshCFLAGS+=	-DLOADER_NANDFS_SUPPORT
974927bbceSWarner Losh.endif
984927bbceSWarner Losh.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
994927bbceSWarner LoshCFLAGS+=	-DLOADER_UFS_SUPPORT
1004927bbceSWarner Losh.endif
1014927bbceSWarner Losh
1024927bbceSWarner Losh# Compression
1034927bbceSWarner Losh.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
1044927bbceSWarner LoshCFLAGS+=	-DLOADER_GZIP_SUPPORT
1054927bbceSWarner Losh.endif
1064927bbceSWarner Losh.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
1074927bbceSWarner LoshCFLAGS+=	-DLOADER_BZIP2_SUPPORT
1084927bbceSWarner Losh.endif
1094927bbceSWarner Losh
1104927bbceSWarner Losh# Network related things
1114927bbceSWarner Losh.if ${LOADER_NET_SUPPORT:Uno} == "yes"
1124927bbceSWarner LoshCFLAGS+=	-DLOADER_NET_SUPPORT
1134927bbceSWarner Losh.endif
1144927bbceSWarner Losh.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
1154927bbceSWarner LoshCFLAGS+=	-DLOADER_NFS_SUPPORT
1164927bbceSWarner Losh.endif
1174927bbceSWarner Losh.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
1184927bbceSWarner LoshCFLAGS+=	-DLOADER_TFTP_SUPPORT
1194927bbceSWarner Losh.endif
1204927bbceSWarner Losh
1218701bb8fSWarner Losh# Partition support
1224927bbceSWarner Losh.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
1234927bbceSWarner LoshCFLAGS+= -DLOADER_GPT_SUPPORT
1244927bbceSWarner Losh.endif
1254927bbceSWarner Losh.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
1264927bbceSWarner LoshCFLAGS+= -DLOADER_MBR_SUPPORT
1274927bbceSWarner Losh.endif
1284927bbceSWarner Losh
129ca987d46SWarner Losh.if defined(HAVE_ZFS)
130ca987d46SWarner LoshCFLAGS+=	-DLOADER_ZFS_SUPPORT
131ca987d46SWarner LoshCFLAGS+=	-I${ZFSSRC}
132ca987d46SWarner LoshCFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
133ca987d46SWarner Losh.if ${MACHINE} == "amd64"
134ca987d46SWarner Losh# Have to override to use 32-bit version of zfs library...
135ca987d46SWarner Losh# kinda lame to select that there XXX
136ca987d46SWarner LoshLIBZFSBOOT=	${BOOTOBJ}/zfs32/libzfsboot.a
137ca987d46SWarner Losh.else
138ca987d46SWarner LoshLIBZFSBOOT=	${BOOTOBJ}/zfs/libzfsboot.a
139ca987d46SWarner Losh.endif
140ca987d46SWarner Losh.endif
141ca987d46SWarner Losh
14276a8f5b0SWarner LoshLIBFICL=	${BOOTOBJ}/ficl/libficl.a
14376a8f5b0SWarner Losh.if ${MACHINE} == "i386"
14476a8f5b0SWarner LoshLIBFICL32=	${LIBFICL}
14576a8f5b0SWarner Losh.else
14676a8f5b0SWarner LoshLIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
14776a8f5b0SWarner Losh.endif
1487cafeaa1SWarner Losh
1497cafeaa1SWarner LoshLIBLUA=		${BOOTOBJ}/liblua/liblua.a
1507cafeaa1SWarner Losh.if ${MACHINE} == "i386"
1517cafeaa1SWarner LoshLIBLUA32=	${LIBFICL}
1527cafeaa1SWarner Losh.else
1537cafeaa1SWarner LoshLIBLUA32=	${BOOTOBJ}/liblua32/liblua.a
15476a8f5b0SWarner Losh.endif
15576a8f5b0SWarner Losh
156ca987d46SWarner LoshCLEANFILES+=	vers.c
157ca987d46SWarner LoshVERSION_FILE?=	${.CURDIR}/version
158ca987d46SWarner Losh.if ${MK_REPRODUCIBLE_BUILD} != no
159ca987d46SWarner LoshREPRO_FLAG=	-r
160ca987d46SWarner Losh.endif
161ca987d46SWarner Loshvers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
162ca987d46SWarner Losh	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
163ca987d46SWarner Losh	    ${NEWVERSWHAT}
164ca987d46SWarner Losh
165ca987d46SWarner Losh.if !empty(HELP_FILES)
16625c2f4cbSWarner LoshHELP_FILES+=	${LDRSRC}/help.common
16725c2f4cbSWarner Losh
168ca987d46SWarner LoshCLEANFILES+=	loader.help
169ca987d46SWarner LoshFILES+=		loader.help
170ca987d46SWarner Losh
171ca987d46SWarner Loshloader.help: ${HELP_FILES}
172ca987d46SWarner Losh	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
173ca987d46SWarner Losh.endif
174