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