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