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