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