xref: /freebsd/stand/loader.mk (revision 1a498d2e689f9e8220e2ad64b018eb1f0d11127e)
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
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 defined(BOOT_PROMPT_123)
77CFLAGS+=	-DBOOT_PROMPT_123
78.endif
79
80.if defined(LOADER_INSTALL_SUPPORT)
81SRCS+=	install.c
82.endif
83
84# Filesystem support
85.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
86CFLAGS+=	-DLOADER_CD9660_SUPPORT
87.endif
88.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
89CFLAGS+=	-DLOADER_EXT2FS_SUPPORT
90.endif
91.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
92CFLAGS+=	-DLOADER_MSDOS_SUPPORT
93.endif
94.if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes"
95CFLAGS+=	-DLOADER_NANDFS_SUPPORT
96.endif
97.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
98CFLAGS+=	-DLOADER_UFS_SUPPORT
99.endif
100
101# Compression
102.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
103CFLAGS+=	-DLOADER_GZIP_SUPPORT
104.endif
105.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
106CFLAGS+=	-DLOADER_BZIP2_SUPPORT
107.endif
108
109# Network related things
110.if ${LOADER_NET_SUPPORT:Uno} == "yes"
111CFLAGS+=	-DLOADER_NET_SUPPORT
112.endif
113.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
114CFLAGS+=	-DLOADER_NFS_SUPPORT
115.endif
116.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
117CFLAGS+=	-DLOADER_TFTP_SUPPORT
118.endif
119
120# Partition support
121.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
122CFLAGS+= -DLOADER_GPT_SUPPORT
123.endif
124.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
125CFLAGS+= -DLOADER_MBR_SUPPORT
126.endif
127
128.if ${HAVE_ZFS:Uno} == "yes"
129CFLAGS+=	-DLOADER_ZFS_SUPPORT
130CFLAGS+=	-I${ZFSSRC}
131CFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
132SRCS+=		zfs_cmd.c
133.endif
134
135LIBFICL=	${BOOTOBJ}/ficl/libficl.a
136.if ${MACHINE} == "i386"
137LIBFICL32=	${LIBFICL}
138.else
139LIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
140.endif
141
142LIBLUA=		${BOOTOBJ}/liblua/liblua.a
143.if ${MACHINE} == "i386"
144LIBLUA32=	${LIBLUA}
145.else
146LIBLUA32=	${BOOTOBJ}/liblua32/liblua.a
147.endif
148
149CLEANFILES+=	vers.c
150VERSION_FILE?=	${.CURDIR}/version
151.if ${MK_REPRODUCIBLE_BUILD} != no
152REPRO_FLAG=	-r
153.endif
154vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
155	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
156	    ${NEWVERSWHAT}
157
158.if !empty(HELP_FILES)
159HELP_FILES+=	${LDRSRC}/help.common
160
161CLEANFILES+=	loader.help
162FILES+=		loader.help
163
164loader.help: ${HELP_FILES}
165	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
166.endif
167