New port arm64-efi
[grub.git] / configure.ac
1 # -*- autoconf -*-
2
3 # Process this file with autoconf to produce a configure script.
4
5 # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
6 #
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.
10 #
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.
15
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.
34
35 AC_INIT([GRUB],[2.00],[bug-grub@gnu.org])
36
37 AC_CONFIG_AUX_DIR([build-aux])
38
39 # We don't want -g -O2 by default in CFLAGS
40 : ${CFLAGS=""}
41
42 # Checks for host and target systems.
43 AC_CANONICAL_HOST
44 save_program_prefix="${program_prefix}"
45 AC_CANONICAL_TARGET
46 program_prefix="${save_program_prefix}"
47
48 AM_INIT_AUTOMAKE([1.10.1])
49 AC_PREREQ(2.60)
50 AC_CONFIG_SRCDIR([include/grub/dl.h])
51 AC_CONFIG_HEADER([config-util.h])
52
53 # Program name transformations
54 AC_ARG_PROGRAM
55 grub_TRANSFORM([grub-bios-setup])
56 grub_TRANSFORM([grub-editenv])
57 grub_TRANSFORM([grub-install])
58 grub_TRANSFORM([grub-mkconfig])
59 grub_TRANSFORM([grub-mkfont])
60 grub_TRANSFORM([grub-mkimage])
61 grub_TRANSFORM([grub-glue-efi])
62 grub_TRANSFORM([grub-mklayout])
63 grub_TRANSFORM([grub-mkpasswd-pbkdf2])
64 grub_TRANSFORM([grub-mkrelpath])
65 grub_TRANSFORM([grub-mkrescue])
66 grub_TRANSFORM([grub-probe])
67 grub_TRANSFORM([grub-reboot])
68 grub_TRANSFORM([grub-script-check])
69 grub_TRANSFORM([grub-set-default])
70 grub_TRANSFORM([grub-sparc64-setup])
71 grub_TRANSFORM([grub-render-label])
72
73 # Optimization flag.  Allow user to override.
74 if test "x$TARGET_CFLAGS" = x; then
75   TARGET_CFLAGS="$TARGET_CFLAGS -Os"
76 fi
77
78 # Default HOST_CPPFLAGS
79 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
80 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
81 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
82
83 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
84 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
85 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
86
87 case "$target_cpu" in
88   i[[3456]]86)  target_cpu=i386 ;;
89   amd64)        target_cpu=x86_64 ;;
90   sparc)        target_cpu=sparc64 ;;
91   mipsel|mips64el)
92                 target_cpu=mipsel;
93                 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
94                 ;;
95   mips|mips64)
96                 target_cpu=mips;
97                 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
98                 ;;
99   arm*)
100                 target_cpu=arm;
101                 ;;
102   aarch64*)
103                 target_cpu=arm64;
104                 ;;
105 esac
106
107 # Specify the platform (such as firmware).
108 AC_ARG_WITH([platform],
109             AS_HELP_STRING([--with-platform=PLATFORM],
110                            [select the host platform [[guessed]]]))
111
112 # Guess the platform if not specified.
113 if test "x$with_platform" = x; then
114   case "$target_cpu"-"$target_vendor" in
115     i386-apple) platform=efi ;;
116     i386-*) platform=pc ;;
117     x86_64-apple) platform=efi ;;
118     x86_64-*) platform=pc ;;
119     powerpc-*) platform=ieee1275 ;;
120     powerpc64-*) platform=ieee1275 ;;
121     sparc64-*) platform=ieee1275 ;;
122     mipsel-*) platform=loongson ;;
123     mips-*) platform=arc ;;
124     ia64-*) platform=efi ;;
125     arm-*) platform=uboot ;;
126     arm64-*) platform=efi ;;
127     *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
128   esac
129 else
130   platform="$with_platform"
131 fi
132
133 case "$target_cpu"-"$platform" in
134   x86_64-efi) ;;
135   x86_64-emu) ;;
136   x86_64-xen) ;;
137   x86_64-*) target_cpu=i386 ;;
138   powerpc64-ieee1275) target_cpu=powerpc ;;
139 esac
140
141 # Check if the platform is supported, make final adjustments.
142 case "$target_cpu"-"$platform" in
143   i386-efi) ;;
144   x86_64-efi) ;;
145   i386-xen) ;;
146   x86_64-xen) ;;
147   i386-pc) ;;
148   i386-multiboot) ;;
149   i386-coreboot) ;;
150   i386-linuxbios) platform=coreboot ;;
151   i386-ieee1275) ;;
152   i386-qemu) ;;
153   powerpc-ieee1275) ;;
154   sparc64-ieee1275) ;;
155   ia64-efi) ;;
156   mips-qemu_mips) ;;
157   mips-qemu-mips) platform=qemu_mips;;
158   mips-arc) ;;
159   mipsel-arc) ;;
160   mipsel-qemu_mips) ;;
161   mipsel-qemu-mips) platform=qemu_mips;;
162   mipsel-yeeloong) platform=loongson ;;
163   mipsel-fuloong) platform=loongson ;;
164   mipsel-loongson) ;;
165   arm-uboot) ;;
166   arm-efi) ;;
167   arm64-efi) ;;
168   *-emu) ;;
169   *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
170 esac
171
172 if test x$platform != xemu ; then
173    case "$target_cpu" in
174         i386 | powerpc) target_m32=1 ;;
175         x86_64 | sparc64) target_m64=1 ;;
176    esac
177 fi
178
179 case "$target_os" in
180   windows* | mingw32*) target_os=cygwin ;;
181 esac
182
183 # This normalizes the names, and creates a new variable ("host_kernel")
184 # while at it, since the mapping is not always 1:1 (e.g. different OSes
185 # using the same kernel type).
186 case "$host_os" in
187   gnu*)                         host_kernel=hurd ;;
188   linux*)                       host_kernel=linux ;;
189   freebsd* | kfreebsd*-gnu)     host_kernel=kfreebsd ;;
190   netbsd*)                      host_kernel=netbsd ;;
191   solaris*)                     host_kernel=illumos ;;
192   darwin*)                      host_kernel=xnu ;;
193   cygwin | windows* | mingw32*) host_kernel=windows ;;
194 esac
195
196 case "$host_os" in
197   cygwin | windows* | mingw32*) have_exec=n ;;
198   aros*) have_exec=n ;;
199   *) have_exec=y;;
200 esac
201
202 case "$platform" in
203   coreboot)     machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
204   multiboot)    machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
205   efi)          machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
206   xen)          machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
207   ieee1275)     machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
208   uboot)        machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
209   qemu)         machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
210   pc)           machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
211   emu)          machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
212   loongson)     machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
213   qemu_mips)    machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
214   arc)  machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
215 esac
216 case "$target_cpu" in
217   arm)          machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
218   arm64)        machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM64=1" ;;
219   mips |mipsel)         machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
220   sparc64)      machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
221 esac
222 if test x${target_cpu} = xmipsel ; then
223    machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
224 else
225    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"
226 fi
227
228 case "${target_cpu}-$platform" in
229      mips-arc)
230         TARGET_LINK_ADDR=0x88200000
231         TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
232         ;;
233      mipsel-arc)
234         TARGET_LINK_ADDR=0x80700000
235         TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
236         ;;
237      mips*-qemu_mips | mips*-loongson)
238         TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
239         ;;
240 esac
241
242 AC_SUBST(TARGET_LINK_ADDR)
243 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
244
245 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
246
247 AC_SUBST(host_cpu)
248 AC_SUBST(host_os)
249 AC_SUBST(host_kernel)
250
251 AC_SUBST(target_cpu)
252 AC_SUBST(platform)
253
254 # Define default variables
255
256 have_with_bootdir=n
257 AC_ARG_WITH([bootdir],
258             AS_HELP_STRING([--with-bootdir=DIR],
259                            [set the name of /boot directory [[guessed]]]),
260                            [have_with_bootdir=y],
261                            [have_with_bootdir=n])
262 if test x$have_with_bootdir = xy; then
263    bootdirname="$with_bootdir"
264 else
265    case "$host_os" in
266      netbsd* | openbsd*)
267         # Because /boot is used for the boot block in NetBSD and OpenBSD,
268            bootdirname=''      ;;
269      *)    bootdirname='boot'  ;;
270    esac
271 fi
272
273 AC_SUBST(bootdirname)
274 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
275     [Default boot directory name]")
276
277 AC_ARG_WITH([grubdir],
278             AS_HELP_STRING([--with-grubdir=DIR],
279                            [set the name of grub directory [[guessed]]]),
280                            [grubdirname="$with_grubdir"],
281                            [grubdirname="$PACKAGE"])
282
283 AC_SUBST(grubdirname)
284 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
285     [Default grub directory name])
286
287 #
288 # Checks for build programs.
289 #
290
291 # Although cmp is listed in the GNU Coding Standards as a command which
292 # can used directly, OpenBSD lacks cmp in the default installation.
293 AC_CHECK_PROGS([CMP], [cmp])
294 if test "x$CMP" = x; then
295   AC_MSG_ERROR([cmp is not found])
296 fi
297
298 AC_CHECK_PROGS([YACC], [bison])
299 if test "x$YACC" = x; then
300   AC_MSG_ERROR([bison is not found])
301 fi
302
303 AC_PROG_RANLIB
304 AC_PROG_INSTALL
305 AC_PROG_AWK
306 AC_PROG_LEX
307 AC_PROG_YACC
308 AC_PROG_MAKE_SET
309 AC_PROG_MKDIR_P
310 AC_PROG_LN_S
311
312 if test "x$LEX" = "x:"; then
313   AC_MSG_ERROR([flex is not found])
314 else
315   version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
316   if test -n "$version" -a "$version" -ge 20535; then
317     :
318   else
319     AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
320   fi
321 fi
322
323 # These are not a "must".
324 AC_PATH_PROGS(MAKEINFO, makeinfo true)
325
326 #
327 # Checks for host programs.
328 #
329
330 AC_PROG_CC
331 gl_EARLY
332 AC_PROG_CXX
333 AM_PROG_CC_C_O
334 AM_PROG_AS
335
336 # Must be GCC.
337 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
338
339 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
340
341 AC_GNU_SOURCE
342 AM_GNU_GETTEXT([external])
343 AC_SYS_LARGEFILE
344
345 # Identify characteristics of the host architecture.
346 unset ac_cv_c_bigendian
347
348 AC_C_BIGENDIAN
349 AC_CHECK_SIZEOF(void *)
350 AC_CHECK_SIZEOF(long)
351
352 case "$host_os" in
353   cygwin | windows* | mingw32*)
354      HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
355      CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
356      AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
357    ;;
358 esac
359
360 if test x$USE_NLS = xno; then
361   HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
362 fi
363
364 if test "x$cross_compiling" = xyes; then
365   AC_MSG_WARN([cannot generate manual pages while cross compiling])
366 else
367   AC_PATH_PROG(HELP2MAN, help2man)
368 fi
369
370 # Check for functions and headers.
371 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
372 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
373
374 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
375 #include <sys/param.h>
376 #include <sys/mount.h>])
377
378 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
379 #include <sys/param.h>
380 #include <sys/mount.h>])
381
382 # For opendisk() and getrawpartition() on NetBSD.
383 # Used in util/deviceiter.c and in util/hostdisk.c.
384 AC_CHECK_HEADER([util.h], [
385   AC_CHECK_LIB([util], [opendisk], [
386     LIBUTIL="-lutil"
387     AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
388   ])
389   AC_CHECK_LIB([util], [getrawpartition], [
390     LIBUTIL="-lutil"
391     AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
392   ])
393 ])
394 AC_SUBST([LIBUTIL])
395
396 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
397   SAVED_CFLAGS="$CFLAGS"
398   CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
399   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
400 int va_arg_func (int fixed, va_list args);]], [[]])],
401       [grub_cv_host_cc_wtrampolines=yes],
402       [grub_cv_host_cc_wtrampolines=no])
403   CFLAGS="$SAVED_CFLAGS"
404 ])
405
406 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
407   HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
408 fi
409
410 #
411 # Check for host and build compilers.
412 #
413 HOST_CC=$CC
414 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
415 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
416 BUILD_CPP="$BUILD_CC -E"
417
418 case "$build_os" in
419   haiku*)                               BUILD_LIBM= ;;
420   *)                                    BUILD_LIBM=-lm ;;
421 esac
422 # For gnulib.
423 gl_INIT
424
425 #
426 # Check for target programs.
427 #
428
429 # Find tools for the target.
430 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
431   tmp_ac_tool_prefix="$ac_tool_prefix"
432   ac_tool_prefix=$target_alias-
433
434   AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
435                  [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
436   AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
437   AC_CHECK_TOOL(TARGET_STRIP, strip)
438   AC_CHECK_TOOL(TARGET_NM, nm)
439   AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
440
441   ac_tool_prefix="$tmp_ac_tool_prefix"
442 else
443   if test "x$TARGET_CC" = x; then
444     TARGET_CC=$CC
445   fi
446   AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
447   AC_CHECK_TOOL(TARGET_STRIP, strip)
448   AC_CHECK_TOOL(TARGET_NM, nm)
449   AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
450 fi
451
452 AC_SUBST(HOST_CC)
453 AC_SUBST(BUILD_CC)
454 AC_SUBST(BUILD_CFLAGS)
455 AC_SUBST(BUILD_CPPFLAGS)
456 AC_SUBST(TARGET_CC)
457 AC_SUBST(TARGET_NM)
458 AC_SUBST(TARGET_RANLIB)
459 AC_SUBST(TARGET_STRIP)
460 AC_SUBST(TARGET_OBJCOPY)
461
462 # Test the C compiler for the target environment.
463 tmp_CC="$CC"
464 tmp_CFLAGS="$CFLAGS"
465 tmp_LDFLAGS="$LDFLAGS"
466 tmp_CPPFLAGS="$CPPFLAGS"
467 tmp_LIBS="$LIBS"
468 CC="$TARGET_CC"
469 CFLAGS="$TARGET_CFLAGS"
470 CPPFLAGS="$TARGET_CPPFLAGS"
471 LDFLAGS="$TARGET_LDFLAGS"
472 LIBS=""
473
474 # debug flags.
475 WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value  -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
476 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
477 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
478 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
479
480 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
481 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
482 fi
483
484 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
485 [AC_COMPILE_IFELSE(
486 [AC_LANG_PROGRAM([], [[
487 #ifdef __clang__
488 #error "is clang"
489 #endif
490 ]])],
491 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
492
493 # on x86 clang doesn't support .code16
494 # on arm clang doesn't support .arch directive
495 # on mips clang doesn't support privilegied instructions, doubleword store/load
496 # and crashes with hand-written assembly
497 if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
498    || test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \
499    || test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then
500    TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
501 fi
502
503 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
504   TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
505 fi
506
507 if test "x$target_m32" = x1; then
508   # Force 32-bit mode.
509   TARGET_CFLAGS="$TARGET_CFLAGS -m32"
510   TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
511   TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
512   TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
513   TARGET_MODULE_FORMAT="elf32"
514 fi
515
516 if test "x$target_m64" = x1; then
517   # Force 64-bit mode.
518   TARGET_CFLAGS="$TARGET_CFLAGS -m64"
519   TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
520   TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
521   TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
522   TARGET_MODULE_FORMAT="elf64"
523 fi
524
525 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
526    TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
527 fi
528
529 # on mips redirect cache flushing function to non-existant one.
530 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
531   AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
532     CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
533     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
534         [grub_cv_cc_mflush_func=yes],
535         [grub_cv_cc_mflush_func=no])
536   ])
537
538   if test "x$grub_cv_cc_mflush_func" = xyes; then
539     TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
540   fi
541 fi
542
543
544 # Force no alignment to save space on i386.
545 if test "x$target_cpu" = xi386; then
546   AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
547     CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
548     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
549         [grub_cv_cc_falign_loop=yes],
550         [grub_cv_cc_falign_loop=no])
551   ])
552
553   AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
554     CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
555     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
556         [grub_cv_cc_malign_loop=yes],
557         [grub_cv_cc_malign_loop=no])
558   ])
559
560   if test "x$grub_cv_cc_falign_loop" = xyes; then
561     TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
562   elif test "x$grub_cv_cc_malign_loop" = xyes; then
563     TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
564   fi
565 fi
566
567 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
568     CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
569     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
570         [grub_cv_cc_freg_struct_return=yes],
571         [grub_cv_cc_freg_struct_return=no])
572 ])
573
574 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
575     TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
576 fi
577
578 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
579   # Some toolchains enable these features by default, but they need
580   # registers that aren't set up properly in GRUB.
581   TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
582 fi
583
584 # By default, GCC 4.4 generates .eh_frame sections containing unwind
585 # information in some cases where it previously did not. GRUB doesn't need
586 # these and they just use up vital space. Restore the old compiler
587 # behaviour.
588 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
589   CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
590   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
591       [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
592       [grub_cv_cc_fno_dwarf2_cfi_asm=no])
593 ])
594
595 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
596   TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
597 fi
598
599 if test x"$target_os" = xcygwin; then
600   AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
601     CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
602     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
603                       [grub_cv_cc_no_reorder_functions=yes],
604                       [grub_cv_cc_no_reorder_functions=no])
605   ])
606 fi
607
608 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
609   TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
610 fi
611
612 # By default, GCC 4.6 generates .eh_frame sections containing unwind
613 # information in some cases where it previously did not. GRUB doesn't need
614 # these and they just use up vital space. Restore the old compiler
615 # behaviour.
616 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
617   CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
618   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
619       [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
620       [grub_cv_cc_fno_asynchronous_unwind_tables=no])
621 ])
622
623 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
624   TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
625 fi
626
627 # For platforms where ELF is not the default link format.
628 case "${target_os}" in
629   cygwin)
630 # FIXME: put proper test here
631   NEED_REGISTER_FRAME_INFO=1
632   ;;
633   *) NEED_REGISTER_FRAME_INFO=0 ;;
634 esac
635
636
637 AC_ARG_ENABLE([efiemu],
638               [AS_HELP_STRING([--enable-efiemu],
639                              [build and install the efiemu runtimes (default=guessed)])])
640 if test x"$enable_efiemu" = xno ; then
641   efiemu_excuse="explicitly disabled"
642 fi
643 if test x"$target_os" = xcygwin ; then
644   efiemu_excuse="not available on cygwin"
645 fi
646 if test x"$target_cpu" != xi386 ; then
647   efiemu_excuse="only available on i386"
648 fi
649 if test x"$platform" = xefi ; then
650   efiemu_excuse="not available on efi"
651 fi
652 if test x"$efiemu_excuse" = x ; then
653   AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
654     CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
655     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
656                       [grub_cv_cc_efiemu=yes],
657                       [grub_cv_cc_efiemu=no])
658   ])
659   if test x$grub_cv_cc_efiemu = xno; then
660      efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
661   fi
662 fi
663 if test x"$efiemu_excuse" = x ; then
664   AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
665     grub_cv_target_cc_efiemu64_link_format=unknown
666     for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
667       CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
668       LDFLAGS="-m64 -Wl,$format -nostdlib -static"
669       AC_LINK_IFELSE([AC_LANG_PROGRAM([[
670       asm (".globl start; start:");
671       asm (".globl _start; _start:");
672       asm (".globl __start; __start:");
673       void __main (void);
674       void __main (void) {}
675       ]], [[]])], [flag=1], [flag=0])
676       if test x"$flag" = x1; then
677         grub_cv_target_cc_efiemu64_link_format="$format"
678         break;
679       fi
680     done])
681   if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
682     efiemu_excuse="no suitable link format for efiemu64 found"
683   else
684     EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
685   fi
686 fi
687 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
688   AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
689 fi
690 if test x"$efiemu_excuse" = x ; then
691 enable_efiemu=yes
692 else
693 enable_efiemu=no
694 fi
695 AC_SUBST([enable_efiemu])
696 AC_SUBST([EFIEMU64_LINK_FORMAT])
697
698 CFLAGS="$TARGET_CFLAGS"
699
700 if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
701   AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
702     grub_cv_target_cc_link_format=unknown
703     for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do
704       if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
705         continue
706       fi
707       CFLAGS="$TARGET_CFLAGS"
708       LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
709       AC_LINK_IFELSE([AC_LANG_PROGRAM([[
710       asm (".globl start; start:");
711       asm (".globl _start; _start:");
712       asm (".globl __start; __start:");
713       void __main (void);
714       void __main (void) {}
715       ]], [[]])], [flag=1], [flag=0])
716       if test x"$flag" = x1; then
717         grub_cv_target_cc_link_format="$format"
718         break;
719       fi
720     done])
721   if test x"$grub_cv_target_cc_link_format" = xunknown; then
722     AC_MSG_ERROR([no suitable link format found])
723   fi
724   TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
725   if test x"$grub_cv_target_cc_link_format" = x-mi386pe; then
726     TARGET_OBJ2ELF='./build-grub-pe2elf';
727   fi
728 fi
729
730 if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_cc_link_format = x-arch,x86_64; then
731    TARGET_APPLE_LINKER=1
732    AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
733    if test "x$TARGET_OBJCONV" = x ; then
734       AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
735    fi
736    if test "x$TARGET_OBJCONV" = x ; then
737       AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
738    fi
739    TARGET_IMG_LDSCRIPT=
740    TARGET_IMG_CFLAGS="-static"
741    TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
742    TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
743    TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
744    TARGET_LDFLAGS_OLDMAGIC=""
745 elif test x$grub_cv_target_cc_link_format = x-mi386pe && test x$platform = xpc; then
746   TARGET_APPLE_LINKER=0
747   TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
748   TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
749   TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
750   TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
751   TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
752   TARGET_IMG_CFLAGS=
753 else
754   TARGET_APPLE_LINKER=0
755   TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
756   TARGET_IMG_LDSCRIPT=
757   TARGET_IMG_LDFLAGS='-Wl,-N'
758   TARGET_IMG_LDFLAGS_AC='-Wl,-N'
759   TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
760   TARGET_IMG_CFLAGS=
761 fi
762
763 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
764
765
766 LDFLAGS="$TARGET_LDFLAGS"
767
768 if test "$target_cpu" = x86_64; then
769   # Use large model to support 4G memory
770   AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
771     CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
772     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
773                       [grub_cv_cc_mcmodel=yes],
774                       [grub_cv_cc_mcmodel=no])
775   ])
776   if test "x$grub_cv_cc_mcmodel" = xyes; then
777     TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
778   fi
779 fi
780
781 if test "$target_cpu"-"$platform" = x86_64-efi; then
782   # EFI writes to stack below %rsp, we must not use the red zone
783   AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
784     CFLAGS="$TARGET_CFLAGS -m64 -mno-red-zone"
785     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
786                       [grub_cv_cc_no_red_zone=yes],
787                       [grub_cv_cc_no_red_zone=no])
788   ])
789   if test "x$grub_cv_cc_no_red_zone" = xno; then
790     AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
791   fi
792
793   TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
794 fi
795
796 #
797 # Compiler features.
798 #
799
800 CFLAGS="$TARGET_CFLAGS"
801
802 # Position independent executable.
803 grub_CHECK_PIE
804 [# Need that, because some distributions ship compilers that include
805 # `-fPIE' in the default specs.
806 if [ x"$pie_possible" = xyes ]; then
807   TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
808 fi]
809
810 CFLAGS="$TARGET_CFLAGS"
811
812 # Position independent executable.
813 grub_CHECK_PIC
814 [# On most platforms we don't want PIC as it only makes relocations harder
815 # and code less efficient. On mips we want to have one got table per module
816 # and reload $gp in every function.
817 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
818 # However with clang we need PIC for this reloading to happen.
819 # Since default varies across dictributions use either -fPIC or -fno-PIC
820 # explicitly.
821 if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then
822    TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
823 elif [ x"$pic_possible" = xyes ]; then
824    TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
825 fi]
826
827 CFLAGS="$TARGET_CFLAGS"
828
829 # Smashing stack protector.
830 grub_CHECK_STACK_PROTECTOR
831 # Need that, because some distributions ship compilers that include
832 # `-fstack-protector' in the default specs.
833 if test "x$ssp_possible" = xyes; then
834   TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
835 fi
836
837 CFLAGS="$TARGET_CFLAGS"
838
839 grub_CHECK_STACK_ARG_PROBE
840 # Cygwin's GCC uses alloca() to probe the stackframe on static
841 # stack allocations above some threshold.
842 if test x"$sap_possible" = xyes; then
843   TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
844 fi
845
846 CFLAGS="$TARGET_CFLAGS"
847
848 # -mno-unaligned-access -mstrict-align
849 if test "$target_cpu" = arm; then
850   AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
851     grub_cv_target_cc_strict_align=unknown
852     for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
853       CFLAGS="$TARGET_CFLAGS $arg -Werror"
854       LDFLAGS="$TARGET_LDFLAGS"
855       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
856       if test x"$flag" = x1; then
857         grub_cv_target_cc_strict_align="$arg"
858         break;
859       fi
860     done])
861
862   if test x"$grub_cv_target_cc_strict_align" = xunknown; then
863     AC_MSG_ERROR([couldnt instruct compiler not to use unaligned access])
864   fi
865   TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
866   if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
867     TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
868   fi
869 fi
870
871 # Set them to their new values for the tests below.
872 CC="$TARGET_CC"
873 if test "x$TARGET_APPLE_LINKER" = x1 ; then
874 CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
875 else
876 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
877 fi
878 CPPFLAGS="$TARGET_CPPFLAGS"
879 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
880 TARGET_LIBGCC=
881 else
882 TARGET_LIBGCC=-lgcc
883 fi
884
885 LIBS="$TARGET_LIBGCC"
886
887 grub_ASM_USCORE
888 if test "x$TARGET_APPLE_LINKER" = x0 ; then
889 if test x$grub_cv_asm_uscore = xyes; then
890 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,_abort=_main"
891 else
892 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,abort=main"
893 fi
894 fi
895
896 # Check for libgcc symbols
897 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
898
899 if test "x$TARGET_APPLE_LINKER" = x1 ; then
900 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
901 else
902 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
903 fi
904 LIBS=""
905
906 # Defined in aclocal.m4.
907 grub_PROG_TARGET_CC
908 if test "x$TARGET_APPLE_LINKER" != x1 ; then
909 grub_PROG_OBJCOPY_ABSOLUTE
910 fi
911 grub_PROG_LD_BUILD_ID_NONE
912 if test "x$target_cpu" = xi386; then
913   if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
914     if test ! -z "$TARGET_IMG_LDSCRIPT"; then
915       # Check symbols provided by linker script.
916       CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000 -Wl,--defsym,___main=0x8100"
917     fi
918     grub_CHECK_BSS_START_SYMBOL
919     grub_CHECK_END_SYMBOL
920   fi
921   CFLAGS="$TARGET_CFLAGS"
922   grub_I386_ASM_PREFIX_REQUIREMENT
923   grub_I386_ASM_ADDR32
924 fi
925
926 grub_PROG_NM_WORKS
927 grub_PROG_NM_MINUS_P
928 grub_PROG_NM_DEFINED_ONLY
929 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
930 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
931
932 if test "$platform" != emu; then
933 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
934   SAVED_CPPFLAGS="$CPPFLAGS"
935   CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
936   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
937 #include <stddef.h>
938 int va_arg_func (int fixed, va_list args);]], [[]])],
939       [grub_cv_cc_isystem=yes],
940       [grub_cv_cc_isystem=no])
941   CPPFLAGS="$SAVED_CPPFLAGS"
942 ])
943
944 if test x"$grub_cv_cc_isystem" = xyes ; then
945   TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
946 fi
947 fi
948
949 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
950   CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
951   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
952 int va_arg_func (int fixed, va_list args);]], [[]])],
953       [grub_cv_cc_wtrampolines=yes],
954       [grub_cv_cc_wtrampolines=no])
955 ])
956
957 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
958   TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
959 fi
960
961 # Restore the flags.
962 CC="$tmp_CC"
963 CFLAGS="$tmp_CFLAGS"
964 CPPFLAGS="$tmp_CPPFLAGS"
965 LDFLAGS="$tmp_LDFLAGS"
966 LIBS="$tmp_LIBS"
967
968 #
969 # Check for options.
970 #
971
972 # Memory manager debugging.
973 AC_ARG_ENABLE([mm-debug],
974               AS_HELP_STRING([--enable-mm-debug],
975                              [include memory manager debugging]),
976               [AC_DEFINE([MM_DEBUG], [1],
977                          [Define to 1 if you enable memory manager debugging.])])
978
979 AC_ARG_ENABLE([cache-stats],
980               AS_HELP_STRING([--enable-cache-stats],
981                              [enable disk cache statistics collection]))
982
983 if test x$enable_cache_stats = xyes; then
984   DISK_CACHE_STATS=1
985 else
986   DISK_CACHE_STATS=0
987 fi
988 AC_SUBST([DISK_CACHE_STATS])
989
990 AC_ARG_ENABLE([boot-time],
991               AS_HELP_STRING([--enable-boot-time],
992                              [enable boot time statistics collection]))
993
994 if test x$enable_boot_time = xyes; then
995   BOOT_TIME_STATS=1
996 else
997   BOOT_TIME_STATS=0
998 fi
999 AC_SUBST([BOOT_TIME_STATS])
1000
1001 AC_ARG_ENABLE([grub-emu-usb],
1002               [AS_HELP_STRING([--enable-grub-emu-usb],
1003                              [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
1004
1005 AC_ARG_ENABLE([grub-emu-sdl],
1006               [AS_HELP_STRING([--enable-grub-emu-sdl],
1007                              [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
1008
1009 AC_ARG_ENABLE([grub-emu-pci],
1010               [AS_HELP_STRING([--enable-grub-emu-pci],
1011                              [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
1012
1013 if test "$platform" = emu; then
1014
1015 if test x"$enable_grub_emu_usb" != xyes ; then
1016    grub_emu_usb_excuse="not enabled"
1017 fi
1018
1019 if test x"$enable_grub_emu_pci" = xyes ; then
1020    grub_emu_usb_excuse="conflicts with PCI support"
1021 fi
1022
1023 [if [ x"$grub_emu_usb_excuse" = x ]; then
1024     # Check for libusb libraries.]
1025 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
1026     [grub_emu_usb_excuse=["need libusb library"]])
1027     AC_SUBST([LIBUSB])
1028 [fi]
1029 [if [ x"$grub_emu_usb_excuse" = x ]; then
1030     # Check for headers.]
1031     AC_CHECK_HEADERS([usb.h], [],
1032       [grub_emu_usb_excuse=["need libusb headers"]])
1033 [fi]
1034 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
1035   AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
1036 fi
1037 if test x"$grub_emu_usb_excuse" = x ; then
1038 enable_grub_emu_usb=yes
1039 else
1040 enable_grub_emu_usb=no
1041 fi
1042
1043 if test x"$enable_grub_emu_sdl" = xno ; then
1044   grub_emu_sdl_excuse="explicitely disabled"
1045 fi
1046 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1047     # Check for libSDL libraries.]
1048 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1049     [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1050     AC_SUBST([LIBSDL])
1051 [fi]
1052
1053 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1054     # Check for headers.]
1055     AC_CHECK_HEADERS([SDL/SDL.h], [],
1056       [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1057 [fi]
1058
1059 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1060   AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
1061 fi
1062 if test x"$grub_emu_sdl_excuse" = x ; then
1063 enable_grub_emu_sdl=yes
1064 else
1065 enable_grub_emu_sdl=no
1066 fi
1067
1068 if test x"$enable_grub_emu_pci" != xyes ; then
1069    grub_emu_pci_excuse="not enabled"
1070 fi
1071
1072 if test x"$enable_grub_emu_usb" = xyes ; then
1073    grub_emu_pci_excuse="conflicts with USB support"
1074 fi
1075
1076 [if [ x"$grub_emu_pci_excuse" = x ]; then
1077       # Check for libpci libraries.]
1078    AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1079       [grub_emu_pci_excuse=["need libpciaccess library"]])
1080     AC_SUBST([LIBPCIACCESS])
1081 [fi]
1082 [if [ x"$grub_emu_pci_excuse" = x ]; then
1083     # Check for headers.]
1084     AC_CHECK_HEADERS([pci/pci.h], [],
1085       [grub_emu_pci_excuse=["need libpciaccess headers"]])
1086 [fi]
1087
1088 if test x"$grub_emu_pci_excuse" = x ; then
1089 enable_grub_emu_pci=yes
1090 else
1091
1092 enable_grub_emu_pci=no
1093 fi
1094
1095 AC_SUBST([enable_grub_emu_sdl])
1096 AC_SUBST([enable_grub_emu_usb])
1097 AC_SUBST([enable_grub_emu_pci])
1098
1099 else
1100
1101 # Ignore --enable-emu-* if platform is not emu
1102 enable_grub_emu_sdl=no
1103 enable_grub_emu_usb=no
1104 enable_grub_emu_pci=no
1105 fi
1106
1107 AC_ARG_ENABLE([grub-mkfont],
1108               [AS_HELP_STRING([--enable-grub-mkfont],
1109                              [build and install the `grub-mkfont' utility (default=guessed)])])
1110 if test x"$enable_grub_mkfont" = xno ; then
1111   grub_mkfont_excuse="explicitly disabled"
1112 fi
1113
1114 if test x"$grub_mkfont_excuse" = x ; then
1115   # Check for freetype libraries.
1116   AC_CHECK_TOOLS([FREETYPE], [freetype-config])
1117   if test "x$FREETYPE" = x ; then
1118     grub_mkfont_excuse=["need freetype2 library"]
1119   fi
1120 fi
1121
1122 unset ac_cv_header_ft2build_h
1123
1124 if test x"$grub_mkfont_excuse" = x ; then
1125   # Check for freetype libraries.
1126   freetype_cflags=`$FREETYPE --cflags`
1127   freetype_libs=`$FREETYPE --libs`
1128   SAVED_CPPFLAGS="$CPPFLAGS"
1129   CPPFLAGS="$CPPFLAGS $freetype_cflags"
1130   AC_CHECK_HEADERS([ft2build.h], [],
1131         [grub_mkfont_excuse=["need freetype2 headers"]])
1132   CPPFLAGS="$SAVED_CPPFLAGS"
1133 fi
1134
1135 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1136   AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
1137 fi
1138 if test x"$grub_mkfont_excuse" = x ; then
1139 enable_grub_mkfont=yes
1140 else
1141 enable_grub_mkfont=no
1142 fi
1143 AC_SUBST([enable_grub_mkfont])
1144 AC_SUBST([freetype_cflags])
1145 AC_SUBST([freetype_libs])
1146
1147 SAVED_CC="$CC"
1148 SAVED_CPP="$CPP"
1149 SAVED_CFLAGS="$CFLAGS"
1150 SAVED_CPPFLAGS="$CPPFLAGS"
1151 CC="$BUILD_CC"
1152 CPP="$BUILD_CPP"
1153 CFLAGS="$BUILD_CFLAGS"
1154 CPPFLAGS="$BUILD_CPPFLAGS"
1155
1156 unset ac_cv_c_bigendian
1157 unset ac_cv_header_ft2build_h
1158
1159 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1160 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1161 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1162
1163 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1164    AC_MSG_ERROR([couldnt determine build endianness])
1165 fi
1166
1167 AC_SUBST([BUILD_SIZEOF_LONG])
1168 AC_SUBST([BUILD_SIZEOF_VOID_P])
1169 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1170
1171 if test x"$grub_build_mkfont_excuse" = x ; then
1172   # Check for freetype libraries.
1173   AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config])
1174   if test "x$BUILD_FREETYPE" = x ; then
1175     grub_build_mkfont_excuse=["need freetype2 library"]
1176   fi
1177 fi
1178
1179 if test x"$grub_build_mkfont_excuse" = x ; then
1180   # Check for freetype libraries.
1181   build_freetype_cflags=`$BUILD_FREETYPE --cflags`
1182   build_freetype_libs=`$BUILD_FREETYPE --libs`
1183   SAVED_CPPFLAGS_2="$CPPFLAGS"
1184   CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
1185   AC_CHECK_HEADERS([ft2build.h], [],
1186         [grub_build_mkfont_excuse=["need freetype2 headers"]])
1187   CPPFLAGS="$SAVED_CPPFLAGS_2"
1188 fi
1189
1190 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1191   AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled])
1192 fi
1193 if test x"$grub_build_mkfont_excuse" = x ; then
1194   enable_build_grub_mkfont=yes
1195 else
1196   enable_build_grub_mkfont=no
1197 fi
1198 if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
1199   AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports needs build-time grub-mkfont])
1200 fi
1201
1202 AC_SUBST([build_freetype_cflags])
1203 AC_SUBST([build_freetype_libs])
1204
1205 CC="$SAVED_CC"
1206 CPP="$SAVED_CPP"
1207 CFLAGS="$SAVED_CFLAGS"
1208 CPPFLAGS="$SAVED_CPPFLAGS"
1209
1210
1211 DJVU_FONT_SOURCE=
1212
1213 starfield_excuse=
1214
1215 AC_ARG_ENABLE([grub-themes],
1216               [AS_HELP_STRING([--enable-grub-themes],
1217                              [build and install GRUB themes (default=guessed)])])
1218 if test x"$enable_grub_themes" = xno ; then
1219   starfield_excuse="explicitly disabled"
1220 fi
1221
1222 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1223   starfield_excuse="No build-time grub-mkfont"
1224 fi
1225
1226 if test x"$starfield_excuse" = x; then
1227    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1228      for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
1229         if test -f "$dir/DejaVuSans.$ext"; then
1230           DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1231           break 2
1232         fi
1233      done
1234    done
1235
1236    if test "x$DJVU_FONT_SOURCE" = x; then
1237      starfield_excuse="No DejaVu found"
1238    fi
1239 fi
1240
1241 if test x"$enable_grub_themes" = xyes &&  test x"$starfield_excuse" != x; then
1242    AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied])
1243 fi
1244
1245 AC_SUBST([DJVU_FONT_SOURCE])
1246
1247 FONT_SOURCE=
1248
1249 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1250   for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do
1251     if test -f "$dir/unifont.$ext"; then
1252       FONT_SOURCE="$dir/unifont.$ext"
1253       break 2
1254     fi
1255   done
1256 done
1257
1258 if test x"$enable_build_grub_mkfont" = xno ; then
1259   FONT_SOURCE=
1260 fi
1261
1262 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
1263    AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports need unifont])
1264 fi
1265
1266 AC_SUBST([FONT_SOURCE])
1267
1268 if test x"$FONT_SOURCE" = x &&  test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1269   grub_build_mkfont_excuse="no fonts"
1270 fi
1271
1272
1273 AC_ARG_ENABLE([grub-mount],
1274               [AS_HELP_STRING([--enable-grub-mount],
1275                              [build and install the `grub-mount' utility (default=guessed)])])
1276 if test x"$enable_grub_mount" = xno ; then
1277   grub_mount_excuse="explicitly disabled"
1278 fi
1279
1280 if test x"$grub_mount_excuse" = x ; then
1281   AC_CHECK_LIB([fuse], [fuse_main_real], [],
1282                [grub_mount_excuse="need FUSE library"])
1283 fi
1284
1285 if test x"$grub_mount_excuse" = x ; then
1286   # Check for fuse headers.
1287   SAVED_CPPFLAGS="$CPPFLAGS"
1288   CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
1289   AC_CHECK_HEADERS([fuse/fuse.h], [],
1290         [grub_mount_excuse=["need FUSE headers"]])
1291   CPPFLAGS="$SAVED_CPPFLAGS"
1292 fi
1293
1294 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1295   AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
1296 fi
1297 if test x"$grub_mount_excuse" = x ; then
1298 enable_grub_mount=yes
1299 else
1300 enable_grub_mount=no
1301 fi
1302 AC_SUBST([enable_grub_mount])
1303
1304 AC_ARG_ENABLE([device-mapper],
1305               [AS_HELP_STRING([--enable-device-mapper],
1306                               [enable Linux device-mapper support (default=guessed)])])
1307 if test x"$enable_device_mapper" = xno ; then
1308   device_mapper_excuse="explicitly disabled"
1309 fi
1310
1311 if test x"$device_mapper_excuse" = x ; then
1312   # Check for device-mapper header.
1313   AC_CHECK_HEADER([libdevmapper.h], [],
1314                [device_mapper_excuse="need libdevmapper header"])
1315 fi
1316
1317 if test x"$device_mapper_excuse" = x ; then
1318   # Check for device-mapper library.
1319   AC_CHECK_LIB([devmapper], [dm_task_create], [],
1320                [device_mapper_excuse="need devmapper library"])
1321 fi
1322
1323 if test x"$device_mapper_excuse" = x ; then
1324   # Check for device-mapper library.
1325   AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1326                [],
1327                [device_mapper_excuse="need devmapper library"])
1328 fi
1329
1330 if test x"$device_mapper_excuse" = x ; then
1331    LIBDEVMAPPER="-ldevmapper";
1332    AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1333              [Define to 1 if you have the devmapper library.])
1334 fi
1335
1336 AC_SUBST([LIBDEVMAPPER])
1337
1338 LIBGEOM=
1339 if test x$host_kernel = xkfreebsd; then
1340   AC_CHECK_LIB([geom], [geom_gettree], [],
1341                [AC_MSG_ERROR([Your platform requires libgeom])])
1342   LIBGEOM="-lgeom"
1343 fi
1344
1345 AC_SUBST([LIBGEOM])
1346
1347 AC_ARG_ENABLE([liblzma],
1348               [AS_HELP_STRING([--enable-liblzma],
1349                               [enable liblzma integration (default=guessed)])])
1350 if test x"$enable_liblzma" = xno ; then
1351   liblzma_excuse="explicitly disabled"
1352 fi
1353
1354 if test x"$liblzma_excuse" = x ; then
1355 AC_CHECK_LIB([lzma], [lzma_code],
1356              [],[liblzma_excuse="need lzma library"])
1357 fi
1358 if test x"$liblzma_excuse" = x ; then
1359 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1360 fi
1361
1362 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1363   AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied])
1364 fi
1365
1366
1367 if test x"$liblzma_excuse" = x ; then
1368    LIBLZMA="-llzma"
1369    AC_DEFINE([USE_LIBLZMA], [1],
1370              [Define to 1 if you have the LZMA library.])
1371 fi
1372
1373 AC_SUBST([LIBLZMA])
1374
1375 AC_ARG_ENABLE([libzfs],
1376               [AS_HELP_STRING([--enable-libzfs],
1377                               [enable libzfs integration (default=guessed)])])
1378 if test x"$enable_libzfs" = xno ; then
1379   libzfs_excuse="explicitly disabled"
1380 fi
1381
1382 if test x"$libzfs_excuse" = x ; then
1383   # Only check for system headers if libzfs support has not been disabled.
1384   AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1385 fi
1386
1387 if test x"$libzfs_excuse" = x ; then
1388   AC_CHECK_LIB([zfs], [libzfs_init],
1389                [],
1390                [libzfs_excuse="need zfs library"])
1391 fi
1392
1393 if test x"$libzfs_excuse" = x ; then
1394   AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1395                [],
1396                [libzfs_excuse="need nvpair library"])
1397 fi
1398
1399 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1400   AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1401 fi
1402
1403 if test x"$libzfs_excuse" = x ; then
1404   # We need both libzfs and libnvpair for a successful build.
1405   LIBZFS="-lzfs"
1406   AC_DEFINE([HAVE_LIBZFS], [1],
1407             [Define to 1 if you have the ZFS library.])
1408   LIBNVPAIR="-lnvpair"
1409   AC_DEFINE([HAVE_LIBNVPAIR], [1],
1410             [Define to 1 if you have the NVPAIR library.])
1411 fi
1412
1413 AC_SUBST([LIBZFS])
1414 AC_SUBST([LIBNVPAIR])
1415
1416 LIBS=""
1417
1418 AC_SUBST([FONT_SOURCE])
1419 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1420             [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1421
1422 AC_SUBST(HAVE_ASM_USCORE)
1423 AC_SUBST(ADDR32)
1424 AC_SUBST(DATA32)
1425 AC_SUBST(BSS_START_SYMBOL)
1426 AC_SUBST(END_SYMBOL)
1427 AC_SUBST(PACKAGE)
1428 AC_SUBST(VERSION)
1429 AC_SUBST(NEED_REGISTER_FRAME_INFO)
1430
1431 AC_ARG_ENABLE([werror],
1432               [AS_HELP_STRING([--disable-werror],
1433                              [do not use -Werror when building GRUB])])
1434 if test x"$enable_werror" != xno ; then
1435   TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1436   HOST_CFLAGS="$HOST_CFLAGS -Werror"
1437 fi
1438
1439 if test "x$grub_cv_cc_target_clang" = xno; then
1440    TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
1441 else
1442    TARGET_LDFLAGS_STATIC_LIBGCC=
1443 fi
1444
1445 TARGET_CPP="$TARGET_CC -E"
1446 TARGET_CCAS=$TARGET_CC
1447
1448 GRUB_TARGET_CPU="${target_cpu}"
1449 GRUB_PLATFORM="${platform}"
1450
1451 AC_SUBST(GRUB_TARGET_CPU)
1452 AC_SUBST(GRUB_PLATFORM)
1453
1454 AC_SUBST(TARGET_OBJCONV)
1455 AC_SUBST(TARGET_LIBGCC)
1456 AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
1457 AC_SUBST(TARGET_CPP)
1458 AC_SUBST(TARGET_CCAS)
1459 AC_SUBST(TARGET_OBJ2ELF)
1460 AC_SUBST(TARGET_MODULE_FORMAT)
1461
1462 AC_SUBST(TARGET_CFLAGS)
1463 AC_SUBST(TARGET_LDFLAGS)
1464 AC_SUBST(TARGET_CPPFLAGS)
1465 AC_SUBST(TARGET_CCASFLAGS)
1466
1467 AC_SUBST(TARGET_IMG_LDSCRIPT)
1468 AC_SUBST(TARGET_IMG_LDFLAGS)
1469 AC_SUBST(TARGET_IMG_CFLAGS)
1470 AC_SUBST(TARGET_IMG_BASE_LDOPT)
1471 AC_SUBST(TARGET_APPLE_LINKER)
1472
1473 AC_SUBST(HOST_CFLAGS)
1474 AC_SUBST(HOST_LDFLAGS)
1475 AC_SUBST(HOST_CPPFLAGS)
1476 AC_SUBST(HOST_CCASFLAGS)
1477
1478 AC_SUBST(BUILD_LIBM)
1479
1480 #
1481 # Automake conditionals
1482 #
1483
1484 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1485 AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
1486 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1487 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1488 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1489 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1490 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1491 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1492 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1493 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1494 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1495 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
1496 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1497 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")"  -a x$platform = xqemu_mips])
1498 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")"  -a x$platform = xarc])
1499 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1500 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1501 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1502 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1503 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1504 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1505 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1506 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1507 AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
1508 AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
1509
1510 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1511 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1512 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1513 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1514 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1515 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1516 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1517
1518 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1519 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1520 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1521 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1522 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1523 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1524 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1525 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
1526 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1527 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1528 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1529
1530 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1531
1532 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1533 AM_CONDITIONAL([COND_CYGWIN], [test x$target_os = xcygwin])
1534 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1535 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
1536
1537 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
1538 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
1539 datarootdir="$(eval echo "$datarootdir")"
1540 grub_libdir="$(eval echo "$libdir")"
1541 grub_localedir="$(eval echo "$localedir")"
1542 grub_datadir="$(eval echo "$datadir")"
1543 grub_sysconfdir="$(eval echo "$sysconfdir")"
1544 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
1545 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
1546 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
1547 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
1548
1549
1550 # Output files.
1551 cpudir="${target_cpu}"
1552 if test x${cpudir} = xmipsel; then
1553   cpudir=mips;
1554 fi
1555 grub_CHECK_LINK_DIR
1556 if test x"$link_dir" = xyes ; then
1557   AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1558   if test "$platform" != emu ; then
1559     AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1560   fi
1561 else
1562   mkdir -p include/grub 2>/dev/null
1563   rm -rf include/grub/cpu
1564   cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1565   if test "$platform" != emu ; then
1566     rm -rf include/grub/machine
1567     cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1568   fi
1569 fi
1570
1571 AC_CONFIG_FILES([Makefile])
1572 AC_CONFIG_FILES([grub-core/Makefile])
1573 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1574 AC_CONFIG_FILES([po/Makefile.in])
1575 AC_CONFIG_FILES([docs/Makefile])
1576 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1577 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1578 AC_CONFIG_FILES([config.h])
1579
1580 AC_OUTPUT
1581 [
1582 echo "*******************************************************"
1583 echo GRUB2 will be compiled with following components:
1584 echo Platform: "$target_cpu"-"$platform"
1585 if [ x"$platform" = xemu ]; then
1586 if [ x"$grub_emu_usb_excuse" = x ]; then
1587 echo USB support for grub-emu: Yes
1588 else
1589 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1590 fi
1591 if [ x"$grub_emu_sdl_excuse" = x ]; then
1592 echo SDL support for grub-emu: Yes
1593 else
1594 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1595 fi
1596 if [ x"$grub_emu_pci_excuse" = x ]; then
1597 echo PCI support for grub-emu: Yes
1598 else
1599 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1600 fi
1601 fi
1602 if test x"$device_mapper_excuse" = x ; then
1603 echo With devmapper support: Yes
1604 else
1605 echo With devmapper support: No "($device_mapper_excuse)"
1606 fi
1607 if [ x"$enable_mm_debug" = xyes ]; then
1608 echo With memory debugging: Yes
1609 else
1610 echo With memory debugging: No
1611 fi
1612 if [ x"$enable_cache_stats" = xyes ]; then
1613 echo With disk cache statistics: Yes
1614 else
1615 echo With disk cache statistics: No
1616 fi
1617
1618 if [ x"$enable_boot_time" = xyes ]; then
1619 echo With boot time statistics: Yes
1620 else
1621 echo With boot time statistics: No
1622 fi
1623
1624 if [ x"$efiemu_excuse" = x ]; then
1625 echo efiemu runtime: Yes
1626 else
1627 echo efiemu runtime: No "($efiemu_excuse)"
1628 fi
1629 if [ x"$grub_mkfont_excuse" = x ]; then
1630 echo grub-mkfont: Yes
1631 else
1632 echo grub-mkfont: No "($grub_mkfont_excuse)"
1633 fi
1634 if [ x"$grub_mount_excuse" = x ]; then
1635 echo grub-mount: Yes
1636 else
1637 echo grub-mount: No "($grub_mount_excuse)"
1638 fi
1639 if [ x"$starfield_excuse" = x ]; then
1640 echo starfield theme: Yes
1641 else
1642 echo starfield theme: No "($starfield_excuse)"
1643 fi
1644 if [ x"$libzfs_excuse" = x ]; then
1645 echo With libzfs support: Yes
1646 else
1647 echo With libzfs support: No "($libzfs_excuse)"
1648 fi
1649 if [ x"$grub_build_mkfont_excuse" = x ]; then
1650   echo Build-time grub-mkfont: Yes
1651   if test "x$FONT_SOURCE" = x ; then
1652     echo "Without unifont"
1653   else
1654     echo "With unifont from $FONT_SOURCE"
1655   fi
1656 else
1657   echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
1658   echo "Without unifont (no build-time grub-mkfont)"
1659 fi
1660 if test x"$liblzma_excuse" != x ; then
1661 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
1662 else
1663 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
1664 fi
1665 echo "*******************************************************"
1666 ]