]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - stand/defs.mk
Now it's safe to bump WARNS to 1.
[FreeBSD/FreeBSD.git] / stand / defs.mk
1 # $FreeBSD$
2
3 .include <src.opts.mk>
4
5 WARNS?=1
6
7 .if !defined(__BOOT_DEFS_MK__)
8 __BOOT_DEFS_MK__=${MFILE}
9
10 BOOTSRC=        ${SRCTOP}/stand
11 EFISRC=         ${BOOTSRC}/efi
12 EFIINC=         ${EFISRC}/include
13 EFIINCMD=       ${EFIINC}/${MACHINE}
14 FDTSRC=         ${BOOTSRC}/fdt
15 FICLSRC=        ${BOOTSRC}/ficl
16 LDRSRC=         ${BOOTSRC}/common
17 SASRC=          ${BOOTSRC}/libsa
18 SYSDIR=         ${SRCTOP}/sys
19 UBOOTSRC=       ${BOOTSRC}/uboot
20 ZFSSRC=         ${BOOTSRC}/zfs
21
22 BOOTOBJ=        ${OBJTOP}/stand
23
24 # BINDIR is where we install
25 BINDIR?=        /boot
26
27 # NB: The makefiles depend on these being empty when we don't build forth.
28 .if ${MK_FORTH} != "no"
29 LIBFICL=        ${BOOTOBJ}/ficl/libficl.a
30 .if ${MACHINE} == "i386"
31 LIBFICL32=      ${LIBFICL}
32 .else
33 LIBFICL32=      ${BOOTOBJ}/ficl32/libficl.a
34 .endif
35 .endif
36 LIBSA=          ${BOOTOBJ}/libsa/libsa.a
37 .if ${MACHINE} == "i386"
38 LIBSA32=        ${LIBSA}
39 .else
40 LIBSA32=        ${BOOTOBJ}/libsa32/libsa32.a
41 .endif
42
43 # Standard options:
44 CFLAGS+=        -I${SASRC} -D_STANDALONE
45 CFLAGS+=        -I${SYSDIR}
46
47 # Filesystem support
48 .if ${LOADER_CD9660_SUPPORT:Uno} == "yes"
49 CFLAGS+=        -DLOADER_CD9660_SUPPORT
50 .endif
51 .if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes"
52 CFLAGS+=        -DLOADER_EXT2FS_SUPPORT
53 .endif
54 .if ${LOADER_MSDOS_SUPPORT:Uno} == "yes"
55 CFLAGS+=        -DLOADER_MSDOS_SUPPORT
56 .endif
57 .if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes"
58 CFLAGS+=        -DLOADER_NANDFS_SUPPORT
59 .endif
60 .if ${LOADER_UFS_SUPPORT:Uyes} == "yes"
61 CFLAGS+=        -DLOADER_UFS_SUPPORT
62 .endif
63
64 # Compression
65 .if ${LOADER_GZIP_SUPPORT:Uno} == "yes"
66 CFLAGS+=        -DLOADER_GZIP_SUPPORT
67 .endif
68 .if ${LOADER_BZIP2_SUPPORT:Uno} == "yes"
69 CFLAGS+=        -DLOADER_BZIP2_SUPPORT
70 .endif
71
72 # Network related things
73 .if ${LOADER_NET_SUPPORT:Uno} == "yes"
74 CFLAGS+=        -DLOADER_NET_SUPPORT
75 .endif
76 .if ${LOADER_NFS_SUPPORT:Uno} == "yes"
77 CFLAGS+=        -DLOADER_NFS_SUPPORT
78 .endif
79 .if ${LOADER_TFTP_SUPPORT:Uno} == "yes"
80 CFLAGS+=        -DLOADER_TFTP_SUPPORT
81 .endif
82
83 # Disk and partition support
84 .if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
85 CFLAGS+= -DLOADER_DISK_SUPPORT
86 .if ${LOADER_GPT_SUPPORT:Uyes} == "yes"
87 CFLAGS+= -DLOADER_GPT_SUPPORT
88 .endif
89 .if ${LOADER_MBR_SUPPORT:Uyes} == "yes"
90 CFLAGS+= -DLOADER_MBR_SUPPORT
91 .endif
92
93 # GELI Support, with backward compat hooks
94 .if defined(HAVE_GELI)
95 .if defined(LOADER_NO_GELI_SUPPORT)
96 MK_LOADER_GELI=no
97 .warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI"
98 .endif
99 .if defined(LOADER_GELI_SUPPORT)
100 MK_LOADER_GELI=yes
101 .warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI"
102 .endif
103 .if ${MK_LOADER_GELI} == "yes"
104 CFLAGS+=        -DLOADER_GELI_SUPPORT
105 CFLAGS+=        -I${BOOTSRC}/geli
106 LIBGELIBOOT=    ${BOOTOBJ}/geli/libgeliboot.a
107 .endif
108 .endif
109 .endif
110
111 # Machine specific flags for all builds here
112
113 # All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc
114 # or powerpc64.
115 .if ${MACHINE_ARCH} == "powerpc64"
116 CFLAGS+=        -m32 -mcpu=powerpc
117 .endif
118
119 # For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is
120 # build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here
121 # and activate it when DO32 is explicitly defined to be 1.
122 .if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
123 CFLAGS+=        -m32 -mcpu=i386
124 # LD_FLAGS is passed directly to ${LD}, not via ${CC}:
125 LD_FLAGS+=      -m elf_i386_fbsd
126 AFLAGS+=        --32
127 .endif
128
129 SSP_CFLAGS=
130
131 # Add in the no float / no SIMD stuff and announce we're freestanding
132 # aarch64 and riscv don't have -msoft-float, but all others do. riscv
133 # currently has no /boot/loader, but may soon.
134 CFLAGS+=        -ffreestanding ${CFLAGS_NO_SIMD}
135 .if ${MACHINE_CPUARCH} == "aarch64"
136 CFLAGS+=        -mgeneral-regs-only
137 .elif ${MACHINE_CPUARCH} != "riscv"
138 CFLAGS+=        -msoft-float
139 .endif
140
141 .if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1)
142 CFLAGS+=        -march=i386
143 CFLAGS.gcc+=    -mpreferred-stack-boundary=2
144 .endif
145
146
147 .if ${MACHINE_CPUARCH} == "arm"
148 # Do not generate movt/movw, because the relocation fixup for them does not
149 # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
150 # Also, the fpu is not available in a standalone environment.
151 .if ${COMPILER_VERSION} < 30800
152 CFLAGS.clang+=  -mllvm -arm-use-movt=0
153 .else
154 CFLAGS.clang+=  -mno-movt
155 .endif
156 CFLAGS.clang+=  -mfpu=none
157 .endif
158
159 # The boot loader build uses dd status=none, where possible, for reproducible
160 # build output (since performance varies from run to run). Trouble is that
161 # option was recently (10.3) added to FreeBSD and is non-standard. Only use it
162 # when this test succeeds rather than require dd to be a bootstrap tool.
163 DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true
164 DD=dd ${DD_NOSTATUS}
165
166 .if ${MK_LOADER_FORCE_LE} != "no"
167 .if ${MACHINE_ARCH} == "powerpc64"
168 CFLAGS+=        -mlittle-endian
169 .endif
170 .endif
171
172 # Make sure we use the machine link we're about to create
173 CFLAGS+=-I.
174
175 _ILINKS=machine
176 .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64"
177 _ILINKS+=${MACHINE_CPUARCH}
178 .endif
179 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
180 _ILINKS+=x86
181 .endif
182 CLEANFILES+=${_ILINKS}
183
184 all: ${PROG}
185
186 beforedepend: ${_ILINKS}
187 beforebuild: ${_ILINKS}
188
189 # Ensure that the links exist without depending on it when it exists which
190 # causes all the modules to be rebuilt when the directory pointed to changes.
191 .for _link in ${_ILINKS}
192 .if !exists(${.OBJDIR}/${_link})
193 ${OBJS}:       ${_link}
194 .endif
195 .endfor
196
197 .NOPATH: ${_ILINKS}
198
199 ${_ILINKS}:
200         @case ${.TARGET} in \
201         machine) \
202                 if [ ${DO32:U0} -eq 0 ]; then \
203                         path=${SYSDIR}/${MACHINE}/include ; \
204                 else \
205                         path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \
206                 fi ;; \
207         *) \
208                 path=${SYSDIR}/${.TARGET:T}/include ;; \
209         esac ; \
210         path=`(cd $$path && /bin/pwd)` ; \
211         ${ECHO} ${.TARGET:T} "->" $$path ; \
212         ln -fhs $$path ${.TARGET:T}
213
214 # For loader implementations, we generate a loader.help file. This can be suppressed by
215 # setting HELP_FILES to nothing.
216 HELP_FILES=     ${LDRSRC}/help.common
217
218 .endif # __BOOT_DEFS_MK__