]> git.proxmox.com Git - grub2.git/blame - configure.ac
arm64: align linux kernel magic macro naming with i386
[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
e54c99aa 34AC_INIT([GRUB],[2.02],[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
3eec9111
CW
53# Explicitly check for pkg-config early on, since otherwise conditional
54# calls are problematic.
55PKG_PROG_PKG_CONFIG
56
1d543c3e 57# Program name transformations
58AC_ARG_PROGRAM
fd49ceb3
CW
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])
67ab8353 65grub_TRANSFORM([grub-glue-efi])
fd49ceb3
CW
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])
fd49ceb3 74grub_TRANSFORM([grub-sparc64-setup])
a79b8a15 75grub_TRANSFORM([grub-render-label])
ec824e0f 76grub_TRANSFORM([grub-file])
1d543c3e 77
90d1e879
RM
78# Optimization flag. Allow user to override.
79if test "x$TARGET_CFLAGS" = x; then
80 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
81fi
82
76ed06b9
BC
83# Default HOST_CPPFLAGS
84HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
76ed06b9 85HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
76ed06b9
BC
86
87TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
76ed06b9 88
b977bf01 89case "$target_cpu" in
02164e1b 90 i[[3456]]86) target_cpu=i386 ;;
c7ef54aa 91 amd64) target_cpu=x86_64 ;;
02164e1b 92 sparc) target_cpu=sparc64 ;;
ade85305 93 mipsel|mips64el)
4d94b2db
CW
94 target_cpu=mipsel
95 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
4a1eefb6 96 ;;
ade85305 97 mips|mips64)
4d94b2db
CW
98 target_cpu=mips
99 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
4a1eefb6 100 ;;
389b31cd 101 arm*)
4d94b2db 102 target_cpu=arm
389b31cd 103 ;;
15a463d7 104 aarch64*)
4d94b2db 105 target_cpu=arm64
15a463d7 106 ;;
6a161fa9 107esac
108
05568c2e 109# Specify the platform (such as firmware).
110AC_ARG_WITH([platform],
111 AS_HELP_STRING([--with-platform=PLATFORM],
83b984de 112 [select the host platform [[guessed]]]))
05568c2e 113
114# Guess the platform if not specified.
115if test "x$with_platform" = x; then
b977bf01 116 case "$target_cpu"-"$target_vendor" in
05568c2e 117 i386-apple) platform=efi ;;
118 i386-*) platform=pc ;;
58393a2d 119 x86_64-apple) platform=efi ;;
737feb35 120 x86_64-*) platform=pc ;;
05568c2e 121 powerpc-*) platform=ieee1275 ;;
58393a2d 122 powerpc64-*) platform=ieee1275 ;;
5c46165a 123 powerpc64le-*) platform=ieee1275 ;;
05568c2e 124 sparc64-*) platform=ieee1275 ;;
4959e111
VS
125 mipsel-*) platform=loongson ;;
126 mips-*) platform=arc ;;
e68d3b24 127 ia64-*) platform=efi ;;
389b31cd 128 arm-*) platform=uboot ;;
15a463d7 129 arm64-*) platform=efi ;;
5d90f6e5
CW
130 *)
131 AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
132 platform=none
133 ;;
05568c2e 134 esac
135else
136 platform="$with_platform"
137fi
138
ec1dfd63
VS
139case "$target_cpu"-"$platform" in
140 x86_64-efi) ;;
141 x86_64-emu) ;;
9612ebc0 142 x86_64-xen) ;;
5d90f6e5 143 x86_64-none) ;;
ec1dfd63
VS
144 x86_64-*) target_cpu=i386 ;;
145 powerpc64-ieee1275) target_cpu=powerpc ;;
5c46165a 146 powerpc64le-ieee1275) target_cpu=powerpc ;;
ec1dfd63 147esac
20011694 148
58393a2d 149# Check if the platform is supported, make final adjustments.
b977bf01 150case "$target_cpu"-"$platform" in
05568c2e 151 i386-efi) ;;
3f4ce737 152 x86_64-efi) ;;
9612ebc0
VS
153 i386-xen) ;;
154 x86_64-xen) ;;
05568c2e 155 i386-pc) ;;
7210dca9 156 i386-multiboot) ;;
546f966a 157 i386-coreboot) ;;
58393a2d 158 i386-linuxbios) platform=coreboot ;;
3d04eab8 159 i386-ieee1275) ;;
8231fb77 160 i386-qemu) ;;
05568c2e 161 powerpc-ieee1275) ;;
162 sparc64-ieee1275) ;;
2c40cc78 163 ia64-efi) ;;
f440c33f 164 mips-qemu_mips) ;;
3666d5f6 165 mips-qemu-mips) platform=qemu_mips;;
8906c3dd 166 mips-arc) ;;
7f63a64f 167 mipsel-arc) ;;
4959e111
VS
168 mipsel-qemu_mips) ;;
169 mipsel-qemu-mips) platform=qemu_mips;;
170 mipsel-yeeloong) platform=loongson ;;
171 mipsel-fuloong) platform=loongson ;;
172 mipsel-loongson) ;;
389b31cd
LL
173 arm-uboot) ;;
174 arm-efi) ;;
15a463d7 175 arm64-efi) ;;
f84b481b 176 *-emu) ;;
5d90f6e5 177 *-none) ;;
58393a2d 178 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
6a161fa9 179esac
180
48145ea3 181if test x$platform != xemu ; then
dd614590
VS
182 case "$target_cpu" in
183 i386 | powerpc) target_m32=1 ;;
184 x86_64 | sparc64) target_m64=1 ;;
185 esac
186fi
3f4ce737 187
eaf01c25 188if test x"$target_cpu-$platform" = xsparc64-emu ; then
4d94b2db 189 target_m64=1
eaf01c25
VS
190fi
191
fc97214f 192case "$target_os" in
c3302aa5 193 windows* | mingw32*) target_os=cygwin ;;
fc97214f
VS
194esac
195
9304eef1 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 ;;
67937d4d 202 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
2c7031b1 203 netbsd*) host_kernel=netbsd ;;
958ee221 204 solaris*) host_kernel=illumos ;;
b105df76 205 darwin*) host_kernel=xnu ;;
7e518ca8 206 cygwin | windows* | mingw32*) host_kernel=windows ;;
9304eef1 207esac
208
cd46aa6c
VS
209case "$host_os" in
210 cygwin | windows* | mingw32*) have_exec=n ;;
211 aros*) have_exec=n ;;
212 *) have_exec=y;;
213esac
214
f84b481b 215case "$platform" in
c721825b
BC
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" ;;
9612ebc0 219 xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
c721825b 220 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
389b31cd 221 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
c721825b
BC
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" ;;
0c930a84
VS
225 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
226 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
3666d5f6 227 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
f84b481b 228esac
4959e111
VS
229if test x${target_cpu} = xmipsel ; then
230 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
231else
0c930a84 232 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
4959e111 233fi
6bea3f89 234
7f63a64f
VS
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 ;;
5fe67f39 244 mips*-qemu_mips | mips*-loongson)
7f63a64f
VS
245 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
246 ;;
247esac
248
249AC_SUBST(TARGET_LINK_ADDR)
250AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
251
c721825b 252TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
f84b481b 253
56978920 254AC_SUBST(host_cpu)
255AC_SUBST(host_os)
9304eef1 256AC_SUBST(host_kernel)
6e5a42fe 257
071114bb
VS
258AC_SUBST(target_cpu)
259AC_SUBST(platform)
260
d87aedff 261# Define default variables
7134247c
VS
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*)
d87aedff 274 # Because /boot is used for the boot block in NetBSD and OpenBSD,
7134247c
VS
275 bootdirname='' ;;
276 *) bootdirname='boot' ;;
277 esac
278fi
279
d87aedff 280AC_SUBST(bootdirname)
a4c1d277
YB
281AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
282 [Default boot directory name]")
d87aedff 283
7134247c
VS
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
d87aedff 290AC_SUBST(grubdirname)
a4c1d277
YB
291AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
292 [Default grub directory name])
d87aedff 293
b977bf01 294#
295# Checks for build programs.
296#
144f1f98 297
6c826348 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
144f1f98 305AC_CHECK_PROGS([YACC], [bison])
1569ec51 306if test "x$YACC" = x; then
6c826348 307 AC_MSG_ERROR([bison is not found])
1569ec51 308fi
309
76ed06b9 310AC_PROG_RANLIB
b977bf01 311AC_PROG_INSTALL
312AC_PROG_AWK
09220190 313AC_PROG_LEX
76ed06b9 314AC_PROG_YACC
b977bf01 315AC_PROG_MAKE_SET
ff420223 316AC_PROG_MKDIR_P
e1fd1939 317AC_PROG_LN_S
b977bf01 318
c7c75cf4 319if test "x$LEX" = "x:"; then
09220190
BC
320 AC_MSG_ERROR([flex is not found])
321else
a2618427 322 version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
b777c18e 323 if test -n "$version" -a "$version" -ge 20535; then
09220190
BC
324 :
325 else
326 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
327 fi
328fi
329
68807e5f 330# These are not a "must".
51fa856c 331AC_PATH_PROGS(MAKEINFO, makeinfo true)
6a161fa9 332
b977bf01 333#
334# Checks for host programs.
335#
336
337AC_PROG_CC
15c69261 338gl_EARLY
1eed0e6e 339AC_PROG_CXX
76ed06b9
BC
340AM_PROG_CC_C_O
341AM_PROG_AS
342
6a161fa9 343# Must be GCC.
344test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
345
1eed0e6e
VS
346AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
347
4889bdec 348AC_GNU_SOURCE
2f1a3acf 349AM_GNU_GETTEXT([external])
b977bf01 350AC_SYS_LARGEFILE
351
352# Identify characteristics of the host architecture.
7b780018
VS
353unset ac_cv_c_bigendian
354
eaf01c25
VS
355if test x"$target_cpu-$platform" = xsparc64-emu ; then
356 CFLAGS="$CFLAGS -m64"
357 HOST_CFLAGS="$HOST_CFLAGS -m64"
358fi
359
fc7a64bc
VS
360CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
361HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
362
b977bf01 363AC_C_BIGENDIAN
364AC_CHECK_SIZEOF(void *)
365AC_CHECK_SIZEOF(long)
366
7e518ca8
VS
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
3bac4caa
FJ
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
aad32b14
VS
383if test x$USE_NLS = xno; then
384 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
385fi
386
86695375 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
3169f4c7 393# Check for functions and headers.
0f7e980b 394AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
7a5b301e 395AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
07662af7
AB
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"
7a5b301e 402AC_HEADER_MAJOR
07662af7 403CFLAGS="$SAVED_CFLAGS"
7c4e16ff 404
fb90b546
RM
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
2c7031b1
GS
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
19ce697d 427AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
00c05e22 428 SAVED_CFLAGS="$CFLAGS"
b35ec299 429 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
00c05e22
VS
430 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
431int va_arg_func (int fixed, va_list args);]], [[]])],
19ce697d
VS
432 [grub_cv_host_cc_wtrampolines=yes],
433 [grub_cv_host_cc_wtrampolines=no])
00c05e22
VS
434 CFLAGS="$SAVED_CFLAGS"
435])
436
19ce697d
VS
437if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
438 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
00c05e22
VS
439fi
440
76ed06b9
BC
441#
442# Check for host and build compilers.
443#
444HOST_CC=$CC
816719c8
VS
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.])
b224c266 447BUILD_CPP="$BUILD_CC -E"
76ed06b9 448
29013cba
VS
449case "$build_os" in
450 haiku*) BUILD_LIBM= ;;
451 *) BUILD_LIBM=-lm ;;
452esac
1ecf96fc
AB
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
15c69261
YB
463# For gnulib.
464gl_INIT
465
93bf55e6 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"
ae558c2c 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"
60d5e9cb
VS
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
b977bf01 486#
487# Check for target programs.
488#
489
5b5d4aa5 490# Find tools for the target.
491if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
b977bf01 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.])])
fc97214f
VS
497 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
498 AC_CHECK_TOOL(TARGET_STRIP, strip)
499 AC_CHECK_TOOL(TARGET_NM, nm)
0e8daad0 500 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
b977bf01 501
502 ac_tool_prefix="$tmp_ac_tool_prefix"
503else
504 if test "x$TARGET_CC" = x; then
505 TARGET_CC=$CC
506 fi
fc97214f
VS
507 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
508 AC_CHECK_TOOL(TARGET_STRIP, strip)
509 AC_CHECK_TOOL(TARGET_NM, nm)
0e8daad0 510 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
b977bf01 511fi
fc97214f 512
76ed06b9
BC
513AC_SUBST(HOST_CC)
514AC_SUBST(BUILD_CC)
7c9d0c39
VS
515AC_SUBST(BUILD_CFLAGS)
516AC_SUBST(BUILD_CPPFLAGS)
dcecae1a 517AC_SUBST(BUILD_LDFLAGS)
b977bf01 518AC_SUBST(TARGET_CC)
fc97214f 519AC_SUBST(TARGET_NM)
1bd73025 520AC_SUBST(TARGET_RANLIB)
fc97214f
VS
521AC_SUBST(TARGET_STRIP)
522AC_SUBST(TARGET_OBJCOPY)
b977bf01 523
b977bf01 524# Test the C compiler for the target environment.
525tmp_CC="$CC"
526tmp_CFLAGS="$CFLAGS"
527tmp_LDFLAGS="$LDFLAGS"
528tmp_CPPFLAGS="$CPPFLAGS"
aa6d7826 529tmp_LIBS="$LIBS"
b977bf01 530CC="$TARGET_CC"
531CFLAGS="$TARGET_CFLAGS"
532CPPFLAGS="$TARGET_CPPFLAGS"
533LDFLAGS="$TARGET_LDFLAGS"
aa6d7826 534LIBS=""
b977bf01 535
90d1e879 536# debug flags.
4e27343f 537TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
76ed06b9 538TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
6a161fa9 539
c12936c5
VS
540if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
541TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
542fi
543
6a7957f9
VS
544TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
545
60d5e9cb
VS
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"
37378f74
VS
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])
60d5e9cb
VS
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
86f05f14 566AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
b73b70eb
VS
567[
568CFLAGS="$TARGET_CFLAGS"
569AC_COMPILE_IFELSE(
60375a88
VS
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
a3645c12 577if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
5c46165a
VS
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
a3645c12
AB
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
5c46165a
VS
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:");
a3645c12
AB
592asm (".globl _start; _start:");
593asm (".globl __start; __start:");
5c46165a
VS
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"
a3645c12
AB
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"
5c46165a
VS
647fi
648
be25d921
AB
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
065ad910
VS
683AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
684test_program=
f16b8c04
VS
685case "x$target_cpu-$platform" in
686 xmips-* | xmipsel-*)
065ad910
VS
687 test_program=mips
688 ;;
f16b8c04
VS
689 xi386-pc)
690 test_program=i386-pc
691 ;;
692 xi386-* | xx86_64-*)
065ad910
VS
693 test_program=i386
694 ;;
f16b8c04 695 xpowerpc-* | xsparc64-* | xarm-*)
065ad910
VS
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
60375a88 715fi
065ad910 716])
60375a88 717
065ad910 718TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
b73b70eb 719
60375a88
VS
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
f93ddcfd
VS
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
90d1e879
RM
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], [
b35ec299 764 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
eb73121d 765 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
90d1e879
RM
766 [grub_cv_cc_falign_loop=yes],
767 [grub_cv_cc_falign_loop=no])
6a161fa9 768 ])
6a161fa9 769
c966a489 770 AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
b35ec299 771 CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
c966a489
VS
772 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
773 [grub_cv_cc_malign_loop=yes],
774 [grub_cv_cc_malign_loop=no])
775 ])
776
90d1e879
RM
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"
c966a489 779 elif test "x$grub_cv_cc_malign_loop" = xyes; then
90d1e879 780 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
6a161fa9 781 fi
89e0240c 782fi
6a161fa9 783
cdc17f60
VS
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
ee0220bc 795if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
90d1e879
RM
796 # Some toolchains enable these features by default, but they need
797 # registers that aren't set up properly in GRUB.
cd6d79cd 798 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
90d1e879 799fi
77c55a87 800
3661261f
VS
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.
ebe316e4
VS
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
43d42314 809 CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
ebe316e4 810 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
43d42314 811 [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
ebe316e4 812 fi
ea39b87a
VS
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
6a4ecd27
VS
818 for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
819 "-Xclang -msoft-float -Xclang -no-implicit-float" \
ebe316e4
VS
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
6a4ecd27 835 x*"-Xclang"*)
ebe316e4
VS
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
43d42314 843 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
345076a7 844
2da4171e 845fi
3661261f 846
155f334f
VS
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"
aa6ccc05 856 CPPFLAGS="$TARGET_CPPFLAGS"
155f334f
VS
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
90d1e879
RM
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], [
24f4e57c 902 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
90d1e879
RM
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])
90d1e879 906])
77c55a87 907
90d1e879
RM
908if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
909 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
b977bf01 910fi
6a161fa9 911
1c1f31e5
VS
912if test x"$target_os" = xcygwin; then
913 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
24f4e57c 914 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
1c1f31e5
VS
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
f1b35253
VS
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
e9d3421c
VS
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], [
5ae590b3 942 CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
e9d3421c
VS
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])
e9d3421c
VS
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
40051fed
VS
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
30c7d3ce 963
a9f25a08
VS
964CFLAGS="$TARGET_CFLAGS"
965
bf082198
VS
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
4d94b2db
CW
977 grub_cv_target_cc_link_format=-mi386pe
978 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
bf082198
VS
979 fi
980 if test x${target_cpu} = xx86_64 ; then
4d94b2db
CW
981 grub_cv_target_cc_link_format=-mi386pep
982 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
bf082198
VS
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
c2b70d09 988 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
a9f25a08 989 grub_cv_target_cc_link_format=unknown
6f1f6a0c 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
bf082198 991 if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
6f1f6a0c
VS
992 continue
993 fi
bf082198 994 if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
a9f25a08
VS
995 continue
996 fi
246a434f
VS
997 CFLAGS="$TARGET_CFLAGS"
998 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
a9f25a08
VS
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) {}
c2b70d09 1005 ]], [[]])], [flag=1], [flag=0])
a9f25a08
VS
1006 if test x"$flag" = x1; then
1007 grub_cv_target_cc_link_format="$format"
4d94b2db 1008 break
a9f25a08
VS
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"
6f1f6a0c 1015 if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
4d94b2db 1016 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
a9f25a08 1017 fi
6f1f6a0c 1018 if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
4d94b2db 1019 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
6f1f6a0c 1020 fi
a9f25a08
VS
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=""
6f1f6a0c 1038elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
a9f25a08
VS
1039 TARGET_APPLE_LINKER=0
1040 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
60b967be 1041 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
a9f25a08 1042 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
60b967be 1043 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
a9f25a08
VS
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
80fdaf1d
VS
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
a9f25a08
VS
1123AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
1124
1125
1126LDFLAGS="$TARGET_LDFLAGS"
8f0baaac 1127
155f334f 1128if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
7e9ca17a 1129 # Use large model to support 4G memory
6e09b8b7 1130 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
2a5a532c 1131 CFLAGS="$TARGET_CFLAGS -mcmodel=large"
6e09b8b7 1132 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1133 [grub_cv_cc_mcmodel=yes],
1134 [grub_cv_cc_mcmodel=no])
1135 ])
a3ba7410 1136 if test "x$grub_cv_cc_mcmodel" = xyes; then
c8600122 1137 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
155f334f 1138 elif test "$target_cpu" = sparc64; then
eaf01c25 1139 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
6e09b8b7 1140 fi
46546fc5 1141fi
7e9ca17a 1142
46546fc5 1143if test "$target_cpu"-"$platform" = x86_64-efi; then
7e9ca17a 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, [
2a5a532c 1146 CFLAGS="$TARGET_CFLAGS -mno-red-zone"
7e9ca17a 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
c8600122 1155 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
20011694 1156fi
1157
41822625 1158if test "x$target_cpu" = xarm; then
d15f17b2
VS
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
bf9c5616 1171 ])
d15f17b2
VS
1172
1173 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
bf9c5616 1174 # A trick so that clang doesn't see it on link stage
d15f17b2 1175 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt"
bf9c5616 1176 fi
a29f317a
VS
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"
2066c35b 1185 # Clang defaults to thumb interworking
a29f317a
VS
1186 elif test "x$grub_cv_cc_target_clang" = xno ; then
1187 AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
a29f317a 1188 fi
41822625
VS
1189fi
1190
57bc5d43
VS
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
baa2a121 1200#
1201# Compiler features.
1202#
1203
28668d80
VS
1204CFLAGS="$TARGET_CFLAGS"
1205
93a81088 1206# Position independent executable.
1207grub_CHECK_PIE
a3e9da05 1208grub_CHECK_NO_PIE
b53f595b
VS
1209grub_CHECK_NO_PIE_ONEWORD
1210grub_CHECK_LINK_PIE
93a81088 1211[# Need that, because some distributions ship compilers that include
a3e9da05 1212# `-fPIE' or '-fpie' and '-pie' in the default specs.
93a81088 1213if [ x"$pie_possible" = xyes ]; then
f4d35d49 1214 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
a3e9da05 1215fi
b53f595b
VS
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
93a81088 1224fi]
1225
28668d80 1226CFLAGS="$TARGET_CFLAGS"
a3e9da05 1227LDFLAGS="$TARGET_LDFLAGS"
28668d80 1228
7bd8b0c7
VS
1229# Position independent executable.
1230grub_CHECK_PIC
9cf12b20
VS
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.
393cc591
VS
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.
9cf12b20
VS
1239# Since default varies across dictributions use either -fPIC or -fno-PIC
1240# explicitly.
393cc591 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
9cf12b20
VS
1242 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
1243elif [ x"$pic_possible" = xyes ]; then
1244 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
7bd8b0c7
VS
1245fi]
1246
28668d80
VS
1247CFLAGS="$TARGET_CFLAGS"
1248
baa2a121 1249# Smashing stack protector.
1250grub_CHECK_STACK_PROTECTOR
c3db8364 1251# Need that, because some distributions ship compilers that include
baa2a121 1252# `-fstack-protector' in the default specs.
c3db8364 1253if test "x$ssp_possible" = xyes; then
1254 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
1255fi
28668d80
VS
1256
1257CFLAGS="$TARGET_CFLAGS"
1258
2a8a80e4 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
baa2a121 1265
28668d80
VS
1266CFLAGS="$TARGET_CFLAGS"
1267
d74b9a1d 1268# -mno-unaligned-access -mstrict-align
bb9f92b9 1269if test "$target_cpu" = arm; then
d74b9a1d 1270 AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
bdb6090d 1271 grub_cv_target_cc_strict_align=
d74b9a1d
VS
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"
4d94b2db 1278 break
d74b9a1d
VS
1279 fi
1280 done])
1281
d74b9a1d
VS
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"
bb9f92b9 1285 fi
bdb6090d
VS
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
bb9f92b9
LL
1297fi
1298
aa6d7826 1299# Set them to their new values for the tests below.
1300CC="$TARGET_CC"
064360e6
VS
1301if test x"$platform" = xemu ; then
1302CFLAGS="$TARGET_CFLAGS -Wno-error"
1303elif test "x$TARGET_APPLE_LINKER" = x1 ; then
246a434f 1304CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
26de2bcd 1305else
37378f74 1306CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
26de2bcd 1307fi
aa6d7826 1308CPPFLAGS="$TARGET_CPPFLAGS"
d5524ca8 1309
01fcf061 1310grub_ASM_USCORE
064360e6 1311if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
01fcf061 1312if test x$grub_cv_asm_uscore = xyes; then
37378f74 1313DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
01fcf061 1314else
37378f74 1315DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main"
01fcf061 1316fi
37378f74 1317CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
a9f25a08 1318fi
01fcf061 1319
69be5b74 1320# Check for libgcc symbols
064360e6 1321if test x"$platform" = xemu; then
ca73ae44 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)
064360e6 1323fi
69be5b74 1324
a9f25a08 1325if test "x$TARGET_APPLE_LINKER" = x1 ; then
246a434f 1326CFLAGS="$TARGET_CFLAGS -nostdlib -static"
69be5b74 1327else
37378f74 1328CFLAGS="$TARGET_CFLAGS -nostdlib"
69be5b74 1329fi
42e0cba3 1330LIBS=""
aa6d7826 1331
6a161fa9 1332# Defined in aclocal.m4.
f6130a12 1333grub_PROG_TARGET_CC
a9f25a08 1334if test "x$TARGET_APPLE_LINKER" != x1 ; then
b977bf01 1335grub_PROG_OBJCOPY_ABSOLUTE
2b167a72 1336fi
cb71ba20 1337grub_PROG_LD_BUILD_ID_NONE
b977bf01 1338if test "x$target_cpu" = xi386; then
a9f25a08 1339 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
2aec1692
CF
1340 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
1341 # Check symbols provided by linker script.
37378f74 1342 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
2aec1692 1343 fi
2a8a80e4 1344 grub_CHECK_BSS_START_SYMBOL
1345 grub_CHECK_END_SYMBOL
1346 fi
1347 CFLAGS="$TARGET_CFLAGS"
6a161fa9 1348fi
1349
20aea949
VS
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
016a671b 1356if test "$platform" != emu; then
8f9a632b
VS
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>
ce938140 1361#include <stddef.h>
8f9a632b
VS
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
dae79b6b 1371fi
5ce5507f 1372
19ce697d 1373AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
24f4e57c 1374 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
779dc15b
VS
1375 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1376int va_arg_func (int fixed, va_list args);]], [[]])],
19ce697d
VS
1377 [grub_cv_cc_wtrampolines=yes],
1378 [grub_cv_cc_wtrampolines=no])
779dc15b
VS
1379])
1380
19ce697d
VS
1381if test x"$grub_cv_cc_wtrampolines" = xyes ; then
1382 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
779dc15b
VS
1383fi
1384
c9a86192 1385# Restore the flags.
9962ed99 1386CC="$tmp_CC"
1387CFLAGS="$tmp_CFLAGS"
1388CPPFLAGS="$tmp_CPPFLAGS"
c9a86192 1389LDFLAGS="$tmp_LDFLAGS"
aa6d7826 1390LIBS="$tmp_LIBS"
6a161fa9 1391
4fe9862e 1392#
2965c7cc 1393# Check for options.
4fe9862e 1394#
1395
1396# Memory manager debugging.
b39f9d20 1397AC_ARG_ENABLE([mm-debug],
2965c7cc 1398 AS_HELP_STRING([--enable-mm-debug],
90ce5d56 1399 [include memory manager debugging]),
2965c7cc 1400 [AC_DEFINE([MM_DEBUG], [1],
1401 [Define to 1 if you enable memory manager debugging.])])
1402
c5dc1690
SJ
1403AC_ARG_ENABLE([cache-stats],
1404 AS_HELP_STRING([--enable-cache-stats],
055e2b8b 1405 [enable disk cache statistics collection]))
c5dc1690
SJ
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
e744219b
VS
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
927d0134
VS
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
3affd0ec 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
f84b481b 1433if test "$platform" = emu; then
f84b481b 1434
927d0134 1435if test x"$enable_grub_emu_sdl" = xno ; then
16f7455b 1436 grub_emu_sdl_excuse="explicitly disabled"
927d0134
VS
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]
9f293ab0 1444
927d0134
VS
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]
9f293ab0 1450
927d0134 1451if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
16f7455b 1452 AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
927d0134
VS
1453fi
1454if test x"$grub_emu_sdl_excuse" = x ; then
1455enable_grub_emu_sdl=yes
1456else
1457enable_grub_emu_sdl=no
1458fi
1459
3affd0ec 1460if test x"$enable_grub_emu_pci" != xyes ; then
325c8258 1461 grub_emu_pci_excuse="not enabled"
1462fi
1463
325c8258 1464[if [ x"$grub_emu_pci_excuse" = x ]; then
1465 # Check for libpci libraries.]
459fed4b 1466 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1467 [grub_emu_pci_excuse=["need libpciaccess library"]])
1468 AC_SUBST([LIBPCIACCESS])
325c8258 1469[fi]
1470[if [ x"$grub_emu_pci_excuse" = x ]; then
1471 # Check for headers.]
5959b15c 1472 AC_CHECK_HEADERS([pciaccess.h], [],
459fed4b 1473 [grub_emu_pci_excuse=["need libpciaccess headers"]])
325c8258 1474[fi]
1475
1476if test x"$grub_emu_pci_excuse" = x ; then
1477enable_grub_emu_pci=yes
1478else
9f293ab0 1479
325c8258 1480enable_grub_emu_pci=no
3affd0ec 1481fi
1482
927d0134 1483AC_SUBST([enable_grub_emu_sdl])
3affd0ec 1484AC_SUBST([enable_grub_emu_pci])
e7d09ac4
AB
1485
1486else
1487
1488# Ignore --enable-emu-* if platform is not emu
1489enable_grub_emu_sdl=no
e7d09ac4 1490enable_grub_emu_pci=no
f84b481b 1491fi
4fe9862e 1492
e52db1f7 1493AC_ARG_ENABLE([grub-mkfont],
1494 [AS_HELP_STRING([--enable-grub-mkfont],
5ce5507f 1495 [build and install the `grub-mkfont' utility (default=guessed)])])
1496if test x"$enable_grub_mkfont" = xno ; then
ce7a733d 1497 grub_mkfont_excuse="explicitly disabled"
5ce5507f 1498fi
1499
7b780018
VS
1500unset ac_cv_header_ft2build_h
1501
660960d6
VS
1502if test x"$grub_mkfont_excuse" = x ; then
1503 # Check for freetype libraries.
3eec9111
CW
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"]])
660960d6
VS
1516fi
1517
5ce5507f 1518if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
d642d761 1519 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
5ce5507f 1520fi
1521if test x"$grub_mkfont_excuse" = x ; then
1522enable_grub_mkfont=yes
1523else
1524enable_grub_mkfont=no
1525fi
e52db1f7 1526AC_SUBST([enable_grub_mkfont])
e52db1f7 1527
7c9d0c39 1528SAVED_CC="$CC"
b224c266 1529SAVED_CPP="$CPP"
7c9d0c39
VS
1530SAVED_CFLAGS="$CFLAGS"
1531SAVED_CPPFLAGS="$CPPFLAGS"
dcecae1a 1532SAVED_LDFLAGS="$LDFLAGS"
7c9d0c39 1533CC="$BUILD_CC"
b224c266 1534CPP="$BUILD_CPP"
7c9d0c39 1535CFLAGS="$BUILD_CFLAGS"
7b780018 1536CPPFLAGS="$BUILD_CPPFLAGS"
dcecae1a 1537LDFLAGS="$BUILD_LDFAGS"
7b780018
VS
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])
c5884973 1553
7c9d0c39
VS
1554if test x"$grub_build_mkfont_excuse" = x ; then
1555 # Check for freetype libraries.
3eec9111
CW
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"
7c9d0c39
VS
1571fi
1572
1573if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
d642d761 1574 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
7c9d0c39
VS
1575fi
1576if test x"$grub_build_mkfont_excuse" = x ; then
1577 enable_build_grub_mkfont=yes
1578else
1579 enable_build_grub_mkfont=no
c5884973 1580fi
0af7539b 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
d642d761 1582 if test x"$grub_build_mkfont_excuse" = x ; then
0af7539b 1583 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont])
d642d761 1584 else
0af7539b 1585 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)])
d642d761 1586 fi
7c9d0c39
VS
1587fi
1588
7c9d0c39 1589CC="$SAVED_CC"
b224c266 1590CPP="$SAVED_CPP"
7c9d0c39
VS
1591CFLAGS="$SAVED_CFLAGS"
1592CPPFLAGS="$SAVED_CPPFLAGS"
dcecae1a 1593LDFLAGS="$SAVED_LDFLAGS"
7c9d0c39
VS
1594
1595
1596DJVU_FONT_SOURCE=
1597
1598starfield_excuse=
c5884973 1599
300f48c5
VS
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
7b966834
VS
1608 starfield_excuse="No build-time grub-mkfont"
1609fi
1610
501b9e4b 1611if test x"$starfield_excuse" = x; then
c5884973 1612 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
36387ece 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
c5884973
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
300f48c5 1626if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
d642d761 1627 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
300f48c5
VS
1628fi
1629
c5884973
DO
1630AC_SUBST([DJVU_FONT_SOURCE])
1631
7c9d0c39
VS
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
0277eab7
VS
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
4d94b2db 1640 continue
0277eab7 1641 fi
7c9d0c39
VS
1642 FONT_SOURCE="$dir/unifont.$ext"
1643 break 2
1644 fi
1645 done
1646done
1647
7b966834
VS
1648if test x"$enable_build_grub_mkfont" = xno ; then
1649 FONT_SOURCE=
1650fi
1651
0af7539b 1652if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
d642d761 1653 if test x"$grub_build_mkfont_excuse" = x ; then
0af7539b 1654 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont])
d642d761 1655 else
0af7539b 1656 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
d642d761 1657 fi
7c9d0c39
VS
1658fi
1659
1660AC_SUBST([FONT_SOURCE])
1661
7b780018 1662if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
7c9d0c39
VS
1663 grub_build_mkfont_excuse="no fonts"
1664fi
1665
1666
897e6207
CW
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"
92bb0786
VS
1672fi
1673
897e6207 1674if test x"$grub_mount_excuse" = x ; then
92bb0786 1675 AC_CHECK_LIB([fuse], [fuse_main_real], [],
897e6207 1676 [grub_mount_excuse="need FUSE library"])
92bb0786
VS
1677fi
1678
897e6207 1679if test x"$grub_mount_excuse" = x ; then
92bb0786
VS
1680 # Check for fuse headers.
1681 SAVED_CPPFLAGS="$CPPFLAGS"
fc7a64bc 1682 CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
92bb0786 1683 AC_CHECK_HEADERS([fuse/fuse.h], [],
897e6207 1684 [grub_mount_excuse=["need FUSE headers"]])
92bb0786
VS
1685 CPPFLAGS="$SAVED_CPPFLAGS"
1686fi
1687
897e6207 1688if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
d642d761 1689 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
92bb0786 1690fi
897e6207
CW
1691if test x"$grub_mount_excuse" = x ; then
1692enable_grub_mount=yes
92bb0786 1693else
897e6207 1694enable_grub_mount=no
92bb0786 1695fi
897e6207 1696AC_SUBST([enable_grub_mount])
92bb0786 1697
7181e228
CW
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
53798c4b
GS
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
7181e228
CW
1711if test x"$device_mapper_excuse" = x ; then
1712 # Check for device-mapper library.
61d720e5 1713 AC_CHECK_LIB([devmapper], [dm_task_create], [],
7181e228 1714 [device_mapper_excuse="need devmapper library"])
7181e228 1715fi
61d720e5
VS
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
4d94b2db 1725 LIBDEVMAPPER="-ldevmapper"
61d720e5
VS
1726 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1727 [Define to 1 if you have the devmapper library.])
1728fi
1729
62f7d208 1730AC_SUBST([LIBDEVMAPPER])
76ed06b9 1731
f4727da9
VS
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
0d2d30bb
VS
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
2c44e493 1749AC_CHECK_LIB([lzma], [lzma_code],
0d2d30bb
VS
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
d642d761 1757 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
0d2d30bb
VS
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
2c44e493
VS
1767AC_SUBST([LIBLZMA])
1768
e4c498a1
MG
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
16c7cb32 1775
e4c498a1
MG
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
27f9d02e 1788 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
e4c498a1
MG
1789 [],
1790 [libzfs_excuse="need nvpair library"])
1791fi
1792
1793if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
d642d761 1794 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
e4c498a1
MG
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])
16c7cb32
BC
1808AC_SUBST([LIBNVPAIR])
1809
c8164bdd
CW
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
aa30b8a1
CW
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
82480176
CW
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
9cccd716
EB
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
94c17f66
CW
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
9f915872
VS
1865LIBS=""
1866
76ed06b9 1867AC_SUBST([FONT_SOURCE])
76ed06b9
BC
1868AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1869 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
7181e228 1870
742f9232 1871AC_SUBST(HAVE_ASM_USCORE)
742f9232
VS
1872AC_SUBST(BSS_START_SYMBOL)
1873AC_SUBST(END_SYMBOL)
1874AC_SUBST(PACKAGE)
1875AC_SUBST(VERSION)
742f9232 1876
d5524ca8
VS
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
d5524ca8
VS
1885TARGET_CPP="$TARGET_CC -E"
1886TARGET_CCAS=$TARGET_CC
1887
b46bf3cd
VS
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
d5524ca8
VS
1894GRUB_TARGET_CPU="${target_cpu}"
1895GRUB_PLATFORM="${platform}"
1896
1897AC_SUBST(GRUB_TARGET_CPU)
1898AC_SUBST(GRUB_PLATFORM)
1899
1900AC_SUBST(TARGET_OBJCONV)
d5524ca8
VS
1901AC_SUBST(TARGET_CPP)
1902AC_SUBST(TARGET_CCAS)
1903AC_SUBST(TARGET_OBJ2ELF)
d5524ca8 1904AC_SUBST(TARGET_MODULE_FORMAT)
6a7957f9 1905AC_SUBST(TARGET_CC_VERSION)
d5524ca8
VS
1906
1907AC_SUBST(TARGET_CFLAGS)
1908AC_SUBST(TARGET_LDFLAGS)
1909AC_SUBST(TARGET_CPPFLAGS)
1910AC_SUBST(TARGET_CCASFLAGS)
1911
d5524ca8
VS
1912AC_SUBST(TARGET_IMG_LDFLAGS)
1913AC_SUBST(TARGET_IMG_CFLAGS)
1914AC_SUBST(TARGET_IMG_BASE_LDOPT)
a9f25a08 1915AC_SUBST(TARGET_APPLE_LINKER)
d5524ca8
VS
1916
1917AC_SUBST(HOST_CFLAGS)
1918AC_SUBST(HOST_LDFLAGS)
1919AC_SUBST(HOST_CPPFLAGS)
1920AC_SUBST(HOST_CCASFLAGS)
1921
1922AC_SUBST(BUILD_LIBM)
1923
76ed06b9
BC
1924#
1925# Automake conditionals
1926#
8c411768 1927
5d90f6e5 1928AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
76ed06b9
BC
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])
6585de4c 1932AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
76ed06b9
BC
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])
9612ebc0
VS
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])
4959e111
VS
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])
7f63a64f 1942AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
76ed06b9 1943AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
eaf01c25 1944AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
76ed06b9 1945AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
4959e111 1946AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
37ba07eb
VS
1947AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1948AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
389b31cd
LL
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])
15a463d7
LL
1952AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
1953AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
f7711f5e 1954
faf4a65e
VS
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])
f7711f5e 1958AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
faf4a65e
VS
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])
2d465fb0 1962
76ed06b9 1963AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
76ed06b9
BC
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])
897e6207 1967AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
76ed06b9 1968AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
6f07c4e4
VS
1969if test x$FONT_SOURCE != x ; then
1970 HAVE_FONT_SOURCE=1
1971else
1972 HAVE_FONT_SOURCE=0
1973fi
1974AC_SUBST(HAVE_FONT_SOURCE)
a9f25a08 1975AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
76ed06b9 1976AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
c5dc1690 1977AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
e744219b 1978AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
fc45fb58 1979
1eed0e6e
VS
1980AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1981
742f9232 1982AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
c5884973 1983AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
cd46aa6c
VS
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
742f9232 1998
6a161fa9 1999# Output files.
5d90f6e5
CW
2000if test "$platform" != none; then
2001 cpudir="${target_cpu}"
2002 if test x${cpudir} = xmipsel; then
2003 cpudir=mips;
f84b481b 2004 fi
5d90f6e5
CW
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
f84b481b 2019 fi
5d90f6e5
CW
2020else
2021 # Just enough to stop the compiler failing with -I$(srcdir)/include.
2022 mkdir -p include 2>/dev/null
77063f4c 2023 rm -rf include/grub/cpu include/grub/machine
1f4147aa 2024fi
6304d292 2025
8c411768 2026AC_CONFIG_FILES([Makefile])
6304d292 2027AC_CONFIG_FILES([grub-core/Makefile])
15c69261 2028AC_CONFIG_FILES([grub-core/gnulib/Makefile])
269004c1 2029AC_CONFIG_FILES([po/Makefile.in])
8c411768 2030AC_CONFIG_FILES([docs/Makefile])
b23ffd70 2031AC_CONFIG_FILES([util/bash-completion.d/Makefile])
6a161fa9 2032AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
742f9232 2033AC_CONFIG_FILES([config.h])
8c411768 2034
6a161fa9 2035AC_OUTPUT
5ce5507f 2036[
2037echo "*******************************************************"
2038echo GRUB2 will be compiled with following components:
2039echo Platform: "$target_cpu"-"$platform"
f84b481b 2040if [ x"$platform" = xemu ]; then
927d0134
VS
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
325c8258 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
f84b481b 2051fi
61d720e5
VS
2052if test x"$device_mapper_excuse" = x ; then
2053echo With devmapper support: Yes
2054else
2055echo With devmapper support: No "($device_mapper_excuse)"
2056fi
5ce5507f 2057if [ x"$enable_mm_debug" = xyes ]; then
2058echo With memory debugging: Yes
2059else
2060echo With memory debugging: No
2061fi
c5dc1690
SJ
2062if [ x"$enable_cache_stats" = xyes ]; then
2063echo With disk cache statistics: Yes
2064else
2065echo With disk cache statistics: No
2066fi
e744219b
VS
2067
2068if [ x"$enable_boot_time" = xyes ]; then
2069echo With boot time statistics: Yes
2070else
2071echo With boot time statistics: No
2072fi
2073
5ce5507f 2074if [ x"$efiemu_excuse" = x ]; then
2075echo efiemu runtime: Yes
2076else
2077echo efiemu runtime: No "($efiemu_excuse)"
2078fi
5ce5507f 2079if [ x"$grub_mkfont_excuse" = x ]; then
2080echo grub-mkfont: Yes
2081else
2082echo grub-mkfont: No "($grub_mkfont_excuse)"
2083fi
897e6207 2084if [ x"$grub_mount_excuse" = x ]; then
89644ef1 2085echo grub-mount: Yes
92bb0786 2086else
897e6207 2087echo grub-mount: No "($grub_mount_excuse)"
92bb0786 2088fi
c5884973
DO
2089if [ x"$starfield_excuse" = x ]; then
2090echo starfield theme: Yes
443b3222 2091echo With DejaVuSans font from $DJVU_FONT_SOURCE
c5884973
DO
2092else
2093echo starfield theme: No "($starfield_excuse)"
2094fi
e4c498a1
MG
2095if [ x"$libzfs_excuse" = x ]; then
2096echo With libzfs support: Yes
2097else
2098echo With libzfs support: No "($libzfs_excuse)"
2099fi
7b780018 2100if [ x"$grub_build_mkfont_excuse" = x ]; then
7c9d0c39
VS
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
4b80e43c 2107else
7b780018 2108 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
7c9d0c39 2109 echo "Without unifont (no build-time grub-mkfont)"
4b80e43c 2110fi
0d2d30bb
VS
2111if test x"$liblzma_excuse" != x ; then
2112echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
64fce2d8
VS
2113else
2114echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
2115fi
aa30b8a1
CW
2116if [ x"$enable_quiet_boot" = xyes ]; then
2117echo With quiet boot: Yes
2118else
2119echo With quiet boot: No
2120fi
5ce5507f 2121echo "*******************************************************"
2122]