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 # Explicitly check for pkg-config early on, since otherwise conditional
54 # calls are problematic.
57 # Program name transformations
59 grub_TRANSFORM([grub-bios-setup])
60 grub_TRANSFORM([grub-editenv])
61 grub_TRANSFORM([grub-install])
62 grub_TRANSFORM([grub-mkconfig])
63 grub_TRANSFORM([grub-mkfont])
64 grub_TRANSFORM([grub-mkimage])
65 grub_TRANSFORM([grub-glue-efi])
66 grub_TRANSFORM([grub-mklayout])
67 grub_TRANSFORM([grub-mkpasswd-pbkdf2])
68 grub_TRANSFORM([grub-mkrelpath])
69 grub_TRANSFORM([grub-mkrescue])
70 grub_TRANSFORM([grub-probe])
71 grub_TRANSFORM([grub-reboot])
72 grub_TRANSFORM([grub-script-check])
73 grub_TRANSFORM([grub-set-default])
74 grub_TRANSFORM([grub-sparc64-setup])
75 grub_TRANSFORM([grub-render-label])
76 grub_TRANSFORM([grub-file])
78 # Optimization flag. Allow user to override.
79 if test "x$TARGET_CFLAGS" = x; then
80 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
83 # Default HOST_CPPFLAGS
84 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
85 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
87 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
90 i[[3456]]86) target_cpu=i386 ;;
91 amd64) target_cpu=x86_64 ;;
92 sparc) target_cpu=sparc64 ;;
95 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
99 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
109 # Specify the platform (such as firmware).
110 AC_ARG_WITH([platform],
111 AS_HELP_STRING([--with-platform=PLATFORM],
112 [select the host platform [[guessed]]]))
114 # Guess the platform if not specified.
115 if test "x$with_platform" = x; then
116 case "$target_cpu"-"$target_vendor" in
117 i386-apple) platform=efi ;;
118 i386-*) platform=pc ;;
119 x86_64-apple) platform=efi ;;
120 x86_64-*) platform=pc ;;
121 powerpc-*) platform=ieee1275 ;;
122 powerpc64-*) platform=ieee1275 ;;
123 powerpc64le-*) platform=ieee1275 ;;
124 sparc64-*) platform=ieee1275 ;;
125 mipsel-*) platform=loongson ;;
126 mips-*) platform=arc ;;
127 ia64-*) platform=efi ;;
128 arm-*) platform=uboot ;;
129 arm64-*) platform=efi ;;
131 AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
136 platform="$with_platform"
139 case "$target_cpu"-"$platform" in
144 x86_64-*) target_cpu=i386 ;;
145 powerpc64-ieee1275) target_cpu=powerpc ;;
146 powerpc64le-ieee1275) target_cpu=powerpc ;;
149 # Check if the platform is supported, make final adjustments.
150 case "$target_cpu"-"$platform" in
158 i386-linuxbios) platform=coreboot ;;
165 mips-qemu-mips) platform=qemu_mips;;
169 mipsel-qemu-mips) platform=qemu_mips;;
170 mipsel-yeeloong) platform=loongson ;;
171 mipsel-fuloong) platform=loongson ;;
179 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
182 if test x$platform != xemu ; then
183 case "$target_cpu" in
184 i386 | powerpc) target_m32=1 ;;
185 x86_64 | sparc64) target_m64=1 ;;
189 if test x"$target_cpu-$platform" = xsparc64-emu ; then
194 windows* | mingw32*) target_os=cygwin ;;
197 # This normalizes the names, and creates a new variable ("host_kernel")
198 # while at it, since the mapping is not always 1:1 (e.g. different OSes
199 # using the same kernel type).
201 gnu*) host_kernel=hurd ;;
202 linux*) host_kernel=linux ;;
203 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
204 netbsd*) host_kernel=netbsd ;;
205 solaris*) host_kernel=illumos ;;
206 darwin*) host_kernel=xnu ;;
207 cygwin | windows* | mingw32*) host_kernel=windows ;;
211 cygwin) have_exec=y ;;
212 windows* | mingw32*) have_exec=n ;;
213 aros*) have_exec=n ;;
218 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
219 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
220 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
221 xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
222 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
223 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
224 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
225 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
226 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
227 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
228 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
229 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
231 if test x${target_cpu} = xmipsel ; then
232 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
234 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
237 case "${target_cpu}-$platform" in
239 TARGET_LINK_ADDR=0x88200000
240 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
243 TARGET_LINK_ADDR=0x80700000
244 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
246 mips*-qemu_mips | mips*-loongson)
247 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
251 AC_SUBST(TARGET_LINK_ADDR)
252 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
254 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
258 AC_SUBST(host_kernel)
263 # Define default variables
266 AC_ARG_WITH([bootdir],
267 AS_HELP_STRING([--with-bootdir=DIR],
268 [set the name of /boot directory [[guessed]]]),
269 [have_with_bootdir=y],
270 [have_with_bootdir=n])
271 if test x$have_with_bootdir = xy; then
272 bootdirname="$with_bootdir"
276 # Because /boot is used for the boot block in NetBSD and OpenBSD,
278 *) bootdirname='boot' ;;
282 AC_SUBST(bootdirname)
283 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
284 [Default boot directory name])
286 AC_ARG_WITH([grubdir],
287 AS_HELP_STRING([--with-grubdir=DIR],
288 [set the name of grub directory [[guessed]]]),
289 [grubdirname="$with_grubdir"],
290 [grubdirname="$PACKAGE"])
292 AC_SUBST(grubdirname)
293 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
294 [Default grub directory name])
297 # Checks for build programs.
300 # Although cmp is listed in the GNU Coding Standards as a command which
301 # can used directly, OpenBSD lacks cmp in the default installation.
302 AC_CHECK_PROGS([CMP], [cmp])
303 if test "x$CMP" = x; then
304 AC_MSG_ERROR([cmp is not found])
307 AC_CHECK_PROGS([YACC], [bison])
308 if test "x$YACC" = x; then
309 AC_MSG_ERROR([bison is not found])
321 if test "x$LEX" = "x:"; then
322 AC_MSG_ERROR([flex is not found])
324 version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
325 if test -n "$version" -a "$version" -ge 20535; then
328 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
332 # These are not a "must".
333 AC_PATH_PROGS(MAKEINFO, makeinfo true)
336 # Checks for host programs.
344 AM_PATH_PYTHON([2.6])
347 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
349 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
352 AM_GNU_GETTEXT([external])
355 # Identify characteristics of the host architecture.
356 unset ac_cv_c_bigendian
358 if test x"$target_cpu-$platform" = xsparc64-emu ; then
359 CFLAGS="$CFLAGS -m64"
360 HOST_CFLAGS="$HOST_CFLAGS -m64"
363 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
364 HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
367 AC_CHECK_SIZEOF(void *)
368 AC_CHECK_SIZEOF(long)
371 cygwin | windows* | mingw32*)
372 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
373 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
374 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
379 cygwin | windows* | mingw32* | aros*)
382 AC_CHECK_SIZEOF(off_t)
383 if test x"$ac_cv_sizeof_off_t" != x8 ; then
384 AC_CHECK_SIZEOF(off64_t)
385 test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required])
389 if test x$USE_NLS = xno; then
390 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
393 if test "x$cross_compiling" = xyes; then
394 AC_MSG_WARN([cannot generate manual pages while cross compiling])
396 AC_PATH_PROG(HELP2MAN, help2man)
399 # Check for functions and headers.
400 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
401 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
403 # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
404 # warning which causes compilation failure later with -Werror. So use -Werror here
405 # as well to force proper sys/sysmacros.h detection.
406 SAVED_CFLAGS="$CFLAGS"
407 CFLAGS="$HOST_CFLAGS -Werror"
409 CFLAGS="$SAVED_CFLAGS"
411 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
412 #include <sys/param.h>
413 #include <sys/mount.h>])
415 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
416 #include <sys/param.h>
417 #include <sys/mount.h>])
419 # For opendisk() and getrawpartition() on NetBSD.
420 # Used in util/deviceiter.c and in util/hostdisk.c.
421 AC_CHECK_HEADER([util.h], [
422 AC_CHECK_LIB([util], [opendisk], [
424 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
426 AC_CHECK_LIB([util], [getrawpartition], [
428 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
433 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
434 SAVED_CFLAGS="$CFLAGS"
435 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
436 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
437 int va_arg_func (int fixed, va_list args);]], [[]])],
438 [grub_cv_host_cc_wtrampolines=yes],
439 [grub_cv_host_cc_wtrampolines=no])
440 CFLAGS="$SAVED_CFLAGS"
443 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
444 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
448 # Check for host and build compilers.
451 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
452 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
453 BUILD_CPP="$BUILD_CC -E"
456 haiku*) BUILD_LIBM= ;;
460 dnl FIXME proper test seems to require too deep dive into Autoconf internals.
461 dnl For now just list known platforms that we support.
464 cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
467 AC_SUBST(BUILD_EXEEXT)
469 # In some build environments like termux /bin/sh is not a valid
470 # shebang. Use $SHELL instead if it's executable and /bin/sh isn't
471 BUILD_SHEBANG=/bin/sh
472 for she in /bin/sh "$SHELL"; do
473 if test -x "$she" ; then
477 AC_SUBST(BUILD_SHEBANG)
482 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"
483 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"
485 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
487 AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
488 SAVED_CFLAGS="$CFLAGS"
489 grub_cv_cc_w_extra_flags=
490 for x in $EXTRA_WARN_FLAGS; do
491 CFLAGS="$HOST_CFLAGS $x -Werror"
492 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
493 if test x$flag = x1 ; then
494 grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
497 CFLAGS="$SAVED_CFLAGS"
500 HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
503 # Check for target programs.
506 # Find tools for the target.
507 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
508 tmp_ac_tool_prefix="$ac_tool_prefix"
509 ac_tool_prefix=$target_alias-
511 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
512 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
513 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
514 AC_CHECK_TOOL(TARGET_STRIP, strip)
515 AC_CHECK_TOOL(TARGET_NM, nm)
516 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
518 ac_tool_prefix="$tmp_ac_tool_prefix"
520 if test "x$TARGET_CC" = x; then
523 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
524 AC_CHECK_TOOL(TARGET_STRIP, strip)
525 AC_CHECK_TOOL(TARGET_NM, nm)
526 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
531 AC_SUBST(BUILD_CFLAGS)
532 AC_SUBST(BUILD_CPPFLAGS)
533 AC_SUBST(BUILD_LDFLAGS)
536 AC_SUBST(TARGET_RANLIB)
537 AC_SUBST(TARGET_STRIP)
538 AC_SUBST(TARGET_OBJCOPY)
540 # Test the C compiler for the target environment.
543 tmp_LDFLAGS="$LDFLAGS"
544 tmp_CPPFLAGS="$CPPFLAGS"
547 CFLAGS="$TARGET_CFLAGS"
548 CPPFLAGS="$TARGET_CPPFLAGS"
549 LDFLAGS="$TARGET_LDFLAGS"
553 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
554 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
556 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
557 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
560 TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
562 AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
563 LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
565 grub_cv_target_cc_w_extra_flags=
566 for x in $EXTRA_WARN_FLAGS; do
567 CFLAGS="$TARGET_CFLAGS $x -Werror"
568 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
569 asm (".globl start; start:");
571 void __main (void) {}
573 ]], [[]])], [flag=1], [flag=0])
574 if test x$flag = x1 ; then
575 grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
580 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
582 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
584 CFLAGS="$TARGET_CFLAGS"
586 [AC_LANG_PROGRAM([], [[
591 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
593 if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
594 AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
595 grub_cv_target_cc_big_endian=no
596 for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
597 "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
598 "-EB" "-mbig-endian"; do
599 if test x"$grub_cv_target_cc_big_endian" != xno ; then
602 CFLAGS="$TARGET_CFLAGS $cand -Werror"
603 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
604 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
605 #error still little endian
607 asm (".globl start; start:");
608 asm (".globl _start; _start:");
609 asm (".globl __start; __start:");
611 void __main (void) {}
614 [grub_cv_target_cc_big_endian="$cand"], [])
618 if test x"$grub_cv_target_cc_big_endian" = xno ; then
619 AC_MSG_ERROR([could not force big-endian])
622 skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
624 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
625 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
626 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
627 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
628 elif test x$target_cpu = xmipsel; then
629 AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
630 grub_cv_target_cc_little_endian=no
631 for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
632 "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
634 if test x"$grub_cv_target_cc_little_endian" != xno ; then
637 CFLAGS="$TARGET_CFLAGS $cand -Werror"
638 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
639 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
640 #error still big endian
642 asm (".globl start; start:");
643 asm (".globl _start; _start:");
644 asm (".globl __start; __start:");
646 void __main (void) {}
649 [grub_cv_target_cc_little_endian="$cand"], [])
653 if test x"$grub_cv_target_cc_little_endian" = xno ; then
654 AC_MSG_ERROR([could not force little-endian])
657 skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
659 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
660 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
661 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
662 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
665 # GRUB code is N32-compliant but it's experimental and we would prefer to
666 # avoid having too much variety when it doesn't result in any real improvement.
667 # Moreover N64 isn't supported.
668 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
669 AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
670 grub_cv_target_cc_mips_o32_abi=no
671 for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
672 if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
675 CFLAGS="$TARGET_CFLAGS $arg -Werror"
676 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
677 #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
680 asm (".globl start; start:");
681 asm (".globl _start; _start:");
682 asm (".globl __start; __start:");
684 void __main (void) {}
687 [grub_cv_target_cc_mips_o32_abi="$arg"], [])
691 if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
692 AC_MSG_ERROR([could not force MIPS o32 ABI])
695 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
696 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
699 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
701 case "x$target_cpu-$platform" in
711 xpowerpc-* | xsparc64-* | xarm-*)
712 test_program=$target_cpu
715 if test x"$test_program" = x ; then
716 grub_cv_cc_target_asm_compile=
719 for arg in "" "-no-integrated-as"; do
720 cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
721 echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
722 if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
723 grub_cv_cc_target_asm_compile="$arg"
728 if test x"$found" = xno ; then
729 AC_MSG_ERROR([could not compile assembly])
734 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
736 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
737 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
740 if test "x$target_m32" = x1; then
742 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
743 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
744 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
745 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
746 TARGET_MODULE_FORMAT="elf32"
749 if test "x$target_m64" = x1; then
751 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
752 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
753 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
754 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
755 TARGET_MODULE_FORMAT="elf64"
758 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
759 TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
762 # on mips redirect cache flushing function to non-existant one.
763 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
764 AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
765 CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
766 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
767 [grub_cv_cc_mflush_func=yes],
768 [grub_cv_cc_mflush_func=no])
771 if test "x$grub_cv_cc_mflush_func" = xyes; then
772 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
777 # Force no alignment to save space on i386.
778 if test "x$target_cpu" = xi386; then
779 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
780 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
781 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
782 [grub_cv_cc_falign_loop=yes],
783 [grub_cv_cc_falign_loop=no])
786 AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
787 CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
788 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
789 [grub_cv_cc_malign_loop=yes],
790 [grub_cv_cc_malign_loop=no])
793 if test "x$grub_cv_cc_falign_loop" = xyes; then
794 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
795 elif test "x$grub_cv_cc_malign_loop" = xyes; then
796 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
800 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
801 CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
802 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
803 [grub_cv_cc_freg_struct_return=yes],
804 [grub_cv_cc_freg_struct_return=no])
807 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
808 TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
811 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
812 # Some toolchains enable these features by default, but they need
813 # registers that aren't set up properly in GRUB.
814 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
817 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
818 # that floats are a good fit to run instead of what's written in the code.
819 # Given that floating point unit is disabled (if present to begin with)
820 # when GRUB is running which may result in various hard crashes.
821 if test x"$platform" != xemu ; then
822 AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
823 grub_cv_target_cc_soft_float=no
824 if test "x$target_cpu" = xarm64; then
825 CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
826 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
827 [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
829 if test "x$target_cpu" = xia64; then
830 CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
831 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
832 [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
834 for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
835 "-Xclang -msoft-float -Xclang -no-implicit-float" \
836 "-Xclang -msoft-float" "-msoft-float"; do
837 if test x"$grub_cv_target_cc_soft_float" != xno ; then
840 CFLAGS="$TARGET_CFLAGS $cand -Werror"
841 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
842 [grub_cv_target_cc_soft_float="$cand"], [])
846 if test x"$grub_cv_target_cc_soft_float" = xno ; then
847 AC_MSG_ERROR([could not force soft-float])
850 case x"$grub_cv_target_cc_soft_float" in
852 # A trick so that clang doesn't see it on link stаge
853 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
856 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
859 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
863 if test x"$target_cpu" = xsparc64 ; then
864 AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
865 grub_cv_target_cc_mno_app_regs=no
866 for cand in "-mllvm -sparc-reserve-app-registers" \
868 if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
871 CFLAGS="$TARGET_CFLAGS $cand -Werror"
872 CPPFLAGS="$TARGET_CPPFLAGS"
873 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
874 [grub_cv_target_cc_mno_app_regs="$cand"], [])
878 if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
879 AC_MSG_ERROR([could not reserve application registers])
881 if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
882 # A trick so that clang doesn't see it on link stаge
883 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
885 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
888 AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
889 grub_cv_target_cc_mno_relax=no
890 for cand in "-mno-relax" "-Wl,--no-relax"; do
891 if test x"$grub_cv_target_cc_mno_relax" != xno ; then
894 LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
895 CFLAGS="$TARGET_CFLAGS -Werror"
896 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
897 asm (".globl start; start:");
899 void __main (void) {}
901 ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
904 LDFLAGS="$TARGET_LDFLAGS"
905 CFLAGS="$TARGET_CFLAGS"
907 if test x"$grub_cv_target_cc_mno_relax" = xno ; then
908 AC_MSG_ERROR([could not find no-relax options])
910 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
913 # By default, GCC 4.4 generates .eh_frame sections containing unwind
914 # information in some cases where it previously did not. GRUB doesn't need
915 # these and they just use up vital space. Restore the old compiler
917 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
918 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
919 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
920 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
921 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
924 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
925 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
928 if test x"$target_os" = xcygwin; then
929 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
930 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
931 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
932 [grub_cv_cc_no_reorder_functions=yes],
933 [grub_cv_cc_no_reorder_functions=no])
937 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
938 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
941 AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
942 CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
943 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
944 [grub_cv_cc_mno_stack_arg_probe=yes],
945 [grub_cv_cc_mno_stack_arg_probe=no])
948 if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
949 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
953 # By default, GCC 4.6 generates .eh_frame sections containing unwind
954 # information in some cases where it previously did not. GRUB doesn't need
955 # these and they just use up vital space. Restore the old compiler
957 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
958 CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
959 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
960 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
961 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
964 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
965 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
968 AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
969 CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
970 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
971 [grub_cv_cc_fno_unwind_tables=yes],
972 [grub_cv_cc_fno_unwind_tables=no])
975 if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
976 TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
980 CFLAGS="$TARGET_CFLAGS"
983 if test x"$platform" = xemu ; then
985 grub_cv_target_cc_link_format=
988 grub_cv_target_cc_link_format="-arch,${target_cpu}"
989 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
991 *windows* | *cygwin* | *mingw*)
992 if test x${target_cpu} = xi386 ; then
993 grub_cv_target_cc_link_format=-mi386pe
994 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
996 if test x${target_cpu} = xx86_64 ; then
997 grub_cv_target_cc_link_format=-mi386pep
998 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1000 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1003 elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
1004 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
1005 grub_cv_target_cc_link_format=unknown
1006 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
1007 if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
1010 if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
1013 CFLAGS="$TARGET_CFLAGS"
1014 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
1015 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1016 asm (".globl start; start:");
1017 asm (".globl _start; _start:");
1018 asm (".globl __start; __start:");
1020 void __main (void) {}
1021 ]], [[]])], [flag=1], [flag=0])
1022 if test x"$flag" = x1; then
1023 grub_cv_target_cc_link_format="$format"
1027 if test x"$grub_cv_target_cc_link_format" = xunknown; then
1028 AC_MSG_ERROR([no suitable link format found])
1030 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1031 if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
1032 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1034 if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1035 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1039 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
1040 TARGET_APPLE_LINKER=1
1041 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
1042 if test "x$TARGET_OBJCONV" = x ; then
1043 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
1045 if test "x$TARGET_OBJCONV" = x ; then
1046 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
1048 TARGET_IMG_LDSCRIPT=
1049 TARGET_IMG_CFLAGS="-static"
1050 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1051 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1052 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
1053 TARGET_LDFLAGS_OLDMAGIC=""
1054 elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
1055 TARGET_APPLE_LINKER=0
1056 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1057 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1058 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
1059 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1060 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1063 TARGET_APPLE_LINKER=0
1064 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1065 TARGET_IMG_LDSCRIPT=
1066 TARGET_IMG_LDFLAGS='-Wl,-N'
1067 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
1068 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1072 CFLAGS="$TARGET_CFLAGS"
1074 AC_ARG_ENABLE([efiemu],
1075 [AS_HELP_STRING([--enable-efiemu],
1076 [build and install the efiemu runtimes (default=guessed)])])
1077 if test x"$enable_efiemu" = xno ; then
1078 efiemu_excuse="explicitly disabled"
1081 if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1082 efiemu_excuse="not available on cygwin"
1084 if test x"$target_cpu" != xi386 ; then
1085 efiemu_excuse="only available on i386"
1087 if test x"$platform" = xefi ; then
1088 efiemu_excuse="not available on efi"
1091 if test x"$efiemu_excuse" = x ; then
1092 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
1093 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1094 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1095 [grub_cv_cc_efiemu=yes],
1096 [grub_cv_cc_efiemu=no])
1098 if test x$grub_cv_cc_efiemu = xno; then
1099 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
1102 if test x"$efiemu_excuse" = x ; then
1103 AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
1104 grub_cv_target_cc_efiemu64_link_format=unknown
1105 for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
1106 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1107 LDFLAGS="-m64 -Wl,$format -nostdlib -static"
1108 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1109 asm (".globl start; start:");
1110 asm (".globl _start; _start:");
1111 asm (".globl __start; __start:");
1113 void __main (void) {}
1114 ]], [[]])], [flag=1], [flag=0])
1115 if test x"$flag" = x1; then
1116 grub_cv_target_cc_efiemu64_link_format="$format"
1120 if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
1121 efiemu_excuse="no suitable link format for efiemu64 found"
1123 EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
1126 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
1127 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
1129 if test x"$efiemu_excuse" = x ; then
1134 AC_SUBST([enable_efiemu])
1135 AC_SUBST([EFIEMU64_LINK_FORMAT])
1137 CFLAGS="$TARGET_CFLAGS"
1139 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
1142 LDFLAGS="$TARGET_LDFLAGS"
1144 if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
1145 # Use large model to support 4G memory
1146 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
1147 CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1148 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1149 [grub_cv_cc_mcmodel=yes],
1150 [grub_cv_cc_mcmodel=no])
1152 if test "x$grub_cv_cc_mcmodel" = xyes; then
1153 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1154 elif test "$target_cpu" = sparc64; then
1155 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
1159 if test "$target_cpu"-"$platform" = x86_64-efi; then
1160 # EFI writes to stack below %rsp, we must not use the red zone
1161 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
1162 CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1163 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1164 [grub_cv_cc_no_red_zone=yes],
1165 [grub_cv_cc_no_red_zone=no])
1167 if test "x$grub_cv_cc_no_red_zone" = xno; then
1168 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
1171 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1174 if test "x$target_cpu" = xarm; then
1175 AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [
1176 grub_cv_target_cc_mno_movt=no
1177 for cand in "-mno-movt" \
1178 "-mllvm -arm-use-movt=0"; do
1179 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1182 CFLAGS="$TARGET_CFLAGS $cand -Werror"
1183 CPPFLAGS="$TARGET_CPPFLAGS"
1184 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1185 [grub_cv_target_cc_mno_movt="$cand"], [])
1189 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1190 # A trick so that clang doesn't see it on link stage
1191 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt"
1193 AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
1194 CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
1195 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1196 [grub_cv_cc_mthumb_interwork=yes],
1197 [grub_cv_cc_mthumb_interwork=no])
1199 if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
1200 TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
1201 # Clang defaults to thumb interworking
1202 elif test "x$grub_cv_cc_target_clang" = xno ; then
1203 AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
1207 AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
1208 CFLAGS="$TARGET_CFLAGS -Qn -Werror"
1209 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1210 [grub_cv_target_cc_qn=yes],
1211 [grub_cv_target_cc_qn=no])])
1212 if test "x$grub_cv_target_cc_qn" = xyes; then
1213 TARGET_CFLAGS="$TARGET_CFLAGS -Qn"
1217 # Compiler features.
1220 CFLAGS="$TARGET_CFLAGS"
1222 # Position independent executable.
1225 grub_CHECK_NO_PIE_ONEWORD
1227 [# Need that, because some distributions ship compilers that include
1228 # `-fPIE' or '-fpie' and '-pie' in the default specs.
1229 if [ x"$pie_possible" = xyes ]; then
1230 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
1233 if [ x"$link_nopie_needed" = xyes ] || [ x"$pie_possible" = xyes ]; then
1234 if [ x"$nopie_possible" = xyes ]; then
1235 TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
1237 if [ x"$nopie_oneword_possible" = xyes ]; then
1238 TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie"
1242 CFLAGS="$TARGET_CFLAGS"
1243 LDFLAGS="$TARGET_LDFLAGS"
1245 # Position independent executable.
1247 [# On most platforms we don't want PIC as it only makes relocations harder
1248 # and code less efficient. On mips we want to have one got table per module
1249 # and reload $gp in every function.
1250 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
1251 # However with clang we need PIC for this reloading to happen.
1252 # With arm64 we need relocations that are in some way representable in
1253 # PE as we need to support arm64-efi. Without -fPIC clang generates
1254 # movk's which aren't representable.
1255 # Since default varies across dictributions use either -fPIC or -fno-PIC
1257 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
1258 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
1259 elif [ x"$pic_possible" = xyes ]; then
1260 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
1263 CFLAGS="$TARGET_CFLAGS"
1265 # Smashing stack protector.
1266 grub_CHECK_STACK_PROTECTOR
1267 # Need that, because some distributions ship compilers that include
1268 # `-fstack-protector' in the default specs.
1269 if test "x$ssp_possible" = xyes; then
1270 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
1273 CFLAGS="$TARGET_CFLAGS"
1275 grub_CHECK_STACK_ARG_PROBE
1276 # Cygwin's GCC uses alloca() to probe the stackframe on static
1277 # stack allocations above some threshold.
1278 if test x"$sap_possible" = xyes; then
1279 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
1282 CFLAGS="$TARGET_CFLAGS"
1284 # -mno-unaligned-access -mstrict-align
1285 if test "$target_cpu" = arm; then
1286 AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
1287 grub_cv_target_cc_strict_align=
1288 for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
1289 CFLAGS="$TARGET_CFLAGS $arg -Werror"
1290 LDFLAGS="$TARGET_LDFLAGS"
1291 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
1292 if test x"$flag" = x1; then
1293 grub_cv_target_cc_strict_align="$arg"
1298 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
1299 if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
1300 TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
1302 AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
1303 [CFLAGS="$TARGET_CFLAGS"
1304 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1305 #ifdef __ARM_FEATURE_UNALIGNED
1309 [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
1310 if test x$grub_cv_cc_target_emits_unaligned = xyes; then
1311 AC_MSG_ERROR([compiler generates unaligned accesses])
1315 # Set them to their new values for the tests below.
1317 if test x"$platform" = xemu ; then
1318 CFLAGS="$TARGET_CFLAGS -Wno-error"
1319 elif test "x$TARGET_APPLE_LINKER" = x1 ; then
1320 CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
1322 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
1324 CPPFLAGS="$TARGET_CPPFLAGS"
1327 if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
1328 if test x$grub_cv_asm_uscore = xyes; then
1329 DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
1331 DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main"
1333 CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
1336 # Check for libgcc symbols
1337 if test x"$platform" = xemu; then
1338 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)
1341 if test "x$TARGET_APPLE_LINKER" = x1 ; then
1342 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
1344 CFLAGS="$TARGET_CFLAGS -nostdlib"
1348 # Defined in aclocal.m4.
1350 if test "x$TARGET_APPLE_LINKER" != x1 ; then
1351 grub_PROG_OBJCOPY_ABSOLUTE
1353 grub_PROG_LD_BUILD_ID_NONE
1354 if test "x$target_cpu" = xi386; then
1355 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
1356 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
1357 # Check symbols provided by linker script.
1358 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
1360 grub_CHECK_BSS_START_SYMBOL
1361 grub_CHECK_END_SYMBOL
1363 CFLAGS="$TARGET_CFLAGS"
1367 grub_PROG_NM_MINUS_P
1368 grub_PROG_NM_DEFINED_ONLY
1369 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
1370 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
1372 if test "$platform" != emu; then
1373 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
1374 SAVED_CPPFLAGS="$CPPFLAGS"
1375 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1378 int va_arg_func (int fixed, va_list args);]], [[]])],
1379 [grub_cv_cc_isystem=yes],
1380 [grub_cv_cc_isystem=no])
1381 CPPFLAGS="$SAVED_CPPFLAGS"
1384 if test x"$grub_cv_cc_isystem" = xyes ; then
1385 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1389 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
1390 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
1391 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1392 int va_arg_func (int fixed, va_list args);]], [[]])],
1393 [grub_cv_cc_wtrampolines=yes],
1394 [grub_cv_cc_wtrampolines=no])
1397 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
1398 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
1401 # Restore the flags.
1403 CFLAGS="$tmp_CFLAGS"
1404 CPPFLAGS="$tmp_CPPFLAGS"
1405 LDFLAGS="$tmp_LDFLAGS"
1409 # Check for options.
1412 # Memory manager debugging.
1413 AC_ARG_ENABLE([mm-debug],
1414 AS_HELP_STRING([--enable-mm-debug],
1415 [include memory manager debugging]),
1416 [AC_DEFINE([MM_DEBUG], [1],
1417 [Define to 1 if you enable memory manager debugging.])])
1419 AC_ARG_ENABLE([cache-stats],
1420 AS_HELP_STRING([--enable-cache-stats],
1421 [enable disk cache statistics collection]))
1423 if test x$enable_cache_stats = xyes; then
1428 AC_SUBST([DISK_CACHE_STATS])
1430 AC_ARG_ENABLE([boot-time],
1431 AS_HELP_STRING([--enable-boot-time],
1432 [enable boot time statistics collection]))
1434 if test x$enable_boot_time = xyes; then
1439 AC_SUBST([BOOT_TIME_STATS])
1441 AC_ARG_ENABLE([grub-emu-sdl],
1442 [AS_HELP_STRING([--enable-grub-emu-sdl],
1443 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
1445 AC_ARG_ENABLE([grub-emu-pci],
1446 [AS_HELP_STRING([--enable-grub-emu-pci],
1447 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
1449 if test "$platform" = emu; then
1451 if test x"$enable_grub_emu_sdl" = xno ; then
1452 grub_emu_sdl_excuse="explicitly disabled"
1454 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1455 # Check for libSDL libraries.]
1456 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1457 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1461 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1462 # Check for headers.]
1463 AC_CHECK_HEADERS([SDL/SDL.h], [],
1464 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1467 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1468 AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
1470 if test x"$grub_emu_sdl_excuse" = x ; then
1471 enable_grub_emu_sdl=yes
1473 enable_grub_emu_sdl=no
1476 if test x"$enable_grub_emu_pci" != xyes ; then
1477 grub_emu_pci_excuse="not enabled"
1480 [if [ x"$grub_emu_pci_excuse" = x ]; then
1481 # Check for libpci libraries.]
1482 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1483 [grub_emu_pci_excuse=["need libpciaccess library"]])
1484 AC_SUBST([LIBPCIACCESS])
1486 [if [ x"$grub_emu_pci_excuse" = x ]; then
1487 # Check for headers.]
1488 AC_CHECK_HEADERS([pciaccess.h], [],
1489 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1492 if test x"$grub_emu_pci_excuse" = x ; then
1493 enable_grub_emu_pci=yes
1496 enable_grub_emu_pci=no
1499 AC_SUBST([enable_grub_emu_sdl])
1500 AC_SUBST([enable_grub_emu_pci])
1504 # Ignore --enable-emu-* if platform is not emu
1505 enable_grub_emu_sdl=no
1506 enable_grub_emu_pci=no
1509 AC_ARG_ENABLE([grub-mkfont],
1510 [AS_HELP_STRING([--enable-grub-mkfont],
1511 [build and install the `grub-mkfont' utility (default=guessed)])])
1512 if test x"$enable_grub_mkfont" = xno ; then
1513 grub_mkfont_excuse="explicitly disabled"
1516 unset ac_cv_header_ft2build_h
1518 if test x"$grub_mkfont_excuse" = x ; then
1519 # Check for freetype libraries.
1520 PKG_CHECK_MODULES([FREETYPE], [freetype2], [
1521 SAVED_CPPFLAGS="$CPPFLAGS"
1523 CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
1524 LIBS="$LIBS $FREETYPE_LIBS"
1525 AC_CHECK_HEADERS([ft2build.h], [],
1526 [grub_mkfont_excuse=["need freetype2 headers"]])
1527 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
1528 [grub_mkfont_excuse=["freetype2 library unusable"]])
1529 CPPFLAGS="$SAVED_CPPFLAGS"
1531 ], [grub_mkfont_excuse=["need freetype2 library"]])
1534 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1535 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
1537 if test x"$grub_mkfont_excuse" = x ; then
1538 enable_grub_mkfont=yes
1540 enable_grub_mkfont=no
1542 AC_SUBST([enable_grub_mkfont])
1546 SAVED_CFLAGS="$CFLAGS"
1547 SAVED_CPPFLAGS="$CPPFLAGS"
1548 SAVED_LDFLAGS="$LDFLAGS"
1551 CFLAGS="$BUILD_CFLAGS"
1552 CPPFLAGS="$BUILD_CPPFLAGS"
1553 LDFLAGS="$BUILD_LDFAGS"
1555 unset ac_cv_c_bigendian
1556 unset ac_cv_header_ft2build_h
1558 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1559 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1560 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1562 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1563 AC_MSG_ERROR([couldnt determine build endianness])
1566 AC_SUBST([BUILD_SIZEOF_LONG])
1567 AC_SUBST([BUILD_SIZEOF_VOID_P])
1568 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1570 if test x"$grub_build_mkfont_excuse" = x ; then
1571 # Check for freetype libraries.
1572 SAVED_PKG_CONFIG="$PKG_CONFIG"
1573 test -z "$BUILD_PKG_CONFIG" || PKG_CONFIG="$BUILD_PKG_CONFIG"
1574 PKG_CHECK_MODULES([BUILD_FREETYPE], [freetype2], [
1575 SAVED_CPPFLAGS_2="$CPPFLAGS"
1577 CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS"
1578 LIBS="$LIBS $BUILD_FREETYPE_LIBS"
1579 AC_CHECK_HEADERS([ft2build.h], [],
1580 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1581 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
1582 [grub_build_mkfont_excuse=["freetype2 library unusable"]])
1584 CPPFLAGS="$SAVED_CPPFLAGS_2"
1585 ], [grub_build_mkfont_excuse=["need freetype2 library"]])
1586 PKG_CONFIG="$SAVED_PKG_CONFIG"
1589 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1590 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
1592 if test x"$grub_build_mkfont_excuse" = x ; then
1593 enable_build_grub_mkfont=yes
1595 enable_build_grub_mkfont=no
1597 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
1598 if test x"$grub_build_mkfont_excuse" = x ; then
1599 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont])
1601 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)])
1607 CFLAGS="$SAVED_CFLAGS"
1608 CPPFLAGS="$SAVED_CPPFLAGS"
1609 LDFLAGS="$SAVED_LDFLAGS"
1616 AC_ARG_ENABLE([grub-themes],
1617 [AS_HELP_STRING([--enable-grub-themes],
1618 [build and install GRUB themes (default=guessed)])])
1619 if test x"$enable_grub_themes" = xno ; then
1620 starfield_excuse="explicitly disabled"
1623 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1624 starfield_excuse="No build-time grub-mkfont"
1627 if test x"$starfield_excuse" = x; then
1628 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1629 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
1630 if test -f "$dir/DejaVuSans.$ext"; then
1631 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1637 if test "x$DJVU_FONT_SOURCE" = x; then
1638 starfield_excuse="No DejaVu found"
1642 if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1643 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
1646 AC_SUBST([DJVU_FONT_SOURCE])
1650 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1651 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
1652 if test -f "$dir/unifont.$ext"; then
1653 md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
1654 # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
1655 if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
1658 FONT_SOURCE="$dir/unifont.$ext"
1664 if test x"$enable_build_grub_mkfont" = xno ; then
1668 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
1669 if test x"$grub_build_mkfont_excuse" = x ; then
1670 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont])
1672 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
1676 AC_SUBST([FONT_SOURCE])
1678 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1679 grub_build_mkfont_excuse="no fonts"
1683 AC_ARG_ENABLE([grub-mount],
1684 [AS_HELP_STRING([--enable-grub-mount],
1685 [build and install the `grub-mount' utility (default=guessed)])])
1686 if test x"$enable_grub_mount" = xno ; then
1687 grub_mount_excuse="explicitly disabled"
1690 if test x"$grub_mount_excuse" = x ; then
1691 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1692 [grub_mount_excuse="need FUSE library"])
1695 if test x"$grub_mount_excuse" = x ; then
1696 # Check for fuse headers.
1697 SAVED_CPPFLAGS="$CPPFLAGS"
1698 CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
1699 AC_CHECK_HEADERS([fuse/fuse.h], [],
1700 [grub_mount_excuse=["need FUSE headers"]])
1701 CPPFLAGS="$SAVED_CPPFLAGS"
1704 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1705 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
1707 if test x"$grub_mount_excuse" = x ; then
1708 enable_grub_mount=yes
1710 enable_grub_mount=no
1712 AC_SUBST([enable_grub_mount])
1714 AC_ARG_ENABLE([device-mapper],
1715 [AS_HELP_STRING([--enable-device-mapper],
1716 [enable Linux device-mapper support (default=guessed)])])
1717 if test x"$enable_device_mapper" = xno ; then
1718 device_mapper_excuse="explicitly disabled"
1721 if test x"$device_mapper_excuse" = x ; then
1722 # Check for device-mapper header.
1723 AC_CHECK_HEADER([libdevmapper.h], [],
1724 [device_mapper_excuse="need libdevmapper header"])
1727 if test x"$device_mapper_excuse" = x ; then
1728 # Check for device-mapper library.
1729 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1730 [device_mapper_excuse="need devmapper library"])
1733 if test x"$device_mapper_excuse" = x ; then
1734 # Check for device-mapper library.
1735 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1737 [device_mapper_excuse="need devmapper library"])
1740 if test x"$device_mapper_excuse" = x ; then
1741 LIBDEVMAPPER="-ldevmapper"
1742 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1743 [Define to 1 if you have the devmapper library.])
1746 AC_SUBST([LIBDEVMAPPER])
1749 if test x$host_kernel = xkfreebsd; then
1750 AC_CHECK_LIB([geom], [geom_gettree], [],
1751 [AC_MSG_ERROR([Your platform requires libgeom])])
1757 AC_ARG_ENABLE([liblzma],
1758 [AS_HELP_STRING([--enable-liblzma],
1759 [enable liblzma integration (default=guessed)])])
1760 if test x"$enable_liblzma" = xno ; then
1761 liblzma_excuse="explicitly disabled"
1764 if test x"$liblzma_excuse" = x ; then
1765 AC_CHECK_LIB([lzma], [lzma_code],
1766 [],[liblzma_excuse="need lzma library"])
1768 if test x"$liblzma_excuse" = x ; then
1769 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1772 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1773 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
1777 if test x"$liblzma_excuse" = x ; then
1779 AC_DEFINE([USE_LIBLZMA], [1],
1780 [Define to 1 if you have the LZMA library.])
1785 AC_ARG_ENABLE([libzfs],
1786 [AS_HELP_STRING([--enable-libzfs],
1787 [enable libzfs integration (default=guessed)])])
1788 if test x"$enable_libzfs" = xno ; then
1789 libzfs_excuse="explicitly disabled"
1792 if test x"$libzfs_excuse" = x ; then
1793 # Only check for system headers if libzfs support has not been disabled.
1794 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1797 if test x"$libzfs_excuse" = x ; then
1798 AC_CHECK_LIB([zfs], [libzfs_init],
1800 [libzfs_excuse="need zfs library"])
1803 if test x"$libzfs_excuse" = x ; then
1804 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1806 [libzfs_excuse="need nvpair library"])
1809 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1810 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
1813 if test x"$libzfs_excuse" = x ; then
1814 # We need both libzfs and libnvpair for a successful build.
1816 AC_DEFINE([HAVE_LIBZFS], [1],
1817 [Define to 1 if you have the ZFS library.])
1818 LIBNVPAIR="-lnvpair"
1819 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1820 [Define to 1 if you have the NVPAIR library.])
1824 AC_SUBST([LIBNVPAIR])
1828 AC_SUBST([FONT_SOURCE])
1829 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1830 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1832 AC_SUBST(HAVE_ASM_USCORE)
1833 AC_SUBST(BSS_START_SYMBOL)
1834 AC_SUBST(END_SYMBOL)
1838 AC_ARG_ENABLE([werror],
1839 [AS_HELP_STRING([--disable-werror],
1840 [do not use -Werror when building GRUB])])
1841 if test x"$enable_werror" != xno ; then
1842 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1843 HOST_CFLAGS="$HOST_CFLAGS -Werror"
1846 TARGET_CPP="$TARGET_CC -E"
1847 TARGET_CCAS=$TARGET_CC
1849 # Includes which include make-time substitutions. They must come last
1850 # as to avoid executing top_builddir in shell.
1851 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
1852 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
1853 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
1855 GRUB_TARGET_CPU="${target_cpu}"
1856 GRUB_PLATFORM="${platform}"
1858 AC_SUBST(GRUB_TARGET_CPU)
1859 AC_SUBST(GRUB_PLATFORM)
1861 AC_SUBST(TARGET_OBJCONV)
1862 AC_SUBST(TARGET_CPP)
1863 AC_SUBST(TARGET_CCAS)
1864 AC_SUBST(TARGET_OBJ2ELF)
1865 AC_SUBST(TARGET_MODULE_FORMAT)
1866 AC_SUBST(TARGET_CC_VERSION)
1868 AC_SUBST(TARGET_CFLAGS)
1869 AC_SUBST(TARGET_LDFLAGS)
1870 AC_SUBST(TARGET_CPPFLAGS)
1871 AC_SUBST(TARGET_CCASFLAGS)
1873 AC_SUBST(TARGET_IMG_LDFLAGS)
1874 AC_SUBST(TARGET_IMG_CFLAGS)
1875 AC_SUBST(TARGET_IMG_BASE_LDOPT)
1876 AC_SUBST(TARGET_APPLE_LINKER)
1878 AC_SUBST(HOST_CFLAGS)
1879 AC_SUBST(HOST_LDFLAGS)
1880 AC_SUBST(HOST_CPPFLAGS)
1881 AC_SUBST(HOST_CCASFLAGS)
1883 AC_SUBST(BUILD_LIBM)
1886 # Automake conditionals
1889 AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
1890 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1891 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1892 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1893 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1894 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1895 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1896 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1897 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1898 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1899 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1900 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
1901 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1902 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1903 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1904 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1905 AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
1906 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1907 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1908 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1909 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1910 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1911 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1912 AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot])
1913 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1914 AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
1915 AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
1917 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1918 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1919 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1920 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1921 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1922 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1923 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1925 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1926 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1927 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1928 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1929 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1930 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1931 if test x$FONT_SOURCE != x ; then
1936 AC_SUBST(HAVE_FONT_SOURCE)
1937 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
1938 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1939 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1940 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1942 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1944 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1945 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1946 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
1948 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
1949 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
1950 datarootdir="$(eval echo "$datarootdir")"
1951 grub_libdir="$(eval echo "$libdir")"
1952 grub_localedir="$(eval echo "$localedir")"
1953 grub_datadir="$(eval echo "$datadir")"
1954 grub_sysconfdir="$(eval echo "$sysconfdir")"
1955 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
1956 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
1957 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
1958 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
1962 if test "$platform" != none; then
1963 cpudir="${target_cpu}"
1964 if test x${cpudir} = xmipsel; then
1968 if test x"$link_dir" = xyes ; then
1969 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1970 if test "$platform" != emu ; then
1971 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1974 mkdir -p include/grub 2>/dev/null
1975 rm -rf include/grub/cpu
1976 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1977 if test "$platform" != emu ; then
1978 rm -rf include/grub/machine
1979 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1983 # Just enough to stop the compiler failing with -I$(srcdir)/include.
1984 mkdir -p include 2>/dev/null
1985 rm -rf include/grub/cpu include/grub/machine
1988 AC_CONFIG_FILES([Makefile])
1989 AC_CONFIG_FILES([grub-core/Makefile])
1990 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1991 AC_CONFIG_FILES([po/Makefile.in])
1992 AC_CONFIG_FILES([docs/Makefile])
1993 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1994 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1995 AC_CONFIG_FILES([config.h])
1999 echo "*******************************************************"
2000 echo GRUB2 will be compiled with following components:
2001 echo Platform: "$target_cpu"-"$platform"
2002 if [ x"$platform" = xemu ]; then
2003 if [ x"$grub_emu_sdl_excuse" = x ]; then
2004 echo SDL support for grub-emu: Yes
2006 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
2008 if [ x"$grub_emu_pci_excuse" = x ]; then
2009 echo PCI support for grub-emu: Yes
2011 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
2014 if test x"$device_mapper_excuse" = x ; then
2015 echo With devmapper support: Yes
2017 echo With devmapper support: No "($device_mapper_excuse)"
2019 if [ x"$enable_mm_debug" = xyes ]; then
2020 echo With memory debugging: Yes
2022 echo With memory debugging: No
2024 if [ x"$enable_cache_stats" = xyes ]; then
2025 echo With disk cache statistics: Yes
2027 echo With disk cache statistics: No
2030 if [ x"$enable_boot_time" = xyes ]; then
2031 echo With boot time statistics: Yes
2033 echo With boot time statistics: No
2036 if [ x"$efiemu_excuse" = x ]; then
2037 echo efiemu runtime: Yes
2039 echo efiemu runtime: No "($efiemu_excuse)"
2041 if [ x"$grub_mkfont_excuse" = x ]; then
2042 echo grub-mkfont: Yes
2044 echo grub-mkfont: No "($grub_mkfont_excuse)"
2046 if [ x"$grub_mount_excuse" = x ]; then
2047 echo grub-mount: Yes
2049 echo grub-mount: No "($grub_mount_excuse)"
2051 if [ x"$starfield_excuse" = x ]; then
2052 echo starfield theme: Yes
2053 echo With DejaVuSans font from $DJVU_FONT_SOURCE
2055 echo starfield theme: No "($starfield_excuse)"
2057 if [ x"$libzfs_excuse" = x ]; then
2058 echo With libzfs support: Yes
2060 echo With libzfs support: No "($libzfs_excuse)"
2062 if [ x"$grub_build_mkfont_excuse" = x ]; then
2063 echo Build-time grub-mkfont: Yes
2064 if test "x$FONT_SOURCE" = x ; then
2065 echo "Without unifont"
2067 echo "With unifont from $FONT_SOURCE"
2070 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
2071 echo "Without unifont (no build-time grub-mkfont)"
2073 if test x"$liblzma_excuse" != x ; then
2074 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
2076 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
2078 echo "*******************************************************"