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.98],[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 mips-*) platform=yeeloong ;;
100 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
103 platform="$with_platform"
106 # Adjust CPU unless target was explicitly specified.
107 if test -z "$target_alias"; then
108 case "$target_cpu"-"$platform" in
111 x86_64-*) target_cpu=i386 ;;
112 powerpc64-ieee1275) target_cpu=powerpc ;;
116 # Check if the platform is supported, make final adjustments.
117 case "$target_cpu"-"$platform" in
123 i386-linuxbios) platform=coreboot ;;
131 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
134 case "$target_cpu" in
135 i386 | powerpc) target_m32=1 ;;
136 x86_64 | sparc64) target_m64=1 ;;
140 mingw32*) host_os=cygwin ;;
143 # This normalizes the names, and creates a new variable ("host_kernel")
144 # while at it, since the mapping is not always 1:1 (e.g. different OSes
145 # using the same kernel type).
147 gnu*) host_kernel=hurd ;;
148 linux*) host_kernel=linux ;;
149 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
150 netbsd*) host_kernel=netbsd ;;
151 cygwin) host_kernel=windows ;;
155 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
156 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
157 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
158 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
159 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
160 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
161 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
162 yeeloong) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
163 qemu-mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
165 case "$target_cpu" in
166 mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
167 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
169 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
171 HOST_CPPFLAGS="$HOST_CPPFLAGS $machine_CPPFLAGS"
172 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
176 AC_SUBST(host_kernel)
181 # Define default variables
184 # Because /boot is used for the boot block in NetBSD and OpenBSD,
186 *) bootdirname='boot' ;;
188 bootdirname=`echo "$bootdirname" | sed "$program_transform_name"`
189 AC_SUBST(bootdirname)
191 grubdirname=`echo "$PACKAGE" | sed "$program_transform_name"`
192 AC_SUBST(grubdirname)
195 # Checks for build programs.
198 # Although cmp is listed in the GNU Coding Standards as a command which
199 # can used directly, OpenBSD lacks cmp in the default installation.
200 AC_CHECK_PROGS([CMP], [cmp])
201 if test "x$CMP" = x; then
202 AC_MSG_ERROR([cmp is not found])
205 AC_CHECK_PROGS([YACC], [bison])
206 if test "x$YACC" = x; then
207 AC_MSG_ERROR([bison is not found])
212 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
213 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
214 if test -f "$dir/unifont.$ext"; then
215 FONT_SOURCE="$dir/unifont.$ext"
221 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xyeeloong ); then
222 AC_MSG_ERROR([qemu and yeeloong ports need unifont])
225 AC_SUBST([FONT_SOURCE])
235 if test "x$LEX" = "x:"; then
236 AC_MSG_ERROR([flex is not found])
238 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
239 if test -n "$version" -a "$version" -ge 20535; then
242 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
246 # These are not a "must".
247 AC_PATH_PROG(MAKEINFO, makeinfo)
250 # Checks for host programs.
259 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
262 AM_GNU_GETTEXT([external])
265 # Identify characteristics of the host architecture.
267 AC_CHECK_SIZEOF(void *)
268 AC_CHECK_SIZEOF(long)
271 if test x$grub_cv_apple_cc = xyes ; then
272 HOST_CPPFLAGS="$HOST_CPPFLAGS -DAPPLE_CC=1"
273 HOST_CFLAGS="$HOST_CFLAGS -fnested-functions"
276 if test "x$cross_compiling" = xyes; then
277 AC_MSG_WARN([cannot generate manual pages while cross compiling])
279 AC_PATH_PROG(HELP2MAN, help2man)
282 # Check for functions and headers.
283 AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
284 AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h)
286 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
287 #include <sys/param.h>
288 #include <sys/mount.h>])
290 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
291 #include <sys/param.h>
292 #include <sys/mount.h>])
294 # For opendisk() and getrawpartition() on NetBSD.
295 # Used in util/deviceiter.c and in util/hostdisk.c.
296 AC_CHECK_HEADER([util.h], [
297 AC_CHECK_LIB([util], [opendisk], [
299 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
301 AC_CHECK_LIB([util], [getrawpartition], [
303 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
309 # Check for host and build compilers.
312 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
313 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
319 # Check for target programs.
322 # Find tools for the target.
323 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
324 tmp_ac_tool_prefix="$ac_tool_prefix"
325 ac_tool_prefix=$target_alias-
327 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
328 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
329 AC_CHECK_TOOL(OBJCOPY, objcopy)
330 AC_CHECK_TOOL(STRIP, strip)
331 AC_CHECK_TOOL(NM, nm)
333 ac_tool_prefix="$tmp_ac_tool_prefix"
335 if test "x$TARGET_CC" = x; then
338 AC_CHECK_TOOL(OBJCOPY, objcopy)
339 AC_CHECK_TOOL(STRIP, strip)
340 AC_CHECK_TOOL(NM, nm)
346 # Test the C compiler for the target environment.
349 tmp_LDFLAGS="$LDFLAGS"
350 tmp_CPPFLAGS="$CPPFLAGS"
353 CFLAGS="$TARGET_CFLAGS"
354 CPPFLAGS="$TARGET_CPPFLAGS"
355 LDFLAGS="$TARGET_LDFLAGS"
359 TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g"
360 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
362 # Force no alignment to save space on i386.
363 if test "x$target_cpu" = xi386; then
364 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
365 CFLAGS="$CFLAGS -falign-loops=1"
366 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
367 [grub_cv_cc_falign_loop=yes],
368 [grub_cv_cc_falign_loop=no])
371 if test "x$grub_cv_cc_falign_loop" = xyes; then
372 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
374 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
377 # Some toolchains enable these features by default, but they need
378 # registers that aren't set up properly in GRUB.
379 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
382 # By default, GCC 4.4 generates .eh_frame sections containing unwind
383 # information in some cases where it previously did not. GRUB doesn't need
384 # these and they just use up vital space. Restore the old compiler
386 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
387 SAVE_CFLAGS="$CFLAGS"
388 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
389 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
390 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
391 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
392 CFLAGS="$SAVE_CFLAGS"
395 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
396 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
400 if test x$grub_cv_apple_target_cc = xyes ; then
401 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DAPPLE_CC=1"
402 TARGET_CFLAGS="$TARGET_CFLAGS -fnested-functions"
404 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
406 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
407 if test "x$OBJCONV" = x ; then
408 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
410 if test "x$OBJCONV" = x ; then
411 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
414 TARGET_IMG_CFLAGS="-static"
415 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
416 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
417 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
420 # Use linker script if present, otherwise use builtin -N script.
421 if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
422 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
423 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
424 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
425 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
428 TARGET_IMG_LDFLAGS='-Wl,-N'
429 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
430 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
435 # For platforms where ELF is not the default link format.
436 AC_MSG_CHECKING([for command to convert module to ELF format])
438 cygwin) TARGET_OBJ2ELF='$(grub_utildir)/grub-pe2elf';
439 # FIXME: put proper test here
440 NEED_REGISTER_FRAME_INFO=1
442 *) NEED_REGISTER_FRAME_INFO=0 ;;
444 AC_MSG_RESULT([$TARGET_OBJ2ELF])
446 if test "x$target_m32" = x1; then
448 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
449 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
450 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
451 TARGET_MODULE_FORMAT="elf32"
454 if test "x$target_m64" = x1; then
456 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
457 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
458 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
459 TARGET_MODULE_FORMAT="elf64"
462 if test "$target_cpu"-"$platform" = x86_64-efi; then
463 # Use large model to support 4G memory
464 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
466 CFLAGS="$CFLAGS -m64 -mcmodel=large"
467 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
468 [grub_cv_cc_mcmodel=yes],
469 [grub_cv_cc_mcmodel=no])
471 if test "x$grub_cv_cc_mcmodel" = xno; then
472 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
474 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
477 # EFI writes to stack below %rsp, we must not use the red zone
478 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
479 CFLAGS="$CFLAGS -m64 -mno-red-zone"
480 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
481 [grub_cv_cc_no_red_zone=yes],
482 [grub_cv_cc_no_red_zone=no])
484 if test "x$grub_cv_cc_no_red_zone" = xno; then
485 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
488 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
495 # Need __enable_execute_stack() for nested function trampolines?
496 grub_CHECK_ENABLE_EXECUTE_STACK
498 # Position independent executable.
500 [# Need that, because some distributions ship compilers that include
501 # `-fPIE' in the default specs.
502 if [ x"$pie_possible" = xyes ]; then
503 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
506 # Smashing stack protector.
507 grub_CHECK_STACK_PROTECTOR
508 # Need that, because some distributions ship compilers that include
509 # `-fstack-protector' in the default specs.
510 if test "x$ssp_possible" = xyes; then
511 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
513 grub_CHECK_STACK_ARG_PROBE
514 # Cygwin's GCC uses alloca() to probe the stackframe on static
515 # stack allocations above some threshold.
516 if test x"$sap_possible" = xyes; then
517 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
520 AC_ARG_ENABLE([werror],
521 [AS_HELP_STRING([--disable-werror],
522 [do not use -Werror when building GRUB])])
523 if test x"$enable_werror" != xno ; then
524 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
527 TARGET_CPP="$TARGET_CC -E"
528 TARGET_CCAS=$TARGET_CC
532 AC_SUBST(TARGET_CCAS)
533 AC_SUBST(TARGET_OBJ2ELF)
534 AC_SUBST(TARGET_APPLE_CC)
535 AC_SUBST(TARGET_MODULE_FORMAT)
537 AC_SUBST(TARGET_CFLAGS)
538 AC_SUBST(TARGET_LDFLAGS)
539 AC_SUBST(TARGET_CPPFLAGS)
540 AC_SUBST(TARGET_CCASFLAGS)
542 AC_SUBST(TARGET_IMG_LDSCRIPT)
543 AC_SUBST(TARGET_IMG_LDFLAGS)
544 AC_SUBST(TARGET_IMG_CFLAGS)
545 AC_SUBST(TARGET_IMG_BASE_LDOPT)
547 AC_SUBST(HOST_CFLAGS)
548 AC_SUBST(HOST_LDFLAGS)
549 AC_SUBST(HOST_CPPFLAGS)
550 AC_SUBST(HOST_CCASFLAGS)
552 # Set them to their new values for the tests below.
554 if test "x$TARGET_APPLE_CC" = x1 ; then
555 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
557 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
559 CPPFLAGS="$TARGET_CPPFLAGS"
560 LDFLAGS="$TARGET_LDFLAGS"
564 if test x$grub_cv_asm_uscore = xyes; then
565 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
567 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
570 # Check for libgcc symbols
571 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
573 if test "x$TARGET_APPLE_CC" = x1 ; then
574 CFLAGS="$TARGET_CFLAGS -nostdlib"
576 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
580 # Defined in aclocal.m4.
582 if test "x$TARGET_APPLE_CC" != x1 ; then
583 grub_PROG_OBJCOPY_ABSOLUTE
585 grub_PROG_LD_BUILD_ID_NONE
586 if test "x$target_cpu" = xi386; then
587 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
588 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
589 # Check symbols provided by linker script.
590 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
592 grub_CHECK_BSS_START_SYMBOL
593 grub_CHECK_END_SYMBOL
595 CFLAGS="$TARGET_CFLAGS"
596 grub_I386_ASM_PREFIX_REQUIREMENT
600 AC_ARG_ENABLE([efiemu],
601 [AS_HELP_STRING([--enable-efiemu],
602 [build and install the efiemu runtimes (default=guessed)])])
603 if test x"$enable_efiemu" = xno ; then
604 efiemu_excuse="explicitly disabled"
606 if test x"$target_cpu" != xi386 ; then
607 efiemu_excuse="only available on i386"
609 if test x"$platform" = xefi ; then
610 efiemu_excuse="not available on efi"
612 if test x"$efiemu_excuse" = x ; then
613 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
614 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
615 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
616 [grub_cv_cc_efiemu=yes],
617 [grub_cv_cc_efiemu=no])
619 if test x$grub_cv_cc_efiemu = xno; then
620 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
623 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
624 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
626 if test x"$efiemu_excuse" = x ; then
631 AC_SUBST([enable_efiemu])
633 if test "$platform" != emu; then
634 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
635 SAVED_CPPFLAGS="$CPPFLAGS"
636 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
637 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
638 int va_arg_func (int fixed, va_list args);]], [[]])],
639 [grub_cv_cc_isystem=yes],
640 [grub_cv_cc_isystem=no])
641 CPPFLAGS="$SAVED_CPPFLAGS"
644 if test x"$grub_cv_cc_isystem" = xyes ; then
645 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
652 CPPFLAGS="$tmp_CPPFLAGS"
653 LDFLAGS="$tmp_LDFLAGS"
660 # Memory manager debugging.
661 AC_ARG_ENABLE([mm-debug],
662 AS_HELP_STRING([--enable-mm-debug],
663 [include memory manager debugging]),
664 [AC_DEFINE([MM_DEBUG], [1],
665 [Define to 1 if you enable memory manager debugging.])])
667 AC_ARG_ENABLE([grub-emu-usb],
668 [AS_HELP_STRING([--enable-grub-emu-usb],
669 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
671 AC_ARG_ENABLE([grub-emu-sdl],
672 [AS_HELP_STRING([--enable-grub-emu-sdl],
673 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
675 AC_ARG_ENABLE([grub-emu-pci],
676 [AS_HELP_STRING([--enable-grub-emu-pci],
677 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
679 if test "$platform" = emu; then
681 [# Check for curses libraries.]
682 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
683 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
684 [missing_ncurses=[true]])])
685 AC_SUBST([LIBCURSES])
686 [if [ x"$missing_ncurses" = x ]; then ]
687 [# Check for headers.]
688 AC_CHECK_HEADERS([ncurses/curses.h], [],
689 [AC_CHECK_HEADERS([ncurses.h], [],
690 [AC_CHECK_HEADERS([curses.h], [],
691 [missing_ncurses=[true]])])])
693 if test x"$missing_ncurses" = xtrue ; then
694 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
697 if test x"$enable_grub_emu_usb" != xyes ; then
698 grub_emu_usb_excuse="not enabled"
701 if test x"$enable_grub_emu_pci" = xyes ; then
702 grub_emu_usb_excuse="conflicts with PCI support"
705 [if [ x"$grub_emu_usb_excuse" = x ]; then
706 # Check for libusb libraries.]
707 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
708 [grub_emu_usb_excuse=["need libusb library"]])
711 [if [ x"$grub_emu_usb_excuse" = x ]; then
712 # Check for headers.]
713 AC_CHECK_HEADERS([usb.h], [],
714 [grub_emu_usb_excuse=["need libusb headers"]])
716 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
717 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
719 if test x"$grub_emu_usb_excuse" = x ; then
720 enable_grub_emu_usb=yes
722 enable_grub_emu_usb=no
725 if test x"$enable_grub_emu_sdl" = xno ; then
726 grub_emu_sdl_excuse="explicitely disabled"
728 [if [ x"$grub_emu_sdl_excuse" = x ]; then
729 # Check for libSDL libraries.]
730 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
731 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
735 [if [ x"$grub_emu_sdl_excuse" = x ]; then
736 # Check for headers.]
737 AC_CHECK_HEADERS([SDL/SDL.h], [],
738 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
741 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
742 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
744 if test x"$grub_emu_sdl_excuse" = x ; then
745 enable_grub_emu_sdl=yes
747 enable_grub_emu_sdl=no
750 if test x"$enable_grub_emu_pci" != xyes ; then
751 grub_emu_pci_excuse="not enabled"
754 if test x"$enable_grub_emu_usb" = xyes ; then
755 grub_emu_pci_excuse="conflicts with USB support"
758 [if [ x"$grub_emu_pci_excuse" = x ]; then
759 # Check for libpci libraries.]
760 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
761 [grub_emu_pci_excuse=["need libpciaccess library"]])
762 AC_SUBST([LIBPCIACCESS])
764 [if [ x"$grub_emu_pci_excuse" = x ]; then
765 # Check for headers.]
766 AC_CHECK_HEADERS([pci/pci.h], [],
767 [grub_emu_pci_excuse=["need libpciaccess headers"]])
770 if test x"$grub_emu_pci_excuse" = x ; then
771 enable_grub_emu_pci=yes
774 enable_grub_emu_pci=no
777 AC_SUBST([enable_grub_emu_sdl])
778 AC_SUBST([enable_grub_emu_usb])
779 AC_SUBST([enable_grub_emu_pci])
782 AC_ARG_ENABLE([grub-mkfont],
783 [AS_HELP_STRING([--enable-grub-mkfont],
784 [build and install the `grub-mkfont' utility (default=guessed)])])
785 if test x"$enable_grub_mkfont" = xno ; then
786 grub_mkfont_excuse="explicitly disabled"
789 if test x"$grub_mkfont_excuse" = x ; then
790 # Check for freetype libraries.
791 AC_CHECK_PROGS([FREETYPE], [freetype-config])
792 if test "x$FREETYPE" = x ; then
793 grub_mkfont_excuse=["need freetype2 library"]
797 if test x"$grub_mkfont_excuse" = x ; then
798 # Check for freetype libraries.
799 freetype_cflags=`freetype-config --cflags`
800 freetype_libs=`freetype-config --libs`
801 SAVED_CPPFLAGS="$CPPFLAGS"
802 CPPFLAGS="$CPPFLAGS $freetype_cflags"
803 AC_CHECK_HEADERS([ft2build.h], [],
804 [grub_mkfont_excuse=["need freetype2 headers"]])
805 CPPFLAGS="$SAVED_CPPFLAGS"
808 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
809 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
811 if test x"$grub_mkfont_excuse" = x ; then
812 enable_grub_mkfont=yes
814 enable_grub_mkfont=no
816 AC_SUBST([enable_grub_mkfont])
817 AC_SUBST([freetype_cflags])
818 AC_SUBST([freetype_libs])
820 AC_ARG_ENABLE([device-mapper],
821 [AS_HELP_STRING([--enable-device-mapper],
822 [enable Linux device-mapper support (default=guessed)])])
823 if test x"$enable_device_mapper" = xno ; then
824 device_mapper_excuse="explicitly disabled"
827 if test x"$device_mapper_excuse" = x ; then
828 # Check for device-mapper library.
829 AC_CHECK_LIB([devmapper], [dm_task_create], [],
830 [device_mapper_excuse="need devmapper library"])
833 if test x"$device_mapper_excuse" = x ; then
834 # Check for device-mapper library.
835 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
837 [device_mapper_excuse="need devmapper library"])
840 if test x"$device_mapper_excuse" = x ; then
841 LIBDEVMAPPER="-ldevmapper";
842 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
843 [Define to 1 if you have the devmapper library.])
846 AC_SUBST([LIBDEVMAPPER])
848 AC_CHECK_LIB([zfs], [libzfs_init],
850 AC_DEFINE([HAVE_LIBZFS], [1],
851 [Define to 1 if you have the ZFS library.])],)
854 AC_CHECK_LIB([nvpair], [nvlist_print],
855 [LIBNVPAIR="-lnvpair"
856 AC_DEFINE([HAVE_LIBNVPAIR], [1],
857 [Define to 1 if you have the NVPAIR library.])],)
858 AC_SUBST([LIBNVPAIR])
862 pkglibrootdir='$(libdir)'/`echo $PACKAGE | sed "$program_transform_name"`
863 AC_SUBST(pkglibrootdir)
865 AC_SUBST([FONT_SOURCE])
866 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
867 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
868 AS_IF([test x$TARGET_APPLE_CC = x1],
869 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
871 AC_SUBST(HAVE_ASM_USCORE)
874 AC_SUBST(BSS_START_SYMBOL)
878 AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
879 AC_SUBST(NEED_REGISTER_FRAME_INFO)
882 # Automake conditionals
885 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
886 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
887 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
888 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
889 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
890 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
891 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
892 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
893 AM_CONDITIONAL([COND_mips_yeeloong], [test x$target_cpu = xmips -a x$platform = xyeeloong])
894 AM_CONDITIONAL([COND_mips_qemu_mips], [test x$target_cpu = xmips -a x$platform = xqemu_mips])
895 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
896 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
897 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips])
899 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
900 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
901 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
902 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
903 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
905 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
906 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
907 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
908 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
909 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
910 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
911 AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
912 AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
913 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
915 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
919 if test x"$link_dir" = xyes ; then
920 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu])
921 if test "$platform" != emu ; then
922 AC_CONFIG_LINKS([include/grub/machine:include/grub/$target_cpu/$platform])
925 mkdir -p include/grub 2>/dev/null
926 rm -rf include/grub/cpu
927 cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null
928 if test "$platform" != emu ; then
929 rm -rf include/grub/machine
930 cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
934 AC_CONFIG_FILES([Makefile])
935 AC_CONFIG_FILES([grub-core/Makefile])
936 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
937 AC_CONFIG_FILES([po/Makefile.in])
938 AC_CONFIG_FILES([docs/Makefile])
939 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
940 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
941 AC_CONFIG_FILES([config.h])
945 echo "*******************************************************"
946 echo GRUB2 will be compiled with following components:
947 echo Platform: "$target_cpu"-"$platform"
948 if [ x"$platform" = xemu ]; then
949 if [ x"$grub_emu_usb_excuse" = x ]; then
950 echo USB support for grub-emu: Yes
952 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
954 if [ x"$grub_emu_sdl_excuse" = x ]; then
955 echo SDL support for grub-emu: Yes
957 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
959 if [ x"$grub_emu_pci_excuse" = x ]; then
960 echo PCI support for grub-emu: Yes
962 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
965 if test x"$device_mapper_excuse" = x ; then
966 echo With devmapper support: Yes
968 echo With devmapper support: No "($device_mapper_excuse)"
970 if [ x"$enable_mm_debug" = xyes ]; then
971 echo With memory debugging: Yes
973 echo With memory debugging: No
975 if [ x"$efiemu_excuse" = x ]; then
976 echo efiemu runtime: Yes
978 echo efiemu runtime: No "($efiemu_excuse)"
980 if [ x"$grub_mkfont_excuse" = x ]; then
981 echo grub-mkfont: Yes
983 echo grub-mkfont: No "($grub_mkfont_excuse)"
985 echo "*******************************************************"