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