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