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