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