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