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