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],[1.99],[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.
48 AC_CONFIG_SRCDIR([include/grub/dl.h])
49 AC_CONFIG_HEADER([config-util.h])
51 # Program name transformations
54 # Optimization flag. Allow user to override.
55 if test "x$TARGET_CFLAGS" = x; then
56 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
59 # Default HOST_CPPFLAGS
60 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
61 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
62 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
63 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
64 HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
66 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
67 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
68 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
71 i[[3456]]86) target_cpu=i386 ;;
72 amd64) target_cpu=x86_64 ;;
73 sparc) target_cpu=sparc64 ;;
76 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
80 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
84 # Specify the platform (such as firmware).
85 AC_ARG_WITH([platform],
86 AS_HELP_STRING([--with-platform=PLATFORM],
87 [select the host platform [[guessed]]]))
89 # Guess the platform if not specified.
90 if test "x$with_platform" = x; then
91 case "$target_cpu"-"$target_vendor" in
92 i386-apple) platform=efi ;;
93 i386-*) platform=pc ;;
94 x86_64-apple) platform=efi ;;
95 x86_64-*) platform=pc ;;
96 powerpc-*) platform=ieee1275 ;;
97 powerpc64-*) platform=ieee1275 ;;
98 sparc64-*) platform=ieee1275 ;;
99 mipsel-*) platform=loongson ;;
100 mips-*) platform=arc ;;
101 ia64-*) platform=efi ;;
102 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
105 platform="$with_platform"
108 case "$target_cpu"-"$platform" in
111 x86_64-*) target_cpu=i386 ;;
112 powerpc64-ieee1275) target_cpu=powerpc ;;
115 # Check if the platform is supported, make final adjustments.
116 case "$target_cpu"-"$platform" in
122 i386-linuxbios) platform=coreboot ;;
129 mips-qemu-mips) platform=qemu_mips;;
132 mipsel-qemu-mips) platform=qemu_mips;;
133 mipsel-yeeloong) platform=loongson ;;
134 mipsel-fuloong) platform=loongson ;;
137 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
140 case "$target_cpu" in
141 i386 | powerpc) target_m32=1 ;;
142 x86_64 | sparc64) target_m64=1 ;;
146 mingw32*) host_os=cygwin ;;
149 # This normalizes the names, and creates a new variable ("host_kernel")
150 # while at it, since the mapping is not always 1:1 (e.g. different OSes
151 # using the same kernel type).
153 gnu*) host_kernel=hurd ;;
154 linux*) host_kernel=linux ;;
155 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
156 netbsd*) host_kernel=netbsd ;;
157 solaris*) host_kernel=illumos ;;
158 cygwin) host_kernel=windows ;;
162 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
163 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
164 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
165 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
166 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
167 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
168 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
169 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
170 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
171 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
173 case "$target_cpu" in
174 mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
175 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
177 if test x${target_cpu} = xmipsel ; then
178 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
180 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"
183 HOST_CPPFLAGS="$HOST_CPPFLAGS $machine_CPPFLAGS"
184 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
188 AC_SUBST(host_kernel)
193 # Define default variables
196 # Because /boot is used for the boot block in NetBSD and OpenBSD,
198 *) bootdirname='boot' ;;
200 bootdirname=`echo "$bootdirname" | sed "$program_transform_name"`
201 AC_SUBST(bootdirname)
202 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
203 [Default boot directory name]")
205 grubdirname=`echo "$PACKAGE" | sed "$program_transform_name"`
206 AC_SUBST(grubdirname)
207 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
208 [Default grub directory name])
211 # Checks for build programs.
214 # Although cmp is listed in the GNU Coding Standards as a command which
215 # can used directly, OpenBSD lacks cmp in the default installation.
216 AC_CHECK_PROGS([CMP], [cmp])
217 if test "x$CMP" = x; then
218 AC_MSG_ERROR([cmp is not found])
221 AC_CHECK_PROGS([YACC], [bison])
222 if test "x$YACC" = x; then
223 AC_MSG_ERROR([bison is not found])
228 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
229 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
230 if test -f "$dir/unifont.$ext"; then
231 FONT_SOURCE="$dir/unifont.$ext"
237 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips); then
238 AC_MSG_ERROR([qemu and loongson ports need unifont])
241 AC_SUBST([FONT_SOURCE])
252 if test "x$LEX" = "x:"; then
253 AC_MSG_ERROR([flex is not found])
255 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
256 if test -n "$version" -a "$version" -ge 20535; then
259 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
263 # These are not a "must".
264 AC_PATH_PROGS(MAKEINFO, makeinfo true)
267 # Checks for host programs.
276 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
279 AM_GNU_GETTEXT([external])
282 # Identify characteristics of the host architecture.
284 AC_CHECK_SIZEOF(void *)
285 AC_CHECK_SIZEOF(long)
288 if test x$grub_cv_apple_cc = xyes ; then
289 HOST_CPPFLAGS="$HOST_CPPFLAGS -DAPPLE_CC=1"
290 HOST_CFLAGS="$HOST_CFLAGS -fnested-functions"
293 if test "x$cross_compiling" = xyes; then
294 AC_MSG_WARN([cannot generate manual pages while cross compiling])
296 AC_PATH_PROG(HELP2MAN, help2man)
299 # Check for functions and headers.
300 AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
301 AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h)
303 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
304 #include <sys/param.h>
305 #include <sys/mount.h>])
307 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
308 #include <sys/param.h>
309 #include <sys/mount.h>])
311 # For opendisk() and getrawpartition() on NetBSD.
312 # Used in util/deviceiter.c and in util/hostdisk.c.
313 AC_CHECK_HEADER([util.h], [
314 AC_CHECK_LIB([util], [opendisk], [
316 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
318 AC_CHECK_LIB([util], [getrawpartition], [
320 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
326 # Check for host and build compilers.
329 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
330 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
336 # Check for target programs.
339 # Find tools for the target.
340 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
341 tmp_ac_tool_prefix="$ac_tool_prefix"
342 ac_tool_prefix=$target_alias-
344 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
345 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
346 AC_CHECK_TOOL(OBJCOPY, objcopy)
347 AC_CHECK_TOOL(STRIP, strip)
348 AC_CHECK_TOOL(NM, nm)
350 ac_tool_prefix="$tmp_ac_tool_prefix"
352 if test "x$TARGET_CC" = x; then
355 AC_CHECK_TOOL(OBJCOPY, objcopy)
356 AC_CHECK_TOOL(STRIP, strip)
357 AC_CHECK_TOOL(NM, nm)
363 # Test the C compiler for the target environment.
366 tmp_LDFLAGS="$LDFLAGS"
367 tmp_CPPFLAGS="$CPPFLAGS"
370 CFLAGS="$TARGET_CFLAGS"
371 CPPFLAGS="$TARGET_CPPFLAGS"
372 LDFLAGS="$TARGET_LDFLAGS"
376 TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g"
377 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
379 # Force no alignment to save space on i386.
380 if test "x$target_cpu" = xi386; then
381 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
382 CFLAGS="$CFLAGS -falign-loops=1"
383 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
384 [grub_cv_cc_falign_loop=yes],
385 [grub_cv_cc_falign_loop=no])
388 if test "x$grub_cv_cc_falign_loop" = xyes; then
389 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
391 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
394 # Some toolchains enable these features by default, but they need
395 # registers that aren't set up properly in GRUB.
396 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
399 # By default, GCC 4.4 generates .eh_frame sections containing unwind
400 # information in some cases where it previously did not. GRUB doesn't need
401 # these and they just use up vital space. Restore the old compiler
403 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
404 SAVE_CFLAGS="$CFLAGS"
405 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
406 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
407 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
408 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
409 CFLAGS="$SAVE_CFLAGS"
412 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
413 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
416 # By default, GCC 4.6 generates .eh_frame sections containing unwind
417 # information in some cases where it previously did not. GRUB doesn't need
418 # these and they just use up vital space. Restore the old compiler
420 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
421 SAVE_CFLAGS="$CFLAGS"
422 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
423 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
424 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
425 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
426 CFLAGS="$SAVE_CFLAGS"
429 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
430 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
434 if test x$grub_cv_apple_target_cc = xyes ; then
435 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DAPPLE_CC=1"
436 TARGET_CFLAGS="$TARGET_CFLAGS -fnested-functions"
438 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
440 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
441 if test "x$OBJCONV" = x ; then
442 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
444 if test "x$OBJCONV" = x ; then
445 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
448 TARGET_IMG_CFLAGS="-static"
449 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
450 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
451 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
454 # Use linker script if present, otherwise use builtin -N script.
455 if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
456 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
457 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
458 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
459 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
462 TARGET_IMG_LDFLAGS='-Wl,-N'
463 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
464 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
469 # For platforms where ELF is not the default link format.
470 AC_MSG_CHECKING([for command to convert module to ELF format])
472 cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf';
473 # FIXME: put proper test here
474 NEED_REGISTER_FRAME_INFO=1
476 *) NEED_REGISTER_FRAME_INFO=0 ;;
478 AC_MSG_RESULT([$TARGET_OBJ2ELF])
481 AC_ARG_ENABLE([efiemu],
482 [AS_HELP_STRING([--enable-efiemu],
483 [build and install the efiemu runtimes (default=guessed)])])
484 if test x"$enable_efiemu" = xno ; then
485 efiemu_excuse="explicitly disabled"
487 if test x"$target_cpu" != xi386 ; then
488 efiemu_excuse="only available on i386"
490 if test x"$platform" = xefi ; then
491 efiemu_excuse="not available on efi"
493 if test x"$efiemu_excuse" = x ; then
494 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
495 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
496 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
497 [grub_cv_cc_efiemu=yes],
498 [grub_cv_cc_efiemu=no])
500 if test x$grub_cv_cc_efiemu = xno; then
501 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
504 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
505 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
507 if test x"$efiemu_excuse" = x ; then
512 AC_SUBST([enable_efiemu])
514 if test "x$target_m32" = x1; then
516 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
517 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
518 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
519 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
520 TARGET_MODULE_FORMAT="elf32"
523 if test "x$target_m64" = x1; then
525 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
526 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
527 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
528 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
529 TARGET_MODULE_FORMAT="elf64"
532 if test "$target_cpu"-"$platform" = x86_64-efi; then
533 # Use large model to support 4G memory
534 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
536 CFLAGS="$CFLAGS -m64 -mcmodel=large"
537 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
538 [grub_cv_cc_mcmodel=yes],
539 [grub_cv_cc_mcmodel=no])
541 if test "x$grub_cv_cc_mcmodel" = xno; then
542 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
544 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
547 # EFI writes to stack below %rsp, we must not use the red zone
548 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
549 CFLAGS="$CFLAGS -m64 -mno-red-zone"
550 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
551 [grub_cv_cc_no_red_zone=yes],
552 [grub_cv_cc_no_red_zone=no])
554 if test "x$grub_cv_cc_no_red_zone" = xno; then
555 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
558 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
565 # Need __enable_execute_stack() for nested function trampolines?
566 grub_CHECK_ENABLE_EXECUTE_STACK
568 # Position independent executable.
570 [# Need that, because some distributions ship compilers that include
571 # `-fPIE' in the default specs.
572 if [ x"$pie_possible" = xyes ]; then
573 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
576 # Smashing stack protector.
577 grub_CHECK_STACK_PROTECTOR
578 # Need that, because some distributions ship compilers that include
579 # `-fstack-protector' in the default specs.
580 if test "x$ssp_possible" = xyes; then
581 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
583 grub_CHECK_STACK_ARG_PROBE
584 # Cygwin's GCC uses alloca() to probe the stackframe on static
585 # stack allocations above some threshold.
586 if test x"$sap_possible" = xyes; then
587 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
590 AC_ARG_ENABLE([werror],
591 [AS_HELP_STRING([--disable-werror],
592 [do not use -Werror when building GRUB])])
593 if test x"$enable_werror" != xno ; then
594 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
597 TARGET_CPP="$TARGET_CC -E"
598 TARGET_CCAS=$TARGET_CC
602 AC_SUBST(TARGET_CCAS)
603 AC_SUBST(TARGET_OBJ2ELF)
604 AC_SUBST(TARGET_APPLE_CC)
605 AC_SUBST(TARGET_MODULE_FORMAT)
607 AC_SUBST(TARGET_CFLAGS)
608 AC_SUBST(TARGET_LDFLAGS)
609 AC_SUBST(TARGET_CPPFLAGS)
610 AC_SUBST(TARGET_CCASFLAGS)
612 AC_SUBST(TARGET_IMG_LDSCRIPT)
613 AC_SUBST(TARGET_IMG_LDFLAGS)
614 AC_SUBST(TARGET_IMG_CFLAGS)
615 AC_SUBST(TARGET_IMG_BASE_LDOPT)
617 AC_SUBST(HOST_CFLAGS)
618 AC_SUBST(HOST_LDFLAGS)
619 AC_SUBST(HOST_CPPFLAGS)
620 AC_SUBST(HOST_CCASFLAGS)
622 # Set them to their new values for the tests below.
624 if test "x$TARGET_APPLE_CC" = x1 ; then
625 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
627 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
629 CPPFLAGS="$TARGET_CPPFLAGS"
630 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
637 if test x$grub_cv_asm_uscore = xyes; then
638 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
640 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
643 # Check for libgcc symbols
644 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x __ia64_trampoline __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
646 if test "x$TARGET_APPLE_CC" = x1 ; then
647 CFLAGS="$TARGET_CFLAGS -nostdlib"
649 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
653 # Defined in aclocal.m4.
655 if test "x$TARGET_APPLE_CC" != x1 ; then
656 grub_PROG_OBJCOPY_ABSOLUTE
658 grub_PROG_LD_BUILD_ID_NONE
659 if test "x$target_cpu" = xi386; then
660 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
661 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
662 # Check symbols provided by linker script.
663 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
665 grub_CHECK_BSS_START_SYMBOL
666 grub_CHECK_END_SYMBOL
668 CFLAGS="$TARGET_CFLAGS"
669 grub_I386_ASM_PREFIX_REQUIREMENT
673 if test "$platform" != emu; then
674 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
675 SAVED_CPPFLAGS="$CPPFLAGS"
676 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
677 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
678 int va_arg_func (int fixed, va_list args);]], [[]])],
679 [grub_cv_cc_isystem=yes],
680 [grub_cv_cc_isystem=no])
681 CPPFLAGS="$SAVED_CPPFLAGS"
684 if test x"$grub_cv_cc_isystem" = xyes ; then
685 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
689 AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_cc_wnotrampolines], [
690 SAVED_CFLAGS="$CFLAGS"
691 # Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
692 # in the event of later failures (since -Wno-* is always accepted, but
693 # produces a diagnostic if something else is wrong).
694 CFLAGS="$TARGET_CFLAGS -Wtrampolines"
695 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
696 int va_arg_func (int fixed, va_list args);]], [[]])],
697 [grub_cv_cc_wnotrampolines=yes],
698 [grub_cv_cc_wnotrampolines=no])
699 CFLAGS="$SAVED_CFLAGS"
702 if test x"$grub_cv_cc_wnotrampolines" = xyes ; then
703 TARGET_CFLAGS="$TARGET_CFLAGS -Wno-trampolines"
709 CPPFLAGS="$tmp_CPPFLAGS"
710 LDFLAGS="$tmp_LDFLAGS"
717 # Memory manager debugging.
718 AC_ARG_ENABLE([mm-debug],
719 AS_HELP_STRING([--enable-mm-debug],
720 [include memory manager debugging]),
721 [AC_DEFINE([MM_DEBUG], [1],
722 [Define to 1 if you enable memory manager debugging.])])
724 AC_ARG_ENABLE([cache-stats],
725 AS_HELP_STRING([--enable-cache-stats],
726 [enable disk cache statistics collection]))
728 if test x$enable_cache_stats = xyes; then
733 AC_SUBST([DISK_CACHE_STATS])
735 AC_ARG_ENABLE([grub-emu-usb],
736 [AS_HELP_STRING([--enable-grub-emu-usb],
737 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
739 AC_ARG_ENABLE([grub-emu-sdl],
740 [AS_HELP_STRING([--enable-grub-emu-sdl],
741 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
743 AC_ARG_ENABLE([grub-emu-pci],
744 [AS_HELP_STRING([--enable-grub-emu-pci],
745 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
747 if test "$platform" = emu; then
749 [# Check for curses libraries.]
750 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
751 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
752 [missing_ncurses=[true]])])
753 AC_SUBST([LIBCURSES])
754 [if [ x"$missing_ncurses" = x ]; then ]
755 [# Check for headers.]
756 AC_CHECK_HEADERS([ncurses/curses.h], [],
757 [AC_CHECK_HEADERS([ncurses.h], [],
758 [AC_CHECK_HEADERS([curses.h], [],
759 [missing_ncurses=[true]])])])
761 if test x"$missing_ncurses" = xtrue ; then
762 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
765 if test x"$enable_grub_emu_usb" != xyes ; then
766 grub_emu_usb_excuse="not enabled"
769 if test x"$enable_grub_emu_pci" = xyes ; then
770 grub_emu_usb_excuse="conflicts with PCI support"
773 [if [ x"$grub_emu_usb_excuse" = x ]; then
774 # Check for libusb libraries.]
775 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
776 [grub_emu_usb_excuse=["need libusb library"]])
779 [if [ x"$grub_emu_usb_excuse" = x ]; then
780 # Check for headers.]
781 AC_CHECK_HEADERS([usb.h], [],
782 [grub_emu_usb_excuse=["need libusb headers"]])
784 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
785 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
787 if test x"$grub_emu_usb_excuse" = x ; then
788 enable_grub_emu_usb=yes
790 enable_grub_emu_usb=no
793 if test x"$enable_grub_emu_sdl" = xno ; then
794 grub_emu_sdl_excuse="explicitely disabled"
796 [if [ x"$grub_emu_sdl_excuse" = x ]; then
797 # Check for libSDL libraries.]
798 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
799 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
803 [if [ x"$grub_emu_sdl_excuse" = x ]; then
804 # Check for headers.]
805 AC_CHECK_HEADERS([SDL/SDL.h], [],
806 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
809 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
810 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
812 if test x"$grub_emu_sdl_excuse" = x ; then
813 enable_grub_emu_sdl=yes
815 enable_grub_emu_sdl=no
818 if test x"$enable_grub_emu_pci" != xyes ; then
819 grub_emu_pci_excuse="not enabled"
822 if test x"$enable_grub_emu_usb" = xyes ; then
823 grub_emu_pci_excuse="conflicts with USB support"
826 [if [ x"$grub_emu_pci_excuse" = x ]; then
827 # Check for libpci libraries.]
828 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
829 [grub_emu_pci_excuse=["need libpciaccess library"]])
830 AC_SUBST([LIBPCIACCESS])
832 [if [ x"$grub_emu_pci_excuse" = x ]; then
833 # Check for headers.]
834 AC_CHECK_HEADERS([pci/pci.h], [],
835 [grub_emu_pci_excuse=["need libpciaccess headers"]])
838 if test x"$grub_emu_pci_excuse" = x ; then
839 enable_grub_emu_pci=yes
842 enable_grub_emu_pci=no
845 AC_SUBST([enable_grub_emu_sdl])
846 AC_SUBST([enable_grub_emu_usb])
847 AC_SUBST([enable_grub_emu_pci])
850 AC_ARG_ENABLE([grub-mkfont],
851 [AS_HELP_STRING([--enable-grub-mkfont],
852 [build and install the `grub-mkfont' utility (default=guessed)])])
853 if test x"$enable_grub_mkfont" = xno ; then
854 grub_mkfont_excuse="explicitly disabled"
857 if test x"$grub_mkfont_excuse" = x ; then
858 # Check for freetype libraries.
859 AC_CHECK_PROGS([FREETYPE], [freetype-config])
860 if test "x$FREETYPE" = x ; then
861 grub_mkfont_excuse=["need freetype2 library"]
865 if test x"$grub_mkfont_excuse" = x ; then
866 # Check for freetype libraries.
867 freetype_cflags=`freetype-config --cflags`
868 freetype_libs=`freetype-config --libs`
869 SAVED_CPPFLAGS="$CPPFLAGS"
870 CPPFLAGS="$CPPFLAGS $freetype_cflags"
871 AC_CHECK_HEADERS([ft2build.h], [],
872 [grub_mkfont_excuse=["need freetype2 headers"]])
873 CPPFLAGS="$SAVED_CPPFLAGS"
876 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
877 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
879 if test x"$grub_mkfont_excuse" = x ; then
880 enable_grub_mkfont=yes
882 enable_grub_mkfont=no
884 if test x"$enable_grub_mkfont" = xno && test "x$platform" = xloongson; then
885 AC_MSG_ERROR([loongson port needs grub-mkfont])
887 AC_SUBST([enable_grub_mkfont])
888 AC_SUBST([freetype_cflags])
889 AC_SUBST([freetype_libs])
891 AC_ARG_ENABLE([grub-mount],
892 [AS_HELP_STRING([--enable-grub-mount],
893 [build and install the `grub-mount' utility (default=guessed)])])
894 if test x"$enable_grub_mount" = xno ; then
895 grub_mount_excuse="explicitly disabled"
898 if test x"$grub_mount_excuse" = x ; then
899 AC_CHECK_LIB([fuse], [fuse_main_real], [],
900 [grub_mount_excuse="need FUSE library"])
903 if test x"$grub_mount_excuse" = x ; then
904 # Check for fuse headers.
905 SAVED_CPPFLAGS="$CPPFLAGS"
906 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
907 AC_CHECK_HEADERS([fuse/fuse.h], [],
908 [grub_mount_excuse=["need FUSE headers"]])
909 CPPFLAGS="$SAVED_CPPFLAGS"
912 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
913 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
915 if test x"$grub_mount_excuse" = x ; then
916 enable_grub_mount=yes
920 AC_SUBST([enable_grub_mount])
922 AC_ARG_ENABLE([device-mapper],
923 [AS_HELP_STRING([--enable-device-mapper],
924 [enable Linux device-mapper support (default=guessed)])])
925 if test x"$enable_device_mapper" = xno ; then
926 device_mapper_excuse="explicitly disabled"
929 if test x"$device_mapper_excuse" = x ; then
930 # Check for device-mapper header.
931 AC_CHECK_HEADER([libdevmapper.h], [],
932 [device_mapper_excuse="need libdevmapper header"])
935 if test x"$device_mapper_excuse" = x ; then
936 # Check for device-mapper library.
937 AC_CHECK_LIB([devmapper], [dm_task_create], [],
938 [device_mapper_excuse="need devmapper library"])
941 if test x"$device_mapper_excuse" = x ; then
942 # Check for device-mapper library.
943 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
945 [device_mapper_excuse="need devmapper library"])
948 if test x"$device_mapper_excuse" = x ; then
949 LIBDEVMAPPER="-ldevmapper";
950 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
951 [Define to 1 if you have the devmapper library.])
954 AC_SUBST([LIBDEVMAPPER])
957 if test x$host_kernel = xkfreebsd; then
958 AC_CHECK_LIB([geom], [geom_gettree], [],
959 [AC_MSG_ERROR([Your platform requires libgeom])])
965 AC_CHECK_LIB([lzma], [lzma_code],
967 AC_DEFINE([HAVE_LIBLZMA], [1],
968 [Define to 1 if you have the LZMA library.])],)
971 AC_CHECK_LIB([zfs], [libzfs_init],
973 AC_DEFINE([HAVE_LIBZFS], [1],
974 [Define to 1 if you have the ZFS library.])],)
977 AC_CHECK_LIB([nvpair], [nvlist_print],
978 [LIBNVPAIR="-lnvpair"
979 AC_DEFINE([HAVE_LIBNVPAIR], [1],
980 [Define to 1 if you have the NVPAIR library.])],)
981 AC_SUBST([LIBNVPAIR])
985 pkglibrootdir='$(libdir)'/`echo $PACKAGE | sed "$program_transform_name"`
986 AC_SUBST(pkglibrootdir)
988 AC_SUBST([FONT_SOURCE])
989 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
990 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
991 AS_IF([test x$TARGET_APPLE_CC = x1],
992 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
994 AC_SUBST(HAVE_ASM_USCORE)
997 AC_SUBST(BSS_START_SYMBOL)
1001 AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
1002 AC_SUBST(NEED_REGISTER_FRAME_INFO)
1005 # Automake conditionals
1008 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1009 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1010 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1011 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1012 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1013 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1014 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1015 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1016 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1017 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1018 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1019 AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
1020 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1021 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1022 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1024 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1025 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1026 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1027 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1028 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1029 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1031 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1032 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1033 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1034 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1035 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1036 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1037 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1038 AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
1039 AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
1040 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1041 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1043 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1044 AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin])
1047 cpudir="${target_cpu}"
1048 if test x${cpudir} = xmipsel; then
1052 if test x"$link_dir" = xyes ; then
1053 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1054 if test "$platform" != emu ; then
1055 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1058 mkdir -p include/grub 2>/dev/null
1059 rm -rf include/grub/cpu
1060 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1061 if test "$platform" != emu ; then
1062 rm -rf include/grub/machine
1063 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1067 AC_CONFIG_FILES([Makefile])
1068 AC_CONFIG_FILES([grub-core/Makefile])
1069 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1070 AC_CONFIG_FILES([po/Makefile.in])
1071 AC_CONFIG_FILES([docs/Makefile])
1072 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1073 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1074 AC_CONFIG_FILES([config.h])
1078 echo "*******************************************************"
1079 echo GRUB2 will be compiled with following components:
1080 echo Platform: "$target_cpu"-"$platform"
1081 if [ x"$platform" = xemu ]; then
1082 if [ x"$grub_emu_usb_excuse" = x ]; then
1083 echo USB support for grub-emu: Yes
1085 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1087 if [ x"$grub_emu_sdl_excuse" = x ]; then
1088 echo SDL support for grub-emu: Yes
1090 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1092 if [ x"$grub_emu_pci_excuse" = x ]; then
1093 echo PCI support for grub-emu: Yes
1095 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1098 if test x"$device_mapper_excuse" = x ; then
1099 echo With devmapper support: Yes
1101 echo With devmapper support: No "($device_mapper_excuse)"
1103 if [ x"$enable_mm_debug" = xyes ]; then
1104 echo With memory debugging: Yes
1106 echo With memory debugging: No
1108 if [ x"$enable_cache_stats" = xyes ]; then
1109 echo With disk cache statistics: Yes
1111 echo With disk cache statistics: No
1113 if [ x"$efiemu_excuse" = x ]; then
1114 echo efiemu runtime: Yes
1116 echo efiemu runtime: No "($efiemu_excuse)"
1118 if [ x"$grub_mkfont_excuse" = x ]; then
1119 echo grub-mkfont: Yes
1121 echo grub-mkfont: No "($grub_mkfont_excuse)"
1123 if [ x"$grub_mount_excuse" = x ]; then
1124 echo grub-mount: Yes
1126 echo grub-mount: No "($grub_mount_excuse)"
1128 echo "*******************************************************"