xref: /freebsd/stand/loader.mk (revision b88cc53d4ddda4486683ee2121f131b10ed21c30)
1# $FreeBSD$
2
3.PATH: ${LDRSRC} ${BOOTSRC}/libsa
4
5CFLAGS+=-I${LDRSRC}
6
7SRCS+=	boot.c commands.c console.c devopen.c interp.c
8SRCS+=	interp_backslash.c interp_parse.c ls.c misc.c
9SRCS+=	module.c
10
11.if ${MACHINE} == "i386" || ${MACHINE_CPUARCH} == "amd64"
12SRCS+=	load_elf32.c load_elf32_obj.c reloc_elf32.c
13SRCS+=	load_elf64.c load_elf64_obj.c reloc_elf64.c
14.elif ${MACHINE_CPUARCH} == "aarch64"
15SRCS+=	load_elf64.c reloc_elf64.c
16.elif ${MACHINE_CPUARCH} == "arm"
17SRCS+=	load_elf32.c reloc_elf32.c
18.elif ${MACHINE_CPUARCH} == "powerpc"
19SRCS+=	load_elf32.c reloc_elf32.c
20SRCS+=	load_elf64.c reloc_elf64.c
21SRCS+=	metadata.c
22.elif ${MACHINE_CPUARCH} == "sparc64"
23SRCS+=	load_elf64.c reloc_elf64.c
24SRCS+=	metadata.c
25.elif ${MACHINE_ARCH:Mmips64*} != ""
26SRCS+= load_elf64.c reloc_elf64.c
27SRCS+=	metadata.c
28.elif ${MACHINE} == "mips"
29SRCS+=	load_elf32.c reloc_elf32.c
30SRCS+=	metadata.c
31.endif
32
33.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
34SRCS+=	disk.c part.c vdisk.c
35.endif
36
37.if ${LOADER_NET_SUPPORT:Uno} == "yes"
38SRCS+= dev_net.c
39.endif
40
41.if defined(HAVE_BCACHE)
42SRCS+=  bcache.c
43.endif
44
45.if defined(MD_IMAGE_SIZE)
46CFLAGS+= -DMD_IMAGE_SIZE=${MD_IMAGE_SIZE}
47SRCS+=	md.c
48.else
49CLEANFILES+=	md.o
50.endif
51
52# Machine-independant ISA PnP
53.if defined(HAVE_ISABUS)
54SRCS+=	isapnp.c
55.endif
56.if defined(HAVE_PNP)
57SRCS+=	pnp.c
58.endif
59
60.if ${LOADER_INTERP} == "lua"
61SRCS+=	interp_lua.c
62.include "${BOOTSRC}/lua.mk"
63LDR_INTERP=	${LIBLUA}
64LDR_INTERP32=	${LIBLUA32}
65.elif ${LOADER_INTERP} == "4th"
66SRCS+=	interp_forth.c
67.include "${BOOTSRC}/ficl.mk"
68LDR_INTERP=	${LIBFICL}
69LDR_INTERP32=	${LIBFICL32}
70.elif ${LOADER_INTERP} == "simp"
71SRCS+=	interp_simple.c
72.else
73.error Unknown interpreter ${LOADER_INTERP}
74.endif
75
76.if ${MK_LOADER_VERIEXEC} != "no"
77CFLAGS+= -DLOADER_VERIEXEC -I${SRCTOP}/lib/libsecureboot/h
78.endif
79
80.if ${MK_LOADER_VERIEXEC_PASS_MANIFEST} != "no"
81CFLAGS+= -DLOADER_VERIEXEC_PASS_MANIFEST -I${SRCTOP}/lib/libsecureboot/h
82.endif
83
84.if defined(BOOT_PROMPT_123)
85CFLAGS+=	-DBOOT_PROMPT_123
86.endif
87
88.if defined(LOADER_INSTALL_SUPPORT)
89SRCS+=	install.c
90.endif
91
92# Filesystem support
93.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
94CFLAGS+=	-DLOADER_CD9660_SUPPORT
95.endif
96.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
97CFLAGS+=	-DLOADER_EXT2FS_SUPPORT
98.endif
99.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
100CFLAGS+=	-DLOADER_MSDOS_SUPPORT
101.endif
102.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
103CFLAGS+=	-DLOADER_UFS_SUPPORT
104.endif
105
106# Compression
107.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
108CFLAGS+=	-DLOADER_GZIP_SUPPORT
109.endif
110.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
111CFLAGS+=	-DLOADER_BZIP2_SUPPORT
112.endif
113
114# Network related things
115.if ${LOADER_NET_SUPPORT:Uno} == "yes"
116CFLAGS+=	-DLOADER_NET_SUPPORT
117.endif
118.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
119CFLAGS+=	-DLOADER_NFS_SUPPORT
120.endif
121.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
122CFLAGS+=	-DLOADER_TFTP_SUPPORT
123.endif
124
125# Partition support
126.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
127CFLAGS+= -DLOADER_GPT_SUPPORT
128.endif
129.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
130CFLAGS+= -DLOADER_MBR_SUPPORT
131.endif
132
133.if ${HAVE_ZFS:Uno} == "yes"
134CFLAGS+=	-DLOADER_ZFS_SUPPORT
135CFLAGS+=	-I${ZFSSRC}
136CFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
137SRCS+=		zfs_cmd.c
138.endif
139
140LIBFICL=	${BOOTOBJ}/ficl/libficl.a
141.if ${MACHINE} == "i386"
142LIBFICL32=	${LIBFICL}
143.else
144LIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
145.endif
146
147LIBLUA=		${BOOTOBJ}/liblua/liblua.a
148.if ${MACHINE} == "i386"
149LIBLUA32=	${LIBLUA}
150.else
151LIBLUA32=	${BOOTOBJ}/liblua32/liblua.a
152.endif
153
154CLEANFILES+=	vers.c
155VERSION_FILE?=	${.CURDIR}/version
156.if ${MK_REPRODUCIBLE_BUILD} != no
157REPRO_FLAG=	-r
158.endif
159vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
160	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
161	    ${NEWVERSWHAT}
162
163.if ${MK_LOADER_VERBOSE} != "no"
164CFLAGS+=	-DELF_VERBOSE
165.endif
166
167.if !empty(HELP_FILES)
168HELP_FILES+=	${LDRSRC}/help.common
169
170CLEANFILES+=	loader.help
171FILES+=		loader.help
172
173loader.help: ${HELP_FILES}
174	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
175.endif
176