defs.mk revision 329140
1# $FreeBSD: stable/11/sys/boot/defs.mk 329140 2018-02-11 20:58:00Z kevans $
2
3.include <src.opts.mk>
4
5.if !defined(__BOOT_DEFS_MK__)
6__BOOT_DEFS_MK__=${MFILE}
7
8BOOTSRC=	${SRCTOP}/sys/boot
9EFISRC=		${BOOTSRC}/efi
10EFIINC=		${EFISRC}/include
11EFIINCMD=	${EFIINC}/${MACHINE}
12FDTSRC=		${BOOTSRC}/fdt
13FICLSRC=	${BOOTSRC}/ficl
14LDRSRC=		${BOOTSRC}/common
15SASRC=		${BOOTSRC}/libsa
16SYSDIR=		${SRCTOP}/sys
17UBOOTSRC=	${BOOTSRC}/uboot
18ZFSSRC=		${BOOTSRC}/zfs
19
20BOOTOBJ=	${OBJTOP}/sys/boot
21
22# BINDIR is where we install
23BINDIR?=	/boot
24
25# NB: The makefiles depend on these being empty when we don't build forth.
26.if ${MK_FORTH} != "no"
27LIBFICL=	${BOOTOBJ}/ficl/libficl.a
28.if ${MACHINE} == "i386"
29LIBFICL32=	${LIBFICL}
30.else
31LIBFICL32=	${BOOTOBJ}/ficl32/libficl.a
32.endif
33.endif
34LIBSA=		${BOOTOBJ}/libsa/libsa.a
35.if ${MACHINE} == "i386"
36LIBSA32=	${LIBSA}
37.else
38LIBSA32=	${BOOTOBJ}/libsa32/libsa32.a
39.endif
40
41# Standard options:
42
43# Filesystem support
44.if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
45CFLAGS+=	-DLOADER_CD9660_SUPPORT
46.endif
47.if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
48CFLAGS+=	-DLOADER_EXT2FS_SUPPORT
49.endif
50.if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
51CFLAGS+=	-DLOADER_MSDOS_SUPPORT
52.endif
53.if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes"
54CFLAGS+=	-DLOADER_NANDFS_SUPPORT
55.endif
56.if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
57CFLAGS+=	-DLOADER_UFS_SUPPORT
58.endif
59
60# Compression
61.if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
62CFLAGS+=	-DLOADER_GZIP_SUPPORT
63.endif
64.if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
65CFLAGS+=	-DLOADER_BZIP2_SUPPORT
66.endif
67
68# Network related things
69.if ${LOADER_NET_SUPPORT:Uno} == "yes"
70CFLAGS+=	-DLOADER_NET_SUPPORT
71.endif
72.if ${LOADER_NFS_SUPPORT:Uno} == "yes"
73CFLAGS+=	-DLOADER_NFS_SUPPORT
74.endif
75.if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
76CFLAGS+=	-DLOADER_TFTP_SUPPORT
77.endif
78
79# Disk and partition support
80.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
81CFLAGS+= -DLOADER_DISK_SUPPORT
82.if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
83CFLAGS+= -DLOADER_GPT_SUPPORT
84.endif
85.if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
86CFLAGS+= -DLOADER_MBR_SUPPORT
87.endif
88
89# GELI Support, with backward compat hooks
90.if defined(HAVE_GELI)
91.if defined(LOADER_NO_GELI_SUPPORT)
92MK_LOADER_GELI=no
93.warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI"
94.endif
95.if defined(LOADER_GELI_SUPPORT)
96MK_LOADER_GELI=yes
97.warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI"
98.endif
99.if ${MK_LOADER_GELI} == "yes"
100CFLAGS+=	-DLOADER_GELI_SUPPORT
101CFLAGS+=	-I${BOOTSRC}/geli
102LIBGELIBOOT=	${BOOTOBJ}/geli/libgeliboot.a
103.endif
104.endif
105.endif
106
107CFLAGS+=	-I${SYSDIR}
108
109# All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc
110# or powerpc64.
111.if ${MACHINE_ARCH} == "powerpc64"
112CFLAGS+=	-m32 -mcpu=powerpc
113.endif
114
115# For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is
116# build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here
117# and activate it when DO32 is explicitly defined to be 1.
118.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
119CFLAGS+=	-m32 -mcpu=i386
120# LD_FLAGS is passed directly to ${LD}, not via ${CC}:
121LD_FLAGS+=	-m elf_i386_fbsd
122AFLAGS+=	--32
123.endif
124
125# Make sure we use the machine link we're about to create
126CFLAGS+=-I.
127
128_ILINKS=machine
129.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64"
130_ILINKS+=${MACHINE_CPUARCH}
131.endif
132.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
133_ILINKS+=x86
134.endif
135CLEANFILES+=${_ILINKS}
136
137all: ${PROG}
138
139beforedepend: ${_ILINKS}
140beforebuild: ${_ILINKS}
141
142# Ensure that the links exist without depending on it when it exists which
143# causes all the modules to be rebuilt when the directory pointed to changes.
144.for _link in ${_ILINKS}
145.if !exists(${.OBJDIR}/${_link})
146${OBJS}:       ${_link}
147.endif
148.endfor
149
150.NOPATH: ${_ILINKS}
151
152${_ILINKS}:
153	@case ${.TARGET} in \
154	machine) \
155		if [ ${DO32:U0} -eq 0 ]; then \
156			path=${SYSDIR}/${MACHINE}/include ; \
157		else \
158			path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \
159		fi ;; \
160	*) \
161		path=${SYSDIR}/${.TARGET:T}/include ;; \
162	esac ; \
163	path=`(cd $$path && /bin/pwd)` ; \
164	${ECHO} ${.TARGET:T} "->" $$path ; \
165	ln -fhs $$path ${.TARGET:T}
166
167# For loader implementations, we generate a loader.help file. This can be suppressed by
168# setting HELP_FILES to nothing.
169HELP_FILES=	${LDRSRC}/help.common
170
171.endif # __BOOT_DEFS_MK__
172