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.04],[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.11])
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_MIPS64EL=1"
99 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
103 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
119 # Specify the platform (such as firmware).
120 AC_ARG_WITH([platform],
121 AS_HELP_STRING([--with-platform=PLATFORM],
122 [select the host platform [[guessed]]]))
124 # Guess the platform if not specified.
125 if test "x$with_platform" = x; then
126 case "$target_cpu"-"$target_vendor" in
127 i386-apple) platform=efi ;;
128 i386-*) platform=pc ;;
129 x86_64-apple) platform=efi ;;
130 x86_64-*) platform=pc ;;
131 powerpc-*) platform=ieee1275 ;;
132 powerpc64-*) platform=ieee1275 ;;
133 powerpc64le-*) platform=ieee1275 ;;
134 sparc64-*) platform=ieee1275 ;;
135 mips64el-*) platform=efi;;
136 mipsel-*) platform=loongson ;;
137 mips-*) platform=arc ;;
138 ia64-*) platform=efi ;;
139 arm-*) platform=uboot ;;
140 arm64-*) platform=efi ;;
141 riscv32-*) platform=efi ;;
142 riscv64-*) platform=efi ;;
144 AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
149 platform="$with_platform"
152 case "$target_cpu"-"$platform" in
157 x86_64-*) target_cpu=i386 ;;
158 powerpc64-ieee1275) target_cpu=powerpc ;;
159 powerpc64le-ieee1275) target_cpu=powerpc ;;
162 # Check if the platform is supported, make final adjustments.
163 case "$target_cpu"-"$platform" in
172 i386-linuxbios) platform=coreboot ;;
179 mips-qemu-mips) platform=qemu_mips;;
183 mipsel-qemu-mips) platform=qemu_mips;;
184 mipsel-yeeloong) platform=loongson ;;
185 mipsel-fuloong) platform=loongson ;;
196 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
199 if test x$platform != xemu ; then
200 case "$target_cpu" in
201 i386 | powerpc) target_m32=1 ;;
202 x86_64 | sparc64) target_m64=1 ;;
206 if test x"$target_cpu-$platform" = xsparc64-emu ; then
211 windows* | mingw32*) target_os=cygwin ;;
214 # This normalizes the names, and creates a new variable ("host_kernel")
215 # while at it, since the mapping is not always 1:1 (e.g. different OSes
216 # using the same kernel type).
218 gnu*) host_kernel=hurd ;;
219 linux*) host_kernel=linux ;;
220 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
221 netbsd*) host_kernel=netbsd ;;
222 solaris*) host_kernel=illumos ;;
223 darwin*) host_kernel=xnu ;;
224 cygwin | windows* | mingw32*) host_kernel=windows ;;
228 cygwin) have_exec=y ;;
229 windows* | mingw32*) have_exec=n ;;
230 aros*) have_exec=n ;;
235 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
236 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
237 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
238 xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
239 xen_pvh) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN_PVH=1" ;;
240 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
241 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
242 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
243 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
244 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
245 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
246 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
247 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
249 if test x${target_cpu} = xmipsel ; then
250 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
252 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
255 case "${target_cpu}-$platform" in
257 TARGET_LINK_ADDR=0x88200000
258 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
261 TARGET_LINK_ADDR=0x80700000
262 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
264 mips*-qemu_mips | mips*-loongson)
265 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
269 AC_SUBST(TARGET_LINK_ADDR)
270 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
272 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
276 AC_SUBST(host_kernel)
281 # Define default variables
284 AC_ARG_WITH([bootdir],
285 AS_HELP_STRING([--with-bootdir=DIR],
286 [set the name of /boot directory [[guessed]]]),
287 [have_with_bootdir=y],
288 [have_with_bootdir=n])
289 if test x$have_with_bootdir = xy; then
290 bootdirname="$with_bootdir"
294 # Because /boot is used for the boot block in NetBSD and OpenBSD,
296 *) bootdirname='boot' ;;
300 AC_SUBST(bootdirname)
301 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
302 [Default boot directory name])
304 AC_ARG_WITH([grubdir],
305 AS_HELP_STRING([--with-grubdir=DIR],
306 [set the name of grub directory [[guessed]]]),
307 [grubdirname="$with_grubdir"],
308 [grubdirname="$PACKAGE"])
310 AC_SUBST(grubdirname)
311 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
312 [Default grub directory name])
315 # Checks for build programs.
318 # Although cmp is listed in the GNU Coding Standards as a command which
319 # can used directly, OpenBSD lacks cmp in the default installation.
320 AC_CHECK_PROGS([CMP], [cmp])
321 if test "x$CMP" = x; then
322 AC_MSG_ERROR([cmp is not found])
325 AC_CHECK_PROGS([YACC], [bison])
326 if test "x$YACC" = x; then
327 AC_MSG_ERROR([bison is not found])
339 if test "x$LEX" = "x:"; then
340 AC_MSG_ERROR([flex is not found])
342 version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
343 if test -n "$version" -a "$version" -ge 20535; then
346 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
350 # These are not a "must".
351 AC_PATH_PROGS(MAKEINFO, makeinfo true)
354 # Checks for host programs.
362 AM_PATH_PYTHON([2.6])
365 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
367 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
370 AM_GNU_GETTEXT([external])
371 AM_GNU_GETTEXT_VERSION([0.18.3])
374 # Identify characteristics of the host architecture.
375 unset ac_cv_c_bigendian
377 if test x"$target_cpu-$platform" = xsparc64-emu ; then
378 CFLAGS="$CFLAGS -m64"
379 HOST_CFLAGS="$HOST_CFLAGS -m64"
382 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
383 HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
386 AC_CHECK_SIZEOF(void *)
387 AC_CHECK_SIZEOF(long)
390 cygwin | windows* | mingw32*)
391 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
392 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
393 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
398 cygwin | windows* | mingw32* | aros*)
401 AC_CHECK_SIZEOF(off_t)
402 if test x"$ac_cv_sizeof_off_t" != x8 ; then
403 AC_CHECK_SIZEOF(off64_t)
404 test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required])
408 if test x$USE_NLS = xno; then
409 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
412 if test "x$cross_compiling" = xyes; then
413 AC_MSG_WARN([cannot generate manual pages while cross compiling])
415 AC_PATH_PROG(HELP2MAN, help2man)
418 # Check for functions and headers.
419 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
420 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
422 # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
423 # warning which causes compilation failure later with -Werror. So use -Werror here
424 # as well to force proper sys/sysmacros.h detection.
425 SAVED_CFLAGS="$CFLAGS"
426 CFLAGS="$HOST_CFLAGS -Werror"
428 CFLAGS="$SAVED_CFLAGS"
430 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
431 #include <sys/param.h>
432 #include <sys/mount.h>])
434 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
435 #include <sys/param.h>
436 #include <sys/mount.h>])
438 # For opendisk() and getrawpartition() on NetBSD.
439 # Used in util/deviceiter.c and in util/hostdisk.c.
440 AC_CHECK_HEADER([util.h], [
441 AC_CHECK_LIB([util], [opendisk], [
443 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
445 AC_CHECK_LIB([util], [getrawpartition], [
447 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
452 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
453 SAVED_CFLAGS="$CFLAGS"
454 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
455 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
456 int va_arg_func (int fixed, va_list args);]], [[]])],
457 [grub_cv_host_cc_wtrampolines=yes],
458 [grub_cv_host_cc_wtrampolines=no])
459 CFLAGS="$SAVED_CFLAGS"
462 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
463 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
467 # Check for host and build compilers.
470 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
471 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
472 BUILD_CPP="$BUILD_CC -E"
475 haiku*) BUILD_LIBM= ;;
479 dnl FIXME proper test seems to require too deep dive into Autoconf internals.
480 dnl For now just list known platforms that we support.
483 cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
486 AC_SUBST(BUILD_EXEEXT)
488 # In some build environments like termux /bin/sh is not a valid
489 # shebang. Use $SHELL instead if it's executable and /bin/sh isn't
490 BUILD_SHEBANG=/bin/sh
491 for she in /bin/sh "$SHELL"; do
492 if test -x "$she" ; then
496 AC_SUBST(BUILD_SHEBANG)
501 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"
502 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"
504 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
506 AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
507 SAVED_CFLAGS="$CFLAGS"
508 grub_cv_cc_w_extra_flags=
509 for x in $EXTRA_WARN_FLAGS; do
510 CFLAGS="$HOST_CFLAGS $x -Werror"
511 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
512 if test x$flag = x1 ; then
513 grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
516 CFLAGS="$SAVED_CFLAGS"
519 HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
522 # Check for target programs.
525 # Find tools for the target.
526 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
527 tmp_ac_tool_prefix="$ac_tool_prefix"
528 ac_tool_prefix=$target_alias-
530 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
531 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
532 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
533 AC_CHECK_TOOL(TARGET_STRIP, strip)
534 AC_CHECK_TOOL(TARGET_NM, nm)
535 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
537 ac_tool_prefix="$tmp_ac_tool_prefix"
539 if test "x$TARGET_CC" = x; then
542 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
543 AC_CHECK_TOOL(TARGET_STRIP, strip)
544 AC_CHECK_TOOL(TARGET_NM, nm)
545 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
550 AC_SUBST(BUILD_CFLAGS)
551 AC_SUBST(BUILD_CPPFLAGS)
552 AC_SUBST(BUILD_LDFLAGS)
555 AC_SUBST(TARGET_RANLIB)
556 AC_SUBST(TARGET_STRIP)
557 AC_SUBST(TARGET_OBJCOPY)
559 # Test the C compiler for the target environment.
562 tmp_LDFLAGS="$LDFLAGS"
563 tmp_CPPFLAGS="$CPPFLAGS"
566 CFLAGS="$TARGET_CFLAGS"
567 CPPFLAGS="$TARGET_CPPFLAGS"
568 LDFLAGS="$TARGET_LDFLAGS"
572 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
573 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
575 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
576 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
579 TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
581 AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
582 LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
584 grub_cv_target_cc_w_extra_flags=
585 for x in $EXTRA_WARN_FLAGS; do
586 CFLAGS="$TARGET_CFLAGS $x -Werror"
587 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
588 asm (".globl start; start:");
590 void __main (void) {}
592 ]], [[]])], [flag=1], [flag=0])
593 if test x$flag = x1 ; then
594 grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
599 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
601 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
603 CFLAGS="$TARGET_CFLAGS"
605 [AC_LANG_PROGRAM([], [[
610 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
612 if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
613 AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
614 grub_cv_target_cc_big_endian=no
615 for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
616 "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
617 "-EB" "-mbig-endian"; do
618 if test x"$grub_cv_target_cc_big_endian" != xno ; then
621 CFLAGS="$TARGET_CFLAGS $cand -Werror"
622 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
623 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
624 #error still little endian
626 asm (".globl start; start:");
627 asm (".globl _start; _start:");
628 asm (".globl __start; __start:");
630 void __main (void) {}
633 [grub_cv_target_cc_big_endian="$cand"], [])
637 if test x"$grub_cv_target_cc_big_endian" = xno ; then
638 AC_MSG_ERROR([could not force big-endian])
641 skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
643 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
644 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
645 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
646 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
647 elif test x$target_cpu = xmipsel; then
648 AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
649 grub_cv_target_cc_little_endian=no
650 for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
651 "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
653 if test x"$grub_cv_target_cc_little_endian" != xno ; then
656 CFLAGS="$TARGET_CFLAGS $cand -Werror"
657 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
658 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
659 #error still big endian
661 asm (".globl start; start:");
662 asm (".globl _start; _start:");
663 asm (".globl __start; __start:");
665 void __main (void) {}
668 [grub_cv_target_cc_little_endian="$cand"], [])
672 if test x"$grub_cv_target_cc_little_endian" = xno ; then
673 AC_MSG_ERROR([could not force little-endian])
676 skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
678 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
679 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
680 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
681 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
684 # GRUB code is N32-compliant but it's experimental and we would prefer to
685 # avoid having too much variety when it doesn't result in any real improvement.
686 # Moreover N64 isn't supported.
687 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
688 AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
689 grub_cv_target_cc_mips_o32_abi=no
690 for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
691 if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
694 CFLAGS="$TARGET_CFLAGS $arg -Werror"
695 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
696 #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
699 asm (".globl start; start:");
700 asm (".globl _start; _start:");
701 asm (".globl __start; __start:");
703 void __main (void) {}
706 [grub_cv_target_cc_mips_o32_abi="$arg"], [])
710 if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
711 AC_MSG_ERROR([could not force MIPS o32 ABI])
714 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
715 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
718 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
720 case "x$target_cpu-$platform" in
730 xpowerpc-* | xsparc64-* | xarm-*)
731 test_program=$target_cpu
734 if test x"$test_program" = x ; then
735 grub_cv_cc_target_asm_compile=
738 for arg in "" "-no-integrated-as"; do
739 cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
740 echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
741 if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
742 grub_cv_cc_target_asm_compile="$arg"
747 if test x"$found" = xno ; then
748 AC_MSG_ERROR([could not compile assembly])
753 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
755 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
756 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
759 if test "x$target_m32" = x1; then
761 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
762 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
763 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
764 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
765 TARGET_MODULE_FORMAT="elf32"
768 if test "x$target_m64" = x1; then
770 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
771 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
772 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
773 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
774 TARGET_MODULE_FORMAT="elf64"
777 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
778 TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
781 # on mips redirect cache flushing function to non-existant one.
782 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
783 AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
784 CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
785 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
786 [grub_cv_cc_mflush_func=yes],
787 [grub_cv_cc_mflush_func=no])
790 if test "x$grub_cv_cc_mflush_func" = xyes; then
791 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
796 # Force no alignment to save space on i386.
797 if test "x$target_cpu" = xi386; then
798 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
799 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
800 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
801 [grub_cv_cc_falign_loop=yes],
802 [grub_cv_cc_falign_loop=no])
805 AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
806 CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
807 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
808 [grub_cv_cc_malign_loop=yes],
809 [grub_cv_cc_malign_loop=no])
812 if test "x$grub_cv_cc_falign_loop" = xyes; then
813 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
814 elif test "x$grub_cv_cc_malign_loop" = xyes; then
815 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
819 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
820 CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
821 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
822 [grub_cv_cc_freg_struct_return=yes],
823 [grub_cv_cc_freg_struct_return=no])
826 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
827 TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
830 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
831 # Some toolchains enable these features by default, but they need
832 # registers that aren't set up properly in GRUB.
833 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
836 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
837 # that floats are a good fit to run instead of what's written in the code.
838 # Given that floating point unit is disabled (if present to begin with)
839 # when GRUB is running which may result in various hard crashes.
840 #if test x"$platform" != xemu ; then
841 if ( test x"$platform" != xemu && x"$platform" != mips64el-efi ) ; then
842 AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
843 grub_cv_target_cc_soft_float=no
844 if test "x$target_cpu" = xarm64; then
845 CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
846 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
847 [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
849 if test "x$target_cpu" = xriscv32; then
850 CFLAGS="$TARGET_CFLAGS -march=rv32imac -mabi=ilp32 -Werror"
851 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
852 [grub_cv_target_cc_soft_float="-march=rv32imac -mabi=ilp32"], [])
854 if test "x$target_cpu" = xriscv64; then
855 CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror"
856 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
857 [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], [])
859 if test "x$target_cpu" = xia64; then
860 CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
861 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
862 [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
864 for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
865 "-Xclang -msoft-float -Xclang -no-implicit-float" \
866 "-Xclang -msoft-float" "-msoft-float"; do
867 if test x"$grub_cv_target_cc_soft_float" != xno ; then
870 CFLAGS="$TARGET_CFLAGS $cand -Werror"
871 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
872 [grub_cv_target_cc_soft_float="$cand"], [])
876 if test x"$grub_cv_target_cc_soft_float" = xno ; then
877 AC_MSG_ERROR([could not force soft-float])
880 case x"$grub_cv_target_cc_soft_float" in
882 # A trick so that clang doesn't see it on link stаge
883 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
886 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
889 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
893 if test x"$target_cpu" = xsparc64 ; then
894 AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
895 grub_cv_target_cc_mno_app_regs=no
896 for cand in "-mllvm -sparc-reserve-app-registers" \
898 if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
901 CFLAGS="$TARGET_CFLAGS $cand -Werror"
902 CPPFLAGS="$TARGET_CPPFLAGS"
903 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
904 [grub_cv_target_cc_mno_app_regs="$cand"], [])
908 if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
909 AC_MSG_ERROR([could not reserve application registers])
911 if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
912 # A trick so that clang doesn't see it on link stаge
913 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
915 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
918 AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
919 grub_cv_target_cc_mno_relax=no
920 for cand in "-mno-relax" "-Wl,--no-relax"; do
921 if test x"$grub_cv_target_cc_mno_relax" != xno ; then
924 LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
925 CFLAGS="$TARGET_CFLAGS -Werror"
926 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
927 asm (".globl start; start:");
929 void __main (void) {}
931 ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
934 LDFLAGS="$TARGET_LDFLAGS"
935 CFLAGS="$TARGET_CFLAGS"
937 if test x"$grub_cv_target_cc_mno_relax" = xno ; then
938 AC_MSG_ERROR([could not find no-relax options])
940 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
943 # By default, GCC 4.4 generates .eh_frame sections containing unwind
944 # information in some cases where it previously did not. GRUB doesn't need
945 # these and they just use up vital space. Restore the old compiler
947 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
948 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
949 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
950 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
951 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
954 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
955 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
958 if test x"$target_os" = xcygwin; then
959 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
960 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
961 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
962 [grub_cv_cc_no_reorder_functions=yes],
963 [grub_cv_cc_no_reorder_functions=no])
967 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
968 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
971 AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
972 CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
973 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
974 [grub_cv_cc_mno_stack_arg_probe=yes],
975 [grub_cv_cc_mno_stack_arg_probe=no])
978 if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
979 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
983 # By default, GCC 4.6 generates .eh_frame sections containing unwind
984 # information in some cases where it previously did not. GRUB doesn't need
985 # these and they just use up vital space. Restore the old compiler
987 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
988 CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
989 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
990 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
991 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
994 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
995 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
998 AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
999 CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
1000 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1001 [grub_cv_cc_fno_unwind_tables=yes],
1002 [grub_cv_cc_fno_unwind_tables=no])
1005 if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
1006 TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
1010 CFLAGS="$TARGET_CFLAGS"
1013 if test x"$platform" = xemu ; then
1015 grub_cv_target_cc_link_format=
1018 grub_cv_target_cc_link_format="-arch,${target_cpu}"
1019 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1021 *windows* | *cygwin* | *mingw*)
1022 if test x${target_cpu} = xi386 ; then
1023 grub_cv_target_cc_link_format=-mi386pe
1024 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1026 if test x${target_cpu} = xx86_64 ; then
1027 grub_cv_target_cc_link_format=-mi386pep
1028 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1030 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1033 elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
1034 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
1035 grub_cv_target_cc_link_format=unknown
1036 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
1037 if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
1040 if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
1043 CFLAGS="$TARGET_CFLAGS"
1044 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
1045 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1046 asm (".globl start; start:");
1047 asm (".globl _start; _start:");
1048 asm (".globl __start; __start:");
1050 void __main (void) {}
1051 ]], [[]])], [flag=1], [flag=0])
1052 if test x"$flag" = x1; then
1053 grub_cv_target_cc_link_format="$format"
1057 if test x"$grub_cv_target_cc_link_format" = xunknown; then
1058 AC_MSG_ERROR([no suitable link format found])
1060 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1061 if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
1062 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1064 if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1065 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1069 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
1070 TARGET_APPLE_LINKER=1
1071 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
1072 if test "x$TARGET_OBJCONV" = x ; then
1073 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
1075 if test "x$TARGET_OBJCONV" = x ; then
1076 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
1078 TARGET_IMG_LDSCRIPT=
1079 TARGET_IMG_CFLAGS="-static"
1080 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1081 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1082 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
1083 TARGET_LDFLAGS_OLDMAGIC=""
1084 elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
1085 TARGET_APPLE_LINKER=0
1086 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1087 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1088 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
1089 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1090 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1093 TARGET_APPLE_LINKER=0
1094 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1095 TARGET_IMG_LDSCRIPT=
1096 TARGET_IMG_LDFLAGS='-Wl,-N'
1097 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
1098 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1102 CFLAGS="$TARGET_CFLAGS"
1104 AC_ARG_ENABLE([efiemu],
1105 [AS_HELP_STRING([--enable-efiemu],
1106 [build and install the efiemu runtimes (default=guessed)])])
1107 if test x"$enable_efiemu" = xno ; then
1108 efiemu_excuse="explicitly disabled"
1111 if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1112 efiemu_excuse="not available on cygwin"
1114 if test x"$target_cpu" != xi386 ; then
1115 efiemu_excuse="only available on i386"
1117 if test x"$platform" = xefi ; then
1118 efiemu_excuse="not available on efi"
1121 if test x"$efiemu_excuse" = x ; then
1122 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
1123 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1124 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1125 [grub_cv_cc_efiemu=yes],
1126 [grub_cv_cc_efiemu=no])
1128 if test x$grub_cv_cc_efiemu = xno; then
1129 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
1132 if test x"$efiemu_excuse" = x ; then
1133 AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
1134 grub_cv_target_cc_efiemu64_link_format=unknown
1135 for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
1136 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1137 LDFLAGS="-m64 -Wl,$format -nostdlib -static"
1138 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1139 asm (".globl start; start:");
1140 asm (".globl _start; _start:");
1141 asm (".globl __start; __start:");
1143 void __main (void) {}
1144 ]], [[]])], [flag=1], [flag=0])
1145 if test x"$flag" = x1; then
1146 grub_cv_target_cc_efiemu64_link_format="$format"
1150 if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
1151 efiemu_excuse="no suitable link format for efiemu64 found"
1153 EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
1156 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
1157 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
1159 if test x"$efiemu_excuse" = x ; then
1164 AC_SUBST([enable_efiemu])
1165 AC_SUBST([EFIEMU64_LINK_FORMAT])
1167 CFLAGS="$TARGET_CFLAGS"
1169 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
1172 LDFLAGS="$TARGET_LDFLAGS"
1174 if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64 ; then
1175 # Use large model to support 4G memory
1176 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
1177 CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1178 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1179 [grub_cv_cc_mcmodel=yes],
1180 [grub_cv_cc_mcmodel=no])
1182 if test "x$grub_cv_cc_mcmodel" = xyes; then
1183 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1184 elif test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64; then
1185 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
1189 if test "$target_cpu"-"$platform" = x86_64-efi; then
1190 # EFI writes to stack below %rsp, we must not use the red zone
1191 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
1192 CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1193 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1194 [grub_cv_cc_no_red_zone=yes],
1195 [grub_cv_cc_no_red_zone=no])
1197 if test "x$grub_cv_cc_no_red_zone" = xno; then
1198 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
1201 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1204 if test "x$target_cpu" = xarm; then
1205 AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [
1206 grub_cv_target_cc_mno_movt=no
1207 for cand in "-mno-movt" \
1208 "-mllvm -arm-use-movt=0"; do
1209 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1212 CFLAGS="$TARGET_CFLAGS $cand -Werror"
1213 CPPFLAGS="$TARGET_CPPFLAGS"
1214 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1215 [grub_cv_target_cc_mno_movt="$cand"], [])
1219 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1220 # A trick so that clang doesn't see it on link stage
1221 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt"
1223 AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
1224 CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
1225 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1226 [grub_cv_cc_mthumb_interwork=yes],
1227 [grub_cv_cc_mthumb_interwork=no])
1229 if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
1230 TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
1231 # Clang defaults to thumb interworking
1232 elif test "x$grub_cv_cc_target_clang" = xno ; then
1233 AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
1237 AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
1238 CFLAGS="$TARGET_CFLAGS -Qn -Qunused-arguments -Werror"
1239 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1240 [grub_cv_target_cc_qn=yes],
1241 [grub_cv_target_cc_qn=no])])
1242 if test "x$grub_cv_target_cc_qn" = xyes; then
1243 TARGET_CFLAGS="$TARGET_CFLAGS -Qn -Qunused-arguments"
1247 # Compiler features.
1250 CFLAGS="$TARGET_CFLAGS"
1252 # Position independent executable.
1255 grub_CHECK_NO_PIE_ONEWORD
1257 [# Need that, because some distributions ship compilers that include
1258 # `-fPIE' or '-fpie' and '-pie' in the default specs.
1259 if [ x"$pie_possible" = xyes ]; then
1260 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
1263 if [ x"$link_nopie_needed" = xyes ] || [ x"$pie_possible" = xyes ]; then
1264 if [ x"$nopie_possible" = xyes ]; then
1265 TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
1267 if [ x"$nopie_oneword_possible" = xyes ]; then
1268 TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie"
1272 CFLAGS="$TARGET_CFLAGS"
1273 LDFLAGS="$TARGET_LDFLAGS"
1275 # Position independent executable.
1277 [# On most platforms we don't want PIC as it only makes relocations harder
1278 # and code less efficient. On mips we want to have one got table per module
1279 # and reload $gp in every function.
1280 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
1281 # However with clang we need PIC for this reloading to happen.
1282 # With arm64 we need relocations that are in some way representable in
1283 # PE as we need to support arm64-efi. Without -fPIC clang generates
1284 # movk's which aren't representable.
1285 # Since default varies across dictributions use either -fPIC or -fno-PIC
1287 if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel || test x$target_cpu = xarm64 || test x$target_cpu = xmips64el ) && test "x$grub_cv_cc_target_clang" = xyes ; then
1288 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
1289 elif [ x"$pic_possible" = xyes ]; then
1290 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
1292 # Don't generate SVR4-style position-independent code for MIPS64.
1293 if test x$target_cpu = xmips64el ; then
1294 TARGET_CFLAGS="$TARGET_CFLAGS -mno-abicalls"
1295 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mno-abicalls"
1298 CFLAGS="$TARGET_CFLAGS"
1300 # Smashing stack protector.
1301 grub_CHECK_STACK_PROTECTOR
1302 # Need that, because some distributions ship compilers that include
1303 # `-fstack-protector' in the default specs.
1304 if test "x$ssp_possible" = xyes; then
1305 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
1308 CFLAGS="$TARGET_CFLAGS"
1310 grub_CHECK_STACK_ARG_PROBE
1311 # Cygwin's GCC uses alloca() to probe the stackframe on static
1312 # stack allocations above some threshold.
1313 if test x"$sap_possible" = xyes; then
1314 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
1317 CFLAGS="$TARGET_CFLAGS"
1319 # -mno-unaligned-access -mstrict-align
1320 if test "$target_cpu" = arm; then
1321 AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
1322 grub_cv_target_cc_strict_align=
1323 for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
1324 CFLAGS="$TARGET_CFLAGS $arg -Werror"
1325 LDFLAGS="$TARGET_LDFLAGS"
1326 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
1327 if test x"$flag" = x1; then
1328 grub_cv_target_cc_strict_align="$arg"
1333 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
1334 if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
1335 TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
1337 AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
1338 [CFLAGS="$TARGET_CFLAGS"
1339 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1340 #ifdef __ARM_FEATURE_UNALIGNED
1344 [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
1345 if test x$grub_cv_cc_target_emits_unaligned = xyes; then
1346 AC_MSG_ERROR([compiler generates unaligned accesses])
1350 # Set them to their new values for the tests below.
1352 if test x"$platform" = xemu ; then
1353 CFLAGS="$TARGET_CFLAGS -Wno-error"
1354 elif test "x$TARGET_APPLE_LINKER" = x1 ; then
1355 CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
1357 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
1359 CPPFLAGS="$TARGET_CPPFLAGS"
1362 if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
1363 if test x$grub_cv_asm_uscore = xyes; then
1364 DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
1366 DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main"
1368 CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
1371 # Check for libgcc symbols
1372 if test x"$platform" = xemu; then
1373 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)
1376 if test "x$TARGET_APPLE_LINKER" = x1 ; then
1377 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
1379 CFLAGS="$TARGET_CFLAGS -nostdlib"
1383 # Defined in aclocal.m4.
1385 if test "x$TARGET_APPLE_LINKER" != x1 ; then
1386 grub_PROG_OBJCOPY_ABSOLUTE
1388 grub_PROG_LD_BUILD_ID_NONE
1389 if test "x$target_cpu" = xi386; then
1390 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
1391 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
1392 # Check symbols provided by linker script.
1393 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
1395 grub_CHECK_BSS_START_SYMBOL
1396 grub_CHECK_END_SYMBOL
1398 CFLAGS="$TARGET_CFLAGS"
1402 grub_PROG_NM_MINUS_P
1403 grub_PROG_NM_DEFINED_ONLY
1404 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
1405 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
1407 if test "$platform" != emu; then
1408 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
1409 SAVED_CPPFLAGS="$CPPFLAGS"
1410 CPPFLAGS="$TARGET_CPPFLAGS -nostdlib -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1411 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1413 int va_arg_func (int fixed, va_list args);]], [[]])],
1414 [grub_cv_cc_isystem=yes],
1415 [grub_cv_cc_isystem=no])
1416 CPPFLAGS="$SAVED_CPPFLAGS"
1419 if test x"$grub_cv_cc_isystem" = xyes ; then
1420 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1424 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
1425 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
1426 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1427 int va_arg_func (int fixed, va_list args);]], [[]])],
1428 [grub_cv_cc_wtrampolines=yes],
1429 [grub_cv_cc_wtrampolines=no])
1432 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
1433 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
1436 # Restore the flags.
1438 CFLAGS="$tmp_CFLAGS"
1439 CPPFLAGS="$tmp_CPPFLAGS"
1440 LDFLAGS="$tmp_LDFLAGS"
1444 # Check for options.
1447 # Memory manager debugging.
1448 AC_ARG_ENABLE([mm-debug],
1449 AS_HELP_STRING([--enable-mm-debug],
1450 [include memory manager debugging]),
1451 [AC_DEFINE([MM_DEBUG], [1],
1452 [Define to 1 if you enable memory manager debugging.])])
1454 AC_ARG_ENABLE([cache-stats],
1455 AS_HELP_STRING([--enable-cache-stats],
1456 [enable disk cache statistics collection]))
1458 if test x$enable_cache_stats = xyes; then
1463 AC_SUBST([DISK_CACHE_STATS])
1465 AC_ARG_ENABLE([boot-time],
1466 AS_HELP_STRING([--enable-boot-time],
1467 [enable boot time statistics collection]))
1469 if test x$enable_boot_time = xyes; then
1474 AC_SUBST([BOOT_TIME_STATS])
1476 AC_ARG_ENABLE([grub-emu-sdl],
1477 [AS_HELP_STRING([--enable-grub-emu-sdl],
1478 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
1480 AC_ARG_ENABLE([grub-emu-pci],
1481 [AS_HELP_STRING([--enable-grub-emu-pci],
1482 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
1484 if test "$platform" = emu; then
1486 if test x"$enable_grub_emu_sdl" = xno ; then
1487 grub_emu_sdl_excuse="explicitly disabled"
1489 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1490 # Check for libSDL libraries.]
1491 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1492 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1496 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1497 # Check for headers.]
1498 AC_CHECK_HEADERS([SDL/SDL.h], [],
1499 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1502 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1503 AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
1505 if test x"$grub_emu_sdl_excuse" = x ; then
1506 enable_grub_emu_sdl=yes
1508 enable_grub_emu_sdl=no
1511 if test x"$enable_grub_emu_pci" != xyes ; then
1512 grub_emu_pci_excuse="not enabled"
1515 [if [ x"$grub_emu_pci_excuse" = x ]; then
1516 # Check for libpci libraries.]
1517 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1518 [grub_emu_pci_excuse=["need libpciaccess library"]])
1519 AC_SUBST([LIBPCIACCESS])
1521 [if [ x"$grub_emu_pci_excuse" = x ]; then
1522 # Check for headers.]
1523 AC_CHECK_HEADERS([pciaccess.h], [],
1524 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1527 if test x"$grub_emu_pci_excuse" = x ; then
1528 enable_grub_emu_pci=yes
1531 enable_grub_emu_pci=no
1534 AC_SUBST([enable_grub_emu_sdl])
1535 AC_SUBST([enable_grub_emu_pci])
1539 # Ignore --enable-emu-* if platform is not emu
1540 enable_grub_emu_sdl=no
1541 enable_grub_emu_pci=no
1544 AC_ARG_ENABLE([grub-mkfont],
1545 [AS_HELP_STRING([--enable-grub-mkfont],
1546 [build and install the `grub-mkfont' utility (default=guessed)])])
1547 if test x"$enable_grub_mkfont" = xno ; then
1548 grub_mkfont_excuse="explicitly disabled"
1551 unset ac_cv_header_ft2build_h
1553 if test x"$grub_mkfont_excuse" = x ; then
1554 # Check for freetype libraries.
1555 PKG_CHECK_MODULES([FREETYPE], [freetype2], [
1556 SAVED_CPPFLAGS="$CPPFLAGS"
1558 CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
1559 LIBS="$LIBS $FREETYPE_LIBS"
1560 AC_CHECK_HEADERS([ft2build.h], [],
1561 [grub_mkfont_excuse=["need freetype2 headers"]])
1562 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
1563 [grub_mkfont_excuse=["freetype2 library unusable"]])
1564 CPPFLAGS="$SAVED_CPPFLAGS"
1566 ], [grub_mkfont_excuse=["need freetype2 library"]])
1569 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1570 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
1572 if test x"$grub_mkfont_excuse" = x ; then
1573 enable_grub_mkfont=yes
1575 enable_grub_mkfont=no
1577 AC_SUBST([enable_grub_mkfont])
1581 SAVED_CFLAGS="$CFLAGS"
1582 SAVED_CPPFLAGS="$CPPFLAGS"
1583 SAVED_LDFLAGS="$LDFLAGS"
1586 CFLAGS="$BUILD_CFLAGS"
1587 CPPFLAGS="$BUILD_CPPFLAGS"
1588 LDFLAGS="$BUILD_LDFAGS"
1590 unset ac_cv_c_bigendian
1591 unset ac_cv_header_ft2build_h
1593 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1594 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1595 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1597 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1598 AC_MSG_ERROR([couldnt determine build endianness])
1601 AC_SUBST([BUILD_SIZEOF_LONG])
1602 AC_SUBST([BUILD_SIZEOF_VOID_P])
1603 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1605 if test x"$grub_build_mkfont_excuse" = x ; then
1606 # Check for freetype libraries.
1607 SAVED_PKG_CONFIG="$PKG_CONFIG"
1608 test -z "$BUILD_PKG_CONFIG" || PKG_CONFIG="$BUILD_PKG_CONFIG"
1609 PKG_CHECK_MODULES([BUILD_FREETYPE], [freetype2], [
1610 SAVED_CPPFLAGS_2="$CPPFLAGS"
1612 CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS"
1613 LIBS="$LIBS $BUILD_FREETYPE_LIBS"
1614 AC_CHECK_HEADERS([ft2build.h], [],
1615 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1616 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
1617 [grub_build_mkfont_excuse=["freetype2 library unusable"]])
1619 CPPFLAGS="$SAVED_CPPFLAGS_2"
1620 ], [grub_build_mkfont_excuse=["need freetype2 library"]])
1621 PKG_CONFIG="$SAVED_PKG_CONFIG"
1624 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1625 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
1627 if test x"$grub_build_mkfont_excuse" = x ; then
1628 enable_build_grub_mkfont=yes
1630 enable_build_grub_mkfont=no
1632 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
1633 if test x"$grub_build_mkfont_excuse" = x ; then
1634 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont])
1636 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)])
1642 CFLAGS="$SAVED_CFLAGS"
1643 CPPFLAGS="$SAVED_CPPFLAGS"
1644 LDFLAGS="$SAVED_LDFLAGS"
1651 AC_ARG_ENABLE([grub-themes],
1652 [AS_HELP_STRING([--enable-grub-themes],
1653 [build and install GRUB themes (default=guessed)])])
1654 if test x"$enable_grub_themes" = xno ; then
1655 starfield_excuse="explicitly disabled"
1658 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1659 starfield_excuse="No build-time grub-mkfont"
1662 if test x"$starfield_excuse" = x; then
1663 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1664 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
1665 if test -f "$dir/DejaVuSans.$ext"; then
1666 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1672 if test "x$DJVU_FONT_SOURCE" = x; then
1673 starfield_excuse="No DejaVu found"
1677 if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1678 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
1681 AC_SUBST([DJVU_FONT_SOURCE])
1685 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1686 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
1687 if test -f "$dir/unifont.$ext"; then
1688 md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
1689 # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
1690 if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
1693 FONT_SOURCE="$dir/unifont.$ext"
1699 if test x"$enable_build_grub_mkfont" = xno ; then
1703 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
1704 if test x"$grub_build_mkfont_excuse" = x ; then
1705 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont])
1707 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
1711 AC_SUBST([FONT_SOURCE])
1713 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1714 grub_build_mkfont_excuse="no fonts"
1718 AC_ARG_ENABLE([grub-mount],
1719 [AS_HELP_STRING([--enable-grub-mount],
1720 [build and install the `grub-mount' utility (default=guessed)])])
1721 if test x"$enable_grub_mount" = xno ; then
1722 grub_mount_excuse="explicitly disabled"
1725 if test x"$grub_mount_excuse" = x ; then
1726 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1727 [grub_mount_excuse="need FUSE library"])
1730 if test x"$grub_mount_excuse" = x ; then
1731 # Check for fuse headers.
1732 SAVED_CPPFLAGS="$CPPFLAGS"
1733 CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
1734 AC_CHECK_HEADERS([fuse/fuse.h], [],
1735 [grub_mount_excuse=["need FUSE headers"]])
1736 CPPFLAGS="$SAVED_CPPFLAGS"
1739 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1740 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
1742 if test x"$grub_mount_excuse" = x ; then
1743 enable_grub_mount=yes
1745 enable_grub_mount=no
1747 AC_SUBST([enable_grub_mount])
1749 AC_ARG_ENABLE([device-mapper],
1750 [AS_HELP_STRING([--enable-device-mapper],
1751 [enable Linux device-mapper support (default=guessed)])])
1752 if test x"$enable_device_mapper" = xno ; then
1753 device_mapper_excuse="explicitly disabled"
1756 if test x"$device_mapper_excuse" = x ; then
1757 # Check for device-mapper header.
1758 AC_CHECK_HEADER([libdevmapper.h], [],
1759 [device_mapper_excuse="need libdevmapper header"])
1762 if test x"$device_mapper_excuse" = x ; then
1763 # Check for device-mapper library.
1764 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1765 [device_mapper_excuse="need devmapper library"])
1768 if test x"$device_mapper_excuse" = x ; then
1769 # Check for device-mapper library.
1770 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1772 [device_mapper_excuse="need devmapper library"])
1775 if test x"$device_mapper_excuse" = x ; then
1776 LIBDEVMAPPER="-ldevmapper"
1777 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1778 [Define to 1 if you have the devmapper library.])
1781 AC_SUBST([LIBDEVMAPPER])
1784 if test x$host_kernel = xkfreebsd; then
1785 AC_CHECK_LIB([geom], [geom_gettree], [],
1786 [AC_MSG_ERROR([Your platform requires libgeom])])
1792 AC_ARG_ENABLE([liblzma],
1793 [AS_HELP_STRING([--enable-liblzma],
1794 [enable liblzma integration (default=guessed)])])
1795 if test x"$enable_liblzma" = xno ; then
1796 liblzma_excuse="explicitly disabled"
1799 if test x"$liblzma_excuse" = x ; then
1800 AC_CHECK_LIB([lzma], [lzma_code],
1801 [],[liblzma_excuse="need lzma library"])
1803 if test x"$liblzma_excuse" = x ; then
1804 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1807 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1808 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
1812 if test x"$liblzma_excuse" = x ; then
1814 AC_DEFINE([USE_LIBLZMA], [1],
1815 [Define to 1 if you have the LZMA library.])
1820 AC_ARG_ENABLE([libzfs],
1821 [AS_HELP_STRING([--enable-libzfs],
1822 [enable libzfs integration (default=guessed)])])
1823 if test x"$enable_libzfs" = xno ; then
1824 libzfs_excuse="explicitly disabled"
1827 if test x"$libzfs_excuse" = x ; then
1828 # Only check for system headers if libzfs support has not been disabled.
1829 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1832 if test x"$libzfs_excuse" = x ; then
1833 AC_CHECK_LIB([zfs], [libzfs_init],
1835 [libzfs_excuse="need zfs library"])
1838 if test x"$libzfs_excuse" = x ; then
1839 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1841 [libzfs_excuse="need nvpair library"])
1844 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1845 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
1848 if test x"$libzfs_excuse" = x ; then
1849 # We need both libzfs and libnvpair for a successful build.
1851 AC_DEFINE([HAVE_LIBZFS], [1],
1852 [Define to 1 if you have the ZFS library.])
1853 LIBNVPAIR="-lnvpair"
1854 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1855 [Define to 1 if you have the NVPAIR library.])
1859 AC_SUBST([LIBNVPAIR])
1863 AC_SUBST([FONT_SOURCE])
1864 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1865 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1867 AC_SUBST(HAVE_ASM_USCORE)
1868 AC_SUBST(BSS_START_SYMBOL)
1869 AC_SUBST(END_SYMBOL)
1873 AC_ARG_ENABLE([werror],
1874 [AS_HELP_STRING([--disable-werror],
1875 [do not use -Werror when building GRUB])])
1876 if test x"$enable_werror" != xno ; then
1877 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1878 HOST_CFLAGS="$HOST_CFLAGS -Werror"
1881 TARGET_CPP="$TARGET_CC -E"
1882 TARGET_CCAS=$TARGET_CC
1884 # Includes which include make-time substitutions. They must come last
1885 # as to avoid executing top_builddir in shell.
1886 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
1887 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
1888 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
1890 GRUB_TARGET_CPU="${target_cpu}"
1891 GRUB_PLATFORM="${platform}"
1893 AC_SUBST(GRUB_TARGET_CPU)
1894 AC_SUBST(GRUB_PLATFORM)
1896 AC_SUBST(TARGET_OBJCONV)
1897 AC_SUBST(TARGET_CPP)
1898 AC_SUBST(TARGET_CCAS)
1899 AC_SUBST(TARGET_OBJ2ELF)
1900 AC_SUBST(TARGET_MODULE_FORMAT)
1901 AC_SUBST(TARGET_CC_VERSION)
1903 AC_SUBST(TARGET_CFLAGS)
1904 AC_SUBST(TARGET_LDFLAGS)
1905 AC_SUBST(TARGET_CPPFLAGS)
1906 AC_SUBST(TARGET_CCASFLAGS)
1908 AC_SUBST(TARGET_IMG_LDFLAGS)
1909 AC_SUBST(TARGET_IMG_CFLAGS)
1910 AC_SUBST(TARGET_IMG_BASE_LDOPT)
1911 AC_SUBST(TARGET_APPLE_LINKER)
1913 AC_SUBST(HOST_CFLAGS)
1914 AC_SUBST(HOST_LDFLAGS)
1915 AC_SUBST(HOST_CPPFLAGS)
1916 AC_SUBST(HOST_CCASFLAGS)
1918 AC_SUBST(BUILD_LIBM)
1921 # Automake conditionals
1924 AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
1925 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1926 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1927 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1928 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1929 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1930 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1931 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1932 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1933 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1934 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1935 AM_CONDITIONAL([COND_i386_xen_pvh], [test x$target_cpu = xi386 -a x$platform = xxen_pvh])
1936 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
1937 AM_CONDITIONAL([COND_mips64_efi], [test x$target_cpu = xmips64el -a x$platform = xefi])
1938 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1939 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1940 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1941 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1942 AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
1943 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1944 AM_CONDITIONAL([COND_mips64el], [test x$target_cpu = xmips64el])
1945 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1946 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1947 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1948 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1949 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1950 AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot])
1951 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1952 AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
1953 AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
1954 AM_CONDITIONAL([COND_riscv32], [test x$target_cpu = xriscv32 ])
1955 AM_CONDITIONAL([COND_riscv64], [test x$target_cpu = xriscv64 ])
1956 AM_CONDITIONAL([COND_riscv32_efi], [test x$target_cpu = xriscv32 -a x$platform = xefi])
1957 AM_CONDITIONAL([COND_riscv64_efi], [test x$target_cpu = xriscv64 -a x$platform = xefi])
1959 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1960 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1961 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1962 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1963 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1964 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1965 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1967 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1968 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1969 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1970 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1971 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1972 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1973 if test x$FONT_SOURCE != x ; then
1978 AC_SUBST(HAVE_FONT_SOURCE)
1979 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
1980 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1981 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1982 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1984 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1986 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1987 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1988 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
1990 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
1991 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
1992 datarootdir="$(eval echo "$datarootdir")"
1993 grub_libdir="$(eval echo "$libdir")"
1994 grub_localedir="$(eval echo "$localedir")"
1995 grub_datadir="$(eval echo "$datadir")"
1996 grub_sysconfdir="$(eval echo "$sysconfdir")"
1997 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
1998 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
1999 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
2000 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
2004 if test "$platform" != none; then
2005 cpudir="${target_cpu}"
2006 if test x${cpudir} = xmips64el; then
2008 elif test x${cpudir} = xmipsel; then
2012 if test x"$link_dir" = xyes ; then
2013 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
2014 if test "$platform" != emu ; then
2015 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
2018 mkdir -p include/grub 2>/dev/null
2019 rm -rf include/grub/cpu
2020 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
2021 if test "$platform" != emu ; then
2022 rm -rf include/grub/machine
2023 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
2027 # Just enough to stop the compiler failing with -I$(srcdir)/include.
2028 mkdir -p include 2>/dev/null
2029 rm -rf include/grub/cpu include/grub/machine
2032 AC_CONFIG_FILES([Makefile])
2033 AC_CONFIG_FILES([grub-core/Makefile])
2034 AC_CONFIG_FILES([grub-core/lib/gnulib/Makefile])
2035 AC_CONFIG_FILES([po/Makefile.in])
2036 AC_CONFIG_FILES([docs/Makefile])
2037 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
2038 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
2039 AC_CONFIG_FILES([config.h])
2043 echo "*******************************************************"
2044 echo GRUB2 will be compiled with following components:
2045 echo Platform: "$target_cpu"-"$platform"
2046 if [ x"$platform" = xemu ]; then
2047 if [ x"$grub_emu_sdl_excuse" = x ]; then
2048 echo SDL support for grub-emu: Yes
2050 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
2052 if [ x"$grub_emu_pci_excuse" = x ]; then
2053 echo PCI support for grub-emu: Yes
2055 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
2058 if test x"$device_mapper_excuse" = x ; then
2059 echo With devmapper support: Yes
2061 echo With devmapper support: No "($device_mapper_excuse)"
2063 if [ x"$enable_mm_debug" = xyes ]; then
2064 echo With memory debugging: Yes
2066 echo With memory debugging: No
2068 if [ x"$enable_cache_stats" = xyes ]; then
2069 echo With disk cache statistics: Yes
2071 echo With disk cache statistics: No
2074 if [ x"$enable_boot_time" = xyes ]; then
2075 echo With boot time statistics: Yes
2077 echo With boot time statistics: No
2080 if [ x"$efiemu_excuse" = x ]; then
2081 echo efiemu runtime: Yes
2083 echo efiemu runtime: No "($efiemu_excuse)"
2085 if [ x"$grub_mkfont_excuse" = x ]; then
2086 echo grub-mkfont: Yes
2088 echo grub-mkfont: No "($grub_mkfont_excuse)"
2090 if [ x"$grub_mount_excuse" = x ]; then
2091 echo grub-mount: Yes
2093 echo grub-mount: No "($grub_mount_excuse)"
2095 if [ x"$starfield_excuse" = x ]; then
2096 echo starfield theme: Yes
2097 echo With DejaVuSans font from $DJVU_FONT_SOURCE
2099 echo starfield theme: No "($starfield_excuse)"
2101 if [ x"$libzfs_excuse" = x ]; then
2102 echo With libzfs support: Yes
2104 echo With libzfs support: No "($libzfs_excuse)"
2106 if [ x"$grub_build_mkfont_excuse" = x ]; then
2107 echo Build-time grub-mkfont: Yes
2108 if test "x$FONT_SOURCE" = x ; then
2109 echo "Without unifont"
2111 echo "With unifont from $FONT_SOURCE"
2114 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
2115 echo "Without unifont (no build-time grub-mkfont)"
2117 if test x"$liblzma_excuse" != x ; then
2118 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
2120 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
2122 echo "*******************************************************"