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