]> git.proxmox.com Git - grub2.git/blame - configure.ac
* grub-core/fs/iso9660.c (grub_iso9660_susp_iterate): Avoid hang if
[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])
67grub_TRANSFORM([grub-setup])
68grub_TRANSFORM([grub-sparc64-setup])
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
76ed06b9
BC
361#
362# Check for host and build compilers.
363#
364HOST_CC=$CC
365AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
366 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
367
15c69261
YB
368# For gnulib.
369gl_INIT
370
b977bf01 371#
372# Check for target programs.
373#
374
5b5d4aa5 375# Find tools for the target.
376if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
b977bf01 377 tmp_ac_tool_prefix="$ac_tool_prefix"
378 ac_tool_prefix=$target_alias-
379
380 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
381 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
382 AC_CHECK_TOOL(OBJCOPY, objcopy)
383 AC_CHECK_TOOL(STRIP, strip)
384 AC_CHECK_TOOL(NM, nm)
385
386 ac_tool_prefix="$tmp_ac_tool_prefix"
387else
388 if test "x$TARGET_CC" = x; then
389 TARGET_CC=$CC
390 fi
391 AC_CHECK_TOOL(OBJCOPY, objcopy)
392 AC_CHECK_TOOL(STRIP, strip)
393 AC_CHECK_TOOL(NM, nm)
394fi
76ed06b9
BC
395AC_SUBST(HOST_CC)
396AC_SUBST(BUILD_CC)
b977bf01 397AC_SUBST(TARGET_CC)
398
b977bf01 399# Test the C compiler for the target environment.
400tmp_CC="$CC"
401tmp_CFLAGS="$CFLAGS"
402tmp_LDFLAGS="$LDFLAGS"
403tmp_CPPFLAGS="$CPPFLAGS"
aa6d7826 404tmp_LIBS="$LIBS"
b977bf01 405CC="$TARGET_CC"
406CFLAGS="$TARGET_CFLAGS"
407CPPFLAGS="$TARGET_CPPFLAGS"
408LDFLAGS="$TARGET_LDFLAGS"
aa6d7826 409LIBS=""
b977bf01 410
90d1e879 411# debug flags.
c2deb798 412WARN_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 413HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
4e27343f 414TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
76ed06b9 415TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
6a161fa9 416
90d1e879
RM
417# Force no alignment to save space on i386.
418if test "x$target_cpu" = xi386; then
419 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
420 CFLAGS="$CFLAGS -falign-loops=1"
eb73121d 421 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
90d1e879
RM
422 [grub_cv_cc_falign_loop=yes],
423 [grub_cv_cc_falign_loop=no])
6a161fa9 424 ])
6a161fa9 425
90d1e879
RM
426 if test "x$grub_cv_cc_falign_loop" = xyes; then
427 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
6a161fa9 428 else
90d1e879 429 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
6a161fa9 430 fi
431
90d1e879
RM
432 # Some toolchains enable these features by default, but they need
433 # registers that aren't set up properly in GRUB.
434 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
435fi
77c55a87 436
90d1e879
RM
437# By default, GCC 4.4 generates .eh_frame sections containing unwind
438# information in some cases where it previously did not. GRUB doesn't need
439# these and they just use up vital space. Restore the old compiler
440# behaviour.
441AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
442 SAVE_CFLAGS="$CFLAGS"
443 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
444 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
445 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
446 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
447 CFLAGS="$SAVE_CFLAGS"
448])
77c55a87 449
90d1e879
RM
450if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
451 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
b977bf01 452fi
6a161fa9 453
e9d3421c
VS
454# By default, GCC 4.6 generates .eh_frame sections containing unwind
455# information in some cases where it previously did not. GRUB doesn't need
456# these and they just use up vital space. Restore the old compiler
457# behaviour.
458AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
459 SAVE_CFLAGS="$CFLAGS"
460 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
462 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
463 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
464 CFLAGS="$SAVE_CFLAGS"
465])
466
467if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
468 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
469fi
470
2b167a72 471grub_apple_target_cc
c9da87d0 472if test x$grub_cv_apple_target_cc = xyes ; then
403e25a5 473 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -fnested-functions"
76ed06b9 474
6fd0b143 475 CFLAGS="$CFLAGS -fnested-functions"
2b167a72 476 TARGET_APPLE_CC=1
cf00df31 477 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
478 if test "x$OBJCONV" = x ; then
479 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
480 fi
481 if test "x$OBJCONV" = x ; then
482 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
483 fi
2b167a72 484 TARGET_IMG_LDSCRIPT=
485 TARGET_IMG_CFLAGS="-static"
76ed06b9
BC
486 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
487 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
488 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
46cf439c 489 TARGET_LDFLAGS_OLDMAGIC=""
2b167a72 490else
491 TARGET_APPLE_CC=0
f04a9a21 492 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
2b167a72 493# Use linker script if present, otherwise use builtin -N script.
76ed06b9
BC
494if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
495 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
496 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
497 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
498 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
2b167a72 499else
500 TARGET_IMG_LDSCRIPT=
76ed06b9
BC
501 TARGET_IMG_LDFLAGS='-Wl,-N'
502 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
503 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
2b167a72 504fi
505TARGET_IMG_CFLAGS=
506fi
507
46cf439c
VS
508AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
509
2b167a72 510# For platforms where ELF is not the default link format.
511AC_MSG_CHECKING([for command to convert module to ELF format])
512case "${host_os}" in
f1632d4d 513 cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf';
4b0cd8f8 514# FIXME: put proper test here
742f9232 515 NEED_REGISTER_FRAME_INFO=1
4b0cd8f8 516 ;;
742f9232 517 *) NEED_REGISTER_FRAME_INFO=0 ;;
2b167a72 518esac
2b167a72 519AC_MSG_RESULT([$TARGET_OBJ2ELF])
520
30c7d3ce
VS
521
522AC_ARG_ENABLE([efiemu],
523 [AS_HELP_STRING([--enable-efiemu],
524 [build and install the efiemu runtimes (default=guessed)])])
525if test x"$enable_efiemu" = xno ; then
526 efiemu_excuse="explicitly disabled"
527fi
528if test x"$target_cpu" != xi386 ; then
529 efiemu_excuse="only available on i386"
530fi
531if test x"$platform" = xefi ; then
532 efiemu_excuse="not available on efi"
533fi
534if test x"$efiemu_excuse" = x ; then
535 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
dfc8aeb0 536 SAVED_CFLAGS="$CFLAGS"
30c7d3ce
VS
537 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
539 [grub_cv_cc_efiemu=yes],
540 [grub_cv_cc_efiemu=no])
dfc8aeb0 541 CFLAGS="$SAVED_CFLAGS"
30c7d3ce
VS
542 ])
543 if test x$grub_cv_cc_efiemu = xno; then
544 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
545 fi
546fi
547if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
548 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
549fi
550if test x"$efiemu_excuse" = x ; then
551enable_efiemu=yes
552else
553enable_efiemu=no
554fi
555AC_SUBST([enable_efiemu])
556
b977bf01 557if test "x$target_m32" = x1; then
558 # Force 32-bit mode.
559 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
76ed06b9 560 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
19e81ba7 561 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
b977bf01 562 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
2b167a72 563 TARGET_MODULE_FORMAT="elf32"
6a161fa9 564fi
b977bf01 565
20011694 566if test "x$target_m64" = x1; then
567 # Force 64-bit mode.
7e9ca17a 568 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
76ed06b9 569 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
19e81ba7 570 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
7e9ca17a 571 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
2b167a72 572 TARGET_MODULE_FORMAT="elf64"
7e9ca17a 573fi
574
575if test "$target_cpu"-"$platform" = x86_64-efi; then
576 # Use large model to support 4G memory
6e09b8b7 577 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
c8600122 578 SAVED_CFLAGS=$CFLAGS
579 CFLAGS="$CFLAGS -m64 -mcmodel=large"
6e09b8b7 580 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
581 [grub_cv_cc_mcmodel=yes],
582 [grub_cv_cc_mcmodel=no])
583 ])
c8600122 584 if test "x$grub_cv_cc_mcmodel" = xno; then
4ba8d354 585 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
c8600122 586 else
587 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
6e09b8b7 588 fi
7e9ca17a 589
590 # EFI writes to stack below %rsp, we must not use the red zone
591 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
c8600122 592 CFLAGS="$CFLAGS -m64 -mno-red-zone"
7e9ca17a 593 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
594 [grub_cv_cc_no_red_zone=yes],
595 [grub_cv_cc_no_red_zone=no])
596 ])
597 if test "x$grub_cv_cc_no_red_zone" = xno; then
598 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
599 fi
600
c8600122 601 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
20011694 602fi
603
baa2a121 604#
605# Compiler features.
606#
607
9035dce4 608# Need __enable_execute_stack() for nested function trampolines?
609grub_CHECK_ENABLE_EXECUTE_STACK
610
93a81088 611# Position independent executable.
612grub_CHECK_PIE
613[# Need that, because some distributions ship compilers that include
614# `-fPIE' in the default specs.
615if [ x"$pie_possible" = xyes ]; then
616 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
617fi]
618
7bd8b0c7
VS
619# Position independent executable.
620grub_CHECK_PIC
621[# Need that, because some distributions ship compilers that include
622# `-fPIC' in the default specs.
623if [ x"$pic_possible" = xyes ]; then
624 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
625fi]
626
baa2a121 627# Smashing stack protector.
628grub_CHECK_STACK_PROTECTOR
c3db8364 629# Need that, because some distributions ship compilers that include
baa2a121 630# `-fstack-protector' in the default specs.
c3db8364 631if test "x$ssp_possible" = xyes; then
632 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
633fi
2a8a80e4 634grub_CHECK_STACK_ARG_PROBE
635# Cygwin's GCC uses alloca() to probe the stackframe on static
636# stack allocations above some threshold.
637if test x"$sap_possible" = xyes; then
638 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
639fi
baa2a121 640
63f745e8 641AC_ARG_ENABLE([werror],
642 [AS_HELP_STRING([--disable-werror],
643 [do not use -Werror when building GRUB])])
644if test x"$enable_werror" != xno ; then
645 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
ebcecdf1 646 HOST_CFLAGS="$HOST_CFLAGS -Werror"
63f745e8 647fi
648
76ed06b9
BC
649TARGET_CPP="$TARGET_CC -E"
650TARGET_CCAS=$TARGET_CC
651
92cd0f6e
VS
652GRUB_TARGET_CPU="${target_cpu}"
653GRUB_PLATFORM="${platform}"
654
655AC_SUBST(GRUB_TARGET_CPU)
656AC_SUBST(GRUB_PLATFORM)
657
cf00df31 658AC_SUBST(OBJCONV)
76ed06b9
BC
659AC_SUBST(TARGET_CPP)
660AC_SUBST(TARGET_CCAS)
661AC_SUBST(TARGET_OBJ2ELF)
2b167a72 662AC_SUBST(TARGET_APPLE_CC)
76ed06b9
BC
663AC_SUBST(TARGET_MODULE_FORMAT)
664
665AC_SUBST(TARGET_CFLAGS)
b977bf01 666AC_SUBST(TARGET_LDFLAGS)
76ed06b9
BC
667AC_SUBST(TARGET_CPPFLAGS)
668AC_SUBST(TARGET_CCASFLAGS)
669
670AC_SUBST(TARGET_IMG_LDSCRIPT)
671AC_SUBST(TARGET_IMG_LDFLAGS)
672AC_SUBST(TARGET_IMG_CFLAGS)
673AC_SUBST(TARGET_IMG_BASE_LDOPT)
674
675AC_SUBST(HOST_CFLAGS)
676AC_SUBST(HOST_LDFLAGS)
677AC_SUBST(HOST_CPPFLAGS)
678AC_SUBST(HOST_CCASFLAGS)
6a161fa9 679
aa6d7826 680# Set them to their new values for the tests below.
681CC="$TARGET_CC"
26de2bcd 682if test "x$TARGET_APPLE_CC" = x1 ; then
69be5b74 683CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
26de2bcd 684else
01fcf061 685CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
26de2bcd 686fi
aa6d7826 687CPPFLAGS="$TARGET_CPPFLAGS"
03f80960
VS
688if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
689LIBS=
690else
69be5b74 691LIBS=-lgcc
03f80960 692fi
69be5b74 693
01fcf061
VS
694grub_ASM_USCORE
695if test x$grub_cv_asm_uscore = xyes; then
696CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
697else
698CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
699fi
700
69be5b74 701# Check for libgcc symbols
2afb7f6c 702AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x __ia64_trampoline __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
69be5b74
VS
703
704if test "x$TARGET_APPLE_CC" = x1 ; then
705CFLAGS="$TARGET_CFLAGS -nostdlib"
706else
707CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
708fi
42e0cba3 709LIBS=""
aa6d7826 710
6a161fa9 711# Defined in aclocal.m4.
f6130a12 712grub_PROG_TARGET_CC
2b167a72 713if test "x$TARGET_APPLE_CC" != x1 ; then
b977bf01 714grub_PROG_OBJCOPY_ABSOLUTE
2b167a72 715fi
cb71ba20 716grub_PROG_LD_BUILD_ID_NONE
b977bf01 717if test "x$target_cpu" = xi386; then
2aec1692
CF
718 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
719 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
720 # Check symbols provided by linker script.
76ed06b9 721 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
2aec1692 722 fi
2a8a80e4 723 grub_CHECK_BSS_START_SYMBOL
724 grub_CHECK_END_SYMBOL
725 fi
726 CFLAGS="$TARGET_CFLAGS"
4b13b216 727 grub_I386_ASM_PREFIX_REQUIREMENT
728 grub_I386_ASM_ADDR32
6a161fa9 729fi
730
016a671b 731if test "$platform" != emu; then
8f9a632b
VS
732AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
733 SAVED_CPPFLAGS="$CPPFLAGS"
734 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
735 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
ce938140 736#include <stddef.h>
8f9a632b
VS
737int va_arg_func (int fixed, va_list args);]], [[]])],
738 [grub_cv_cc_isystem=yes],
739 [grub_cv_cc_isystem=no])
740 CPPFLAGS="$SAVED_CPPFLAGS"
741])
742
743if test x"$grub_cv_cc_isystem" = xyes ; then
744 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
745fi
dae79b6b 746fi
5ce5507f 747
779dc15b
VS
748AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_cc_wnotrampolines], [
749 SAVED_CFLAGS="$CFLAGS"
72b7c7aa
CW
750 # Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
751 # in the event of later failures (since -Wno-* is always accepted, but
752 # produces a diagnostic if something else is wrong).
753 CFLAGS="$TARGET_CFLAGS -Wtrampolines"
779dc15b
VS
754 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
755int va_arg_func (int fixed, va_list args);]], [[]])],
756 [grub_cv_cc_wnotrampolines=yes],
757 [grub_cv_cc_wnotrampolines=no])
758 CFLAGS="$SAVED_CFLAGS"
759])
760
761if test x"$grub_cv_cc_wnotrampolines" = xyes ; then
762 TARGET_CFLAGS="$TARGET_CFLAGS -Wno-trampolines"
763fi
764
c9a86192 765# Restore the flags.
9962ed99 766CC="$tmp_CC"
767CFLAGS="$tmp_CFLAGS"
768CPPFLAGS="$tmp_CPPFLAGS"
c9a86192 769LDFLAGS="$tmp_LDFLAGS"
aa6d7826 770LIBS="$tmp_LIBS"
6a161fa9 771
4fe9862e 772#
2965c7cc 773# Check for options.
4fe9862e 774#
775
776# Memory manager debugging.
b39f9d20 777AC_ARG_ENABLE([mm-debug],
2965c7cc 778 AS_HELP_STRING([--enable-mm-debug],
90ce5d56 779 [include memory manager debugging]),
2965c7cc 780 [AC_DEFINE([MM_DEBUG], [1],
781 [Define to 1 if you enable memory manager debugging.])])
782
c5dc1690
SJ
783AC_ARG_ENABLE([cache-stats],
784 AS_HELP_STRING([--enable-cache-stats],
055e2b8b 785 [enable disk cache statistics collection]))
c5dc1690
SJ
786
787if test x$enable_cache_stats = xyes; then
788 DISK_CACHE_STATS=1
789else
790 DISK_CACHE_STATS=0
791fi
792AC_SUBST([DISK_CACHE_STATS])
793
d64399b5 794AC_ARG_ENABLE([grub-emu-usb],
795 [AS_HELP_STRING([--enable-grub-emu-usb],
5ce5507f 796 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
5ce5507f 797
927d0134
VS
798AC_ARG_ENABLE([grub-emu-sdl],
799 [AS_HELP_STRING([--enable-grub-emu-sdl],
800 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
801
3affd0ec 802AC_ARG_ENABLE([grub-emu-pci],
803 [AS_HELP_STRING([--enable-grub-emu-pci],
804 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
805
f84b481b
RM
806if test "$platform" = emu; then
807 missing_ncurses=
808[# Check for curses libraries.]
4fe9862e 809 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
810 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
f84b481b 811 [missing_ncurses=[true]])])
4fe9862e 812 AC_SUBST([LIBCURSES])
f84b481b 813[if [ x"$missing_ncurses" = x ]; then ]
4fe9862e 814 [# Check for headers.]
815 AC_CHECK_HEADERS([ncurses/curses.h], [],
816 [AC_CHECK_HEADERS([ncurses.h], [],
817 [AC_CHECK_HEADERS([curses.h], [],
f84b481b 818 [missing_ncurses=[true]])])])
5ce5507f 819[fi]
f84b481b
RM
820if test x"$missing_ncurses" = xtrue ; then
821 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
5ce5507f 822fi
f84b481b 823
62a747cb
VS
824if test x"$enable_grub_emu_usb" != xyes ; then
825 grub_emu_usb_excuse="not enabled"
5ce5507f 826fi
325c8258 827
0e848909
VS
828if test x"$enable_grub_emu_pci" = xyes ; then
829 grub_emu_usb_excuse="conflicts with PCI support"
830fi
831
5ce5507f 832[if [ x"$grub_emu_usb_excuse" = x ]; then
d64399b5 833 # Check for libusb libraries.]
5ce5507f 834AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
e98cd0c2 835 [grub_emu_usb_excuse=["need libusb library"]])
d64399b5 836 AC_SUBST([LIBUSB])
5ce5507f 837[fi]
838[if [ x"$grub_emu_usb_excuse" = x ]; then
839 # Check for headers.]
d64399b5 840 AC_CHECK_HEADERS([usb.h], [],
e98cd0c2 841 [grub_emu_usb_excuse=["need libusb headers"]])
4fe9862e 842[fi]
c6f3b249 843if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
ce7a733d 844 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
5ce5507f 845fi
846if test x"$grub_emu_usb_excuse" = x ; then
847enable_grub_emu_usb=yes
848else
849enable_grub_emu_usb=no
850fi
851
927d0134
VS
852if test x"$enable_grub_emu_sdl" = xno ; then
853 grub_emu_sdl_excuse="explicitely disabled"
854fi
855[if [ x"$grub_emu_sdl_excuse" = x ]; then
856 # Check for libSDL libraries.]
857AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
858 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
859 AC_SUBST([LIBSDL])
860[fi]
9f293ab0 861
927d0134
VS
862[if [ x"$grub_emu_sdl_excuse" = x ]; then
863 # Check for headers.]
864 AC_CHECK_HEADERS([SDL/SDL.h], [],
865 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
866[fi]
9f293ab0 867
927d0134
VS
868if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
869 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
870fi
871if test x"$grub_emu_sdl_excuse" = x ; then
872enable_grub_emu_sdl=yes
873else
874enable_grub_emu_sdl=no
875fi
876
3affd0ec 877if test x"$enable_grub_emu_pci" != xyes ; then
325c8258 878 grub_emu_pci_excuse="not enabled"
879fi
880
881if test x"$enable_grub_emu_usb" = xyes ; then
882 grub_emu_pci_excuse="conflicts with USB support"
883fi
884
885[if [ x"$grub_emu_pci_excuse" = x ]; then
886 # Check for libpci libraries.]
459fed4b 887 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
888 [grub_emu_pci_excuse=["need libpciaccess library"]])
889 AC_SUBST([LIBPCIACCESS])
325c8258 890[fi]
891[if [ x"$grub_emu_pci_excuse" = x ]; then
892 # Check for headers.]
893 AC_CHECK_HEADERS([pci/pci.h], [],
459fed4b 894 [grub_emu_pci_excuse=["need libpciaccess headers"]])
325c8258 895[fi]
896
897if test x"$grub_emu_pci_excuse" = x ; then
898enable_grub_emu_pci=yes
899else
9f293ab0 900
325c8258 901enable_grub_emu_pci=no
3affd0ec 902fi
903
927d0134 904AC_SUBST([enable_grub_emu_sdl])
d64399b5 905AC_SUBST([enable_grub_emu_usb])
3affd0ec 906AC_SUBST([enable_grub_emu_pci])
f84b481b 907fi
4fe9862e 908
e52db1f7 909AC_ARG_ENABLE([grub-mkfont],
910 [AS_HELP_STRING([--enable-grub-mkfont],
5ce5507f 911 [build and install the `grub-mkfont' utility (default=guessed)])])
912if test x"$enable_grub_mkfont" = xno ; then
ce7a733d 913 grub_mkfont_excuse="explicitly disabled"
5ce5507f 914fi
915
916if test x"$grub_mkfont_excuse" = x ; then
e52db1f7 917 # Check for freetype libraries.
918 AC_CHECK_PROGS([FREETYPE], [freetype-config])
919 if test "x$FREETYPE" = x ; then
e98cd0c2 920 grub_mkfont_excuse=["need freetype2 library"]
e52db1f7 921 fi
e52db1f7 922fi
660960d6
VS
923
924if test x"$grub_mkfont_excuse" = x ; then
925 # Check for freetype libraries.
10854d0d
YB
926 freetype_cflags=`freetype-config --cflags`
927 freetype_libs=`freetype-config --libs`
d1e8a02f
VS
928 SAVED_CPPFLAGS="$CPPFLAGS"
929 CPPFLAGS="$CPPFLAGS $freetype_cflags"
660960d6
VS
930 AC_CHECK_HEADERS([ft2build.h], [],
931 [grub_mkfont_excuse=["need freetype2 headers"]])
d1e8a02f 932 CPPFLAGS="$SAVED_CPPFLAGS"
660960d6
VS
933fi
934
5ce5507f 935if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
ce7a733d 936 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
5ce5507f 937fi
938if test x"$grub_mkfont_excuse" = x ; then
939enable_grub_mkfont=yes
940else
941enable_grub_mkfont=no
942fi
20168fca
CW
943if test x"$enable_grub_mkfont" = xno && test "x$platform" = xloongson; then
944 AC_MSG_ERROR([loongson port needs grub-mkfont])
945fi
e52db1f7 946AC_SUBST([enable_grub_mkfont])
947AC_SUBST([freetype_cflags])
948AC_SUBST([freetype_libs])
949
c5884973
DO
950DJVU_FONT_SOURCE=
951
952starfield_excuse=
953
954if test x$enable_grub_mkfont = xno; then
955 starfield_excuse="No grub-mkfont"
956fi
957
501b9e4b 958if test x"$starfield_excuse" = x; then
c5884973 959 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
32745f51 960 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
c5884973
DO
961 if test -f "$dir/DejaVuSans.$ext"; then
962 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
963 break 2
964 fi
965 done
966 done
967
968 if test "x$DJVU_FONT_SOURCE" = x; then
969 starfield_excuse="No DejaVu found"
970 fi
971fi
972
973AC_SUBST([DJVU_FONT_SOURCE])
974
897e6207
CW
975AC_ARG_ENABLE([grub-mount],
976 [AS_HELP_STRING([--enable-grub-mount],
977 [build and install the `grub-mount' utility (default=guessed)])])
978if test x"$enable_grub_mount" = xno ; then
979 grub_mount_excuse="explicitly disabled"
92bb0786
VS
980fi
981
897e6207 982if test x"$grub_mount_excuse" = x ; then
92bb0786 983 AC_CHECK_LIB([fuse], [fuse_main_real], [],
897e6207 984 [grub_mount_excuse="need FUSE library"])
92bb0786
VS
985fi
986
897e6207 987if test x"$grub_mount_excuse" = x ; then
92bb0786
VS
988 # Check for fuse headers.
989 SAVED_CPPFLAGS="$CPPFLAGS"
338c7fab 990 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
92bb0786 991 AC_CHECK_HEADERS([fuse/fuse.h], [],
897e6207 992 [grub_mount_excuse=["need FUSE headers"]])
92bb0786
VS
993 CPPFLAGS="$SAVED_CPPFLAGS"
994fi
995
897e6207 996if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
89644ef1 997 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
92bb0786 998fi
897e6207
CW
999if test x"$grub_mount_excuse" = x ; then
1000enable_grub_mount=yes
92bb0786 1001else
897e6207 1002enable_grub_mount=no
92bb0786 1003fi
897e6207 1004AC_SUBST([enable_grub_mount])
92bb0786 1005
7181e228
CW
1006AC_ARG_ENABLE([device-mapper],
1007 [AS_HELP_STRING([--enable-device-mapper],
1008 [enable Linux device-mapper support (default=guessed)])])
1009if test x"$enable_device_mapper" = xno ; then
1010 device_mapper_excuse="explicitly disabled"
1011fi
1012
53798c4b
GS
1013if test x"$device_mapper_excuse" = x ; then
1014 # Check for device-mapper header.
1015 AC_CHECK_HEADER([libdevmapper.h], [],
1016 [device_mapper_excuse="need libdevmapper header"])
1017fi
1018
7181e228
CW
1019if test x"$device_mapper_excuse" = x ; then
1020 # Check for device-mapper library.
61d720e5 1021 AC_CHECK_LIB([devmapper], [dm_task_create], [],
7181e228 1022 [device_mapper_excuse="need devmapper library"])
7181e228 1023fi
61d720e5
VS
1024
1025if test x"$device_mapper_excuse" = x ; then
1026 # Check for device-mapper library.
1027 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1028 [],
1029 [device_mapper_excuse="need devmapper library"])
1030fi
1031
1032if test x"$device_mapper_excuse" = x ; then
1033 LIBDEVMAPPER="-ldevmapper";
1034 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1035 [Define to 1 if you have the devmapper library.])
1036fi
1037
62f7d208 1038AC_SUBST([LIBDEVMAPPER])
76ed06b9 1039
f4727da9
VS
1040LIBGEOM=
1041if test x$host_kernel = xkfreebsd; then
1042 AC_CHECK_LIB([geom], [geom_gettree], [],
1043 [AC_MSG_ERROR([Your platform requires libgeom])])
1044 LIBGEOM="-lgeom"
1045fi
1046
1047AC_SUBST([LIBGEOM])
1048
2c44e493
VS
1049AC_CHECK_LIB([lzma], [lzma_code],
1050 [LIBLZMA="-llzma"
1051 AC_DEFINE([HAVE_LIBLZMA], [1],
1052 [Define to 1 if you have the LZMA library.])],)
1053AC_SUBST([LIBLZMA])
1054
e4c498a1
MG
1055AC_ARG_ENABLE([libzfs],
1056 [AS_HELP_STRING([--enable-libzfs],
1057 [enable libzfs integration (default=guessed)])])
1058if test x"$enable_libzfs" = xno ; then
1059 libzfs_excuse="explicitly disabled"
1060fi
16c7cb32 1061
e4c498a1
MG
1062if test x"$libzfs_excuse" = x ; then
1063 # Only check for system headers if libzfs support has not been disabled.
1064 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1065fi
1066
1067if test x"$libzfs_excuse" = x ; then
1068 AC_CHECK_LIB([zfs], [libzfs_init],
1069 [],
1070 [libzfs_excuse="need zfs library"])
1071fi
1072
1073if test x"$libzfs_excuse" = x ; then
1074 AC_CHECK_LIB([nvpair], [nvlist_print],
1075 [],
1076 [libzfs_excuse="need nvpair library"])
1077fi
1078
1079if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1080 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1081fi
1082
1083if test x"$libzfs_excuse" = x ; then
1084 # We need both libzfs and libnvpair for a successful build.
1085 LIBZFS="-lzfs"
1086 AC_DEFINE([HAVE_LIBZFS], [1],
1087 [Define to 1 if you have the ZFS library.])
1088 LIBNVPAIR="-lnvpair"
1089 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1090 [Define to 1 if you have the NVPAIR library.])
1091fi
1092
1093AC_SUBST([LIBZFS])
16c7cb32
BC
1094AC_SUBST([LIBNVPAIR])
1095
9f915872
VS
1096LIBS=""
1097
76ed06b9 1098AC_SUBST([FONT_SOURCE])
76ed06b9
BC
1099AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1100 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
76ed06b9
BC
1101AS_IF([test x$TARGET_APPLE_CC = x1],
1102 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
7181e228 1103
742f9232
VS
1104AC_SUBST(HAVE_ASM_USCORE)
1105AC_SUBST(ADDR32)
1106AC_SUBST(DATA32)
1107AC_SUBST(BSS_START_SYMBOL)
1108AC_SUBST(END_SYMBOL)
1109AC_SUBST(PACKAGE)
1110AC_SUBST(VERSION)
1111AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
1112AC_SUBST(NEED_REGISTER_FRAME_INFO)
1113
76ed06b9
BC
1114#
1115# Automake conditionals
1116#
8c411768 1117
76ed06b9
BC
1118AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1119AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1120AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
6585de4c 1121AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
76ed06b9
BC
1122AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1123AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1124AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1125AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1126AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
4959e111
VS
1127AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1128AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
8906c3dd 1129AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
76ed06b9
BC
1130AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1131AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
4959e111 1132AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
37ba07eb
VS
1133AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1134AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
f7711f5e
BC
1135
1136AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1137AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1138AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1139AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1140AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
b105df76 1141AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
958ee221 1142AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
2d465fb0 1143
76ed06b9
BC
1144AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1145AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1146AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1147AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1148AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
897e6207 1149AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
76ed06b9 1150AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
76ed06b9 1151AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
771111e5 1152AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
76ed06b9 1153AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
c5dc1690 1154AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
fc45fb58 1155
742f9232 1156AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
f1632d4d 1157AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin])
c5884973 1158AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
742f9232 1159
6a161fa9 1160# Output files.
4959e111
VS
1161cpudir="${target_cpu}"
1162if test x${cpudir} = xmipsel; then
1163 cpudir=mips;
1164fi
1f4147aa 1165grub_CHECK_LINK_DIR
1166if test x"$link_dir" = xyes ; then
4959e111 1167 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
f84b481b 1168 if test "$platform" != emu ; then
4959e111 1169 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
f84b481b 1170 fi
1f4147aa 1171else
1172 mkdir -p include/grub 2>/dev/null
1173 rm -rf include/grub/cpu
4959e111 1174 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
f84b481b
RM
1175 if test "$platform" != emu ; then
1176 rm -rf include/grub/machine
4959e111 1177 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
f84b481b 1178 fi
1f4147aa 1179fi
6304d292 1180
8c411768 1181AC_CONFIG_FILES([Makefile])
6304d292 1182AC_CONFIG_FILES([grub-core/Makefile])
15c69261 1183AC_CONFIG_FILES([grub-core/gnulib/Makefile])
269004c1 1184AC_CONFIG_FILES([po/Makefile.in])
8c411768 1185AC_CONFIG_FILES([docs/Makefile])
b23ffd70 1186AC_CONFIG_FILES([util/bash-completion.d/Makefile])
6a161fa9 1187AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
742f9232 1188AC_CONFIG_FILES([config.h])
8c411768 1189
6a161fa9 1190AC_OUTPUT
5ce5507f 1191[
1192echo "*******************************************************"
1193echo GRUB2 will be compiled with following components:
1194echo Platform: "$target_cpu"-"$platform"
f84b481b 1195if [ x"$platform" = xemu ]; then
5ce5507f 1196if [ x"$grub_emu_usb_excuse" = x ]; then
1197echo USB support for grub-emu: Yes
1198else
1199echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1200fi
927d0134
VS
1201if [ x"$grub_emu_sdl_excuse" = x ]; then
1202echo SDL support for grub-emu: Yes
1203else
1204echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1205fi
325c8258 1206if [ x"$grub_emu_pci_excuse" = x ]; then
1207echo PCI support for grub-emu: Yes
1208else
1209echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1210fi
f84b481b 1211fi
61d720e5
VS
1212if test x"$device_mapper_excuse" = x ; then
1213echo With devmapper support: Yes
1214else
1215echo With devmapper support: No "($device_mapper_excuse)"
1216fi
5ce5507f 1217if [ x"$enable_mm_debug" = xyes ]; then
1218echo With memory debugging: Yes
1219else
1220echo With memory debugging: No
1221fi
c5dc1690
SJ
1222if [ x"$enable_cache_stats" = xyes ]; then
1223echo With disk cache statistics: Yes
1224else
1225echo With disk cache statistics: No
1226fi
5ce5507f 1227if [ x"$efiemu_excuse" = x ]; then
1228echo efiemu runtime: Yes
1229else
1230echo efiemu runtime: No "($efiemu_excuse)"
1231fi
5ce5507f 1232if [ x"$grub_mkfont_excuse" = x ]; then
1233echo grub-mkfont: Yes
1234else
1235echo grub-mkfont: No "($grub_mkfont_excuse)"
1236fi
897e6207 1237if [ x"$grub_mount_excuse" = x ]; then
89644ef1 1238echo grub-mount: Yes
92bb0786 1239else
897e6207 1240echo grub-mount: No "($grub_mount_excuse)"
92bb0786 1241fi
c5884973
DO
1242if [ x"$starfield_excuse" = x ]; then
1243echo starfield theme: Yes
1244else
1245echo starfield theme: No "($starfield_excuse)"
1246fi
e4c498a1
MG
1247if [ x"$libzfs_excuse" = x ]; then
1248echo With libzfs support: Yes
1249else
1250echo With libzfs support: No "($libzfs_excuse)"
1251fi
5ce5507f 1252echo "*******************************************************"
1253]