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