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