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