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