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 as well as the build type,
30 dnl because GRUB does not need to use those variables for the build
31 dnl type, so there is no conflict. Variables with the prefix "TARGET_"
32 dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
35 AC_INIT([GRUB],[2.00],[bug-grub@gnu.org])
37 AC_CONFIG_AUX_DIR([build-aux])
39 # We don't want -g -O2 by default in CFLAGS
42 # Checks for host and target systems.
44 save_program_prefix="${program_prefix}"
46 program_prefix="${save_program_prefix}"
48 AM_INIT_AUTOMAKE([1.10.1])
50 AC_CONFIG_SRCDIR([include/grub/dl.h])
51 AC_CONFIG_HEADER([config-util.h])
53 # Program name transformations
55 grub_TRANSFORM([grub-bios-setup])
56 grub_TRANSFORM([grub-editenv])
57 grub_TRANSFORM([grub-install])
58 grub_TRANSFORM([grub-mkconfig])
59 grub_TRANSFORM([grub-mkfont])
60 grub_TRANSFORM([grub-mkimage])
61 grub_TRANSFORM([grub-glue-efi])
62 grub_TRANSFORM([grub-mklayout])
63 grub_TRANSFORM([grub-mkpasswd-pbkdf2])
64 grub_TRANSFORM([grub-mkrelpath])
65 grub_TRANSFORM([grub-mkrescue])
66 grub_TRANSFORM([grub-probe])
67 grub_TRANSFORM([grub-reboot])
68 grub_TRANSFORM([grub-script-check])
69 grub_TRANSFORM([grub-set-default])
70 grub_TRANSFORM([grub-sparc64-setup])
71 grub_TRANSFORM([grub-render-label])
73 # Optimization flag. Allow user to override.
74 if test "x$TARGET_CFLAGS" = x; then
75 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
78 # Default HOST_CPPFLAGS
79 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
80 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
81 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
83 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
84 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
85 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
88 i[[3456]]86) target_cpu=i386 ;;
89 amd64) target_cpu=x86_64 ;;
90 sparc) target_cpu=sparc64 ;;
93 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
97 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
104 # Specify the platform (such as firmware).
105 AC_ARG_WITH([platform],
106 AS_HELP_STRING([--with-platform=PLATFORM],
107 [select the host platform [[guessed]]]))
109 # Guess the platform if not specified.
110 if test "x$with_platform" = x; then
111 case "$target_cpu"-"$target_vendor" in
112 i386-apple) platform=efi ;;
113 i386-*) platform=pc ;;
114 x86_64-apple) platform=efi ;;
115 x86_64-*) platform=pc ;;
116 powerpc-*) platform=ieee1275 ;;
117 powerpc64-*) platform=ieee1275 ;;
118 sparc64-*) platform=ieee1275 ;;
119 mipsel-*) platform=loongson ;;
120 mips-*) platform=arc ;;
121 ia64-*) platform=efi ;;
122 arm-*) platform=uboot ;;
123 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
126 platform="$with_platform"
129 case "$target_cpu"-"$platform" in
133 x86_64-*) target_cpu=i386 ;;
134 powerpc64-ieee1275) target_cpu=powerpc ;;
137 # Check if the platform is supported, make final adjustments.
138 case "$target_cpu"-"$platform" in
146 i386-linuxbios) platform=coreboot ;;
153 mips-qemu-mips) platform=qemu_mips;;
157 mipsel-qemu-mips) platform=qemu_mips;;
158 mipsel-yeeloong) platform=loongson ;;
159 mipsel-fuloong) platform=loongson ;;
164 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
167 if test x$platform != xemu ; then
168 case "$target_cpu" in
169 i386 | powerpc) target_m32=1 ;;
170 x86_64 | sparc64) target_m64=1 ;;
175 windows* | mingw32*) target_os=cygwin ;;
178 # This normalizes the names, and creates a new variable ("host_kernel")
179 # while at it, since the mapping is not always 1:1 (e.g. different OSes
180 # using the same kernel type).
182 gnu*) host_kernel=hurd ;;
183 linux*) host_kernel=linux ;;
184 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
185 netbsd*) host_kernel=netbsd ;;
186 solaris*) host_kernel=illumos ;;
187 darwin*) host_kernel=xnu ;;
188 cygwin | windows* | mingw32*) host_kernel=windows ;;
192 cygwin | windows* | mingw32*) have_exec=n ;;
193 aros*) have_exec=n ;;
198 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
199 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
200 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
201 xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
202 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
203 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
204 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
205 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
206 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
207 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
208 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
209 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
211 case "$target_cpu" in
212 arm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
213 mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
214 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
216 if test x${target_cpu} = xmipsel ; then
217 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
219 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,` -DGRUB_TARGET_CPU_`echo ${target_cpu} | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`=1"
222 case "${target_cpu}-$platform" in
224 TARGET_LINK_ADDR=0x88200000
225 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
228 TARGET_LINK_ADDR=0x80700000
229 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
231 mips*-qemu_mips | mips*-loongson)
232 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
236 AC_SUBST(TARGET_LINK_ADDR)
237 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
239 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
243 AC_SUBST(host_kernel)
248 # Define default variables
251 AC_ARG_WITH([bootdir],
252 AS_HELP_STRING([--with-bootdir=DIR],
253 [set the name of /boot directory [[guessed]]]),
254 [have_with_bootdir=y],
255 [have_with_bootdir=n])
256 if test x$have_with_bootdir = xy; then
257 bootdirname="$with_bootdir"
261 # Because /boot is used for the boot block in NetBSD and OpenBSD,
263 *) bootdirname='boot' ;;
267 AC_SUBST(bootdirname)
268 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
269 [Default boot directory name]")
271 AC_ARG_WITH([grubdir],
272 AS_HELP_STRING([--with-grubdir=DIR],
273 [set the name of grub directory [[guessed]]]),
274 [grubdirname="$with_grubdir"],
275 [grubdirname="$PACKAGE"])
277 AC_SUBST(grubdirname)
278 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
279 [Default grub directory name])
282 # Checks for build programs.
285 # Although cmp is listed in the GNU Coding Standards as a command which
286 # can used directly, OpenBSD lacks cmp in the default installation.
287 AC_CHECK_PROGS([CMP], [cmp])
288 if test "x$CMP" = x; then
289 AC_MSG_ERROR([cmp is not found])
292 AC_CHECK_PROGS([YACC], [bison])
293 if test "x$YACC" = x; then
294 AC_MSG_ERROR([bison is not found])
306 if test "x$LEX" = "x:"; then
307 AC_MSG_ERROR([flex is not found])
309 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
310 if test -n "$version" -a "$version" -ge 20535; then
313 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
317 # These are not a "must".
318 AC_PATH_PROGS(MAKEINFO, makeinfo true)
321 # Checks for host programs.
331 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
333 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
336 AM_GNU_GETTEXT([external])
339 # Identify characteristics of the host architecture.
340 unset ac_cv_c_bigendian
343 AC_CHECK_SIZEOF(void *)
344 AC_CHECK_SIZEOF(long)
347 cygwin | windows* | mingw32*)
348 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
349 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
350 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
354 if test x$USE_NLS = xno; then
355 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
358 if test "x$cross_compiling" = xyes; then
359 AC_MSG_WARN([cannot generate manual pages while cross compiling])
361 AC_PATH_PROG(HELP2MAN, help2man)
364 # Check for functions and headers.
365 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
366 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
368 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
369 #include <sys/param.h>
370 #include <sys/mount.h>])
372 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
373 #include <sys/param.h>
374 #include <sys/mount.h>])
376 # For opendisk() and getrawpartition() on NetBSD.
377 # Used in util/deviceiter.c and in util/hostdisk.c.
378 AC_CHECK_HEADER([util.h], [
379 AC_CHECK_LIB([util], [opendisk], [
381 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
383 AC_CHECK_LIB([util], [getrawpartition], [
385 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
390 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
391 SAVED_CFLAGS="$CFLAGS"
392 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
393 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
394 int va_arg_func (int fixed, va_list args);]], [[]])],
395 [grub_cv_host_cc_wtrampolines=yes],
396 [grub_cv_host_cc_wtrampolines=no])
397 CFLAGS="$SAVED_CFLAGS"
400 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
401 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
405 # Check for host and build compilers.
408 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
409 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
410 BUILD_CPP="$BUILD_CC -E"
413 haiku*) BUILD_LIBM= ;;
420 # Check for target programs.
423 # Find tools for the target.
424 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
425 tmp_ac_tool_prefix="$ac_tool_prefix"
426 ac_tool_prefix=$target_alias-
428 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
429 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
430 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
431 AC_CHECK_TOOL(TARGET_STRIP, strip)
432 AC_CHECK_TOOL(TARGET_NM, nm)
433 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
435 ac_tool_prefix="$tmp_ac_tool_prefix"
437 if test "x$TARGET_CC" = x; then
440 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
441 AC_CHECK_TOOL(TARGET_STRIP, strip)
442 AC_CHECK_TOOL(TARGET_NM, nm)
443 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
448 AC_SUBST(BUILD_CFLAGS)
449 AC_SUBST(BUILD_CPPFLAGS)
452 AC_SUBST(TARGET_RANLIB)
453 AC_SUBST(TARGET_STRIP)
454 AC_SUBST(TARGET_OBJCOPY)
456 # Test the C compiler for the target environment.
459 tmp_LDFLAGS="$LDFLAGS"
460 tmp_CPPFLAGS="$CPPFLAGS"
463 CFLAGS="$TARGET_CFLAGS"
464 CPPFLAGS="$TARGET_CPPFLAGS"
465 LDFLAGS="$TARGET_LDFLAGS"
469 WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
470 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
471 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
472 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
474 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
475 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
478 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
480 [AC_LANG_PROGRAM([], [[
485 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
487 # on x86 clang doesn't support .code16
488 # on arm clang doesn't support .arch directive
489 # on mips clang doesn't support privilegied instructions, doubleword store/load
490 # and crashes with hand-written assembly
491 if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
492 || test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \
493 || test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then
494 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
497 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
498 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
501 if test "x$target_m32" = x1; then
503 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
504 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
505 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
506 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
507 TARGET_MODULE_FORMAT="elf32"
510 if test "x$target_m64" = x1; then
512 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
513 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
514 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
515 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
516 TARGET_MODULE_FORMAT="elf64"
519 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
520 TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
523 # on mips redirect cache flushing function to non-existant one.
524 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
525 AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
526 CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
527 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
528 [grub_cv_cc_mflush_func=yes],
529 [grub_cv_cc_mflush_func=no])
532 if test "x$grub_cv_cc_mflush_func" = xyes; then
533 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
538 # Force no alignment to save space on i386.
539 if test "x$target_cpu" = xi386; then
540 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
541 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
542 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
543 [grub_cv_cc_falign_loop=yes],
544 [grub_cv_cc_falign_loop=no])
547 AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
548 CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
549 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
550 [grub_cv_cc_malign_loop=yes],
551 [grub_cv_cc_malign_loop=no])
554 if test "x$grub_cv_cc_falign_loop" = xyes; then
555 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
556 elif test "x$grub_cv_cc_malign_loop" = xyes; then
557 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
561 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
562 CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
563 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
564 [grub_cv_cc_freg_struct_return=yes],
565 [grub_cv_cc_freg_struct_return=no])
568 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
569 TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
572 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
573 # Some toolchains enable these features by default, but they need
574 # registers that aren't set up properly in GRUB.
575 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
578 # By default, GCC 4.4 generates .eh_frame sections containing unwind
579 # information in some cases where it previously did not. GRUB doesn't need
580 # these and they just use up vital space. Restore the old compiler
582 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
583 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
584 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
585 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
586 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
589 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
590 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
593 if test x"$target_os" = xcygwin; then
594 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
595 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
596 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
597 [grub_cv_cc_no_reorder_functions=yes],
598 [grub_cv_cc_no_reorder_functions=no])
602 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
603 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
606 # By default, GCC 4.6 generates .eh_frame sections containing unwind
607 # information in some cases where it previously did not. GRUB doesn't need
608 # these and they just use up vital space. Restore the old compiler
610 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
611 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
612 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
613 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
614 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
617 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
618 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
621 # For platforms where ELF is not the default link format.
622 case "${target_os}" in
624 # FIXME: put proper test here
625 NEED_REGISTER_FRAME_INFO=1
627 *) NEED_REGISTER_FRAME_INFO=0 ;;
631 AC_ARG_ENABLE([efiemu],
632 [AS_HELP_STRING([--enable-efiemu],
633 [build and install the efiemu runtimes (default=guessed)])])
634 if test x"$enable_efiemu" = xno ; then
635 efiemu_excuse="explicitly disabled"
637 if test x"$target_os" = xcygwin ; then
638 efiemu_excuse="not available on cygwin"
640 if test x"$target_cpu" != xi386 ; then
641 efiemu_excuse="only available on i386"
643 if test x"$platform" = xefi ; then
644 efiemu_excuse="not available on efi"
646 if test x"$efiemu_excuse" = x ; then
647 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
648 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
649 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
650 [grub_cv_cc_efiemu=yes],
651 [grub_cv_cc_efiemu=no])
653 if test x$grub_cv_cc_efiemu = xno; then
654 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
657 if test x"$efiemu_excuse" = x ; then
658 AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
659 grub_cv_target_cc_efiemu64_link_format=unknown
660 for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
661 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
662 LDFLAGS="-m64 -Wl,$format -nostdlib -static"
663 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
664 asm (".globl start; start:");
665 asm (".globl _start; _start:");
666 asm (".globl __start; __start:");
668 void __main (void) {}
669 ]], [[]])], [flag=1], [flag=0])
670 if test x"$flag" = x1; then
671 grub_cv_target_cc_efiemu64_link_format="$format"
675 if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
676 efiemu_excuse="no suitable link format for efiemu64 found"
678 EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
681 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
682 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
684 if test x"$efiemu_excuse" = x ; then
689 AC_SUBST([enable_efiemu])
690 AC_SUBST([EFIEMU64_LINK_FORMAT])
692 CFLAGS="$TARGET_CFLAGS"
694 if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
695 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
696 grub_cv_target_cc_link_format=unknown
697 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do
698 if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
701 CFLAGS="$TARGET_CFLAGS"
702 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
703 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
704 asm (".globl start; start:");
705 asm (".globl _start; _start:");
706 asm (".globl __start; __start:");
708 void __main (void) {}
709 ]], [[]])], [flag=1], [flag=0])
710 if test x"$flag" = x1; then
711 grub_cv_target_cc_link_format="$format"
715 if test x"$grub_cv_target_cc_link_format" = xunknown; then
716 AC_MSG_ERROR([no suitable link format found])
718 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
719 if test x"$grub_cv_target_cc_link_format" = x-mi386pe; then
720 TARGET_OBJ2ELF='./build-grub-pe2elf';
724 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
725 TARGET_APPLE_LINKER=1
726 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
727 if test "x$TARGET_OBJCONV" = x ; then
728 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
730 if test "x$TARGET_OBJCONV" = x ; then
731 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
734 TARGET_IMG_CFLAGS="-static"
735 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
736 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
737 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
738 TARGET_LDFLAGS_OLDMAGIC=""
739 elif test x$grub_cv_target_cc_link_format = x-mi386pe && test x$platform = xpc; then
740 TARGET_APPLE_LINKER=0
741 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
742 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
743 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
744 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
745 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
748 TARGET_APPLE_LINKER=0
749 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
751 TARGET_IMG_LDFLAGS='-Wl,-N'
752 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
753 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
757 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
760 LDFLAGS="$TARGET_LDFLAGS"
762 if test "$target_cpu" = x86_64; then
763 # Use large model to support 4G memory
764 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
765 CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
766 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
767 [grub_cv_cc_mcmodel=yes],
768 [grub_cv_cc_mcmodel=no])
770 if test "x$grub_cv_cc_mcmodel" = xyes; then
771 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
775 if test "$target_cpu"-"$platform" = x86_64-efi; then
776 # EFI writes to stack below %rsp, we must not use the red zone
777 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
778 CFLAGS="$TARGET_CFLAGS -m64 -mno-red-zone"
779 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
780 [grub_cv_cc_no_red_zone=yes],
781 [grub_cv_cc_no_red_zone=no])
783 if test "x$grub_cv_cc_no_red_zone" = xno; then
784 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
787 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
794 CFLAGS="$TARGET_CFLAGS"
796 # Position independent executable.
798 [# Need that, because some distributions ship compilers that include
799 # `-fPIE' in the default specs.
800 if [ x"$pie_possible" = xyes ]; then
801 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
804 CFLAGS="$TARGET_CFLAGS"
806 # Position independent executable.
808 [# On most platforms we don't want PIC as it only makes relocations harder
809 # and code less efficient. On mips we want to have one got table per module
810 # and reload $gp in every function.
811 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
812 # However with clang we need PIC for this reloading to happen.
813 # Since default varies across dictributions use either -fPIC or -fno-PIC
815 if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then
816 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
817 elif [ x"$pic_possible" = xyes ]; then
818 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
821 CFLAGS="$TARGET_CFLAGS"
823 # Smashing stack protector.
824 grub_CHECK_STACK_PROTECTOR
825 # Need that, because some distributions ship compilers that include
826 # `-fstack-protector' in the default specs.
827 if test "x$ssp_possible" = xyes; then
828 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
831 CFLAGS="$TARGET_CFLAGS"
833 grub_CHECK_STACK_ARG_PROBE
834 # Cygwin's GCC uses alloca() to probe the stackframe on static
835 # stack allocations above some threshold.
836 if test x"$sap_possible" = xyes; then
837 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
840 CFLAGS="$TARGET_CFLAGS"
842 # -mno-unaligned-access
843 if test "$target_cpu" = arm; then
844 grub_CHECK_NO_UNALIGNED_ACCESS
845 if test x"$nua_possible" = xyes; then
846 TARGET_CFLAGS="$TARGET_CFLAGS -mno-unaligned-access"
850 # Set them to their new values for the tests below.
852 if test "x$TARGET_APPLE_LINKER" = x1 ; then
853 CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
855 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
857 CPPFLAGS="$TARGET_CPPFLAGS"
858 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
864 LIBS="$TARGET_LIBGCC"
867 if test "x$TARGET_APPLE_LINKER" = x0 ; then
868 if test x$grub_cv_asm_uscore = xyes; then
869 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,_abort=_main"
871 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,abort=main"
875 # Check for libgcc symbols
876 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
878 if test "x$TARGET_APPLE_LINKER" = x1 ; then
879 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
881 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
885 # Defined in aclocal.m4.
887 if test "x$TARGET_APPLE_LINKER" != x1 ; then
888 grub_PROG_OBJCOPY_ABSOLUTE
890 grub_PROG_LD_BUILD_ID_NONE
891 if test "x$target_cpu" = xi386; then
892 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
893 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
894 # Check symbols provided by linker script.
895 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000 -Wl,--defsym,___main=0x8100"
897 grub_CHECK_BSS_START_SYMBOL
898 grub_CHECK_END_SYMBOL
900 CFLAGS="$TARGET_CFLAGS"
901 grub_I386_ASM_PREFIX_REQUIREMENT
907 grub_PROG_NM_DEFINED_ONLY
908 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
909 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
911 if test "$platform" != emu; then
912 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
913 SAVED_CPPFLAGS="$CPPFLAGS"
914 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
915 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
917 int va_arg_func (int fixed, va_list args);]], [[]])],
918 [grub_cv_cc_isystem=yes],
919 [grub_cv_cc_isystem=no])
920 CPPFLAGS="$SAVED_CPPFLAGS"
923 if test x"$grub_cv_cc_isystem" = xyes ; then
924 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
928 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
929 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
930 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
931 int va_arg_func (int fixed, va_list args);]], [[]])],
932 [grub_cv_cc_wtrampolines=yes],
933 [grub_cv_cc_wtrampolines=no])
936 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
937 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
943 CPPFLAGS="$tmp_CPPFLAGS"
944 LDFLAGS="$tmp_LDFLAGS"
951 # Memory manager debugging.
952 AC_ARG_ENABLE([mm-debug],
953 AS_HELP_STRING([--enable-mm-debug],
954 [include memory manager debugging]),
955 [AC_DEFINE([MM_DEBUG], [1],
956 [Define to 1 if you enable memory manager debugging.])])
958 AC_ARG_ENABLE([cache-stats],
959 AS_HELP_STRING([--enable-cache-stats],
960 [enable disk cache statistics collection]))
962 if test x$enable_cache_stats = xyes; then
967 AC_SUBST([DISK_CACHE_STATS])
969 AC_ARG_ENABLE([boot-time],
970 AS_HELP_STRING([--enable-boot-time],
971 [enable boot time statistics collection]))
973 if test x$enable_boot_time = xyes; then
978 AC_SUBST([BOOT_TIME_STATS])
980 AC_ARG_ENABLE([grub-emu-usb],
981 [AS_HELP_STRING([--enable-grub-emu-usb],
982 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
984 AC_ARG_ENABLE([grub-emu-sdl],
985 [AS_HELP_STRING([--enable-grub-emu-sdl],
986 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
988 AC_ARG_ENABLE([grub-emu-pci],
989 [AS_HELP_STRING([--enable-grub-emu-pci],
990 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
992 if test "$platform" = emu; then
994 if test x"$enable_grub_emu_usb" != xyes ; then
995 grub_emu_usb_excuse="not enabled"
998 if test x"$enable_grub_emu_pci" = xyes ; then
999 grub_emu_usb_excuse="conflicts with PCI support"
1002 [if [ x"$grub_emu_usb_excuse" = x ]; then
1003 # Check for libusb libraries.]
1004 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
1005 [grub_emu_usb_excuse=["need libusb library"]])
1008 [if [ x"$grub_emu_usb_excuse" = x ]; then
1009 # Check for headers.]
1010 AC_CHECK_HEADERS([usb.h], [],
1011 [grub_emu_usb_excuse=["need libusb headers"]])
1013 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
1014 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
1016 if test x"$grub_emu_usb_excuse" = x ; then
1017 enable_grub_emu_usb=yes
1019 enable_grub_emu_usb=no
1022 if test x"$enable_grub_emu_sdl" = xno ; then
1023 grub_emu_sdl_excuse="explicitely disabled"
1025 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1026 # Check for libSDL libraries.]
1027 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1028 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1032 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1033 # Check for headers.]
1034 AC_CHECK_HEADERS([SDL/SDL.h], [],
1035 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1038 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1039 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
1041 if test x"$grub_emu_sdl_excuse" = x ; then
1042 enable_grub_emu_sdl=yes
1044 enable_grub_emu_sdl=no
1047 if test x"$enable_grub_emu_pci" != xyes ; then
1048 grub_emu_pci_excuse="not enabled"
1051 if test x"$enable_grub_emu_usb" = xyes ; then
1052 grub_emu_pci_excuse="conflicts with USB support"
1055 [if [ x"$grub_emu_pci_excuse" = x ]; then
1056 # Check for libpci libraries.]
1057 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1058 [grub_emu_pci_excuse=["need libpciaccess library"]])
1059 AC_SUBST([LIBPCIACCESS])
1061 [if [ x"$grub_emu_pci_excuse" = x ]; then
1062 # Check for headers.]
1063 AC_CHECK_HEADERS([pci/pci.h], [],
1064 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1067 if test x"$grub_emu_pci_excuse" = x ; then
1068 enable_grub_emu_pci=yes
1071 enable_grub_emu_pci=no
1074 AC_SUBST([enable_grub_emu_sdl])
1075 AC_SUBST([enable_grub_emu_usb])
1076 AC_SUBST([enable_grub_emu_pci])
1080 # Ignore --enable-emu-* if platform is not emu
1081 enable_grub_emu_sdl=no
1082 enable_grub_emu_usb=no
1083 enable_grub_emu_pci=no
1086 AC_ARG_ENABLE([grub-mkfont],
1087 [AS_HELP_STRING([--enable-grub-mkfont],
1088 [build and install the `grub-mkfont' utility (default=guessed)])])
1089 if test x"$enable_grub_mkfont" = xno ; then
1090 grub_mkfont_excuse="explicitly disabled"
1093 if test x"$grub_mkfont_excuse" = x ; then
1094 # Check for freetype libraries.
1095 AC_CHECK_TOOLS([FREETYPE], [freetype-config])
1096 if test "x$FREETYPE" = x ; then
1097 grub_mkfont_excuse=["need freetype2 library"]
1101 unset ac_cv_header_ft2build_h
1103 if test x"$grub_mkfont_excuse" = x ; then
1104 # Check for freetype libraries.
1105 freetype_cflags=`$FREETYPE --cflags`
1106 freetype_libs=`$FREETYPE --libs`
1107 SAVED_CPPFLAGS="$CPPFLAGS"
1108 CPPFLAGS="$CPPFLAGS $freetype_cflags"
1109 AC_CHECK_HEADERS([ft2build.h], [],
1110 [grub_mkfont_excuse=["need freetype2 headers"]])
1111 CPPFLAGS="$SAVED_CPPFLAGS"
1114 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1115 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
1117 if test x"$grub_mkfont_excuse" = x ; then
1118 enable_grub_mkfont=yes
1120 enable_grub_mkfont=no
1122 AC_SUBST([enable_grub_mkfont])
1123 AC_SUBST([freetype_cflags])
1124 AC_SUBST([freetype_libs])
1128 SAVED_CFLAGS="$CFLAGS"
1129 SAVED_CPPFLAGS="$CPPFLAGS"
1132 CFLAGS="$BUILD_CFLAGS"
1133 CPPFLAGS="$BUILD_CPPFLAGS"
1135 unset ac_cv_c_bigendian
1136 unset ac_cv_header_ft2build_h
1138 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1139 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1140 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1142 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1143 AC_MSG_ERROR([couldnt determine build endianness])
1146 AC_SUBST([BUILD_SIZEOF_LONG])
1147 AC_SUBST([BUILD_SIZEOF_VOID_P])
1148 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1150 if test x"$grub_build_mkfont_excuse" = x ; then
1151 # Check for freetype libraries.
1152 AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config])
1153 if test "x$BUILD_FREETYPE" = x ; then
1154 grub_build_mkfont_excuse=["need freetype2 library"]
1158 if test x"$grub_build_mkfont_excuse" = x ; then
1159 # Check for freetype libraries.
1160 build_freetype_cflags=`$BUILD_FREETYPE --cflags`
1161 build_freetype_libs=`$BUILD_FREETYPE --libs`
1162 SAVED_CPPFLAGS_2="$CPPFLAGS"
1163 CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
1164 AC_CHECK_HEADERS([ft2build.h], [],
1165 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1166 CPPFLAGS="$SAVED_CPPFLAGS_2"
1169 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1170 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled])
1172 if test x"$grub_build_mkfont_excuse" = x ; then
1173 enable_build_grub_mkfont=yes
1175 enable_build_grub_mkfont=no
1177 if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
1178 AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports needs build-time grub-mkfont])
1181 AC_SUBST([build_freetype_cflags])
1182 AC_SUBST([build_freetype_libs])
1186 CFLAGS="$SAVED_CFLAGS"
1187 CPPFLAGS="$SAVED_CPPFLAGS"
1194 AC_ARG_ENABLE([grub-themes],
1195 [AS_HELP_STRING([--enable-grub-themes],
1196 [build and install GRUB themes (default=guessed)])])
1197 if test x"$enable_grub_themes" = xno ; then
1198 starfield_excuse="explicitly disabled"
1201 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1202 starfield_excuse="No build-time grub-mkfont"
1205 if test x"$starfield_excuse" = x; then
1206 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1207 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
1208 if test -f "$dir/DejaVuSans.$ext"; then
1209 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1215 if test "x$DJVU_FONT_SOURCE" = x; then
1216 starfield_excuse="No DejaVu found"
1220 if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1221 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied])
1224 AC_SUBST([DJVU_FONT_SOURCE])
1228 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1229 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
1230 if test -f "$dir/unifont.$ext"; then
1231 FONT_SOURCE="$dir/unifont.$ext"
1237 if test x"$enable_build_grub_mkfont" = xno ; then
1241 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
1242 AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports need unifont])
1245 AC_SUBST([FONT_SOURCE])
1247 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1248 grub_build_mkfont_excuse="no fonts"
1252 AC_ARG_ENABLE([grub-mount],
1253 [AS_HELP_STRING([--enable-grub-mount],
1254 [build and install the `grub-mount' utility (default=guessed)])])
1255 if test x"$enable_grub_mount" = xno ; then
1256 grub_mount_excuse="explicitly disabled"
1259 if test x"$grub_mount_excuse" = x ; then
1260 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1261 [grub_mount_excuse="need FUSE library"])
1264 if test x"$grub_mount_excuse" = x ; then
1265 # Check for fuse headers.
1266 SAVED_CPPFLAGS="$CPPFLAGS"
1267 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
1268 AC_CHECK_HEADERS([fuse/fuse.h], [],
1269 [grub_mount_excuse=["need FUSE headers"]])
1270 CPPFLAGS="$SAVED_CPPFLAGS"
1273 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1274 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
1276 if test x"$grub_mount_excuse" = x ; then
1277 enable_grub_mount=yes
1279 enable_grub_mount=no
1281 AC_SUBST([enable_grub_mount])
1283 AC_ARG_ENABLE([device-mapper],
1284 [AS_HELP_STRING([--enable-device-mapper],
1285 [enable Linux device-mapper support (default=guessed)])])
1286 if test x"$enable_device_mapper" = xno ; then
1287 device_mapper_excuse="explicitly disabled"
1290 if test x"$device_mapper_excuse" = x ; then
1291 # Check for device-mapper header.
1292 AC_CHECK_HEADER([libdevmapper.h], [],
1293 [device_mapper_excuse="need libdevmapper header"])
1296 if test x"$device_mapper_excuse" = x ; then
1297 # Check for device-mapper library.
1298 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1299 [device_mapper_excuse="need devmapper library"])
1302 if test x"$device_mapper_excuse" = x ; then
1303 # Check for device-mapper library.
1304 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1306 [device_mapper_excuse="need devmapper library"])
1309 if test x"$device_mapper_excuse" = x ; then
1310 LIBDEVMAPPER="-ldevmapper";
1311 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1312 [Define to 1 if you have the devmapper library.])
1315 AC_SUBST([LIBDEVMAPPER])
1318 if test x$host_kernel = xkfreebsd; then
1319 AC_CHECK_LIB([geom], [geom_gettree], [],
1320 [AC_MSG_ERROR([Your platform requires libgeom])])
1326 AC_ARG_ENABLE([liblzma],
1327 [AS_HELP_STRING([--enable-liblzma],
1328 [enable liblzma integration (default=guessed)])])
1329 if test x"$enable_liblzma" = xno ; then
1330 liblzma_excuse="explicitly disabled"
1333 if test x"$liblzma_excuse" = x ; then
1334 AC_CHECK_LIB([lzma], [lzma_code],
1335 [],[liblzma_excuse="need lzma library"])
1337 if test x"$liblzma_excuse" = x ; then
1338 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1341 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1342 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied])
1346 if test x"$liblzma_excuse" = x ; then
1348 AC_DEFINE([USE_LIBLZMA], [1],
1349 [Define to 1 if you have the LZMA library.])
1354 AC_ARG_ENABLE([libzfs],
1355 [AS_HELP_STRING([--enable-libzfs],
1356 [enable libzfs integration (default=guessed)])])
1357 if test x"$enable_libzfs" = xno ; then
1358 libzfs_excuse="explicitly disabled"
1361 if test x"$libzfs_excuse" = x ; then
1362 # Only check for system headers if libzfs support has not been disabled.
1363 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1366 if test x"$libzfs_excuse" = x ; then
1367 AC_CHECK_LIB([zfs], [libzfs_init],
1369 [libzfs_excuse="need zfs library"])
1372 if test x"$libzfs_excuse" = x ; then
1373 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1375 [libzfs_excuse="need nvpair library"])
1378 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1379 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1382 if test x"$libzfs_excuse" = x ; then
1383 # We need both libzfs and libnvpair for a successful build.
1385 AC_DEFINE([HAVE_LIBZFS], [1],
1386 [Define to 1 if you have the ZFS library.])
1387 LIBNVPAIR="-lnvpair"
1388 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1389 [Define to 1 if you have the NVPAIR library.])
1393 AC_SUBST([LIBNVPAIR])
1397 AC_SUBST([FONT_SOURCE])
1398 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1399 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1401 AC_SUBST(HAVE_ASM_USCORE)
1404 AC_SUBST(BSS_START_SYMBOL)
1405 AC_SUBST(END_SYMBOL)
1408 AC_SUBST(NEED_REGISTER_FRAME_INFO)
1410 AC_ARG_ENABLE([werror],
1411 [AS_HELP_STRING([--disable-werror],
1412 [do not use -Werror when building GRUB])])
1413 if test x"$enable_werror" != xno ; then
1414 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1415 HOST_CFLAGS="$HOST_CFLAGS -Werror"
1418 if test "x$grub_cv_cc_target_clang" = xno; then
1419 TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
1421 TARGET_LDFLAGS_STATIC_LIBGCC=
1424 TARGET_CPP="$TARGET_CC -E"
1425 TARGET_CCAS=$TARGET_CC
1427 GRUB_TARGET_CPU="${target_cpu}"
1428 GRUB_PLATFORM="${platform}"
1430 AC_SUBST(GRUB_TARGET_CPU)
1431 AC_SUBST(GRUB_PLATFORM)
1433 AC_SUBST(TARGET_OBJCONV)
1434 AC_SUBST(TARGET_LIBGCC)
1435 AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
1436 AC_SUBST(TARGET_CPP)
1437 AC_SUBST(TARGET_CCAS)
1438 AC_SUBST(TARGET_OBJ2ELF)
1439 AC_SUBST(TARGET_MODULE_FORMAT)
1441 AC_SUBST(TARGET_CFLAGS)
1442 AC_SUBST(TARGET_LDFLAGS)
1443 AC_SUBST(TARGET_CPPFLAGS)
1444 AC_SUBST(TARGET_CCASFLAGS)
1446 AC_SUBST(TARGET_IMG_LDSCRIPT)
1447 AC_SUBST(TARGET_IMG_LDFLAGS)
1448 AC_SUBST(TARGET_IMG_CFLAGS)
1449 AC_SUBST(TARGET_IMG_BASE_LDOPT)
1450 AC_SUBST(TARGET_APPLE_LINKER)
1452 AC_SUBST(HOST_CFLAGS)
1453 AC_SUBST(HOST_LDFLAGS)
1454 AC_SUBST(HOST_CPPFLAGS)
1455 AC_SUBST(HOST_CCASFLAGS)
1457 AC_SUBST(BUILD_LIBM)
1460 # Automake conditionals
1463 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1464 AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
1465 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1466 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1467 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1468 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1469 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1470 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1471 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1472 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1473 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1474 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
1475 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1476 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1477 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1478 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1479 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1480 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1481 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1482 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1483 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1484 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1485 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1487 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1488 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1489 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1490 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1491 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1492 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1493 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1495 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1496 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1497 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1498 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1499 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1500 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1501 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1502 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
1503 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1504 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1505 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1507 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1509 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1510 AM_CONDITIONAL([COND_CYGWIN], [test x$target_os = xcygwin])
1511 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1512 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
1514 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
1515 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
1516 datarootdir="$(eval echo "$datarootdir")"
1517 grub_libdir="$(eval echo "$libdir")"
1518 grub_localedir="$(eval echo "$localedir")"
1519 grub_datadir="$(eval echo "$datadir")"
1520 grub_sysconfdir="$(eval echo "$sysconfdir")"
1521 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
1522 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
1523 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
1524 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
1528 cpudir="${target_cpu}"
1529 if test x${cpudir} = xmipsel; then
1533 if test x"$link_dir" = xyes ; then
1534 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1535 if test "$platform" != emu ; then
1536 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1539 mkdir -p include/grub 2>/dev/null
1540 rm -rf include/grub/cpu
1541 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1542 if test "$platform" != emu ; then
1543 rm -rf include/grub/machine
1544 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1548 AC_CONFIG_FILES([Makefile])
1549 AC_CONFIG_FILES([grub-core/Makefile])
1550 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1551 AC_CONFIG_FILES([po/Makefile.in])
1552 AC_CONFIG_FILES([docs/Makefile])
1553 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1554 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1555 AC_CONFIG_FILES([config.h])
1559 echo "*******************************************************"
1560 echo GRUB2 will be compiled with following components:
1561 echo Platform: "$target_cpu"-"$platform"
1562 if [ x"$platform" = xemu ]; then
1563 if [ x"$grub_emu_usb_excuse" = x ]; then
1564 echo USB support for grub-emu: Yes
1566 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1568 if [ x"$grub_emu_sdl_excuse" = x ]; then
1569 echo SDL support for grub-emu: Yes
1571 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1573 if [ x"$grub_emu_pci_excuse" = x ]; then
1574 echo PCI support for grub-emu: Yes
1576 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1579 if test x"$device_mapper_excuse" = x ; then
1580 echo With devmapper support: Yes
1582 echo With devmapper support: No "($device_mapper_excuse)"
1584 if [ x"$enable_mm_debug" = xyes ]; then
1585 echo With memory debugging: Yes
1587 echo With memory debugging: No
1589 if [ x"$enable_cache_stats" = xyes ]; then
1590 echo With disk cache statistics: Yes
1592 echo With disk cache statistics: No
1595 if [ x"$enable_boot_time" = xyes ]; then
1596 echo With boot time statistics: Yes
1598 echo With boot time statistics: No
1601 if [ x"$efiemu_excuse" = x ]; then
1602 echo efiemu runtime: Yes
1604 echo efiemu runtime: No "($efiemu_excuse)"
1606 if [ x"$grub_mkfont_excuse" = x ]; then
1607 echo grub-mkfont: Yes
1609 echo grub-mkfont: No "($grub_mkfont_excuse)"
1611 if [ x"$grub_mount_excuse" = x ]; then
1612 echo grub-mount: Yes
1614 echo grub-mount: No "($grub_mount_excuse)"
1616 if [ x"$starfield_excuse" = x ]; then
1617 echo starfield theme: Yes
1619 echo starfield theme: No "($starfield_excuse)"
1621 if [ x"$libzfs_excuse" = x ]; then
1622 echo With libzfs support: Yes
1624 echo With libzfs support: No "($libzfs_excuse)"
1626 if [ x"$grub_build_mkfont_excuse" = x ]; then
1627 echo Build-time grub-mkfont: Yes
1628 if test "x$FONT_SOURCE" = x ; then
1629 echo "Without unifont"
1631 echo "With unifont from $FONT_SOURCE"
1634 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
1635 echo "Without unifont (no build-time grub-mkfont)"
1637 if test x"$liblzma_excuse" != x ; then
1638 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
1640 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
1642 echo "*******************************************************"