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}"
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 BUILD_CPPFLAGS="$BUILD_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
80 # Default HOST_CPPFLAGS
81 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
82 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
83 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
84 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
85 HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
87 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
88 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
89 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
92 i[[3456]]86) target_cpu=i386 ;;
93 amd64) target_cpu=x86_64 ;;
94 sparc) target_cpu=sparc64 ;;
97 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
101 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
108 # Specify the platform (such as firmware).
109 AC_ARG_WITH([platform],
110 AS_HELP_STRING([--with-platform=PLATFORM],
111 [select the host platform [[guessed]]]))
113 # Guess the platform if not specified.
114 if test "x$with_platform" = x; then
115 case "$target_cpu"-"$target_vendor" in
116 i386-apple) platform=efi ;;
117 i386-*) platform=pc ;;
118 x86_64-apple) platform=efi ;;
119 x86_64-*) platform=pc ;;
120 powerpc-*) platform=ieee1275 ;;
121 powerpc64-*) platform=ieee1275 ;;
122 sparc64-*) platform=ieee1275 ;;
123 mipsel-*) platform=loongson ;;
124 mips-*) platform=arc ;;
125 ia64-*) platform=efi ;;
126 arm-*) platform=uboot ;;
127 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
130 platform="$with_platform"
133 case "$target_cpu"-"$platform" in
136 x86_64-*) target_cpu=i386 ;;
137 powerpc64-ieee1275) target_cpu=powerpc ;;
140 # Check if the platform is supported, make final adjustments.
141 case "$target_cpu"-"$platform" in
147 i386-linuxbios) platform=coreboot ;;
154 mips-qemu-mips) platform=qemu_mips;;
158 mipsel-qemu-mips) platform=qemu_mips;;
159 mipsel-yeeloong) platform=loongson ;;
160 mipsel-fuloong) platform=loongson ;;
165 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
168 if test x$platform != xemu ; then
169 case "$target_cpu" in
170 i386 | powerpc) target_m32=1 ;;
171 x86_64 | sparc64) target_m64=1 ;;
176 windows* | mingw32*) target_os=cygwin ;;
179 # This normalizes the names, and creates a new variable ("host_kernel")
180 # while at it, since the mapping is not always 1:1 (e.g. different OSes
181 # using the same kernel type).
183 gnu*) host_kernel=hurd ;;
184 linux*) host_kernel=linux ;;
185 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
186 netbsd*) host_kernel=netbsd ;;
187 solaris*) host_kernel=illumos ;;
188 darwin*) host_kernel=xnu ;;
189 cygwin | windows* | mingw32*) host_kernel=windows ;;
193 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
194 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
195 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
196 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
197 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
198 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
199 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
200 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
201 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
202 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
203 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
205 case "$target_cpu" in
206 arm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
207 mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
208 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
210 if test x${target_cpu} = xmipsel ; then
211 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
213 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"
216 case "${target_cpu}-$platform" in
218 TARGET_LINK_ADDR=0x88200000
219 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
222 TARGET_LINK_ADDR=0x80700000
223 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
225 mips*-qemu_mips | mips*-loongson)
226 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
230 AC_SUBST(TARGET_LINK_ADDR)
231 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
233 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
237 AC_SUBST(host_kernel)
242 # Define default variables
245 AC_ARG_WITH([bootdir],
246 AS_HELP_STRING([--with-bootdir=DIR],
247 [set the name of /boot directory [[guessed]]]),
248 [have_with_bootdir=y],
249 [have_with_bootdir=n])
250 if test x$have_with_bootdir = xy; then
251 bootdirname="$with_bootdir"
255 # Because /boot is used for the boot block in NetBSD and OpenBSD,
257 *) bootdirname='boot' ;;
261 AC_SUBST(bootdirname)
262 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
263 [Default boot directory name]")
265 AC_ARG_WITH([grubdir],
266 AS_HELP_STRING([--with-grubdir=DIR],
267 [set the name of grub directory [[guessed]]]),
268 [grubdirname="$with_grubdir"],
269 [grubdirname="$PACKAGE"])
271 AC_SUBST(grubdirname)
272 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
273 [Default grub directory name])
276 # Checks for build programs.
279 # Although cmp is listed in the GNU Coding Standards as a command which
280 # can used directly, OpenBSD lacks cmp in the default installation.
281 AC_CHECK_PROGS([CMP], [cmp])
282 if test "x$CMP" = x; then
283 AC_MSG_ERROR([cmp is not found])
286 AC_CHECK_PROGS([YACC], [bison])
287 if test "x$YACC" = x; then
288 AC_MSG_ERROR([bison is not found])
300 if test "x$LEX" = "x:"; then
301 AC_MSG_ERROR([flex is not found])
303 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
304 if test -n "$version" -a "$version" -ge 20535; then
307 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
311 # These are not a "must".
312 AC_PATH_PROGS(MAKEINFO, makeinfo true)
315 # Checks for host programs.
325 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
327 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
330 AM_GNU_GETTEXT([external])
333 # Identify characteristics of the host architecture.
334 unset ac_cv_c_bigendian
337 AC_CHECK_SIZEOF(void *)
338 AC_CHECK_SIZEOF(long)
341 cygwin | windows* | mingw32*)
342 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
343 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
344 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
349 if test x$grub_cv_apple_cc = xyes ; then
350 HOST_CPPFLAGS="$HOST_CPPFLAGS -fnested-functions"
351 HOST_LDFLAGS="$HOST_LDFLAGS -Wl,-allow_stack_execute"
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"
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 grub_PROG_NM_DEFINED_ONLY
470 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
471 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
474 WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wcast-align -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"
475 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
476 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
477 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
479 # Force no alignment to save space on i386.
480 if test "x$target_cpu" = xi386; then
481 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
482 CFLAGS="$CFLAGS -falign-loops=1"
483 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
484 [grub_cv_cc_falign_loop=yes],
485 [grub_cv_cc_falign_loop=no])
488 if test "x$grub_cv_cc_falign_loop" = xyes; then
489 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
491 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
495 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
496 # Some toolchains enable these features by default, but they need
497 # registers that aren't set up properly in GRUB.
498 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
501 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
502 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
505 # By default, GCC 4.4 generates .eh_frame sections containing unwind
506 # information in some cases where it previously did not. GRUB doesn't need
507 # these and they just use up vital space. Restore the old compiler
509 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
510 SAVE_CFLAGS="$CFLAGS"
511 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
512 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
513 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
514 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
515 CFLAGS="$SAVE_CFLAGS"
518 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
519 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
522 if test x"$target_os" = xcygwin; then
523 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
524 CFLAGS="$CFLAGS -fno-reorder-functions"
525 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
526 [grub_cv_cc_no_reorder_functions=yes],
527 [grub_cv_cc_no_reorder_functions=no])
531 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
532 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
535 # By default, GCC 4.6 generates .eh_frame sections containing unwind
536 # information in some cases where it previously did not. GRUB doesn't need
537 # these and they just use up vital space. Restore the old compiler
539 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
540 SAVE_CFLAGS="$CFLAGS"
541 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
542 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
543 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
544 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
545 CFLAGS="$SAVE_CFLAGS"
548 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
549 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
553 if test x$grub_cv_apple_target_cc = xyes ; then
554 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -fnested-functions"
556 CFLAGS="$CFLAGS -fnested-functions"
558 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
559 if test "x$TARGET_OBJCONV" = x ; then
560 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
562 if test "x$TARGET_OBJCONV" = x ; then
563 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
566 TARGET_IMG_CFLAGS="-static"
567 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
568 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
569 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
570 TARGET_LDFLAGS_OLDMAGIC=""
573 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
574 # Use linker script if present, otherwise use builtin -N script.
575 if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"; then
576 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"
577 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
578 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"
579 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
582 TARGET_IMG_LDFLAGS='-Wl,-N'
583 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
584 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
589 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
591 # For platforms where ELF is not the default link format.
592 AC_MSG_CHECKING([for command to convert module to ELF format])
593 case "${target_os}" in
594 cygwin) TARGET_OBJ2ELF='./build-grub-pe2elf';
595 # FIXME: put proper test here
596 NEED_REGISTER_FRAME_INFO=1
598 *) NEED_REGISTER_FRAME_INFO=0 ;;
600 AC_MSG_RESULT([$TARGET_OBJ2ELF])
603 AC_ARG_ENABLE([efiemu],
604 [AS_HELP_STRING([--enable-efiemu],
605 [build and install the efiemu runtimes (default=guessed)])])
606 if test x"$enable_efiemu" = xno ; then
607 efiemu_excuse="explicitly disabled"
609 if test x"$target_os" = xcygwin ; then
610 efiemu_excuse="not available on cygwin"
612 if test x"$target_cpu" != xi386 ; then
613 efiemu_excuse="only available on i386"
615 if test x"$platform" = xefi ; then
616 efiemu_excuse="not available on efi"
618 if test x"$efiemu_excuse" = x ; then
619 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
620 SAVED_CFLAGS="$CFLAGS"
621 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
622 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
623 [grub_cv_cc_efiemu=yes],
624 [grub_cv_cc_efiemu=no])
625 CFLAGS="$SAVED_CFLAGS"
627 if test x$grub_cv_cc_efiemu = xno; then
628 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
631 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
632 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
634 if test x"$efiemu_excuse" = x ; then
639 AC_SUBST([enable_efiemu])
641 if test "x$target_m32" = x1; then
643 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
644 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
645 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
646 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
647 TARGET_MODULE_FORMAT="elf32"
650 if test "x$target_m64" = x1; then
652 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
653 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
654 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
655 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
656 TARGET_MODULE_FORMAT="elf64"
663 if test x"$target_cpu" = xi386; then
664 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_fbsd"
666 if test x"$target_cpu" = xx86_64; then
667 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64_fbsd"
671 if test x"$target_cpu" = xi386; then
672 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_obsd"
674 if test x"$target_cpu" = xx86_64; then
675 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64_obsd"
679 if test x"$target_cpu" = xi386; then
680 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_haiku"
682 if test x"$target_cpu" = xx86_64; then
683 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64_haiku"
687 if test x"$target_cpu" = xi386; then
688 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386"
690 if test x"$target_cpu" = xx86_64; then
691 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64"
696 if test "$target_cpu" = x86_64; then
697 # Use large model to support 4G memory
698 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
700 CFLAGS="$CFLAGS -m64 -mcmodel=large"
701 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
702 [grub_cv_cc_mcmodel=yes],
703 [grub_cv_cc_mcmodel=no])
705 if test "x$grub_cv_cc_mcmodel" = xno; then
706 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
708 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
712 if test "$target_cpu"-"$platform" = x86_64-efi; then
713 # EFI writes to stack below %rsp, we must not use the red zone
714 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
715 CFLAGS="$CFLAGS -m64 -mno-red-zone"
716 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
717 [grub_cv_cc_no_red_zone=yes],
718 [grub_cv_cc_no_red_zone=no])
720 if test "x$grub_cv_cc_no_red_zone" = xno; then
721 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
724 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
731 # Position independent executable.
733 [# Need that, because some distributions ship compilers that include
734 # `-fPIE' in the default specs.
735 if [ x"$pie_possible" = xyes ]; then
736 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
739 # Position independent executable.
741 [# Need that, because some distributions ship compilers that include
742 # `-fPIC' in the default specs.
743 if [ x"$pic_possible" = xyes ]; then
744 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
747 # Smashing stack protector.
748 grub_CHECK_STACK_PROTECTOR
749 # Need that, because some distributions ship compilers that include
750 # `-fstack-protector' in the default specs.
751 if test "x$ssp_possible" = xyes; then
752 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
754 grub_CHECK_STACK_ARG_PROBE
755 # Cygwin's GCC uses alloca() to probe the stackframe on static
756 # stack allocations above some threshold.
757 if test x"$sap_possible" = xyes; then
758 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
761 # -mno-unaligned-access
762 if test "$target_cpu" = arm; then
763 grub_CHECK_NO_UNALIGNED_ACCESS
764 if test x"$nua_possible" = xyes; then
765 TARGET_CFLAGS="$TARGET_CFLAGS -mno-unaligned-access"
769 AC_ARG_ENABLE([werror],
770 [AS_HELP_STRING([--disable-werror],
771 [do not use -Werror when building GRUB])])
772 if test x"$enable_werror" != xno ; then
773 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
774 HOST_CFLAGS="$HOST_CFLAGS -Werror"
777 TARGET_CPP="$TARGET_CC -E"
778 TARGET_CCAS=$TARGET_CC
780 GRUB_TARGET_CPU="${target_cpu}"
781 GRUB_PLATFORM="${platform}"
783 AC_SUBST(GRUB_TARGET_CPU)
784 AC_SUBST(GRUB_PLATFORM)
786 AC_SUBST(TARGET_OBJCONV)
788 AC_SUBST(TARGET_CCAS)
789 AC_SUBST(TARGET_OBJ2ELF)
790 AC_SUBST(TARGET_APPLE_CC)
791 AC_SUBST(TARGET_MODULE_FORMAT)
793 AC_SUBST(TARGET_CFLAGS)
794 AC_SUBST(TARGET_LDFLAGS)
795 AC_SUBST(TARGET_CPPFLAGS)
796 AC_SUBST(TARGET_CCASFLAGS)
798 AC_SUBST(TARGET_IMG_LDSCRIPT)
799 AC_SUBST(TARGET_IMG_LDFLAGS)
800 AC_SUBST(TARGET_IMG_CFLAGS)
801 AC_SUBST(TARGET_IMG_BASE_LDOPT)
803 AC_SUBST(HOST_CFLAGS)
804 AC_SUBST(HOST_LDFLAGS)
805 AC_SUBST(HOST_CPPFLAGS)
806 AC_SUBST(HOST_CCASFLAGS)
810 # Set them to their new values for the tests below.
812 if test "x$TARGET_APPLE_CC" = x1 ; then
813 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
815 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
817 CPPFLAGS="$TARGET_CPPFLAGS"
818 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
825 if test x$grub_cv_asm_uscore = xyes; then
826 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
828 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
831 # Check for libgcc symbols
832 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
834 if test "x$TARGET_APPLE_CC" = x1 ; then
835 CFLAGS="$TARGET_CFLAGS -nostdlib"
837 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
841 # Defined in aclocal.m4.
843 if test "x$TARGET_APPLE_CC" != x1 ; then
844 grub_PROG_OBJCOPY_ABSOLUTE
846 grub_PROG_LD_BUILD_ID_NONE
847 if test "x$target_cpu" = xi386; then
848 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
849 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
850 # Check symbols provided by linker script.
851 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000 -Wl,--defsym,___main=0x8100"
853 grub_CHECK_BSS_START_SYMBOL
854 grub_CHECK_END_SYMBOL
856 CFLAGS="$TARGET_CFLAGS"
857 grub_I386_ASM_PREFIX_REQUIREMENT
861 if test "$platform" != emu; then
862 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
863 SAVED_CPPFLAGS="$CPPFLAGS"
864 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
865 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
867 int va_arg_func (int fixed, va_list args);]], [[]])],
868 [grub_cv_cc_isystem=yes],
869 [grub_cv_cc_isystem=no])
870 CPPFLAGS="$SAVED_CPPFLAGS"
873 if test x"$grub_cv_cc_isystem" = xyes ; then
874 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
878 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
879 SAVED_CFLAGS="$CFLAGS"
880 CFLAGS="$TARGET_CFLAGS -Wtrampolines"
881 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
882 int va_arg_func (int fixed, va_list args);]], [[]])],
883 [grub_cv_cc_wtrampolines=yes],
884 [grub_cv_cc_wtrampolines=no])
885 CFLAGS="$SAVED_CFLAGS"
888 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
889 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
895 CPPFLAGS="$tmp_CPPFLAGS"
896 LDFLAGS="$tmp_LDFLAGS"
903 # Memory manager debugging.
904 AC_ARG_ENABLE([mm-debug],
905 AS_HELP_STRING([--enable-mm-debug],
906 [include memory manager debugging]),
907 [AC_DEFINE([MM_DEBUG], [1],
908 [Define to 1 if you enable memory manager debugging.])])
910 AC_ARG_ENABLE([cache-stats],
911 AS_HELP_STRING([--enable-cache-stats],
912 [enable disk cache statistics collection]))
914 if test x$enable_cache_stats = xyes; then
919 AC_SUBST([DISK_CACHE_STATS])
921 AC_ARG_ENABLE([boot-time],
922 AS_HELP_STRING([--enable-boot-time],
923 [enable boot time statistics collection]))
925 if test x$enable_boot_time = xyes; then
930 AC_SUBST([BOOT_TIME_STATS])
932 AC_ARG_ENABLE([grub-emu-usb],
933 [AS_HELP_STRING([--enable-grub-emu-usb],
934 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
936 AC_ARG_ENABLE([grub-emu-sdl],
937 [AS_HELP_STRING([--enable-grub-emu-sdl],
938 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
940 AC_ARG_ENABLE([grub-emu-pci],
941 [AS_HELP_STRING([--enable-grub-emu-pci],
942 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
944 if test "$platform" = emu; then
946 if test x"$enable_grub_emu_usb" != xyes ; then
947 grub_emu_usb_excuse="not enabled"
950 if test x"$enable_grub_emu_pci" = xyes ; then
951 grub_emu_usb_excuse="conflicts with PCI support"
954 [if [ x"$grub_emu_usb_excuse" = x ]; then
955 # Check for libusb libraries.]
956 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
957 [grub_emu_usb_excuse=["need libusb library"]])
960 [if [ x"$grub_emu_usb_excuse" = x ]; then
961 # Check for headers.]
962 AC_CHECK_HEADERS([usb.h], [],
963 [grub_emu_usb_excuse=["need libusb headers"]])
965 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
966 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
968 if test x"$grub_emu_usb_excuse" = x ; then
969 enable_grub_emu_usb=yes
971 enable_grub_emu_usb=no
974 if test x"$enable_grub_emu_sdl" = xno ; then
975 grub_emu_sdl_excuse="explicitely disabled"
977 [if [ x"$grub_emu_sdl_excuse" = x ]; then
978 # Check for libSDL libraries.]
979 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
980 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
984 [if [ x"$grub_emu_sdl_excuse" = x ]; then
985 # Check for headers.]
986 AC_CHECK_HEADERS([SDL/SDL.h], [],
987 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
990 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
991 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
993 if test x"$grub_emu_sdl_excuse" = x ; then
994 enable_grub_emu_sdl=yes
996 enable_grub_emu_sdl=no
999 if test x"$enable_grub_emu_pci" != xyes ; then
1000 grub_emu_pci_excuse="not enabled"
1003 if test x"$enable_grub_emu_usb" = xyes ; then
1004 grub_emu_pci_excuse="conflicts with USB support"
1007 [if [ x"$grub_emu_pci_excuse" = x ]; then
1008 # Check for libpci libraries.]
1009 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1010 [grub_emu_pci_excuse=["need libpciaccess library"]])
1011 AC_SUBST([LIBPCIACCESS])
1013 [if [ x"$grub_emu_pci_excuse" = x ]; then
1014 # Check for headers.]
1015 AC_CHECK_HEADERS([pci/pci.h], [],
1016 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1019 if test x"$grub_emu_pci_excuse" = x ; then
1020 enable_grub_emu_pci=yes
1023 enable_grub_emu_pci=no
1026 AC_SUBST([enable_grub_emu_sdl])
1027 AC_SUBST([enable_grub_emu_usb])
1028 AC_SUBST([enable_grub_emu_pci])
1032 # Ignore --enable-emu-* if platform is not emu
1033 enable_grub_emu_sdl=no
1034 enable_grub_emu_usb=no
1035 enable_grub_emu_pci=no
1038 AC_ARG_ENABLE([grub-mkfont],
1039 [AS_HELP_STRING([--enable-grub-mkfont],
1040 [build and install the `grub-mkfont' utility (default=guessed)])])
1041 if test x"$enable_grub_mkfont" = xno ; then
1042 grub_mkfont_excuse="explicitly disabled"
1045 if test x"$grub_mkfont_excuse" = x ; then
1046 # Check for freetype libraries.
1047 AC_CHECK_TOOLS([FREETYPE], [freetype-config])
1048 if test "x$FREETYPE" = x ; then
1049 grub_mkfont_excuse=["need freetype2 library"]
1053 unset ac_cv_header_ft2build_h
1055 if test x"$grub_mkfont_excuse" = x ; then
1056 # Check for freetype libraries.
1057 freetype_cflags=`$FREETYPE --cflags`
1058 freetype_libs=`$FREETYPE --libs`
1059 SAVED_CPPFLAGS="$CPPFLAGS"
1060 CPPFLAGS="$CPPFLAGS $freetype_cflags"
1061 AC_CHECK_HEADERS([ft2build.h], [],
1062 [grub_mkfont_excuse=["need freetype2 headers"]])
1063 CPPFLAGS="$SAVED_CPPFLAGS"
1066 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1067 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
1069 if test x"$grub_mkfont_excuse" = x ; then
1070 enable_grub_mkfont=yes
1072 enable_grub_mkfont=no
1074 AC_SUBST([enable_grub_mkfont])
1075 AC_SUBST([freetype_cflags])
1076 AC_SUBST([freetype_libs])
1080 SAVED_CFLAGS="$CFLAGS"
1081 SAVED_CPPFLAGS="$CPPFLAGS"
1084 CFLAGS="$BUILD_CFLAGS"
1085 CPPFLAGS="$BUILD_CPPFLAGS"
1087 unset ac_cv_c_bigendian
1088 unset ac_cv_header_ft2build_h
1090 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1091 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1092 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1094 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1095 AC_MSG_ERROR([couldnt determine build endianness])
1098 AC_SUBST([BUILD_SIZEOF_LONG])
1099 AC_SUBST([BUILD_SIZEOF_VOID_P])
1100 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1102 if test x"$grub_build_mkfont_excuse" = x ; then
1103 # Check for freetype libraries.
1104 AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config])
1105 if test "x$BUILD_FREETYPE" = x ; then
1106 grub_build_mkfont_excuse=["need freetype2 library"]
1110 if test x"$grub_build_mkfont_excuse" = x ; then
1111 # Check for freetype libraries.
1112 build_freetype_cflags=`$BUILD_FREETYPE --cflags`
1113 build_freetype_libs=`$BUILD_FREETYPE --libs`
1114 SAVED_CPPFLAGS_2="$CPPFLAGS"
1115 CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
1116 AC_CHECK_HEADERS([ft2build.h], [],
1117 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1118 CPPFLAGS="$SAVED_CPPFLAGS_2"
1121 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1122 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled])
1124 if test x"$grub_build_mkfont_excuse" = x ; then
1125 enable_build_grub_mkfont=yes
1127 enable_build_grub_mkfont=no
1129 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
1130 AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports needs build-time grub-mkfont])
1133 AC_SUBST([build_freetype_cflags])
1134 AC_SUBST([build_freetype_libs])
1138 CFLAGS="$SAVED_CFLAGS"
1139 CPPFLAGS="$SAVED_CPPFLAGS"
1146 if test x"$enable_build_grub_mkfont" = xno ; then
1147 starfield_excuse="No build-time grub-mkfont"
1150 if test x"$starfield_excuse" = x; then
1151 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1152 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
1153 if test -f "$dir/DejaVuSans.$ext"; then
1154 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1160 if test "x$DJVU_FONT_SOURCE" = x; then
1161 starfield_excuse="No DejaVu found"
1165 AC_SUBST([DJVU_FONT_SOURCE])
1169 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1170 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
1171 if test -f "$dir/unifont.$ext"; then
1172 FONT_SOURCE="$dir/unifont.$ext"
1178 if test x"$enable_build_grub_mkfont" = xno ; then
1182 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
1183 AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports need unifont])
1186 AC_SUBST([FONT_SOURCE])
1188 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1189 grub_build_mkfont_excuse="no fonts"
1193 AC_ARG_ENABLE([grub-mount],
1194 [AS_HELP_STRING([--enable-grub-mount],
1195 [build and install the `grub-mount' utility (default=guessed)])])
1196 if test x"$enable_grub_mount" = xno ; then
1197 grub_mount_excuse="explicitly disabled"
1200 if test x"$grub_mount_excuse" = x ; then
1201 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1202 [grub_mount_excuse="need FUSE library"])
1205 if test x"$grub_mount_excuse" = x ; then
1206 # Check for fuse headers.
1207 SAVED_CPPFLAGS="$CPPFLAGS"
1208 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
1209 AC_CHECK_HEADERS([fuse/fuse.h], [],
1210 [grub_mount_excuse=["need FUSE headers"]])
1211 CPPFLAGS="$SAVED_CPPFLAGS"
1214 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1215 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
1217 if test x"$grub_mount_excuse" = x ; then
1218 enable_grub_mount=yes
1220 enable_grub_mount=no
1222 AC_SUBST([enable_grub_mount])
1224 AC_ARG_ENABLE([device-mapper],
1225 [AS_HELP_STRING([--enable-device-mapper],
1226 [enable Linux device-mapper support (default=guessed)])])
1227 if test x"$enable_device_mapper" = xno ; then
1228 device_mapper_excuse="explicitly disabled"
1231 if test x"$device_mapper_excuse" = x ; then
1232 # Check for device-mapper header.
1233 AC_CHECK_HEADER([libdevmapper.h], [],
1234 [device_mapper_excuse="need libdevmapper header"])
1237 if test x"$device_mapper_excuse" = x ; then
1238 # Check for device-mapper library.
1239 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1240 [device_mapper_excuse="need devmapper library"])
1243 if test x"$device_mapper_excuse" = x ; then
1244 # Check for device-mapper library.
1245 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1247 [device_mapper_excuse="need devmapper library"])
1250 if test x"$device_mapper_excuse" = x ; then
1251 LIBDEVMAPPER="-ldevmapper";
1252 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1253 [Define to 1 if you have the devmapper library.])
1256 AC_SUBST([LIBDEVMAPPER])
1259 if test x$host_kernel = xkfreebsd; then
1260 AC_CHECK_LIB([geom], [geom_gettree], [],
1261 [AC_MSG_ERROR([Your platform requires libgeom])])
1267 AC_CHECK_LIB([lzma], [lzma_code],
1269 AC_DEFINE([HAVE_LIBLZMA], [1],
1270 [Define to 1 if you have the LZMA library.])],)
1273 AC_ARG_ENABLE([libzfs],
1274 [AS_HELP_STRING([--enable-libzfs],
1275 [enable libzfs integration (default=guessed)])])
1276 if test x"$enable_libzfs" = xno ; then
1277 libzfs_excuse="explicitly disabled"
1280 if test x"$libzfs_excuse" = x ; then
1281 # Only check for system headers if libzfs support has not been disabled.
1282 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1285 if test x"$libzfs_excuse" = x ; then
1286 AC_CHECK_LIB([zfs], [libzfs_init],
1288 [libzfs_excuse="need zfs library"])
1291 if test x"$libzfs_excuse" = x ; then
1292 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1294 [libzfs_excuse="need nvpair library"])
1297 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1298 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1301 if test x"$libzfs_excuse" = x ; then
1302 # We need both libzfs and libnvpair for a successful build.
1304 AC_DEFINE([HAVE_LIBZFS], [1],
1305 [Define to 1 if you have the ZFS library.])
1306 LIBNVPAIR="-lnvpair"
1307 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1308 [Define to 1 if you have the NVPAIR library.])
1312 AC_SUBST([LIBNVPAIR])
1316 AC_SUBST([FONT_SOURCE])
1317 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1318 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1319 AS_IF([test x$TARGET_APPLE_CC = x1],
1320 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
1322 AC_SUBST(HAVE_ASM_USCORE)
1325 AC_SUBST(BSS_START_SYMBOL)
1326 AC_SUBST(END_SYMBOL)
1329 AC_SUBST(NEED_REGISTER_FRAME_INFO)
1332 # Automake conditionals
1335 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1336 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1337 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1338 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1339 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1340 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1341 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1342 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1343 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1344 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1345 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1346 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1347 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1348 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1349 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1350 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1351 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1352 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1353 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1354 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1356 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1357 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1358 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1359 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1360 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1361 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1362 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1364 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1365 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1366 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1367 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1368 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1369 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1370 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1371 AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
1372 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1373 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1374 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1376 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1378 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1379 AM_CONDITIONAL([COND_CYGWIN], [test x$target_os = xcygwin])
1380 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1383 cpudir="${target_cpu}"
1384 if test x${cpudir} = xmipsel; then
1388 if test x"$link_dir" = xyes ; then
1389 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1390 if test "$platform" != emu ; then
1391 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1394 mkdir -p include/grub 2>/dev/null
1395 rm -rf include/grub/cpu
1396 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1397 if test "$platform" != emu ; then
1398 rm -rf include/grub/machine
1399 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1403 AC_CONFIG_FILES([Makefile])
1404 AC_CONFIG_FILES([grub-core/Makefile])
1405 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1406 AC_CONFIG_FILES([po/Makefile.in])
1407 AC_CONFIG_FILES([docs/Makefile])
1408 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1409 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1410 AC_CONFIG_FILES([config.h])
1414 echo "*******************************************************"
1415 echo GRUB2 will be compiled with following components:
1416 echo Platform: "$target_cpu"-"$platform"
1417 if [ x"$platform" = xemu ]; then
1418 if [ x"$grub_emu_usb_excuse" = x ]; then
1419 echo USB support for grub-emu: Yes
1421 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1423 if [ x"$grub_emu_sdl_excuse" = x ]; then
1424 echo SDL support for grub-emu: Yes
1426 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1428 if [ x"$grub_emu_pci_excuse" = x ]; then
1429 echo PCI support for grub-emu: Yes
1431 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1434 if test x"$device_mapper_excuse" = x ; then
1435 echo With devmapper support: Yes
1437 echo With devmapper support: No "($device_mapper_excuse)"
1439 if [ x"$enable_mm_debug" = xyes ]; then
1440 echo With memory debugging: Yes
1442 echo With memory debugging: No
1444 if [ x"$enable_cache_stats" = xyes ]; then
1445 echo With disk cache statistics: Yes
1447 echo With disk cache statistics: No
1450 if [ x"$enable_boot_time" = xyes ]; then
1451 echo With boot time statistics: Yes
1453 echo With boot time statistics: No
1456 if [ x"$efiemu_excuse" = x ]; then
1457 echo efiemu runtime: Yes
1459 echo efiemu runtime: No "($efiemu_excuse)"
1461 if [ x"$grub_mkfont_excuse" = x ]; then
1462 echo grub-mkfont: Yes
1464 echo grub-mkfont: No "($grub_mkfont_excuse)"
1466 if [ x"$grub_mount_excuse" = x ]; then
1467 echo grub-mount: Yes
1469 echo grub-mount: No "($grub_mount_excuse)"
1471 if [ x"$starfield_excuse" = x ]; then
1472 echo starfield theme: Yes
1474 echo starfield theme: No "($starfield_excuse)"
1476 if [ x"$libzfs_excuse" = x ]; then
1477 echo With libzfs support: Yes
1479 echo With libzfs support: No "($libzfs_excuse)"
1481 if [ x"$grub_build_mkfont_excuse" = x ]; then
1482 echo Build-time grub-mkfont: Yes
1483 if test "x$FONT_SOURCE" = x ; then
1484 echo "Without unifont"
1486 echo "With unifont from $FONT_SOURCE"
1489 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
1490 echo "Without unifont (no build-time grub-mkfont)"
1492 if test "x$LIBLZMA" = x ; then
1493 echo "Without liblzma (no support for XZ-compressed mips images)"
1495 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
1497 echo "*******************************************************"