Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / configure.ac
blobdc0f22d737b7ed19a92d727a6752910759855352
1 # -*- autoconf -*-
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
14 # PARTICULAR PURPOSE.
16 dnl This configure script is complicated, because GRUB needs to deal
17 dnl with three potentially different types:
18 dnl
19 dnl   build  -- the environment for building GRUB
20 dnl   host   -- the environment for running utilities
21 dnl   target -- the environment for running GRUB
22 dnl
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.
27 dnl
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
33 dnl type.
35 AC_INIT([GRUB],[2.00],[bug-grub@gnu.org])
37 AC_CONFIG_AUX_DIR([build-aux])
39 # We don't want -g -O2 by default in CFLAGS
40 : ${CFLAGS=""}
42 # Checks for host and target systems.
43 AC_CANONICAL_HOST
44 AC_CANONICAL_TARGET
46 AM_INIT_AUTOMAKE()
47 AC_PREREQ(2.60)
48 AC_CONFIG_SRCDIR([include/grub/dl.h])
49 AC_CONFIG_HEADER([config-util.h])
51 # Program name transformations
52 AC_ARG_PROGRAM
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"
70 case "$target_cpu" in
71   i[[3456]]86)  target_cpu=i386 ;;
72   amd64)        target_cpu=x86_64 ;;
73   sparc)        target_cpu=sparc64 ;;
74   mipsel|mips64el)
75                 target_cpu=mipsel;
76                 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
77                 ;;
78   mips|mips64)
79                 target_cpu=mips;
80                 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
81                 ;;
82 esac
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"]) ;;
103   esac
104 else
105   platform="$with_platform"
108 case "$target_cpu"-"$platform" in
109   x86_64-efi) ;;
110   x86_64-emu) ;;
111   x86_64-*) target_cpu=i386 ;;
112   powerpc64-ieee1275) target_cpu=powerpc ;;
113 esac
115 # Check if the platform is supported, make final adjustments.
116 case "$target_cpu"-"$platform" in
117   i386-efi) ;;
118   x86_64-efi) ;;
119   i386-pc) ;;
120   i386-multiboot) ;;
121   i386-coreboot) ;;
122   i386-linuxbios) platform=coreboot ;;
123   i386-ieee1275) ;;
124   i386-qemu) ;;
125   powerpc-ieee1275) ;;
126   sparc64-ieee1275) ;;
127   ia64-efi) ;;
128   mips-qemu_mips) ;;
129   mips-qemu-mips) platform=qemu_mips;;
130   mips-arc) ;;
131   mipsel-qemu_mips) ;;
132   mipsel-qemu-mips) platform=qemu_mips;;
133   mipsel-yeeloong) platform=loongson ;;
134   mipsel-fuloong) platform=loongson ;;
135   mipsel-loongson) ;;
136   *-emu) ;;
137   *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
138 esac
140 case "$target_cpu" in
141   i386 | powerpc) target_m32=1 ;;
142   x86_64 | sparc64) target_m64=1 ;;
143 esac
145 dnl AROS FIX: Originally $host_os is used here, but this causes problems with AROS build system
146 dnl because it specifies --target, causing a ELF cross-compiler to be used for building standalone
147 dnl grub-core. Using $host_os here caused attempt to use pe2elf on ELF objects.
148 dnl The same affects one more 'cygwin' appearance below (line 462).
149 case "$target_os" in
150   mingw32*) target_os=cygwin ;;
151 esac
153 # This normalizes the names, and creates a new variable ("host_kernel")
154 # while at it, since the mapping is not always 1:1 (e.g. different OSes
155 # using the same kernel type).
156 case "$host_os" in
157   gnu*)                         host_kernel=hurd ;;
158   linux*)                       host_kernel=linux ;;
159   freebsd* | kfreebsd*-gnu)     host_kernel=kfreebsd ;;
160   netbsd*)                      host_kernel=netbsd ;;
161   solaris*)                     host_kernel=illumos ;;
162   darwin*)                      host_kernel=xnu ;;
163   cygwin)                       host_kernel=windows ;;
164 esac
166 case "$platform" in
167   coreboot)     machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
168   multiboot)    machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
169   efi)          machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
170   ieee1275)     machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
171   qemu)         machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
172   pc)           machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
173   emu)          machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
174   loongson)     machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
175   qemu_mips)    machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
176   arc)  machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
177 esac
178 case "$target_cpu" in
179   mips |mipsel)         machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
180   sparc64)      machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
181 esac
182 if test x${target_cpu} = xmipsel ; then
183    machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
184 else
185    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"
188 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
190 AC_SUBST(host_cpu)
191 AC_SUBST(host_os)
192 AC_SUBST(host_kernel)
194 AC_SUBST(target_cpu)
195 AC_SUBST(platform)
197 # Define default variables
199 have_with_bootdir=n
200 AC_ARG_WITH([bootdir],
201             AS_HELP_STRING([--with-bootdir=DIR],
202                            [set the name of /boot directory [[guessed]]]),
203                            [have_with_bootdir=y],
204                            [have_with_bootdir=n])
205 if test x$have_with_bootdir = xy; then
206    bootdirname="$with_bootdir"
207 else
208    case "$host_os" in
209      netbsd* | openbsd*)
210         # Because /boot is used for the boot block in NetBSD and OpenBSD,
211            bootdirname=''      ;;
212      *)    bootdirname='boot'  ;;
213    esac
216 AC_SUBST(bootdirname)
217 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
218     [Default boot directory name]")
220 AC_ARG_WITH([grubdir],
221             AS_HELP_STRING([--with-grubdir=DIR],
222                            [set the name of grub directory [[guessed]]]),
223                            [grubdirname="$with_grubdir"],
224                            [grubdirname="$PACKAGE"])
226 AC_SUBST(grubdirname)
227 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
228     [Default grub directory name])
231 # Checks for build programs.
234 # Although cmp is listed in the GNU Coding Standards as a command which
235 # can used directly, OpenBSD lacks cmp in the default installation.
236 AC_CHECK_PROGS([CMP], [cmp])
237 if test "x$CMP" = x; then
238   AC_MSG_ERROR([cmp is not found])
241 AC_CHECK_PROGS([YACC], [bison])
242 if test "x$YACC" = x; then
243   AC_MSG_ERROR([bison is not found])
246 FONT_SOURCE=
248 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
249   for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
250     if test -f "$dir/unifont.$ext"; then
251       FONT_SOURCE="$dir/unifont.$ext"
252       break 2
253     fi
254   done
255 done
257 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips); then
258    AC_MSG_ERROR([qemu and loongson ports need unifont])
261 AC_SUBST([FONT_SOURCE])
263 AC_PROG_RANLIB
264 AC_PROG_INSTALL
265 AC_PROG_AWK
266 AC_PROG_LEX
267 AC_PROG_YACC
268 AC_PROG_MAKE_SET
269 AC_PROG_MKDIR_P
270 AC_PROG_LN_S
272 if test "x$LEX" = "x:"; then
273   AC_MSG_ERROR([flex is not found])
274 else
275   version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
276   if test -n "$version" -a "$version" -ge 20535; then
277     :
278   else
279     AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
280   fi
283 # These are not a "must".
284 AC_PATH_PROGS(MAKEINFO, makeinfo true)
287 # Checks for host programs.
290 AC_PROG_CC
291 gl_EARLY
292 AM_PROG_CC_C_O
293 AM_PROG_AS
295 # Must be GCC.
296 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
298 AC_GNU_SOURCE
299 AM_GNU_GETTEXT([external])
300 AC_SYS_LARGEFILE
302 # Identify characteristics of the host architecture.
303 AC_C_BIGENDIAN
304 AC_CHECK_SIZEOF(void *)
305 AC_CHECK_SIZEOF(long)
307 grub_apple_cc
308 if test x$grub_cv_apple_cc = xyes ; then
309   HOST_CPPFLAGS="$HOST_CPPFLAGS -fnested-functions"
310   HOST_LDFLAGS="$HOST_LDFLAGS -Wl,-allow_stack_execute"
313 if test x$USE_NLS = xno; then
314   HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
317 if test "x$cross_compiling" = xyes; then
318   AC_MSG_WARN([cannot generate manual pages while cross compiling])
319 else
320   AC_PATH_PROG(HELP2MAN, help2man)
323 # Check for functions and headers.
324 AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
325 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
327 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
328 #include <sys/param.h>
329 #include <sys/mount.h>])
331 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
332 #include <sys/param.h>
333 #include <sys/mount.h>])
335 # For opendisk() and getrawpartition() on NetBSD.
336 # Used in util/deviceiter.c and in util/hostdisk.c.
337 AC_CHECK_HEADER([util.h], [
338   AC_CHECK_LIB([util], [opendisk], [
339     LIBUTIL="-lutil"
340     AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
341   ])
342   AC_CHECK_LIB([util], [getrawpartition], [
343     LIBUTIL="-lutil"
344     AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
345   ])
347 AC_SUBST([LIBUTIL])
350 # Check for host and build compilers.
352 HOST_CC=$CC
353 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
354                  [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
356 # For gnulib.
357 gl_INIT
360 # Check for target programs.
363 # Find tools for the target.
364 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
365   tmp_ac_tool_prefix="$ac_tool_prefix"
366   ac_tool_prefix=$target_alias-
368   AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
369                  [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
370   AC_CHECK_TOOL(OBJCOPY, objcopy)
371   AC_CHECK_TOOL(STRIP, strip)
372   AC_CHECK_TOOL(NM, nm)
373 dnl AROS FIX: added TARGET_RANLIB, TARGET_STRIP and TARGET_NM, used by grub-core/Makefile.am
374   AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
375   AC_CHECK_TOOL(TARGET_STRIP, strip)
376   AC_CHECK_TOOL(TARGET_NM, nm)
378   ac_tool_prefix="$tmp_ac_tool_prefix"
379 else
380   if test "x$TARGET_CC" = x; then
381     TARGET_CC=$CC
382   fi
383   if test "x$TARGET_RANLIB" = x; then
384     TARGET_RANLIB=$RANLIB
385   fi
386   AC_CHECK_TOOL(OBJCOPY, objcopy)
387   AC_CHECK_TOOL(STRIP, strip)
388   if test "x$TARGET_STRIP" = x; then
389     TARGET_STRIP=$STRIP
390   fi
391   AC_CHECK_TOOL(NM, nm)
392   if test "x$TARGET_NM" = x; then
393     TARGET_NM=$NM
394   fi
396 AC_SUBST(HOST_CC)
397 AC_SUBST(BUILD_CC)
398 AC_SUBST(TARGET_CC)
399 AC_SUBST(TARGET_RANLIB)
400 AC_SUBST(TARGET_STRIP)
401 AC_SUBST(TARGET_NM)
403 # Test the C compiler for the target environment.
404 tmp_CC="$CC"
405 tmp_CFLAGS="$CFLAGS"
406 tmp_LDFLAGS="$LDFLAGS"
407 tmp_CPPFLAGS="$CPPFLAGS"
408 tmp_LIBS="$LIBS"
409 CC="$TARGET_CC"
410 CFLAGS="$TARGET_CFLAGS"
411 CPPFLAGS="$TARGET_CPPFLAGS"
412 LDFLAGS="$TARGET_LDFLAGS"
413 LIBS=""
415 # debug flags.
416 WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
417 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
418 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
419 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
421 # Force no alignment to save space on i386.
422 if test "x$target_cpu" = xi386; then
423   AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
424     CFLAGS="$CFLAGS -falign-loops=1"
425     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
426         [grub_cv_cc_falign_loop=yes],
427         [grub_cv_cc_falign_loop=no])
428   ])
430   if test "x$grub_cv_cc_falign_loop" = xyes; then
431     TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
432   else
433     TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
434   fi
436   # Some toolchains enable these features by default, but they need
437   # registers that aren't set up properly in GRUB.
438   TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
441 # By default, GCC 4.4 generates .eh_frame sections containing unwind
442 # information in some cases where it previously did not. GRUB doesn't need
443 # these and they just use up vital space. Restore the old compiler
444 # behaviour.
445 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
446   SAVE_CFLAGS="$CFLAGS"
447   CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
448   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
449       [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
450       [grub_cv_cc_fno_dwarf2_cfi_asm=no])
451   CFLAGS="$SAVE_CFLAGS"
454 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
455   TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
458 # By default, GCC 4.6 generates .eh_frame sections containing unwind
459 # information in some cases where it previously did not. GRUB doesn't need
460 # these and they just use up vital space. Restore the old compiler
461 # behaviour.
462 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
463   SAVE_CFLAGS="$CFLAGS"
464   CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
465   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
466       [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
467       [grub_cv_cc_fno_asynchronous_unwind_tables=no])
468   CFLAGS="$SAVE_CFLAGS"
471 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
472   TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
475 grub_apple_target_cc
476 if test x$grub_cv_apple_target_cc = xyes ; then
477   TARGET_CPPFLAGS="$TARGET_CPPFLAGS -fnested-functions"
479   CFLAGS="$CFLAGS -fnested-functions"
480   TARGET_APPLE_CC=1
481   AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
482   if test "x$OBJCONV" = x ; then
483      AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
484   fi
485   if test "x$OBJCONV" = x ; then
486     AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
487   fi
488   TARGET_IMG_LDSCRIPT=
489   TARGET_IMG_CFLAGS="-static"
490   TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
491   TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
492   TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
493   TARGET_LDFLAGS_OLDMAGIC=""
494 else
495   TARGET_APPLE_CC=0
496   TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
497 # Use linker script if present, otherwise use builtin -N script.
498 if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
499   TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
500   TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
501   TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
502   TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
503 else
504   TARGET_IMG_LDSCRIPT=
505   TARGET_IMG_LDFLAGS='-Wl,-N'
506   TARGET_IMG_LDFLAGS_AC='-Wl,-N'
507   TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
509 TARGET_IMG_CFLAGS=
512 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
514 # For platforms where ELF is not the default link format.
515 AC_MSG_CHECKING([for command to convert module to ELF format])
516 case "${target_os}" in
517   cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf';
518 # FIXME: put proper test here
519   NEED_REGISTER_FRAME_INFO=1
520   ;;
521   *) NEED_REGISTER_FRAME_INFO=0 ;;
522 esac
523 AC_MSG_RESULT([$TARGET_OBJ2ELF])
526 AC_ARG_ENABLE([efiemu],
527               [AS_HELP_STRING([--enable-efiemu],
528                              [build and install the efiemu runtimes (default=guessed)])])
529 if test x"$enable_efiemu" = xno ; then
530   efiemu_excuse="explicitly disabled"
532 if test x"$target_cpu" != xi386 ; then
533   efiemu_excuse="only available on i386"
535 if test x"$platform" = xefi ; then
536   efiemu_excuse="not available on efi"
538 if test x"$efiemu_excuse" = x ; then
539   AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
540     SAVED_CFLAGS="$CFLAGS"
541     CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
542     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
543                       [grub_cv_cc_efiemu=yes],
544                       [grub_cv_cc_efiemu=no])
545     CFLAGS="$SAVED_CFLAGS"
546   ])
547   if test x$grub_cv_cc_efiemu = xno; then
548      efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
549   fi
551 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
552   AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
554 if test x"$efiemu_excuse" = x ; then
555 enable_efiemu=yes
556 else
557 enable_efiemu=no
559 AC_SUBST([enable_efiemu])
561 if test "x$target_m32" = x1; then
562   # Force 32-bit mode.
563   TARGET_CFLAGS="$TARGET_CFLAGS -m32"
564   TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
565   TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
566   TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
567   TARGET_MODULE_FORMAT="elf32"
570 if test "x$target_m64" = x1; then
571   # Force 64-bit mode.
572   TARGET_CFLAGS="$TARGET_CFLAGS -m64"
573   TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
574   TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
575   TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
576   TARGET_MODULE_FORMAT="elf64"
579 if test "$target_cpu"-"$platform" = x86_64-efi; then
580   # Use large model to support 4G memory
581   AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
582     SAVED_CFLAGS=$CFLAGS
583     CFLAGS="$CFLAGS -m64 -mcmodel=large"
584     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
585                       [grub_cv_cc_mcmodel=yes],
586                       [grub_cv_cc_mcmodel=no])
587   ])
588   if test "x$grub_cv_cc_mcmodel" = xno; then
589     AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
590   else
591     TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
592   fi
594   # EFI writes to stack below %rsp, we must not use the red zone
595   AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
596     CFLAGS="$CFLAGS -m64 -mno-red-zone"
597     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
598                       [grub_cv_cc_no_red_zone=yes],
599                       [grub_cv_cc_no_red_zone=no])
600   ])
601   if test "x$grub_cv_cc_no_red_zone" = xno; then
602     AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
603   fi
605   TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
609 # Compiler features.
612 # Need __enable_execute_stack() for nested function trampolines?
613 grub_CHECK_ENABLE_EXECUTE_STACK
615 # Position independent executable.
616 grub_CHECK_PIE
617 [# Need that, because some distributions ship compilers that include
618 # `-fPIE' in the default specs.
619 if [ x"$pie_possible" = xyes ]; then
620   TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
623 # Position independent executable.
624 grub_CHECK_PIC
625 [# Need that, because some distributions ship compilers that include
626 # `-fPIC' in the default specs.
627 if [ x"$pic_possible" = xyes ]; then
628   TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
631 # Smashing stack protector.
632 grub_CHECK_STACK_PROTECTOR
633 # Need that, because some distributions ship compilers that include
634 # `-fstack-protector' in the default specs.
635 if test "x$ssp_possible" = xyes; then
636   TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
638 grub_CHECK_STACK_ARG_PROBE
639 # Cygwin's GCC uses alloca() to probe the stackframe on static
640 # stack allocations above some threshold.
641 if test x"$sap_possible" = xyes; then
642   TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
645 AC_ARG_ENABLE([werror],
646               [AS_HELP_STRING([--disable-werror],
647                              [do not use -Werror when building GRUB])])
648 if test x"$enable_werror" != xno ; then
649   TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
650   HOST_CFLAGS="$HOST_CFLAGS -Werror"
653 TARGET_CPP="$TARGET_CC -E"
654 TARGET_CCAS=$TARGET_CC
656 GRUB_TARGET_CPU="${target_cpu}"
657 GRUB_PLATFORM="${platform}"
659 AC_SUBST(GRUB_TARGET_CPU)
660 AC_SUBST(GRUB_PLATFORM)
662 AC_SUBST(OBJCONV)
663 AC_SUBST(TARGET_CPP)
664 AC_SUBST(TARGET_CCAS)
665 AC_SUBST(TARGET_OBJ2ELF)
666 AC_SUBST(TARGET_APPLE_CC)
667 AC_SUBST(TARGET_MODULE_FORMAT)
669 AC_SUBST(TARGET_CFLAGS)
670 AC_SUBST(TARGET_LDFLAGS)
671 AC_SUBST(TARGET_CPPFLAGS)
672 AC_SUBST(TARGET_CCASFLAGS)
674 AC_SUBST(TARGET_IMG_LDSCRIPT)
675 AC_SUBST(TARGET_IMG_LDFLAGS)
676 AC_SUBST(TARGET_IMG_CFLAGS)
677 AC_SUBST(TARGET_IMG_BASE_LDOPT)
679 AC_SUBST(HOST_CFLAGS)
680 AC_SUBST(HOST_LDFLAGS)
681 AC_SUBST(HOST_CPPFLAGS)
682 AC_SUBST(HOST_CCASFLAGS)
684 # Set them to their new values for the tests below.
685 CC="$TARGET_CC"
686 if test "x$TARGET_APPLE_CC" = x1 ; then
687 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
688 else
689 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
691 CPPFLAGS="$TARGET_CPPFLAGS"
692 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
693 LIBS=
694 else
695 LIBS=-lgcc
698 grub_ASM_USCORE
699 if test x$grub_cv_asm_uscore = xyes; then
700 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
701 else
702 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
705 # Check for libgcc symbols
706 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)
708 if test "x$TARGET_APPLE_CC" = x1 ; then
709 CFLAGS="$TARGET_CFLAGS -nostdlib"
710 else
711 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
713 LIBS=""
715 # Defined in aclocal.m4.
716 grub_PROG_TARGET_CC
717 if test "x$TARGET_APPLE_CC" != x1 ; then
718 grub_PROG_OBJCOPY_ABSOLUTE
720 grub_PROG_LD_BUILD_ID_NONE
721 if test "x$target_cpu" = xi386; then
722   if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
723     if test ! -z "$TARGET_IMG_LDSCRIPT"; then
724       # Check symbols provided by linker script.
725       CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
726     fi
727     grub_CHECK_BSS_START_SYMBOL
728     grub_CHECK_END_SYMBOL
729   fi
730   CFLAGS="$TARGET_CFLAGS"
731   grub_I386_ASM_PREFIX_REQUIREMENT
732   grub_I386_ASM_ADDR32
735 if test "$platform" != emu; then
736 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
737   SAVED_CPPFLAGS="$CPPFLAGS"
738   CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
739   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
740 int va_arg_func (int fixed, va_list args);]], [[]])],
741       [grub_cv_cc_isystem=yes],
742       [grub_cv_cc_isystem=no])
743   CPPFLAGS="$SAVED_CPPFLAGS"
746 if test x"$grub_cv_cc_isystem" = xyes ; then
747   TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
751 AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_cc_wnotrampolines], [
752   SAVED_CFLAGS="$CFLAGS"
753   # Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
754   # in the event of later failures (since -Wno-* is always accepted, but
755   # produces a diagnostic if something else is wrong).
756   CFLAGS="$TARGET_CFLAGS -Wtrampolines"
757   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
758 int va_arg_func (int fixed, va_list args);]], [[]])],
759       [grub_cv_cc_wnotrampolines=yes],
760       [grub_cv_cc_wnotrampolines=no])
761   CFLAGS="$SAVED_CFLAGS"
764 if test x"$grub_cv_cc_wnotrampolines" = xyes ; then
765   TARGET_CFLAGS="$TARGET_CFLAGS -Wno-trampolines"
768 # Restore the flags.
769 CC="$tmp_CC"
770 CFLAGS="$tmp_CFLAGS"
771 CPPFLAGS="$tmp_CPPFLAGS"
772 LDFLAGS="$tmp_LDFLAGS"
773 LIBS="$tmp_LIBS"
776 # Check for options.
779 # Memory manager debugging.
780 AC_ARG_ENABLE([mm-debug],
781               AS_HELP_STRING([--enable-mm-debug],
782                              [include memory manager debugging]),
783               [AC_DEFINE([MM_DEBUG], [1],
784                          [Define to 1 if you enable memory manager debugging.])])
786 AC_ARG_ENABLE([cache-stats],
787               AS_HELP_STRING([--enable-cache-stats],
788                              [enable disk cache statistics collection]))
790 if test x$enable_cache_stats = xyes; then
791   DISK_CACHE_STATS=1
792 else
793   DISK_CACHE_STATS=0
795 AC_SUBST([DISK_CACHE_STATS])
797 AC_ARG_ENABLE([grub-emu-usb],
798               [AS_HELP_STRING([--enable-grub-emu-usb],
799                              [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
801 AC_ARG_ENABLE([grub-emu-sdl],
802               [AS_HELP_STRING([--enable-grub-emu-sdl],
803                              [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
805 AC_ARG_ENABLE([grub-emu-pci],
806               [AS_HELP_STRING([--enable-grub-emu-pci],
807                              [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
809 if test "$platform" = emu; then
810   missing_ncurses=
811 [# Check for curses libraries.]
812   AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
813     [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
814       [missing_ncurses=[true]])])
815   AC_SUBST([LIBCURSES])
816 [if [ x"$missing_ncurses" = x ]; then ]
817   [# Check for headers.]
818   AC_CHECK_HEADERS([ncurses/curses.h], [],
819     [AC_CHECK_HEADERS([ncurses.h], [],
820       [AC_CHECK_HEADERS([curses.h], [],
821         [missing_ncurses=[true]])])])
822 [fi]
823 if test x"$missing_ncurses" = xtrue ; then
824   AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
827 if test x"$enable_grub_emu_usb" != xyes ; then
828    grub_emu_usb_excuse="not enabled"
831 if test x"$enable_grub_emu_pci" = xyes ; then
832    grub_emu_usb_excuse="conflicts with PCI support"
835 [if [ x"$grub_emu_usb_excuse" = x ]; then
836     # Check for libusb libraries.]
837 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
838     [grub_emu_usb_excuse=["need libusb library"]])
839     AC_SUBST([LIBUSB])
840 [fi]
841 [if [ x"$grub_emu_usb_excuse" = x ]; then
842     # Check for headers.]
843     AC_CHECK_HEADERS([usb.h], [],
844       [grub_emu_usb_excuse=["need libusb headers"]])
845 [fi]
846 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
847   AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
849 if test x"$grub_emu_usb_excuse" = x ; then
850 enable_grub_emu_usb=yes
851 else
852 enable_grub_emu_usb=no
855 if test x"$enable_grub_emu_sdl" = xno ; then
856   grub_emu_sdl_excuse="explicitely disabled"
858 [if [ x"$grub_emu_sdl_excuse" = x ]; then
859     # Check for libSDL libraries.]
860 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
861     [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
862     AC_SUBST([LIBSDL])
863 [fi]
865 [if [ x"$grub_emu_sdl_excuse" = x ]; then
866     # Check for headers.]
867     AC_CHECK_HEADERS([SDL/SDL.h], [],
868       [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
869 [fi]
871 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
872   AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
874 if test x"$grub_emu_sdl_excuse" = x ; then
875 enable_grub_emu_sdl=yes
876 else
877 enable_grub_emu_sdl=no
880 if test x"$enable_grub_emu_pci" != xyes ; then
881    grub_emu_pci_excuse="not enabled"
884 if test x"$enable_grub_emu_usb" = xyes ; then
885    grub_emu_pci_excuse="conflicts with USB support"
888 [if [ x"$grub_emu_pci_excuse" = x ]; then
889       # Check for libpci libraries.]
890    AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
891       [grub_emu_pci_excuse=["need libpciaccess library"]])
892     AC_SUBST([LIBPCIACCESS])
893 [fi]
894 [if [ x"$grub_emu_pci_excuse" = x ]; then
895     # Check for headers.]
896     AC_CHECK_HEADERS([pci/pci.h], [],
897       [grub_emu_pci_excuse=["need libpciaccess headers"]])
898 [fi]
900 if test x"$grub_emu_pci_excuse" = x ; then
901 enable_grub_emu_pci=yes
902 else
904 enable_grub_emu_pci=no
907 AC_SUBST([enable_grub_emu_sdl])
908 AC_SUBST([enable_grub_emu_usb])
909 AC_SUBST([enable_grub_emu_pci])
912 AC_ARG_ENABLE([grub-mkfont],
913               [AS_HELP_STRING([--enable-grub-mkfont],
914                              [build and install the `grub-mkfont' utility (default=guessed)])])
915 if test x"$enable_grub_mkfont" = xno ; then
916   grub_mkfont_excuse="explicitly disabled"
919 if test x"$grub_mkfont_excuse" = x ; then
920   # Check for freetype libraries.
921   AC_CHECK_PROGS([FREETYPE], [freetype-config])
922   if test "x$FREETYPE" = x ; then
923     grub_mkfont_excuse=["need freetype2 library"]
924   fi
927 if test x"$grub_mkfont_excuse" = x ; then
928   # Check for freetype libraries.
929   freetype_cflags=`freetype-config --cflags`
930   freetype_libs=`freetype-config --libs`
931   SAVED_CPPFLAGS="$CPPFLAGS"
932   CPPFLAGS="$CPPFLAGS $freetype_cflags"
933   AC_CHECK_HEADERS([ft2build.h], [],
934         [grub_mkfont_excuse=["need freetype2 headers"]])
935   CPPFLAGS="$SAVED_CPPFLAGS"
938 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
939   AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
941 if test x"$grub_mkfont_excuse" = x ; then
942 enable_grub_mkfont=yes
943 else
944 enable_grub_mkfont=no
946 if test x"$enable_grub_mkfont" = xno && test "x$platform" = xloongson; then
947   AC_MSG_ERROR([loongson port needs grub-mkfont])
949 AC_SUBST([enable_grub_mkfont])
950 AC_SUBST([freetype_cflags])
951 AC_SUBST([freetype_libs])
953 DJVU_FONT_SOURCE=
955 starfield_excuse=
957 if test x$enable_grub_mkfont = xno; then
958    starfield_excuse="No grub-mkfont"
961 if test x"$starfield_excuse" = x; then
962    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
963      for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
964         if test -f "$dir/DejaVuSans.$ext"; then
965           DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
966           break 2
967         fi
968      done
969    done
971    if test "x$DJVU_FONT_SOURCE" = x; then
972      starfield_excuse="No DejaVu found"
973    fi
976 AC_SUBST([DJVU_FONT_SOURCE])
978 AC_ARG_ENABLE([grub-mount],
979               [AS_HELP_STRING([--enable-grub-mount],
980                              [build and install the `grub-mount' utility (default=guessed)])])
981 if test x"$enable_grub_mount" = xno ; then
982   grub_mount_excuse="explicitly disabled"
985 if test x"$grub_mount_excuse" = x ; then
986   AC_CHECK_LIB([fuse], [fuse_main_real], [],
987                [grub_mount_excuse="need FUSE library"])
990 if test x"$grub_mount_excuse" = x ; then
991   # Check for fuse headers.
992   SAVED_CPPFLAGS="$CPPFLAGS"
993   CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
994   AC_CHECK_HEADERS([fuse/fuse.h], [],
995         [grub_mount_excuse=["need FUSE headers"]])
996   CPPFLAGS="$SAVED_CPPFLAGS"
999 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1000   AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
1002 if test x"$grub_mount_excuse" = x ; then
1003 enable_grub_mount=yes
1004 else
1005 enable_grub_mount=no
1007 AC_SUBST([enable_grub_mount])
1009 AC_ARG_ENABLE([device-mapper],
1010               [AS_HELP_STRING([--enable-device-mapper],
1011                               [enable Linux device-mapper support (default=guessed)])])
1012 if test x"$enable_device_mapper" = xno ; then
1013   device_mapper_excuse="explicitly disabled"
1016 if test x"$device_mapper_excuse" = x ; then
1017   # Check for device-mapper header.
1018   AC_CHECK_HEADER([libdevmapper.h], [],
1019                [device_mapper_excuse="need libdevmapper header"])
1022 if test x"$device_mapper_excuse" = x ; then
1023   # Check for device-mapper library.
1024   AC_CHECK_LIB([devmapper], [dm_task_create], [],
1025                [device_mapper_excuse="need devmapper library"])
1028 if test x"$device_mapper_excuse" = x ; then
1029   # Check for device-mapper library.
1030   AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1031                [],
1032                [device_mapper_excuse="need devmapper library"])
1035 if test x"$device_mapper_excuse" = x ; then
1036    LIBDEVMAPPER="-ldevmapper";
1037    AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1038              [Define to 1 if you have the devmapper library.])
1041 AC_SUBST([LIBDEVMAPPER])
1043 LIBGEOM=
1044 if test x$host_kernel = xkfreebsd; then
1045   AC_CHECK_LIB([geom], [geom_gettree], [],
1046                [AC_MSG_ERROR([Your platform requires libgeom])])
1047   LIBGEOM="-lgeom"
1050 AC_SUBST([LIBGEOM])
1052 AC_CHECK_LIB([lzma], [lzma_code],
1053              [LIBLZMA="-llzma"
1054               AC_DEFINE([HAVE_LIBLZMA], [1],
1055                         [Define to 1 if you have the LZMA library.])],)
1056 AC_SUBST([LIBLZMA])
1058 AC_ARG_ENABLE([libzfs],
1059               [AS_HELP_STRING([--enable-libzfs],
1060                               [enable libzfs integration (default=guessed)])])
1061 if test x"$enable_libzfs" = xno ; then
1062   libzfs_excuse="explicitly disabled"
1065 if test x"$libzfs_excuse" = x ; then
1066   # Only check for system headers if libzfs support has not been disabled.
1067   AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1070 if test x"$libzfs_excuse" = x ; then
1071   AC_CHECK_LIB([zfs], [libzfs_init],
1072                [],
1073                [libzfs_excuse="need zfs library"])
1076 if test x"$libzfs_excuse" = x ; then
1077   AC_CHECK_LIB([nvpair], [nvlist_print],
1078                [],
1079                [libzfs_excuse="need nvpair library"])
1082 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1083   AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1086 if test x"$libzfs_excuse" = x ; then
1087   # We need both libzfs and libnvpair for a successful build.
1088   LIBZFS="-lzfs"
1089   AC_DEFINE([HAVE_LIBZFS], [1],
1090             [Define to 1 if you have the ZFS library.])
1091   LIBNVPAIR="-lnvpair"
1092   AC_DEFINE([HAVE_LIBNVPAIR], [1],
1093             [Define to 1 if you have the NVPAIR library.])
1096 AC_SUBST([LIBZFS])
1097 AC_SUBST([LIBNVPAIR])
1099 LIBS=""
1101 AC_SUBST([FONT_SOURCE])
1102 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1103             [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1104 AS_IF([test x$TARGET_APPLE_CC = x1],
1105             [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
1107 AC_SUBST(HAVE_ASM_USCORE)
1108 AC_SUBST(ADDR32)
1109 AC_SUBST(DATA32)
1110 AC_SUBST(BSS_START_SYMBOL)
1111 AC_SUBST(END_SYMBOL)
1112 AC_SUBST(PACKAGE)
1113 AC_SUBST(VERSION)
1114 AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
1115 AC_SUBST(NEED_REGISTER_FRAME_INFO)
1118 # Automake conditionals
1121 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1122 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1123 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1124 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1125 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1126 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1127 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1128 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1129 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1130 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1131 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")"  -a x$platform = xqemu_mips])
1132 AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
1133 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1134 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1135 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1136 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1137 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1139 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1140 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1141 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1142 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1143 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1144 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1145 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1147 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1148 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1149 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1150 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1151 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1152 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1153 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1154 AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
1155 AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
1156 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1157 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1159 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1160 AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin])
1161 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1163 # Output files.
1164 cpudir="${target_cpu}"
1165 if test x${cpudir} = xmipsel; then
1166   cpudir=mips;
1168 grub_CHECK_LINK_DIR
1169 if test x"$link_dir" = xyes ; then
1170   AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1171   if test "$platform" != emu ; then
1172     AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1173   fi
1174 else
1175   mkdir -p include/grub 2>/dev/null
1176   rm -rf include/grub/cpu
1177   cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1178   if test "$platform" != emu ; then
1179     rm -rf include/grub/machine
1180     cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1181   fi
1184 AC_CONFIG_FILES([Makefile])
1185 AC_CONFIG_FILES([grub-core/Makefile])
1186 AC_CONFIG_FILES([grub-core/gensyminfo.sh])
1187 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1188 AC_CONFIG_FILES([po/Makefile.in])
1189 AC_CONFIG_FILES([docs/Makefile])
1190 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1191 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1192 AC_CONFIG_FILES([config.h])
1194 AC_OUTPUT
1196 echo "*******************************************************"
1197 echo GRUB2 will be compiled with following components:
1198 echo Platform: "$target_cpu"-"$platform"
1199 if [ x"$platform" = xemu ]; then
1200 if [ x"$grub_emu_usb_excuse" = x ]; then
1201 echo USB support for grub-emu: Yes
1202 else
1203 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1205 if [ x"$grub_emu_sdl_excuse" = x ]; then
1206 echo SDL support for grub-emu: Yes
1207 else
1208 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1210 if [ x"$grub_emu_pci_excuse" = x ]; then
1211 echo PCI support for grub-emu: Yes
1212 else
1213 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1216 if test x"$device_mapper_excuse" = x ; then
1217 echo With devmapper support: Yes
1218 else
1219 echo With devmapper support: No "($device_mapper_excuse)"
1221 if [ x"$enable_mm_debug" = xyes ]; then
1222 echo With memory debugging: Yes
1223 else
1224 echo With memory debugging: No
1226 if [ x"$enable_cache_stats" = xyes ]; then
1227 echo With disk cache statistics: Yes
1228 else
1229 echo With disk cache statistics: No
1231 if [ x"$efiemu_excuse" = x ]; then
1232 echo efiemu runtime: Yes
1233 else
1234 echo efiemu runtime: No "($efiemu_excuse)"
1236 if [ x"$grub_mkfont_excuse" = x ]; then
1237 echo grub-mkfont: Yes
1238 else
1239 echo grub-mkfont: No "($grub_mkfont_excuse)"
1241 if [ x"$grub_mount_excuse" = x ]; then
1242 echo grub-mount: Yes
1243 else
1244 echo grub-mount: No "($grub_mount_excuse)"
1246 if [ x"$starfield_excuse" = x ]; then
1247 echo starfield theme: Yes
1248 else
1249 echo starfield theme: No "($starfield_excuse)"
1251 if [ x"$libzfs_excuse" = x ]; then
1252 echo With libzfs support: Yes
1253 else
1254 echo With libzfs support: No "($libzfs_excuse)"
1256 echo "*******************************************************"