]> git.proxmox.com Git - grub2.git/blame - configure.ac
Merge powerpc grub-mkrescue flavour with common. Use xorriso HFS+
[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
b977bf01 44AC_CANONICAL_TARGET
6a161fa9 45
8c411768
BC
46AM_INIT_AUTOMAKE()
47AC_PREREQ(2.60)
6304d292 48AC_CONFIG_SRCDIR([include/grub/dl.h])
742f9232 49AC_CONFIG_HEADER([config-util.h])
e52db1f7 50
1d543c3e 51# Program name transformations
52AC_ARG_PROGRAM
fd49ceb3
CW
53grub_TRANSFORM([grub-bios-setup])
54grub_TRANSFORM([grub-editenv])
55grub_TRANSFORM([grub-install])
56grub_TRANSFORM([grub-mkconfig])
57grub_TRANSFORM([grub-mkfont])
58grub_TRANSFORM([grub-mkimage])
59grub_TRANSFORM([grub-mklayout])
60grub_TRANSFORM([grub-mkpasswd-pbkdf2])
61grub_TRANSFORM([grub-mkrelpath])
62grub_TRANSFORM([grub-mkrescue])
63grub_TRANSFORM([grub-probe])
64grub_TRANSFORM([grub-reboot])
65grub_TRANSFORM([grub-script-check])
66grub_TRANSFORM([grub-set-default])
fd49ceb3 67grub_TRANSFORM([grub-sparc64-setup])
a79b8a15 68grub_TRANSFORM([grub-render-label])
1d543c3e 69
90d1e879
RM
70# Optimization flag. Allow user to override.
71if test "x$TARGET_CFLAGS" = x; then
72 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
73fi
74
76ed06b9
BC
75# Default HOST_CPPFLAGS
76HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
76ed06b9 77HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
76ed06b9
BC
78HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
79HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
80HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
81
82TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
83TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
84TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
85
b977bf01 86case "$target_cpu" in
02164e1b 87 i[[3456]]86) target_cpu=i386 ;;
c7ef54aa 88 amd64) target_cpu=x86_64 ;;
02164e1b 89 sparc) target_cpu=sparc64 ;;
ade85305 90 mipsel|mips64el)
4959e111 91 target_cpu=mipsel;
c721825b 92 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
4a1eefb6 93 ;;
ade85305 94 mips|mips64)
76ed06b9 95 target_cpu=mips;
c721825b 96 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
4a1eefb6 97 ;;
6a161fa9 98esac
99
05568c2e 100# Specify the platform (such as firmware).
101AC_ARG_WITH([platform],
102 AS_HELP_STRING([--with-platform=PLATFORM],
83b984de 103 [select the host platform [[guessed]]]))
05568c2e 104
105# Guess the platform if not specified.
106if test "x$with_platform" = x; then
b977bf01 107 case "$target_cpu"-"$target_vendor" in
05568c2e 108 i386-apple) platform=efi ;;
109 i386-*) platform=pc ;;
58393a2d 110 x86_64-apple) platform=efi ;;
737feb35 111 x86_64-*) platform=pc ;;
05568c2e 112 powerpc-*) platform=ieee1275 ;;
58393a2d 113 powerpc64-*) platform=ieee1275 ;;
05568c2e 114 sparc64-*) platform=ieee1275 ;;
4959e111
VS
115 mipsel-*) platform=loongson ;;
116 mips-*) platform=arc ;;
e68d3b24 117 ia64-*) platform=efi ;;
58393a2d 118 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
05568c2e 119 esac
120else
121 platform="$with_platform"
122fi
123
ec1dfd63
VS
124case "$target_cpu"-"$platform" in
125 x86_64-efi) ;;
126 x86_64-emu) ;;
127 x86_64-*) target_cpu=i386 ;;
128 powerpc64-ieee1275) target_cpu=powerpc ;;
129esac
20011694 130
58393a2d 131# Check if the platform is supported, make final adjustments.
b977bf01 132case "$target_cpu"-"$platform" in
05568c2e 133 i386-efi) ;;
3f4ce737 134 x86_64-efi) ;;
05568c2e 135 i386-pc) ;;
7210dca9 136 i386-multiboot) ;;
546f966a 137 i386-coreboot) ;;
58393a2d 138 i386-linuxbios) platform=coreboot ;;
3d04eab8 139 i386-ieee1275) ;;
8231fb77 140 i386-qemu) ;;
05568c2e 141 powerpc-ieee1275) ;;
142 sparc64-ieee1275) ;;
2c40cc78 143 ia64-efi) ;;
f440c33f 144 mips-qemu_mips) ;;
3666d5f6 145 mips-qemu-mips) platform=qemu_mips;;
8906c3dd 146 mips-arc) ;;
4959e111
VS
147 mipsel-qemu_mips) ;;
148 mipsel-qemu-mips) platform=qemu_mips;;
149 mipsel-yeeloong) platform=loongson ;;
150 mipsel-fuloong) platform=loongson ;;
151 mipsel-loongson) ;;
f84b481b 152 *-emu) ;;
58393a2d 153 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
6a161fa9 154esac
155
3f4ce737 156case "$target_cpu" in
157 i386 | powerpc) target_m32=1 ;;
158 x86_64 | sparc64) target_m64=1 ;;
159esac
160
6e5a42fe 161case "$host_os" in
4825d790 162 mingw32*) host_os=cygwin ;;
6e5a42fe 163esac
164
9304eef1 165# This normalizes the names, and creates a new variable ("host_kernel")
166# while at it, since the mapping is not always 1:1 (e.g. different OSes
167# using the same kernel type).
168case "$host_os" in
169 gnu*) host_kernel=hurd ;;
170 linux*) host_kernel=linux ;;
67937d4d 171 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
2c7031b1 172 netbsd*) host_kernel=netbsd ;;
958ee221 173 solaris*) host_kernel=illumos ;;
b105df76 174 darwin*) host_kernel=xnu ;;
9304eef1 175 cygwin) host_kernel=windows ;;
176esac
177
f84b481b 178case "$platform" in
c721825b
BC
179 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
180 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
181 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
182 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
183 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
184 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
185 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
54da1feb 186 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
3666d5f6
VS
187 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
188 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
f84b481b 189esac
6bea3f89 190case "$target_cpu" in
4959e111 191 mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
c721825b 192 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
6bea3f89 193esac
4959e111
VS
194if test x${target_cpu} = xmipsel ; then
195 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
196else
3ec0fc1c 197 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 198fi
6bea3f89 199
c721825b 200TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
f84b481b 201
56978920 202AC_SUBST(host_cpu)
203AC_SUBST(host_os)
9304eef1 204AC_SUBST(host_kernel)
6e5a42fe 205
071114bb
VS
206AC_SUBST(target_cpu)
207AC_SUBST(platform)
208
d87aedff 209# Define default variables
7134247c
VS
210
211have_with_bootdir=n
212AC_ARG_WITH([bootdir],
213 AS_HELP_STRING([--with-bootdir=DIR],
214 [set the name of /boot directory [[guessed]]]),
215 [have_with_bootdir=y],
216 [have_with_bootdir=n])
217if test x$have_with_bootdir = xy; then
218 bootdirname="$with_bootdir"
219else
220 case "$host_os" in
221 netbsd* | openbsd*)
d87aedff 222 # Because /boot is used for the boot block in NetBSD and OpenBSD,
7134247c
VS
223 bootdirname='' ;;
224 *) bootdirname='boot' ;;
225 esac
226fi
227
d87aedff 228AC_SUBST(bootdirname)
a4c1d277
YB
229AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
230 [Default boot directory name]")
d87aedff 231
7134247c
VS
232AC_ARG_WITH([grubdir],
233 AS_HELP_STRING([--with-grubdir=DIR],
234 [set the name of grub directory [[guessed]]]),
235 [grubdirname="$with_grubdir"],
236 [grubdirname="$PACKAGE"])
237
d87aedff 238AC_SUBST(grubdirname)
a4c1d277
YB
239AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
240 [Default grub directory name])
d87aedff 241
b977bf01 242#
243# Checks for build programs.
244#
144f1f98 245
6c826348 246# Although cmp is listed in the GNU Coding Standards as a command which
247# can used directly, OpenBSD lacks cmp in the default installation.
248AC_CHECK_PROGS([CMP], [cmp])
249if test "x$CMP" = x; then
250 AC_MSG_ERROR([cmp is not found])
251fi
252
144f1f98 253AC_CHECK_PROGS([YACC], [bison])
1569ec51 254if test "x$YACC" = x; then
6c826348 255 AC_MSG_ERROR([bison is not found])
1569ec51 256fi
257
4d88b9ae
VS
258FONT_SOURCE=
259
f4d095d7 260for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
8e832f71 261 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni; do
f4d095d7 262 if test -f "$dir/unifont.$ext"; then
8e50ec9f 263 FONT_SOURCE="$dir/unifont.$ext"
f4d095d7
GS
264 break 2
265 fi
266 done
4931827f 267done
268
64e3f8f6 269if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips); then
54da1feb 270 AC_MSG_ERROR([qemu and loongson ports need unifont])
4d88b9ae
VS
271fi
272
76ed06b9 273AC_SUBST([FONT_SOURCE])
8e50ec9f 274
76ed06b9 275AC_PROG_RANLIB
b977bf01 276AC_PROG_INSTALL
277AC_PROG_AWK
09220190 278AC_PROG_LEX
76ed06b9 279AC_PROG_YACC
b977bf01 280AC_PROG_MAKE_SET
ff420223 281AC_PROG_MKDIR_P
e1fd1939 282AC_PROG_LN_S
b977bf01 283
c7c75cf4 284if test "x$LEX" = "x:"; then
09220190
BC
285 AC_MSG_ERROR([flex is not found])
286else
2663fb5f 287 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
b777c18e 288 if test -n "$version" -a "$version" -ge 20535; then
09220190
BC
289 :
290 else
291 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
292 fi
293fi
294
68807e5f 295# These are not a "must".
51fa856c 296AC_PATH_PROGS(MAKEINFO, makeinfo true)
6a161fa9 297
b977bf01 298#
299# Checks for host programs.
300#
301
302AC_PROG_CC
15c69261 303gl_EARLY
76ed06b9
BC
304AM_PROG_CC_C_O
305AM_PROG_AS
306
6a161fa9 307# Must be GCC.
308test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
309
4889bdec 310AC_GNU_SOURCE
2f1a3acf 311AM_GNU_GETTEXT([external])
b977bf01 312AC_SYS_LARGEFILE
313
314# Identify characteristics of the host architecture.
315AC_C_BIGENDIAN
316AC_CHECK_SIZEOF(void *)
317AC_CHECK_SIZEOF(long)
318
2b167a72 319grub_apple_cc
c9da87d0 320if test x$grub_cv_apple_cc = xyes ; then
6fd0b143
VS
321 HOST_CPPFLAGS="$HOST_CPPFLAGS -fnested-functions"
322 HOST_LDFLAGS="$HOST_LDFLAGS -Wl,-allow_stack_execute"
2b167a72 323fi
b977bf01 324
aad32b14
VS
325if test x$USE_NLS = xno; then
326 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
327fi
328
86695375 329if test "x$cross_compiling" = xyes; then
330 AC_MSG_WARN([cannot generate manual pages while cross compiling])
331else
332 AC_PATH_PROG(HELP2MAN, help2man)
333fi
334
3169f4c7 335# Check for functions and headers.
c38fe9f4 336AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
e4c498a1 337AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
7c4e16ff 338
fb90b546
RM
339AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
340#include <sys/param.h>
341#include <sys/mount.h>])
342
343AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
344#include <sys/param.h>
345#include <sys/mount.h>])
346
2c7031b1
GS
347# For opendisk() and getrawpartition() on NetBSD.
348# Used in util/deviceiter.c and in util/hostdisk.c.
349AC_CHECK_HEADER([util.h], [
350 AC_CHECK_LIB([util], [opendisk], [
351 LIBUTIL="-lutil"
352 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
353 ])
354 AC_CHECK_LIB([util], [getrawpartition], [
355 LIBUTIL="-lutil"
356 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
357 ])
358])
359AC_SUBST([LIBUTIL])
360
19ce697d 361AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
00c05e22 362 SAVED_CFLAGS="$CFLAGS"
00c05e22
VS
363 CFLAGS="$HOST_CFLAGS -Wtrampolines"
364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
365int va_arg_func (int fixed, va_list args);]], [[]])],
19ce697d
VS
366 [grub_cv_host_cc_wtrampolines=yes],
367 [grub_cv_host_cc_wtrampolines=no])
00c05e22
VS
368 CFLAGS="$SAVED_CFLAGS"
369])
370
19ce697d
VS
371if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
372 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
00c05e22
VS
373fi
374
76ed06b9
BC
375#
376# Check for host and build compilers.
377#
378HOST_CC=$CC
379AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
380 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
381
15c69261
YB
382# For gnulib.
383gl_INIT
384
b977bf01 385#
386# Check for target programs.
387#
388
5b5d4aa5 389# Find tools for the target.
390if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
b977bf01 391 tmp_ac_tool_prefix="$ac_tool_prefix"
392 ac_tool_prefix=$target_alias-
393
394 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
395 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
396 AC_CHECK_TOOL(OBJCOPY, objcopy)
397 AC_CHECK_TOOL(STRIP, strip)
398 AC_CHECK_TOOL(NM, nm)
399
400 ac_tool_prefix="$tmp_ac_tool_prefix"
401else
402 if test "x$TARGET_CC" = x; then
403 TARGET_CC=$CC
404 fi
405 AC_CHECK_TOOL(OBJCOPY, objcopy)
406 AC_CHECK_TOOL(STRIP, strip)
407 AC_CHECK_TOOL(NM, nm)
408fi
76ed06b9
BC
409AC_SUBST(HOST_CC)
410AC_SUBST(BUILD_CC)
b977bf01 411AC_SUBST(TARGET_CC)
412
b977bf01 413# Test the C compiler for the target environment.
414tmp_CC="$CC"
415tmp_CFLAGS="$CFLAGS"
416tmp_LDFLAGS="$LDFLAGS"
417tmp_CPPFLAGS="$CPPFLAGS"
aa6d7826 418tmp_LIBS="$LIBS"
b977bf01 419CC="$TARGET_CC"
420CFLAGS="$TARGET_CFLAGS"
421CPPFLAGS="$TARGET_CPPFLAGS"
422LDFLAGS="$TARGET_LDFLAGS"
aa6d7826 423LIBS=""
b977bf01 424
90d1e879 425# debug flags.
c2deb798 426WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -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 -Wmissing-noreturn -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"
ebcecdf1 427HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
4e27343f 428TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
76ed06b9 429TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
6a161fa9 430
90d1e879
RM
431# Force no alignment to save space on i386.
432if test "x$target_cpu" = xi386; then
433 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
434 CFLAGS="$CFLAGS -falign-loops=1"
eb73121d 435 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
90d1e879
RM
436 [grub_cv_cc_falign_loop=yes],
437 [grub_cv_cc_falign_loop=no])
6a161fa9 438 ])
6a161fa9 439
90d1e879
RM
440 if test "x$grub_cv_cc_falign_loop" = xyes; then
441 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
6a161fa9 442 else
90d1e879 443 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
6a161fa9 444 fi
445
90d1e879
RM
446 # Some toolchains enable these features by default, but they need
447 # registers that aren't set up properly in GRUB.
448 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
449fi
77c55a87 450
90d1e879
RM
451# By default, GCC 4.4 generates .eh_frame sections containing unwind
452# information in some cases where it previously did not. GRUB doesn't need
453# these and they just use up vital space. Restore the old compiler
454# behaviour.
455AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
456 SAVE_CFLAGS="$CFLAGS"
457 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
458 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
459 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
460 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
461 CFLAGS="$SAVE_CFLAGS"
462])
77c55a87 463
90d1e879
RM
464if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
465 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
b977bf01 466fi
6a161fa9 467
e9d3421c
VS
468# By default, GCC 4.6 generates .eh_frame sections containing unwind
469# information in some cases where it previously did not. GRUB doesn't need
470# these and they just use up vital space. Restore the old compiler
471# behaviour.
472AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
473 SAVE_CFLAGS="$CFLAGS"
474 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
475 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
476 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
477 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
478 CFLAGS="$SAVE_CFLAGS"
479])
480
481if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
482 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
483fi
484
2b167a72 485grub_apple_target_cc
c9da87d0 486if test x$grub_cv_apple_target_cc = xyes ; then
403e25a5 487 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -fnested-functions"
76ed06b9 488
6fd0b143 489 CFLAGS="$CFLAGS -fnested-functions"
2b167a72 490 TARGET_APPLE_CC=1
cf00df31 491 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
492 if test "x$OBJCONV" = x ; then
493 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
494 fi
495 if test "x$OBJCONV" = x ; then
496 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
497 fi
2b167a72 498 TARGET_IMG_LDSCRIPT=
499 TARGET_IMG_CFLAGS="-static"
76ed06b9
BC
500 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
501 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
502 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
46cf439c 503 TARGET_LDFLAGS_OLDMAGIC=""
2b167a72 504else
505 TARGET_APPLE_CC=0
f04a9a21 506 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
2b167a72 507# Use linker script if present, otherwise use builtin -N script.
76ed06b9
BC
508if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
509 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
510 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
511 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
512 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
2b167a72 513else
514 TARGET_IMG_LDSCRIPT=
76ed06b9
BC
515 TARGET_IMG_LDFLAGS='-Wl,-N'
516 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
517 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
2b167a72 518fi
519TARGET_IMG_CFLAGS=
520fi
521
46cf439c
VS
522AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
523
2b167a72 524# For platforms where ELF is not the default link format.
525AC_MSG_CHECKING([for command to convert module to ELF format])
526case "${host_os}" in
f1632d4d 527 cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf';
4b0cd8f8 528# FIXME: put proper test here
742f9232 529 NEED_REGISTER_FRAME_INFO=1
4b0cd8f8 530 ;;
742f9232 531 *) NEED_REGISTER_FRAME_INFO=0 ;;
2b167a72 532esac
2b167a72 533AC_MSG_RESULT([$TARGET_OBJ2ELF])
534
30c7d3ce
VS
535
536AC_ARG_ENABLE([efiemu],
537 [AS_HELP_STRING([--enable-efiemu],
538 [build and install the efiemu runtimes (default=guessed)])])
539if test x"$enable_efiemu" = xno ; then
540 efiemu_excuse="explicitly disabled"
541fi
542if test x"$target_cpu" != xi386 ; then
543 efiemu_excuse="only available on i386"
544fi
545if test x"$platform" = xefi ; then
546 efiemu_excuse="not available on efi"
547fi
548if test x"$efiemu_excuse" = x ; then
549 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
dfc8aeb0 550 SAVED_CFLAGS="$CFLAGS"
30c7d3ce
VS
551 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
552 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
553 [grub_cv_cc_efiemu=yes],
554 [grub_cv_cc_efiemu=no])
dfc8aeb0 555 CFLAGS="$SAVED_CFLAGS"
30c7d3ce
VS
556 ])
557 if test x$grub_cv_cc_efiemu = xno; then
558 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
559 fi
560fi
561if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
562 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
563fi
564if test x"$efiemu_excuse" = x ; then
565enable_efiemu=yes
566else
567enable_efiemu=no
568fi
569AC_SUBST([enable_efiemu])
570
b977bf01 571if test "x$target_m32" = x1; then
572 # Force 32-bit mode.
573 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
76ed06b9 574 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
19e81ba7 575 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
b977bf01 576 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
2b167a72 577 TARGET_MODULE_FORMAT="elf32"
6a161fa9 578fi
b977bf01 579
20011694 580if test "x$target_m64" = x1; then
581 # Force 64-bit mode.
7e9ca17a 582 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
76ed06b9 583 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
19e81ba7 584 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
7e9ca17a 585 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
2b167a72 586 TARGET_MODULE_FORMAT="elf64"
7e9ca17a 587fi
588
589if test "$target_cpu"-"$platform" = x86_64-efi; then
590 # Use large model to support 4G memory
6e09b8b7 591 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
c8600122 592 SAVED_CFLAGS=$CFLAGS
593 CFLAGS="$CFLAGS -m64 -mcmodel=large"
6e09b8b7 594 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
595 [grub_cv_cc_mcmodel=yes],
596 [grub_cv_cc_mcmodel=no])
597 ])
c8600122 598 if test "x$grub_cv_cc_mcmodel" = xno; then
4ba8d354 599 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
c8600122 600 else
601 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
6e09b8b7 602 fi
7e9ca17a 603
604 # EFI writes to stack below %rsp, we must not use the red zone
605 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
c8600122 606 CFLAGS="$CFLAGS -m64 -mno-red-zone"
7e9ca17a 607 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
608 [grub_cv_cc_no_red_zone=yes],
609 [grub_cv_cc_no_red_zone=no])
610 ])
611 if test "x$grub_cv_cc_no_red_zone" = xno; then
612 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
613 fi
614
c8600122 615 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
20011694 616fi
617
baa2a121 618#
619# Compiler features.
620#
621
93a81088 622# Position independent executable.
623grub_CHECK_PIE
624[# Need that, because some distributions ship compilers that include
625# `-fPIE' in the default specs.
626if [ x"$pie_possible" = xyes ]; then
627 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
628fi]
629
7bd8b0c7
VS
630# Position independent executable.
631grub_CHECK_PIC
632[# Need that, because some distributions ship compilers that include
633# `-fPIC' in the default specs.
634if [ x"$pic_possible" = xyes ]; then
635 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
636fi]
637
baa2a121 638# Smashing stack protector.
639grub_CHECK_STACK_PROTECTOR
c3db8364 640# Need that, because some distributions ship compilers that include
baa2a121 641# `-fstack-protector' in the default specs.
c3db8364 642if test "x$ssp_possible" = xyes; then
643 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
644fi
2a8a80e4 645grub_CHECK_STACK_ARG_PROBE
646# Cygwin's GCC uses alloca() to probe the stackframe on static
647# stack allocations above some threshold.
648if test x"$sap_possible" = xyes; then
649 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
650fi
baa2a121 651
63f745e8 652AC_ARG_ENABLE([werror],
653 [AS_HELP_STRING([--disable-werror],
654 [do not use -Werror when building GRUB])])
655if test x"$enable_werror" != xno ; then
656 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
ebcecdf1 657 HOST_CFLAGS="$HOST_CFLAGS -Werror"
63f745e8 658fi
659
76ed06b9
BC
660TARGET_CPP="$TARGET_CC -E"
661TARGET_CCAS=$TARGET_CC
662
92cd0f6e
VS
663GRUB_TARGET_CPU="${target_cpu}"
664GRUB_PLATFORM="${platform}"
665
666AC_SUBST(GRUB_TARGET_CPU)
667AC_SUBST(GRUB_PLATFORM)
668
cf00df31 669AC_SUBST(OBJCONV)
76ed06b9
BC
670AC_SUBST(TARGET_CPP)
671AC_SUBST(TARGET_CCAS)
672AC_SUBST(TARGET_OBJ2ELF)
2b167a72 673AC_SUBST(TARGET_APPLE_CC)
76ed06b9
BC
674AC_SUBST(TARGET_MODULE_FORMAT)
675
676AC_SUBST(TARGET_CFLAGS)
b977bf01 677AC_SUBST(TARGET_LDFLAGS)
76ed06b9
BC
678AC_SUBST(TARGET_CPPFLAGS)
679AC_SUBST(TARGET_CCASFLAGS)
680
681AC_SUBST(TARGET_IMG_LDSCRIPT)
682AC_SUBST(TARGET_IMG_LDFLAGS)
683AC_SUBST(TARGET_IMG_CFLAGS)
684AC_SUBST(TARGET_IMG_BASE_LDOPT)
685
686AC_SUBST(HOST_CFLAGS)
687AC_SUBST(HOST_LDFLAGS)
688AC_SUBST(HOST_CPPFLAGS)
689AC_SUBST(HOST_CCASFLAGS)
6a161fa9 690
aa6d7826 691# Set them to their new values for the tests below.
692CC="$TARGET_CC"
26de2bcd 693if test "x$TARGET_APPLE_CC" = x1 ; then
69be5b74 694CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
26de2bcd 695else
01fcf061 696CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
26de2bcd 697fi
aa6d7826 698CPPFLAGS="$TARGET_CPPFLAGS"
03f80960
VS
699if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
700LIBS=
701else
69be5b74 702LIBS=-lgcc
03f80960 703fi
69be5b74 704
01fcf061
VS
705grub_ASM_USCORE
706if test x$grub_cv_asm_uscore = xyes; then
707CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
708else
709CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
710fi
711
69be5b74 712# Check for libgcc symbols
19ce697d 713AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
69be5b74
VS
714
715if test "x$TARGET_APPLE_CC" = x1 ; then
716CFLAGS="$TARGET_CFLAGS -nostdlib"
717else
718CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
719fi
42e0cba3 720LIBS=""
aa6d7826 721
6a161fa9 722# Defined in aclocal.m4.
f6130a12 723grub_PROG_TARGET_CC
2b167a72 724if test "x$TARGET_APPLE_CC" != x1 ; then
b977bf01 725grub_PROG_OBJCOPY_ABSOLUTE
2b167a72 726fi
cb71ba20 727grub_PROG_LD_BUILD_ID_NONE
b977bf01 728if test "x$target_cpu" = xi386; then
2aec1692
CF
729 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
730 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
731 # Check symbols provided by linker script.
76ed06b9 732 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
2aec1692 733 fi
2a8a80e4 734 grub_CHECK_BSS_START_SYMBOL
735 grub_CHECK_END_SYMBOL
736 fi
737 CFLAGS="$TARGET_CFLAGS"
4b13b216 738 grub_I386_ASM_PREFIX_REQUIREMENT
739 grub_I386_ASM_ADDR32
6a161fa9 740fi
741
016a671b 742if test "$platform" != emu; then
8f9a632b
VS
743AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
744 SAVED_CPPFLAGS="$CPPFLAGS"
745 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
746 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
ce938140 747#include <stddef.h>
8f9a632b
VS
748int va_arg_func (int fixed, va_list args);]], [[]])],
749 [grub_cv_cc_isystem=yes],
750 [grub_cv_cc_isystem=no])
751 CPPFLAGS="$SAVED_CPPFLAGS"
752])
753
754if test x"$grub_cv_cc_isystem" = xyes ; then
755 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
756fi
dae79b6b 757fi
5ce5507f 758
19ce697d 759AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
779dc15b 760 SAVED_CFLAGS="$CFLAGS"
72b7c7aa 761 CFLAGS="$TARGET_CFLAGS -Wtrampolines"
779dc15b
VS
762 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
763int va_arg_func (int fixed, va_list args);]], [[]])],
19ce697d
VS
764 [grub_cv_cc_wtrampolines=yes],
765 [grub_cv_cc_wtrampolines=no])
779dc15b
VS
766 CFLAGS="$SAVED_CFLAGS"
767])
768
19ce697d
VS
769if test x"$grub_cv_cc_wtrampolines" = xyes ; then
770 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
779dc15b
VS
771fi
772
c9a86192 773# Restore the flags.
9962ed99 774CC="$tmp_CC"
775CFLAGS="$tmp_CFLAGS"
776CPPFLAGS="$tmp_CPPFLAGS"
c9a86192 777LDFLAGS="$tmp_LDFLAGS"
aa6d7826 778LIBS="$tmp_LIBS"
6a161fa9 779
4fe9862e 780#
2965c7cc 781# Check for options.
4fe9862e 782#
783
784# Memory manager debugging.
b39f9d20 785AC_ARG_ENABLE([mm-debug],
2965c7cc 786 AS_HELP_STRING([--enable-mm-debug],
90ce5d56 787 [include memory manager debugging]),
2965c7cc 788 [AC_DEFINE([MM_DEBUG], [1],
789 [Define to 1 if you enable memory manager debugging.])])
790
c5dc1690
SJ
791AC_ARG_ENABLE([cache-stats],
792 AS_HELP_STRING([--enable-cache-stats],
055e2b8b 793 [enable disk cache statistics collection]))
c5dc1690
SJ
794
795if test x$enable_cache_stats = xyes; then
796 DISK_CACHE_STATS=1
797else
798 DISK_CACHE_STATS=0
799fi
800AC_SUBST([DISK_CACHE_STATS])
801
e744219b
VS
802AC_ARG_ENABLE([boot-time],
803 AS_HELP_STRING([--enable-boot-time],
804 [enable boot time statistics collection]))
805
806if test x$enable_boot_time = xyes; then
807 BOOT_TIME_STATS=1
808else
809 BOOT_TIME_STATS=0
810fi
811AC_SUBST([BOOT_TIME_STATS])
812
d64399b5 813AC_ARG_ENABLE([grub-emu-usb],
814 [AS_HELP_STRING([--enable-grub-emu-usb],
5ce5507f 815 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
5ce5507f 816
927d0134
VS
817AC_ARG_ENABLE([grub-emu-sdl],
818 [AS_HELP_STRING([--enable-grub-emu-sdl],
819 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
820
3affd0ec 821AC_ARG_ENABLE([grub-emu-pci],
822 [AS_HELP_STRING([--enable-grub-emu-pci],
823 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
824
f84b481b
RM
825if test "$platform" = emu; then
826 missing_ncurses=
827[# Check for curses libraries.]
4fe9862e 828 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
829 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
f84b481b 830 [missing_ncurses=[true]])])
4fe9862e 831 AC_SUBST([LIBCURSES])
f84b481b 832[if [ x"$missing_ncurses" = x ]; then ]
4fe9862e 833 [# Check for headers.]
834 AC_CHECK_HEADERS([ncurses/curses.h], [],
835 [AC_CHECK_HEADERS([ncurses.h], [],
836 [AC_CHECK_HEADERS([curses.h], [],
f84b481b 837 [missing_ncurses=[true]])])])
5ce5507f 838[fi]
f84b481b
RM
839if test x"$missing_ncurses" = xtrue ; then
840 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
5ce5507f 841fi
f84b481b 842
62a747cb
VS
843if test x"$enable_grub_emu_usb" != xyes ; then
844 grub_emu_usb_excuse="not enabled"
5ce5507f 845fi
325c8258 846
0e848909
VS
847if test x"$enable_grub_emu_pci" = xyes ; then
848 grub_emu_usb_excuse="conflicts with PCI support"
849fi
850
5ce5507f 851[if [ x"$grub_emu_usb_excuse" = x ]; then
d64399b5 852 # Check for libusb libraries.]
5ce5507f 853AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
e98cd0c2 854 [grub_emu_usb_excuse=["need libusb library"]])
d64399b5 855 AC_SUBST([LIBUSB])
5ce5507f 856[fi]
857[if [ x"$grub_emu_usb_excuse" = x ]; then
858 # Check for headers.]
d64399b5 859 AC_CHECK_HEADERS([usb.h], [],
e98cd0c2 860 [grub_emu_usb_excuse=["need libusb headers"]])
4fe9862e 861[fi]
c6f3b249 862if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
ce7a733d 863 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
5ce5507f 864fi
865if test x"$grub_emu_usb_excuse" = x ; then
866enable_grub_emu_usb=yes
867else
868enable_grub_emu_usb=no
869fi
870
927d0134
VS
871if test x"$enable_grub_emu_sdl" = xno ; then
872 grub_emu_sdl_excuse="explicitely disabled"
873fi
874[if [ x"$grub_emu_sdl_excuse" = x ]; then
875 # Check for libSDL libraries.]
876AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
877 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
878 AC_SUBST([LIBSDL])
879[fi]
9f293ab0 880
927d0134
VS
881[if [ x"$grub_emu_sdl_excuse" = x ]; then
882 # Check for headers.]
883 AC_CHECK_HEADERS([SDL/SDL.h], [],
884 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
885[fi]
9f293ab0 886
927d0134
VS
887if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
888 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
889fi
890if test x"$grub_emu_sdl_excuse" = x ; then
891enable_grub_emu_sdl=yes
892else
893enable_grub_emu_sdl=no
894fi
895
3affd0ec 896if test x"$enable_grub_emu_pci" != xyes ; then
325c8258 897 grub_emu_pci_excuse="not enabled"
898fi
899
900if test x"$enable_grub_emu_usb" = xyes ; then
901 grub_emu_pci_excuse="conflicts with USB support"
902fi
903
904[if [ x"$grub_emu_pci_excuse" = x ]; then
905 # Check for libpci libraries.]
459fed4b 906 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
907 [grub_emu_pci_excuse=["need libpciaccess library"]])
908 AC_SUBST([LIBPCIACCESS])
325c8258 909[fi]
910[if [ x"$grub_emu_pci_excuse" = x ]; then
911 # Check for headers.]
912 AC_CHECK_HEADERS([pci/pci.h], [],
459fed4b 913 [grub_emu_pci_excuse=["need libpciaccess headers"]])
325c8258 914[fi]
915
916if test x"$grub_emu_pci_excuse" = x ; then
917enable_grub_emu_pci=yes
918else
9f293ab0 919
325c8258 920enable_grub_emu_pci=no
3affd0ec 921fi
922
927d0134 923AC_SUBST([enable_grub_emu_sdl])
d64399b5 924AC_SUBST([enable_grub_emu_usb])
3affd0ec 925AC_SUBST([enable_grub_emu_pci])
f84b481b 926fi
4fe9862e 927
e52db1f7 928AC_ARG_ENABLE([grub-mkfont],
929 [AS_HELP_STRING([--enable-grub-mkfont],
5ce5507f 930 [build and install the `grub-mkfont' utility (default=guessed)])])
931if test x"$enable_grub_mkfont" = xno ; then
ce7a733d 932 grub_mkfont_excuse="explicitly disabled"
5ce5507f 933fi
934
935if test x"$grub_mkfont_excuse" = x ; then
e52db1f7 936 # Check for freetype libraries.
937 AC_CHECK_PROGS([FREETYPE], [freetype-config])
938 if test "x$FREETYPE" = x ; then
e98cd0c2 939 grub_mkfont_excuse=["need freetype2 library"]
e52db1f7 940 fi
e52db1f7 941fi
660960d6
VS
942
943if test x"$grub_mkfont_excuse" = x ; then
944 # Check for freetype libraries.
10854d0d
YB
945 freetype_cflags=`freetype-config --cflags`
946 freetype_libs=`freetype-config --libs`
d1e8a02f
VS
947 SAVED_CPPFLAGS="$CPPFLAGS"
948 CPPFLAGS="$CPPFLAGS $freetype_cflags"
660960d6
VS
949 AC_CHECK_HEADERS([ft2build.h], [],
950 [grub_mkfont_excuse=["need freetype2 headers"]])
d1e8a02f 951 CPPFLAGS="$SAVED_CPPFLAGS"
660960d6
VS
952fi
953
5ce5507f 954if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
ce7a733d 955 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
5ce5507f 956fi
957if test x"$grub_mkfont_excuse" = x ; then
958enable_grub_mkfont=yes
959else
960enable_grub_mkfont=no
961fi
20168fca
CW
962if test x"$enable_grub_mkfont" = xno && test "x$platform" = xloongson; then
963 AC_MSG_ERROR([loongson port needs grub-mkfont])
964fi
e52db1f7 965AC_SUBST([enable_grub_mkfont])
966AC_SUBST([freetype_cflags])
967AC_SUBST([freetype_libs])
968
c5884973
DO
969DJVU_FONT_SOURCE=
970
971starfield_excuse=
972
973if test x$enable_grub_mkfont = xno; then
974 starfield_excuse="No grub-mkfont"
975fi
976
501b9e4b 977if test x"$starfield_excuse" = x; then
c5884973 978 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
32745f51 979 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
c5884973
DO
980 if test -f "$dir/DejaVuSans.$ext"; then
981 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
982 break 2
983 fi
984 done
985 done
986
987 if test "x$DJVU_FONT_SOURCE" = x; then
988 starfield_excuse="No DejaVu found"
989 fi
990fi
991
992AC_SUBST([DJVU_FONT_SOURCE])
993
897e6207
CW
994AC_ARG_ENABLE([grub-mount],
995 [AS_HELP_STRING([--enable-grub-mount],
996 [build and install the `grub-mount' utility (default=guessed)])])
997if test x"$enable_grub_mount" = xno ; then
998 grub_mount_excuse="explicitly disabled"
92bb0786
VS
999fi
1000
897e6207 1001if test x"$grub_mount_excuse" = x ; then
92bb0786 1002 AC_CHECK_LIB([fuse], [fuse_main_real], [],
897e6207 1003 [grub_mount_excuse="need FUSE library"])
92bb0786
VS
1004fi
1005
897e6207 1006if test x"$grub_mount_excuse" = x ; then
92bb0786
VS
1007 # Check for fuse headers.
1008 SAVED_CPPFLAGS="$CPPFLAGS"
338c7fab 1009 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
92bb0786 1010 AC_CHECK_HEADERS([fuse/fuse.h], [],
897e6207 1011 [grub_mount_excuse=["need FUSE headers"]])
92bb0786
VS
1012 CPPFLAGS="$SAVED_CPPFLAGS"
1013fi
1014
897e6207 1015if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
89644ef1 1016 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
92bb0786 1017fi
897e6207
CW
1018if test x"$grub_mount_excuse" = x ; then
1019enable_grub_mount=yes
92bb0786 1020else
897e6207 1021enable_grub_mount=no
92bb0786 1022fi
897e6207 1023AC_SUBST([enable_grub_mount])
92bb0786 1024
7181e228
CW
1025AC_ARG_ENABLE([device-mapper],
1026 [AS_HELP_STRING([--enable-device-mapper],
1027 [enable Linux device-mapper support (default=guessed)])])
1028if test x"$enable_device_mapper" = xno ; then
1029 device_mapper_excuse="explicitly disabled"
1030fi
1031
53798c4b
GS
1032if test x"$device_mapper_excuse" = x ; then
1033 # Check for device-mapper header.
1034 AC_CHECK_HEADER([libdevmapper.h], [],
1035 [device_mapper_excuse="need libdevmapper header"])
1036fi
1037
7181e228
CW
1038if test x"$device_mapper_excuse" = x ; then
1039 # Check for device-mapper library.
61d720e5 1040 AC_CHECK_LIB([devmapper], [dm_task_create], [],
7181e228 1041 [device_mapper_excuse="need devmapper library"])
7181e228 1042fi
61d720e5
VS
1043
1044if test x"$device_mapper_excuse" = x ; then
1045 # Check for device-mapper library.
1046 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1047 [],
1048 [device_mapper_excuse="need devmapper library"])
1049fi
1050
1051if test x"$device_mapper_excuse" = x ; then
1052 LIBDEVMAPPER="-ldevmapper";
1053 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1054 [Define to 1 if you have the devmapper library.])
1055fi
1056
62f7d208 1057AC_SUBST([LIBDEVMAPPER])
76ed06b9 1058
f4727da9
VS
1059LIBGEOM=
1060if test x$host_kernel = xkfreebsd; then
1061 AC_CHECK_LIB([geom], [geom_gettree], [],
1062 [AC_MSG_ERROR([Your platform requires libgeom])])
1063 LIBGEOM="-lgeom"
1064fi
1065
1066AC_SUBST([LIBGEOM])
1067
2c44e493
VS
1068AC_CHECK_LIB([lzma], [lzma_code],
1069 [LIBLZMA="-llzma"
1070 AC_DEFINE([HAVE_LIBLZMA], [1],
1071 [Define to 1 if you have the LZMA library.])],)
1072AC_SUBST([LIBLZMA])
1073
e4c498a1
MG
1074AC_ARG_ENABLE([libzfs],
1075 [AS_HELP_STRING([--enable-libzfs],
1076 [enable libzfs integration (default=guessed)])])
1077if test x"$enable_libzfs" = xno ; then
1078 libzfs_excuse="explicitly disabled"
1079fi
16c7cb32 1080
e4c498a1
MG
1081if test x"$libzfs_excuse" = x ; then
1082 # Only check for system headers if libzfs support has not been disabled.
1083 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1084fi
1085
1086if test x"$libzfs_excuse" = x ; then
1087 AC_CHECK_LIB([zfs], [libzfs_init],
1088 [],
1089 [libzfs_excuse="need zfs library"])
1090fi
1091
1092if test x"$libzfs_excuse" = x ; then
1093 AC_CHECK_LIB([nvpair], [nvlist_print],
1094 [],
1095 [libzfs_excuse="need nvpair library"])
1096fi
1097
1098if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1099 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1100fi
1101
1102if test x"$libzfs_excuse" = x ; then
1103 # We need both libzfs and libnvpair for a successful build.
1104 LIBZFS="-lzfs"
1105 AC_DEFINE([HAVE_LIBZFS], [1],
1106 [Define to 1 if you have the ZFS library.])
1107 LIBNVPAIR="-lnvpair"
1108 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1109 [Define to 1 if you have the NVPAIR library.])
1110fi
1111
1112AC_SUBST([LIBZFS])
16c7cb32
BC
1113AC_SUBST([LIBNVPAIR])
1114
9f915872
VS
1115LIBS=""
1116
76ed06b9 1117AC_SUBST([FONT_SOURCE])
76ed06b9
BC
1118AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1119 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
76ed06b9
BC
1120AS_IF([test x$TARGET_APPLE_CC = x1],
1121 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
7181e228 1122
742f9232
VS
1123AC_SUBST(HAVE_ASM_USCORE)
1124AC_SUBST(ADDR32)
1125AC_SUBST(DATA32)
1126AC_SUBST(BSS_START_SYMBOL)
1127AC_SUBST(END_SYMBOL)
1128AC_SUBST(PACKAGE)
1129AC_SUBST(VERSION)
1130AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
1131AC_SUBST(NEED_REGISTER_FRAME_INFO)
1132
76ed06b9
BC
1133#
1134# Automake conditionals
1135#
8c411768 1136
76ed06b9
BC
1137AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1138AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1139AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
6585de4c 1140AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
76ed06b9
BC
1141AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1142AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1143AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1144AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1145AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
4959e111
VS
1146AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1147AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
8906c3dd 1148AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
76ed06b9
BC
1149AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1150AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
4959e111 1151AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
37ba07eb
VS
1152AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1153AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
f7711f5e
BC
1154
1155AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1156AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1157AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1158AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1159AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
b105df76 1160AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
958ee221 1161AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
2d465fb0 1162
76ed06b9
BC
1163AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1164AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1165AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1166AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1167AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
897e6207 1168AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
76ed06b9 1169AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
76ed06b9 1170AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
771111e5 1171AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
76ed06b9 1172AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
c5dc1690 1173AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
e744219b 1174AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
fc45fb58 1175
742f9232 1176AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
f1632d4d 1177AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin])
c5884973 1178AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
742f9232 1179
6a161fa9 1180# Output files.
4959e111
VS
1181cpudir="${target_cpu}"
1182if test x${cpudir} = xmipsel; then
1183 cpudir=mips;
1184fi
1f4147aa 1185grub_CHECK_LINK_DIR
1186if test x"$link_dir" = xyes ; then
4959e111 1187 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
f84b481b 1188 if test "$platform" != emu ; then
4959e111 1189 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
f84b481b 1190 fi
1f4147aa 1191else
1192 mkdir -p include/grub 2>/dev/null
1193 rm -rf include/grub/cpu
4959e111 1194 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
f84b481b
RM
1195 if test "$platform" != emu ; then
1196 rm -rf include/grub/machine
4959e111 1197 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
f84b481b 1198 fi
1f4147aa 1199fi
6304d292 1200
8c411768 1201AC_CONFIG_FILES([Makefile])
6304d292 1202AC_CONFIG_FILES([grub-core/Makefile])
15c69261 1203AC_CONFIG_FILES([grub-core/gnulib/Makefile])
269004c1 1204AC_CONFIG_FILES([po/Makefile.in])
8c411768 1205AC_CONFIG_FILES([docs/Makefile])
b23ffd70 1206AC_CONFIG_FILES([util/bash-completion.d/Makefile])
6a161fa9 1207AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
742f9232 1208AC_CONFIG_FILES([config.h])
8c411768 1209
6a161fa9 1210AC_OUTPUT
5ce5507f 1211[
1212echo "*******************************************************"
1213echo GRUB2 will be compiled with following components:
1214echo Platform: "$target_cpu"-"$platform"
f84b481b 1215if [ x"$platform" = xemu ]; then
5ce5507f 1216if [ x"$grub_emu_usb_excuse" = x ]; then
1217echo USB support for grub-emu: Yes
1218else
1219echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1220fi
927d0134
VS
1221if [ x"$grub_emu_sdl_excuse" = x ]; then
1222echo SDL support for grub-emu: Yes
1223else
1224echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1225fi
325c8258 1226if [ x"$grub_emu_pci_excuse" = x ]; then
1227echo PCI support for grub-emu: Yes
1228else
1229echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1230fi
f84b481b 1231fi
61d720e5
VS
1232if test x"$device_mapper_excuse" = x ; then
1233echo With devmapper support: Yes
1234else
1235echo With devmapper support: No "($device_mapper_excuse)"
1236fi
5ce5507f 1237if [ x"$enable_mm_debug" = xyes ]; then
1238echo With memory debugging: Yes
1239else
1240echo With memory debugging: No
1241fi
c5dc1690
SJ
1242if [ x"$enable_cache_stats" = xyes ]; then
1243echo With disk cache statistics: Yes
1244else
1245echo With disk cache statistics: No
1246fi
e744219b
VS
1247
1248if [ x"$enable_boot_time" = xyes ]; then
1249echo With boot time statistics: Yes
1250else
1251echo With boot time statistics: No
1252fi
1253
5ce5507f 1254if [ x"$efiemu_excuse" = x ]; then
1255echo efiemu runtime: Yes
1256else
1257echo efiemu runtime: No "($efiemu_excuse)"
1258fi
5ce5507f 1259if [ x"$grub_mkfont_excuse" = x ]; then
1260echo grub-mkfont: Yes
1261else
1262echo grub-mkfont: No "($grub_mkfont_excuse)"
1263fi
897e6207 1264if [ x"$grub_mount_excuse" = x ]; then
89644ef1 1265echo grub-mount: Yes
92bb0786 1266else
897e6207 1267echo grub-mount: No "($grub_mount_excuse)"
92bb0786 1268fi
c5884973
DO
1269if [ x"$starfield_excuse" = x ]; then
1270echo starfield theme: Yes
1271else
1272echo starfield theme: No "($starfield_excuse)"
1273fi
e4c498a1
MG
1274if [ x"$libzfs_excuse" = x ]; then
1275echo With libzfs support: Yes
1276else
1277echo With libzfs support: No "($libzfs_excuse)"
1278fi
5ce5507f 1279echo "*******************************************************"
1280]