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