3 # Process this file with autoconf to produce a configure script.
5 # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
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.
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
16 dnl This configure script is complicated, because GRUB needs to deal
17 dnl with three potentially different types:
19 dnl build -- the environment for building GRUB
20 dnl host -- the environment for running utilities
21 dnl target -- the environment for running GRUB
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.
28 dnl The current strategy is to use variables with no prefix (such as
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.
34 AC_INIT([GRUB],[2.03],[bug-grub@gnu.org])
36 AC_CONFIG_AUX_DIR([build-aux])
38 # We don't want -g -O2 by default in CFLAGS
41 # Checks for build, host and target systems.
44 save_program_prefix="${program_prefix}"
46 program_prefix="${save_program_prefix}"
48 AM_INIT_AUTOMAKE([1.10.1])
50 AC_CONFIG_SRCDIR([include/grub/dl.h])
51 AC_CONFIG_HEADER([config-util.h])
53 # Program name transformations
55 grub_TRANSFORM([grub-bios-setup])
56 grub_TRANSFORM([grub-editenv])
57 grub_TRANSFORM([grub-install])
58 grub_TRANSFORM([grub-mkconfig])
59 grub_TRANSFORM([grub-mkfont])
60 grub_TRANSFORM([grub-mkimage])
61 grub_TRANSFORM([grub-glue-efi])
62 grub_TRANSFORM([grub-mklayout])
63 grub_TRANSFORM([grub-mkpasswd-pbkdf2])
64 grub_TRANSFORM([grub-mkrelpath])
65 grub_TRANSFORM([grub-mkrescue])
66 grub_TRANSFORM([grub-probe])
67 grub_TRANSFORM([grub-reboot])
68 grub_TRANSFORM([grub-script-check])
69 grub_TRANSFORM([grub-set-default])
70 grub_TRANSFORM([grub-sparc64-setup])
71 grub_TRANSFORM([grub-render-label])
72 grub_TRANSFORM([grub-file])
74 # Optimization flag. Allow user to override.
75 if test "x$TARGET_CFLAGS" = x; then
76 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
79 # Default HOST_CPPFLAGS
80 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
81 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
83 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
86 i[[3456]]86) target_cpu=i386 ;;
87 amd64) target_cpu=x86_64 ;;
88 sparc) target_cpu=sparc64 ;;
91 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
95 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
105 # Specify the platform (such as firmware).
106 AC_ARG_WITH([platform],
107 AS_HELP_STRING([--with-platform=PLATFORM],
108 [select the host platform [[guessed]]]))
110 # Guess the platform if not specified.
111 if test "x$with_platform" = x; then
112 case "$target_cpu"-"$target_vendor" in
113 i386-apple) platform=efi ;;
114 i386-*) platform=pc ;;
115 x86_64-apple) platform=efi ;;
116 x86_64-*) platform=pc ;;
117 powerpc-*) platform=ieee1275 ;;
118 powerpc64-*) platform=ieee1275 ;;
119 powerpc64le-*) platform=ieee1275 ;;
120 sparc64-*) platform=ieee1275 ;;
121 mipsel-*) platform=loongson ;;
122 mips-*) platform=arc ;;
123 ia64-*) platform=efi ;;
124 arm-*) platform=uboot ;;
125 arm64-*) platform=efi ;;
127 AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
132 platform="$with_platform"
135 case "$target_cpu"-"$platform" in
140 x86_64-*) target_cpu=i386 ;;
141 powerpc64-ieee1275) target_cpu=powerpc ;;
142 powerpc64le-ieee1275) target_cpu=powerpc ;;
145 # Check if the platform is supported, make final adjustments.
146 case "$target_cpu"-"$platform" in
154 i386-linuxbios) platform=coreboot ;;
161 mips-qemu-mips) platform=qemu_mips;;
165 mipsel-qemu-mips) platform=qemu_mips;;
166 mipsel-yeeloong) platform=loongson ;;
167 mipsel-fuloong) platform=loongson ;;
174 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
177 if test x$platform != xemu ; then
178 case "$target_cpu" in
179 i386 | powerpc) target_m32=1 ;;
180 x86_64 | sparc64) target_m64=1 ;;
184 if test x"$target_cpu-$platform" = xsparc64-emu ; then
189 windows* | mingw32*) target_os=cygwin ;;
192 # This normalizes the names, and creates a new variable ("host_kernel")
193 # while at it, since the mapping is not always 1:1 (e.g. different OSes
194 # using the same kernel type).
196 gnu*) host_kernel=hurd ;;
197 linux*) host_kernel=linux ;;
198 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
199 netbsd*) host_kernel=netbsd ;;
200 solaris*) host_kernel=illumos ;;
201 darwin*) host_kernel=xnu ;;
202 cygwin | windows* | mingw32*) host_kernel=windows ;;
206 cygwin | windows* | mingw32*) have_exec=n ;;
207 aros*) have_exec=n ;;
212 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
213 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
214 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
215 xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
216 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
217 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
218 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
219 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
220 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
221 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
222 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
223 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
225 if test x${target_cpu} = xmipsel ; then
226 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
228 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
231 case "${target_cpu}-$platform" in
233 TARGET_LINK_ADDR=0x88200000
234 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
237 TARGET_LINK_ADDR=0x80700000
238 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
240 mips*-qemu_mips | mips*-loongson)
241 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
245 AC_SUBST(TARGET_LINK_ADDR)
246 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
248 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
252 AC_SUBST(host_kernel)
257 # Define default variables
260 AC_ARG_WITH([bootdir],
261 AS_HELP_STRING([--with-bootdir=DIR],
262 [set the name of /boot directory [[guessed]]]),
263 [have_with_bootdir=y],
264 [have_with_bootdir=n])
265 if test x$have_with_bootdir = xy; then
266 bootdirname="$with_bootdir"
270 # Because /boot is used for the boot block in NetBSD and OpenBSD,
272 *) bootdirname='boot' ;;
276 AC_SUBST(bootdirname)
277 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
278 [Default boot directory name]")
280 AC_ARG_WITH([grubdir],
281 AS_HELP_STRING([--with-grubdir=DIR],
282 [set the name of grub directory [[guessed]]]),
283 [grubdirname="$with_grubdir"],
284 [grubdirname="$PACKAGE"])
286 AC_SUBST(grubdirname)
287 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
288 [Default grub directory name])
291 # Checks for build programs.
294 # Although cmp is listed in the GNU Coding Standards as a command which
295 # can used directly, OpenBSD lacks cmp in the default installation.
296 AC_CHECK_PROGS([CMP], [cmp])
297 if test "x$CMP" = x; then
298 AC_MSG_ERROR([cmp is not found])
301 AC_CHECK_PROGS([YACC], [bison])
302 if test "x$YACC" = x; then
303 AC_MSG_ERROR([bison is not found])
315 if test "x$LEX" = "x:"; then
316 AC_MSG_ERROR([flex is not found])
318 version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
319 if test -n "$version" -a "$version" -ge 20535; then
322 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
326 # These are not a "must".
327 AC_PATH_PROGS(MAKEINFO, makeinfo true)
330 # Checks for host programs.
340 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
342 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
345 AM_GNU_GETTEXT([external])
348 # Identify characteristics of the host architecture.
349 unset ac_cv_c_bigendian
351 if test x"$target_cpu-$platform" = xsparc64-emu ; then
352 CFLAGS="$CFLAGS -m64"
353 HOST_CFLAGS="$HOST_CFLAGS -m64"
356 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
357 HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
360 AC_CHECK_SIZEOF(void *)
361 AC_CHECK_SIZEOF(long)
364 cygwin | windows* | mingw32*)
365 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
366 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
367 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
372 cygwin | windows* | mingw32* | aros*)
375 AC_CHECK_SIZEOF(off_t)
376 if test x"$ac_cv_sizeof_off_t" != x8 ; then
377 AC_CHECK_SIZEOF(off64_t)
378 test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required])
382 if test x$USE_NLS = xno; then
383 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
386 if test "x$cross_compiling" = xyes; then
387 AC_MSG_WARN([cannot generate manual pages while cross compiling])
389 AC_PATH_PROG(HELP2MAN, help2man)
392 # Check for functions and headers.
393 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
394 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
396 # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
397 # warning which causes compilation failure later with -Werror. So use -Werror here
398 # as well to force proper sys/sysmacros.h detection.
399 SAVED_CFLAGS="$CFLAGS"
400 CFLAGS="$HOST_CFLAGS -Werror"
402 CFLAGS="$SAVED_CFLAGS"
404 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
405 #include <sys/param.h>
406 #include <sys/mount.h>])
408 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
409 #include <sys/param.h>
410 #include <sys/mount.h>])
412 # For opendisk() and getrawpartition() on NetBSD.
413 # Used in util/deviceiter.c and in util/hostdisk.c.
414 AC_CHECK_HEADER([util.h], [
415 AC_CHECK_LIB([util], [opendisk], [
417 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
419 AC_CHECK_LIB([util], [getrawpartition], [
421 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
426 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
427 SAVED_CFLAGS="$CFLAGS"
428 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
429 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
430 int va_arg_func (int fixed, va_list args);]], [[]])],
431 [grub_cv_host_cc_wtrampolines=yes],
432 [grub_cv_host_cc_wtrampolines=no])
433 CFLAGS="$SAVED_CFLAGS"
436 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
437 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
441 # Check for host and build compilers.
444 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
445 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
446 BUILD_CPP="$BUILD_CC -E"
449 haiku*) BUILD_LIBM= ;;
453 dnl FIXME proper test seems to require too deep dive into Autoconf internals.
454 dnl For now just list known platforms that we support.
457 cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
460 AC_SUBST(BUILD_EXEEXT)
465 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"
466 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"
468 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
470 AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
471 SAVED_CFLAGS="$CFLAGS"
472 grub_cv_cc_w_extra_flags=
473 for x in $EXTRA_WARN_FLAGS; do
474 CFLAGS="$HOST_CFLAGS $x -Werror"
475 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
476 if test x$flag = x1 ; then
477 grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
480 CFLAGS="$SAVED_CFLAGS"
483 HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
486 # Check for target programs.
489 # Find tools for the target.
490 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
491 tmp_ac_tool_prefix="$ac_tool_prefix"
492 ac_tool_prefix=$target_alias-
494 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
495 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
496 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
497 AC_CHECK_TOOL(TARGET_STRIP, strip)
498 AC_CHECK_TOOL(TARGET_NM, nm)
499 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
501 ac_tool_prefix="$tmp_ac_tool_prefix"
503 if test "x$TARGET_CC" = x; then
506 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
507 AC_CHECK_TOOL(TARGET_STRIP, strip)
508 AC_CHECK_TOOL(TARGET_NM, nm)
509 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
514 AC_SUBST(BUILD_CFLAGS)
515 AC_SUBST(BUILD_CPPFLAGS)
516 AC_SUBST(BUILD_LDFLAGS)
519 AC_SUBST(TARGET_RANLIB)
520 AC_SUBST(TARGET_STRIP)
521 AC_SUBST(TARGET_OBJCOPY)
523 # Test the C compiler for the target environment.
526 tmp_LDFLAGS="$LDFLAGS"
527 tmp_CPPFLAGS="$CPPFLAGS"
530 CFLAGS="$TARGET_CFLAGS"
531 CPPFLAGS="$TARGET_CPPFLAGS"
532 LDFLAGS="$TARGET_LDFLAGS"
536 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
537 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
539 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
540 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
543 TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
545 AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
546 LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
548 grub_cv_target_cc_w_extra_flags=
549 for x in $EXTRA_WARN_FLAGS; do
550 CFLAGS="$TARGET_CFLAGS $x -Werror"
551 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
552 asm (".globl start; start:");
554 void __main (void) {}
556 ]], [[]])], [flag=1], [flag=0])
557 if test x$flag = x1 ; then
558 grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
563 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
565 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
567 CFLAGS="$TARGET_CFLAGS"
569 [AC_LANG_PROGRAM([], [[
574 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
576 if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
577 AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
578 grub_cv_target_cc_big_endian=no
579 for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
580 "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
581 "-EB" "-mbig-endian"; do
582 if test x"$grub_cv_target_cc_big_endian" != xno ; then
585 CFLAGS="$TARGET_CFLAGS $cand -Werror"
586 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
587 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
588 #error still little endian
590 asm (".globl start; start:");
591 asm (".globl _start; _start:");
592 asm (".globl __start; __start:");
594 void __main (void) {}
597 [grub_cv_target_cc_big_endian="$cand"], [])
601 if test x"$grub_cv_target_cc_big_endian" = xno ; then
602 AC_MSG_ERROR([could not force big-endian])
605 skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
607 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
608 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
609 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
610 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
611 elif test x$target_cpu = xmipsel; then
612 AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
613 grub_cv_target_cc_little_endian=no
614 for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
615 "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
617 if test x"$grub_cv_target_cc_little_endian" != xno ; then
620 CFLAGS="$TARGET_CFLAGS $cand -Werror"
621 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
622 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
623 #error still big endian
625 asm (".globl start; start:");
626 asm (".globl _start; _start:");
627 asm (".globl __start; __start:");
629 void __main (void) {}
632 [grub_cv_target_cc_little_endian="$cand"], [])
636 if test x"$grub_cv_target_cc_little_endian" = xno ; then
637 AC_MSG_ERROR([could not force little-endian])
640 skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
642 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
643 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
644 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
645 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
648 # GRUB code is N32-compliant but it's experimental and we would prefer to
649 # avoid having too much variety when it doesn't result in any real improvement.
650 # Moreover N64 isn't supported.
651 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
652 AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
653 grub_cv_target_cc_mips_o32_abi=no
654 for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
655 if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
658 CFLAGS="$TARGET_CFLAGS $arg -Werror"
659 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
660 #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
663 asm (".globl start; start:");
664 asm (".globl _start; _start:");
665 asm (".globl __start; __start:");
667 void __main (void) {}
670 [grub_cv_target_cc_mips_o32_abi="$arg"], [])
674 if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
675 AC_MSG_ERROR([could not force MIPS o32 ABI])
678 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
679 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
682 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
684 case "x$target_cpu-$platform" in
694 xpowerpc-* | xsparc64-* | xarm-*)
695 test_program=$target_cpu
698 if test x"$test_program" = x ; then
699 grub_cv_cc_target_asm_compile=
702 for arg in "" "-no-integrated-as"; do
703 cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
704 echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
705 if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
706 grub_cv_cc_target_asm_compile="$arg"
711 if test x"$found" = xno ; then
712 AC_MSG_ERROR([could not compile assembly])
717 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
719 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
720 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
723 if test "x$target_m32" = x1; then
725 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
726 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
727 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
728 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
729 TARGET_MODULE_FORMAT="elf32"
732 if test "x$target_m64" = x1; then
734 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
735 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
736 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
737 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
738 TARGET_MODULE_FORMAT="elf64"
741 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
742 TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
745 # on mips redirect cache flushing function to non-existant one.
746 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
747 AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
748 CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
749 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
750 [grub_cv_cc_mflush_func=yes],
751 [grub_cv_cc_mflush_func=no])
754 if test "x$grub_cv_cc_mflush_func" = xyes; then
755 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
760 # Force no alignment to save space on i386.
761 if test "x$target_cpu" = xi386; then
762 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
763 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
764 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
765 [grub_cv_cc_falign_loop=yes],
766 [grub_cv_cc_falign_loop=no])
769 AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
770 CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
771 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
772 [grub_cv_cc_malign_loop=yes],
773 [grub_cv_cc_malign_loop=no])
776 if test "x$grub_cv_cc_falign_loop" = xyes; then
777 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
778 elif test "x$grub_cv_cc_malign_loop" = xyes; then
779 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
783 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
784 CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
785 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
786 [grub_cv_cc_freg_struct_return=yes],
787 [grub_cv_cc_freg_struct_return=no])
790 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
791 TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
794 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
795 # Some toolchains enable these features by default, but they need
796 # registers that aren't set up properly in GRUB.
797 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
800 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
801 # that floats are a good fit to run instead of what's written in the code.
802 # Given that floating point unit is disabled (if present to begin with)
803 # when GRUB is running which may result in various hard crashes.
804 if test x"$platform" != xemu ; then
805 AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
806 grub_cv_target_cc_soft_float=no
807 if test "x$target_cpu" = xarm64; then
808 CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
809 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
810 [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
812 if test "x$target_cpu" = xia64; then
813 CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
814 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
815 [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
817 for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
818 "-Xclang -msoft-float -Xclang -no-implicit-float" \
819 "-Xclang -msoft-float" "-msoft-float"; do
820 if test x"$grub_cv_target_cc_soft_float" != xno ; then
823 CFLAGS="$TARGET_CFLAGS $cand -Werror"
824 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
825 [grub_cv_target_cc_soft_float="$cand"], [])
829 if test x"$grub_cv_target_cc_soft_float" = xno ; then
830 AC_MSG_ERROR([could not force soft-float])
833 case x"$grub_cv_target_cc_soft_float" in
835 # A trick so that clang doesn't see it on link stаge
836 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
839 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
842 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
846 if test x"$target_cpu" = xsparc64 ; then
847 AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
848 grub_cv_target_cc_mno_app_regs=no
849 for cand in "-mllvm -sparc-reserve-app-registers" \
851 if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
854 CFLAGS="$TARGET_CFLAGS $cand -Werror"
855 CPPFLAGS="$TARGET_CPPFLAGS"
856 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
857 [grub_cv_target_cc_mno_app_regs="$cand"], [])
861 if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
862 AC_MSG_ERROR([could not reserve application registers])
864 if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
865 # A trick so that clang doesn't see it on link stаge
866 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
868 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
871 AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
872 grub_cv_target_cc_mno_relax=no
873 for cand in "-mno-relax" "-Wl,--no-relax"; do
874 if test x"$grub_cv_target_cc_mno_relax" != xno ; then
877 LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
878 CFLAGS="$TARGET_CFLAGS -Werror"
879 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
880 asm (".globl start; start:");
882 void __main (void) {}
884 ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
887 LDFLAGS="$TARGET_LDFLAGS"
888 CFLAGS="$TARGET_CFLAGS"
890 if test x"$grub_cv_target_cc_mno_relax" = xno ; then
891 AC_MSG_ERROR([could not find no-relax options])
893 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
896 # By default, GCC 4.4 generates .eh_frame sections containing unwind
897 # information in some cases where it previously did not. GRUB doesn't need
898 # these and they just use up vital space. Restore the old compiler
900 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
901 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
902 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
903 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
904 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
907 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
908 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
911 if test x"$target_os" = xcygwin; then
912 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
913 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
914 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
915 [grub_cv_cc_no_reorder_functions=yes],
916 [grub_cv_cc_no_reorder_functions=no])
920 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
921 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
924 AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
925 CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
926 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
927 [grub_cv_cc_mno_stack_arg_probe=yes],
928 [grub_cv_cc_mno_stack_arg_probe=no])
931 if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
932 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
936 # By default, GCC 4.6 generates .eh_frame sections containing unwind
937 # information in some cases where it previously did not. GRUB doesn't need
938 # these and they just use up vital space. Restore the old compiler
940 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
941 CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
942 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
943 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
944 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
947 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
948 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
951 AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
952 CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
953 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
954 [grub_cv_cc_fno_unwind_tables=yes],
955 [grub_cv_cc_fno_unwind_tables=no])
958 if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
959 TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
963 CFLAGS="$TARGET_CFLAGS"
966 if test x"$platform" = xemu ; then
968 grub_cv_target_cc_link_format=
971 grub_cv_target_cc_link_format="-arch,${target_cpu}"
972 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
974 *windows* | *cygwin* | *mingw*)
975 if test x${target_cpu} = xi386 ; then
976 grub_cv_target_cc_link_format=-mi386pe
977 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
979 if test x${target_cpu} = xx86_64 ; then
980 grub_cv_target_cc_link_format=-mi386pep
981 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
983 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
986 elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
987 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
988 grub_cv_target_cc_link_format=unknown
989 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
990 if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
993 if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
996 CFLAGS="$TARGET_CFLAGS"
997 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
998 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
999 asm (".globl start; start:");
1000 asm (".globl _start; _start:");
1001 asm (".globl __start; __start:");
1003 void __main (void) {}
1004 ]], [[]])], [flag=1], [flag=0])
1005 if test x"$flag" = x1; then
1006 grub_cv_target_cc_link_format="$format"
1010 if test x"$grub_cv_target_cc_link_format" = xunknown; then
1011 AC_MSG_ERROR([no suitable link format found])
1013 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1014 if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
1015 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1017 if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1018 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1022 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
1023 TARGET_APPLE_LINKER=1
1024 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
1025 if test "x$TARGET_OBJCONV" = x ; then
1026 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
1028 if test "x$TARGET_OBJCONV" = x ; then
1029 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
1031 TARGET_IMG_LDSCRIPT=
1032 TARGET_IMG_CFLAGS="-static"
1033 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1034 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1035 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
1036 TARGET_LDFLAGS_OLDMAGIC=""
1037 elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
1038 TARGET_APPLE_LINKER=0
1039 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1040 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1041 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
1042 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1043 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1046 TARGET_APPLE_LINKER=0
1047 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1048 TARGET_IMG_LDSCRIPT=
1049 TARGET_IMG_LDFLAGS='-Wl,-N'
1050 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
1051 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1055 CFLAGS="$TARGET_CFLAGS"
1057 AC_ARG_ENABLE([efiemu],
1058 [AS_HELP_STRING([--enable-efiemu],
1059 [build and install the efiemu runtimes (default=guessed)])])
1060 if test x"$enable_efiemu" = xno ; then
1061 efiemu_excuse="explicitly disabled"
1064 if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1065 efiemu_excuse="not available on cygwin"
1067 if test x"$target_cpu" != xi386 ; then
1068 efiemu_excuse="only available on i386"
1070 if test x"$platform" = xefi ; then
1071 efiemu_excuse="not available on efi"
1074 if test x"$efiemu_excuse" = x ; then
1075 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
1076 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1077 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1078 [grub_cv_cc_efiemu=yes],
1079 [grub_cv_cc_efiemu=no])
1081 if test x$grub_cv_cc_efiemu = xno; then
1082 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
1085 if test x"$efiemu_excuse" = x ; then
1086 AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
1087 grub_cv_target_cc_efiemu64_link_format=unknown
1088 for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
1089 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1090 LDFLAGS="-m64 -Wl,$format -nostdlib -static"
1091 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1092 asm (".globl start; start:");
1093 asm (".globl _start; _start:");
1094 asm (".globl __start; __start:");
1096 void __main (void) {}
1097 ]], [[]])], [flag=1], [flag=0])
1098 if test x"$flag" = x1; then
1099 grub_cv_target_cc_efiemu64_link_format="$format"
1103 if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
1104 efiemu_excuse="no suitable link format for efiemu64 found"
1106 EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
1109 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
1110 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
1112 if test x"$efiemu_excuse" = x ; then
1117 AC_SUBST([enable_efiemu])
1118 AC_SUBST([EFIEMU64_LINK_FORMAT])
1120 CFLAGS="$TARGET_CFLAGS"
1122 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
1125 LDFLAGS="$TARGET_LDFLAGS"
1127 if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
1128 # Use large model to support 4G memory
1129 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
1130 CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1131 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1132 [grub_cv_cc_mcmodel=yes],
1133 [grub_cv_cc_mcmodel=no])
1135 if test "x$grub_cv_cc_mcmodel" = xyes; then
1136 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1137 elif test "$target_cpu" = sparc64; then
1138 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
1142 if test "$target_cpu"-"$platform" = x86_64-efi; then
1143 # EFI writes to stack below %rsp, we must not use the red zone
1144 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
1145 CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1147 [grub_cv_cc_no_red_zone=yes],
1148 [grub_cv_cc_no_red_zone=no])
1150 if test "x$grub_cv_cc_no_red_zone" = xno; then
1151 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
1154 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1157 if test "x$target_cpu" = xarm; then
1158 AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [
1159 grub_cv_target_cc_mno_movt=no
1160 for cand in "-mno-movt" \
1161 "-mllvm -arm-use-movt=0"; do
1162 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1165 CFLAGS="$TARGET_CFLAGS $cand -Werror"
1166 CPPFLAGS="$TARGET_CPPFLAGS"
1167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1168 [grub_cv_target_cc_mno_movt="$cand"], [])
1172 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1173 # A trick so that clang doesn't see it on link stage
1174 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt"
1176 AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
1177 CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
1178 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1179 [grub_cv_cc_mthumb_interwork=yes],
1180 [grub_cv_cc_mthumb_interwork=no])
1182 if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
1183 TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
1184 # Clang defaults to thumb interworking
1185 elif test "x$grub_cv_cc_target_clang" = xno ; then
1186 AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
1190 AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
1191 CFLAGS="$TARGET_CFLAGS -Qn -Werror"
1192 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1193 [grub_cv_target_cc_qn=yes],
1194 [grub_cv_target_cc_qn=no])])
1195 if test "x$grub_cv_target_cc_qn" = xyes; then
1196 TARGET_CFLAGS="$TARGET_CFLAGS -Qn"
1200 # Compiler features.
1203 CFLAGS="$TARGET_CFLAGS"
1205 # Position independent executable.
1208 grub_CHECK_NO_PIE_ONEWORD
1210 [# Need that, because some distributions ship compilers that include
1211 # `-fPIE' or '-fpie' and '-pie' in the default specs.
1212 if [ x"$pie_possible" = xyes ]; then
1213 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
1216 if [ x"$link_nopie_needed" = xyes ] || [ x"$pie_possible" = xyes ]; then
1217 if [ x"$nopie_possible" = xyes ]; then
1218 TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
1220 if [ x"$nopie_oneword_possible" = xyes ]; then
1221 TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie"
1225 CFLAGS="$TARGET_CFLAGS"
1226 LDFLAGS="$TARGET_LDFLAGS"
1228 # Position independent executable.
1230 [# On most platforms we don't want PIC as it only makes relocations harder
1231 # and code less efficient. On mips we want to have one got table per module
1232 # and reload $gp in every function.
1233 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
1234 # However with clang we need PIC for this reloading to happen.
1235 # With arm64 we need relocations that are in some way representable in
1236 # PE as we need to support arm64-efi. Without -fPIC clang generates
1237 # movk's which aren't representable.
1238 # Since default varies across dictributions use either -fPIC or -fno-PIC
1240 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
1241 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
1242 elif [ x"$pic_possible" = xyes ]; then
1243 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
1246 CFLAGS="$TARGET_CFLAGS"
1248 # Smashing stack protector.
1249 grub_CHECK_STACK_PROTECTOR
1250 # Need that, because some distributions ship compilers that include
1251 # `-fstack-protector' in the default specs.
1252 if test "x$ssp_possible" = xyes; then
1253 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
1256 CFLAGS="$TARGET_CFLAGS"
1258 grub_CHECK_STACK_ARG_PROBE
1259 # Cygwin's GCC uses alloca() to probe the stackframe on static
1260 # stack allocations above some threshold.
1261 if test x"$sap_possible" = xyes; then
1262 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
1265 CFLAGS="$TARGET_CFLAGS"
1267 # -mno-unaligned-access -mstrict-align
1268 if test "$target_cpu" = arm; then
1269 AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
1270 grub_cv_target_cc_strict_align=
1271 for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
1272 CFLAGS="$TARGET_CFLAGS $arg -Werror"
1273 LDFLAGS="$TARGET_LDFLAGS"
1274 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
1275 if test x"$flag" = x1; then
1276 grub_cv_target_cc_strict_align="$arg"
1281 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
1282 if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
1283 TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
1285 AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
1286 [CFLAGS="$TARGET_CFLAGS"
1287 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1288 #ifdef __ARM_FEATURE_UNALIGNED
1292 [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
1293 if test x$grub_cv_cc_target_emits_unaligned = xyes; then
1294 AC_MSG_ERROR([compiler generates unaligned accesses])
1298 # Set them to their new values for the tests below.
1300 if test x"$platform" = xemu ; then
1301 CFLAGS="$TARGET_CFLAGS -Wno-error"
1302 elif test "x$TARGET_APPLE_LINKER" = x1 ; then
1303 CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
1305 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
1307 CPPFLAGS="$TARGET_CPPFLAGS"
1310 if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
1311 if test x$grub_cv_asm_uscore = xyes; then
1312 DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
1314 DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main"
1316 CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
1319 # Check for libgcc symbols
1320 if test x"$platform" = xemu; then
1321 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)
1324 if test "x$TARGET_APPLE_LINKER" = x1 ; then
1325 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
1327 CFLAGS="$TARGET_CFLAGS -nostdlib"
1331 # Defined in aclocal.m4.
1333 if test "x$TARGET_APPLE_LINKER" != x1 ; then
1334 grub_PROG_OBJCOPY_ABSOLUTE
1336 grub_PROG_LD_BUILD_ID_NONE
1337 if test "x$target_cpu" = xi386; then
1338 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
1339 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
1340 # Check symbols provided by linker script.
1341 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
1343 grub_CHECK_BSS_START_SYMBOL
1344 grub_CHECK_END_SYMBOL
1346 CFLAGS="$TARGET_CFLAGS"
1350 grub_PROG_NM_MINUS_P
1351 grub_PROG_NM_DEFINED_ONLY
1352 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
1353 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
1355 if test "$platform" != emu; then
1356 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
1357 SAVED_CPPFLAGS="$CPPFLAGS"
1358 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1361 int va_arg_func (int fixed, va_list args);]], [[]])],
1362 [grub_cv_cc_isystem=yes],
1363 [grub_cv_cc_isystem=no])
1364 CPPFLAGS="$SAVED_CPPFLAGS"
1367 if test x"$grub_cv_cc_isystem" = xyes ; then
1368 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1372 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
1373 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
1374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1375 int va_arg_func (int fixed, va_list args);]], [[]])],
1376 [grub_cv_cc_wtrampolines=yes],
1377 [grub_cv_cc_wtrampolines=no])
1380 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
1381 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
1384 # Restore the flags.
1386 CFLAGS="$tmp_CFLAGS"
1387 CPPFLAGS="$tmp_CPPFLAGS"
1388 LDFLAGS="$tmp_LDFLAGS"
1392 # Check for options.
1395 # Memory manager debugging.
1396 AC_ARG_ENABLE([mm-debug],
1397 AS_HELP_STRING([--enable-mm-debug],
1398 [include memory manager debugging]),
1399 [AC_DEFINE([MM_DEBUG], [1],
1400 [Define to 1 if you enable memory manager debugging.])])
1402 AC_ARG_ENABLE([cache-stats],
1403 AS_HELP_STRING([--enable-cache-stats],
1404 [enable disk cache statistics collection]))
1406 if test x$enable_cache_stats = xyes; then
1411 AC_SUBST([DISK_CACHE_STATS])
1413 AC_ARG_ENABLE([boot-time],
1414 AS_HELP_STRING([--enable-boot-time],
1415 [enable boot time statistics collection]))
1417 if test x$enable_boot_time = xyes; then
1422 AC_SUBST([BOOT_TIME_STATS])
1424 AC_ARG_ENABLE([grub-emu-sdl],
1425 [AS_HELP_STRING([--enable-grub-emu-sdl],
1426 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
1428 AC_ARG_ENABLE([grub-emu-pci],
1429 [AS_HELP_STRING([--enable-grub-emu-pci],
1430 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
1432 if test "$platform" = emu; then
1434 if test x"$enable_grub_emu_sdl" = xno ; then
1435 grub_emu_sdl_excuse="explicitly disabled"
1437 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1438 # Check for libSDL libraries.]
1439 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1440 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1444 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1445 # Check for headers.]
1446 AC_CHECK_HEADERS([SDL/SDL.h], [],
1447 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1450 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1451 AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
1453 if test x"$grub_emu_sdl_excuse" = x ; then
1454 enable_grub_emu_sdl=yes
1456 enable_grub_emu_sdl=no
1459 if test x"$enable_grub_emu_pci" != xyes ; then
1460 grub_emu_pci_excuse="not enabled"
1463 [if [ x"$grub_emu_pci_excuse" = x ]; then
1464 # Check for libpci libraries.]
1465 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1466 [grub_emu_pci_excuse=["need libpciaccess library"]])
1467 AC_SUBST([LIBPCIACCESS])
1469 [if [ x"$grub_emu_pci_excuse" = x ]; then
1470 # Check for headers.]
1471 AC_CHECK_HEADERS([pciaccess.h], [],
1472 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1475 if test x"$grub_emu_pci_excuse" = x ; then
1476 enable_grub_emu_pci=yes
1479 enable_grub_emu_pci=no
1482 AC_SUBST([enable_grub_emu_sdl])
1483 AC_SUBST([enable_grub_emu_pci])
1487 # Ignore --enable-emu-* if platform is not emu
1488 enable_grub_emu_sdl=no
1489 enable_grub_emu_pci=no
1492 AC_ARG_ENABLE([grub-mkfont],
1493 [AS_HELP_STRING([--enable-grub-mkfont],
1494 [build and install the `grub-mkfont' utility (default=guessed)])])
1495 if test x"$enable_grub_mkfont" = xno ; then
1496 grub_mkfont_excuse="explicitly disabled"
1499 if test x"$grub_mkfont_excuse" = x ; then
1500 # Check for freetype libraries.
1501 AC_CHECK_TOOLS([FREETYPE], [freetype-config])
1502 if test "x$FREETYPE" = x ; then
1503 grub_mkfont_excuse=["need freetype2 library"]
1507 unset ac_cv_header_ft2build_h
1509 if test x"$grub_mkfont_excuse" = x ; then
1510 # Check for freetype libraries.
1511 freetype_cflags=`$FREETYPE --cflags`
1512 freetype_libs=`$FREETYPE --libs`
1513 SAVED_CPPFLAGS="$CPPFLAGS"
1515 CPPFLAGS="$CPPFLAGS $freetype_cflags"
1516 LIBS="$LIBS $freetype_libs"
1517 AC_CHECK_HEADERS([ft2build.h], [],
1518 [grub_mkfont_excuse=["need freetype2 headers"]])
1519 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_mkfont_excuse=["freetype2 library unusable"]])
1520 CPPFLAGS="$SAVED_CPPFLAGS"
1524 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1525 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
1527 if test x"$grub_mkfont_excuse" = x ; then
1528 enable_grub_mkfont=yes
1530 enable_grub_mkfont=no
1532 AC_SUBST([enable_grub_mkfont])
1533 AC_SUBST([freetype_cflags])
1534 AC_SUBST([freetype_libs])
1538 SAVED_CFLAGS="$CFLAGS"
1539 SAVED_CPPFLAGS="$CPPFLAGS"
1540 SAVED_LDFLAGS="$LDFLAGS"
1543 CFLAGS="$BUILD_CFLAGS"
1544 CPPFLAGS="$BUILD_CPPFLAGS"
1545 LDFLAGS="$BUILD_LDFAGS"
1547 unset ac_cv_c_bigendian
1548 unset ac_cv_header_ft2build_h
1550 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1551 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1552 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1554 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1555 AC_MSG_ERROR([couldnt determine build endianness])
1558 AC_SUBST([BUILD_SIZEOF_LONG])
1559 AC_SUBST([BUILD_SIZEOF_VOID_P])
1560 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1562 if test x"$grub_build_mkfont_excuse" = x ; then
1563 # Check for freetype libraries.
1564 AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config])
1565 if test "x$BUILD_FREETYPE" = x ; then
1566 grub_build_mkfont_excuse=["need freetype2 library"]
1570 if test x"$grub_build_mkfont_excuse" = x ; then
1571 # Check for freetype libraries.
1572 build_freetype_cflags=`$BUILD_FREETYPE --cflags`
1573 build_freetype_libs=`$BUILD_FREETYPE --libs`
1574 SAVED_CPPFLAGS_2="$CPPFLAGS"
1576 CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
1577 LIBS="$LIBS $build_freetype_libs"
1578 AC_CHECK_HEADERS([ft2build.h], [],
1579 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1580 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_build_mkfont_excuse=["freetype2 library unusable"]])
1582 CPPFLAGS="$SAVED_CPPFLAGS_2"
1585 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1586 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
1588 if test x"$grub_build_mkfont_excuse" = x ; then
1589 enable_build_grub_mkfont=yes
1591 enable_build_grub_mkfont=no
1593 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
1594 if test x"$grub_build_mkfont_excuse" = x ; then
1595 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont])
1597 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)])
1601 AC_SUBST([build_freetype_cflags])
1602 AC_SUBST([build_freetype_libs])
1606 CFLAGS="$SAVED_CFLAGS"
1607 CPPFLAGS="$SAVED_CPPFLAGS"
1608 LDFLAGS="$SAVED_LDFLAGS"
1615 AC_ARG_ENABLE([grub-themes],
1616 [AS_HELP_STRING([--enable-grub-themes],
1617 [build and install GRUB themes (default=guessed)])])
1618 if test x"$enable_grub_themes" = xno ; then
1619 starfield_excuse="explicitly disabled"
1622 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1623 starfield_excuse="No build-time grub-mkfont"
1626 if test x"$starfield_excuse" = x; then
1627 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1628 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
1629 if test -f "$dir/DejaVuSans.$ext"; then
1630 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1636 if test "x$DJVU_FONT_SOURCE" = x; then
1637 starfield_excuse="No DejaVu found"
1641 if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1642 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
1645 AC_SUBST([DJVU_FONT_SOURCE])
1649 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1650 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
1651 if test -f "$dir/unifont.$ext"; then
1652 md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
1653 # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
1654 if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
1657 FONT_SOURCE="$dir/unifont.$ext"
1663 if test x"$enable_build_grub_mkfont" = xno ; then
1667 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
1668 if test x"$grub_build_mkfont_excuse" = x ; then
1669 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont])
1671 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
1675 AC_SUBST([FONT_SOURCE])
1677 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1678 grub_build_mkfont_excuse="no fonts"
1682 AC_ARG_ENABLE([grub-mount],
1683 [AS_HELP_STRING([--enable-grub-mount],
1684 [build and install the `grub-mount' utility (default=guessed)])])
1685 if test x"$enable_grub_mount" = xno ; then
1686 grub_mount_excuse="explicitly disabled"
1689 if test x"$grub_mount_excuse" = x ; then
1690 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1691 [grub_mount_excuse="need FUSE library"])
1694 if test x"$grub_mount_excuse" = x ; then
1695 # Check for fuse headers.
1696 SAVED_CPPFLAGS="$CPPFLAGS"
1697 CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
1698 AC_CHECK_HEADERS([fuse/fuse.h], [],
1699 [grub_mount_excuse=["need FUSE headers"]])
1700 CPPFLAGS="$SAVED_CPPFLAGS"
1703 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1704 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
1706 if test x"$grub_mount_excuse" = x ; then
1707 enable_grub_mount=yes
1709 enable_grub_mount=no
1711 AC_SUBST([enable_grub_mount])
1713 AC_ARG_ENABLE([device-mapper],
1714 [AS_HELP_STRING([--enable-device-mapper],
1715 [enable Linux device-mapper support (default=guessed)])])
1716 if test x"$enable_device_mapper" = xno ; then
1717 device_mapper_excuse="explicitly disabled"
1720 if test x"$device_mapper_excuse" = x ; then
1721 # Check for device-mapper header.
1722 AC_CHECK_HEADER([libdevmapper.h], [],
1723 [device_mapper_excuse="need libdevmapper header"])
1726 if test x"$device_mapper_excuse" = x ; then
1727 # Check for device-mapper library.
1728 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1729 [device_mapper_excuse="need devmapper library"])
1732 if test x"$device_mapper_excuse" = x ; then
1733 # Check for device-mapper library.
1734 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1736 [device_mapper_excuse="need devmapper library"])
1739 if test x"$device_mapper_excuse" = x ; then
1740 LIBDEVMAPPER="-ldevmapper"
1741 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1742 [Define to 1 if you have the devmapper library.])
1745 AC_SUBST([LIBDEVMAPPER])
1748 if test x$host_kernel = xkfreebsd; then
1749 AC_CHECK_LIB([geom], [geom_gettree], [],
1750 [AC_MSG_ERROR([Your platform requires libgeom])])
1756 AC_ARG_ENABLE([liblzma],
1757 [AS_HELP_STRING([--enable-liblzma],
1758 [enable liblzma integration (default=guessed)])])
1759 if test x"$enable_liblzma" = xno ; then
1760 liblzma_excuse="explicitly disabled"
1763 if test x"$liblzma_excuse" = x ; then
1764 AC_CHECK_LIB([lzma], [lzma_code],
1765 [],[liblzma_excuse="need lzma library"])
1767 if test x"$liblzma_excuse" = x ; then
1768 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1771 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1772 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
1776 if test x"$liblzma_excuse" = x ; then
1778 AC_DEFINE([USE_LIBLZMA], [1],
1779 [Define to 1 if you have the LZMA library.])
1784 AC_ARG_ENABLE([libzfs],
1785 [AS_HELP_STRING([--enable-libzfs],
1786 [enable libzfs integration (default=guessed)])])
1787 if test x"$enable_libzfs" = xno ; then
1788 libzfs_excuse="explicitly disabled"
1791 if test x"$libzfs_excuse" = x ; then
1792 # Only check for system headers if libzfs support has not been disabled.
1793 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1796 if test x"$libzfs_excuse" = x ; then
1797 AC_CHECK_LIB([zfs], [libzfs_init],
1799 [libzfs_excuse="need zfs library"])
1802 if test x"$libzfs_excuse" = x ; then
1803 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1805 [libzfs_excuse="need nvpair library"])
1808 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1809 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
1812 if test x"$libzfs_excuse" = x ; then
1813 # We need both libzfs and libnvpair for a successful build.
1815 AC_DEFINE([HAVE_LIBZFS], [1],
1816 [Define to 1 if you have the ZFS library.])
1817 LIBNVPAIR="-lnvpair"
1818 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1819 [Define to 1 if you have the NVPAIR library.])
1823 AC_SUBST([LIBNVPAIR])
1827 AC_SUBST([FONT_SOURCE])
1828 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1829 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1831 AC_SUBST(HAVE_ASM_USCORE)
1832 AC_SUBST(BSS_START_SYMBOL)
1833 AC_SUBST(END_SYMBOL)
1837 AC_ARG_ENABLE([werror],
1838 [AS_HELP_STRING([--disable-werror],
1839 [do not use -Werror when building GRUB])])
1840 if test x"$enable_werror" != xno ; then
1841 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1842 HOST_CFLAGS="$HOST_CFLAGS -Werror"
1845 TARGET_CPP="$TARGET_CC -E"
1846 TARGET_CCAS=$TARGET_CC
1848 # Includes which include make-time substitutions. They must come last
1849 # as to avoid executing top_builddir in shell.
1850 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
1851 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
1852 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
1854 GRUB_TARGET_CPU="${target_cpu}"
1855 GRUB_PLATFORM="${platform}"
1857 AC_SUBST(GRUB_TARGET_CPU)
1858 AC_SUBST(GRUB_PLATFORM)
1860 AC_SUBST(TARGET_OBJCONV)
1861 AC_SUBST(TARGET_CPP)
1862 AC_SUBST(TARGET_CCAS)
1863 AC_SUBST(TARGET_OBJ2ELF)
1864 AC_SUBST(TARGET_MODULE_FORMAT)
1865 AC_SUBST(TARGET_CC_VERSION)
1867 AC_SUBST(TARGET_CFLAGS)
1868 AC_SUBST(TARGET_LDFLAGS)
1869 AC_SUBST(TARGET_CPPFLAGS)
1870 AC_SUBST(TARGET_CCASFLAGS)
1872 AC_SUBST(TARGET_IMG_LDFLAGS)
1873 AC_SUBST(TARGET_IMG_CFLAGS)
1874 AC_SUBST(TARGET_IMG_BASE_LDOPT)
1875 AC_SUBST(TARGET_APPLE_LINKER)
1877 AC_SUBST(HOST_CFLAGS)
1878 AC_SUBST(HOST_LDFLAGS)
1879 AC_SUBST(HOST_CPPFLAGS)
1880 AC_SUBST(HOST_CCASFLAGS)
1882 AC_SUBST(BUILD_LIBM)
1885 # Automake conditionals
1888 AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
1889 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1890 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1891 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1892 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1893 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1894 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1895 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1896 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1897 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1898 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1899 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
1900 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1901 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1902 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1903 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1904 AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
1905 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1906 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1907 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1908 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1909 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1910 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1911 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1912 AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
1913 AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
1915 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1916 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1917 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1918 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1919 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1920 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1921 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1923 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1924 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1925 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1926 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1927 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1928 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1929 if test x$FONT_SOURCE != x ; then
1934 AC_SUBST(HAVE_FONT_SOURCE)
1935 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
1936 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1937 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1938 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1940 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1942 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1943 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1944 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
1946 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
1947 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
1948 datarootdir="$(eval echo "$datarootdir")"
1949 grub_libdir="$(eval echo "$libdir")"
1950 grub_localedir="$(eval echo "$localedir")"
1951 grub_datadir="$(eval echo "$datadir")"
1952 grub_sysconfdir="$(eval echo "$sysconfdir")"
1953 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
1954 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
1955 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
1956 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
1960 if test "$platform" != none; then
1961 cpudir="${target_cpu}"
1962 if test x${cpudir} = xmipsel; then
1966 if test x"$link_dir" = xyes ; then
1967 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1968 if test "$platform" != emu ; then
1969 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1972 mkdir -p include/grub 2>/dev/null
1973 rm -rf include/grub/cpu
1974 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1975 if test "$platform" != emu ; then
1976 rm -rf include/grub/machine
1977 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1981 # Just enough to stop the compiler failing with -I$(srcdir)/include.
1982 mkdir -p include 2>/dev/null
1983 rm -rf include/grub/cpu include/grub/machine
1986 AC_CONFIG_FILES([Makefile])
1987 AC_CONFIG_FILES([grub-core/Makefile])
1988 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1989 AC_CONFIG_FILES([po/Makefile.in])
1990 AC_CONFIG_FILES([docs/Makefile])
1991 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1992 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1993 AC_CONFIG_FILES([config.h])
1997 echo "*******************************************************"
1998 echo GRUB2 will be compiled with following components:
1999 echo Platform: "$target_cpu"-"$platform"
2000 if [ x"$platform" = xemu ]; then
2001 if [ x"$grub_emu_sdl_excuse" = x ]; then
2002 echo SDL support for grub-emu: Yes
2004 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
2006 if [ x"$grub_emu_pci_excuse" = x ]; then
2007 echo PCI support for grub-emu: Yes
2009 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
2012 if test x"$device_mapper_excuse" = x ; then
2013 echo With devmapper support: Yes
2015 echo With devmapper support: No "($device_mapper_excuse)"
2017 if [ x"$enable_mm_debug" = xyes ]; then
2018 echo With memory debugging: Yes
2020 echo With memory debugging: No
2022 if [ x"$enable_cache_stats" = xyes ]; then
2023 echo With disk cache statistics: Yes
2025 echo With disk cache statistics: No
2028 if [ x"$enable_boot_time" = xyes ]; then
2029 echo With boot time statistics: Yes
2031 echo With boot time statistics: No
2034 if [ x"$efiemu_excuse" = x ]; then
2035 echo efiemu runtime: Yes
2037 echo efiemu runtime: No "($efiemu_excuse)"
2039 if [ x"$grub_mkfont_excuse" = x ]; then
2040 echo grub-mkfont: Yes
2042 echo grub-mkfont: No "($grub_mkfont_excuse)"
2044 if [ x"$grub_mount_excuse" = x ]; then
2045 echo grub-mount: Yes
2047 echo grub-mount: No "($grub_mount_excuse)"
2049 if [ x"$starfield_excuse" = x ]; then
2050 echo starfield theme: Yes
2051 echo With DejaVuSans font from $DJVU_FONT_SOURCE
2053 echo starfield theme: No "($starfield_excuse)"
2055 if [ x"$libzfs_excuse" = x ]; then
2056 echo With libzfs support: Yes
2058 echo With libzfs support: No "($libzfs_excuse)"
2060 if [ x"$grub_build_mkfont_excuse" = x ]; then
2061 echo Build-time grub-mkfont: Yes
2062 if test "x$FONT_SOURCE" = x ; then
2063 echo "Without unifont"
2065 echo "With unifont from $FONT_SOURCE"
2068 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
2069 echo "Without unifont (no build-time grub-mkfont)"
2071 if test x"$liblzma_excuse" != x ; then
2072 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
2074 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
2076 echo "*******************************************************"