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