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