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