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 and target type, variables with
30 dnl prefix "BUILD_" (such as BUILD_CC, BUILD_CFLAGS, etc.) for the
31 dnl build type, variables with prefix "HOST_" (such as HOST_CC,
32 dnl HOST_CFLAGS, etc.) for the host type and variables with the prefix
33 dnl "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for
34 dnl the target type. See INSTALL for full list of variables and
35 dnl description of the relationships between them.
37 AC_INIT([GRUB],[2.13],[bug-grub@gnu.org])
39 AS_CASE(["$ERROR_PLATFORM_NOT_SUPPORT_SSP"],
40 [n | no | nO | N | No | NO], [ERROR_PLATFORM_NOT_SUPPORT_SSP=no],
41 [ERROR_PLATFORM_NOT_SUPPORT_SSP=yes])
43 # We don't want -g -O2 by default in CFLAGS
46 AC_USE_SYSTEM_EXTENSIONS
47 AC_CONFIG_AUX_DIR([build-aux])
49 # Checks for build, host and target systems.
52 save_program_prefix="${program_prefix}"
54 program_prefix="${save_program_prefix}"
56 AM_INIT_AUTOMAKE([1.11])
58 AC_CONFIG_SRCDIR([include/grub/dl.h])
59 AC_CONFIG_HEADERS([config-util.h])
61 # Explicitly check for pkg-config early on, since otherwise conditional
62 # calls are problematic.
65 # Program name transformations
67 grub_TRANSFORM([grub-bios-setup])
68 grub_TRANSFORM([grub-editenv])
69 grub_TRANSFORM([grub-install])
70 grub_TRANSFORM([grub-mkconfig])
71 grub_TRANSFORM([grub-mkfont])
72 grub_TRANSFORM([grub-mkimage])
73 grub_TRANSFORM([grub-glue-efi])
74 grub_TRANSFORM([grub-mklayout])
75 grub_TRANSFORM([grub-mkpasswd-pbkdf2])
76 grub_TRANSFORM([grub-mkrelpath])
77 grub_TRANSFORM([grub-mkrescue])
78 grub_TRANSFORM([grub-probe])
79 grub_TRANSFORM([grub-reboot])
80 grub_TRANSFORM([grub-script-check])
81 grub_TRANSFORM([grub-set-default])
82 grub_TRANSFORM([grub-sparc64-setup])
83 grub_TRANSFORM([grub-render-label])
84 grub_TRANSFORM([grub-file])
86 # Allow HOST_CC to override CC.
87 if test "x$HOST_CC" != x; then
91 # Optimization flag. Allow user to override.
92 if test "x$TARGET_CFLAGS" = x; then
96 # Enable support for "restrict" keyword and other
97 # features from gnu99 C language standard.
98 BUILD_CFLAGS="-std=gnu99 -fno-common $BUILD_CFLAGS"
99 HOST_CFLAGS="-std=gnu99 -fno-common $HOST_CFLAGS"
100 TARGET_CFLAGS="-std=gnu99 -fno-common $TARGET_CFLAGS"
102 # Default HOST_CPPFLAGS
103 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
104 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
106 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
108 case "$target_cpu" in
109 i[[3456]]86) target_cpu=i386 ;;
110 amd64) target_cpu=x86_64 ;;
111 sparc) target_cpu=sparc64 ;;
114 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
118 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
120 arm*) target_cpu=arm ;;
121 aarch64*) target_cpu=arm64 ;;
122 loongarch64) target_cpu=loongarch64 ;;
123 riscv32*) target_cpu=riscv32 ;;
124 riscv64*) target_cpu=riscv64 ;;
127 # Specify the platform (such as firmware).
128 AC_ARG_WITH([platform],
129 AS_HELP_STRING([--with-platform=PLATFORM],
130 [select the host platform [[guessed]]]))
132 # Guess the platform if not specified.
133 if test "x$with_platform" = x; then
134 case "$target_cpu"-"$target_vendor" in
135 i386-apple) platform=efi ;;
136 i386-*) platform=pc ;;
137 x86_64-apple) platform=efi ;;
138 x86_64-*) platform=pc ;;
139 powerpc-*) platform=ieee1275 ;;
140 powerpc64-*) platform=ieee1275 ;;
141 powerpc64le-*) platform=ieee1275 ;;
142 sparc64-*) platform=ieee1275 ;;
143 mipsel-*) platform=loongson ;;
144 mips-*) platform=arc ;;
145 ia64-*) platform=efi ;;
146 arm-*) platform=uboot ;;
147 arm64-*) platform=efi ;;
148 loongarch64-*) platform=efi;;
149 riscv32-*) platform=efi ;;
150 riscv64-*) platform=efi ;;
152 AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
157 platform="$with_platform"
160 case "$target_cpu"-"$platform" in
165 x86_64-*) target_cpu=i386 ;;
166 powerpc64-ieee1275) target_cpu=powerpc ;;
167 powerpc64le-ieee1275) target_cpu=powerpc ;;
170 # Check if the platform is supported, make final adjustments.
171 case "$target_cpu"-"$platform" in
180 i386-linuxbios) platform=coreboot ;;
187 mips-qemu-mips) platform=qemu_mips;;
191 mipsel-qemu-mips) platform=qemu_mips;;
192 mipsel-yeeloong) platform=loongson ;;
193 mipsel-fuloong) platform=loongson ;;
204 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
207 if test x$platform != xemu ; then
208 case "$target_cpu" in
209 i386 | powerpc) target_m32=1 ;;
210 x86_64 | sparc64) target_m64=1 ;;
214 if test x"$target_cpu-$platform" = xsparc64-emu ; then
219 windows* | mingw32*) target_os=cygwin ;;
222 # This normalizes the names, and creates a new variable ("host_kernel")
223 # while at it, since the mapping is not always 1:1 (e.g. different OSes
224 # using the same kernel type).
226 gnu*) host_kernel=hurd ;;
227 linux*) host_kernel=linux ;;
228 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
229 netbsd*) host_kernel=netbsd ;;
230 solaris*) host_kernel=illumos ;;
231 darwin*) host_kernel=xnu ;;
232 cygwin | windows* | mingw32*) host_kernel=windows ;;
236 cygwin) have_exec=y ;;
237 windows* | mingw32*) have_exec=n ;;
238 aros*) have_exec=n ;;
243 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
244 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
245 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
246 xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
247 xen_pvh) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN_PVH=1" ;;
248 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
249 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
250 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
251 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
252 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
253 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
254 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
255 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
257 if test x${target_cpu} = xmipsel ; then
258 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
260 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
263 case "${target_cpu}-$platform" in
265 TARGET_LINK_ADDR=0x88200000
266 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
269 TARGET_LINK_ADDR=0x80700000
270 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
272 mips*-qemu_mips | mips*-loongson)
273 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
277 AC_SUBST(TARGET_LINK_ADDR)
278 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
280 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
284 AC_SUBST(host_kernel)
289 # Define default variables
292 AC_ARG_WITH([bootdir],
293 AS_HELP_STRING([--with-bootdir=DIR],
294 [set the name of /boot directory [[guessed]]]),
295 [have_with_bootdir=y],
296 [have_with_bootdir=n])
297 if test x$have_with_bootdir = xy; then
298 bootdirname="$with_bootdir"
302 # Because /boot is used for the boot block in NetBSD and OpenBSD,
304 *) bootdirname='boot' ;;
308 AC_SUBST(bootdirname)
309 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
310 [Default boot directory name])
312 AC_ARG_WITH([grubdir],
313 AS_HELP_STRING([--with-grubdir=DIR],
314 [set the name of grub directory [[guessed]]]),
315 [grubdirname="$with_grubdir"],
316 [grubdirname="$PACKAGE"])
318 AC_SUBST(grubdirname)
319 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
320 [Default grub directory name])
323 # Checks for build programs.
326 # Although cmp is listed in the GNU Coding Standards as a command which
327 # can used directly, OpenBSD lacks cmp in the default installation.
328 AC_CHECK_PROGS([CMP], [cmp])
329 if test "x$CMP" = x; then
330 AC_MSG_ERROR([cmp is not found])
333 AC_CHECK_PROGS([YACC], [bison])
334 if test "x$YACC" = x; then
335 AC_MSG_ERROR([bison is not found])
341 AC_PROG_LEX([noyywrap])
347 if test "x$LEX" = "x:"; then
348 AC_MSG_ERROR([flex is not found])
350 version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
351 if test -n "$version" -a "$version" -ge 20535; then
354 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
358 # These are not a "must".
359 AC_PATH_PROGS(MAKEINFO, makeinfo true)
362 # Checks for host programs.
370 AM_PATH_PYTHON([2.6])
373 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
375 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
377 AM_GNU_GETTEXT([external])
378 AM_GNU_GETTEXT_VERSION([0.18.3])
381 PLATFORMS_PCI=" $(PYTHONPATH="${srcdir}" $PYTHON -c 'import gentpl; print(" ".join(gentpl.GROUPS[["pci"]]))') "
382 if test x"${PLATFORMS_PCI##* ${target_cpu}_${platform} *}" = x ; then
386 # Identify characteristics of the host architecture.
387 unset ac_cv_c_bigendian
389 if test x"$target_cpu-$platform" = xsparc64-emu ; then
390 CFLAGS="$CFLAGS -m64"
391 HOST_CFLAGS="$HOST_CFLAGS -m64"
394 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
395 HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
398 AC_CHECK_SIZEOF(void *)
399 AC_CHECK_SIZEOF(long)
402 cygwin | windows* | mingw32*)
403 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
404 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
405 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
410 cygwin | windows* | mingw32* | aros*)
413 AC_CHECK_SIZEOF(off_t)
414 if test x"$ac_cv_sizeof_off_t" != x8 ; then
415 AC_CHECK_SIZEOF(off64_t)
416 test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required])
420 if test x$USE_NLS = xno; then
421 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
424 if test "x$cross_compiling" = xyes; then
425 AC_MSG_WARN([cannot generate manual pages while cross compiling])
427 AC_PATH_PROG(HELP2MAN, help2man)
430 # Check for functions and headers.
431 AC_CHECK_FUNCS(posix_memalign memalign getextmntent atexit)
432 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
434 # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
435 # warning which causes compilation failure later with -Werror. So use -Werror here
436 # as well to force proper sys/sysmacros.h detection. Used in include/grub/osdep/major.h.
437 SAVED_CFLAGS="$CFLAGS"
438 CFLAGS="$HOST_CFLAGS -Werror"
440 CFLAGS="$SAVED_CFLAGS"
442 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
443 #include <sys/param.h>
444 #include <sys/mount.h>])
446 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
447 #include <sys/param.h>
448 #include <sys/mount.h>])
450 # For opendisk() and getrawpartition() on NetBSD.
451 # Used in util/deviceiter.c and in util/hostdisk.c.
452 AC_CHECK_HEADER([util.h], [
453 AC_CHECK_LIB([util], [opendisk], [
455 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
457 AC_CHECK_LIB([util], [getrawpartition], [
459 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
464 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
465 SAVED_CFLAGS="$CFLAGS"
466 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
467 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
468 int va_arg_func (int fixed, va_list args);]], [[]])],
469 [grub_cv_host_cc_wtrampolines=yes],
470 [grub_cv_host_cc_wtrampolines=no])
471 CFLAGS="$SAVED_CFLAGS"
474 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
475 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
479 # Check for host and build compilers.
482 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
483 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
484 BUILD_CPP="$BUILD_CC -E"
487 haiku*) BUILD_LIBM= ;;
491 dnl FIXME proper test seems to require too deep dive into Autoconf internals.
492 dnl For now just list known platforms that we support.
495 cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
498 AC_SUBST(BUILD_EXEEXT)
500 # In some build environments like termux /bin/sh is not a valid
501 # shebang. Use $SHELL instead if it's executable and /bin/sh isn't
502 BUILD_SHEBANG=/bin/sh
503 for she in /bin/sh "$SHELL"; do
504 if test -x "$she" ; then
508 AC_SUBST(BUILD_SHEBANG)
513 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"
514 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"
516 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
518 AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
519 SAVED_CFLAGS="$CFLAGS"
520 grub_cv_cc_w_extra_flags=
521 for x in $EXTRA_WARN_FLAGS; do
522 CFLAGS="$HOST_CFLAGS $x -Werror"
523 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
524 if test x$flag = x1 ; then
525 grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
528 CFLAGS="$SAVED_CFLAGS"
531 HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
534 # Check for target programs.
537 # Find tools for the target.
538 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
539 tmp_ac_tool_prefix="$ac_tool_prefix"
540 ac_tool_prefix=$target_alias-
542 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
543 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
544 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
545 AC_CHECK_TOOL(TARGET_STRIP, strip)
546 AC_CHECK_TOOL(TARGET_NM, nm)
547 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
549 ac_tool_prefix="$tmp_ac_tool_prefix"
551 if test "x$TARGET_CC" = x; then
554 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
555 AC_CHECK_TOOL(TARGET_STRIP, strip)
556 AC_CHECK_TOOL(TARGET_NM, nm)
557 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
562 AC_SUBST(BUILD_CFLAGS)
563 AC_SUBST(BUILD_CPPFLAGS)
564 AC_SUBST(BUILD_LDFLAGS)
567 AC_SUBST(TARGET_RANLIB)
568 AC_SUBST(TARGET_STRIP)
569 AC_SUBST(TARGET_OBJCOPY)
571 # Test the C compiler for the target environment.
574 tmp_LDFLAGS="$LDFLAGS"
575 tmp_CPPFLAGS="$CPPFLAGS"
578 CFLAGS="$TARGET_CFLAGS"
579 CPPFLAGS="$TARGET_CPPFLAGS"
580 LDFLAGS="$TARGET_LDFLAGS"
583 if test "x$target_m32" = x1; then
585 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
586 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
587 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
588 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
589 TARGET_MODULE_FORMAT="elf32"
592 if test "x$target_m64" = x1; then
594 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
595 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
596 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
597 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
598 TARGET_MODULE_FORMAT="elf64"
602 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
603 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
605 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
606 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
609 TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
611 AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
612 LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
614 grub_cv_target_cc_w_extra_flags=
615 for x in $EXTRA_WARN_FLAGS; do
616 CFLAGS="$TARGET_CFLAGS $x -Werror"
617 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
618 asm (".globl start; start:");
620 void __main (void) {}
622 ]], [[]])], [flag=1], [flag=0])
623 if test x$flag = x1 ; then
624 grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
629 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
631 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
633 CFLAGS="$TARGET_CFLAGS"
635 [AC_LANG_PROGRAM([], [[
640 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
642 if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
643 AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
644 grub_cv_target_cc_big_endian=no
645 for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
646 "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
647 "-EB" "-mbig-endian"; do
648 if test x"$grub_cv_target_cc_big_endian" != xno ; then
651 CFLAGS="$TARGET_CFLAGS $cand -Werror"
652 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
653 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
654 #error still little endian
656 asm (".globl start; start:");
657 asm (".globl _start; _start:");
658 asm (".globl __start; __start:");
660 void __main (void) {}
663 [grub_cv_target_cc_big_endian="$cand"], [])
667 if test x"$grub_cv_target_cc_big_endian" = xno ; then
668 AC_MSG_ERROR([could not force big-endian])
671 skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
673 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
674 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
675 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
676 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
677 elif test x$target_cpu = xmipsel; then
678 AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
679 grub_cv_target_cc_little_endian=no
680 for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
681 "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
683 if test x"$grub_cv_target_cc_little_endian" != xno ; then
686 CFLAGS="$TARGET_CFLAGS $cand -Werror"
687 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
688 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
689 #error still big endian
691 asm (".globl start; start:");
692 asm (".globl _start; _start:");
693 asm (".globl __start; __start:");
695 void __main (void) {}
698 [grub_cv_target_cc_little_endian="$cand"], [])
702 if test x"$grub_cv_target_cc_little_endian" = xno ; then
703 AC_MSG_ERROR([could not force little-endian])
706 skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
708 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
709 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
710 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
711 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
714 # GRUB code is N32-compliant but it's experimental and we would prefer to
715 # avoid having too much variety when it doesn't result in any real improvement.
716 # Moreover N64 isn't supported.
717 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
718 AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
719 grub_cv_target_cc_mips_o32_abi=no
720 for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
721 if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
724 CFLAGS="$TARGET_CFLAGS $arg -Werror"
725 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
726 #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
729 asm (".globl start; start:");
730 asm (".globl _start; _start:");
731 asm (".globl __start; __start:");
733 void __main (void) {}
736 [grub_cv_target_cc_mips_o32_abi="$arg"], [])
740 if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
741 AC_MSG_ERROR([could not force MIPS o32 ABI])
744 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
745 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
748 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
750 case "x$target_cpu-$platform" in
760 xpowerpc-* | xsparc64-* | xarm-*)
761 test_program=$target_cpu
764 if test x"$test_program" = x ; then
765 grub_cv_cc_target_asm_compile=
768 for arg in "" "-no-integrated-as"; do
769 cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
770 echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
771 if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
772 grub_cv_cc_target_asm_compile="$arg"
777 if test x"$found" = xno ; then
778 AC_MSG_ERROR([could not compile assembly])
783 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
785 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
786 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
789 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
790 TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
793 # on mips redirect cache flushing function to non-existant one.
794 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
795 AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
796 CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
797 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
798 [grub_cv_cc_mflush_func=yes],
799 [grub_cv_cc_mflush_func=no])
802 if test "x$grub_cv_cc_mflush_func" = xyes; then
803 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
808 # Force no alignment to save space on i386.
809 if test "x$target_cpu" = xi386; then
810 TARGET_CFLAGS="$TARGET_CFLAGS -falign-functions=1"
812 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
813 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
814 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
815 [grub_cv_cc_falign_loop=yes],
816 [grub_cv_cc_falign_loop=no])
819 if test "x$grub_cv_cc_falign_loop" = xyes; then
820 TARGET_CFLAGS="$TARGET_CFLAGS -falign-loops=1"
823 AC_CACHE_CHECK([whether -falign-jumps works], [grub_cv_cc_falign_jumps], [
824 CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -Werror"
825 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
826 [grub_cv_cc_falign_jumps=yes],
827 [grub_cv_cc_falign_jumps=no])
830 if test "x$grub_cv_cc_falign_jumps" = xyes; then
831 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1"
835 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
836 CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
837 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
838 [grub_cv_cc_freg_struct_return=yes],
839 [grub_cv_cc_freg_struct_return=no])
842 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
843 TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
846 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
847 # Some toolchains enable these features by default, but they need
848 # registers that aren't set up properly in GRUB.
849 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
852 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ); then
853 AC_CACHE_CHECK([whether -Wa,-mx86-used-note works], [grub_cv_cc_mx86_used_note], [
854 CFLAGS="$TARGET_CFLAGS -Wa,-mx86-used-note=no -Werror"
855 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
856 [grub_cv_cc_mx86_used_note=yes],
857 [grub_cv_cc_mx86_used_note=no])
860 if test "x$grub_cv_cc_mx86_used_note" = xyes; then
861 TARGET_CFLAGS="$TARGET_CFLAGS -Wa,-mx86-used-note=no"
862 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mx86-used-note=no"
866 if test "x$target_cpu" = xloongarch64; then
867 AC_CACHE_CHECK([whether _mno_explicit_relocs works], [grub_cv_cc_mno_explicit_relocs], [
868 CFLAGS="$TARGET_CFLAGS -mno-explicit-relocs -Werror"
869 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
870 [grub_cv_cc_mno_explicit_relocs=yes],
871 [grub_cv_cc_mno_explicit_relocs=no])
873 if test "x$grub_cv_cc_mno_explicit_relocs" = xyes; then
874 TARGET_CFLAGS="$TARGET_CFLAGS -mno-explicit-relocs -fno-plt"
875 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -mno-explicit-relocs -fno-plt"
878 AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
879 grub_cv_target_cc_mno_relax=no
880 for cand in "-mno-relax" "-Wa,-mno-relax"; do
881 if test x"$grub_cv_target_cc_mno_relax" != xno ; then
884 CFLAGS="$TARGET_CFLAGS $cand -Werror"
885 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
886 asm (".globl start; start:");
888 void __main (void) {}
890 ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
893 CFLAGS="$TARGET_CFLAGS"
895 if test x"$grub_cv_target_cc_mno_relax" != xno ; then
896 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_relax"
897 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mno_relax"
900 TARGET_CFLAGS="$TARGET_CFLAGS -Wa,-mla-global-with-abs"
901 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mla-global-with-abs"
904 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
905 # that floats are a good fit to run instead of what's written in the code.
906 # Given that floating point unit is disabled (if present to begin with)
907 # when GRUB is running which may result in various hard crashes.
908 if test x"$platform" != xemu ; then
909 AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
910 grub_cv_target_cc_soft_float=no
911 if test "x$target_cpu" = xarm64; then
912 CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
913 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
914 [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
916 if test "x$target_cpu" = xriscv32; then
917 CFLAGS="$TARGET_CFLAGS -march=rv32imac -mabi=ilp32 -Werror"
918 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
919 [grub_cv_target_cc_soft_float="-march=rv32imac -mabi=ilp32"], [])
920 # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
921 CFLAGS="$TARGET_CFLAGS -march=rv32imac_zicsr_zifencei -mabi=ilp32 -Werror"
922 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
923 [grub_cv_target_cc_soft_float="-march=rv32imac_zicsr_zifencei -mabi=ilp32"], [])
925 if test "x$target_cpu" = xriscv64; then
926 CFLAGS="$TARGET_CFLAGS -march=rv64imac -mabi=lp64 -Werror"
927 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
928 [grub_cv_target_cc_soft_float="-march=rv64imac -mabi=lp64"], [])
929 # ISA spec version 20191213 factored out extensions Zicsr and Zifencei
930 CFLAGS="$TARGET_CFLAGS -march=rv64imac_zicsr_zifencei -mabi=lp64 -Werror"
931 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
932 [grub_cv_target_cc_soft_float="-march=rv64imac_zicsr_zifencei -mabi=lp64"], [])
934 if test "x$target_cpu" = xia64; then
935 CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
936 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
937 [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
939 if test "x$target_cpu" = xsh4; then
940 CFLAGS="$TARGET_CFLAGS -m4-nofpu -Werror"
941 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
942 [grub_cv_target_cc_soft_float="-m4-nofpu"], [])
944 for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
945 "-Xclang -msoft-float -Xclang -no-implicit-float" \
946 "-Xclang -msoft-float" "-msoft-float"; do
947 if test x"$grub_cv_target_cc_soft_float" != xno ; then
950 CFLAGS="$TARGET_CFLAGS $cand -Werror"
951 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
952 [grub_cv_target_cc_soft_float="$cand"], [])
956 if test x"$grub_cv_target_cc_soft_float" = xno ; then
957 AC_MSG_ERROR([could not force soft-float])
960 case x"$grub_cv_target_cc_soft_float" in
962 # A trick so that clang doesn't see it on link stаge
963 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
966 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
969 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
973 if test x"$target_cpu" = xsparc64 ; then
974 AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
975 grub_cv_target_cc_mno_app_regs=no
976 for cand in "-mllvm -sparc-reserve-app-registers" \
978 if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
981 CFLAGS="$TARGET_CFLAGS $cand -Werror"
982 CPPFLAGS="$TARGET_CPPFLAGS"
983 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
984 [grub_cv_target_cc_mno_app_regs="$cand"], [])
988 if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
989 AC_MSG_ERROR([could not reserve application registers])
991 if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
992 # A trick so that clang doesn't see it on link stаge
993 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
995 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
998 AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
999 grub_cv_target_cc_mno_relax=no
1000 for cand in "-mno-relax" "-Wl,--no-relax"; do
1001 if test x"$grub_cv_target_cc_mno_relax" != xno ; then
1004 LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
1005 CFLAGS="$TARGET_CFLAGS -Werror"
1006 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1007 asm (".globl start; start:");
1009 void __main (void) {}
1011 ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
1014 LDFLAGS="$TARGET_LDFLAGS"
1015 CFLAGS="$TARGET_CFLAGS"
1017 if test x"$grub_cv_target_cc_mno_relax" = xno ; then
1018 AC_MSG_ERROR([could not find no-relax options])
1020 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
1023 # The backtrace module relies on frame pointers and the default optimization
1024 # level, -Os, omits them. Make sure they are enabled.
1025 AC_CACHE_CHECK([whether -fno-omit-frame-pointer works], [grub_cv_cc_fno_omit_frame_pointer], [
1026 CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer"
1027 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1028 [grub_cv_cc_fno_omit_frame_pointer=yes],
1029 [grub_cv_cc_fno_omit_frame_pointer=no])
1032 if test "x$grub_cv_cc_fno_omit_frame_pointer" = xyes; then
1033 TARGET_CFLAGS="$TARGET_CFLAGS -fno-omit-frame-pointer"
1036 # By default, GCC 4.4 generates .eh_frame sections containing unwind
1037 # information in some cases where it previously did not. GRUB doesn't need
1038 # these and they just use up vital space. Restore the old compiler
1040 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
1041 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
1042 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1043 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
1044 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
1047 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
1048 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
1051 if test x"$target_os" = xcygwin; then
1052 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
1053 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
1054 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1055 [grub_cv_cc_no_reorder_functions=yes],
1056 [grub_cv_cc_no_reorder_functions=no])
1060 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
1061 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
1064 AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
1065 CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
1066 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1067 [grub_cv_cc_mno_stack_arg_probe=yes],
1068 [grub_cv_cc_mno_stack_arg_probe=no])
1071 if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
1072 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
1076 # By default, GCC 4.6 generates .eh_frame sections containing unwind
1077 # information in some cases where it previously did not. GRUB doesn't need
1078 # these and they just use up vital space. Restore the old compiler
1080 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
1081 CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
1082 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1083 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
1084 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
1087 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
1088 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
1091 AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
1092 CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
1093 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1094 [grub_cv_cc_fno_unwind_tables=yes],
1095 [grub_cv_cc_fno_unwind_tables=no])
1098 if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
1099 TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
1102 # Do not generate .ident sections.
1103 AC_CACHE_CHECK([whether -fno-ident works], [grub_cv_cc_fno_ident], [
1104 CFLAGS="$TARGET_CFLAGS -fno-ident"
1105 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1106 [grub_cv_cc_fno_ident=yes],
1107 [grub_cv_cc_fno_ident=no])
1110 if test "x$grub_cv_cc_fno_ident" = xyes; then
1111 TARGET_CFLAGS="$TARGET_CFLAGS -fno-ident"
1114 CFLAGS="$TARGET_CFLAGS"
1117 if test x"$platform" = xemu ; then
1119 grub_cv_target_cc_link_format=
1122 grub_cv_target_cc_link_format="-arch,${target_cpu}"
1123 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1125 *windows* | *cygwin* | *mingw*)
1126 if test x${target_cpu} = xi386 ; then
1127 grub_cv_target_cc_link_format=-mi386pe
1128 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1130 if test x${target_cpu} = xx86_64 ; then
1131 grub_cv_target_cc_link_format=-mi386pep
1132 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1134 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1137 elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
1138 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
1139 grub_cv_target_cc_link_format=unknown
1140 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
1141 if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
1144 if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
1147 CFLAGS="$TARGET_CFLAGS"
1148 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
1149 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1150 asm (".globl start; start:");
1151 asm (".globl _start; _start:");
1152 asm (".globl __start; __start:");
1154 void __main (void) {}
1155 ]], [[]])], [flag=1], [flag=0])
1156 if test x"$flag" = x1; then
1157 grub_cv_target_cc_link_format="$format"
1161 if test x"$grub_cv_target_cc_link_format" = xunknown; then
1162 AC_MSG_ERROR([no suitable link format found])
1164 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1165 if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
1166 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1168 if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1169 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1173 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
1174 TARGET_APPLE_LINKER=1
1175 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
1176 if test "x$TARGET_OBJCONV" = x ; then
1177 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
1179 if test "x$TARGET_OBJCONV" = x ; then
1180 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
1182 TARGET_IMG_LDSCRIPT=
1183 TARGET_IMG_CFLAGS="-static"
1184 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1185 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1186 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
1187 TARGET_LDFLAGS_OLDMAGIC=""
1188 elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
1189 TARGET_APPLE_LINKER=0
1190 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1191 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/i386-cygwin-img-ld.sc"
1192 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
1193 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/i386-cygwin-img-ld.sc"
1194 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1197 TARGET_APPLE_LINKER=0
1198 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1199 TARGET_IMG_LDSCRIPT=
1200 TARGET_IMG_LDFLAGS='-Wl,-N'
1201 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
1202 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1206 CFLAGS="$TARGET_CFLAGS"
1208 AC_ARG_ENABLE([efiemu],
1209 [AS_HELP_STRING([--enable-efiemu],
1210 [build and install the efiemu runtimes (default=guessed)])])
1211 if test x"$enable_efiemu" = xno ; then
1212 efiemu_excuse="explicitly disabled"
1215 if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1216 efiemu_excuse="not available on cygwin"
1218 if test x"$target_cpu" != xi386 ; then
1219 efiemu_excuse="only available on i386"
1221 if test x"$platform" = xefi ; then
1222 efiemu_excuse="not available on efi"
1225 if test x"$efiemu_excuse" = x ; then
1226 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
1227 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1228 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1229 [grub_cv_cc_efiemu=yes],
1230 [grub_cv_cc_efiemu=no])
1232 if test x$grub_cv_cc_efiemu = xno; then
1233 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
1236 if test x"$efiemu_excuse" = x ; then
1237 AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
1238 grub_cv_target_cc_efiemu64_link_format=unknown
1239 for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
1240 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1241 LDFLAGS="-m64 -Wl,$format -nostdlib -static"
1242 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1243 asm (".globl start; start:");
1244 asm (".globl _start; _start:");
1245 asm (".globl __start; __start:");
1247 void __main (void) {}
1248 ]], [[]])], [flag=1], [flag=0])
1249 if test x"$flag" = x1; then
1250 grub_cv_target_cc_efiemu64_link_format="$format"
1254 if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
1255 efiemu_excuse="no suitable link format for efiemu64 found"
1257 EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
1260 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
1261 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
1263 if test x"$efiemu_excuse" = x ; then
1268 AC_SUBST([enable_efiemu])
1269 AC_SUBST([EFIEMU64_LINK_FORMAT])
1271 CFLAGS="$TARGET_CFLAGS"
1273 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
1276 LDFLAGS="$TARGET_LDFLAGS"
1278 if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64 ; then
1279 # Use large model to support 4G memory
1280 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
1281 CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1282 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1283 [grub_cv_cc_mcmodel=yes],
1284 [grub_cv_cc_mcmodel=no])
1286 if test "x$grub_cv_cc_mcmodel" = xyes; then
1287 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1288 elif test "$target_cpu" = sparc64 || test "$target_cpu" = riscv64; then
1289 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
1293 if test "$target_cpu"-"$platform" = x86_64-efi; then
1294 # EFI writes to stack below %rsp, we must not use the red zone
1295 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
1296 CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1298 [grub_cv_cc_no_red_zone=yes],
1299 [grub_cv_cc_no_red_zone=no])
1301 if test "x$grub_cv_cc_no_red_zone" = xno; then
1302 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
1305 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1308 if test "x$target_cpu" = xarm; then
1309 AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [
1310 grub_cv_target_cc_mno_movt=no
1311 for cand in "-mno-movt" \
1312 "-mllvm -arm-use-movt=0" \
1313 "-mword-relocations"; do
1314 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1317 CFLAGS="$TARGET_CFLAGS $cand -Werror"
1318 CPPFLAGS="$TARGET_CPPFLAGS"
1319 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1320 [grub_cv_target_cc_mno_movt="$cand"], [])
1324 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1325 # A trick so that clang doesn't see it on link stage
1326 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt"
1328 AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
1329 CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
1330 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1331 [grub_cv_cc_mthumb_interwork=yes],
1332 [grub_cv_cc_mthumb_interwork=no])
1334 if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
1335 TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
1336 # Clang defaults to thumb interworking
1337 elif test "x$grub_cv_cc_target_clang" = xno ; then
1338 AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
1342 AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
1343 CFLAGS="$TARGET_CFLAGS -Qn -Qunused-arguments -Werror"
1344 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1345 [grub_cv_target_cc_qn=yes],
1346 [grub_cv_target_cc_qn=no])])
1347 if test "x$grub_cv_target_cc_qn" = xyes; then
1348 TARGET_CFLAGS="$TARGET_CFLAGS -Qn -Qunused-arguments"
1352 # Compiler features.
1355 CFLAGS="$TARGET_CFLAGS"
1357 # Position independent executable.
1360 grub_CHECK_NO_PIE_ONEWORD
1362 [# Need that, because some distributions ship compilers that include
1363 # `-fPIE' or '-fpie' and '-pie' in the default specs.
1364 if [ x"$pie_possible" = xyes ]; then
1365 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
1366 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -fno-PIE -fno-pie"
1369 if [ x"$link_nopie_needed" = xyes ] || [ x"$pie_possible" = xyes ]; then
1370 if [ x"$nopie_possible" = xyes ]; then
1371 TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
1373 if [ x"$nopie_oneword_possible" = xyes ]; then
1374 TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie"
1378 CFLAGS="$TARGET_CFLAGS"
1379 LDFLAGS="$TARGET_LDFLAGS"
1381 # Position independent executable.
1383 [# On most platforms we don't want PIC as it only makes relocations harder
1384 # and code less efficient. On mips we want to have one got table per module
1385 # and reload $gp in every function.
1386 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
1387 # However with clang we need PIC for this reloading to happen.
1388 # With arm64 we need relocations that are in some way representable in
1389 # PE as we need to support arm64-efi. Without -fPIC clang generates
1390 # movk's which aren't representable.
1391 # Since default varies across dictributions use either -fPIC or -fno-PIC
1393 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
1394 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
1395 elif [ x"$pic_possible" = xyes ]; then
1396 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
1399 CFLAGS="$TARGET_CFLAGS"
1401 # Stack smashing protector.
1402 grub_CHECK_STACK_PROTECTOR
1403 AC_ARG_ENABLE([stack-protector],
1404 AS_HELP_STRING([--enable-stack-protector],
1405 [enable the stack protector]),
1407 [enable_stack_protector=no])
1408 if test "x$enable_stack_protector" = xno; then
1409 if test "x$ssp_possible" = xyes; then
1410 # Need that, because some distributions ship compilers that include
1411 # `-fstack-protector' in the default specs.
1412 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
1414 elif test "x$platform" != xefi; then
1415 if test "$ERROR_PLATFORM_NOT_SUPPORT_SSP" = "yes"; then
1416 AC_MSG_ERROR([--enable-stack-protector is only supported on EFI platforms])
1418 AC_MSG_WARN([--enable-stack-protector is only supported on EFI platforms])
1420 enable_stack_protector=no
1421 elif test "x$ssp_global_possible" != xyes; then
1422 AC_MSG_ERROR([--enable-stack-protector is not supported (compiler doesn't support -mstack-protector-guard=global)])
1424 TARGET_CFLAGS="$TARGET_CFLAGS -mstack-protector-guard=global"
1425 if test "x$enable_stack_protector" = xyes; then
1426 if test "x$ssp_possible" != xyes; then
1427 AC_MSG_ERROR([--enable-stack-protector is not supported (compiler doesn't support -fstack-protector)])
1429 TARGET_CFLAGS="$TARGET_CFLAGS -fstack-protector"
1430 elif test "x$enable_stack_protector" = xstrong; then
1431 if test "x$ssp_strong_possible" != xyes; then
1432 AC_MSG_ERROR([--enable-stack-protector=strong is not supported (compiler doesn't support -fstack-protector-strong)])
1434 TARGET_CFLAGS="$TARGET_CFLAGS -fstack-protector-strong"
1436 # Note, -fstack-protector-all requires that the protector is disabled for
1437 # functions that appear in the call stack when the canary is initialized.
1438 AC_MSG_ERROR([invalid value $enable_stack_protector for --enable-stack-protector])
1440 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DGRUB_STACK_PROTECTOR=1"
1442 if test -n "$SOURCE_DATE_EPOCH"; then
1443 GRUB_STACK_PROTECTOR_INIT="0x00f2b7e2$(printf "%x" "$SOURCE_DATE_EPOCH" | sed 's/.*\(........\)$/\1/')"
1444 elif test -r /dev/urandom; then
1445 # Generate the 8 byte stack protector canary at build time if /dev/urandom
1446 # is able to be read. The first byte should be NUL to filter out string
1447 # buffer overflow attacks.
1448 GRUB_STACK_PROTECTOR_INIT="$($PYTHON -c 'import codecs; rf=open("/dev/urandom", "rb"); print("0x00"+codecs.encode(rf.read(7), "hex").decode("ascii"))')"
1450 # Some hosts may not have a urandom, e.g. Windows, so use statically
1451 # generated random bytes
1452 GRUB_STACK_PROTECTOR_INIT="0x00f2b7e2f193b25c"
1455 if test x"$target_m32" = x1 ; then
1456 # Make sure that the canary default value is 24-bits by only using the
1457 # lower 3 bytes on 32 bit systems. This allows the upper byte to be NUL
1458 # to filter out string buffer overflow attacks.
1459 GRUB_STACK_PROTECTOR_INIT="0x00$(echo "$GRUB_STACK_PROTECTOR_INIT" | sed 's/.*\(......\)$/\1/')"
1462 AC_SUBST([GRUB_STACK_PROTECTOR_INIT])
1465 CFLAGS="$TARGET_CFLAGS"
1467 grub_CHECK_STACK_ARG_PROBE
1468 # Cygwin's GCC uses alloca() to probe the stackframe on static
1469 # stack allocations above some threshold.
1470 if test x"$sap_possible" = xyes; then
1471 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
1474 CFLAGS="$TARGET_CFLAGS"
1476 # -mno-unaligned-access -mstrict-align
1477 if test "$target_cpu" = arm; then
1478 AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
1479 grub_cv_target_cc_strict_align=
1480 for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
1481 CFLAGS="$TARGET_CFLAGS $arg -Werror"
1482 LDFLAGS="$TARGET_LDFLAGS"
1483 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
1484 if test x"$flag" = x1; then
1485 grub_cv_target_cc_strict_align="$arg"
1490 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
1491 if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
1492 TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
1494 AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
1495 [CFLAGS="$TARGET_CFLAGS"
1496 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1497 #ifdef __ARM_FEATURE_UNALIGNED
1501 [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
1502 if test x$grub_cv_cc_target_emits_unaligned = xyes; then
1503 AC_MSG_ERROR([compiler generates unaligned accesses])
1507 # Set them to their new values for the tests below.
1509 CPPFLAGS="$TARGET_CPPFLAGS"
1511 # Check for libgcc symbols
1512 if test x"$platform" = xemu; then
1513 CFLAGS="$TARGET_CFLAGS -Wno-error"
1514 AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __clzdi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
1517 if test "x$TARGET_APPLE_LINKER" = x1 ; then
1518 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
1520 CFLAGS="$TARGET_CFLAGS -nostdlib"
1524 # Defined in acinclude.m4.
1527 if test "x$TARGET_APPLE_LINKER" != x1 ; then
1528 grub_PROG_OBJCOPY_ABSOLUTE
1530 grub_PROG_LD_BUILD_ID_NONE
1531 if test "x$target_cpu" = xi386; then
1532 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
1533 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
1534 # Check symbols provided by linker script.
1535 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
1537 grub_CHECK_BSS_START_SYMBOL
1538 grub_CHECK_END_SYMBOL
1540 CFLAGS="$TARGET_CFLAGS"
1544 grub_PROG_NM_MINUS_P
1545 grub_PROG_NM_DEFINED_ONLY
1546 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
1547 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
1549 if test "$platform" != emu; then
1550 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
1551 SAVED_CPPFLAGS="$CPPFLAGS"
1552 CPPFLAGS="$TARGET_CPPFLAGS -nostdlib -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1553 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1555 int va_arg_func (int fixed, va_list args);]], [[]])],
1556 [grub_cv_cc_isystem=yes],
1557 [grub_cv_cc_isystem=no])
1558 CPPFLAGS="$SAVED_CPPFLAGS"
1561 if test x"$grub_cv_cc_isystem" = xyes ; then
1562 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1566 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
1567 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
1568 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1569 int va_arg_func (int fixed, va_list args);]], [[]])],
1570 [grub_cv_cc_wtrampolines=yes],
1571 [grub_cv_cc_wtrampolines=no])
1574 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
1575 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
1578 # Restore the flags.
1580 CFLAGS="$tmp_CFLAGS"
1581 CPPFLAGS="$tmp_CPPFLAGS"
1582 LDFLAGS="$tmp_LDFLAGS"
1586 # Check for options.
1589 # Memory manager debugging.
1590 AC_ARG_ENABLE([mm-debug],
1591 AS_HELP_STRING([--enable-mm-debug],
1592 [include memory manager debugging]))
1593 if test x$enable_mm_debug = xyes; then
1598 AC_SUBST([MM_DEBUG])
1599 AM_CONDITIONAL([COND_MM_DEBUG], [test x$MM_DEBUG = x1])
1601 AC_ARG_ENABLE([cache-stats],
1602 AS_HELP_STRING([--enable-cache-stats],
1603 [enable disk cache statistics collection]))
1605 if test x$enable_cache_stats = xyes; then
1610 AC_SUBST([DISK_CACHE_STATS])
1612 AC_ARG_ENABLE([boot-time],
1613 AS_HELP_STRING([--enable-boot-time],
1614 [enable boot time statistics collection]))
1616 if test x$enable_boot_time = xyes; then
1621 AC_SUBST([BOOT_TIME_STATS])
1623 AC_ARG_ENABLE([grub-emu-sdl2],
1624 [AS_HELP_STRING([--enable-grub-emu-sdl2],
1625 [build and install the `grub-emu' debugging utility with SDL2 support (default=guessed)])])
1627 AC_ARG_ENABLE([grub-emu-sdl],
1628 [AS_HELP_STRING([--enable-grub-emu-sdl],
1629 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
1631 AC_ARG_ENABLE([grub-emu-pci],
1632 [AS_HELP_STRING([--enable-grub-emu-pci],
1633 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
1635 if test "$platform" = emu; then
1636 if test x"$enable_grub_emu_sdl2" = xno ; then
1637 grub_emu_sdl2_excuse="explicitly disabled"
1639 [if [ x"$grub_emu_sdl2_excuse" = x ]; then
1640 # Check for libSDL libraries.]
1641 PKG_CHECK_MODULES([SDL2], [sdl2], [
1642 AC_DEFINE([HAVE_SDL2], [1], [Define to 1 if you have SDL2 library.])
1643 AC_SUBST(HAVE_SDL2)],
1644 [grub_emu_sdl2_excuse="libSDL2 libraries are required to build \`grub-emu' with SDL2 support"])
1646 if test x"$enable_grub_emu_sdl2" = xyes && test x"$grub_emu_sdl2_excuse" != x ; then
1647 AC_MSG_ERROR([SDL2 support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl2_excuse)])
1649 if test x"$grub_emu_sdl2_excuse" = x ; then
1650 enable_grub_emu_sdl2=yes
1652 enable_grub_emu_sdl2=no
1654 if test x"$enable_grub_emu_sdl2" = xyes ; then
1655 grub_emu_sdl_excuse="disabled by sdl2"
1659 if test x"$enable_grub_emu_sdl" = xno ; then
1660 grub_emu_sdl_excuse="explicitly disabled"
1662 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1663 # Check for libSDL libraries.]
1664 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1665 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1669 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1670 # Check for headers.]
1671 AC_CHECK_HEADERS([SDL/SDL.h], [],
1672 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1675 if test x"$enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1676 AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
1678 if test x"$grub_emu_sdl_excuse" = x ; then
1679 enable_grub_emu_sdl=yes
1681 enable_grub_emu_sdl=no
1684 if test x"$enable_grub_emu_pci" != xyes ; then
1685 grub_emu_pci_excuse="not enabled"
1688 [if [ x"$grub_emu_pci_excuse" = x ]; then
1689 # Check for libpci libraries.]
1690 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1691 [grub_emu_pci_excuse=["need libpciaccess library"]])
1692 AC_SUBST([LIBPCIACCESS])
1694 [if [ x"$grub_emu_pci_excuse" = x ]; then
1695 # Check for headers.]
1696 AC_CHECK_HEADERS([pciaccess.h], [],
1697 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1700 if test x"$grub_emu_pci_excuse" = x ; then
1701 enable_grub_emu_pci=yes
1703 enable_grub_emu_pci=no
1706 AC_SUBST([enable_grub_emu_sdl2])
1707 AC_SUBST([enable_grub_emu_sdl])
1708 AC_SUBST([enable_grub_emu_pci])
1712 # Ignore --enable-emu-* if platform is not emu
1713 enable_grub_emu_sdl2=no
1714 enable_grub_emu_sdl=no
1715 enable_grub_emu_pci=no
1718 AC_ARG_ENABLE([grub-mkfont],
1719 [AS_HELP_STRING([--enable-grub-mkfont],
1720 [build and install the `grub-mkfont' utility (default=guessed)])])
1721 if test x"$enable_grub_mkfont" = xno ; then
1722 grub_mkfont_excuse="explicitly disabled"
1725 unset ac_cv_header_ft2build_h
1727 if test x"$grub_mkfont_excuse" = x ; then
1728 # Check for freetype libraries.
1729 PKG_CHECK_MODULES([FREETYPE], [freetype2], [
1730 SAVED_CPPFLAGS="$CPPFLAGS"
1732 CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
1733 LIBS="$LIBS $FREETYPE_LIBS"
1734 AC_CHECK_HEADERS([ft2build.h], [],
1735 [grub_mkfont_excuse=["need freetype2 headers"]])
1736 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
1737 [grub_mkfont_excuse=["freetype2 library unusable"]])
1738 CPPFLAGS="$SAVED_CPPFLAGS"
1740 ], [grub_mkfont_excuse=["need freetype2 library"]])
1741 if test x"$grub_mkfont_excuse" = x && test x"$host_kernel" = xnetbsd ; then
1742 FREETYPE_LIBS="$FREETYPE_LIBS -Wl,-R,/usr/pkg/lib" ;
1746 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1747 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
1749 if test x"$grub_mkfont_excuse" = x ; then
1750 enable_grub_mkfont=yes
1752 enable_grub_mkfont=no
1754 AC_SUBST([enable_grub_mkfont])
1758 SAVED_CFLAGS="$CFLAGS"
1759 SAVED_CPPFLAGS="$CPPFLAGS"
1760 SAVED_LDFLAGS="$LDFLAGS"
1763 CFLAGS="$BUILD_CFLAGS"
1764 CPPFLAGS="$BUILD_CPPFLAGS"
1765 LDFLAGS="$BUILD_LDFLAGS"
1767 unset ac_cv_c_bigendian
1768 unset ac_cv_header_ft2build_h
1770 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1771 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1772 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1774 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1775 AC_MSG_ERROR([couldnt determine build endianness])
1778 AC_SUBST([BUILD_SIZEOF_LONG])
1779 AC_SUBST([BUILD_SIZEOF_VOID_P])
1780 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1782 if test x"$grub_build_mkfont_excuse" = x ; then
1783 # Check for freetype libraries.
1784 SAVED_PKG_CONFIG="$PKG_CONFIG"
1785 test -z "$BUILD_PKG_CONFIG" || PKG_CONFIG="$BUILD_PKG_CONFIG"
1786 PKG_CHECK_MODULES([BUILD_FREETYPE], [freetype2], [
1787 SAVED_CPPFLAGS_2="$CPPFLAGS"
1789 CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS"
1790 LIBS="$LIBS $BUILD_FREETYPE_LIBS"
1791 AC_CHECK_HEADERS([ft2build.h], [],
1792 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1793 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
1794 [grub_build_mkfont_excuse=["freetype2 library unusable"]])
1796 CPPFLAGS="$SAVED_CPPFLAGS_2"
1797 ], [grub_build_mkfont_excuse=["need freetype2 library"]])
1798 if test x"$grub_build_mkfont_excuse" = x ; then
1799 case x"$build_os" in
1800 xnetbsd*) BUILD_FREETYPE_LIBS="$BUILD_FREETYPE_LIBS -Wl,-R,/usr/pkg/lib" ;;
1803 PKG_CONFIG="$SAVED_PKG_CONFIG"
1806 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1807 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
1809 if test x"$grub_build_mkfont_excuse" = x ; then
1810 enable_build_grub_mkfont=yes
1812 enable_build_grub_mkfont=no
1814 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
1815 if test x"$grub_build_mkfont_excuse" = x ; then
1816 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont])
1818 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)])
1824 CFLAGS="$SAVED_CFLAGS"
1825 CPPFLAGS="$SAVED_CPPFLAGS"
1826 LDFLAGS="$SAVED_LDFLAGS"
1831 AC_ARG_ENABLE([grub-themes],
1832 [AS_HELP_STRING([--enable-grub-themes],
1833 [build and install GRUB themes (default=guessed)])])
1834 if test x"$enable_grub_themes" = xno ; then
1835 starfield_excuse="explicitly disabled"
1838 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1839 starfield_excuse="No build-time grub-mkfont"
1842 AC_ARG_WITH([dejavufont],
1843 AS_HELP_STRING([--with-dejavufont=FILE],
1844 [set the DejeVu source [[guessed]]]))
1846 if test "x$with_dejavufont" = x; then
1847 # search in well-known directories
1848 if test x"$starfield_excuse" = x; then
1849 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1850 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype /usr/pkg/share/fonts/X11/TTF /usr/local/share/fonts/dejavu /usr/X11R6/lib/X11/fonts/TTF; do
1851 if test -f "$dir/DejaVuSans.$ext"; then
1852 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1858 if test "x$DJVU_FONT_SOURCE" = x; then
1859 starfield_excuse="No DejaVu found"
1863 DJVU_FONT_SOURCE="$with_dejavufont"
1866 if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1867 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
1870 AC_SUBST([DJVU_FONT_SOURCE])
1872 AC_ARG_WITH([unifont],
1873 AS_HELP_STRING([--with-unifont=FILE],
1874 [set the unifont source [[guessed]]]))
1876 if test "x$with_unifont" = x; then
1877 # search in well-known directories
1878 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1879 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 /usr/pkg/share/fonts/X11/misc /usr/local/share/fonts/gnu-unifont /usr/local/share/fonts/unifont; do
1880 if test -f "$dir/unifont.$ext"; then
1881 md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
1882 # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
1883 if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
1886 FONT_SOURCE="$dir/unifont.$ext"
1892 FONT_SOURCE="$with_unifont"
1895 if test x"$enable_build_grub_mkfont" = xno ; then
1899 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
1900 if test x"$grub_build_mkfont_excuse" = x ; then
1901 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont])
1903 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
1907 AC_SUBST([FONT_SOURCE])
1909 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1910 grub_build_mkfont_excuse="no fonts"
1914 AC_ARG_ENABLE([grub-mount],
1915 [AS_HELP_STRING([--enable-grub-mount],
1916 [build and install the `grub-mount' utility (default=guessed)])])
1917 if test x"$enable_grub_mount" = xno ; then
1918 grub_mount_excuse="explicitly disabled"
1921 if test x"$grub_mount_excuse" = x ; then
1922 PKG_CHECK_MODULES([FUSE], [fuse3], [FUSE_CFLAGS="$FUSE_CFLAGS -DFUSE_USE_VERSION=32"], [
1923 PKG_CHECK_MODULES([FUSE], [fuse], [FUSE_CFLAGS="$FUSE_CFLAGS -DFUSE_USE_VERSION=26"], [
1924 grub_mount_excuse="need fuse or fuse3 libraries"
1929 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1930 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
1932 if test x"$grub_mount_excuse" = x ; then
1933 enable_grub_mount=yes
1935 enable_grub_mount=no
1937 AC_SUBST([enable_grub_mount])
1939 AC_ARG_ENABLE([device-mapper],
1940 [AS_HELP_STRING([--enable-device-mapper],
1941 [enable Linux device-mapper support (default=guessed)])])
1942 if test x"$enable_device_mapper" = xno ; then
1943 device_mapper_excuse="explicitly disabled"
1946 if test x"$device_mapper_excuse" = x ; then
1947 # Check for device-mapper header.
1948 AC_CHECK_HEADER([libdevmapper.h], [],
1949 [device_mapper_excuse="need libdevmapper header"])
1952 if test x"$device_mapper_excuse" = x ; then
1953 # Check for device-mapper library.
1954 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1955 [device_mapper_excuse="need devmapper library"])
1958 if test x"$device_mapper_excuse" = x ; then
1959 # Check for device-mapper library.
1960 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1962 [device_mapper_excuse="need devmapper library"])
1965 if test x"$device_mapper_excuse" = x ; then
1966 LIBDEVMAPPER="-ldevmapper"
1967 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1968 [Define to 1 if you have the devmapper library.])
1971 AC_SUBST([LIBDEVMAPPER])
1974 if test x$host_kernel = xkfreebsd; then
1975 AC_CHECK_LIB([geom], [geom_gettree], [],
1976 [AC_MSG_ERROR([Your platform requires libgeom])])
1982 AC_ARG_ENABLE([liblzma],
1983 [AS_HELP_STRING([--enable-liblzma],
1984 [enable liblzma integration (default=guessed)])])
1985 if test x"$enable_liblzma" = xno ; then
1986 liblzma_excuse="explicitly disabled"
1989 if test x"$liblzma_excuse" = x ; then
1990 AC_CHECK_LIB([lzma], [lzma_code],
1991 [],[liblzma_excuse="need lzma library"])
1993 if test x"$liblzma_excuse" = x ; then
1994 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1997 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1998 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
2002 if test x"$liblzma_excuse" = x ; then
2004 AC_DEFINE([USE_LIBLZMA], [1],
2005 [Define to 1 if you have the LZMA library.])
2010 AC_ARG_ENABLE([libzfs],
2011 [AS_HELP_STRING([--enable-libzfs],
2012 [enable libzfs integration (default=guessed)])])
2013 if test x"$enable_libzfs" = xno ; then
2014 libzfs_excuse="explicitly disabled"
2017 if test x"$libzfs_excuse" = x ; then
2018 # Only check for system headers if libzfs support has not been disabled.
2019 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
2022 if test x"$libzfs_excuse" = x ; then
2023 AC_CHECK_LIB([zfs], [libzfs_init],
2025 [libzfs_excuse="need zfs library"])
2028 if test x"$libzfs_excuse" = x ; then
2029 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
2030 [have_normal_nvpair=yes],
2031 [have_normal_nvpair=no])
2032 if test x"$have_normal_nvpair" = xno ; then
2033 AC_CHECK_LIB([nvpair], [opensolaris_nvlist_lookup_string],
2034 [have_prefixed_nvpair=yes],
2035 [have_prefixed_nvpair=no])
2036 if test x"$have_prefixed_nvpair" = xyes ; then
2037 AC_DEFINE([GRUB_UTIL_NVPAIR_IS_PREFIXED], [1],
2038 [Define to 1 if libnvpair symbols are prefixed with opensolaris_.])
2040 libzfs_excuse="need nvpair library"
2045 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
2046 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
2049 if test x"$libzfs_excuse" = x ; then
2050 # We need both libzfs and libnvpair for a successful build.
2052 LIBNVPAIR="-lnvpair"
2053 AC_DEFINE([USE_LIBZFS], [1],
2054 [Define to 1 if ZFS library should be used.])
2058 AC_SUBST([LIBNVPAIR])
2062 AC_SUBST([FONT_SOURCE])
2063 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
2064 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
2066 AC_SUBST(HAVE_ASM_USCORE)
2067 AC_SUBST(BSS_START_SYMBOL)
2068 AC_SUBST(END_SYMBOL)
2072 AC_ARG_ENABLE([werror],
2073 [AS_HELP_STRING([--disable-werror],
2074 [do not use -Werror when building GRUB])])
2075 if test x"$enable_werror" != xno ; then
2076 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
2077 HOST_CFLAGS="$HOST_CFLAGS -Werror"
2078 if test "x$grub_cv_cc_target_clang" = xyes; then
2079 TARGET_CFLAGS="$TARGET_CFLAGS -Wno-error=vla"
2080 HOST_CFLAGS="$HOST_CFLAGS -Wno-error=vla"
2084 TARGET_CPP="$TARGET_CC -E"
2085 TARGET_CCAS=$TARGET_CC
2087 # Includes which include make-time substitutions. They must come last
2088 # as to avoid executing top_builddir in shell.
2089 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
2090 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
2091 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
2093 GRUB_TARGET_CPU="${target_cpu}"
2094 GRUB_PLATFORM="${platform}"
2096 AC_SUBST(GRUB_TARGET_CPU)
2097 AC_SUBST(GRUB_PLATFORM)
2099 AC_SUBST(TARGET_OBJCONV)
2100 AC_SUBST(TARGET_CPP)
2101 AC_SUBST(TARGET_CCAS)
2102 AC_SUBST(TARGET_OBJ2ELF)
2103 AC_SUBST(TARGET_MODULE_FORMAT)
2104 AC_SUBST(TARGET_CC_VERSION)
2106 AC_SUBST(TARGET_CFLAGS)
2107 AC_SUBST(TARGET_LDFLAGS)
2108 AC_SUBST(TARGET_CPPFLAGS)
2109 AC_SUBST(TARGET_CCASFLAGS)
2111 AC_SUBST(TARGET_IMG_LDFLAGS)
2112 AC_SUBST(TARGET_IMG_CFLAGS)
2113 AC_SUBST(TARGET_IMG_BASE_LDOPT)
2114 AC_SUBST(TARGET_APPLE_LINKER)
2116 AC_SUBST(HOST_CFLAGS)
2117 AC_SUBST(HOST_LDFLAGS)
2118 AC_SUBST(HOST_CPPFLAGS)
2119 AC_SUBST(HOST_CCASFLAGS)
2121 AC_SUBST(BUILD_LIBM)
2124 # Automake conditionals
2127 AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
2128 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
2129 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
2130 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
2131 AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot])
2132 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
2133 AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
2134 AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
2135 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
2136 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
2137 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
2138 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
2139 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
2140 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
2141 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
2142 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
2143 AM_CONDITIONAL([COND_i386_xen_pvh], [test x$target_cpu = xi386 -a x$platform = xxen_pvh])
2144 AM_CONDITIONAL([COND_loongarch64], [test x$target_cpu = xloongarch64])
2145 AM_CONDITIONAL([COND_loongarch64_efi], [test x$target_cpu = xloongarch64 -a x$platform = xefi])
2146 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
2147 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
2148 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
2149 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
2150 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
2151 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
2152 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
2153 AM_CONDITIONAL([COND_riscv32], [test x$target_cpu = xriscv32 ])
2154 AM_CONDITIONAL([COND_riscv64], [test x$target_cpu = xriscv64 ])
2155 AM_CONDITIONAL([COND_riscv32_efi], [test x$target_cpu = xriscv32 -a x$platform = xefi])
2156 AM_CONDITIONAL([COND_riscv64_efi], [test x$target_cpu = xriscv64 -a x$platform = xefi])
2157 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
2158 AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
2159 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
2160 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
2162 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
2163 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
2164 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
2165 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
2166 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
2167 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
2168 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
2170 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
2171 AM_CONDITIONAL([COND_GRUB_EMU_SDL2], [test x$enable_grub_emu_sdl2 = xyes])
2172 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
2173 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
2174 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
2175 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
2176 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
2177 if test x$FONT_SOURCE != x ; then
2182 AC_SUBST(HAVE_FONT_SOURCE)
2183 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
2184 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
2185 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
2186 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
2188 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
2190 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
2191 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
2192 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
2193 AM_CONDITIONAL([COND_HAVE_PCI], [test "x$have_pci" = xy])
2195 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
2196 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
2197 datarootdir="$(eval echo "$datarootdir")"
2198 grub_libdir="$(eval echo "$libdir")"
2199 grub_localedir="$(eval echo "$localedir")"
2200 grub_datadir="$(eval echo "$datadir")"
2201 grub_sysconfdir="$(eval echo "$sysconfdir")"
2202 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
2203 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
2204 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
2205 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
2209 if test "$platform" != none; then
2210 cpudir="${target_cpu}"
2211 if test x${cpudir} = xmipsel; then
2215 if test x"$link_dir" = xyes ; then
2216 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
2217 if test "$platform" != emu ; then
2218 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
2221 mkdir -p include/grub 2>/dev/null
2222 rm -rf include/grub/cpu
2223 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
2224 if test "$platform" != emu ; then
2225 rm -rf include/grub/machine
2226 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
2230 # Just enough to stop the compiler failing with -I$(srcdir)/include.
2231 mkdir -p include 2>/dev/null
2232 rm -rf include/grub/cpu include/grub/machine
2235 AC_CONFIG_FILES([Makefile])
2236 AC_CONFIG_FILES([grub-core/Makefile])
2237 AC_CONFIG_FILES([grub-core/lib/gnulib/Makefile])
2238 AC_CONFIG_FILES([po/Makefile.in])
2239 AC_CONFIG_FILES([docs/Makefile])
2240 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
2241 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
2242 AC_CONFIG_FILES([config.h])
2246 echo "*******************************************************"
2247 echo GRUB2 will be compiled with following components:
2248 echo Platform: "$target_cpu"-"$platform"
2249 if [ x"$platform" = xemu ]; then
2250 if [ x"$grub_emu_sdl2_excuse" = x ]; then
2251 echo SDL2 support for grub-emu: Yes
2253 echo SDL2 support for grub-emu: No "($grub_emu_sdl2_excuse)"
2255 if [ x"$grub_emu_sdl_excuse" = x ]; then
2256 echo SDL support for grub-emu: Yes
2258 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
2260 if [ x"$grub_emu_pci_excuse" = x ]; then
2261 echo PCI support for grub-emu: Yes
2263 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
2266 if test x"$device_mapper_excuse" = x ; then
2267 echo With devmapper support: Yes
2269 echo With devmapper support: No "($device_mapper_excuse)"
2271 if [ x"$enable_mm_debug" = xyes ]; then
2272 echo With memory debugging: Yes
2274 echo With memory debugging: No
2276 if [ x"$enable_cache_stats" = xyes ]; then
2277 echo With disk cache statistics: Yes
2279 echo With disk cache statistics: No
2282 if [ x"$enable_boot_time" = xyes ]; then
2283 echo With boot time statistics: Yes
2285 echo With boot time statistics: No
2288 if [ x"$efiemu_excuse" = x ]; then
2289 echo efiemu runtime: Yes
2291 echo efiemu runtime: No "($efiemu_excuse)"
2293 if [ x"$grub_mkfont_excuse" = x ]; then
2294 echo grub-mkfont: Yes
2296 echo grub-mkfont: No "($grub_mkfont_excuse)"
2298 if [ x"$grub_mount_excuse" = x ]; then
2299 echo grub-mount: Yes
2301 echo grub-mount: No "($grub_mount_excuse)"
2303 if [ x"$starfield_excuse" = x ]; then
2304 echo starfield theme: Yes
2305 echo With DejaVuSans font from $DJVU_FONT_SOURCE
2307 echo starfield theme: No "($starfield_excuse)"
2309 if [ x"$libzfs_excuse" = x ]; then
2310 echo With libzfs support: Yes
2312 echo With libzfs support: No "($libzfs_excuse)"
2314 if [ x"$grub_build_mkfont_excuse" = x ]; then
2315 echo Build-time grub-mkfont: Yes
2316 if test "x$FONT_SOURCE" = x ; then
2317 echo "Without unifont"
2319 echo "With unifont from $FONT_SOURCE"
2322 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
2323 echo "Without unifont (no build-time grub-mkfont)"
2325 if test x"$liblzma_excuse" != x ; then
2326 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
2328 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
2330 if test "x$enable_stack_protector" != xno; then
2331 echo "With stack smashing protector: Yes"
2333 echo "With stack smashing protector: No"
2335 echo "*******************************************************"