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 cygwin) host_kernel=windows ;;
161 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
162 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
163 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
164 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
165 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
166 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
167 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
168 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
169 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
170 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
172 case "$target_cpu" in
173 mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
174 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
176 if test x${target_cpu} = xmipsel ; then
177 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
179 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
182 HOST_CPPFLAGS="$HOST_CPPFLAGS $machine_CPPFLAGS"
183 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
187 AC_SUBST(host_kernel)
192 # Define default variables
195 # Because /boot is used for the boot block in NetBSD and OpenBSD,
197 *) bootdirname='boot' ;;
199 bootdirname=`echo "$bootdirname" | sed "$program_transform_name"`
200 AC_SUBST(bootdirname)
201 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
202 [Default boot directory name]")
204 grubdirname=`echo "$PACKAGE" | sed "$program_transform_name"`
205 AC_SUBST(grubdirname)
206 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
207 [Default grub directory name])
210 # Checks for build programs.
213 # Although cmp is listed in the GNU Coding Standards as a command which
214 # can used directly, OpenBSD lacks cmp in the default installation.
215 AC_CHECK_PROGS([CMP], [cmp])
216 if test "x$CMP" = x; then
217 AC_MSG_ERROR([cmp is not found])
220 AC_CHECK_PROGS([YACC], [bison])
221 if test "x$YACC" = x; then
222 AC_MSG_ERROR([bison is not found])
227 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
228 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
229 if test -f "$dir/unifont.$ext"; then
230 FONT_SOURCE="$dir/unifont.$ext"
236 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson ); then
237 AC_MSG_ERROR([qemu and loongson ports need unifont])
240 AC_SUBST([FONT_SOURCE])
251 if test "x$LEX" = "x:"; then
252 AC_MSG_ERROR([flex is not found])
254 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
255 if test -n "$version" -a "$version" -ge 20535; then
258 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
262 # These are not a "must".
263 AC_PATH_PROGS(MAKEINFO, makeinfo true)
266 # Checks for host programs.
275 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
278 AM_GNU_GETTEXT([external])
281 # Identify characteristics of the host architecture.
283 AC_CHECK_SIZEOF(void *)
284 AC_CHECK_SIZEOF(long)
287 if test x$grub_cv_apple_cc = xyes ; then
288 HOST_CPPFLAGS="$HOST_CPPFLAGS -DAPPLE_CC=1"
289 HOST_CFLAGS="$HOST_CFLAGS -fnested-functions"
292 if test "x$cross_compiling" = xyes; then
293 AC_MSG_WARN([cannot generate manual pages while cross compiling])
295 AC_PATH_PROG(HELP2MAN, help2man)
298 # Check for functions and headers.
299 AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
300 AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h)
302 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
303 #include <sys/param.h>
304 #include <sys/mount.h>])
306 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
307 #include <sys/param.h>
308 #include <sys/mount.h>])
310 # For opendisk() and getrawpartition() on NetBSD.
311 # Used in util/deviceiter.c and in util/hostdisk.c.
312 AC_CHECK_HEADER([util.h], [
313 AC_CHECK_LIB([util], [opendisk], [
315 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
317 AC_CHECK_LIB([util], [getrawpartition], [
319 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
325 # Check for host and build compilers.
328 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
329 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
335 # Check for target programs.
338 # Find tools for the target.
339 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
340 tmp_ac_tool_prefix="$ac_tool_prefix"
341 ac_tool_prefix=$target_alias-
343 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
344 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
345 AC_CHECK_TOOL(OBJCOPY, objcopy)
346 AC_CHECK_TOOL(STRIP, strip)
347 AC_CHECK_TOOL(NM, nm)
349 ac_tool_prefix="$tmp_ac_tool_prefix"
351 if test "x$TARGET_CC" = x; then
354 AC_CHECK_TOOL(OBJCOPY, objcopy)
355 AC_CHECK_TOOL(STRIP, strip)
356 AC_CHECK_TOOL(NM, nm)
362 # Test the C compiler for the target environment.
365 tmp_LDFLAGS="$LDFLAGS"
366 tmp_CPPFLAGS="$CPPFLAGS"
369 CFLAGS="$TARGET_CFLAGS"
370 CPPFLAGS="$TARGET_CPPFLAGS"
371 LDFLAGS="$TARGET_LDFLAGS"
375 TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g"
376 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
378 # Force no alignment to save space on i386.
379 if test "x$target_cpu" = xi386; then
380 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
381 CFLAGS="$CFLAGS -falign-loops=1"
382 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
383 [grub_cv_cc_falign_loop=yes],
384 [grub_cv_cc_falign_loop=no])
387 if test "x$grub_cv_cc_falign_loop" = xyes; then
388 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
390 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
393 # Some toolchains enable these features by default, but they need
394 # registers that aren't set up properly in GRUB.
395 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
398 # By default, GCC 4.4 generates .eh_frame sections containing unwind
399 # information in some cases where it previously did not. GRUB doesn't need
400 # these and they just use up vital space. Restore the old compiler
402 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
403 SAVE_CFLAGS="$CFLAGS"
404 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
405 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
406 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
407 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
408 CFLAGS="$SAVE_CFLAGS"
411 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
412 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
415 if test "${target_cpu}-${platform}" = mipsel-loongson; then
416 AC_CACHE_CHECK([whether -march=loongson2f works], [grub_cv_cc_march_loongson2f], [
417 SAVE_CFLAGS="$CFLAGS"
418 CFLAGS="$CFLAGS -march=loongson2f"
419 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
420 [grub_cv_cc_march_loongson2f=yes],
421 [grub_cv_cc_march_loongson2f=no])
422 CFLAGS="$SAVE_CFLAGS"
425 if test "x$grub_cv_cc_march_loongson2f" = xyes; then
426 TARGET_CFLAGS="$TARGET_CFLAGS -march=loongson2f"
428 TARGET_CFLAGS="$TARGET_CFLAGS -march=mips3"
433 if test x$grub_cv_apple_target_cc = xyes ; then
434 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DAPPLE_CC=1"
435 TARGET_CFLAGS="$TARGET_CFLAGS -fnested-functions"
437 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
439 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
440 if test "x$OBJCONV" = x ; then
441 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
443 if test "x$OBJCONV" = x ; then
444 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
447 TARGET_IMG_CFLAGS="-static"
448 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
449 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
450 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
453 # Use linker script if present, otherwise use builtin -N script.
454 if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
455 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
456 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
457 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
458 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
461 TARGET_IMG_LDFLAGS='-Wl,-N'
462 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
463 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
468 # For platforms where ELF is not the default link format.
469 AC_MSG_CHECKING([for command to convert module to ELF format])
471 cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf';
472 # FIXME: put proper test here
473 NEED_REGISTER_FRAME_INFO=1
475 *) NEED_REGISTER_FRAME_INFO=0 ;;
477 AC_MSG_RESULT([$TARGET_OBJ2ELF])
479 if test "x$target_m32" = x1; then
481 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
482 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
483 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
484 TARGET_MODULE_FORMAT="elf32"
487 if test "x$target_m64" = x1; then
489 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
490 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
491 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
492 TARGET_MODULE_FORMAT="elf64"
495 if test "$target_cpu"-"$platform" = x86_64-efi; then
496 # Use large model to support 4G memory
497 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
499 CFLAGS="$CFLAGS -m64 -mcmodel=large"
500 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
501 [grub_cv_cc_mcmodel=yes],
502 [grub_cv_cc_mcmodel=no])
504 if test "x$grub_cv_cc_mcmodel" = xno; then
505 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
507 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
510 # EFI writes to stack below %rsp, we must not use the red zone
511 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
512 CFLAGS="$CFLAGS -m64 -mno-red-zone"
513 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
514 [grub_cv_cc_no_red_zone=yes],
515 [grub_cv_cc_no_red_zone=no])
517 if test "x$grub_cv_cc_no_red_zone" = xno; then
518 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
521 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
528 # Need __enable_execute_stack() for nested function trampolines?
529 grub_CHECK_ENABLE_EXECUTE_STACK
531 # Position independent executable.
533 [# Need that, because some distributions ship compilers that include
534 # `-fPIE' in the default specs.
535 if [ x"$pie_possible" = xyes ]; then
536 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
539 # Smashing stack protector.
540 grub_CHECK_STACK_PROTECTOR
541 # Need that, because some distributions ship compilers that include
542 # `-fstack-protector' in the default specs.
543 if test "x$ssp_possible" = xyes; then
544 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
546 grub_CHECK_STACK_ARG_PROBE
547 # Cygwin's GCC uses alloca() to probe the stackframe on static
548 # stack allocations above some threshold.
549 if test x"$sap_possible" = xyes; then
550 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
553 AC_ARG_ENABLE([werror],
554 [AS_HELP_STRING([--disable-werror],
555 [do not use -Werror when building GRUB])])
556 if test x"$enable_werror" != xno ; then
557 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
560 TARGET_CPP="$TARGET_CC -E"
561 TARGET_CCAS=$TARGET_CC
565 AC_SUBST(TARGET_CCAS)
566 AC_SUBST(TARGET_OBJ2ELF)
567 AC_SUBST(TARGET_APPLE_CC)
568 AC_SUBST(TARGET_MODULE_FORMAT)
570 AC_SUBST(TARGET_CFLAGS)
571 AC_SUBST(TARGET_LDFLAGS)
572 AC_SUBST(TARGET_CPPFLAGS)
573 AC_SUBST(TARGET_CCASFLAGS)
575 AC_SUBST(TARGET_IMG_LDSCRIPT)
576 AC_SUBST(TARGET_IMG_LDFLAGS)
577 AC_SUBST(TARGET_IMG_CFLAGS)
578 AC_SUBST(TARGET_IMG_BASE_LDOPT)
580 AC_SUBST(HOST_CFLAGS)
581 AC_SUBST(HOST_LDFLAGS)
582 AC_SUBST(HOST_CPPFLAGS)
583 AC_SUBST(HOST_CCASFLAGS)
585 # Set them to their new values for the tests below.
587 if test "x$TARGET_APPLE_CC" = x1 ; then
588 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
590 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
592 CPPFLAGS="$TARGET_CPPFLAGS"
593 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
600 if test x$grub_cv_asm_uscore = xyes; then
601 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
603 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
606 # Check for libgcc symbols
607 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x __ia64_trampoline __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3)
609 if test "x$TARGET_APPLE_CC" = x1 ; then
610 CFLAGS="$TARGET_CFLAGS -nostdlib"
612 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
616 # Defined in aclocal.m4.
618 if test "x$TARGET_APPLE_CC" != x1 ; then
619 grub_PROG_OBJCOPY_ABSOLUTE
621 grub_PROG_LD_BUILD_ID_NONE
622 if test "x$target_cpu" = xi386; then
623 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
624 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
625 # Check symbols provided by linker script.
626 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
628 grub_CHECK_BSS_START_SYMBOL
629 grub_CHECK_END_SYMBOL
631 CFLAGS="$TARGET_CFLAGS"
632 grub_I386_ASM_PREFIX_REQUIREMENT
636 AC_ARG_ENABLE([efiemu],
637 [AS_HELP_STRING([--enable-efiemu],
638 [build and install the efiemu runtimes (default=guessed)])])
639 if test x"$enable_efiemu" = xno ; then
640 efiemu_excuse="explicitly disabled"
642 if test x"$target_cpu" != xi386 ; then
643 efiemu_excuse="only available on i386"
645 if test x"$platform" = xefi ; then
646 efiemu_excuse="not available on efi"
648 if test x"$efiemu_excuse" = x ; then
649 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
650 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
651 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
652 [grub_cv_cc_efiemu=yes],
653 [grub_cv_cc_efiemu=no])
655 if test x$grub_cv_cc_efiemu = xno; then
656 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
659 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
660 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
662 if test x"$efiemu_excuse" = x ; then
667 AC_SUBST([enable_efiemu])
669 if test "$platform" != emu; then
670 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
671 SAVED_CPPFLAGS="$CPPFLAGS"
672 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
673 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
674 int va_arg_func (int fixed, va_list args);]], [[]])],
675 [grub_cv_cc_isystem=yes],
676 [grub_cv_cc_isystem=no])
677 CPPFLAGS="$SAVED_CPPFLAGS"
680 if test x"$grub_cv_cc_isystem" = xyes ; then
681 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
685 AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_cc_wnotrampolines], [
686 SAVED_CFLAGS="$CFLAGS"
687 # Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
688 # in the event of later failures (since -Wno-* is always accepted, but
689 # produces a diagnostic if something else is wrong).
690 CFLAGS="$TARGET_CFLAGS -Wtrampolines"
691 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
692 int va_arg_func (int fixed, va_list args);]], [[]])],
693 [grub_cv_cc_wnotrampolines=yes],
694 [grub_cv_cc_wnotrampolines=no])
695 CFLAGS="$SAVED_CFLAGS"
698 if test x"$grub_cv_cc_wnotrampolines" = xyes ; then
699 TARGET_CFLAGS="$TARGET_CFLAGS -Wno-trampolines"
705 CPPFLAGS="$tmp_CPPFLAGS"
706 LDFLAGS="$tmp_LDFLAGS"
713 # Memory manager debugging.
714 AC_ARG_ENABLE([mm-debug],
715 AS_HELP_STRING([--enable-mm-debug],
716 [include memory manager debugging]),
717 [AC_DEFINE([MM_DEBUG], [1],
718 [Define to 1 if you enable memory manager debugging.])])
720 AC_ARG_ENABLE([grub-emu-usb],
721 [AS_HELP_STRING([--enable-grub-emu-usb],
722 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
724 AC_ARG_ENABLE([grub-emu-sdl],
725 [AS_HELP_STRING([--enable-grub-emu-sdl],
726 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
728 AC_ARG_ENABLE([grub-emu-pci],
729 [AS_HELP_STRING([--enable-grub-emu-pci],
730 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
732 if test "$platform" = emu; then
734 [# Check for curses libraries.]
735 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
736 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
737 [missing_ncurses=[true]])])
738 AC_SUBST([LIBCURSES])
739 [if [ x"$missing_ncurses" = x ]; then ]
740 [# Check for headers.]
741 AC_CHECK_HEADERS([ncurses/curses.h], [],
742 [AC_CHECK_HEADERS([ncurses.h], [],
743 [AC_CHECK_HEADERS([curses.h], [],
744 [missing_ncurses=[true]])])])
746 if test x"$missing_ncurses" = xtrue ; then
747 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
750 if test x"$enable_grub_emu_usb" != xyes ; then
751 grub_emu_usb_excuse="not enabled"
754 if test x"$enable_grub_emu_pci" = xyes ; then
755 grub_emu_usb_excuse="conflicts with PCI support"
758 [if [ x"$grub_emu_usb_excuse" = x ]; then
759 # Check for libusb libraries.]
760 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
761 [grub_emu_usb_excuse=["need libusb library"]])
764 [if [ x"$grub_emu_usb_excuse" = x ]; then
765 # Check for headers.]
766 AC_CHECK_HEADERS([usb.h], [],
767 [grub_emu_usb_excuse=["need libusb headers"]])
769 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
770 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
772 if test x"$grub_emu_usb_excuse" = x ; then
773 enable_grub_emu_usb=yes
775 enable_grub_emu_usb=no
778 if test x"$enable_grub_emu_sdl" = xno ; then
779 grub_emu_sdl_excuse="explicitely disabled"
781 [if [ x"$grub_emu_sdl_excuse" = x ]; then
782 # Check for libSDL libraries.]
783 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
784 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
788 [if [ x"$grub_emu_sdl_excuse" = x ]; then
789 # Check for headers.]
790 AC_CHECK_HEADERS([SDL/SDL.h], [],
791 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
794 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
795 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
797 if test x"$grub_emu_sdl_excuse" = x ; then
798 enable_grub_emu_sdl=yes
800 enable_grub_emu_sdl=no
803 if test x"$enable_grub_emu_pci" != xyes ; then
804 grub_emu_pci_excuse="not enabled"
807 if test x"$enable_grub_emu_usb" = xyes ; then
808 grub_emu_pci_excuse="conflicts with USB support"
811 [if [ x"$grub_emu_pci_excuse" = x ]; then
812 # Check for libpci libraries.]
813 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
814 [grub_emu_pci_excuse=["need libpciaccess library"]])
815 AC_SUBST([LIBPCIACCESS])
817 [if [ x"$grub_emu_pci_excuse" = x ]; then
818 # Check for headers.]
819 AC_CHECK_HEADERS([pci/pci.h], [],
820 [grub_emu_pci_excuse=["need libpciaccess headers"]])
823 if test x"$grub_emu_pci_excuse" = x ; then
824 enable_grub_emu_pci=yes
827 enable_grub_emu_pci=no
830 AC_SUBST([enable_grub_emu_sdl])
831 AC_SUBST([enable_grub_emu_usb])
832 AC_SUBST([enable_grub_emu_pci])
835 AC_ARG_ENABLE([grub-mkfont],
836 [AS_HELP_STRING([--enable-grub-mkfont],
837 [build and install the `grub-mkfont' utility (default=guessed)])])
838 if test x"$enable_grub_mkfont" = xno ; then
839 grub_mkfont_excuse="explicitly disabled"
842 if test x"$grub_mkfont_excuse" = x ; then
843 # Check for freetype libraries.
844 AC_CHECK_PROGS([FREETYPE], [freetype-config])
845 if test "x$FREETYPE" = x ; then
846 grub_mkfont_excuse=["need freetype2 library"]
850 if test x"$grub_mkfont_excuse" = x ; then
851 # Check for freetype libraries.
852 freetype_cflags=`freetype-config --cflags`
853 freetype_libs=`freetype-config --libs`
854 SAVED_CPPFLAGS="$CPPFLAGS"
855 CPPFLAGS="$CPPFLAGS $freetype_cflags"
856 AC_CHECK_HEADERS([ft2build.h], [],
857 [grub_mkfont_excuse=["need freetype2 headers"]])
858 CPPFLAGS="$SAVED_CPPFLAGS"
861 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
862 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
864 if test x"$grub_mkfont_excuse" = x ; then
865 enable_grub_mkfont=yes
867 enable_grub_mkfont=no
869 AC_SUBST([enable_grub_mkfont])
870 AC_SUBST([freetype_cflags])
871 AC_SUBST([freetype_libs])
873 AC_ARG_ENABLE([device-mapper],
874 [AS_HELP_STRING([--enable-device-mapper],
875 [enable Linux device-mapper support (default=guessed)])])
876 if test x"$enable_device_mapper" = xno ; then
877 device_mapper_excuse="explicitly disabled"
880 if test x"$device_mapper_excuse" = x ; then
881 # Check for device-mapper header.
882 AC_CHECK_HEADER([libdevmapper.h], [],
883 [device_mapper_excuse="need libdevmapper header"])
886 if test x"$device_mapper_excuse" = x ; then
887 # Check for device-mapper library.
888 AC_CHECK_LIB([devmapper], [dm_task_create], [],
889 [device_mapper_excuse="need devmapper library"])
892 if test x"$device_mapper_excuse" = x ; then
893 # Check for device-mapper library.
894 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
896 [device_mapper_excuse="need devmapper library"])
899 if test x"$device_mapper_excuse" = x ; then
900 LIBDEVMAPPER="-ldevmapper";
901 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
902 [Define to 1 if you have the devmapper library.])
905 AC_SUBST([LIBDEVMAPPER])
908 if test x$host_kernel = xkfreebsd; then
909 AC_CHECK_LIB([geom], [geom_gettree], [],
910 [AC_MSG_ERROR([Your platform requires libgeom])])
916 AC_CHECK_LIB([lzma], [lzma_code],
918 AC_DEFINE([HAVE_LIBLZMA], [1],
919 [Define to 1 if you have the LZMA library.])],)
922 AC_CHECK_LIB([zfs], [libzfs_init],
924 AC_DEFINE([HAVE_LIBZFS], [1],
925 [Define to 1 if you have the ZFS library.])],)
928 AC_CHECK_LIB([nvpair], [nvlist_print],
929 [LIBNVPAIR="-lnvpair"
930 AC_DEFINE([HAVE_LIBNVPAIR], [1],
931 [Define to 1 if you have the NVPAIR library.])],)
932 AC_SUBST([LIBNVPAIR])
936 pkglibrootdir='$(libdir)'/`echo $PACKAGE | sed "$program_transform_name"`
937 AC_SUBST(pkglibrootdir)
939 AC_SUBST([FONT_SOURCE])
940 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
941 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
942 AS_IF([test x$TARGET_APPLE_CC = x1],
943 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
945 AC_SUBST(HAVE_ASM_USCORE)
948 AC_SUBST(BSS_START_SYMBOL)
952 AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
953 AC_SUBST(NEED_REGISTER_FRAME_INFO)
956 # Automake conditionals
959 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
960 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
961 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
962 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
963 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
964 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
965 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
966 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
967 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
968 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
969 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
970 AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
971 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
972 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
973 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
975 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
976 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
977 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
978 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
979 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
981 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
982 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
983 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
984 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
985 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
986 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
987 AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
988 AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
989 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
991 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
992 AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin])
995 cpudir="${target_cpu}"
996 if test x${cpudir} = xmipsel; then
1000 if test x"$link_dir" = xyes ; then
1001 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1002 if test "$platform" != emu ; then
1003 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1006 mkdir -p include/grub 2>/dev/null
1007 rm -rf include/grub/cpu
1008 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1009 if test "$platform" != emu ; then
1010 rm -rf include/grub/machine
1011 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1015 AC_CONFIG_FILES([Makefile])
1016 AC_CONFIG_FILES([grub-core/Makefile])
1017 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1018 AC_CONFIG_FILES([po/Makefile.in])
1019 AC_CONFIG_FILES([docs/Makefile])
1020 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1021 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1022 AC_CONFIG_FILES([config.h])
1026 echo "*******************************************************"
1027 echo GRUB2 will be compiled with following components:
1028 echo Platform: "$target_cpu"-"$platform"
1029 if [ x"$platform" = xemu ]; then
1030 if [ x"$grub_emu_usb_excuse" = x ]; then
1031 echo USB support for grub-emu: Yes
1033 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1035 if [ x"$grub_emu_sdl_excuse" = x ]; then
1036 echo SDL support for grub-emu: Yes
1038 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1040 if [ x"$grub_emu_pci_excuse" = x ]; then
1041 echo PCI support for grub-emu: Yes
1043 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1046 if test x"$device_mapper_excuse" = x ; then
1047 echo With devmapper support: Yes
1049 echo With devmapper support: No "($device_mapper_excuse)"
1051 if [ x"$enable_mm_debug" = xyes ]; then
1052 echo With memory debugging: Yes
1054 echo With memory debugging: No
1056 if [ x"$efiemu_excuse" = x ]; then
1057 echo efiemu runtime: Yes
1059 echo efiemu runtime: No "($efiemu_excuse)"
1061 if [ x"$grub_mkfont_excuse" = x ]; then
1062 echo grub-mkfont: Yes
1064 echo grub-mkfont: No "($grub_mkfont_excuse)"
1066 echo "*******************************************************"