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