]> git.proxmox.com Git - grub2.git/blame - configure.ac
* grub-core/kern/arm/cache.S: Don't switch back to ARM mode when
[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 600# For platforms where ELF is not the default link format.
fc97214f 601case "${target_os}" in
a9f25a08 602 cygwin)
4b0cd8f8 603# FIXME: put proper test here
742f9232 604 NEED_REGISTER_FRAME_INFO=1
4b0cd8f8 605 ;;
742f9232 606 *) NEED_REGISTER_FRAME_INFO=0 ;;
2b167a72 607esac
2b167a72 608
30c7d3ce
VS
609
610AC_ARG_ENABLE([efiemu],
611 [AS_HELP_STRING([--enable-efiemu],
612 [build and install the efiemu runtimes (default=guessed)])])
613if test x"$enable_efiemu" = xno ; then
614 efiemu_excuse="explicitly disabled"
615fi
1c1f31e5
VS
616if test x"$target_os" = xcygwin ; then
617 efiemu_excuse="not available on cygwin"
618fi
30c7d3ce
VS
619if test x"$target_cpu" != xi386 ; then
620 efiemu_excuse="only available on i386"
621fi
622if test x"$platform" = xefi ; then
623 efiemu_excuse="not available on efi"
624fi
625if test x"$efiemu_excuse" = x ; then
626 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
3c2304d5 627 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
30c7d3ce
VS
628 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
629 [grub_cv_cc_efiemu=yes],
630 [grub_cv_cc_efiemu=no])
631 ])
632 if test x$grub_cv_cc_efiemu = xno; then
633 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
634 fi
635fi
636if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
637 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
638fi
639if test x"$efiemu_excuse" = x ; then
640enable_efiemu=yes
641else
642enable_efiemu=no
643fi
644AC_SUBST([enable_efiemu])
645
a9f25a08
VS
646CFLAGS="$TARGET_CFLAGS"
647
648if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
649 AC_CACHE_CHECK([for linking format], [grub_cv_target_cc_link_format], [
650 grub_cv_target_cc_link_format=unknown
651 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do
652 if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
653 continue
654 fi
655 CFLAGS="$TARGET_CFLAGS -static"
656 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib"
657 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
658 asm (".globl start; start:");
659 asm (".globl _start; _start:");
660 asm (".globl __start; __start:");
661 void __main (void);
662 void __main (void) {}
663 ]], [[]])], [flag=1], [])
664 if test x"$flag" = x1; then
665 grub_cv_target_cc_link_format="$format"
666 break;
667 fi
668 done])
669 if test x"$grub_cv_target_cc_link_format" = xunknown; then
670 AC_MSG_ERROR([no suitable link format found])
671 fi
672 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
673 if test x"$grub_cv_target_cc_link_format" = x-mi386pe; then
674 TARGET_OBJ2ELF='./build-grub-pe2elf';
675 fi
676fi
677
678if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_cc_link_format = x-arch,x86_64; then
679 TARGET_APPLE_LINKER=1
680 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
681 if test "x$TARGET_OBJCONV" = x ; then
682 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
683 fi
684 if test "x$TARGET_OBJCONV" = x ; then
685 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
686 fi
687 TARGET_IMG_LDSCRIPT=
688 TARGET_IMG_CFLAGS="-static"
689 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
690 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
691 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
692 TARGET_LDFLAGS_OLDMAGIC=""
693elif test x$grub_cv_target_cc_link_format = x-mi386pe && test x$platform = xpc; then
694 TARGET_APPLE_LINKER=0
695 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
696 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
697 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
698 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
699 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
700 TARGET_IMG_CFLAGS=
701else
702 TARGET_APPLE_LINKER=0
703 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
704 TARGET_IMG_LDSCRIPT=
705 TARGET_IMG_LDFLAGS='-Wl,-N'
706 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
707 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
708 TARGET_IMG_CFLAGS=
709fi
710
711AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
712
713
714LDFLAGS="$TARGET_LDFLAGS"
8f0baaac 715
46546fc5 716if test "$target_cpu" = x86_64; then
7e9ca17a 717 # Use large model to support 4G memory
6e09b8b7 718 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
24f4e57c 719 CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
6e09b8b7 720 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
721 [grub_cv_cc_mcmodel=yes],
722 [grub_cv_cc_mcmodel=no])
723 ])
c8600122 724 if test "x$grub_cv_cc_mcmodel" = xno; then
4ba8d354 725 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
c8600122 726 else
727 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
6e09b8b7 728 fi
46546fc5 729fi
7e9ca17a 730
46546fc5 731if test "$target_cpu"-"$platform" = x86_64-efi; then
7e9ca17a 732 # EFI writes to stack below %rsp, we must not use the red zone
733 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
24f4e57c 734 CFLAGS="$TARGET_CFLAGS -m64 -mno-red-zone"
7e9ca17a 735 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
736 [grub_cv_cc_no_red_zone=yes],
737 [grub_cv_cc_no_red_zone=no])
738 ])
739 if test "x$grub_cv_cc_no_red_zone" = xno; then
740 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
741 fi
742
c8600122 743 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
20011694 744fi
745
baa2a121 746#
747# Compiler features.
748#
749
28668d80
VS
750CFLAGS="$TARGET_CFLAGS"
751
93a81088 752# Position independent executable.
753grub_CHECK_PIE
754[# Need that, because some distributions ship compilers that include
755# `-fPIE' in the default specs.
756if [ x"$pie_possible" = xyes ]; then
757 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
758fi]
759
28668d80
VS
760CFLAGS="$TARGET_CFLAGS"
761
7bd8b0c7
VS
762# Position independent executable.
763grub_CHECK_PIC
764[# Need that, because some distributions ship compilers that include
765# `-fPIC' in the default specs.
766if [ x"$pic_possible" = xyes ]; then
767 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
768fi]
769
28668d80
VS
770CFLAGS="$TARGET_CFLAGS"
771
baa2a121 772# Smashing stack protector.
773grub_CHECK_STACK_PROTECTOR
c3db8364 774# Need that, because some distributions ship compilers that include
baa2a121 775# `-fstack-protector' in the default specs.
c3db8364 776if test "x$ssp_possible" = xyes; then
777 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
778fi
28668d80
VS
779
780CFLAGS="$TARGET_CFLAGS"
781
2a8a80e4 782grub_CHECK_STACK_ARG_PROBE
783# Cygwin's GCC uses alloca() to probe the stackframe on static
784# stack allocations above some threshold.
785if test x"$sap_possible" = xyes; then
786 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
787fi
baa2a121 788
28668d80
VS
789CFLAGS="$TARGET_CFLAGS"
790
bb9f92b9
LL
791# -mno-unaligned-access
792if test "$target_cpu" = arm; then
793 grub_CHECK_NO_UNALIGNED_ACCESS
794 if test x"$nua_possible" = xyes; then
795 TARGET_CFLAGS="$TARGET_CFLAGS -mno-unaligned-access"
796 fi
797fi
798
aa6d7826 799# Set them to their new values for the tests below.
800CC="$TARGET_CC"
a9f25a08 801if test "x$TARGET_APPLE_LINKER" = x1 ; then
69be5b74 802CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
26de2bcd 803else
01fcf061 804CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
26de2bcd 805fi
aa6d7826 806CPPFLAGS="$TARGET_CPPFLAGS"
d5524ca8
VS
807if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
808TARGET_LIBGCC=
03f80960 809else
d5524ca8 810TARGET_LIBGCC=-lgcc
03f80960 811fi
69be5b74 812
d5524ca8
VS
813LIBS="$TARGET_LIBGCC"
814
01fcf061 815grub_ASM_USCORE
a9f25a08 816if test "x$TARGET_APPLE_LINKER" = x0 ; then
01fcf061 817if test x$grub_cv_asm_uscore = xyes; then
31c0cd43 818CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,_abort=_main"
01fcf061 819else
31c0cd43 820CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,abort=main"
01fcf061 821fi
a9f25a08 822fi
01fcf061 823
69be5b74 824# Check for libgcc symbols
6fcec439 825AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
69be5b74 826
a9f25a08 827if test "x$TARGET_APPLE_LINKER" = x1 ; then
69be5b74
VS
828CFLAGS="$TARGET_CFLAGS -nostdlib"
829else
830CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
831fi
42e0cba3 832LIBS=""
aa6d7826 833
6a161fa9 834# Defined in aclocal.m4.
f6130a12 835grub_PROG_TARGET_CC
a9f25a08 836if test "x$TARGET_APPLE_LINKER" != x1 ; then
b977bf01 837grub_PROG_OBJCOPY_ABSOLUTE
2b167a72 838fi
cb71ba20 839grub_PROG_LD_BUILD_ID_NONE
b977bf01 840if test "x$target_cpu" = xi386; then
a9f25a08 841 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
2aec1692
CF
842 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
843 # Check symbols provided by linker script.
5cf9459c 844 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000 -Wl,--defsym,___main=0x8100"
2aec1692 845 fi
2a8a80e4 846 grub_CHECK_BSS_START_SYMBOL
847 grub_CHECK_END_SYMBOL
848 fi
849 CFLAGS="$TARGET_CFLAGS"
4b13b216 850 grub_I386_ASM_PREFIX_REQUIREMENT
851 grub_I386_ASM_ADDR32
6a161fa9 852fi
853
20aea949
VS
854grub_PROG_NM_WORKS
855grub_PROG_NM_MINUS_P
856grub_PROG_NM_DEFINED_ONLY
857AC_SUBST(TARGET_NMFLAGS_MINUS_P)
858AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
859
016a671b 860if test "$platform" != emu; then
8f9a632b
VS
861AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
862 SAVED_CPPFLAGS="$CPPFLAGS"
863 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
864 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
ce938140 865#include <stddef.h>
8f9a632b
VS
866int va_arg_func (int fixed, va_list args);]], [[]])],
867 [grub_cv_cc_isystem=yes],
868 [grub_cv_cc_isystem=no])
869 CPPFLAGS="$SAVED_CPPFLAGS"
870])
871
872if test x"$grub_cv_cc_isystem" = xyes ; then
873 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
874fi
dae79b6b 875fi
5ce5507f 876
19ce697d 877AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
24f4e57c 878 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
779dc15b
VS
879 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
880int va_arg_func (int fixed, va_list args);]], [[]])],
19ce697d
VS
881 [grub_cv_cc_wtrampolines=yes],
882 [grub_cv_cc_wtrampolines=no])
779dc15b
VS
883])
884
19ce697d
VS
885if test x"$grub_cv_cc_wtrampolines" = xyes ; then
886 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
779dc15b
VS
887fi
888
c9a86192 889# Restore the flags.
9962ed99 890CC="$tmp_CC"
891CFLAGS="$tmp_CFLAGS"
892CPPFLAGS="$tmp_CPPFLAGS"
c9a86192 893LDFLAGS="$tmp_LDFLAGS"
aa6d7826 894LIBS="$tmp_LIBS"
6a161fa9 895
4fe9862e 896#
2965c7cc 897# Check for options.
4fe9862e 898#
899
900# Memory manager debugging.
b39f9d20 901AC_ARG_ENABLE([mm-debug],
2965c7cc 902 AS_HELP_STRING([--enable-mm-debug],
90ce5d56 903 [include memory manager debugging]),
2965c7cc 904 [AC_DEFINE([MM_DEBUG], [1],
905 [Define to 1 if you enable memory manager debugging.])])
906
c5dc1690
SJ
907AC_ARG_ENABLE([cache-stats],
908 AS_HELP_STRING([--enable-cache-stats],
055e2b8b 909 [enable disk cache statistics collection]))
c5dc1690
SJ
910
911if test x$enable_cache_stats = xyes; then
912 DISK_CACHE_STATS=1
913else
914 DISK_CACHE_STATS=0
915fi
916AC_SUBST([DISK_CACHE_STATS])
917
e744219b
VS
918AC_ARG_ENABLE([boot-time],
919 AS_HELP_STRING([--enable-boot-time],
920 [enable boot time statistics collection]))
921
922if test x$enable_boot_time = xyes; then
923 BOOT_TIME_STATS=1
924else
925 BOOT_TIME_STATS=0
926fi
927AC_SUBST([BOOT_TIME_STATS])
928
d64399b5 929AC_ARG_ENABLE([grub-emu-usb],
930 [AS_HELP_STRING([--enable-grub-emu-usb],
5ce5507f 931 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
5ce5507f 932
927d0134
VS
933AC_ARG_ENABLE([grub-emu-sdl],
934 [AS_HELP_STRING([--enable-grub-emu-sdl],
935 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
936
3affd0ec 937AC_ARG_ENABLE([grub-emu-pci],
938 [AS_HELP_STRING([--enable-grub-emu-pci],
939 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
940
f84b481b 941if test "$platform" = emu; then
f84b481b 942
62a747cb
VS
943if test x"$enable_grub_emu_usb" != xyes ; then
944 grub_emu_usb_excuse="not enabled"
5ce5507f 945fi
325c8258 946
0e848909
VS
947if test x"$enable_grub_emu_pci" = xyes ; then
948 grub_emu_usb_excuse="conflicts with PCI support"
949fi
950
5ce5507f 951[if [ x"$grub_emu_usb_excuse" = x ]; then
d64399b5 952 # Check for libusb libraries.]
5ce5507f 953AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
e98cd0c2 954 [grub_emu_usb_excuse=["need libusb library"]])
d64399b5 955 AC_SUBST([LIBUSB])
5ce5507f 956[fi]
957[if [ x"$grub_emu_usb_excuse" = x ]; then
958 # Check for headers.]
d64399b5 959 AC_CHECK_HEADERS([usb.h], [],
e98cd0c2 960 [grub_emu_usb_excuse=["need libusb headers"]])
4fe9862e 961[fi]
c6f3b249 962if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
ce7a733d 963 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
5ce5507f 964fi
965if test x"$grub_emu_usb_excuse" = x ; then
966enable_grub_emu_usb=yes
967else
968enable_grub_emu_usb=no
969fi
970
927d0134
VS
971if test x"$enable_grub_emu_sdl" = xno ; then
972 grub_emu_sdl_excuse="explicitely disabled"
973fi
974[if [ x"$grub_emu_sdl_excuse" = x ]; then
975 # Check for libSDL libraries.]
976AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
977 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
978 AC_SUBST([LIBSDL])
979[fi]
9f293ab0 980
927d0134
VS
981[if [ x"$grub_emu_sdl_excuse" = x ]; then
982 # Check for headers.]
983 AC_CHECK_HEADERS([SDL/SDL.h], [],
984 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
985[fi]
9f293ab0 986
927d0134
VS
987if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
988 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
989fi
990if test x"$grub_emu_sdl_excuse" = x ; then
991enable_grub_emu_sdl=yes
992else
993enable_grub_emu_sdl=no
994fi
995
3affd0ec 996if test x"$enable_grub_emu_pci" != xyes ; then
325c8258 997 grub_emu_pci_excuse="not enabled"
998fi
999
1000if test x"$enable_grub_emu_usb" = xyes ; then
1001 grub_emu_pci_excuse="conflicts with USB support"
1002fi
1003
1004[if [ x"$grub_emu_pci_excuse" = x ]; then
1005 # Check for libpci libraries.]
459fed4b 1006 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1007 [grub_emu_pci_excuse=["need libpciaccess library"]])
1008 AC_SUBST([LIBPCIACCESS])
325c8258 1009[fi]
1010[if [ x"$grub_emu_pci_excuse" = x ]; then
1011 # Check for headers.]
1012 AC_CHECK_HEADERS([pci/pci.h], [],
459fed4b 1013 [grub_emu_pci_excuse=["need libpciaccess headers"]])
325c8258 1014[fi]
1015
1016if test x"$grub_emu_pci_excuse" = x ; then
1017enable_grub_emu_pci=yes
1018else
9f293ab0 1019
325c8258 1020enable_grub_emu_pci=no
3affd0ec 1021fi
1022
927d0134 1023AC_SUBST([enable_grub_emu_sdl])
d64399b5 1024AC_SUBST([enable_grub_emu_usb])
3affd0ec 1025AC_SUBST([enable_grub_emu_pci])
e7d09ac4
AB
1026
1027else
1028
1029# Ignore --enable-emu-* if platform is not emu
1030enable_grub_emu_sdl=no
1031enable_grub_emu_usb=no
1032enable_grub_emu_pci=no
f84b481b 1033fi
4fe9862e 1034
e52db1f7 1035AC_ARG_ENABLE([grub-mkfont],
1036 [AS_HELP_STRING([--enable-grub-mkfont],
5ce5507f 1037 [build and install the `grub-mkfont' utility (default=guessed)])])
1038if test x"$enable_grub_mkfont" = xno ; then
ce7a733d 1039 grub_mkfont_excuse="explicitly disabled"
5ce5507f 1040fi
1041
1042if test x"$grub_mkfont_excuse" = x ; then
e52db1f7 1043 # Check for freetype libraries.
a5b55c4b 1044 AC_CHECK_TOOLS([FREETYPE], [freetype-config])
e52db1f7 1045 if test "x$FREETYPE" = x ; then
e98cd0c2 1046 grub_mkfont_excuse=["need freetype2 library"]
e52db1f7 1047 fi
e52db1f7 1048fi
660960d6 1049
7b780018
VS
1050unset ac_cv_header_ft2build_h
1051
660960d6
VS
1052if test x"$grub_mkfont_excuse" = x ; then
1053 # Check for freetype libraries.
a5b55c4b
DM
1054 freetype_cflags=`$FREETYPE --cflags`
1055 freetype_libs=`$FREETYPE --libs`
d1e8a02f
VS
1056 SAVED_CPPFLAGS="$CPPFLAGS"
1057 CPPFLAGS="$CPPFLAGS $freetype_cflags"
660960d6
VS
1058 AC_CHECK_HEADERS([ft2build.h], [],
1059 [grub_mkfont_excuse=["need freetype2 headers"]])
d1e8a02f 1060 CPPFLAGS="$SAVED_CPPFLAGS"
660960d6
VS
1061fi
1062
5ce5507f 1063if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
ce7a733d 1064 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
5ce5507f 1065fi
1066if test x"$grub_mkfont_excuse" = x ; then
1067enable_grub_mkfont=yes
1068else
1069enable_grub_mkfont=no
1070fi
e52db1f7 1071AC_SUBST([enable_grub_mkfont])
1072AC_SUBST([freetype_cflags])
1073AC_SUBST([freetype_libs])
1074
7c9d0c39 1075SAVED_CC="$CC"
b224c266 1076SAVED_CPP="$CPP"
7c9d0c39
VS
1077SAVED_CFLAGS="$CFLAGS"
1078SAVED_CPPFLAGS="$CPPFLAGS"
1079CC="$BUILD_CC"
b224c266 1080CPP="$BUILD_CPP"
7c9d0c39 1081CFLAGS="$BUILD_CFLAGS"
7b780018
VS
1082CPPFLAGS="$BUILD_CPPFLAGS"
1083
1084unset ac_cv_c_bigendian
1085unset ac_cv_header_ft2build_h
1086
1087AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1088AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1089AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1090
1091if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1092 AC_MSG_ERROR([couldnt determine build endianness])
1093fi
1094
1095AC_SUBST([BUILD_SIZEOF_LONG])
1096AC_SUBST([BUILD_SIZEOF_VOID_P])
1097AC_SUBST([BUILD_WORDS_BIGENDIAN])
c5884973 1098
7c9d0c39
VS
1099if test x"$grub_build_mkfont_excuse" = x ; then
1100 # Check for freetype libraries.
7b780018 1101 AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config])
7c9d0c39
VS
1102 if test "x$BUILD_FREETYPE" = x ; then
1103 grub_build_mkfont_excuse=["need freetype2 library"]
1104 fi
1105fi
c5884973 1106
7c9d0c39
VS
1107if test x"$grub_build_mkfont_excuse" = x ; then
1108 # Check for freetype libraries.
1109 build_freetype_cflags=`$BUILD_FREETYPE --cflags`
1110 build_freetype_libs=`$BUILD_FREETYPE --libs`
1111 SAVED_CPPFLAGS_2="$CPPFLAGS"
1112 CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
1113 AC_CHECK_HEADERS([ft2build.h], [],
1114 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1115 CPPFLAGS="$SAVED_CPPFLAGS_2"
1116fi
1117
1118if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1119 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled])
1120fi
1121if test x"$grub_build_mkfont_excuse" = x ; then
1122 enable_build_grub_mkfont=yes
1123else
1124 enable_build_grub_mkfont=no
c5884973 1125fi
b2e9d276
VS
1126if 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
1127 AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports needs build-time grub-mkfont])
7c9d0c39
VS
1128fi
1129
1130AC_SUBST([build_freetype_cflags])
1131AC_SUBST([build_freetype_libs])
1132
1133CC="$SAVED_CC"
b224c266 1134CPP="$SAVED_CPP"
7c9d0c39
VS
1135CFLAGS="$SAVED_CFLAGS"
1136CPPFLAGS="$SAVED_CPPFLAGS"
1137
1138
1139DJVU_FONT_SOURCE=
1140
1141starfield_excuse=
c5884973 1142
300f48c5
VS
1143AC_ARG_ENABLE([grub-themes],
1144 [AS_HELP_STRING([--enable-grub-themes],
1145 [build and install GRUB themes (default=guessed)])])
1146if test x"$enable_grub_themes" = xno ; then
1147 starfield_excuse="explicitly disabled"
1148fi
1149
1150if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
7b966834
VS
1151 starfield_excuse="No build-time grub-mkfont"
1152fi
1153
501b9e4b 1154if test x"$starfield_excuse" = x; then
c5884973 1155 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
32745f51 1156 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
c5884973
DO
1157 if test -f "$dir/DejaVuSans.$ext"; then
1158 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1159 break 2
1160 fi
1161 done
1162 done
1163
1164 if test "x$DJVU_FONT_SOURCE" = x; then
1165 starfield_excuse="No DejaVu found"
1166 fi
1167fi
1168
300f48c5
VS
1169if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1170 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied])
1171fi
1172
c5884973
DO
1173AC_SUBST([DJVU_FONT_SOURCE])
1174
7c9d0c39
VS
1175FONT_SOURCE=
1176
1177for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1178 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
1179 if test -f "$dir/unifont.$ext"; then
1180 FONT_SOURCE="$dir/unifont.$ext"
1181 break 2
1182 fi
1183 done
1184done
1185
7b966834
VS
1186if test x"$enable_build_grub_mkfont" = xno ; then
1187 FONT_SOURCE=
1188fi
1189
b2e9d276
VS
1190if 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
1191 AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports need unifont])
7c9d0c39
VS
1192fi
1193
1194AC_SUBST([FONT_SOURCE])
1195
7b780018 1196if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
7c9d0c39
VS
1197 grub_build_mkfont_excuse="no fonts"
1198fi
1199
1200
897e6207
CW
1201AC_ARG_ENABLE([grub-mount],
1202 [AS_HELP_STRING([--enable-grub-mount],
1203 [build and install the `grub-mount' utility (default=guessed)])])
1204if test x"$enable_grub_mount" = xno ; then
1205 grub_mount_excuse="explicitly disabled"
92bb0786
VS
1206fi
1207
897e6207 1208if test x"$grub_mount_excuse" = x ; then
92bb0786 1209 AC_CHECK_LIB([fuse], [fuse_main_real], [],
897e6207 1210 [grub_mount_excuse="need FUSE library"])
92bb0786
VS
1211fi
1212
897e6207 1213if test x"$grub_mount_excuse" = x ; then
92bb0786
VS
1214 # Check for fuse headers.
1215 SAVED_CPPFLAGS="$CPPFLAGS"
338c7fab 1216 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
92bb0786 1217 AC_CHECK_HEADERS([fuse/fuse.h], [],
897e6207 1218 [grub_mount_excuse=["need FUSE headers"]])
92bb0786
VS
1219 CPPFLAGS="$SAVED_CPPFLAGS"
1220fi
1221
897e6207 1222if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
89644ef1 1223 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
92bb0786 1224fi
897e6207
CW
1225if test x"$grub_mount_excuse" = x ; then
1226enable_grub_mount=yes
92bb0786 1227else
897e6207 1228enable_grub_mount=no
92bb0786 1229fi
897e6207 1230AC_SUBST([enable_grub_mount])
92bb0786 1231
7181e228
CW
1232AC_ARG_ENABLE([device-mapper],
1233 [AS_HELP_STRING([--enable-device-mapper],
1234 [enable Linux device-mapper support (default=guessed)])])
1235if test x"$enable_device_mapper" = xno ; then
1236 device_mapper_excuse="explicitly disabled"
1237fi
1238
53798c4b
GS
1239if test x"$device_mapper_excuse" = x ; then
1240 # Check for device-mapper header.
1241 AC_CHECK_HEADER([libdevmapper.h], [],
1242 [device_mapper_excuse="need libdevmapper header"])
1243fi
1244
7181e228
CW
1245if test x"$device_mapper_excuse" = x ; then
1246 # Check for device-mapper library.
61d720e5 1247 AC_CHECK_LIB([devmapper], [dm_task_create], [],
7181e228 1248 [device_mapper_excuse="need devmapper library"])
7181e228 1249fi
61d720e5
VS
1250
1251if test x"$device_mapper_excuse" = x ; then
1252 # Check for device-mapper library.
1253 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1254 [],
1255 [device_mapper_excuse="need devmapper library"])
1256fi
1257
1258if test x"$device_mapper_excuse" = x ; then
1259 LIBDEVMAPPER="-ldevmapper";
1260 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1261 [Define to 1 if you have the devmapper library.])
1262fi
1263
62f7d208 1264AC_SUBST([LIBDEVMAPPER])
76ed06b9 1265
f4727da9
VS
1266LIBGEOM=
1267if test x$host_kernel = xkfreebsd; then
1268 AC_CHECK_LIB([geom], [geom_gettree], [],
1269 [AC_MSG_ERROR([Your platform requires libgeom])])
1270 LIBGEOM="-lgeom"
1271fi
1272
1273AC_SUBST([LIBGEOM])
1274
0d2d30bb
VS
1275AC_ARG_ENABLE([liblzma],
1276 [AS_HELP_STRING([--enable-liblzma],
1277 [enable liblzma integration (default=guessed)])])
1278if test x"$enable_liblzma" = xno ; then
1279 liblzma_excuse="explicitly disabled"
1280fi
1281
1282if test x"$liblzma_excuse" = x ; then
2c44e493 1283AC_CHECK_LIB([lzma], [lzma_code],
0d2d30bb
VS
1284 [],[liblzma_excuse="need lzma library"])
1285fi
1286if test x"$liblzma_excuse" = x ; then
1287AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1288fi
1289
1290if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1291 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied])
1292fi
1293
1294
1295if test x"$liblzma_excuse" = x ; then
1296 LIBLZMA="-llzma"
1297 AC_DEFINE([USE_LIBLZMA], [1],
1298 [Define to 1 if you have the LZMA library.])
1299fi
1300
2c44e493
VS
1301AC_SUBST([LIBLZMA])
1302
e4c498a1
MG
1303AC_ARG_ENABLE([libzfs],
1304 [AS_HELP_STRING([--enable-libzfs],
1305 [enable libzfs integration (default=guessed)])])
1306if test x"$enable_libzfs" = xno ; then
1307 libzfs_excuse="explicitly disabled"
1308fi
16c7cb32 1309
e4c498a1
MG
1310if test x"$libzfs_excuse" = x ; then
1311 # Only check for system headers if libzfs support has not been disabled.
1312 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1313fi
1314
1315if test x"$libzfs_excuse" = x ; then
1316 AC_CHECK_LIB([zfs], [libzfs_init],
1317 [],
1318 [libzfs_excuse="need zfs library"])
1319fi
1320
1321if test x"$libzfs_excuse" = x ; then
27f9d02e 1322 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
e4c498a1
MG
1323 [],
1324 [libzfs_excuse="need nvpair library"])
1325fi
1326
1327if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1328 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1329fi
1330
1331if test x"$libzfs_excuse" = x ; then
1332 # We need both libzfs and libnvpair for a successful build.
1333 LIBZFS="-lzfs"
1334 AC_DEFINE([HAVE_LIBZFS], [1],
1335 [Define to 1 if you have the ZFS library.])
1336 LIBNVPAIR="-lnvpair"
1337 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1338 [Define to 1 if you have the NVPAIR library.])
1339fi
1340
1341AC_SUBST([LIBZFS])
16c7cb32
BC
1342AC_SUBST([LIBNVPAIR])
1343
9f915872
VS
1344LIBS=""
1345
76ed06b9 1346AC_SUBST([FONT_SOURCE])
76ed06b9
BC
1347AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1348 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
7181e228 1349
742f9232
VS
1350AC_SUBST(HAVE_ASM_USCORE)
1351AC_SUBST(ADDR32)
1352AC_SUBST(DATA32)
1353AC_SUBST(BSS_START_SYMBOL)
1354AC_SUBST(END_SYMBOL)
1355AC_SUBST(PACKAGE)
1356AC_SUBST(VERSION)
742f9232
VS
1357AC_SUBST(NEED_REGISTER_FRAME_INFO)
1358
d5524ca8
VS
1359AC_ARG_ENABLE([werror],
1360 [AS_HELP_STRING([--disable-werror],
1361 [do not use -Werror when building GRUB])])
1362if test x"$enable_werror" != xno ; then
1363 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1364 HOST_CFLAGS="$HOST_CFLAGS -Werror"
1365fi
1366
1367if test "x$grub_cv_cc_target_clang" = xno; then
1368 TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
1369else
1370 TARGET_LDFLAGS_STATIC_LIBGCC=
1371fi
1372
1373TARGET_CPP="$TARGET_CC -E"
1374TARGET_CCAS=$TARGET_CC
1375
1376GRUB_TARGET_CPU="${target_cpu}"
1377GRUB_PLATFORM="${platform}"
1378
1379AC_SUBST(GRUB_TARGET_CPU)
1380AC_SUBST(GRUB_PLATFORM)
1381
1382AC_SUBST(TARGET_OBJCONV)
1383AC_SUBST(TARGET_LIBGCC)
1384AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
1385AC_SUBST(TARGET_CPP)
1386AC_SUBST(TARGET_CCAS)
1387AC_SUBST(TARGET_OBJ2ELF)
d5524ca8
VS
1388AC_SUBST(TARGET_MODULE_FORMAT)
1389
1390AC_SUBST(TARGET_CFLAGS)
1391AC_SUBST(TARGET_LDFLAGS)
1392AC_SUBST(TARGET_CPPFLAGS)
1393AC_SUBST(TARGET_CCASFLAGS)
1394
1395AC_SUBST(TARGET_IMG_LDSCRIPT)
1396AC_SUBST(TARGET_IMG_LDFLAGS)
1397AC_SUBST(TARGET_IMG_CFLAGS)
1398AC_SUBST(TARGET_IMG_BASE_LDOPT)
a9f25a08 1399AC_SUBST(TARGET_APPLE_LINKER)
d5524ca8
VS
1400
1401AC_SUBST(HOST_CFLAGS)
1402AC_SUBST(HOST_LDFLAGS)
1403AC_SUBST(HOST_CPPFLAGS)
1404AC_SUBST(HOST_CCASFLAGS)
1405
1406AC_SUBST(BUILD_LIBM)
1407
76ed06b9
BC
1408#
1409# Automake conditionals
1410#
8c411768 1411
76ed06b9 1412AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
d59849b2 1413AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
76ed06b9
BC
1414AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1415AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
6585de4c 1416AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
76ed06b9
BC
1417AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1418AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1419AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1420AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1421AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
9612ebc0
VS
1422AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1423AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
4959e111
VS
1424AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1425AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
7f63a64f 1426AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
76ed06b9
BC
1427AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1428AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
4959e111 1429AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
37ba07eb
VS
1430AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1431AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
389b31cd
LL
1432AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1433AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1434AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
f7711f5e
BC
1435
1436AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1437AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1438AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1439AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1440AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
b105df76 1441AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
958ee221 1442AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
2d465fb0 1443
76ed06b9
BC
1444AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1445AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1446AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1447AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1448AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
897e6207 1449AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
76ed06b9 1450AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
a9f25a08 1451AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
76ed06b9 1452AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
c5dc1690 1453AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
e744219b 1454AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
fc45fb58 1455
1eed0e6e
VS
1456AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1457
742f9232 1458AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
fc97214f 1459AM_CONDITIONAL([COND_CYGWIN], [test x$target_os = xcygwin])
c5884973 1460AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
742f9232 1461
6a161fa9 1462# Output files.
4959e111
VS
1463cpudir="${target_cpu}"
1464if test x${cpudir} = xmipsel; then
1465 cpudir=mips;
1466fi
1f4147aa 1467grub_CHECK_LINK_DIR
1468if test x"$link_dir" = xyes ; then
4959e111 1469 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
f84b481b 1470 if test "$platform" != emu ; then
4959e111 1471 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
f84b481b 1472 fi
1f4147aa 1473else
1474 mkdir -p include/grub 2>/dev/null
1475 rm -rf include/grub/cpu
4959e111 1476 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
f84b481b
RM
1477 if test "$platform" != emu ; then
1478 rm -rf include/grub/machine
4959e111 1479 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
f84b481b 1480 fi
1f4147aa 1481fi
6304d292 1482
8c411768 1483AC_CONFIG_FILES([Makefile])
6304d292 1484AC_CONFIG_FILES([grub-core/Makefile])
15c69261 1485AC_CONFIG_FILES([grub-core/gnulib/Makefile])
269004c1 1486AC_CONFIG_FILES([po/Makefile.in])
8c411768 1487AC_CONFIG_FILES([docs/Makefile])
b23ffd70 1488AC_CONFIG_FILES([util/bash-completion.d/Makefile])
6a161fa9 1489AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
742f9232 1490AC_CONFIG_FILES([config.h])
8c411768 1491
6a161fa9 1492AC_OUTPUT
5ce5507f 1493[
1494echo "*******************************************************"
1495echo GRUB2 will be compiled with following components:
1496echo Platform: "$target_cpu"-"$platform"
f84b481b 1497if [ x"$platform" = xemu ]; then
5ce5507f 1498if [ x"$grub_emu_usb_excuse" = x ]; then
1499echo USB support for grub-emu: Yes
1500else
1501echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1502fi
927d0134
VS
1503if [ x"$grub_emu_sdl_excuse" = x ]; then
1504echo SDL support for grub-emu: Yes
1505else
1506echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1507fi
325c8258 1508if [ x"$grub_emu_pci_excuse" = x ]; then
1509echo PCI support for grub-emu: Yes
1510else
1511echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1512fi
f84b481b 1513fi
61d720e5
VS
1514if test x"$device_mapper_excuse" = x ; then
1515echo With devmapper support: Yes
1516else
1517echo With devmapper support: No "($device_mapper_excuse)"
1518fi
5ce5507f 1519if [ x"$enable_mm_debug" = xyes ]; then
1520echo With memory debugging: Yes
1521else
1522echo With memory debugging: No
1523fi
c5dc1690
SJ
1524if [ x"$enable_cache_stats" = xyes ]; then
1525echo With disk cache statistics: Yes
1526else
1527echo With disk cache statistics: No
1528fi
e744219b
VS
1529
1530if [ x"$enable_boot_time" = xyes ]; then
1531echo With boot time statistics: Yes
1532else
1533echo With boot time statistics: No
1534fi
1535
5ce5507f 1536if [ x"$efiemu_excuse" = x ]; then
1537echo efiemu runtime: Yes
1538else
1539echo efiemu runtime: No "($efiemu_excuse)"
1540fi
5ce5507f 1541if [ x"$grub_mkfont_excuse" = x ]; then
1542echo grub-mkfont: Yes
1543else
1544echo grub-mkfont: No "($grub_mkfont_excuse)"
1545fi
897e6207 1546if [ x"$grub_mount_excuse" = x ]; then
89644ef1 1547echo grub-mount: Yes
92bb0786 1548else
897e6207 1549echo grub-mount: No "($grub_mount_excuse)"
92bb0786 1550fi
c5884973
DO
1551if [ x"$starfield_excuse" = x ]; then
1552echo starfield theme: Yes
1553else
1554echo starfield theme: No "($starfield_excuse)"
1555fi
e4c498a1
MG
1556if [ x"$libzfs_excuse" = x ]; then
1557echo With libzfs support: Yes
1558else
1559echo With libzfs support: No "($libzfs_excuse)"
1560fi
7b780018 1561if [ x"$grub_build_mkfont_excuse" = x ]; then
7c9d0c39
VS
1562 echo Build-time grub-mkfont: Yes
1563 if test "x$FONT_SOURCE" = x ; then
1564 echo "Without unifont"
1565 else
1566 echo "With unifont from $FONT_SOURCE"
1567 fi
4b80e43c 1568else
7b780018 1569 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
7c9d0c39 1570 echo "Without unifont (no build-time grub-mkfont)"
4b80e43c 1571fi
0d2d30bb
VS
1572if test x"$liblzma_excuse" != x ; then
1573echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
64fce2d8
VS
1574else
1575echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
1576fi
5ce5507f 1577echo "*******************************************************"
1578]