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