]>
Commit | Line | Data |
---|---|---|
76ed06b9 BC |
1 | # -*- autoconf -*- |
2 | ||
6a161fa9 | 3 | # Process this file with autoconf to produce a configure script. |
4 | ||
2f1a3acf | 5 | # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. |
6a161fa9 | 6 | # |
7 | # This configure.ac is free software; the author | |
8 | # gives unlimited permission to copy and/or distribute it, | |
9 | # with or without modifications, as long as this notice is preserved. | |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without | |
13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
14 | # PARTICULAR PURPOSE. | |
15 | ||
b977bf01 | 16 | dnl This configure script is complicated, because GRUB needs to deal |
17 | dnl with three potentially different types: | |
18 | dnl | |
19 | dnl build -- the environment for building GRUB | |
20 | dnl host -- the environment for running utilities | |
21 | dnl target -- the environment for running GRUB | |
22 | dnl | |
23 | dnl In addition, GRUB needs to deal with a platform specification | |
24 | dnl which specifies the system running GRUB, such as firmware. | |
25 | dnl This is necessary because the target type in autoconf does not | |
26 | dnl describe such a system very well. | |
27 | dnl | |
28 | dnl The current strategy is to use variables with no prefix (such as | |
dcecae1a AB |
29 | dnl CC, CFLAGS, etc.) for the host type, variables with prefix "BUILD_" |
30 | dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables | |
31 | dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are | |
32 | dnl used for the target type. See INSTALL for full list of variables. | |
b977bf01 | 33 | |
b0bad6fd | 34 | AC_INIT([GRUB],[2.03],[bug-grub@gnu.org]) |
6a161fa9 | 35 | |
15c69261 YB |
36 | AC_CONFIG_AUX_DIR([build-aux]) |
37 | ||
76ed06b9 BC |
38 | # We don't want -g -O2 by default in CFLAGS |
39 | : ${CFLAGS=""} | |
6a161fa9 | 40 | |
1ecf96fc AB |
41 | # Checks for build, host and target systems. |
42 | AC_CANONICAL_BUILD | |
6a161fa9 | 43 | AC_CANONICAL_HOST |
ee7fb780 | 44 | save_program_prefix="${program_prefix}" |
b977bf01 | 45 | AC_CANONICAL_TARGET |
ee7fb780 | 46 | program_prefix="${save_program_prefix}" |
6a161fa9 | 47 | |
6fe506b0 | 48 | AM_INIT_AUTOMAKE([1.10.1]) |
8c411768 | 49 | AC_PREREQ(2.60) |
6304d292 | 50 | AC_CONFIG_SRCDIR([include/grub/dl.h]) |
742f9232 | 51 | AC_CONFIG_HEADER([config-util.h]) |
e52db1f7 | 52 | |
7e23437d CW |
53 | # Explicitly check for pkg-config early on, since otherwise conditional |
54 | # calls are problematic. | |
55 | PKG_PROG_PKG_CONFIG | |
56 | ||
1d543c3e | 57 | # Program name transformations |
58 | AC_ARG_PROGRAM | |
fd49ceb3 CW |
59 | grub_TRANSFORM([grub-bios-setup]) |
60 | grub_TRANSFORM([grub-editenv]) | |
61 | grub_TRANSFORM([grub-install]) | |
62 | grub_TRANSFORM([grub-mkconfig]) | |
63 | grub_TRANSFORM([grub-mkfont]) | |
64 | grub_TRANSFORM([grub-mkimage]) | |
67ab8353 | 65 | grub_TRANSFORM([grub-glue-efi]) |
fd49ceb3 CW |
66 | grub_TRANSFORM([grub-mklayout]) |
67 | grub_TRANSFORM([grub-mkpasswd-pbkdf2]) | |
68 | grub_TRANSFORM([grub-mkrelpath]) | |
69 | grub_TRANSFORM([grub-mkrescue]) | |
70 | grub_TRANSFORM([grub-probe]) | |
71 | grub_TRANSFORM([grub-reboot]) | |
72 | grub_TRANSFORM([grub-script-check]) | |
73 | grub_TRANSFORM([grub-set-default]) | |
fd49ceb3 | 74 | grub_TRANSFORM([grub-sparc64-setup]) |
a79b8a15 | 75 | grub_TRANSFORM([grub-render-label]) |
ec824e0f | 76 | grub_TRANSFORM([grub-file]) |
1d543c3e | 77 | |
90d1e879 RM |
78 | # Optimization flag. Allow user to override. |
79 | if test "x$TARGET_CFLAGS" = x; then | |
80 | TARGET_CFLAGS="$TARGET_CFLAGS -Os" | |
81 | fi | |
82 | ||
76ed06b9 BC |
83 | # Default HOST_CPPFLAGS |
84 | HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W" | |
76ed06b9 | 85 | HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1" |
76ed06b9 BC |
86 | |
87 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W" | |
76ed06b9 | 88 | |
b977bf01 | 89 | case "$target_cpu" in |
02164e1b | 90 | i[[3456]]86) target_cpu=i386 ;; |
c7ef54aa | 91 | amd64) target_cpu=x86_64 ;; |
02164e1b | 92 | sparc) target_cpu=sparc64 ;; |
ade85305 | 93 | mipsel|mips64el) |
4d94b2db CW |
94 | target_cpu=mipsel |
95 | machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1" | |
4a1eefb6 | 96 | ;; |
ade85305 | 97 | mips|mips64) |
4d94b2db CW |
98 | target_cpu=mips |
99 | machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1" | |
4a1eefb6 | 100 | ;; |
389b31cd | 101 | arm*) |
4d94b2db | 102 | target_cpu=arm |
389b31cd | 103 | ;; |
15a463d7 | 104 | aarch64*) |
4d94b2db | 105 | target_cpu=arm64 |
15a463d7 | 106 | ;; |
f1957dc8 AG |
107 | riscv32*) |
108 | target_cpu=riscv32 | |
109 | ;; | |
110 | riscv64*) | |
111 | target_cpu=riscv64 | |
112 | ;; | |
6a161fa9 | 113 | esac |
114 | ||
05568c2e | 115 | # Specify the platform (such as firmware). |
116 | AC_ARG_WITH([platform], | |
117 | AS_HELP_STRING([--with-platform=PLATFORM], | |
83b984de | 118 | [select the host platform [[guessed]]])) |
05568c2e | 119 | |
120 | # Guess the platform if not specified. | |
121 | if test "x$with_platform" = x; then | |
b977bf01 | 122 | case "$target_cpu"-"$target_vendor" in |
05568c2e | 123 | i386-apple) platform=efi ;; |
124 | i386-*) platform=pc ;; | |
58393a2d | 125 | x86_64-apple) platform=efi ;; |
737feb35 | 126 | x86_64-*) platform=pc ;; |
05568c2e | 127 | powerpc-*) platform=ieee1275 ;; |
58393a2d | 128 | powerpc64-*) platform=ieee1275 ;; |
5c46165a | 129 | powerpc64le-*) platform=ieee1275 ;; |
05568c2e | 130 | sparc64-*) platform=ieee1275 ;; |
4959e111 VS |
131 | mipsel-*) platform=loongson ;; |
132 | mips-*) platform=arc ;; | |
e68d3b24 | 133 | ia64-*) platform=efi ;; |
389b31cd | 134 | arm-*) platform=uboot ;; |
15a463d7 | 135 | arm64-*) platform=efi ;; |
f1957dc8 AG |
136 | riscv32-*) platform=efi ;; |
137 | riscv64-*) platform=efi ;; | |
5d90f6e5 CW |
138 | *) |
139 | AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities]) | |
140 | platform=none | |
141 | ;; | |
05568c2e | 142 | esac |
143 | else | |
144 | platform="$with_platform" | |
145 | fi | |
146 | ||
ec1dfd63 VS |
147 | case "$target_cpu"-"$platform" in |
148 | x86_64-efi) ;; | |
149 | x86_64-emu) ;; | |
9612ebc0 | 150 | x86_64-xen) ;; |
5d90f6e5 | 151 | x86_64-none) ;; |
ec1dfd63 VS |
152 | x86_64-*) target_cpu=i386 ;; |
153 | powerpc64-ieee1275) target_cpu=powerpc ;; | |
5c46165a | 154 | powerpc64le-ieee1275) target_cpu=powerpc ;; |
ec1dfd63 | 155 | esac |
20011694 | 156 | |
58393a2d | 157 | # Check if the platform is supported, make final adjustments. |
b977bf01 | 158 | case "$target_cpu"-"$platform" in |
05568c2e | 159 | i386-efi) ;; |
3f4ce737 | 160 | x86_64-efi) ;; |
9612ebc0 | 161 | i386-xen) ;; |
d789e70e | 162 | i386-xen_pvh) ;; |
9612ebc0 | 163 | x86_64-xen) ;; |
05568c2e | 164 | i386-pc) ;; |
7210dca9 | 165 | i386-multiboot) ;; |
546f966a | 166 | i386-coreboot) ;; |
58393a2d | 167 | i386-linuxbios) platform=coreboot ;; |
3d04eab8 | 168 | i386-ieee1275) ;; |
8231fb77 | 169 | i386-qemu) ;; |
05568c2e | 170 | powerpc-ieee1275) ;; |
171 | sparc64-ieee1275) ;; | |
2c40cc78 | 172 | ia64-efi) ;; |
f440c33f | 173 | mips-qemu_mips) ;; |
3666d5f6 | 174 | mips-qemu-mips) platform=qemu_mips;; |
8906c3dd | 175 | mips-arc) ;; |
7f63a64f | 176 | mipsel-arc) ;; |
4959e111 VS |
177 | mipsel-qemu_mips) ;; |
178 | mipsel-qemu-mips) platform=qemu_mips;; | |
179 | mipsel-yeeloong) platform=loongson ;; | |
180 | mipsel-fuloong) platform=loongson ;; | |
181 | mipsel-loongson) ;; | |
389b31cd | 182 | arm-uboot) ;; |
24e37a88 | 183 | arm-coreboot) ;; |
389b31cd | 184 | arm-efi) ;; |
15a463d7 | 185 | arm64-efi) ;; |
f1957dc8 AG |
186 | riscv32-efi) ;; |
187 | riscv64-efi) ;; | |
f84b481b | 188 | *-emu) ;; |
5d90f6e5 | 189 | *-none) ;; |
58393a2d | 190 | *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;; |
6a161fa9 | 191 | esac |
192 | ||
48145ea3 | 193 | if test x$platform != xemu ; then |
dd614590 VS |
194 | case "$target_cpu" in |
195 | i386 | powerpc) target_m32=1 ;; | |
196 | x86_64 | sparc64) target_m64=1 ;; | |
197 | esac | |
198 | fi | |
3f4ce737 | 199 | |
eaf01c25 | 200 | if test x"$target_cpu-$platform" = xsparc64-emu ; then |
4d94b2db | 201 | target_m64=1 |
eaf01c25 VS |
202 | fi |
203 | ||
fc97214f | 204 | case "$target_os" in |
c3302aa5 | 205 | windows* | mingw32*) target_os=cygwin ;; |
fc97214f VS |
206 | esac |
207 | ||
9304eef1 | 208 | # This normalizes the names, and creates a new variable ("host_kernel") |
209 | # while at it, since the mapping is not always 1:1 (e.g. different OSes | |
210 | # using the same kernel type). | |
211 | case "$host_os" in | |
212 | gnu*) host_kernel=hurd ;; | |
213 | linux*) host_kernel=linux ;; | |
67937d4d | 214 | freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;; |
2c7031b1 | 215 | netbsd*) host_kernel=netbsd ;; |
958ee221 | 216 | solaris*) host_kernel=illumos ;; |
b105df76 | 217 | darwin*) host_kernel=xnu ;; |
7e518ca8 | 218 | cygwin | windows* | mingw32*) host_kernel=windows ;; |
9304eef1 | 219 | esac |
220 | ||
cd46aa6c | 221 | case "$host_os" in |
5435aaac XG |
222 | cygwin) have_exec=y ;; |
223 | windows* | mingw32*) have_exec=n ;; | |
cd46aa6c VS |
224 | aros*) have_exec=n ;; |
225 | *) have_exec=y;; | |
226 | esac | |
227 | ||
f84b481b | 228 | case "$platform" in |
c721825b BC |
229 | coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;; |
230 | multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;; | |
231 | efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;; | |
9612ebc0 | 232 | xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;; |
d789e70e | 233 | xen_pvh) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN_PVH=1" ;; |
c721825b | 234 | ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;; |
389b31cd | 235 | uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;; |
c721825b BC |
236 | qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;; |
237 | pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;; | |
238 | emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;; | |
0c930a84 VS |
239 | loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;; |
240 | qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;; | |
3666d5f6 | 241 | arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;; |
f84b481b | 242 | esac |
4959e111 VS |
243 | if test x${target_cpu} = xmipsel ; then |
244 | machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`" | |
245 | else | |
0c930a84 | 246 | machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`" |
4959e111 | 247 | fi |
6bea3f89 | 248 | |
7f63a64f VS |
249 | case "${target_cpu}-$platform" in |
250 | mips-arc) | |
251 | TARGET_LINK_ADDR=0x88200000 | |
252 | TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000 | |
253 | ;; | |
254 | mipsel-arc) | |
255 | TARGET_LINK_ADDR=0x80700000 | |
256 | TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000 | |
257 | ;; | |
5fe67f39 | 258 | mips*-qemu_mips | mips*-loongson) |
7f63a64f VS |
259 | TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000 |
260 | ;; | |
261 | esac | |
262 | ||
263 | AC_SUBST(TARGET_LINK_ADDR) | |
264 | AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR) | |
265 | ||
c721825b | 266 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS" |
f84b481b | 267 | |
56978920 | 268 | AC_SUBST(host_cpu) |
269 | AC_SUBST(host_os) | |
9304eef1 | 270 | AC_SUBST(host_kernel) |
6e5a42fe | 271 | |
071114bb VS |
272 | AC_SUBST(target_cpu) |
273 | AC_SUBST(platform) | |
274 | ||
d87aedff | 275 | # Define default variables |
7134247c VS |
276 | |
277 | have_with_bootdir=n | |
278 | AC_ARG_WITH([bootdir], | |
279 | AS_HELP_STRING([--with-bootdir=DIR], | |
280 | [set the name of /boot directory [[guessed]]]), | |
281 | [have_with_bootdir=y], | |
282 | [have_with_bootdir=n]) | |
283 | if test x$have_with_bootdir = xy; then | |
284 | bootdirname="$with_bootdir" | |
285 | else | |
286 | case "$host_os" in | |
287 | netbsd* | openbsd*) | |
d87aedff | 288 | # Because /boot is used for the boot block in NetBSD and OpenBSD, |
7134247c VS |
289 | bootdirname='' ;; |
290 | *) bootdirname='boot' ;; | |
291 | esac | |
292 | fi | |
293 | ||
d87aedff | 294 | AC_SUBST(bootdirname) |
a4c1d277 | 295 | AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname", |
a6c83d4a | 296 | [Default boot directory name]) |
d87aedff | 297 | |
7134247c VS |
298 | AC_ARG_WITH([grubdir], |
299 | AS_HELP_STRING([--with-grubdir=DIR], | |
300 | [set the name of grub directory [[guessed]]]), | |
301 | [grubdirname="$with_grubdir"], | |
302 | [grubdirname="$PACKAGE"]) | |
303 | ||
d87aedff | 304 | AC_SUBST(grubdirname) |
a4c1d277 YB |
305 | AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname", |
306 | [Default grub directory name]) | |
d87aedff | 307 | |
b977bf01 | 308 | # |
309 | # Checks for build programs. | |
310 | # | |
144f1f98 | 311 | |
6c826348 | 312 | # Although cmp is listed in the GNU Coding Standards as a command which |
313 | # can used directly, OpenBSD lacks cmp in the default installation. | |
314 | AC_CHECK_PROGS([CMP], [cmp]) | |
315 | if test "x$CMP" = x; then | |
316 | AC_MSG_ERROR([cmp is not found]) | |
317 | fi | |
318 | ||
144f1f98 | 319 | AC_CHECK_PROGS([YACC], [bison]) |
1569ec51 | 320 | if test "x$YACC" = x; then |
6c826348 | 321 | AC_MSG_ERROR([bison is not found]) |
1569ec51 | 322 | fi |
323 | ||
76ed06b9 | 324 | AC_PROG_RANLIB |
b977bf01 | 325 | AC_PROG_INSTALL |
326 | AC_PROG_AWK | |
09220190 | 327 | AC_PROG_LEX |
76ed06b9 | 328 | AC_PROG_YACC |
b977bf01 | 329 | AC_PROG_MAKE_SET |
ff420223 | 330 | AC_PROG_MKDIR_P |
e1fd1939 | 331 | AC_PROG_LN_S |
b977bf01 | 332 | |
c7c75cf4 | 333 | if test "x$LEX" = "x:"; then |
09220190 BC |
334 | AC_MSG_ERROR([flex is not found]) |
335 | else | |
a2618427 | 336 | version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'` |
b777c18e | 337 | if test -n "$version" -a "$version" -ge 20535; then |
09220190 BC |
338 | : |
339 | else | |
340 | AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above]) | |
341 | fi | |
342 | fi | |
343 | ||
68807e5f | 344 | # These are not a "must". |
51fa856c | 345 | AC_PATH_PROGS(MAKEINFO, makeinfo true) |
6a161fa9 | 346 | |
b977bf01 | 347 | # |
348 | # Checks for host programs. | |
349 | # | |
350 | ||
351 | AC_PROG_CC | |
15c69261 | 352 | gl_EARLY |
1eed0e6e | 353 | AC_PROG_CXX |
76ed06b9 BC |
354 | AM_PROG_CC_C_O |
355 | AM_PROG_AS | |
8b467844 | 356 | AM_PATH_PYTHON([2.6]) |
76ed06b9 | 357 | |
6a161fa9 | 358 | # Must be GCC. |
359 | test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) | |
360 | ||
1eed0e6e VS |
361 | AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no) |
362 | ||
4889bdec | 363 | AC_GNU_SOURCE |
2f1a3acf | 364 | AM_GNU_GETTEXT([external]) |
b977bf01 | 365 | AC_SYS_LARGEFILE |
366 | ||
367 | # Identify characteristics of the host architecture. | |
7b780018 VS |
368 | unset ac_cv_c_bigendian |
369 | ||
eaf01c25 VS |
370 | if test x"$target_cpu-$platform" = xsparc64-emu ; then |
371 | CFLAGS="$CFLAGS -m64" | |
372 | HOST_CFLAGS="$HOST_CFLAGS -m64" | |
373 | fi | |
374 | ||
fc7a64bc VS |
375 | CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64" |
376 | HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64" | |
377 | ||
b977bf01 | 378 | AC_C_BIGENDIAN |
379 | AC_CHECK_SIZEOF(void *) | |
380 | AC_CHECK_SIZEOF(long) | |
381 | ||
7e518ca8 VS |
382 | case "$host_os" in |
383 | cygwin | windows* | mingw32*) | |
384 | HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500" | |
385 | CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500" | |
386 | AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>]) | |
387 | ;; | |
388 | esac | |
389 | ||
3bac4caa FJ |
390 | case "$host_os" in |
391 | cygwin | windows* | mingw32* | aros*) | |
392 | ;; | |
393 | *) | |
394 | AC_CHECK_SIZEOF(off_t) | |
608bec51 VS |
395 | if test x"$ac_cv_sizeof_off_t" != x8 ; then |
396 | AC_CHECK_SIZEOF(off64_t) | |
397 | test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required]) | |
398 | fi;; | |
3bac4caa FJ |
399 | esac |
400 | ||
aad32b14 VS |
401 | if test x$USE_NLS = xno; then |
402 | HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext" | |
403 | fi | |
404 | ||
86695375 | 405 | if test "x$cross_compiling" = xyes; then |
406 | AC_MSG_WARN([cannot generate manual pages while cross compiling]) | |
407 | else | |
408 | AC_PATH_PROG(HELP2MAN, help2man) | |
409 | fi | |
410 | ||
3169f4c7 | 411 | # Check for functions and headers. |
0f7e980b | 412 | AC_CHECK_FUNCS(posix_memalign memalign getextmntent) |
7a5b301e | 413 | AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) |
07662af7 AB |
414 | |
415 | # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation | |
416 | # warning which causes compilation failure later with -Werror. So use -Werror here | |
417 | # as well to force proper sys/sysmacros.h detection. | |
418 | SAVED_CFLAGS="$CFLAGS" | |
419 | CFLAGS="$HOST_CFLAGS -Werror" | |
7a5b301e | 420 | AC_HEADER_MAJOR |
07662af7 | 421 | CFLAGS="$SAVED_CFLAGS" |
7c4e16ff | 422 | |
fb90b546 RM |
423 | AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default |
424 | #include <sys/param.h> | |
425 | #include <sys/mount.h>]) | |
426 | ||
427 | AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default | |
428 | #include <sys/param.h> | |
429 | #include <sys/mount.h>]) | |
430 | ||
2c7031b1 GS |
431 | # For opendisk() and getrawpartition() on NetBSD. |
432 | # Used in util/deviceiter.c and in util/hostdisk.c. | |
433 | AC_CHECK_HEADER([util.h], [ | |
434 | AC_CHECK_LIB([util], [opendisk], [ | |
435 | LIBUTIL="-lutil" | |
436 | AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used]) | |
437 | ]) | |
438 | AC_CHECK_LIB([util], [getrawpartition], [ | |
439 | LIBUTIL="-lutil" | |
440 | AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used]) | |
441 | ]) | |
442 | ]) | |
443 | AC_SUBST([LIBUTIL]) | |
444 | ||
19ce697d | 445 | AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [ |
00c05e22 | 446 | SAVED_CFLAGS="$CFLAGS" |
b35ec299 | 447 | CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror" |
00c05e22 VS |
448 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> |
449 | int va_arg_func (int fixed, va_list args);]], [[]])], | |
19ce697d VS |
450 | [grub_cv_host_cc_wtrampolines=yes], |
451 | [grub_cv_host_cc_wtrampolines=no]) | |
00c05e22 VS |
452 | CFLAGS="$SAVED_CFLAGS" |
453 | ]) | |
454 | ||
19ce697d VS |
455 | if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then |
456 | HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines" | |
00c05e22 VS |
457 | fi |
458 | ||
76ed06b9 BC |
459 | # |
460 | # Check for host and build compilers. | |
461 | # | |
462 | HOST_CC=$CC | |
816719c8 VS |
463 | AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc]) |
464 | test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.]) | |
b224c266 | 465 | BUILD_CPP="$BUILD_CC -E" |
76ed06b9 | 466 | |
29013cba VS |
467 | case "$build_os" in |
468 | haiku*) BUILD_LIBM= ;; | |
469 | *) BUILD_LIBM=-lm ;; | |
470 | esac | |
1ecf96fc AB |
471 | |
472 | dnl FIXME proper test seems to require too deep dive into Autoconf internals. | |
473 | dnl For now just list known platforms that we support. | |
474 | ||
475 | case "$build_os" in | |
476 | cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;; | |
477 | *) BUILD_EXEEXT= ;; | |
478 | esac | |
479 | AC_SUBST(BUILD_EXEEXT) | |
480 | ||
a827807a VS |
481 | # In some build environments like termux /bin/sh is not a valid |
482 | # shebang. Use $SHELL instead if it's executable and /bin/sh isn't | |
483 | BUILD_SHEBANG=/bin/sh | |
484 | for she in /bin/sh "$SHELL"; do | |
485 | if test -x "$she" ; then | |
486 | BUILD_SHEBANG="$she" | |
487 | fi | |
488 | done | |
489 | AC_SUBST(BUILD_SHEBANG) | |
490 | ||
15c69261 YB |
491 | # For gnulib. |
492 | gl_INIT | |
493 | ||
93bf55e6 | 494 | WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes" |
ae558c2c | 495 | EXTRA_WARN_FLAGS="-Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2" |
60d5e9cb VS |
496 | |
497 | HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align" | |
498 | ||
499 | AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [ | |
500 | SAVED_CFLAGS="$CFLAGS" | |
501 | grub_cv_cc_w_extra_flags= | |
502 | for x in $EXTRA_WARN_FLAGS; do | |
503 | CFLAGS="$HOST_CFLAGS $x -Werror" | |
504 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0]) | |
505 | if test x$flag = x1 ; then | |
506 | grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x" | |
507 | fi | |
508 | done | |
509 | CFLAGS="$SAVED_CFLAGS" | |
510 | ]) | |
511 | ||
512 | HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" | |
513 | ||
b977bf01 | 514 | # |
515 | # Check for target programs. | |
516 | # | |
517 | ||
5b5d4aa5 | 518 | # Find tools for the target. |
519 | if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then | |
b977bf01 | 520 | tmp_ac_tool_prefix="$ac_tool_prefix" |
521 | ac_tool_prefix=$target_alias- | |
522 | ||
523 | AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc], | |
524 | [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])]) | |
fc97214f VS |
525 | AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy) |
526 | AC_CHECK_TOOL(TARGET_STRIP, strip) | |
527 | AC_CHECK_TOOL(TARGET_NM, nm) | |
0e8daad0 | 528 | AC_CHECK_TOOL(TARGET_RANLIB, ranlib) |
b977bf01 | 529 | |
530 | ac_tool_prefix="$tmp_ac_tool_prefix" | |
531 | else | |
532 | if test "x$TARGET_CC" = x; then | |
533 | TARGET_CC=$CC | |
534 | fi | |
fc97214f VS |
535 | AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy) |
536 | AC_CHECK_TOOL(TARGET_STRIP, strip) | |
537 | AC_CHECK_TOOL(TARGET_NM, nm) | |
0e8daad0 | 538 | AC_CHECK_TOOL(TARGET_RANLIB, ranlib) |
b977bf01 | 539 | fi |
fc97214f | 540 | |
76ed06b9 BC |
541 | AC_SUBST(HOST_CC) |
542 | AC_SUBST(BUILD_CC) | |
7c9d0c39 VS |
543 | AC_SUBST(BUILD_CFLAGS) |
544 | AC_SUBST(BUILD_CPPFLAGS) | |
dcecae1a | 545 | AC_SUBST(BUILD_LDFLAGS) |
b977bf01 | 546 | AC_SUBST(TARGET_CC) |
fc97214f | 547 | AC_SUBST(TARGET_NM) |
1bd73025 | 548 | AC_SUBST(TARGET_RANLIB) |
fc97214f VS |
549 | AC_SUBST(TARGET_STRIP) |
550 | AC_SUBST(TARGET_OBJCOPY) | |
b977bf01 | 551 | |
b977bf01 | 552 | # Test the C compiler for the target environment. |
553 | tmp_CC="$CC" | |
554 | tmp_CFLAGS="$CFLAGS" | |
555 | tmp_LDFLAGS="$LDFLAGS" | |
556 | tmp_CPPFLAGS="$CPPFLAGS" | |
aa6d7826 | 557 | tmp_LIBS="$LIBS" |
b977bf01 | 558 | CC="$TARGET_CC" |
559 | CFLAGS="$TARGET_CFLAGS" | |
560 | CPPFLAGS="$TARGET_CPPFLAGS" | |
561 | LDFLAGS="$TARGET_LDFLAGS" | |
aa6d7826 | 562 | LIBS="" |
b977bf01 | 563 | |
90d1e879 | 564 | # debug flags. |
4e27343f | 565 | TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations" |
76ed06b9 | 566 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g" |
6a161fa9 | 567 | |
c12936c5 VS |
568 | if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then |
569 | TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align" | |
570 | fi | |
571 | ||
6a7957f9 VS |
572 | TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)" |
573 | ||
60d5e9cb VS |
574 | AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [ |
575 | LDFLAGS="$TARGET_LDFLAGS -nostdlib -static" | |
576 | ||
577 | grub_cv_target_cc_w_extra_flags= | |
578 | for x in $EXTRA_WARN_FLAGS; do | |
579 | CFLAGS="$TARGET_CFLAGS $x -Werror" | |
37378f74 VS |
580 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
581 | asm (".globl start; start:"); | |
582 | void __main (void); | |
583 | void __main (void) {} | |
584 | int main (void); | |
585 | ]], [[]])], [flag=1], [flag=0]) | |
60d5e9cb VS |
586 | if test x$flag = x1 ; then |
587 | grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x" | |
588 | fi | |
589 | done | |
590 | ]) | |
591 | ||
592 | TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags" | |
593 | ||
86f05f14 | 594 | AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang], |
b73b70eb VS |
595 | [ |
596 | CFLAGS="$TARGET_CFLAGS" | |
597 | AC_COMPILE_IFELSE( | |
60375a88 VS |
598 | [AC_LANG_PROGRAM([], [[ |
599 | #ifdef __clang__ | |
600 | #error "is clang" | |
601 | #endif | |
602 | ]])], | |
603 | [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) | |
604 | ||
a3645c12 | 605 | if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then |
5c46165a VS |
606 | AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ |
607 | grub_cv_target_cc_big_endian=no | |
a3645c12 AB |
608 | for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \ |
609 | "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \ | |
610 | "-EB" "-mbig-endian"; do | |
5c46165a VS |
611 | if test x"$grub_cv_target_cc_big_endian" != xno ; then |
612 | break | |
613 | fi | |
614 | CFLAGS="$TARGET_CFLAGS $cand -Werror" | |
615 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
616 | #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__) | |
617 | #error still little endian | |
618 | #endif | |
619 | asm (".globl start; start:"); | |
a3645c12 AB |
620 | asm (".globl _start; _start:"); |
621 | asm (".globl __start; __start:"); | |
5c46165a VS |
622 | void __main (void); |
623 | void __main (void) {} | |
624 | int main (void); | |
625 | ]], [[]])], | |
626 | [grub_cv_target_cc_big_endian="$cand"], []) | |
627 | done | |
628 | ]) | |
629 | ||
630 | if test x"$grub_cv_target_cc_big_endian" = xno ; then | |
631 | AC_MSG_ERROR([could not force big-endian]) | |
632 | fi | |
633 | ||
634 | skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')" | |
635 | ||
636 | TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags" | |
637 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" | |
638 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" | |
639 | TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" | |
a3645c12 AB |
640 | elif test x$target_cpu = xmipsel; then |
641 | AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [ | |
642 | grub_cv_target_cc_little_endian=no | |
643 | for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \ | |
644 | "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \ | |
645 | "-EL"; do | |
646 | if test x"$grub_cv_target_cc_little_endian" != xno ; then | |
647 | break | |
648 | fi | |
649 | CFLAGS="$TARGET_CFLAGS $cand -Werror" | |
650 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
651 | #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__) | |
652 | #error still big endian | |
653 | #endif | |
654 | asm (".globl start; start:"); | |
655 | asm (".globl _start; _start:"); | |
656 | asm (".globl __start; __start:"); | |
657 | void __main (void); | |
658 | void __main (void) {} | |
659 | int main (void); | |
660 | ]], [[]])], | |
661 | [grub_cv_target_cc_little_endian="$cand"], []) | |
662 | done | |
663 | ]) | |
664 | ||
665 | if test x"$grub_cv_target_cc_little_endian" = xno ; then | |
666 | AC_MSG_ERROR([could not force little-endian]) | |
667 | fi | |
668 | ||
669 | skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')" | |
670 | ||
671 | TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags" | |
672 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" | |
673 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" | |
674 | TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian" | |
5c46165a VS |
675 | fi |
676 | ||
be25d921 AB |
677 | # GRUB code is N32-compliant but it's experimental and we would prefer to |
678 | # avoid having too much variety when it doesn't result in any real improvement. | |
679 | # Moreover N64 isn't supported. | |
680 | if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then | |
681 | AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [ | |
682 | grub_cv_target_cc_mips_o32_abi=no | |
683 | for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do | |
684 | if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then | |
685 | break | |
686 | fi | |
687 | CFLAGS="$TARGET_CFLAGS $arg -Werror" | |
688 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
689 | #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32) | |
690 | #error not o32 ABI | |
691 | #endif | |
692 | asm (".globl start; start:"); | |
693 | asm (".globl _start; _start:"); | |
694 | asm (".globl __start; __start:"); | |
695 | void __main (void); | |
696 | void __main (void) {} | |
697 | int main (void); | |
698 | ]], [[]])], | |
699 | [grub_cv_target_cc_mips_o32_abi="$arg"], []) | |
700 | done | |
701 | ]) | |
702 | ||
703 | if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then | |
704 | AC_MSG_ERROR([could not force MIPS o32 ABI]) | |
705 | fi | |
706 | ||
707 | TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi" | |
708 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi" | |
709 | fi | |
710 | ||
065ad910 VS |
711 | AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ |
712 | test_program= | |
f16b8c04 VS |
713 | case "x$target_cpu-$platform" in |
714 | xmips-* | xmipsel-*) | |
065ad910 VS |
715 | test_program=mips |
716 | ;; | |
f16b8c04 VS |
717 | xi386-pc) |
718 | test_program=i386-pc | |
719 | ;; | |
720 | xi386-* | xx86_64-*) | |
065ad910 VS |
721 | test_program=i386 |
722 | ;; | |
f16b8c04 | 723 | xpowerpc-* | xsparc64-* | xarm-*) |
065ad910 VS |
724 | test_program=$target_cpu |
725 | ;; | |
726 | esac | |
727 | if test x"$test_program" = x ; then | |
728 | grub_cv_cc_target_asm_compile= | |
729 | else | |
730 | found=no | |
731 | for arg in "" "-no-integrated-as"; do | |
732 | cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S" | |
733 | echo "Running $cmdline" >&AS_MESSAGE_LOG_FD | |
734 | if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then | |
735 | grub_cv_cc_target_asm_compile="$arg" | |
736 | found=yes | |
737 | break | |
738 | fi | |
739 | done | |
740 | if test x"$found" = xno ; then | |
741 | AC_MSG_ERROR([could not compile assembly]) | |
742 | fi | |
60375a88 | 743 | fi |
065ad910 | 744 | ]) |
60375a88 | 745 | |
065ad910 | 746 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile" |
b73b70eb | 747 | |
60375a88 VS |
748 | if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then |
749 | TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" | |
750 | fi | |
751 | ||
752 | if test "x$target_m32" = x1; then | |
753 | # Force 32-bit mode. | |
754 | TARGET_CFLAGS="$TARGET_CFLAGS -m32" | |
755 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32" | |
756 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32" | |
757 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" | |
758 | TARGET_MODULE_FORMAT="elf32" | |
759 | fi | |
760 | ||
761 | if test "x$target_m64" = x1; then | |
762 | # Force 64-bit mode. | |
763 | TARGET_CFLAGS="$TARGET_CFLAGS -m64" | |
764 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64" | |
765 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64" | |
766 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" | |
767 | TARGET_MODULE_FORMAT="elf64" | |
768 | fi | |
769 | ||
770 | if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then | |
771 | TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3" | |
772 | fi | |
773 | ||
f93ddcfd VS |
774 | # on mips redirect cache flushing function to non-existant one. |
775 | if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then | |
776 | AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [ | |
777 | CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror" | |
778 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
779 | [grub_cv_cc_mflush_func=yes], | |
780 | [grub_cv_cc_mflush_func=no]) | |
781 | ]) | |
782 | ||
783 | if test "x$grub_cv_cc_mflush_func" = xyes; then | |
784 | TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring" | |
785 | fi | |
786 | fi | |
787 | ||
788 | ||
90d1e879 RM |
789 | # Force no alignment to save space on i386. |
790 | if test "x$target_cpu" = xi386; then | |
791 | AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ | |
b35ec299 | 792 | CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror" |
eb73121d | 793 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
90d1e879 RM |
794 | [grub_cv_cc_falign_loop=yes], |
795 | [grub_cv_cc_falign_loop=no]) | |
6a161fa9 | 796 | ]) |
6a161fa9 | 797 | |
c966a489 | 798 | AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [ |
b35ec299 | 799 | CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror" |
c966a489 VS |
800 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
801 | [grub_cv_cc_malign_loop=yes], | |
802 | [grub_cv_cc_malign_loop=no]) | |
803 | ]) | |
804 | ||
90d1e879 RM |
805 | if test "x$grub_cv_cc_falign_loop" = xyes; then |
806 | TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" | |
c966a489 | 807 | elif test "x$grub_cv_cc_malign_loop" = xyes; then |
90d1e879 | 808 | TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" |
6a161fa9 | 809 | fi |
89e0240c | 810 | fi |
6a161fa9 | 811 | |
cdc17f60 VS |
812 | AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [ |
813 | CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror" | |
814 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
815 | [grub_cv_cc_freg_struct_return=yes], | |
816 | [grub_cv_cc_freg_struct_return=no]) | |
817 | ]) | |
818 | ||
819 | if test "x$grub_cv_cc_freg_struct_return" = xyes; then | |
820 | TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return" | |
821 | fi | |
822 | ||
ee0220bc | 823 | if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then |
90d1e879 RM |
824 | # Some toolchains enable these features by default, but they need |
825 | # registers that aren't set up properly in GRUB. | |
cd6d79cd | 826 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow" |
90d1e879 | 827 | fi |
77c55a87 | 828 | |
3661261f VS |
829 | # GRUB doesn't use float or doubles at all. Yet some toolchains may decide |
830 | # that floats are a good fit to run instead of what's written in the code. | |
831 | # Given that floating point unit is disabled (if present to begin with) | |
832 | # when GRUB is running which may result in various hard crashes. | |
ebe316e4 VS |
833 | if test x"$platform" != xemu ; then |
834 | AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [ | |
835 | grub_cv_target_cc_soft_float=no | |
836 | if test "x$target_cpu" = xarm64; then | |
43d42314 | 837 | CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror" |
ebe316e4 | 838 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
43d42314 | 839 | [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], []) |
ebe316e4 | 840 | fi |
f1957dc8 AG |
841 | if test "x$target_cpu" = xriscv32; then |
842 | CFLAGS="$TARGET_CFLAGS -march=rv32imac -mabi=ilp32 -Werror" | |
843 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
844 | [grub_cv_target_cc_soft_float="-march=rv32imac -mabi=ilp32"], []) | |
845 | fi | |
846 | if test "x$target_cpu" = xriscv64; then | |
847 | CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror" | |
848 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
849 | [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], []) | |
850 | fi | |
ea39b87a VS |
851 | if test "x$target_cpu" = xia64; then |
852 | CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror" | |
853 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
854 | [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], []) | |
855 | fi | |
6a4ecd27 VS |
856 | for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \ |
857 | "-Xclang -msoft-float -Xclang -no-implicit-float" \ | |
ebe316e4 VS |
858 | "-Xclang -msoft-float" "-msoft-float"; do |
859 | if test x"$grub_cv_target_cc_soft_float" != xno ; then | |
860 | break | |
861 | fi | |
862 | CFLAGS="$TARGET_CFLAGS $cand -Werror" | |
863 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
864 | [grub_cv_target_cc_soft_float="$cand"], []) | |
865 | done | |
866 | ]) | |
867 | ||
868 | if test x"$grub_cv_target_cc_soft_float" = xno ; then | |
869 | AC_MSG_ERROR([could not force soft-float]) | |
870 | fi | |
871 | ||
872 | case x"$grub_cv_target_cc_soft_float" in | |
6a4ecd27 | 873 | x*"-Xclang"*) |
ebe316e4 VS |
874 | # A trick so that clang doesn't see it on link stаge |
875 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float" | |
876 | ;; | |
877 | *) | |
878 | TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float" | |
879 | ;; | |
880 | esac | |
43d42314 | 881 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" |
345076a7 | 882 | |
2da4171e | 883 | fi |
3661261f | 884 | |
155f334f VS |
885 | if test x"$target_cpu" = xsparc64 ; then |
886 | AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [ | |
887 | grub_cv_target_cc_mno_app_regs=no | |
888 | for cand in "-mllvm -sparc-reserve-app-registers" \ | |
889 | "-mno-app-regs"; do | |
890 | if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then | |
891 | break | |
892 | fi | |
893 | CFLAGS="$TARGET_CFLAGS $cand -Werror" | |
aa6ccc05 | 894 | CPPFLAGS="$TARGET_CPPFLAGS" |
155f334f VS |
895 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
896 | [grub_cv_target_cc_mno_app_regs="$cand"], []) | |
897 | done | |
898 | ]) | |
899 | ||
900 | if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then | |
901 | AC_MSG_ERROR([could not reserve application registers]) | |
902 | fi | |
903 | if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then | |
904 | # A trick so that clang doesn't see it on link stаge | |
905 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs" | |
906 | else | |
907 | TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs" | |
908 | fi | |
909 | ||
910 | AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [ | |
911 | grub_cv_target_cc_mno_relax=no | |
912 | for cand in "-mno-relax" "-Wl,--no-relax"; do | |
913 | if test x"$grub_cv_target_cc_mno_relax" != xno ; then | |
914 | break | |
915 | fi | |
916 | LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static" | |
917 | CFLAGS="$TARGET_CFLAGS -Werror" | |
918 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
919 | asm (".globl start; start:"); | |
920 | void __main (void); | |
921 | void __main (void) {} | |
922 | int main (void); | |
923 | ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], []) | |
924 | done | |
925 | ]) | |
926 | LDFLAGS="$TARGET_LDFLAGS" | |
927 | CFLAGS="$TARGET_CFLAGS" | |
928 | ||
929 | if test x"$grub_cv_target_cc_mno_relax" = xno ; then | |
930 | AC_MSG_ERROR([could not find no-relax options]) | |
931 | fi | |
932 | TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax" | |
933 | fi | |
934 | ||
90d1e879 RM |
935 | # By default, GCC 4.4 generates .eh_frame sections containing unwind |
936 | # information in some cases where it previously did not. GRUB doesn't need | |
937 | # these and they just use up vital space. Restore the old compiler | |
938 | # behaviour. | |
939 | AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [ | |
24f4e57c | 940 | CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" |
90d1e879 RM |
941 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
942 | [grub_cv_cc_fno_dwarf2_cfi_asm=yes], | |
943 | [grub_cv_cc_fno_dwarf2_cfi_asm=no]) | |
90d1e879 | 944 | ]) |
77c55a87 | 945 | |
90d1e879 RM |
946 | if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then |
947 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" | |
b977bf01 | 948 | fi |
6a161fa9 | 949 | |
1c1f31e5 VS |
950 | if test x"$target_os" = xcygwin; then |
951 | AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [ | |
24f4e57c | 952 | CFLAGS="$TARGET_CFLAGS -fno-reorder-functions" |
1c1f31e5 VS |
953 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
954 | [grub_cv_cc_no_reorder_functions=yes], | |
955 | [grub_cv_cc_no_reorder_functions=no]) | |
956 | ]) | |
957 | fi | |
958 | ||
959 | if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then | |
960 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions" | |
961 | fi | |
962 | ||
f1b35253 VS |
963 | AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [ |
964 | CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" | |
965 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
966 | [grub_cv_cc_mno_stack_arg_probe=yes], | |
967 | [grub_cv_cc_mno_stack_arg_probe=no]) | |
968 | ]) | |
969 | ||
970 | if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then | |
971 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" | |
972 | fi | |
973 | ||
974 | ||
e9d3421c VS |
975 | # By default, GCC 4.6 generates .eh_frame sections containing unwind |
976 | # information in some cases where it previously did not. GRUB doesn't need | |
977 | # these and they just use up vital space. Restore the old compiler | |
978 | # behaviour. | |
979 | AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [ | |
5ae590b3 | 980 | CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables" |
e9d3421c VS |
981 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
982 | [grub_cv_cc_fno_asynchronous_unwind_tables=yes], | |
983 | [grub_cv_cc_fno_asynchronous_unwind_tables=no]) | |
e9d3421c VS |
984 | ]) |
985 | ||
986 | if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then | |
987 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables" | |
988 | fi | |
989 | ||
40051fed VS |
990 | AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [ |
991 | CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" | |
992 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
993 | [grub_cv_cc_fno_unwind_tables=yes], | |
994 | [grub_cv_cc_fno_unwind_tables=no]) | |
995 | ]) | |
996 | ||
997 | if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then | |
998 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" | |
999 | fi | |
1000 | ||
30c7d3ce | 1001 | |
a9f25a08 VS |
1002 | CFLAGS="$TARGET_CFLAGS" |
1003 | ||
bf082198 VS |
1004 | |
1005 | if test x"$platform" = xemu ; then | |
1006 | TARGET_OBJ2ELF= | |
1007 | grub_cv_target_cc_link_format= | |
1008 | case "$host_os" in | |
1009 | *darwin* | *mac*) | |
1010 | grub_cv_target_cc_link_format="-arch,${target_cpu}" | |
1011 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" | |
1012 | ;; | |
1013 | *windows* | *cygwin* | *mingw*) | |
1014 | if test x${target_cpu} = xi386 ; then | |
4d94b2db CW |
1015 | grub_cv_target_cc_link_format=-mi386pe |
1016 | TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)' | |
bf082198 VS |
1017 | fi |
1018 | if test x${target_cpu} = xx86_64 ; then | |
4d94b2db CW |
1019 | grub_cv_target_cc_link_format=-mi386pep |
1020 | TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)' | |
bf082198 VS |
1021 | fi |
1022 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" | |
1023 | ;; | |
1024 | esac | |
1025 | elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then | |
c2b70d09 | 1026 | AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [ |
a9f25a08 | 1027 | grub_cv_target_cc_link_format=unknown |
6f1f6a0c | 1028 | for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do |
bf082198 | 1029 | if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then |
6f1f6a0c VS |
1030 | continue |
1031 | fi | |
bf082198 | 1032 | if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then |
a9f25a08 VS |
1033 | continue |
1034 | fi | |
246a434f VS |
1035 | CFLAGS="$TARGET_CFLAGS" |
1036 | LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static" | |
a9f25a08 VS |
1037 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
1038 | asm (".globl start; start:"); | |
1039 | asm (".globl _start; _start:"); | |
1040 | asm (".globl __start; __start:"); | |
1041 | void __main (void); | |
1042 | void __main (void) {} | |
c2b70d09 | 1043 | ]], [[]])], [flag=1], [flag=0]) |
a9f25a08 VS |
1044 | if test x"$flag" = x1; then |
1045 | grub_cv_target_cc_link_format="$format" | |
4d94b2db | 1046 | break |
a9f25a08 VS |
1047 | fi |
1048 | done]) | |
1049 | if test x"$grub_cv_target_cc_link_format" = xunknown; then | |
1050 | AC_MSG_ERROR([no suitable link format found]) | |
1051 | fi | |
1052 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" | |
6f1f6a0c | 1053 | if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then |
4d94b2db | 1054 | TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)' |
a9f25a08 | 1055 | fi |
6f1f6a0c | 1056 | if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then |
4d94b2db | 1057 | TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)' |
6f1f6a0c | 1058 | fi |
a9f25a08 VS |
1059 | fi |
1060 | ||
1061 | if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_cc_link_format = x-arch,x86_64; then | |
1062 | TARGET_APPLE_LINKER=1 | |
1063 | AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], []) | |
1064 | if test "x$TARGET_OBJCONV" = x ; then | |
1065 | AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.]) | |
1066 | fi | |
1067 | if test "x$TARGET_OBJCONV" = x ; then | |
1068 | AC_MSG_ERROR([objconv not found which is required when building with apple compiler]) | |
1069 | fi | |
1070 | TARGET_IMG_LDSCRIPT= | |
1071 | TARGET_IMG_CFLAGS="-static" | |
1072 | TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20' | |
1073 | TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20' | |
1074 | TARGET_IMG_BASE_LDOPT="-Wl,-image_base" | |
1075 | TARGET_LDFLAGS_OLDMAGIC="" | |
6f1f6a0c | 1076 | elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then |
a9f25a08 VS |
1077 | TARGET_APPLE_LINKER=0 |
1078 | TARGET_LDFLAGS_OLDMAGIC="-Wl,-N" | |
60b967be | 1079 | TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc" |
a9f25a08 | 1080 | TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}" |
60b967be | 1081 | TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-cygwin-img-ld.sc" |
a9f25a08 VS |
1082 | TARGET_IMG_BASE_LDOPT="-Wl,-Ttext" |
1083 | TARGET_IMG_CFLAGS= | |
1084 | else | |
1085 | TARGET_APPLE_LINKER=0 | |
1086 | TARGET_LDFLAGS_OLDMAGIC="-Wl,-N" | |
1087 | TARGET_IMG_LDSCRIPT= | |
1088 | TARGET_IMG_LDFLAGS='-Wl,-N' | |
1089 | TARGET_IMG_LDFLAGS_AC='-Wl,-N' | |
1090 | TARGET_IMG_BASE_LDOPT="-Wl,-Ttext" | |
1091 | TARGET_IMG_CFLAGS= | |
1092 | fi | |
1093 | ||
80fdaf1d VS |
1094 | CFLAGS="$TARGET_CFLAGS" |
1095 | ||
1096 | AC_ARG_ENABLE([efiemu], | |
1097 | [AS_HELP_STRING([--enable-efiemu], | |
1098 | [build and install the efiemu runtimes (default=guessed)])]) | |
1099 | if test x"$enable_efiemu" = xno ; then | |
1100 | efiemu_excuse="explicitly disabled" | |
1101 | fi | |
1102 | ||
1103 | if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then | |
1104 | efiemu_excuse="not available on cygwin" | |
1105 | fi | |
1106 | if test x"$target_cpu" != xi386 ; then | |
1107 | efiemu_excuse="only available on i386" | |
1108 | fi | |
1109 | if test x"$platform" = xefi ; then | |
1110 | efiemu_excuse="not available on efi" | |
1111 | fi | |
1112 | ||
1113 | if test x"$efiemu_excuse" = x ; then | |
1114 | AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [ | |
1115 | CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" | |
1116 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
1117 | [grub_cv_cc_efiemu=yes], | |
1118 | [grub_cv_cc_efiemu=no]) | |
1119 | ]) | |
1120 | if test x$grub_cv_cc_efiemu = xno; then | |
1121 | efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" | |
1122 | fi | |
1123 | fi | |
1124 | if test x"$efiemu_excuse" = x ; then | |
1125 | AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [ | |
1126 | grub_cv_target_cc_efiemu64_link_format=unknown | |
1127 | for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do | |
1128 | CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" | |
1129 | LDFLAGS="-m64 -Wl,$format -nostdlib -static" | |
1130 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
1131 | asm (".globl start; start:"); | |
1132 | asm (".globl _start; _start:"); | |
1133 | asm (".globl __start; __start:"); | |
1134 | void __main (void); | |
1135 | void __main (void) {} | |
1136 | ]], [[]])], [flag=1], [flag=0]) | |
1137 | if test x"$flag" = x1; then | |
1138 | grub_cv_target_cc_efiemu64_link_format="$format" | |
1139 | break | |
1140 | fi | |
1141 | done]) | |
1142 | if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then | |
1143 | efiemu_excuse="no suitable link format for efiemu64 found" | |
1144 | else | |
1145 | EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format" | |
1146 | fi | |
1147 | fi | |
1148 | if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then | |
1149 | AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)]) | |
1150 | fi | |
1151 | if test x"$efiemu_excuse" = x ; then | |
1152 | enable_efiemu=yes | |
1153 | else | |
1154 | enable_efiemu=no | |
1155 | fi | |
1156 | AC_SUBST([enable_efiemu]) | |
1157 | AC_SUBST([EFIEMU64_LINK_FORMAT]) | |
1158 | ||
1159 | CFLAGS="$TARGET_CFLAGS" | |
1160 | ||
a9f25a08 VS |
1161 | AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) |
1162 | ||
1163 | ||
1164 | LDFLAGS="$TARGET_LDFLAGS" | |
8f0baaac | 1165 | |
f1957dc8 | 1166 | if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64 ; then |
7e9ca17a | 1167 | # Use large model to support 4G memory |
6e09b8b7 | 1168 | AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ |
2a5a532c | 1169 | CFLAGS="$TARGET_CFLAGS -mcmodel=large" |
6e09b8b7 | 1170 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
1171 | [grub_cv_cc_mcmodel=yes], | |
1172 | [grub_cv_cc_mcmodel=no]) | |
1173 | ]) | |
a3ba7410 | 1174 | if test "x$grub_cv_cc_mcmodel" = xyes; then |
c8600122 | 1175 | TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large" |
f1957dc8 | 1176 | elif test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64; then |
eaf01c25 | 1177 | TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany" |
6e09b8b7 | 1178 | fi |
46546fc5 | 1179 | fi |
7e9ca17a | 1180 | |
46546fc5 | 1181 | if test "$target_cpu"-"$platform" = x86_64-efi; then |
7e9ca17a | 1182 | # EFI writes to stack below %rsp, we must not use the red zone |
1183 | AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [ | |
2a5a532c | 1184 | CFLAGS="$TARGET_CFLAGS -mno-red-zone" |
7e9ca17a | 1185 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
1186 | [grub_cv_cc_no_red_zone=yes], | |
1187 | [grub_cv_cc_no_red_zone=no]) | |
1188 | ]) | |
1189 | if test "x$grub_cv_cc_no_red_zone" = xno; then | |
1190 | AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc]) | |
1191 | fi | |
1192 | ||
c8600122 | 1193 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone" |
20011694 | 1194 | fi |
1195 | ||
41822625 | 1196 | if test "x$target_cpu" = xarm; then |
d15f17b2 VS |
1197 | AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [ |
1198 | grub_cv_target_cc_mno_movt=no | |
1199 | for cand in "-mno-movt" \ | |
1200 | "-mllvm -arm-use-movt=0"; do | |
1201 | if test x"$grub_cv_target_cc_mno_movt" != xno ; then | |
1202 | break | |
1203 | fi | |
1204 | CFLAGS="$TARGET_CFLAGS $cand -Werror" | |
1205 | CPPFLAGS="$TARGET_CPPFLAGS" | |
1206 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
1207 | [grub_cv_target_cc_mno_movt="$cand"], []) | |
1208 | done | |
bf9c5616 | 1209 | ]) |
d15f17b2 VS |
1210 | |
1211 | if test x"$grub_cv_target_cc_mno_movt" != xno ; then | |
bf9c5616 | 1212 | # A trick so that clang doesn't see it on link stage |
d15f17b2 | 1213 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt" |
bf9c5616 | 1214 | fi |
a29f317a VS |
1215 | AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [ |
1216 | CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror" | |
1217 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
1218 | [grub_cv_cc_mthumb_interwork=yes], | |
1219 | [grub_cv_cc_mthumb_interwork=no]) | |
1220 | ]) | |
1221 | if test "x$grub_cv_cc_mthumb_interwork" = xyes; then | |
1222 | TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork" | |
2066c35b | 1223 | # Clang defaults to thumb interworking |
a29f317a VS |
1224 | elif test "x$grub_cv_cc_target_clang" = xno ; then |
1225 | AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork]) | |
a29f317a | 1226 | fi |
41822625 VS |
1227 | fi |
1228 | ||
57bc5d43 VS |
1229 | AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [ |
1230 | CFLAGS="$TARGET_CFLAGS -Qn -Werror" | |
1231 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
1232 | [grub_cv_target_cc_qn=yes], | |
1233 | [grub_cv_target_cc_qn=no])]) | |
1234 | if test "x$grub_cv_target_cc_qn" = xyes; then | |
1235 | TARGET_CFLAGS="$TARGET_CFLAGS -Qn" | |
1236 | fi | |
1237 | ||
baa2a121 | 1238 | # |
1239 | # Compiler features. | |
1240 | # | |
1241 | ||
28668d80 VS |
1242 | CFLAGS="$TARGET_CFLAGS" |
1243 | ||
93a81088 | 1244 | # Position independent executable. |
1245 | grub_CHECK_PIE | |
a3e9da05 | 1246 | grub_CHECK_NO_PIE |
b53f595b VS |
1247 | grub_CHECK_NO_PIE_ONEWORD |
1248 | grub_CHECK_LINK_PIE | |
93a81088 | 1249 | [# Need that, because some distributions ship compilers that include |
a3e9da05 | 1250 | # `-fPIE' or '-fpie' and '-pie' in the default specs. |
93a81088 | 1251 | if [ x"$pie_possible" = xyes ]; then |
f4d35d49 | 1252 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie" |
a3e9da05 | 1253 | fi |
b53f595b VS |
1254 | |
1255 | if [ x"$link_nopie_needed" = xyes ] || [ x"$pie_possible" = xyes ]; then | |
1256 | if [ x"$nopie_possible" = xyes ]; then | |
1257 | TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie" | |
1258 | fi | |
1259 | if [ x"$nopie_oneword_possible" = xyes ]; then | |
1260 | TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie" | |
1261 | fi | |
93a81088 | 1262 | fi] |
1263 | ||
28668d80 | 1264 | CFLAGS="$TARGET_CFLAGS" |
a3e9da05 | 1265 | LDFLAGS="$TARGET_LDFLAGS" |
28668d80 | 1266 | |
7bd8b0c7 VS |
1267 | # Position independent executable. |
1268 | grub_CHECK_PIC | |
9cf12b20 VS |
1269 | [# On most platforms we don't want PIC as it only makes relocations harder |
1270 | # and code less efficient. On mips we want to have one got table per module | |
1271 | # and reload $gp in every function. | |
1272 | # GCC implements it using symbol __gnu_local_gp in non-PIC as well. | |
1273 | # However with clang we need PIC for this reloading to happen. | |
393cc591 VS |
1274 | # With arm64 we need relocations that are in some way representable in |
1275 | # PE as we need to support arm64-efi. Without -fPIC clang generates | |
1276 | # movk's which aren't representable. | |
9cf12b20 VS |
1277 | # Since default varies across dictributions use either -fPIC or -fno-PIC |
1278 | # explicitly. | |
393cc591 | 1279 | if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel || test x$target_cpu = xarm64 ) && test "x$grub_cv_cc_target_clang" = xyes ; then |
9cf12b20 VS |
1280 | TARGET_CFLAGS="$TARGET_CFLAGS -fPIC" |
1281 | elif [ x"$pic_possible" = xyes ]; then | |
1282 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC" | |
7bd8b0c7 VS |
1283 | fi] |
1284 | ||
28668d80 VS |
1285 | CFLAGS="$TARGET_CFLAGS" |
1286 | ||
baa2a121 | 1287 | # Smashing stack protector. |
1288 | grub_CHECK_STACK_PROTECTOR | |
c3db8364 | 1289 | # Need that, because some distributions ship compilers that include |
baa2a121 | 1290 | # `-fstack-protector' in the default specs. |
c3db8364 | 1291 | if test "x$ssp_possible" = xyes; then |
1292 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector" | |
1293 | fi | |
28668d80 VS |
1294 | |
1295 | CFLAGS="$TARGET_CFLAGS" | |
1296 | ||
2a8a80e4 | 1297 | grub_CHECK_STACK_ARG_PROBE |
1298 | # Cygwin's GCC uses alloca() to probe the stackframe on static | |
1299 | # stack allocations above some threshold. | |
1300 | if test x"$sap_possible" = xyes; then | |
1301 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" | |
1302 | fi | |
baa2a121 | 1303 | |
28668d80 VS |
1304 | CFLAGS="$TARGET_CFLAGS" |
1305 | ||
d74b9a1d | 1306 | # -mno-unaligned-access -mstrict-align |
bb9f92b9 | 1307 | if test "$target_cpu" = arm; then |
d74b9a1d | 1308 | AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [ |
bdb6090d | 1309 | grub_cv_target_cc_strict_align= |
d74b9a1d VS |
1310 | for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do |
1311 | CFLAGS="$TARGET_CFLAGS $arg -Werror" | |
1312 | LDFLAGS="$TARGET_LDFLAGS" | |
1313 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0]) | |
1314 | if test x"$flag" = x1; then | |
1315 | grub_cv_target_cc_strict_align="$arg" | |
4d94b2db | 1316 | break |
d74b9a1d VS |
1317 | fi |
1318 | done]) | |
1319 | ||
d74b9a1d VS |
1320 | TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align" |
1321 | if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then | |
1322 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments" | |
bb9f92b9 | 1323 | fi |
bdb6090d VS |
1324 | AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned], |
1325 | [CFLAGS="$TARGET_CFLAGS" | |
1326 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ | |
1327 | #ifdef __ARM_FEATURE_UNALIGNED | |
1328 | #error "unaligned" | |
1329 | #endif | |
1330 | ]])], | |
1331 | [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])]) | |
1332 | if test x$grub_cv_cc_target_emits_unaligned = xyes; then | |
1333 | AC_MSG_ERROR([compiler generates unaligned accesses]) | |
1334 | fi | |
bb9f92b9 LL |
1335 | fi |
1336 | ||
aa6d7826 | 1337 | # Set them to their new values for the tests below. |
1338 | CC="$TARGET_CC" | |
064360e6 VS |
1339 | if test x"$platform" = xemu ; then |
1340 | CFLAGS="$TARGET_CFLAGS -Wno-error" | |
1341 | elif test "x$TARGET_APPLE_LINKER" = x1 ; then | |
246a434f | 1342 | CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error" |
26de2bcd | 1343 | else |
37378f74 | 1344 | CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" |
26de2bcd | 1345 | fi |
aa6d7826 | 1346 | CPPFLAGS="$TARGET_CPPFLAGS" |
d5524ca8 | 1347 | |
01fcf061 | 1348 | grub_ASM_USCORE |
064360e6 | 1349 | if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then |
01fcf061 | 1350 | if test x$grub_cv_asm_uscore = xyes; then |
37378f74 | 1351 | DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main" |
01fcf061 | 1352 | else |
37378f74 | 1353 | DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main" |
01fcf061 | 1354 | fi |
37378f74 | 1355 | CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM" |
a9f25a08 | 1356 | fi |
01fcf061 | 1357 | |
69be5b74 | 1358 | # Check for libgcc symbols |
064360e6 | 1359 | if test x"$platform" = xemu; then |
ca73ae44 | 1360 | AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) |
064360e6 | 1361 | fi |
69be5b74 | 1362 | |
a9f25a08 | 1363 | if test "x$TARGET_APPLE_LINKER" = x1 ; then |
246a434f | 1364 | CFLAGS="$TARGET_CFLAGS -nostdlib -static" |
69be5b74 | 1365 | else |
37378f74 | 1366 | CFLAGS="$TARGET_CFLAGS -nostdlib" |
69be5b74 | 1367 | fi |
42e0cba3 | 1368 | LIBS="" |
aa6d7826 | 1369 | |
6a161fa9 | 1370 | # Defined in aclocal.m4. |
f6130a12 | 1371 | grub_PROG_TARGET_CC |
a9f25a08 | 1372 | if test "x$TARGET_APPLE_LINKER" != x1 ; then |
b977bf01 | 1373 | grub_PROG_OBJCOPY_ABSOLUTE |
2b167a72 | 1374 | fi |
cb71ba20 | 1375 | grub_PROG_LD_BUILD_ID_NONE |
b977bf01 | 1376 | if test "x$target_cpu" = xi386; then |
a9f25a08 | 1377 | if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then |
2aec1692 CF |
1378 | if test ! -z "$TARGET_IMG_LDSCRIPT"; then |
1379 | # Check symbols provided by linker script. | |
37378f74 | 1380 | CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000" |
2aec1692 | 1381 | fi |
2a8a80e4 | 1382 | grub_CHECK_BSS_START_SYMBOL |
1383 | grub_CHECK_END_SYMBOL | |
1384 | fi | |
1385 | CFLAGS="$TARGET_CFLAGS" | |
6a161fa9 | 1386 | fi |
1387 | ||
20aea949 VS |
1388 | grub_PROG_NM_WORKS |
1389 | grub_PROG_NM_MINUS_P | |
1390 | grub_PROG_NM_DEFINED_ONLY | |
1391 | AC_SUBST(TARGET_NMFLAGS_MINUS_P) | |
1392 | AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY) | |
1393 | ||
016a671b | 1394 | if test "$platform" != emu; then |
8f9a632b VS |
1395 | AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [ |
1396 | SAVED_CPPFLAGS="$CPPFLAGS" | |
1397 | CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`" | |
1398 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> | |
ce938140 | 1399 | #include <stddef.h> |
8f9a632b VS |
1400 | int va_arg_func (int fixed, va_list args);]], [[]])], |
1401 | [grub_cv_cc_isystem=yes], | |
1402 | [grub_cv_cc_isystem=no]) | |
1403 | CPPFLAGS="$SAVED_CPPFLAGS" | |
1404 | ]) | |
1405 | ||
1406 | if test x"$grub_cv_cc_isystem" = xyes ; then | |
1407 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`" | |
1408 | fi | |
dae79b6b | 1409 | fi |
5ce5507f | 1410 | |
19ce697d | 1411 | AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [ |
24f4e57c | 1412 | CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror" |
779dc15b VS |
1413 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> |
1414 | int va_arg_func (int fixed, va_list args);]], [[]])], | |
19ce697d VS |
1415 | [grub_cv_cc_wtrampolines=yes], |
1416 | [grub_cv_cc_wtrampolines=no]) | |
779dc15b VS |
1417 | ]) |
1418 | ||
19ce697d VS |
1419 | if test x"$grub_cv_cc_wtrampolines" = xyes ; then |
1420 | TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines" | |
779dc15b VS |
1421 | fi |
1422 | ||
c9a86192 | 1423 | # Restore the flags. |
9962ed99 | 1424 | CC="$tmp_CC" |
1425 | CFLAGS="$tmp_CFLAGS" | |
1426 | CPPFLAGS="$tmp_CPPFLAGS" | |
c9a86192 | 1427 | LDFLAGS="$tmp_LDFLAGS" |
aa6d7826 | 1428 | LIBS="$tmp_LIBS" |
6a161fa9 | 1429 | |
4fe9862e | 1430 | # |
2965c7cc | 1431 | # Check for options. |
4fe9862e | 1432 | # |
1433 | ||
1434 | # Memory manager debugging. | |
b39f9d20 | 1435 | AC_ARG_ENABLE([mm-debug], |
2965c7cc | 1436 | AS_HELP_STRING([--enable-mm-debug], |
90ce5d56 | 1437 | [include memory manager debugging]), |
2965c7cc | 1438 | [AC_DEFINE([MM_DEBUG], [1], |
1439 | [Define to 1 if you enable memory manager debugging.])]) | |
1440 | ||
c5dc1690 SJ |
1441 | AC_ARG_ENABLE([cache-stats], |
1442 | AS_HELP_STRING([--enable-cache-stats], | |
055e2b8b | 1443 | [enable disk cache statistics collection])) |
c5dc1690 SJ |
1444 | |
1445 | if test x$enable_cache_stats = xyes; then | |
1446 | DISK_CACHE_STATS=1 | |
1447 | else | |
1448 | DISK_CACHE_STATS=0 | |
1449 | fi | |
1450 | AC_SUBST([DISK_CACHE_STATS]) | |
1451 | ||
e744219b VS |
1452 | AC_ARG_ENABLE([boot-time], |
1453 | AS_HELP_STRING([--enable-boot-time], | |
1454 | [enable boot time statistics collection])) | |
1455 | ||
1456 | if test x$enable_boot_time = xyes; then | |
1457 | BOOT_TIME_STATS=1 | |
1458 | else | |
1459 | BOOT_TIME_STATS=0 | |
1460 | fi | |
1461 | AC_SUBST([BOOT_TIME_STATS]) | |
1462 | ||
927d0134 VS |
1463 | AC_ARG_ENABLE([grub-emu-sdl], |
1464 | [AS_HELP_STRING([--enable-grub-emu-sdl], | |
1465 | [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])]) | |
1466 | ||
3affd0ec | 1467 | AC_ARG_ENABLE([grub-emu-pci], |
1468 | [AS_HELP_STRING([--enable-grub-emu-pci], | |
1469 | [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])]) | |
1470 | ||
f84b481b | 1471 | if test "$platform" = emu; then |
f84b481b | 1472 | |
927d0134 | 1473 | if test x"$enable_grub_emu_sdl" = xno ; then |
16f7455b | 1474 | grub_emu_sdl_excuse="explicitly disabled" |
927d0134 VS |
1475 | fi |
1476 | [if [ x"$grub_emu_sdl_excuse" = x ]; then | |
1477 | # Check for libSDL libraries.] | |
1478 | AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"], | |
1479 | [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]]) | |
1480 | AC_SUBST([LIBSDL]) | |
1481 | [fi] | |
9f293ab0 | 1482 | |
927d0134 VS |
1483 | [if [ x"$grub_emu_sdl_excuse" = x ]; then |
1484 | # Check for headers.] | |
1485 | AC_CHECK_HEADERS([SDL/SDL.h], [], | |
1486 | [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]]) | |
1487 | [fi] | |
9f293ab0 | 1488 | |
927d0134 | 1489 | if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then |
16f7455b | 1490 | AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)]) |
927d0134 VS |
1491 | fi |
1492 | if test x"$grub_emu_sdl_excuse" = x ; then | |
1493 | enable_grub_emu_sdl=yes | |
1494 | else | |
1495 | enable_grub_emu_sdl=no | |
1496 | fi | |
1497 | ||
3affd0ec | 1498 | if test x"$enable_grub_emu_pci" != xyes ; then |
325c8258 | 1499 | grub_emu_pci_excuse="not enabled" |
1500 | fi | |
1501 | ||
325c8258 | 1502 | [if [ x"$grub_emu_pci_excuse" = x ]; then |
1503 | # Check for libpci libraries.] | |
459fed4b | 1504 | AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"], |
1505 | [grub_emu_pci_excuse=["need libpciaccess library"]]) | |
1506 | AC_SUBST([LIBPCIACCESS]) | |
325c8258 | 1507 | [fi] |
1508 | [if [ x"$grub_emu_pci_excuse" = x ]; then | |
1509 | # Check for headers.] | |
5959b15c | 1510 | AC_CHECK_HEADERS([pciaccess.h], [], |
459fed4b | 1511 | [grub_emu_pci_excuse=["need libpciaccess headers"]]) |
325c8258 | 1512 | [fi] |
1513 | ||
1514 | if test x"$grub_emu_pci_excuse" = x ; then | |
1515 | enable_grub_emu_pci=yes | |
1516 | else | |
9f293ab0 | 1517 | |
325c8258 | 1518 | enable_grub_emu_pci=no |
3affd0ec | 1519 | fi |
1520 | ||
927d0134 | 1521 | AC_SUBST([enable_grub_emu_sdl]) |
3affd0ec | 1522 | AC_SUBST([enable_grub_emu_pci]) |
e7d09ac4 AB |
1523 | |
1524 | else | |
1525 | ||
1526 | # Ignore --enable-emu-* if platform is not emu | |
1527 | enable_grub_emu_sdl=no | |
e7d09ac4 | 1528 | enable_grub_emu_pci=no |
f84b481b | 1529 | fi |
4fe9862e | 1530 | |
e52db1f7 | 1531 | AC_ARG_ENABLE([grub-mkfont], |
1532 | [AS_HELP_STRING([--enable-grub-mkfont], | |
5ce5507f | 1533 | [build and install the `grub-mkfont' utility (default=guessed)])]) |
1534 | if test x"$enable_grub_mkfont" = xno ; then | |
ce7a733d | 1535 | grub_mkfont_excuse="explicitly disabled" |
5ce5507f | 1536 | fi |
1537 | ||
7b780018 VS |
1538 | unset ac_cv_header_ft2build_h |
1539 | ||
660960d6 VS |
1540 | if test x"$grub_mkfont_excuse" = x ; then |
1541 | # Check for freetype libraries. | |
7e23437d CW |
1542 | PKG_CHECK_MODULES([FREETYPE], [freetype2], [ |
1543 | SAVED_CPPFLAGS="$CPPFLAGS" | |
1544 | SAVED_LIBS="$LIBS" | |
1545 | CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS" | |
1546 | LIBS="$LIBS $FREETYPE_LIBS" | |
1547 | AC_CHECK_HEADERS([ft2build.h], [], | |
1548 | [grub_mkfont_excuse=["need freetype2 headers"]]) | |
1549 | AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], | |
1550 | [grub_mkfont_excuse=["freetype2 library unusable"]]) | |
1551 | CPPFLAGS="$SAVED_CPPFLAGS" | |
1552 | LIBS="$SAVED_LIBS" | |
1553 | ], [grub_mkfont_excuse=["need freetype2 library"]]) | |
660960d6 VS |
1554 | fi |
1555 | ||
5ce5507f | 1556 | if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then |
d642d761 | 1557 | AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)]) |
5ce5507f | 1558 | fi |
1559 | if test x"$grub_mkfont_excuse" = x ; then | |
1560 | enable_grub_mkfont=yes | |
1561 | else | |
1562 | enable_grub_mkfont=no | |
1563 | fi | |
e52db1f7 | 1564 | AC_SUBST([enable_grub_mkfont]) |
e52db1f7 | 1565 | |
7c9d0c39 | 1566 | SAVED_CC="$CC" |
b224c266 | 1567 | SAVED_CPP="$CPP" |
7c9d0c39 VS |
1568 | SAVED_CFLAGS="$CFLAGS" |
1569 | SAVED_CPPFLAGS="$CPPFLAGS" | |
dcecae1a | 1570 | SAVED_LDFLAGS="$LDFLAGS" |
7c9d0c39 | 1571 | CC="$BUILD_CC" |
b224c266 | 1572 | CPP="$BUILD_CPP" |
7c9d0c39 | 1573 | CFLAGS="$BUILD_CFLAGS" |
7b780018 | 1574 | CPPFLAGS="$BUILD_CPPFLAGS" |
dcecae1a | 1575 | LDFLAGS="$BUILD_LDFAGS" |
7b780018 VS |
1576 | |
1577 | unset ac_cv_c_bigendian | |
1578 | unset ac_cv_header_ft2build_h | |
1579 | ||
1580 | AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)]) | |
1581 | AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)]) | |
1582 | AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err]) | |
1583 | ||
1584 | if test x$BUILD_WORDS_BIGENDIAN = xerr ; then | |
1585 | AC_MSG_ERROR([couldnt determine build endianness]) | |
1586 | fi | |
1587 | ||
1588 | AC_SUBST([BUILD_SIZEOF_LONG]) | |
1589 | AC_SUBST([BUILD_SIZEOF_VOID_P]) | |
1590 | AC_SUBST([BUILD_WORDS_BIGENDIAN]) | |
c5884973 | 1591 | |
7c9d0c39 VS |
1592 | if test x"$grub_build_mkfont_excuse" = x ; then |
1593 | # Check for freetype libraries. | |
7e23437d CW |
1594 | SAVED_PKG_CONFIG="$PKG_CONFIG" |
1595 | test -z "$BUILD_PKG_CONFIG" || PKG_CONFIG="$BUILD_PKG_CONFIG" | |
1596 | PKG_CHECK_MODULES([BUILD_FREETYPE], [freetype2], [ | |
1597 | SAVED_CPPFLAGS_2="$CPPFLAGS" | |
1598 | SAVED_LIBS="$LIBS" | |
1599 | CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS" | |
1600 | LIBS="$LIBS $BUILD_FREETYPE_LIBS" | |
1601 | AC_CHECK_HEADERS([ft2build.h], [], | |
1602 | [grub_build_mkfont_excuse=["need freetype2 headers"]]) | |
1603 | AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], | |
1604 | [grub_build_mkfont_excuse=["freetype2 library unusable"]]) | |
1605 | LIBS="$SAVED_LIBS" | |
1606 | CPPFLAGS="$SAVED_CPPFLAGS_2" | |
1607 | ], [grub_build_mkfont_excuse=["need freetype2 library"]]) | |
1608 | PKG_CONFIG="$SAVED_PKG_CONFIG" | |
7c9d0c39 VS |
1609 | fi |
1610 | ||
1611 | if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then | |
d642d761 | 1612 | AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)]) |
7c9d0c39 VS |
1613 | fi |
1614 | if test x"$grub_build_mkfont_excuse" = x ; then | |
1615 | enable_build_grub_mkfont=yes | |
1616 | else | |
1617 | enable_build_grub_mkfont=no | |
c5884973 | 1618 | fi |
0af7539b | 1619 | if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then |
d642d761 | 1620 | if test x"$grub_build_mkfont_excuse" = x ; then |
0af7539b | 1621 | AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont]) |
d642d761 | 1622 | else |
0af7539b | 1623 | AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)]) |
d642d761 | 1624 | fi |
7c9d0c39 VS |
1625 | fi |
1626 | ||
7c9d0c39 | 1627 | CC="$SAVED_CC" |
b224c266 | 1628 | CPP="$SAVED_CPP" |
7c9d0c39 VS |
1629 | CFLAGS="$SAVED_CFLAGS" |
1630 | CPPFLAGS="$SAVED_CPPFLAGS" | |
dcecae1a | 1631 | LDFLAGS="$SAVED_LDFLAGS" |
7c9d0c39 VS |
1632 | |
1633 | ||
1634 | DJVU_FONT_SOURCE= | |
1635 | ||
1636 | starfield_excuse= | |
c5884973 | 1637 | |
300f48c5 VS |
1638 | AC_ARG_ENABLE([grub-themes], |
1639 | [AS_HELP_STRING([--enable-grub-themes], | |
1640 | [build and install GRUB themes (default=guessed)])]) | |
1641 | if test x"$enable_grub_themes" = xno ; then | |
1642 | starfield_excuse="explicitly disabled" | |
1643 | fi | |
1644 | ||
1645 | if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then | |
7b966834 VS |
1646 | starfield_excuse="No build-time grub-mkfont" |
1647 | fi | |
1648 | ||
501b9e4b | 1649 | if test x"$starfield_excuse" = x; then |
c5884973 | 1650 | for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do |
36387ece | 1651 | for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do |
c5884973 DO |
1652 | if test -f "$dir/DejaVuSans.$ext"; then |
1653 | DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext" | |
1654 | break 2 | |
1655 | fi | |
1656 | done | |
1657 | done | |
1658 | ||
1659 | if test "x$DJVU_FONT_SOURCE" = x; then | |
1660 | starfield_excuse="No DejaVu found" | |
1661 | fi | |
1662 | fi | |
1663 | ||
300f48c5 | 1664 | if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then |
d642d761 | 1665 | AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)]) |
300f48c5 VS |
1666 | fi |
1667 | ||
c5884973 DO |
1668 | AC_SUBST([DJVU_FONT_SOURCE]) |
1669 | ||
7c9d0c39 VS |
1670 | FONT_SOURCE= |
1671 | ||
1672 | for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do | |
1673 | for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do | |
1674 | if test -f "$dir/unifont.$ext"; then | |
0277eab7 VS |
1675 | md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')" |
1676 | # PCF and BDF from version 6.3 isn't hanled properly by libfreetype. | |
1677 | if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then | |
4d94b2db | 1678 | continue |
0277eab7 | 1679 | fi |
7c9d0c39 VS |
1680 | FONT_SOURCE="$dir/unifont.$ext" |
1681 | break 2 | |
1682 | fi | |
1683 | done | |
1684 | done | |
1685 | ||
7b966834 VS |
1686 | if test x"$enable_build_grub_mkfont" = xno ; then |
1687 | FONT_SOURCE= | |
1688 | fi | |
1689 | ||
0af7539b | 1690 | if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then |
d642d761 | 1691 | if test x"$grub_build_mkfont_excuse" = x ; then |
0af7539b | 1692 | AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont]) |
d642d761 | 1693 | else |
0af7539b | 1694 | AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)]) |
d642d761 | 1695 | fi |
7c9d0c39 VS |
1696 | fi |
1697 | ||
1698 | AC_SUBST([FONT_SOURCE]) | |
1699 | ||
7b780018 | 1700 | if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then |
7c9d0c39 VS |
1701 | grub_build_mkfont_excuse="no fonts" |
1702 | fi | |
1703 | ||
1704 | ||
897e6207 CW |
1705 | AC_ARG_ENABLE([grub-mount], |
1706 | [AS_HELP_STRING([--enable-grub-mount], | |
1707 | [build and install the `grub-mount' utility (default=guessed)])]) | |
1708 | if test x"$enable_grub_mount" = xno ; then | |
1709 | grub_mount_excuse="explicitly disabled" | |
92bb0786 VS |
1710 | fi |
1711 | ||
897e6207 | 1712 | if test x"$grub_mount_excuse" = x ; then |
92bb0786 | 1713 | AC_CHECK_LIB([fuse], [fuse_main_real], [], |
897e6207 | 1714 | [grub_mount_excuse="need FUSE library"]) |
92bb0786 VS |
1715 | fi |
1716 | ||
897e6207 | 1717 | if test x"$grub_mount_excuse" = x ; then |
92bb0786 VS |
1718 | # Check for fuse headers. |
1719 | SAVED_CPPFLAGS="$CPPFLAGS" | |
fc7a64bc | 1720 | CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26" |
92bb0786 | 1721 | AC_CHECK_HEADERS([fuse/fuse.h], [], |
897e6207 | 1722 | [grub_mount_excuse=["need FUSE headers"]]) |
92bb0786 VS |
1723 | CPPFLAGS="$SAVED_CPPFLAGS" |
1724 | fi | |
1725 | ||
897e6207 | 1726 | if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then |
d642d761 | 1727 | AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)]) |
92bb0786 | 1728 | fi |
897e6207 CW |
1729 | if test x"$grub_mount_excuse" = x ; then |
1730 | enable_grub_mount=yes | |
92bb0786 | 1731 | else |
897e6207 | 1732 | enable_grub_mount=no |
92bb0786 | 1733 | fi |
897e6207 | 1734 | AC_SUBST([enable_grub_mount]) |
92bb0786 | 1735 | |
7181e228 CW |
1736 | AC_ARG_ENABLE([device-mapper], |
1737 | [AS_HELP_STRING([--enable-device-mapper], | |
1738 | [enable Linux device-mapper support (default=guessed)])]) | |
1739 | if test x"$enable_device_mapper" = xno ; then | |
1740 | device_mapper_excuse="explicitly disabled" | |
1741 | fi | |
1742 | ||
53798c4b GS |
1743 | if test x"$device_mapper_excuse" = x ; then |
1744 | # Check for device-mapper header. | |
1745 | AC_CHECK_HEADER([libdevmapper.h], [], | |
1746 | [device_mapper_excuse="need libdevmapper header"]) | |
1747 | fi | |
1748 | ||
7181e228 CW |
1749 | if test x"$device_mapper_excuse" = x ; then |
1750 | # Check for device-mapper library. | |
61d720e5 | 1751 | AC_CHECK_LIB([devmapper], [dm_task_create], [], |
7181e228 | 1752 | [device_mapper_excuse="need devmapper library"]) |
7181e228 | 1753 | fi |
61d720e5 VS |
1754 | |
1755 | if test x"$device_mapper_excuse" = x ; then | |
1756 | # Check for device-mapper library. | |
1757 | AC_CHECK_LIB([devmapper], [dm_log_with_errno_init], | |
1758 | [], | |
1759 | [device_mapper_excuse="need devmapper library"]) | |
1760 | fi | |
1761 | ||
1762 | if test x"$device_mapper_excuse" = x ; then | |
4d94b2db | 1763 | LIBDEVMAPPER="-ldevmapper" |
61d720e5 VS |
1764 | AC_DEFINE([HAVE_DEVICE_MAPPER], [1], |
1765 | [Define to 1 if you have the devmapper library.]) | |
1766 | fi | |
1767 | ||
62f7d208 | 1768 | AC_SUBST([LIBDEVMAPPER]) |
76ed06b9 | 1769 | |
f4727da9 VS |
1770 | LIBGEOM= |
1771 | if test x$host_kernel = xkfreebsd; then | |
1772 | AC_CHECK_LIB([geom], [geom_gettree], [], | |
1773 | [AC_MSG_ERROR([Your platform requires libgeom])]) | |
1774 | LIBGEOM="-lgeom" | |
1775 | fi | |
1776 | ||
1777 | AC_SUBST([LIBGEOM]) | |
1778 | ||
0d2d30bb VS |
1779 | AC_ARG_ENABLE([liblzma], |
1780 | [AS_HELP_STRING([--enable-liblzma], | |
1781 | [enable liblzma integration (default=guessed)])]) | |
1782 | if test x"$enable_liblzma" = xno ; then | |
1783 | liblzma_excuse="explicitly disabled" | |
1784 | fi | |
1785 | ||
1786 | if test x"$liblzma_excuse" = x ; then | |
2c44e493 | 1787 | AC_CHECK_LIB([lzma], [lzma_code], |
0d2d30bb VS |
1788 | [],[liblzma_excuse="need lzma library"]) |
1789 | fi | |
1790 | if test x"$liblzma_excuse" = x ; then | |
1791 | AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"]) | |
1792 | fi | |
1793 | ||
1794 | if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then | |
d642d761 | 1795 | AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)]) |
0d2d30bb VS |
1796 | fi |
1797 | ||
1798 | ||
1799 | if test x"$liblzma_excuse" = x ; then | |
1800 | LIBLZMA="-llzma" | |
1801 | AC_DEFINE([USE_LIBLZMA], [1], | |
1802 | [Define to 1 if you have the LZMA library.]) | |
1803 | fi | |
1804 | ||
2c44e493 VS |
1805 | AC_SUBST([LIBLZMA]) |
1806 | ||
e4c498a1 MG |
1807 | AC_ARG_ENABLE([libzfs], |
1808 | [AS_HELP_STRING([--enable-libzfs], | |
1809 | [enable libzfs integration (default=guessed)])]) | |
1810 | if test x"$enable_libzfs" = xno ; then | |
1811 | libzfs_excuse="explicitly disabled" | |
1812 | fi | |
16c7cb32 | 1813 | |
e4c498a1 MG |
1814 | if test x"$libzfs_excuse" = x ; then |
1815 | # Only check for system headers if libzfs support has not been disabled. | |
1816 | AC_CHECK_HEADERS(libzfs.h libnvpair.h) | |
1817 | fi | |
1818 | ||
1819 | if test x"$libzfs_excuse" = x ; then | |
1820 | AC_CHECK_LIB([zfs], [libzfs_init], | |
1821 | [], | |
1822 | [libzfs_excuse="need zfs library"]) | |
1823 | fi | |
1824 | ||
1825 | if test x"$libzfs_excuse" = x ; then | |
27f9d02e | 1826 | AC_CHECK_LIB([nvpair], [nvlist_lookup_string], |
e4c498a1 MG |
1827 | [], |
1828 | [libzfs_excuse="need nvpair library"]) | |
1829 | fi | |
1830 | ||
1831 | if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then | |
d642d761 | 1832 | AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)]) |
e4c498a1 MG |
1833 | fi |
1834 | ||
1835 | if test x"$libzfs_excuse" = x ; then | |
1836 | # We need both libzfs and libnvpair for a successful build. | |
1837 | LIBZFS="-lzfs" | |
1838 | AC_DEFINE([HAVE_LIBZFS], [1], | |
1839 | [Define to 1 if you have the ZFS library.]) | |
1840 | LIBNVPAIR="-lnvpair" | |
1841 | AC_DEFINE([HAVE_LIBNVPAIR], [1], | |
1842 | [Define to 1 if you have the NVPAIR library.]) | |
1843 | fi | |
1844 | ||
1845 | AC_SUBST([LIBZFS]) | |
16c7cb32 BC |
1846 | AC_SUBST([LIBNVPAIR]) |
1847 | ||
9f915872 VS |
1848 | LIBS="" |
1849 | ||
76ed06b9 | 1850 | AC_SUBST([FONT_SOURCE]) |
76ed06b9 BC |
1851 | AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu], |
1852 | [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)]) | |
7181e228 | 1853 | |
742f9232 | 1854 | AC_SUBST(HAVE_ASM_USCORE) |
742f9232 VS |
1855 | AC_SUBST(BSS_START_SYMBOL) |
1856 | AC_SUBST(END_SYMBOL) | |
1857 | AC_SUBST(PACKAGE) | |
1858 | AC_SUBST(VERSION) | |
742f9232 | 1859 | |
d5524ca8 VS |
1860 | AC_ARG_ENABLE([werror], |
1861 | [AS_HELP_STRING([--disable-werror], | |
1862 | [do not use -Werror when building GRUB])]) | |
1863 | if test x"$enable_werror" != xno ; then | |
1864 | TARGET_CFLAGS="$TARGET_CFLAGS -Werror" | |
1865 | HOST_CFLAGS="$HOST_CFLAGS -Werror" | |
1866 | fi | |
1867 | ||
d5524ca8 VS |
1868 | TARGET_CPP="$TARGET_CC -E" |
1869 | TARGET_CCAS=$TARGET_CC | |
1870 | ||
b46bf3cd VS |
1871 | # Includes which include make-time substitutions. They must come last |
1872 | # as to avoid executing top_builddir in shell. | |
1873 | HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" | |
1874 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" | |
1875 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" | |
1876 | ||
d5524ca8 VS |
1877 | GRUB_TARGET_CPU="${target_cpu}" |
1878 | GRUB_PLATFORM="${platform}" | |
1879 | ||
1880 | AC_SUBST(GRUB_TARGET_CPU) | |
1881 | AC_SUBST(GRUB_PLATFORM) | |
1882 | ||
1883 | AC_SUBST(TARGET_OBJCONV) | |
d5524ca8 VS |
1884 | AC_SUBST(TARGET_CPP) |
1885 | AC_SUBST(TARGET_CCAS) | |
1886 | AC_SUBST(TARGET_OBJ2ELF) | |
d5524ca8 | 1887 | AC_SUBST(TARGET_MODULE_FORMAT) |
6a7957f9 | 1888 | AC_SUBST(TARGET_CC_VERSION) |
d5524ca8 VS |
1889 | |
1890 | AC_SUBST(TARGET_CFLAGS) | |
1891 | AC_SUBST(TARGET_LDFLAGS) | |
1892 | AC_SUBST(TARGET_CPPFLAGS) | |
1893 | AC_SUBST(TARGET_CCASFLAGS) | |
1894 | ||
d5524ca8 VS |
1895 | AC_SUBST(TARGET_IMG_LDFLAGS) |
1896 | AC_SUBST(TARGET_IMG_CFLAGS) | |
1897 | AC_SUBST(TARGET_IMG_BASE_LDOPT) | |
a9f25a08 | 1898 | AC_SUBST(TARGET_APPLE_LINKER) |
d5524ca8 VS |
1899 | |
1900 | AC_SUBST(HOST_CFLAGS) | |
1901 | AC_SUBST(HOST_LDFLAGS) | |
1902 | AC_SUBST(HOST_CPPFLAGS) | |
1903 | AC_SUBST(HOST_CCASFLAGS) | |
1904 | ||
1905 | AC_SUBST(BUILD_LIBM) | |
1906 | ||
76ed06b9 BC |
1907 | # |
1908 | # Automake conditionals | |
1909 | # | |
8c411768 | 1910 | |
5d90f6e5 | 1911 | AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone]) |
76ed06b9 BC |
1912 | AM_CONDITIONAL([COND_emu], [test x$platform = xemu]) |
1913 | AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc]) | |
1914 | AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi]) | |
6585de4c | 1915 | AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi]) |
76ed06b9 BC |
1916 | AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu]) |
1917 | AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275]) | |
1918 | AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot]) | |
1919 | AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot]) | |
1920 | AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi]) | |
9612ebc0 | 1921 | AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen]) |
d789e70e | 1922 | AM_CONDITIONAL([COND_i386_xen_pvh], [test x$target_cpu = xi386 -a x$platform = xxen_pvh]) |
9612ebc0 | 1923 | AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen]) |
4959e111 VS |
1924 | AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson]) |
1925 | AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips]) | |
7f63a64f | 1926 | AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc]) |
76ed06b9 | 1927 | AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) |
eaf01c25 | 1928 | AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu]) |
76ed06b9 | 1929 | AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) |
4959e111 | 1930 | AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel]) |
37ba07eb VS |
1931 | AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel]) |
1932 | AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips]) | |
389b31cd LL |
1933 | AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ]) |
1934 | AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot]) | |
24e37a88 | 1935 | AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot]) |
389b31cd | 1936 | AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi]) |
15a463d7 LL |
1937 | AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) |
1938 | AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) | |
f1957dc8 AG |
1939 | AM_CONDITIONAL([COND_riscv32], [test x$target_cpu = xriscv32 ]) |
1940 | AM_CONDITIONAL([COND_riscv64], [test x$target_cpu = xriscv64 ]) | |
1941 | AM_CONDITIONAL([COND_riscv32_efi], [test x$target_cpu = xriscv32 -a x$platform = xefi]) | |
1942 | AM_CONDITIONAL([COND_riscv64_efi], [test x$target_cpu = xriscv64 -a x$platform = xefi]) | |
f7711f5e | 1943 | |
faf4a65e VS |
1944 | AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd]) |
1945 | AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux]) | |
1946 | AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd]) | |
f7711f5e | 1947 | AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows]) |
faf4a65e VS |
1948 | AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd]) |
1949 | AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu]) | |
1950 | AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos]) | |
2d465fb0 | 1951 | |
76ed06b9 | 1952 | AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x]) |
76ed06b9 BC |
1953 | AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes]) |
1954 | AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes]) | |
1955 | AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes]) | |
897e6207 | 1956 | AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes]) |
76ed06b9 | 1957 | AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x]) |
6f07c4e4 VS |
1958 | if test x$FONT_SOURCE != x ; then |
1959 | HAVE_FONT_SOURCE=1 | |
1960 | else | |
1961 | HAVE_FONT_SOURCE=0 | |
1962 | fi | |
1963 | AC_SUBST(HAVE_FONT_SOURCE) | |
a9f25a08 | 1964 | AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1]) |
76ed06b9 | 1965 | AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes]) |
c5dc1690 | 1966 | AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1]) |
e744219b | 1967 | AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1]) |
fc45fb58 | 1968 | |
1eed0e6e VS |
1969 | AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes]) |
1970 | ||
742f9232 | 1971 | AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1]) |
c5884973 | 1972 | AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x]) |
cd46aa6c VS |
1973 | AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy]) |
1974 | ||
1975 | test "x$prefix" = xNONE && prefix="$ac_default_prefix" | |
1976 | test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" | |
1977 | datarootdir="$(eval echo "$datarootdir")" | |
1978 | grub_libdir="$(eval echo "$libdir")" | |
1979 | grub_localedir="$(eval echo "$localedir")" | |
1980 | grub_datadir="$(eval echo "$datadir")" | |
1981 | grub_sysconfdir="$(eval echo "$sysconfdir")" | |
1982 | AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir]) | |
1983 | AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir]) | |
1984 | AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir]) | |
1985 | AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir]) | |
1986 | ||
742f9232 | 1987 | |
6a161fa9 | 1988 | # Output files. |
5d90f6e5 CW |
1989 | if test "$platform" != none; then |
1990 | cpudir="${target_cpu}" | |
1991 | if test x${cpudir} = xmipsel; then | |
1992 | cpudir=mips; | |
f84b481b | 1993 | fi |
5d90f6e5 CW |
1994 | grub_CHECK_LINK_DIR |
1995 | if test x"$link_dir" = xyes ; then | |
1996 | AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir]) | |
1997 | if test "$platform" != emu ; then | |
1998 | AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform]) | |
1999 | fi | |
2000 | else | |
2001 | mkdir -p include/grub 2>/dev/null | |
2002 | rm -rf include/grub/cpu | |
2003 | cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null | |
2004 | if test "$platform" != emu ; then | |
2005 | rm -rf include/grub/machine | |
2006 | cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null | |
2007 | fi | |
f84b481b | 2008 | fi |
5d90f6e5 CW |
2009 | else |
2010 | # Just enough to stop the compiler failing with -I$(srcdir)/include. | |
2011 | mkdir -p include 2>/dev/null | |
77063f4c | 2012 | rm -rf include/grub/cpu include/grub/machine |
1f4147aa | 2013 | fi |
6304d292 | 2014 | |
8c411768 | 2015 | AC_CONFIG_FILES([Makefile]) |
6304d292 | 2016 | AC_CONFIG_FILES([grub-core/Makefile]) |
15c69261 | 2017 | AC_CONFIG_FILES([grub-core/gnulib/Makefile]) |
269004c1 | 2018 | AC_CONFIG_FILES([po/Makefile.in]) |
8c411768 | 2019 | AC_CONFIG_FILES([docs/Makefile]) |
b23ffd70 | 2020 | AC_CONFIG_FILES([util/bash-completion.d/Makefile]) |
6a161fa9 | 2021 | AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) |
742f9232 | 2022 | AC_CONFIG_FILES([config.h]) |
8c411768 | 2023 | |
6a161fa9 | 2024 | AC_OUTPUT |
5ce5507f | 2025 | [ |
2026 | echo "*******************************************************" | |
2027 | echo GRUB2 will be compiled with following components: | |
2028 | echo Platform: "$target_cpu"-"$platform" | |
f84b481b | 2029 | if [ x"$platform" = xemu ]; then |
927d0134 VS |
2030 | if [ x"$grub_emu_sdl_excuse" = x ]; then |
2031 | echo SDL support for grub-emu: Yes | |
2032 | else | |
2033 | echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)" | |
2034 | fi | |
325c8258 | 2035 | if [ x"$grub_emu_pci_excuse" = x ]; then |
2036 | echo PCI support for grub-emu: Yes | |
2037 | else | |
2038 | echo PCI support for grub-emu: No "($grub_emu_pci_excuse)" | |
2039 | fi | |
f84b481b | 2040 | fi |
61d720e5 VS |
2041 | if test x"$device_mapper_excuse" = x ; then |
2042 | echo With devmapper support: Yes | |
2043 | else | |
2044 | echo With devmapper support: No "($device_mapper_excuse)" | |
2045 | fi | |
5ce5507f | 2046 | if [ x"$enable_mm_debug" = xyes ]; then |
2047 | echo With memory debugging: Yes | |
2048 | else | |
2049 | echo With memory debugging: No | |
2050 | fi | |
c5dc1690 SJ |
2051 | if [ x"$enable_cache_stats" = xyes ]; then |
2052 | echo With disk cache statistics: Yes | |
2053 | else | |
2054 | echo With disk cache statistics: No | |
2055 | fi | |
e744219b VS |
2056 | |
2057 | if [ x"$enable_boot_time" = xyes ]; then | |
2058 | echo With boot time statistics: Yes | |
2059 | else | |
2060 | echo With boot time statistics: No | |
2061 | fi | |
2062 | ||
5ce5507f | 2063 | if [ x"$efiemu_excuse" = x ]; then |
2064 | echo efiemu runtime: Yes | |
2065 | else | |
2066 | echo efiemu runtime: No "($efiemu_excuse)" | |
2067 | fi | |
5ce5507f | 2068 | if [ x"$grub_mkfont_excuse" = x ]; then |
2069 | echo grub-mkfont: Yes | |
2070 | else | |
2071 | echo grub-mkfont: No "($grub_mkfont_excuse)" | |
2072 | fi | |
897e6207 | 2073 | if [ x"$grub_mount_excuse" = x ]; then |
89644ef1 | 2074 | echo grub-mount: Yes |
92bb0786 | 2075 | else |
897e6207 | 2076 | echo grub-mount: No "($grub_mount_excuse)" |
92bb0786 | 2077 | fi |
c5884973 DO |
2078 | if [ x"$starfield_excuse" = x ]; then |
2079 | echo starfield theme: Yes | |
443b3222 | 2080 | echo With DejaVuSans font from $DJVU_FONT_SOURCE |
c5884973 DO |
2081 | else |
2082 | echo starfield theme: No "($starfield_excuse)" | |
2083 | fi | |
e4c498a1 MG |
2084 | if [ x"$libzfs_excuse" = x ]; then |
2085 | echo With libzfs support: Yes | |
2086 | else | |
2087 | echo With libzfs support: No "($libzfs_excuse)" | |
2088 | fi | |
7b780018 | 2089 | if [ x"$grub_build_mkfont_excuse" = x ]; then |
7c9d0c39 VS |
2090 | echo Build-time grub-mkfont: Yes |
2091 | if test "x$FONT_SOURCE" = x ; then | |
2092 | echo "Without unifont" | |
2093 | else | |
2094 | echo "With unifont from $FONT_SOURCE" | |
2095 | fi | |
4b80e43c | 2096 | else |
7b780018 | 2097 | echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)" |
7c9d0c39 | 2098 | echo "Without unifont (no build-time grub-mkfont)" |
4b80e43c | 2099 | fi |
0d2d30bb VS |
2100 | if test x"$liblzma_excuse" != x ; then |
2101 | echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)" | |
64fce2d8 VS |
2102 | else |
2103 | echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)" | |
2104 | fi | |
5ce5507f | 2105 | echo "*******************************************************" |
2106 | ] |