loader.mk revision 329183
1# $FreeBSD: stable/11/stand/loader.mk 329183 2018-02-12 20:51:28Z 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
124.if ${MACHINE} == "amd64"
125# Have to override to use 32-bit version of zfs library...
126# kinda lame to select that there XXX
127LIBZFSBOOT=	${BOOTOBJ}/zfs32/libzfsboot.a
128.else
129LIBZFSBOOT=	${BOOTOBJ}/zfs/libzfsboot.a
130.endif
131.endif
132
133LIBFICL=	${BOOTOBJ}/ficl/libficl.a
134.if ${MACHINE} == "i386"
135LIBFICL32=	${LIBFICL}
136.else
137LIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
138.endif
139.if ${MK_FORTH} != no
140LDR_INTERP=	${LIBFICL}
141LDR_INTERP32=	${LIBFICL32}
142.endif
143
144CLEANFILES+=	vers.c
145VERSION_FILE?=	${.CURDIR}/version
146.if ${MK_REPRODUCIBLE_BUILD} != no
147REPRO_FLAG=	-r
148.endif
149vers.c: ${LDRSRC}/newvers.sh ${VERSION_FILE}
150	sh ${LDRSRC}/newvers.sh ${REPRO_FLAG} ${VERSION_FILE} \
151	    ${NEWVERSWHAT}
152
153.if !empty(HELP_FILES)
154HELP_FILES+=	${LDRSRC}/help.common
155
156CLEANFILES+=	loader.help
157FILES+=		loader.help
158
159loader.help: ${HELP_FILES}
160	cat ${HELP_FILES} | awk -f ${LDRSRC}/merge_help.awk > ${.TARGET}
161.endif
162