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.02~beta2],[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 test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required]);;
379 if test x$USE_NLS = xno; then
380 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
383 if test "x$cross_compiling" = xyes; then
384 AC_MSG_WARN([cannot generate manual pages while cross compiling])
386 AC_PATH_PROG(HELP2MAN, help2man)
389 # Check for functions and headers.
390 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
391 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
393 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
394 #include <sys/param.h>
395 #include <sys/mount.h>])
397 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
398 #include <sys/param.h>
399 #include <sys/mount.h>])
401 # For opendisk() and getrawpartition() on NetBSD.
402 # Used in util/deviceiter.c and in util/hostdisk.c.
403 AC_CHECK_HEADER([util.h], [
404 AC_CHECK_LIB([util], [opendisk], [
406 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
408 AC_CHECK_LIB([util], [getrawpartition], [
410 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
415 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
416 SAVED_CFLAGS="$CFLAGS"
417 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
418 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
419 int va_arg_func (int fixed, va_list args);]], [[]])],
420 [grub_cv_host_cc_wtrampolines=yes],
421 [grub_cv_host_cc_wtrampolines=no])
422 CFLAGS="$SAVED_CFLAGS"
425 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
426 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
430 # Check for host and build compilers.
433 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
434 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
435 BUILD_CPP="$BUILD_CC -E"
438 haiku*) BUILD_LIBM= ;;
442 dnl FIXME proper test seems to require too deep dive into Autoconf internals.
443 dnl For now just list known platforms that we support.
446 cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
449 AC_SUBST(BUILD_EXEEXT)
454 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"
455 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"
457 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
459 AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
460 SAVED_CFLAGS="$CFLAGS"
461 grub_cv_cc_w_extra_flags=
462 for x in $EXTRA_WARN_FLAGS; do
463 CFLAGS="$HOST_CFLAGS $x -Werror"
464 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
465 if test x$flag = x1 ; then
466 grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
469 CFLAGS="$SAVED_CFLAGS"
472 HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
475 # Check for target programs.
478 # Find tools for the target.
479 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
480 tmp_ac_tool_prefix="$ac_tool_prefix"
481 ac_tool_prefix=$target_alias-
483 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
484 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
485 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
486 AC_CHECK_TOOL(TARGET_STRIP, strip)
487 AC_CHECK_TOOL(TARGET_NM, nm)
488 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
490 ac_tool_prefix="$tmp_ac_tool_prefix"
492 if test "x$TARGET_CC" = x; then
495 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
496 AC_CHECK_TOOL(TARGET_STRIP, strip)
497 AC_CHECK_TOOL(TARGET_NM, nm)
498 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
503 AC_SUBST(BUILD_CFLAGS)
504 AC_SUBST(BUILD_CPPFLAGS)
505 AC_SUBST(BUILD_LDFLAGS)
508 AC_SUBST(TARGET_RANLIB)
509 AC_SUBST(TARGET_STRIP)
510 AC_SUBST(TARGET_OBJCOPY)
512 # Test the C compiler for the target environment.
515 tmp_LDFLAGS="$LDFLAGS"
516 tmp_CPPFLAGS="$CPPFLAGS"
519 CFLAGS="$TARGET_CFLAGS"
520 CPPFLAGS="$TARGET_CPPFLAGS"
521 LDFLAGS="$TARGET_LDFLAGS"
525 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
526 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
528 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
529 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
532 TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
534 AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
535 LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
537 grub_cv_target_cc_w_extra_flags=
538 for x in $EXTRA_WARN_FLAGS; do
539 CFLAGS="$TARGET_CFLAGS $x -Werror"
540 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
541 asm (".globl start; start:");
543 void __main (void) {}
545 ]], [[]])], [flag=1], [flag=0])
546 if test x$flag = x1 ; then
547 grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
552 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
554 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
556 CFLAGS="$TARGET_CFLAGS"
558 [AC_LANG_PROGRAM([], [[
563 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
565 if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
566 AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
567 grub_cv_target_cc_big_endian=no
568 for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
569 "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
570 "-EB" "-mbig-endian"; do
571 if test x"$grub_cv_target_cc_big_endian" != xno ; then
574 CFLAGS="$TARGET_CFLAGS $cand -Werror"
575 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
576 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
577 #error still little endian
579 asm (".globl start; start:");
580 asm (".globl _start; _start:");
581 asm (".globl __start; __start:");
583 void __main (void) {}
586 [grub_cv_target_cc_big_endian="$cand"], [])
590 if test x"$grub_cv_target_cc_big_endian" = xno ; then
591 AC_MSG_ERROR([could not force big-endian])
594 skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
596 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
597 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
598 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
599 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
600 elif test x$target_cpu = xmipsel; then
601 AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
602 grub_cv_target_cc_little_endian=no
603 for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
604 "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
606 if test x"$grub_cv_target_cc_little_endian" != xno ; then
609 CFLAGS="$TARGET_CFLAGS $cand -Werror"
610 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
611 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
612 #error still big endian
614 asm (".globl start; start:");
615 asm (".globl _start; _start:");
616 asm (".globl __start; __start:");
618 void __main (void) {}
621 [grub_cv_target_cc_little_endian="$cand"], [])
625 if test x"$grub_cv_target_cc_little_endian" = xno ; then
626 AC_MSG_ERROR([could not force little-endian])
629 skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
631 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
632 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
633 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
634 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
637 # GRUB code is N32-compliant but it's experimental and we would prefer to
638 # avoid having too much variety when it doesn't result in any real improvement.
639 # Moreover N64 isn't supported.
640 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
641 AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
642 grub_cv_target_cc_mips_o32_abi=no
643 for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
644 if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
647 CFLAGS="$TARGET_CFLAGS $arg -Werror"
648 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
649 #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
652 asm (".globl start; start:");
653 asm (".globl _start; _start:");
654 asm (".globl __start; __start:");
656 void __main (void) {}
659 [grub_cv_target_cc_mips_o32_abi="$arg"], [])
663 if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
664 AC_MSG_ERROR([could not force MIPS o32 ABI])
667 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
668 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
671 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
673 case "x$target_cpu-$platform" in
683 xpowerpc-* | xsparc64-* | xarm-*)
684 test_program=$target_cpu
687 if test x"$test_program" = x ; then
688 grub_cv_cc_target_asm_compile=
691 for arg in "" "-no-integrated-as"; do
692 cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
693 echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
694 if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
695 grub_cv_cc_target_asm_compile="$arg"
700 if test x"$found" = xno ; then
701 AC_MSG_ERROR([could not compile assembly])
706 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
708 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
709 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
712 if test "x$target_m32" = x1; then
714 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
715 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
716 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
717 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
718 TARGET_MODULE_FORMAT="elf32"
721 if test "x$target_m64" = x1; then
723 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
724 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
725 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
726 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
727 TARGET_MODULE_FORMAT="elf64"
730 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
731 TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
734 # on mips redirect cache flushing function to non-existant one.
735 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
736 AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
737 CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
738 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
739 [grub_cv_cc_mflush_func=yes],
740 [grub_cv_cc_mflush_func=no])
743 if test "x$grub_cv_cc_mflush_func" = xyes; then
744 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
749 # Force no alignment to save space on i386.
750 if test "x$target_cpu" = xi386; then
751 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
752 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
754 [grub_cv_cc_falign_loop=yes],
755 [grub_cv_cc_falign_loop=no])
758 AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
759 CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
760 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
761 [grub_cv_cc_malign_loop=yes],
762 [grub_cv_cc_malign_loop=no])
765 if test "x$grub_cv_cc_falign_loop" = xyes; then
766 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
767 elif test "x$grub_cv_cc_malign_loop" = xyes; then
768 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
772 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
773 CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
774 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
775 [grub_cv_cc_freg_struct_return=yes],
776 [grub_cv_cc_freg_struct_return=no])
779 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
780 TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
783 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
784 # Some toolchains enable these features by default, but they need
785 # registers that aren't set up properly in GRUB.
786 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
789 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
790 # that floats are a good fit to run instead of what's written in the code.
791 # Given that floating point unit is disabled (if present to begin with)
792 # when GRUB is running which may result in various hard crashes.
793 if test x"$platform" != xemu ; then
794 AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
795 grub_cv_target_cc_soft_float=no
796 if test "x$target_cpu" = xarm64; then
797 CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
798 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
799 [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
801 if test "x$target_cpu" = xia64; then
802 CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
803 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
804 [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
806 for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
807 "-Xclang -msoft-float -Xclang -no-implicit-float" \
808 "-Xclang -msoft-float" "-msoft-float"; do
809 if test x"$grub_cv_target_cc_soft_float" != xno ; then
812 CFLAGS="$TARGET_CFLAGS $cand -Werror"
813 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
814 [grub_cv_target_cc_soft_float="$cand"], [])
818 if test x"$grub_cv_target_cc_soft_float" = xno ; then
819 AC_MSG_ERROR([could not force soft-float])
822 case x"$grub_cv_target_cc_soft_float" in
824 # A trick so that clang doesn't see it on link stаge
825 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
828 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
831 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
835 if test x"$target_cpu" = xsparc64 ; then
836 AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
837 grub_cv_target_cc_mno_app_regs=no
838 for cand in "-mllvm -sparc-reserve-app-registers" \
840 if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
843 CFLAGS="$TARGET_CFLAGS $cand -Werror"
844 CPPFLAGS="$TARGET_CPPFLAGS"
845 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
846 [grub_cv_target_cc_mno_app_regs="$cand"], [])
850 if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
851 AC_MSG_ERROR([could not reserve application registers])
853 if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
854 # A trick so that clang doesn't see it on link stаge
855 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
857 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
860 AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
861 grub_cv_target_cc_mno_relax=no
862 for cand in "-mno-relax" "-Wl,--no-relax"; do
863 if test x"$grub_cv_target_cc_mno_relax" != xno ; then
866 LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
867 CFLAGS="$TARGET_CFLAGS -Werror"
868 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
869 asm (".globl start; start:");
871 void __main (void) {}
873 ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
876 LDFLAGS="$TARGET_LDFLAGS"
877 CFLAGS="$TARGET_CFLAGS"
879 if test x"$grub_cv_target_cc_mno_relax" = xno ; then
880 AC_MSG_ERROR([could not find no-relax options])
882 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
885 # By default, GCC 4.4 generates .eh_frame sections containing unwind
886 # information in some cases where it previously did not. GRUB doesn't need
887 # these and they just use up vital space. Restore the old compiler
889 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
890 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
891 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
892 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
893 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
896 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
897 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
900 if test x"$target_os" = xcygwin; then
901 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
902 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
903 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
904 [grub_cv_cc_no_reorder_functions=yes],
905 [grub_cv_cc_no_reorder_functions=no])
909 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
910 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
913 AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
914 CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
915 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
916 [grub_cv_cc_mno_stack_arg_probe=yes],
917 [grub_cv_cc_mno_stack_arg_probe=no])
920 if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
921 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
925 # By default, GCC 4.6 generates .eh_frame sections containing unwind
926 # information in some cases where it previously did not. GRUB doesn't need
927 # these and they just use up vital space. Restore the old compiler
929 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
930 CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
931 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
932 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
933 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
936 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
937 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
940 AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
941 CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
942 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
943 [grub_cv_cc_fno_unwind_tables=yes],
944 [grub_cv_cc_fno_unwind_tables=no])
947 if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
948 TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
951 AC_ARG_ENABLE([efiemu],
952 [AS_HELP_STRING([--enable-efiemu],
953 [build and install the efiemu runtimes (default=guessed)])])
954 if test x"$enable_efiemu" = xno ; then
955 efiemu_excuse="explicitly disabled"
957 if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
958 efiemu_excuse="not available on cygwin"
960 if test x"$target_cpu" != xi386 ; then
961 efiemu_excuse="only available on i386"
963 if test x"$platform" = xefi ; then
964 efiemu_excuse="not available on efi"
966 if test x"$efiemu_excuse" = x ; then
967 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
968 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
969 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
970 [grub_cv_cc_efiemu=yes],
971 [grub_cv_cc_efiemu=no])
973 if test x$grub_cv_cc_efiemu = xno; then
974 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
977 if test x"$efiemu_excuse" = x ; then
978 AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
979 grub_cv_target_cc_efiemu64_link_format=unknown
980 for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
981 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
982 LDFLAGS="-m64 -Wl,$format -nostdlib -static"
983 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
984 asm (".globl start; start:");
985 asm (".globl _start; _start:");
986 asm (".globl __start; __start:");
988 void __main (void) {}
989 ]], [[]])], [flag=1], [flag=0])
990 if test x"$flag" = x1; then
991 grub_cv_target_cc_efiemu64_link_format="$format"
995 if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
996 efiemu_excuse="no suitable link format for efiemu64 found"
998 EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
1001 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
1002 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
1004 if test x"$efiemu_excuse" = x ; then
1009 AC_SUBST([enable_efiemu])
1010 AC_SUBST([EFIEMU64_LINK_FORMAT])
1012 CFLAGS="$TARGET_CFLAGS"
1015 if test x"$platform" = xemu ; then
1017 grub_cv_target_cc_link_format=
1020 grub_cv_target_cc_link_format="-arch,${target_cpu}"
1021 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1023 *windows* | *cygwin* | *mingw*)
1024 if test x${target_cpu} = xi386 ; then
1025 grub_cv_target_cc_link_format=-mi386pe
1026 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1028 if test x${target_cpu} = xx86_64 ; then
1029 grub_cv_target_cc_link_format=-mi386pep
1030 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1032 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1035 elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
1036 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
1037 grub_cv_target_cc_link_format=unknown
1038 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
1039 if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
1042 if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
1045 CFLAGS="$TARGET_CFLAGS"
1046 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
1047 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1048 asm (".globl start; start:");
1049 asm (".globl _start; _start:");
1050 asm (".globl __start; __start:");
1052 void __main (void) {}
1053 ]], [[]])], [flag=1], [flag=0])
1054 if test x"$flag" = x1; then
1055 grub_cv_target_cc_link_format="$format"
1059 if test x"$grub_cv_target_cc_link_format" = xunknown; then
1060 AC_MSG_ERROR([no suitable link format found])
1062 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1063 if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
1064 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1066 if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1067 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1071 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
1072 TARGET_APPLE_LINKER=1
1073 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
1074 if test "x$TARGET_OBJCONV" = x ; then
1075 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
1077 if test "x$TARGET_OBJCONV" = x ; then
1078 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
1080 TARGET_IMG_LDSCRIPT=
1081 TARGET_IMG_CFLAGS="-static"
1082 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1083 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1084 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
1085 TARGET_LDFLAGS_OLDMAGIC=""
1086 elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
1087 TARGET_APPLE_LINKER=0
1088 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1089 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1090 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
1091 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1092 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1095 TARGET_APPLE_LINKER=0
1096 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1097 TARGET_IMG_LDSCRIPT=
1098 TARGET_IMG_LDFLAGS='-Wl,-N'
1099 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
1100 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1104 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
1107 LDFLAGS="$TARGET_LDFLAGS"
1109 if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
1110 # Use large model to support 4G memory
1111 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
1112 CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1113 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1114 [grub_cv_cc_mcmodel=yes],
1115 [grub_cv_cc_mcmodel=no])
1117 if test "x$grub_cv_cc_mcmodel" = xyes; then
1118 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1119 elif test "$target_cpu" = sparc64; then
1120 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
1124 if test "$target_cpu"-"$platform" = x86_64-efi; then
1125 # EFI writes to stack below %rsp, we must not use the red zone
1126 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
1127 CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1128 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1129 [grub_cv_cc_no_red_zone=yes],
1130 [grub_cv_cc_no_red_zone=no])
1132 if test "x$grub_cv_cc_no_red_zone" = xno; then
1133 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
1136 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1139 if test "x$target_cpu" = xarm; then
1140 AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [
1141 CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
1142 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1143 [grub_cv_cc_mlong_calls=yes],
1144 [grub_cv_cc_mlong_calls=no])
1146 if test "x$grub_cv_cc_mlong_calls" = xyes; then
1147 TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls"
1149 AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
1150 CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
1151 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1152 [grub_cv_cc_mthumb_interwork=yes],
1153 [grub_cv_cc_mthumb_interwork=no])
1155 if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
1156 TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
1157 # Clang defaults to thumb interworking
1158 elif test "x$grub_cv_cc_target_clang" = xno ; then
1159 AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
1163 AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
1164 CFLAGS="$TARGET_CFLAGS -Qn -Werror"
1165 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1166 [grub_cv_target_cc_qn=yes],
1167 [grub_cv_target_cc_qn=no])])
1168 if test "x$grub_cv_target_cc_qn" = xyes; then
1169 TARGET_CFLAGS="$TARGET_CFLAGS -Qn"
1173 # Compiler features.
1176 CFLAGS="$TARGET_CFLAGS"
1178 # Position independent executable.
1180 [# Need that, because some distributions ship compilers that include
1181 # `-fPIE' in the default specs.
1182 if [ x"$pie_possible" = xyes ]; then
1183 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
1186 CFLAGS="$TARGET_CFLAGS"
1188 # Position independent executable.
1190 [# On most platforms we don't want PIC as it only makes relocations harder
1191 # and code less efficient. On mips we want to have one got table per module
1192 # and reload $gp in every function.
1193 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
1194 # However with clang we need PIC for this reloading to happen.
1195 # Since default varies across dictributions use either -fPIC or -fno-PIC
1197 if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then
1198 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
1199 elif [ x"$pic_possible" = xyes ]; then
1200 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
1203 CFLAGS="$TARGET_CFLAGS"
1205 # Smashing stack protector.
1206 grub_CHECK_STACK_PROTECTOR
1207 # Need that, because some distributions ship compilers that include
1208 # `-fstack-protector' in the default specs.
1209 if test "x$ssp_possible" = xyes; then
1210 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
1213 CFLAGS="$TARGET_CFLAGS"
1215 grub_CHECK_STACK_ARG_PROBE
1216 # Cygwin's GCC uses alloca() to probe the stackframe on static
1217 # stack allocations above some threshold.
1218 if test x"$sap_possible" = xyes; then
1219 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
1222 CFLAGS="$TARGET_CFLAGS"
1224 # -mno-unaligned-access -mstrict-align
1225 if test "$target_cpu" = arm; then
1226 AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
1227 grub_cv_target_cc_strict_align=
1228 for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
1229 CFLAGS="$TARGET_CFLAGS $arg -Werror"
1230 LDFLAGS="$TARGET_LDFLAGS"
1231 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
1232 if test x"$flag" = x1; then
1233 grub_cv_target_cc_strict_align="$arg"
1238 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
1239 if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
1240 TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
1242 AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
1243 [CFLAGS="$TARGET_CFLAGS"
1244 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1245 #ifdef __ARM_FEATURE_UNALIGNED
1249 [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
1250 if test x$grub_cv_cc_target_emits_unaligned = xyes; then
1251 AC_MSG_ERROR([compiler generates unaligned accesses])
1255 # Set them to their new values for the tests below.
1257 if test x"$platform" = xemu ; then
1258 CFLAGS="$TARGET_CFLAGS -Wno-error"
1259 elif test "x$TARGET_APPLE_LINKER" = x1 ; then
1260 CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
1262 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
1264 CPPFLAGS="$TARGET_CPPFLAGS"
1267 if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
1268 if test x$grub_cv_asm_uscore = xyes; then
1269 DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
1271 DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main"
1273 CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
1276 # Check for libgcc symbols
1277 if test x"$platform" = xemu; then
1278 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)
1281 if test "x$TARGET_APPLE_LINKER" = x1 ; then
1282 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
1284 CFLAGS="$TARGET_CFLAGS -nostdlib"
1288 # Defined in aclocal.m4.
1290 if test "x$TARGET_APPLE_LINKER" != x1 ; then
1291 grub_PROG_OBJCOPY_ABSOLUTE
1293 grub_PROG_LD_BUILD_ID_NONE
1294 if test "x$target_cpu" = xi386; then
1295 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
1296 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
1297 # Check symbols provided by linker script.
1298 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
1300 grub_CHECK_BSS_START_SYMBOL
1301 grub_CHECK_END_SYMBOL
1303 CFLAGS="$TARGET_CFLAGS"
1307 grub_PROG_NM_MINUS_P
1308 grub_PROG_NM_DEFINED_ONLY
1309 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
1310 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
1312 if test "$platform" != emu; then
1313 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
1314 SAVED_CPPFLAGS="$CPPFLAGS"
1315 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1316 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1318 int va_arg_func (int fixed, va_list args);]], [[]])],
1319 [grub_cv_cc_isystem=yes],
1320 [grub_cv_cc_isystem=no])
1321 CPPFLAGS="$SAVED_CPPFLAGS"
1324 if test x"$grub_cv_cc_isystem" = xyes ; then
1325 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1329 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
1330 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
1331 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1332 int va_arg_func (int fixed, va_list args);]], [[]])],
1333 [grub_cv_cc_wtrampolines=yes],
1334 [grub_cv_cc_wtrampolines=no])
1337 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
1338 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
1341 # Restore the flags.
1343 CFLAGS="$tmp_CFLAGS"
1344 CPPFLAGS="$tmp_CPPFLAGS"
1345 LDFLAGS="$tmp_LDFLAGS"
1349 # Check for options.
1352 # Memory manager debugging.
1353 AC_ARG_ENABLE([mm-debug],
1354 AS_HELP_STRING([--enable-mm-debug],
1355 [include memory manager debugging]),
1356 [AC_DEFINE([MM_DEBUG], [1],
1357 [Define to 1 if you enable memory manager debugging.])])
1359 AC_ARG_ENABLE([cache-stats],
1360 AS_HELP_STRING([--enable-cache-stats],
1361 [enable disk cache statistics collection]))
1363 if test x$enable_cache_stats = xyes; then
1368 AC_SUBST([DISK_CACHE_STATS])
1370 AC_ARG_ENABLE([boot-time],
1371 AS_HELP_STRING([--enable-boot-time],
1372 [enable boot time statistics collection]))
1374 if test x$enable_boot_time = xyes; then
1379 AC_SUBST([BOOT_TIME_STATS])
1381 AC_ARG_ENABLE([grub-emu-sdl],
1382 [AS_HELP_STRING([--enable-grub-emu-sdl],
1383 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
1385 AC_ARG_ENABLE([grub-emu-pci],
1386 [AS_HELP_STRING([--enable-grub-emu-pci],
1387 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
1389 if test "$platform" = emu; then
1391 if test x"$enable_grub_emu_sdl" = xno ; then
1392 grub_emu_sdl_excuse="explicitly disabled"
1394 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1395 # Check for libSDL libraries.]
1396 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1397 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1401 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1402 # Check for headers.]
1403 AC_CHECK_HEADERS([SDL/SDL.h], [],
1404 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1407 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1408 AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
1410 if test x"$grub_emu_sdl_excuse" = x ; then
1411 enable_grub_emu_sdl=yes
1413 enable_grub_emu_sdl=no
1416 if test x"$enable_grub_emu_pci" != xyes ; then
1417 grub_emu_pci_excuse="not enabled"
1420 [if [ x"$grub_emu_pci_excuse" = x ]; then
1421 # Check for libpci libraries.]
1422 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1423 [grub_emu_pci_excuse=["need libpciaccess library"]])
1424 AC_SUBST([LIBPCIACCESS])
1426 [if [ x"$grub_emu_pci_excuse" = x ]; then
1427 # Check for headers.]
1428 AC_CHECK_HEADERS([pciaccess.h], [],
1429 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1432 if test x"$grub_emu_pci_excuse" = x ; then
1433 enable_grub_emu_pci=yes
1436 enable_grub_emu_pci=no
1439 AC_SUBST([enable_grub_emu_sdl])
1440 AC_SUBST([enable_grub_emu_pci])
1444 # Ignore --enable-emu-* if platform is not emu
1445 enable_grub_emu_sdl=no
1446 enable_grub_emu_pci=no
1449 AC_ARG_ENABLE([grub-mkfont],
1450 [AS_HELP_STRING([--enable-grub-mkfont],
1451 [build and install the `grub-mkfont' utility (default=guessed)])])
1452 if test x"$enable_grub_mkfont" = xno ; then
1453 grub_mkfont_excuse="explicitly disabled"
1456 if test x"$grub_mkfont_excuse" = x ; then
1457 # Check for freetype libraries.
1458 AC_CHECK_TOOLS([FREETYPE], [freetype-config])
1459 if test "x$FREETYPE" = x ; then
1460 grub_mkfont_excuse=["need freetype2 library"]
1464 unset ac_cv_header_ft2build_h
1466 if test x"$grub_mkfont_excuse" = x ; then
1467 # Check for freetype libraries.
1468 freetype_cflags=`$FREETYPE --cflags`
1469 freetype_libs=`$FREETYPE --libs`
1470 SAVED_CPPFLAGS="$CPPFLAGS"
1472 CPPFLAGS="$CPPFLAGS $freetype_cflags"
1473 LIBS="$LIBS $freetype_libs"
1474 AC_CHECK_HEADERS([ft2build.h], [],
1475 [grub_mkfont_excuse=["need freetype2 headers"]])
1476 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_mkfont_excuse=["freetype2 library unusable"]])
1477 CPPFLAGS="$SAVED_CPPFLAGS"
1481 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1482 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
1484 if test x"$grub_mkfont_excuse" = x ; then
1485 enable_grub_mkfont=yes
1487 enable_grub_mkfont=no
1489 AC_SUBST([enable_grub_mkfont])
1490 AC_SUBST([freetype_cflags])
1491 AC_SUBST([freetype_libs])
1495 SAVED_CFLAGS="$CFLAGS"
1496 SAVED_CPPFLAGS="$CPPFLAGS"
1497 SAVED_LDFLAGS="$LDFLAGS"
1500 CFLAGS="$BUILD_CFLAGS"
1501 CPPFLAGS="$BUILD_CPPFLAGS"
1502 LDFLAGS="$BUILD_LDFAGS"
1504 unset ac_cv_c_bigendian
1505 unset ac_cv_header_ft2build_h
1507 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1508 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1509 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1511 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1512 AC_MSG_ERROR([couldnt determine build endianness])
1515 AC_SUBST([BUILD_SIZEOF_LONG])
1516 AC_SUBST([BUILD_SIZEOF_VOID_P])
1517 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1519 if test x"$grub_build_mkfont_excuse" = x ; then
1520 # Check for freetype libraries.
1521 AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config])
1522 if test "x$BUILD_FREETYPE" = x ; then
1523 grub_build_mkfont_excuse=["need freetype2 library"]
1527 if test x"$grub_build_mkfont_excuse" = x ; then
1528 # Check for freetype libraries.
1529 build_freetype_cflags=`$BUILD_FREETYPE --cflags`
1530 build_freetype_libs=`$BUILD_FREETYPE --libs`
1531 SAVED_CPPFLAGS_2="$CPPFLAGS"
1533 CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
1534 LIBS="$LIBS $build_freetype_libs"
1535 AC_CHECK_HEADERS([ft2build.h], [],
1536 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1537 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_build_mkfont_excuse=["freetype2 library unusable"]])
1539 CPPFLAGS="$SAVED_CPPFLAGS_2"
1542 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1543 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
1545 if test x"$grub_build_mkfont_excuse" = x ; then
1546 enable_build_grub_mkfont=yes
1548 enable_build_grub_mkfont=no
1550 if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
1551 if test x"$grub_build_mkfont_excuse" = x ; then
1552 AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont])
1554 AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont ($grub_build_mkfont_excuse)])
1558 AC_SUBST([build_freetype_cflags])
1559 AC_SUBST([build_freetype_libs])
1563 CFLAGS="$SAVED_CFLAGS"
1564 CPPFLAGS="$SAVED_CPPFLAGS"
1565 LDFLAGS="$SAVED_LDFLAGS"
1572 AC_ARG_ENABLE([grub-themes],
1573 [AS_HELP_STRING([--enable-grub-themes],
1574 [build and install GRUB themes (default=guessed)])])
1575 if test x"$enable_grub_themes" = xno ; then
1576 starfield_excuse="explicitly disabled"
1579 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1580 starfield_excuse="No build-time grub-mkfont"
1583 if test x"$starfield_excuse" = x; then
1584 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1585 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
1586 if test -f "$dir/DejaVuSans.$ext"; then
1587 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1593 if test "x$DJVU_FONT_SOURCE" = x; then
1594 starfield_excuse="No DejaVu found"
1598 if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1599 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
1602 AC_SUBST([DJVU_FONT_SOURCE])
1606 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1607 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
1608 if test -f "$dir/unifont.$ext"; then
1609 md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
1610 # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
1611 if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
1614 FONT_SOURCE="$dir/unifont.$ext"
1620 if test x"$enable_build_grub_mkfont" = xno ; then
1624 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
1625 if test x"$grub_build_mkfont_excuse" = x ; then
1626 AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont])
1628 AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
1632 AC_SUBST([FONT_SOURCE])
1634 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1635 grub_build_mkfont_excuse="no fonts"
1639 AC_ARG_ENABLE([grub-mount],
1640 [AS_HELP_STRING([--enable-grub-mount],
1641 [build and install the `grub-mount' utility (default=guessed)])])
1642 if test x"$enable_grub_mount" = xno ; then
1643 grub_mount_excuse="explicitly disabled"
1646 if test x"$grub_mount_excuse" = x ; then
1647 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1648 [grub_mount_excuse="need FUSE library"])
1651 if test x"$grub_mount_excuse" = x ; then
1652 # Check for fuse headers.
1653 SAVED_CPPFLAGS="$CPPFLAGS"
1654 CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
1655 AC_CHECK_HEADERS([fuse/fuse.h], [],
1656 [grub_mount_excuse=["need FUSE headers"]])
1657 CPPFLAGS="$SAVED_CPPFLAGS"
1660 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1661 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
1663 if test x"$grub_mount_excuse" = x ; then
1664 enable_grub_mount=yes
1666 enable_grub_mount=no
1668 AC_SUBST([enable_grub_mount])
1670 AC_ARG_ENABLE([device-mapper],
1671 [AS_HELP_STRING([--enable-device-mapper],
1672 [enable Linux device-mapper support (default=guessed)])])
1673 if test x"$enable_device_mapper" = xno ; then
1674 device_mapper_excuse="explicitly disabled"
1677 if test x"$device_mapper_excuse" = x ; then
1678 # Check for device-mapper header.
1679 AC_CHECK_HEADER([libdevmapper.h], [],
1680 [device_mapper_excuse="need libdevmapper header"])
1683 if test x"$device_mapper_excuse" = x ; then
1684 # Check for device-mapper library.
1685 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1686 [device_mapper_excuse="need devmapper library"])
1689 if test x"$device_mapper_excuse" = x ; then
1690 # Check for device-mapper library.
1691 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1693 [device_mapper_excuse="need devmapper library"])
1696 if test x"$device_mapper_excuse" = x ; then
1697 LIBDEVMAPPER="-ldevmapper"
1698 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1699 [Define to 1 if you have the devmapper library.])
1702 AC_SUBST([LIBDEVMAPPER])
1705 if test x$host_kernel = xkfreebsd; then
1706 AC_CHECK_LIB([geom], [geom_gettree], [],
1707 [AC_MSG_ERROR([Your platform requires libgeom])])
1713 AC_ARG_ENABLE([liblzma],
1714 [AS_HELP_STRING([--enable-liblzma],
1715 [enable liblzma integration (default=guessed)])])
1716 if test x"$enable_liblzma" = xno ; then
1717 liblzma_excuse="explicitly disabled"
1720 if test x"$liblzma_excuse" = x ; then
1721 AC_CHECK_LIB([lzma], [lzma_code],
1722 [],[liblzma_excuse="need lzma library"])
1724 if test x"$liblzma_excuse" = x ; then
1725 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1728 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1729 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
1733 if test x"$liblzma_excuse" = x ; then
1735 AC_DEFINE([USE_LIBLZMA], [1],
1736 [Define to 1 if you have the LZMA library.])
1741 AC_ARG_ENABLE([libzfs],
1742 [AS_HELP_STRING([--enable-libzfs],
1743 [enable libzfs integration (default=guessed)])])
1744 if test x"$enable_libzfs" = xno ; then
1745 libzfs_excuse="explicitly disabled"
1748 if test x"$libzfs_excuse" = x ; then
1749 # Only check for system headers if libzfs support has not been disabled.
1750 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1753 if test x"$libzfs_excuse" = x ; then
1754 AC_CHECK_LIB([zfs], [libzfs_init],
1756 [libzfs_excuse="need zfs library"])
1759 if test x"$libzfs_excuse" = x ; then
1760 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1762 [libzfs_excuse="need nvpair library"])
1765 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1766 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
1769 if test x"$libzfs_excuse" = x ; then
1770 # We need both libzfs and libnvpair for a successful build.
1772 AC_DEFINE([HAVE_LIBZFS], [1],
1773 [Define to 1 if you have the ZFS library.])
1774 LIBNVPAIR="-lnvpair"
1775 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1776 [Define to 1 if you have the NVPAIR library.])
1780 AC_SUBST([LIBNVPAIR])
1784 AC_SUBST([FONT_SOURCE])
1785 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1786 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1788 AC_SUBST(HAVE_ASM_USCORE)
1789 AC_SUBST(BSS_START_SYMBOL)
1790 AC_SUBST(END_SYMBOL)
1794 AC_ARG_ENABLE([werror],
1795 [AS_HELP_STRING([--disable-werror],
1796 [do not use -Werror when building GRUB])])
1797 if test x"$enable_werror" != xno ; then
1798 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1799 HOST_CFLAGS="$HOST_CFLAGS -Werror"
1802 TARGET_CPP="$TARGET_CC -E"
1803 TARGET_CCAS=$TARGET_CC
1805 # Includes which include make-time substitutions. They must come last
1806 # as to avoid executing top_builddir in shell.
1807 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
1808 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
1809 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
1811 GRUB_TARGET_CPU="${target_cpu}"
1812 GRUB_PLATFORM="${platform}"
1814 AC_SUBST(GRUB_TARGET_CPU)
1815 AC_SUBST(GRUB_PLATFORM)
1817 AC_SUBST(TARGET_OBJCONV)
1818 AC_SUBST(TARGET_CPP)
1819 AC_SUBST(TARGET_CCAS)
1820 AC_SUBST(TARGET_OBJ2ELF)
1821 AC_SUBST(TARGET_MODULE_FORMAT)
1822 AC_SUBST(TARGET_CC_VERSION)
1824 AC_SUBST(TARGET_CFLAGS)
1825 AC_SUBST(TARGET_LDFLAGS)
1826 AC_SUBST(TARGET_CPPFLAGS)
1827 AC_SUBST(TARGET_CCASFLAGS)
1829 AC_SUBST(TARGET_IMG_LDFLAGS)
1830 AC_SUBST(TARGET_IMG_CFLAGS)
1831 AC_SUBST(TARGET_IMG_BASE_LDOPT)
1832 AC_SUBST(TARGET_APPLE_LINKER)
1834 AC_SUBST(HOST_CFLAGS)
1835 AC_SUBST(HOST_LDFLAGS)
1836 AC_SUBST(HOST_CPPFLAGS)
1837 AC_SUBST(HOST_CCASFLAGS)
1839 AC_SUBST(BUILD_LIBM)
1842 # Automake conditionals
1845 AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
1846 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1847 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1848 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1849 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1850 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1851 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1852 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1853 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1854 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1855 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1856 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
1857 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1858 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1859 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1860 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1861 AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
1862 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1863 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1864 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1865 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1866 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1867 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1868 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1869 AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
1870 AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
1872 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1873 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1874 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1875 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1876 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1877 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1878 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1880 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1881 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1882 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1883 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1884 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1885 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1886 if test x$FONT_SOURCE != x ; then
1891 AC_SUBST(HAVE_FONT_SOURCE)
1892 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
1893 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1894 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1895 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1897 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1899 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1900 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1901 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
1903 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
1904 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
1905 datarootdir="$(eval echo "$datarootdir")"
1906 grub_libdir="$(eval echo "$libdir")"
1907 grub_localedir="$(eval echo "$localedir")"
1908 grub_datadir="$(eval echo "$datadir")"
1909 grub_sysconfdir="$(eval echo "$sysconfdir")"
1910 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
1911 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
1912 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
1913 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
1917 if test "$platform" != none; then
1918 cpudir="${target_cpu}"
1919 if test x${cpudir} = xmipsel; then
1923 if test x"$link_dir" = xyes ; then
1924 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1925 if test "$platform" != emu ; then
1926 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1929 mkdir -p include/grub 2>/dev/null
1930 rm -rf include/grub/cpu
1931 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1932 if test "$platform" != emu ; then
1933 rm -rf include/grub/machine
1934 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1938 # Just enough to stop the compiler failing with -I$(srcdir)/include.
1939 mkdir -p include 2>/dev/null
1940 rm -rf include/grub/cpu include/grub/machine
1943 AC_CONFIG_FILES([Makefile])
1944 AC_CONFIG_FILES([grub-core/Makefile])
1945 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1946 AC_CONFIG_FILES([po/Makefile.in])
1947 AC_CONFIG_FILES([docs/Makefile])
1948 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1949 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1950 AC_CONFIG_FILES([config.h])
1954 echo "*******************************************************"
1955 echo GRUB2 will be compiled with following components:
1956 echo Platform: "$target_cpu"-"$platform"
1957 if [ x"$platform" = xemu ]; then
1958 if [ x"$grub_emu_sdl_excuse" = x ]; then
1959 echo SDL support for grub-emu: Yes
1961 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1963 if [ x"$grub_emu_pci_excuse" = x ]; then
1964 echo PCI support for grub-emu: Yes
1966 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1969 if test x"$device_mapper_excuse" = x ; then
1970 echo With devmapper support: Yes
1972 echo With devmapper support: No "($device_mapper_excuse)"
1974 if [ x"$enable_mm_debug" = xyes ]; then
1975 echo With memory debugging: Yes
1977 echo With memory debugging: No
1979 if [ x"$enable_cache_stats" = xyes ]; then
1980 echo With disk cache statistics: Yes
1982 echo With disk cache statistics: No
1985 if [ x"$enable_boot_time" = xyes ]; then
1986 echo With boot time statistics: Yes
1988 echo With boot time statistics: No
1991 if [ x"$efiemu_excuse" = x ]; then
1992 echo efiemu runtime: Yes
1994 echo efiemu runtime: No "($efiemu_excuse)"
1996 if [ x"$grub_mkfont_excuse" = x ]; then
1997 echo grub-mkfont: Yes
1999 echo grub-mkfont: No "($grub_mkfont_excuse)"
2001 if [ x"$grub_mount_excuse" = x ]; then
2002 echo grub-mount: Yes
2004 echo grub-mount: No "($grub_mount_excuse)"
2006 if [ x"$starfield_excuse" = x ]; then
2007 echo starfield theme: Yes
2008 echo With DejaVuSans font from $DJVU_FONT_SOURCE
2010 echo starfield theme: No "($starfield_excuse)"
2012 if [ x"$libzfs_excuse" = x ]; then
2013 echo With libzfs support: Yes
2015 echo With libzfs support: No "($libzfs_excuse)"
2017 if [ x"$grub_build_mkfont_excuse" = x ]; then
2018 echo Build-time grub-mkfont: Yes
2019 if test "x$FONT_SOURCE" = x ; then
2020 echo "Without unifont"
2022 echo "With unifont from $FONT_SOURCE"
2025 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
2026 echo "Without unifont (no build-time grub-mkfont)"
2028 if test x"$liblzma_excuse" != x ; then
2029 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
2031 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
2033 echo "*******************************************************"