loader.mk revision 332128
1# $FreeBSD: stable/11/stand/loader.mk 332128 2018-04-06 18:40:24Z kevans $
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} == "pc98"
17SRCS+=	load_elf32.c load_elf32_obj.c reloc_elf32.c
18.elif ${MACHINE_CPUARCH} == "aarch64"
19SRCS+=	load_elf64.c reloc_elf64.c
20.elif ${MACHINE_CPUARCH} == "arm"
21SRCS+=	load_elf32.c reloc_elf32.c
22.elif ${MACHINE_CPUARCH} == "powerpc"
23SRCS+=	load_elf32.c reloc_elf32.c
24SRCS+=	load_elf64.c reloc_elf64.c
25.elif ${MACHINE_CPUARCH} == "sparc64"
26SRCS+=	load_elf64.c reloc_elf64.c
27.elif ${MACHINE_ARCH:Mmips64*} != ""
28SRCS+= load_elf64.c reloc_elf64.c
29.elif ${MACHINE} == "mips"
30SRCS+=	load_elf32.c reloc_elf32.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# Forth interpreter
61.if ${MK_FORTH} != "no"
62SRCS+=	interp_forth.c
63.include "${BOOTSRC}/ficl.mk"
64.else
65SRCS+=	interp_simple.c
66.endif
67
68.if defined(BOOT_PROMPT_123)
69CFLAGS+=	-DBOOT_PROMPT_123
70.endif
71
72.if defined(LOADER_INSTALL_SUPPORT)
73SRCS+=	install.c
74.endif
75
76# Filesystem support
77.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
78CFLAGS+=	-DLOADER_CD9660_SUPPORT
79.endif
80.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
81CFLAGS+=	-DLOADER_EXT2FS_SUPPORT
82.endif
83.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
84CFLAGS+=	-DLOADER_MSDOS_SUPPORT
85.endif
86.if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes"
87CFLAGS+=	-DLOADER_NANDFS_SUPPORT
88.endif
89.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
90CFLAGS+=	-DLOADER_UFS_SUPPORT
91.endif
92
93# Compression
94.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
95CFLAGS+=	-DLOADER_GZIP_SUPPORT
96.endif
97.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
98CFLAGS+=	-DLOADER_BZIP2_SUPPORT
99.endif
100
101# Network related things
102.if ${LOADER_NET_SUPPORT:Uno} == "yes"
103CFLAGS+=	-DLOADER_NET_SUPPORT
104.endif
105.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
106CFLAGS+=	-DLOADER_NFS_SUPPORT
107.endif
108.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
109CFLAGS+=	-DLOADER_TFTP_SUPPORT
110.endif
111
112# Partition support
113.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
114CFLAGS+= -DLOADER_GPT_SUPPORT
115.endif
116.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
117CFLAGS+= -DLOADER_MBR_SUPPORT
118.endif
119
120.if defined(HAVE_ZFS)
121CFLAGS+=	-DLOADER_ZFS_SUPPORT
122CFLAGS+=	-I${ZFSSRC}
123CFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
124SRCS+=		zfs_cmd.c
125.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1
126# Have to override to use 32-bit version of zfs library...
127# kinda lame to select that there XXX
128LIBZFSBOOT=	${BOOTOBJ}/zfs32/libzfsboot.a
129.else
130LIBZFSBOOT=	${BOOTOBJ}/zfs/libzfsboot.a
131.endif
132.endif
133
134LIBFICL=	${BOOTOBJ}/ficl/libficl.a
135.if ${MACHINE} == "i386"
136LIBFICL32=	${LIBFICL}
137.else
138LIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
139.endif
140.if ${MK_FORTH} != no
141LDR_INTERP=	${LIBFICL}
142LDR_INTERP32=	${LIBFICL32}
143.endif
144
145CLEANFILES+=	vers.c
146VERSION_FILE?=	${.CURDIR}/version
147.if ${MK_REPRODUCIBLE_BUILD} != no
148REPRO_FLAG=	-r
149.endif
150vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
151	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
152	    ${NEWVERSWHAT}
153
154.if !empty(HELP_FILES)
155HELP_FILES+=	${LDRSRC}/help.common
156
157CLEANFILES+=	loader.help
158FILES+=		loader.help
159
160loader.help: ${HELP_FILES}
161	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
162.endif
163