]> git.proxmox.com Git - grub2.git/blob - configure.ac
verifiers: Add possibility to verify kernel and modules command lines
[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, variables with prefix "BUILD_"
30 dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables
31 dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are
32 dnl used for the target type. See INSTALL for full list of variables.
33
34 AC_INIT([GRUB],[2.03],[bug-grub@gnu.org])
35
36 AC_CONFIG_AUX_DIR([build-aux])
37
38 # We don't want -g -O2 by default in CFLAGS
39 : ${CFLAGS=""}
40
41 # Checks for build, host and target systems.
42 AC_CANONICAL_BUILD
43 AC_CANONICAL_HOST
44 save_program_prefix="${program_prefix}"
45 AC_CANONICAL_TARGET
46 program_prefix="${save_program_prefix}"
47
48 AM_INIT_AUTOMAKE([1.10.1])
49 AC_PREREQ(2.60)
50 AC_CONFIG_SRCDIR([include/grub/dl.h])
51 AC_CONFIG_HEADER([config-util.h])
52
53 # Explicitly check for pkg-config early on, since otherwise conditional
54 # calls are problematic.
55 PKG_PROG_PKG_CONFIG
56
57 # Program name transformations
58 AC_ARG_PROGRAM
59 grub_TRANSFORM([grub-bios-setup])
60 grub_TRANSFORM([grub-editenv])
61 grub_TRANSFORM([grub-install])
62 grub_TRANSFORM([grub-mkconfig])
63 grub_TRANSFORM([grub-mkfont])
64 grub_TRANSFORM([grub-mkimage])
65 grub_TRANSFORM([grub-glue-efi])
66 grub_TRANSFORM([grub-mklayout])
67 grub_TRANSFORM([grub-mkpasswd-pbkdf2])
68 grub_TRANSFORM([grub-mkrelpath])
69 grub_TRANSFORM([grub-mkrescue])
70 grub_TRANSFORM([grub-probe])
71 grub_TRANSFORM([grub-reboot])
72 grub_TRANSFORM([grub-script-check])
73 grub_TRANSFORM([grub-set-default])
74 grub_TRANSFORM([grub-sparc64-setup])
75 grub_TRANSFORM([grub-render-label])
76 grub_TRANSFORM([grub-file])
77
78 # Optimization flag. Allow user to override.
79 if test "x$TARGET_CFLAGS" = x; then
80 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
81 fi
82
83 # Default HOST_CPPFLAGS
84 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
85 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
86
87 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
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 aarch64*)
105 target_cpu=arm64
106 ;;
107 esac
108
109 # Specify the platform (such as firmware).
110 AC_ARG_WITH([platform],
111 AS_HELP_STRING([--with-platform=PLATFORM],
112 [select the host platform [[guessed]]]))
113
114 # Guess the platform if not specified.
115 if test "x$with_platform" = x; then
116 case "$target_cpu"-"$target_vendor" in
117 i386-apple) platform=efi ;;
118 i386-*) platform=pc ;;
119 x86_64-apple) platform=efi ;;
120 x86_64-*) platform=pc ;;
121 powerpc-*) platform=ieee1275 ;;
122 powerpc64-*) platform=ieee1275 ;;
123 powerpc64le-*) platform=ieee1275 ;;
124 sparc64-*) platform=ieee1275 ;;
125 mipsel-*) platform=loongson ;;
126 mips-*) platform=arc ;;
127 ia64-*) platform=efi ;;
128 arm-*) platform=uboot ;;
129 arm64-*) platform=efi ;;
130 *)
131 AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
132 platform=none
133 ;;
134 esac
135 else
136 platform="$with_platform"
137 fi
138
139 case "$target_cpu"-"$platform" in
140 x86_64-efi) ;;
141 x86_64-emu) ;;
142 x86_64-xen) ;;
143 x86_64-none) ;;
144 x86_64-*) target_cpu=i386 ;;
145 powerpc64-ieee1275) target_cpu=powerpc ;;
146 powerpc64le-ieee1275) target_cpu=powerpc ;;
147 esac
148
149 # Check if the platform is supported, make final adjustments.
150 case "$target_cpu"-"$platform" in
151 i386-efi) ;;
152 x86_64-efi) ;;
153 i386-xen) ;;
154 x86_64-xen) ;;
155 i386-pc) ;;
156 i386-multiboot) ;;
157 i386-coreboot) ;;
158 i386-linuxbios) platform=coreboot ;;
159 i386-ieee1275) ;;
160 i386-qemu) ;;
161 powerpc-ieee1275) ;;
162 sparc64-ieee1275) ;;
163 ia64-efi) ;;
164 mips-qemu_mips) ;;
165 mips-qemu-mips) platform=qemu_mips;;
166 mips-arc) ;;
167 mipsel-arc) ;;
168 mipsel-qemu_mips) ;;
169 mipsel-qemu-mips) platform=qemu_mips;;
170 mipsel-yeeloong) platform=loongson ;;
171 mipsel-fuloong) platform=loongson ;;
172 mipsel-loongson) ;;
173 arm-uboot) ;;
174 arm-coreboot) ;;
175 arm-efi) ;;
176 arm64-efi) ;;
177 *-emu) ;;
178 *-none) ;;
179 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
180 esac
181
182 if test x$platform != xemu ; then
183 case "$target_cpu" in
184 i386 | powerpc) target_m32=1 ;;
185 x86_64 | sparc64) target_m64=1 ;;
186 esac
187 fi
188
189 if test x"$target_cpu-$platform" = xsparc64-emu ; then
190 target_m64=1
191 fi
192
193 case "$target_os" in
194 windows* | mingw32*) target_os=cygwin ;;
195 esac
196
197 # This normalizes the names, and creates a new variable ("host_kernel")
198 # while at it, since the mapping is not always 1:1 (e.g. different OSes
199 # using the same kernel type).
200 case "$host_os" in
201 gnu*) host_kernel=hurd ;;
202 linux*) host_kernel=linux ;;
203 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
204 netbsd*) host_kernel=netbsd ;;
205 solaris*) host_kernel=illumos ;;
206 darwin*) host_kernel=xnu ;;
207 cygwin | windows* | mingw32*) host_kernel=windows ;;
208 esac
209
210 case "$host_os" in
211 cygwin) have_exec=y ;;
212 windows* | mingw32*) have_exec=n ;;
213 aros*) have_exec=n ;;
214 *) have_exec=y;;
215 esac
216
217 case "$platform" in
218 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
219 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
220 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
221 xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
222 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
223 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
224 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
225 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
226 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
227 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;;
228 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;;
229 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
230 esac
231 if test x${target_cpu} = xmipsel ; then
232 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
233 else
234 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
235 fi
236
237 case "${target_cpu}-$platform" in
238 mips-arc)
239 TARGET_LINK_ADDR=0x88200000
240 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
241 ;;
242 mipsel-arc)
243 TARGET_LINK_ADDR=0x80700000
244 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
245 ;;
246 mips*-qemu_mips | mips*-loongson)
247 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
248 ;;
249 esac
250
251 AC_SUBST(TARGET_LINK_ADDR)
252 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
253
254 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
255
256 AC_SUBST(host_cpu)
257 AC_SUBST(host_os)
258 AC_SUBST(host_kernel)
259
260 AC_SUBST(target_cpu)
261 AC_SUBST(platform)
262
263 # Define default variables
264
265 have_with_bootdir=n
266 AC_ARG_WITH([bootdir],
267 AS_HELP_STRING([--with-bootdir=DIR],
268 [set the name of /boot directory [[guessed]]]),
269 [have_with_bootdir=y],
270 [have_with_bootdir=n])
271 if test x$have_with_bootdir = xy; then
272 bootdirname="$with_bootdir"
273 else
274 case "$host_os" in
275 netbsd* | openbsd*)
276 # Because /boot is used for the boot block in NetBSD and OpenBSD,
277 bootdirname='' ;;
278 *) bootdirname='boot' ;;
279 esac
280 fi
281
282 AC_SUBST(bootdirname)
283 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
284 [Default boot directory name])
285
286 AC_ARG_WITH([grubdir],
287 AS_HELP_STRING([--with-grubdir=DIR],
288 [set the name of grub directory [[guessed]]]),
289 [grubdirname="$with_grubdir"],
290 [grubdirname="$PACKAGE"])
291
292 AC_SUBST(grubdirname)
293 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
294 [Default grub directory name])
295
296 #
297 # Checks for build programs.
298 #
299
300 # Although cmp is listed in the GNU Coding Standards as a command which
301 # can used directly, OpenBSD lacks cmp in the default installation.
302 AC_CHECK_PROGS([CMP], [cmp])
303 if test "x$CMP" = x; then
304 AC_MSG_ERROR([cmp is not found])
305 fi
306
307 AC_CHECK_PROGS([YACC], [bison])
308 if test "x$YACC" = x; then
309 AC_MSG_ERROR([bison is not found])
310 fi
311
312 AC_PROG_RANLIB
313 AC_PROG_INSTALL
314 AC_PROG_AWK
315 AC_PROG_LEX
316 AC_PROG_YACC
317 AC_PROG_MAKE_SET
318 AC_PROG_MKDIR_P
319 AC_PROG_LN_S
320
321 if test "x$LEX" = "x:"; then
322 AC_MSG_ERROR([flex is not found])
323 else
324 version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
325 if test -n "$version" -a "$version" -ge 20535; then
326 :
327 else
328 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
329 fi
330 fi
331
332 # These are not a "must".
333 AC_PATH_PROGS(MAKEINFO, makeinfo true)
334
335 #
336 # Checks for host programs.
337 #
338
339 AC_PROG_CC
340 gl_EARLY
341 AC_PROG_CXX
342 AM_PROG_CC_C_O
343 AM_PROG_AS
344 AM_PATH_PYTHON([2.6])
345
346 # Must be GCC.
347 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
348
349 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
350
351 AC_GNU_SOURCE
352 AM_GNU_GETTEXT([external])
353 AC_SYS_LARGEFILE
354
355 # Identify characteristics of the host architecture.
356 unset ac_cv_c_bigendian
357
358 if test x"$target_cpu-$platform" = xsparc64-emu ; then
359 CFLAGS="$CFLAGS -m64"
360 HOST_CFLAGS="$HOST_CFLAGS -m64"
361 fi
362
363 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
364 HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
365
366 AC_C_BIGENDIAN
367 AC_CHECK_SIZEOF(void *)
368 AC_CHECK_SIZEOF(long)
369
370 case "$host_os" in
371 cygwin | windows* | mingw32*)
372 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
373 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
374 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
375 ;;
376 esac
377
378 case "$host_os" in
379 cygwin | windows* | mingw32* | aros*)
380 ;;
381 *)
382 AC_CHECK_SIZEOF(off_t)
383 if test x"$ac_cv_sizeof_off_t" != x8 ; then
384 AC_CHECK_SIZEOF(off64_t)
385 test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required])
386 fi;;
387 esac
388
389 if test x$USE_NLS = xno; then
390 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
391 fi
392
393 if test "x$cross_compiling" = xyes; then
394 AC_MSG_WARN([cannot generate manual pages while cross compiling])
395 else
396 AC_PATH_PROG(HELP2MAN, help2man)
397 fi
398
399 # Check for functions and headers.
400 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
401 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
402
403 # glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
404 # warning which causes compilation failure later with -Werror. So use -Werror here
405 # as well to force proper sys/sysmacros.h detection.
406 SAVED_CFLAGS="$CFLAGS"
407 CFLAGS="$HOST_CFLAGS -Werror"
408 AC_HEADER_MAJOR
409 CFLAGS="$SAVED_CFLAGS"
410
411 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
412 #include <sys/param.h>
413 #include <sys/mount.h>])
414
415 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
416 #include <sys/param.h>
417 #include <sys/mount.h>])
418
419 # For opendisk() and getrawpartition() on NetBSD.
420 # Used in util/deviceiter.c and in util/hostdisk.c.
421 AC_CHECK_HEADER([util.h], [
422 AC_CHECK_LIB([util], [opendisk], [
423 LIBUTIL="-lutil"
424 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
425 ])
426 AC_CHECK_LIB([util], [getrawpartition], [
427 LIBUTIL="-lutil"
428 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
429 ])
430 ])
431 AC_SUBST([LIBUTIL])
432
433 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
434 SAVED_CFLAGS="$CFLAGS"
435 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
436 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
437 int va_arg_func (int fixed, va_list args);]], [[]])],
438 [grub_cv_host_cc_wtrampolines=yes],
439 [grub_cv_host_cc_wtrampolines=no])
440 CFLAGS="$SAVED_CFLAGS"
441 ])
442
443 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
444 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
445 fi
446
447 #
448 # Check for host and build compilers.
449 #
450 HOST_CC=$CC
451 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
452 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
453 BUILD_CPP="$BUILD_CC -E"
454
455 case "$build_os" in
456 haiku*) BUILD_LIBM= ;;
457 *) BUILD_LIBM=-lm ;;
458 esac
459
460 dnl FIXME proper test seems to require too deep dive into Autoconf internals.
461 dnl For now just list known platforms that we support.
462
463 case "$build_os" in
464 cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
465 *) BUILD_EXEEXT= ;;
466 esac
467 AC_SUBST(BUILD_EXEEXT)
468
469 # In some build environments like termux /bin/sh is not a valid
470 # shebang. Use $SHELL instead if it's executable and /bin/sh isn't
471 BUILD_SHEBANG=/bin/sh
472 for she in /bin/sh "$SHELL"; do
473 if test -x "$she" ; then
474 BUILD_SHEBANG="$she"
475 fi
476 done
477 AC_SUBST(BUILD_SHEBANG)
478
479 # For gnulib.
480 gl_INIT
481
482 WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes"
483 EXTRA_WARN_FLAGS="-Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2"
484
485 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
486
487 AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
488 SAVED_CFLAGS="$CFLAGS"
489 grub_cv_cc_w_extra_flags=
490 for x in $EXTRA_WARN_FLAGS; do
491 CFLAGS="$HOST_CFLAGS $x -Werror"
492 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
493 if test x$flag = x1 ; then
494 grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
495 fi
496 done
497 CFLAGS="$SAVED_CFLAGS"
498 ])
499
500 HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
501
502 #
503 # Check for target programs.
504 #
505
506 # Find tools for the target.
507 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
508 tmp_ac_tool_prefix="$ac_tool_prefix"
509 ac_tool_prefix=$target_alias-
510
511 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
512 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
513 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
514 AC_CHECK_TOOL(TARGET_STRIP, strip)
515 AC_CHECK_TOOL(TARGET_NM, nm)
516 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
517
518 ac_tool_prefix="$tmp_ac_tool_prefix"
519 else
520 if test "x$TARGET_CC" = x; then
521 TARGET_CC=$CC
522 fi
523 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
524 AC_CHECK_TOOL(TARGET_STRIP, strip)
525 AC_CHECK_TOOL(TARGET_NM, nm)
526 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
527 fi
528
529 AC_SUBST(HOST_CC)
530 AC_SUBST(BUILD_CC)
531 AC_SUBST(BUILD_CFLAGS)
532 AC_SUBST(BUILD_CPPFLAGS)
533 AC_SUBST(BUILD_LDFLAGS)
534 AC_SUBST(TARGET_CC)
535 AC_SUBST(TARGET_NM)
536 AC_SUBST(TARGET_RANLIB)
537 AC_SUBST(TARGET_STRIP)
538 AC_SUBST(TARGET_OBJCOPY)
539
540 # Test the C compiler for the target environment.
541 tmp_CC="$CC"
542 tmp_CFLAGS="$CFLAGS"
543 tmp_LDFLAGS="$LDFLAGS"
544 tmp_CPPFLAGS="$CPPFLAGS"
545 tmp_LIBS="$LIBS"
546 CC="$TARGET_CC"
547 CFLAGS="$TARGET_CFLAGS"
548 CPPFLAGS="$TARGET_CPPFLAGS"
549 LDFLAGS="$TARGET_LDFLAGS"
550 LIBS=""
551
552 # debug flags.
553 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
554 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
555
556 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
557 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
558 fi
559
560 TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
561
562 AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
563 LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
564
565 grub_cv_target_cc_w_extra_flags=
566 for x in $EXTRA_WARN_FLAGS; do
567 CFLAGS="$TARGET_CFLAGS $x -Werror"
568 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
569 asm (".globl start; start:");
570 void __main (void);
571 void __main (void) {}
572 int main (void);
573 ]], [[]])], [flag=1], [flag=0])
574 if test x$flag = x1 ; then
575 grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
576 fi
577 done
578 ])
579
580 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
581
582 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
583 [
584 CFLAGS="$TARGET_CFLAGS"
585 AC_COMPILE_IFELSE(
586 [AC_LANG_PROGRAM([], [[
587 #ifdef __clang__
588 #error "is clang"
589 #endif
590 ]])],
591 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
592
593 if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
594 AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
595 grub_cv_target_cc_big_endian=no
596 for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
597 "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
598 "-EB" "-mbig-endian"; do
599 if test x"$grub_cv_target_cc_big_endian" != xno ; then
600 break
601 fi
602 CFLAGS="$TARGET_CFLAGS $cand -Werror"
603 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
604 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
605 #error still little endian
606 #endif
607 asm (".globl start; start:");
608 asm (".globl _start; _start:");
609 asm (".globl __start; __start:");
610 void __main (void);
611 void __main (void) {}
612 int main (void);
613 ]], [[]])],
614 [grub_cv_target_cc_big_endian="$cand"], [])
615 done
616 ])
617
618 if test x"$grub_cv_target_cc_big_endian" = xno ; then
619 AC_MSG_ERROR([could not force big-endian])
620 fi
621
622 skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
623
624 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
625 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
626 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
627 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
628 elif test x$target_cpu = xmipsel; then
629 AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
630 grub_cv_target_cc_little_endian=no
631 for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
632 "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
633 "-EL"; do
634 if test x"$grub_cv_target_cc_little_endian" != xno ; then
635 break
636 fi
637 CFLAGS="$TARGET_CFLAGS $cand -Werror"
638 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
639 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
640 #error still big endian
641 #endif
642 asm (".globl start; start:");
643 asm (".globl _start; _start:");
644 asm (".globl __start; __start:");
645 void __main (void);
646 void __main (void) {}
647 int main (void);
648 ]], [[]])],
649 [grub_cv_target_cc_little_endian="$cand"], [])
650 done
651 ])
652
653 if test x"$grub_cv_target_cc_little_endian" = xno ; then
654 AC_MSG_ERROR([could not force little-endian])
655 fi
656
657 skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
658
659 TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
660 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
661 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
662 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
663 fi
664
665 # GRUB code is N32-compliant but it's experimental and we would prefer to
666 # avoid having too much variety when it doesn't result in any real improvement.
667 # Moreover N64 isn't supported.
668 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
669 AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
670 grub_cv_target_cc_mips_o32_abi=no
671 for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
672 if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
673 break
674 fi
675 CFLAGS="$TARGET_CFLAGS $arg -Werror"
676 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
677 #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
678 #error not o32 ABI
679 #endif
680 asm (".globl start; start:");
681 asm (".globl _start; _start:");
682 asm (".globl __start; __start:");
683 void __main (void);
684 void __main (void) {}
685 int main (void);
686 ]], [[]])],
687 [grub_cv_target_cc_mips_o32_abi="$arg"], [])
688 done
689 ])
690
691 if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
692 AC_MSG_ERROR([could not force MIPS o32 ABI])
693 fi
694
695 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
696 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
697 fi
698
699 AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
700 test_program=
701 case "x$target_cpu-$platform" in
702 xmips-* | xmipsel-*)
703 test_program=mips
704 ;;
705 xi386-pc)
706 test_program=i386-pc
707 ;;
708 xi386-* | xx86_64-*)
709 test_program=i386
710 ;;
711 xpowerpc-* | xsparc64-* | xarm-*)
712 test_program=$target_cpu
713 ;;
714 esac
715 if test x"$test_program" = x ; then
716 grub_cv_cc_target_asm_compile=
717 else
718 found=no
719 for arg in "" "-no-integrated-as"; do
720 cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
721 echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
722 if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
723 grub_cv_cc_target_asm_compile="$arg"
724 found=yes
725 break
726 fi
727 done
728 if test x"$found" = xno ; then
729 AC_MSG_ERROR([could not compile assembly])
730 fi
731 fi
732 ])
733
734 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
735
736 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
737 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
738 fi
739
740 if test "x$target_m32" = x1; then
741 # Force 32-bit mode.
742 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
743 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
744 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
745 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
746 TARGET_MODULE_FORMAT="elf32"
747 fi
748
749 if test "x$target_m64" = x1; then
750 # Force 64-bit mode.
751 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
752 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
753 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
754 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
755 TARGET_MODULE_FORMAT="elf64"
756 fi
757
758 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
759 TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
760 fi
761
762 # on mips redirect cache flushing function to non-existant one.
763 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
764 AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
765 CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
766 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
767 [grub_cv_cc_mflush_func=yes],
768 [grub_cv_cc_mflush_func=no])
769 ])
770
771 if test "x$grub_cv_cc_mflush_func" = xyes; then
772 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
773 fi
774 fi
775
776
777 # Force no alignment to save space on i386.
778 if test "x$target_cpu" = xi386; then
779 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
780 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
781 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
782 [grub_cv_cc_falign_loop=yes],
783 [grub_cv_cc_falign_loop=no])
784 ])
785
786 AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
787 CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
788 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
789 [grub_cv_cc_malign_loop=yes],
790 [grub_cv_cc_malign_loop=no])
791 ])
792
793 if test "x$grub_cv_cc_falign_loop" = xyes; then
794 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
795 elif test "x$grub_cv_cc_malign_loop" = xyes; then
796 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
797 fi
798 fi
799
800 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
801 CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
802 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
803 [grub_cv_cc_freg_struct_return=yes],
804 [grub_cv_cc_freg_struct_return=no])
805 ])
806
807 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
808 TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
809 fi
810
811 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
812 # Some toolchains enable these features by default, but they need
813 # registers that aren't set up properly in GRUB.
814 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
815 fi
816
817 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
818 # that floats are a good fit to run instead of what's written in the code.
819 # Given that floating point unit is disabled (if present to begin with)
820 # when GRUB is running which may result in various hard crashes.
821 if test x"$platform" != xemu ; then
822 AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
823 grub_cv_target_cc_soft_float=no
824 if test "x$target_cpu" = xarm64; then
825 CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
826 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
827 [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
828 fi
829 if test "x$target_cpu" = xia64; then
830 CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
831 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
832 [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
833 fi
834 for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
835 "-Xclang -msoft-float -Xclang -no-implicit-float" \
836 "-Xclang -msoft-float" "-msoft-float"; do
837 if test x"$grub_cv_target_cc_soft_float" != xno ; then
838 break
839 fi
840 CFLAGS="$TARGET_CFLAGS $cand -Werror"
841 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
842 [grub_cv_target_cc_soft_float="$cand"], [])
843 done
844 ])
845
846 if test x"$grub_cv_target_cc_soft_float" = xno ; then
847 AC_MSG_ERROR([could not force soft-float])
848 fi
849
850 case x"$grub_cv_target_cc_soft_float" in
851 x*"-Xclang"*)
852 # A trick so that clang doesn't see it on link stаge
853 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
854 ;;
855 *)
856 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
857 ;;
858 esac
859 TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
860
861 fi
862
863 if test x"$target_cpu" = xsparc64 ; then
864 AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
865 grub_cv_target_cc_mno_app_regs=no
866 for cand in "-mllvm -sparc-reserve-app-registers" \
867 "-mno-app-regs"; do
868 if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
869 break
870 fi
871 CFLAGS="$TARGET_CFLAGS $cand -Werror"
872 CPPFLAGS="$TARGET_CPPFLAGS"
873 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
874 [grub_cv_target_cc_mno_app_regs="$cand"], [])
875 done
876 ])
877
878 if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
879 AC_MSG_ERROR([could not reserve application registers])
880 fi
881 if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
882 # A trick so that clang doesn't see it on link stаge
883 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
884 else
885 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
886 fi
887
888 AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
889 grub_cv_target_cc_mno_relax=no
890 for cand in "-mno-relax" "-Wl,--no-relax"; do
891 if test x"$grub_cv_target_cc_mno_relax" != xno ; then
892 break
893 fi
894 LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
895 CFLAGS="$TARGET_CFLAGS -Werror"
896 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
897 asm (".globl start; start:");
898 void __main (void);
899 void __main (void) {}
900 int main (void);
901 ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
902 done
903 ])
904 LDFLAGS="$TARGET_LDFLAGS"
905 CFLAGS="$TARGET_CFLAGS"
906
907 if test x"$grub_cv_target_cc_mno_relax" = xno ; then
908 AC_MSG_ERROR([could not find no-relax options])
909 fi
910 TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
911 fi
912
913 # By default, GCC 4.4 generates .eh_frame sections containing unwind
914 # information in some cases where it previously did not. GRUB doesn't need
915 # these and they just use up vital space. Restore the old compiler
916 # behaviour.
917 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
918 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
919 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
920 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
921 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
922 ])
923
924 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
925 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
926 fi
927
928 if test x"$target_os" = xcygwin; then
929 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
930 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
931 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
932 [grub_cv_cc_no_reorder_functions=yes],
933 [grub_cv_cc_no_reorder_functions=no])
934 ])
935 fi
936
937 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
938 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
939 fi
940
941 AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [
942 CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
943 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
944 [grub_cv_cc_mno_stack_arg_probe=yes],
945 [grub_cv_cc_mno_stack_arg_probe=no])
946 ])
947
948 if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then
949 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
950 fi
951
952
953 # By default, GCC 4.6 generates .eh_frame sections containing unwind
954 # information in some cases where it previously did not. GRUB doesn't need
955 # these and they just use up vital space. Restore the old compiler
956 # behaviour.
957 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
958 CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
959 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
960 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
961 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
962 ])
963
964 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
965 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
966 fi
967
968 AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
969 CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
970 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
971 [grub_cv_cc_fno_unwind_tables=yes],
972 [grub_cv_cc_fno_unwind_tables=no])
973 ])
974
975 if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then
976 TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
977 fi
978
979
980 CFLAGS="$TARGET_CFLAGS"
981
982
983 if test x"$platform" = xemu ; then
984 TARGET_OBJ2ELF=
985 grub_cv_target_cc_link_format=
986 case "$host_os" in
987 *darwin* | *mac*)
988 grub_cv_target_cc_link_format="-arch,${target_cpu}"
989 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
990 ;;
991 *windows* | *cygwin* | *mingw*)
992 if test x${target_cpu} = xi386 ; then
993 grub_cv_target_cc_link_format=-mi386pe
994 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
995 fi
996 if test x${target_cpu} = xx86_64 ; then
997 grub_cv_target_cc_link_format=-mi386pep
998 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
999 fi
1000 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1001 ;;
1002 esac
1003 elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
1004 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
1005 grub_cv_target_cc_link_format=unknown
1006 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do
1007 if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then
1008 continue
1009 fi
1010 if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then
1011 continue
1012 fi
1013 CFLAGS="$TARGET_CFLAGS"
1014 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
1015 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1016 asm (".globl start; start:");
1017 asm (".globl _start; _start:");
1018 asm (".globl __start; __start:");
1019 void __main (void);
1020 void __main (void) {}
1021 ]], [[]])], [flag=1], [flag=0])
1022 if test x"$flag" = x1; then
1023 grub_cv_target_cc_link_format="$format"
1024 break
1025 fi
1026 done])
1027 if test x"$grub_cv_target_cc_link_format" = xunknown; then
1028 AC_MSG_ERROR([no suitable link format found])
1029 fi
1030 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
1031 if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
1032 TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
1033 fi
1034 if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1035 TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
1036 fi
1037 fi
1038
1039 if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_cc_link_format = x-arch,x86_64; then
1040 TARGET_APPLE_LINKER=1
1041 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
1042 if test "x$TARGET_OBJCONV" = x ; then
1043 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
1044 fi
1045 if test "x$TARGET_OBJCONV" = x ; then
1046 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
1047 fi
1048 TARGET_IMG_LDSCRIPT=
1049 TARGET_IMG_CFLAGS="-static"
1050 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1051 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
1052 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
1053 TARGET_LDFLAGS_OLDMAGIC=""
1054 elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then
1055 TARGET_APPLE_LINKER=0
1056 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1057 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1058 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
1059 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-cygwin-img-ld.sc"
1060 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1061 TARGET_IMG_CFLAGS=
1062 else
1063 TARGET_APPLE_LINKER=0
1064 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
1065 TARGET_IMG_LDSCRIPT=
1066 TARGET_IMG_LDFLAGS='-Wl,-N'
1067 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
1068 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
1069 TARGET_IMG_CFLAGS=
1070 fi
1071
1072 CFLAGS="$TARGET_CFLAGS"
1073
1074 AC_ARG_ENABLE([efiemu],
1075 [AS_HELP_STRING([--enable-efiemu],
1076 [build and install the efiemu runtimes (default=guessed)])])
1077 if test x"$enable_efiemu" = xno ; then
1078 efiemu_excuse="explicitly disabled"
1079 fi
1080
1081 if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
1082 efiemu_excuse="not available on cygwin"
1083 fi
1084 if test x"$target_cpu" != xi386 ; then
1085 efiemu_excuse="only available on i386"
1086 fi
1087 if test x"$platform" = xefi ; then
1088 efiemu_excuse="not available on efi"
1089 fi
1090
1091 if test x"$efiemu_excuse" = x ; then
1092 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
1093 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1094 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1095 [grub_cv_cc_efiemu=yes],
1096 [grub_cv_cc_efiemu=no])
1097 ])
1098 if test x$grub_cv_cc_efiemu = xno; then
1099 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
1100 fi
1101 fi
1102 if test x"$efiemu_excuse" = x ; then
1103 AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
1104 grub_cv_target_cc_efiemu64_link_format=unknown
1105 for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
1106 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
1107 LDFLAGS="-m64 -Wl,$format -nostdlib -static"
1108 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1109 asm (".globl start; start:");
1110 asm (".globl _start; _start:");
1111 asm (".globl __start; __start:");
1112 void __main (void);
1113 void __main (void) {}
1114 ]], [[]])], [flag=1], [flag=0])
1115 if test x"$flag" = x1; then
1116 grub_cv_target_cc_efiemu64_link_format="$format"
1117 break
1118 fi
1119 done])
1120 if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
1121 efiemu_excuse="no suitable link format for efiemu64 found"
1122 else
1123 EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
1124 fi
1125 fi
1126 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
1127 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)])
1128 fi
1129 if test x"$efiemu_excuse" = x ; then
1130 enable_efiemu=yes
1131 else
1132 enable_efiemu=no
1133 fi
1134 AC_SUBST([enable_efiemu])
1135 AC_SUBST([EFIEMU64_LINK_FORMAT])
1136
1137 CFLAGS="$TARGET_CFLAGS"
1138
1139 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
1140
1141
1142 LDFLAGS="$TARGET_LDFLAGS"
1143
1144 if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
1145 # Use large model to support 4G memory
1146 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
1147 CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1148 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1149 [grub_cv_cc_mcmodel=yes],
1150 [grub_cv_cc_mcmodel=no])
1151 ])
1152 if test "x$grub_cv_cc_mcmodel" = xyes; then
1153 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
1154 elif test "$target_cpu" = sparc64; then
1155 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
1156 fi
1157 fi
1158
1159 if test "$target_cpu"-"$platform" = x86_64-efi; then
1160 # EFI writes to stack below %rsp, we must not use the red zone
1161 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
1162 CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1163 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1164 [grub_cv_cc_no_red_zone=yes],
1165 [grub_cv_cc_no_red_zone=no])
1166 ])
1167 if test "x$grub_cv_cc_no_red_zone" = xno; then
1168 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
1169 fi
1170
1171 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
1172 fi
1173
1174 if test "x$target_cpu" = xarm; then
1175 AC_CACHE_CHECK([for options to disable movt and movw], grub_cv_target_cc_mno_movt, [
1176 grub_cv_target_cc_mno_movt=no
1177 for cand in "-mno-movt" \
1178 "-mllvm -arm-use-movt=0"; do
1179 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1180 break
1181 fi
1182 CFLAGS="$TARGET_CFLAGS $cand -Werror"
1183 CPPFLAGS="$TARGET_CPPFLAGS"
1184 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1185 [grub_cv_target_cc_mno_movt="$cand"], [])
1186 done
1187 ])
1188
1189 if test x"$grub_cv_target_cc_mno_movt" != xno ; then
1190 # A trick so that clang doesn't see it on link stage
1191 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt"
1192 fi
1193 AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
1194 CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
1195 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1196 [grub_cv_cc_mthumb_interwork=yes],
1197 [grub_cv_cc_mthumb_interwork=no])
1198 ])
1199 if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
1200 TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
1201 # Clang defaults to thumb interworking
1202 elif test "x$grub_cv_cc_target_clang" = xno ; then
1203 AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
1204 fi
1205 fi
1206
1207 AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
1208 CFLAGS="$TARGET_CFLAGS -Qn -Werror"
1209 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
1210 [grub_cv_target_cc_qn=yes],
1211 [grub_cv_target_cc_qn=no])])
1212 if test "x$grub_cv_target_cc_qn" = xyes; then
1213 TARGET_CFLAGS="$TARGET_CFLAGS -Qn"
1214 fi
1215
1216 #
1217 # Compiler features.
1218 #
1219
1220 CFLAGS="$TARGET_CFLAGS"
1221
1222 # Position independent executable.
1223 grub_CHECK_PIE
1224 grub_CHECK_NO_PIE
1225 grub_CHECK_NO_PIE_ONEWORD
1226 grub_CHECK_LINK_PIE
1227 [# Need that, because some distributions ship compilers that include
1228 # `-fPIE' or '-fpie' and '-pie' in the default specs.
1229 if [ x"$pie_possible" = xyes ]; then
1230 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
1231 fi
1232
1233 if [ x"$link_nopie_needed" = xyes ] || [ x"$pie_possible" = xyes ]; then
1234 if [ x"$nopie_possible" = xyes ]; then
1235 TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
1236 fi
1237 if [ x"$nopie_oneword_possible" = xyes ]; then
1238 TARGET_LDFLAGS="$TARGET_LDFLAGS -nopie"
1239 fi
1240 fi]
1241
1242 CFLAGS="$TARGET_CFLAGS"
1243 LDFLAGS="$TARGET_LDFLAGS"
1244
1245 # Position independent executable.
1246 grub_CHECK_PIC
1247 [# On most platforms we don't want PIC as it only makes relocations harder
1248 # and code less efficient. On mips we want to have one got table per module
1249 # and reload $gp in every function.
1250 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
1251 # However with clang we need PIC for this reloading to happen.
1252 # With arm64 we need relocations that are in some way representable in
1253 # PE as we need to support arm64-efi. Without -fPIC clang generates
1254 # movk's which aren't representable.
1255 # Since default varies across dictributions use either -fPIC or -fno-PIC
1256 # explicitly.
1257 if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel || test x$target_cpu = xarm64 ) && test "x$grub_cv_cc_target_clang" = xyes ; then
1258 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
1259 elif [ x"$pic_possible" = xyes ]; then
1260 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
1261 fi]
1262
1263 CFLAGS="$TARGET_CFLAGS"
1264
1265 # Smashing stack protector.
1266 grub_CHECK_STACK_PROTECTOR
1267 # Need that, because some distributions ship compilers that include
1268 # `-fstack-protector' in the default specs.
1269 if test "x$ssp_possible" = xyes; then
1270 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
1271 fi
1272
1273 CFLAGS="$TARGET_CFLAGS"
1274
1275 grub_CHECK_STACK_ARG_PROBE
1276 # Cygwin's GCC uses alloca() to probe the stackframe on static
1277 # stack allocations above some threshold.
1278 if test x"$sap_possible" = xyes; then
1279 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
1280 fi
1281
1282 CFLAGS="$TARGET_CFLAGS"
1283
1284 # -mno-unaligned-access -mstrict-align
1285 if test "$target_cpu" = arm; then
1286 AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
1287 grub_cv_target_cc_strict_align=
1288 for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
1289 CFLAGS="$TARGET_CFLAGS $arg -Werror"
1290 LDFLAGS="$TARGET_LDFLAGS"
1291 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
1292 if test x"$flag" = x1; then
1293 grub_cv_target_cc_strict_align="$arg"
1294 break
1295 fi
1296 done])
1297
1298 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
1299 if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
1300 TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
1301 fi
1302 AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
1303 [CFLAGS="$TARGET_CFLAGS"
1304 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1305 #ifdef __ARM_FEATURE_UNALIGNED
1306 #error "unaligned"
1307 #endif
1308 ]])],
1309 [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
1310 if test x$grub_cv_cc_target_emits_unaligned = xyes; then
1311 AC_MSG_ERROR([compiler generates unaligned accesses])
1312 fi
1313 fi
1314
1315 # Set them to their new values for the tests below.
1316 CC="$TARGET_CC"
1317 if test x"$platform" = xemu ; then
1318 CFLAGS="$TARGET_CFLAGS -Wno-error"
1319 elif test "x$TARGET_APPLE_LINKER" = x1 ; then
1320 CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
1321 else
1322 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
1323 fi
1324 CPPFLAGS="$TARGET_CPPFLAGS"
1325
1326 grub_ASM_USCORE
1327 if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
1328 if test x$grub_cv_asm_uscore = xyes; then
1329 DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
1330 else
1331 DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main"
1332 fi
1333 CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
1334 fi
1335
1336 # Check for libgcc symbols
1337 if test x"$platform" = xemu; then
1338 AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
1339 fi
1340
1341 if test "x$TARGET_APPLE_LINKER" = x1 ; then
1342 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
1343 else
1344 CFLAGS="$TARGET_CFLAGS -nostdlib"
1345 fi
1346 LIBS=""
1347
1348 # Defined in aclocal.m4.
1349 grub_PROG_TARGET_CC
1350 if test "x$TARGET_APPLE_LINKER" != x1 ; then
1351 grub_PROG_OBJCOPY_ABSOLUTE
1352 fi
1353 grub_PROG_LD_BUILD_ID_NONE
1354 if test "x$target_cpu" = xi386; then
1355 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
1356 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
1357 # Check symbols provided by linker script.
1358 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000"
1359 fi
1360 grub_CHECK_BSS_START_SYMBOL
1361 grub_CHECK_END_SYMBOL
1362 fi
1363 CFLAGS="$TARGET_CFLAGS"
1364 fi
1365
1366 grub_PROG_NM_WORKS
1367 grub_PROG_NM_MINUS_P
1368 grub_PROG_NM_DEFINED_ONLY
1369 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
1370 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
1371
1372 if test "$platform" != emu; then
1373 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
1374 SAVED_CPPFLAGS="$CPPFLAGS"
1375 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1377 #include <stddef.h>
1378 int va_arg_func (int fixed, va_list args);]], [[]])],
1379 [grub_cv_cc_isystem=yes],
1380 [grub_cv_cc_isystem=no])
1381 CPPFLAGS="$SAVED_CPPFLAGS"
1382 ])
1383
1384 if test x"$grub_cv_cc_isystem" = xyes ; then
1385 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1386 fi
1387 fi
1388
1389 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
1390 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
1391 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1392 int va_arg_func (int fixed, va_list args);]], [[]])],
1393 [grub_cv_cc_wtrampolines=yes],
1394 [grub_cv_cc_wtrampolines=no])
1395 ])
1396
1397 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
1398 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
1399 fi
1400
1401 # Restore the flags.
1402 CC="$tmp_CC"
1403 CFLAGS="$tmp_CFLAGS"
1404 CPPFLAGS="$tmp_CPPFLAGS"
1405 LDFLAGS="$tmp_LDFLAGS"
1406 LIBS="$tmp_LIBS"
1407
1408 #
1409 # Check for options.
1410 #
1411
1412 # Memory manager debugging.
1413 AC_ARG_ENABLE([mm-debug],
1414 AS_HELP_STRING([--enable-mm-debug],
1415 [include memory manager debugging]),
1416 [AC_DEFINE([MM_DEBUG], [1],
1417 [Define to 1 if you enable memory manager debugging.])])
1418
1419 AC_ARG_ENABLE([cache-stats],
1420 AS_HELP_STRING([--enable-cache-stats],
1421 [enable disk cache statistics collection]))
1422
1423 if test x$enable_cache_stats = xyes; then
1424 DISK_CACHE_STATS=1
1425 else
1426 DISK_CACHE_STATS=0
1427 fi
1428 AC_SUBST([DISK_CACHE_STATS])
1429
1430 AC_ARG_ENABLE([boot-time],
1431 AS_HELP_STRING([--enable-boot-time],
1432 [enable boot time statistics collection]))
1433
1434 if test x$enable_boot_time = xyes; then
1435 BOOT_TIME_STATS=1
1436 else
1437 BOOT_TIME_STATS=0
1438 fi
1439 AC_SUBST([BOOT_TIME_STATS])
1440
1441 AC_ARG_ENABLE([grub-emu-sdl],
1442 [AS_HELP_STRING([--enable-grub-emu-sdl],
1443 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
1444
1445 AC_ARG_ENABLE([grub-emu-pci],
1446 [AS_HELP_STRING([--enable-grub-emu-pci],
1447 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
1448
1449 if test "$platform" = emu; then
1450
1451 if test x"$enable_grub_emu_sdl" = xno ; then
1452 grub_emu_sdl_excuse="explicitly disabled"
1453 fi
1454 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1455 # Check for libSDL libraries.]
1456 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1457 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1458 AC_SUBST([LIBSDL])
1459 [fi]
1460
1461 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1462 # Check for headers.]
1463 AC_CHECK_HEADERS([SDL/SDL.h], [],
1464 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1465 [fi]
1466
1467 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1468 AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)])
1469 fi
1470 if test x"$grub_emu_sdl_excuse" = x ; then
1471 enable_grub_emu_sdl=yes
1472 else
1473 enable_grub_emu_sdl=no
1474 fi
1475
1476 if test x"$enable_grub_emu_pci" != xyes ; then
1477 grub_emu_pci_excuse="not enabled"
1478 fi
1479
1480 [if [ x"$grub_emu_pci_excuse" = x ]; then
1481 # Check for libpci libraries.]
1482 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1483 [grub_emu_pci_excuse=["need libpciaccess library"]])
1484 AC_SUBST([LIBPCIACCESS])
1485 [fi]
1486 [if [ x"$grub_emu_pci_excuse" = x ]; then
1487 # Check for headers.]
1488 AC_CHECK_HEADERS([pciaccess.h], [],
1489 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1490 [fi]
1491
1492 if test x"$grub_emu_pci_excuse" = x ; then
1493 enable_grub_emu_pci=yes
1494 else
1495
1496 enable_grub_emu_pci=no
1497 fi
1498
1499 AC_SUBST([enable_grub_emu_sdl])
1500 AC_SUBST([enable_grub_emu_pci])
1501
1502 else
1503
1504 # Ignore --enable-emu-* if platform is not emu
1505 enable_grub_emu_sdl=no
1506 enable_grub_emu_pci=no
1507 fi
1508
1509 AC_ARG_ENABLE([grub-mkfont],
1510 [AS_HELP_STRING([--enable-grub-mkfont],
1511 [build and install the `grub-mkfont' utility (default=guessed)])])
1512 if test x"$enable_grub_mkfont" = xno ; then
1513 grub_mkfont_excuse="explicitly disabled"
1514 fi
1515
1516 unset ac_cv_header_ft2build_h
1517
1518 if test x"$grub_mkfont_excuse" = x ; then
1519 # Check for freetype libraries.
1520 PKG_CHECK_MODULES([FREETYPE], [freetype2], [
1521 SAVED_CPPFLAGS="$CPPFLAGS"
1522 SAVED_LIBS="$LIBS"
1523 CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
1524 LIBS="$LIBS $FREETYPE_LIBS"
1525 AC_CHECK_HEADERS([ft2build.h], [],
1526 [grub_mkfont_excuse=["need freetype2 headers"]])
1527 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
1528 [grub_mkfont_excuse=["freetype2 library unusable"]])
1529 CPPFLAGS="$SAVED_CPPFLAGS"
1530 LIBS="$SAVED_LIBS"
1531 ], [grub_mkfont_excuse=["need freetype2 library"]])
1532 fi
1533
1534 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1535 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)])
1536 fi
1537 if test x"$grub_mkfont_excuse" = x ; then
1538 enable_grub_mkfont=yes
1539 else
1540 enable_grub_mkfont=no
1541 fi
1542 AC_SUBST([enable_grub_mkfont])
1543
1544 SAVED_CC="$CC"
1545 SAVED_CPP="$CPP"
1546 SAVED_CFLAGS="$CFLAGS"
1547 SAVED_CPPFLAGS="$CPPFLAGS"
1548 SAVED_LDFLAGS="$LDFLAGS"
1549 CC="$BUILD_CC"
1550 CPP="$BUILD_CPP"
1551 CFLAGS="$BUILD_CFLAGS"
1552 CPPFLAGS="$BUILD_CPPFLAGS"
1553 LDFLAGS="$BUILD_LDFAGS"
1554
1555 unset ac_cv_c_bigendian
1556 unset ac_cv_header_ft2build_h
1557
1558 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1559 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1560 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1561
1562 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1563 AC_MSG_ERROR([couldnt determine build endianness])
1564 fi
1565
1566 AC_SUBST([BUILD_SIZEOF_LONG])
1567 AC_SUBST([BUILD_SIZEOF_VOID_P])
1568 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1569
1570 if test x"$grub_build_mkfont_excuse" = x ; then
1571 # Check for freetype libraries.
1572 SAVED_PKG_CONFIG="$PKG_CONFIG"
1573 test -z "$BUILD_PKG_CONFIG" || PKG_CONFIG="$BUILD_PKG_CONFIG"
1574 PKG_CHECK_MODULES([BUILD_FREETYPE], [freetype2], [
1575 SAVED_CPPFLAGS_2="$CPPFLAGS"
1576 SAVED_LIBS="$LIBS"
1577 CPPFLAGS="$CPPFLAGS $BUILD_FREETYPE_CFLAGS"
1578 LIBS="$LIBS $BUILD_FREETYPE_LIBS"
1579 AC_CHECK_HEADERS([ft2build.h], [],
1580 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1581 AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [],
1582 [grub_build_mkfont_excuse=["freetype2 library unusable"]])
1583 LIBS="$SAVED_LIBS"
1584 CPPFLAGS="$SAVED_CPPFLAGS_2"
1585 ], [grub_build_mkfont_excuse=["need freetype2 library"]])
1586 PKG_CONFIG="$SAVED_PKG_CONFIG"
1587 fi
1588
1589 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1590 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)])
1591 fi
1592 if test x"$grub_build_mkfont_excuse" = x ; then
1593 enable_build_grub_mkfont=yes
1594 else
1595 enable_build_grub_mkfont=no
1596 fi
1597 if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
1598 if test x"$grub_build_mkfont_excuse" = x ; then
1599 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont])
1600 else
1601 AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)])
1602 fi
1603 fi
1604
1605 CC="$SAVED_CC"
1606 CPP="$SAVED_CPP"
1607 CFLAGS="$SAVED_CFLAGS"
1608 CPPFLAGS="$SAVED_CPPFLAGS"
1609 LDFLAGS="$SAVED_LDFLAGS"
1610
1611
1612 DJVU_FONT_SOURCE=
1613
1614 starfield_excuse=
1615
1616 AC_ARG_ENABLE([grub-themes],
1617 [AS_HELP_STRING([--enable-grub-themes],
1618 [build and install GRUB themes (default=guessed)])])
1619 if test x"$enable_grub_themes" = xno ; then
1620 starfield_excuse="explicitly disabled"
1621 fi
1622
1623 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1624 starfield_excuse="No build-time grub-mkfont"
1625 fi
1626
1627 if test x"$starfield_excuse" = x; then
1628 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1629 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
1630 if test -f "$dir/DejaVuSans.$ext"; then
1631 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1632 break 2
1633 fi
1634 done
1635 done
1636
1637 if test "x$DJVU_FONT_SOURCE" = x; then
1638 starfield_excuse="No DejaVu found"
1639 fi
1640 fi
1641
1642 if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1643 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)])
1644 fi
1645
1646 AC_SUBST([DJVU_FONT_SOURCE])
1647
1648 FONT_SOURCE=
1649
1650 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1651 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
1652 if test -f "$dir/unifont.$ext"; then
1653 md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
1654 # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
1655 if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
1656 continue
1657 fi
1658 FONT_SOURCE="$dir/unifont.$ext"
1659 break 2
1660 fi
1661 done
1662 done
1663
1664 if test x"$enable_build_grub_mkfont" = xno ; then
1665 FONT_SOURCE=
1666 fi
1667
1668 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
1669 if test x"$grub_build_mkfont_excuse" = x ; then
1670 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont])
1671 else
1672 AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
1673 fi
1674 fi
1675
1676 AC_SUBST([FONT_SOURCE])
1677
1678 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1679 grub_build_mkfont_excuse="no fonts"
1680 fi
1681
1682
1683 AC_ARG_ENABLE([grub-mount],
1684 [AS_HELP_STRING([--enable-grub-mount],
1685 [build and install the `grub-mount' utility (default=guessed)])])
1686 if test x"$enable_grub_mount" = xno ; then
1687 grub_mount_excuse="explicitly disabled"
1688 fi
1689
1690 if test x"$grub_mount_excuse" = x ; then
1691 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1692 [grub_mount_excuse="need FUSE library"])
1693 fi
1694
1695 if test x"$grub_mount_excuse" = x ; then
1696 # Check for fuse headers.
1697 SAVED_CPPFLAGS="$CPPFLAGS"
1698 CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
1699 AC_CHECK_HEADERS([fuse/fuse.h], [],
1700 [grub_mount_excuse=["need FUSE headers"]])
1701 CPPFLAGS="$SAVED_CPPFLAGS"
1702 fi
1703
1704 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1705 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)])
1706 fi
1707 if test x"$grub_mount_excuse" = x ; then
1708 enable_grub_mount=yes
1709 else
1710 enable_grub_mount=no
1711 fi
1712 AC_SUBST([enable_grub_mount])
1713
1714 AC_ARG_ENABLE([device-mapper],
1715 [AS_HELP_STRING([--enable-device-mapper],
1716 [enable Linux device-mapper support (default=guessed)])])
1717 if test x"$enable_device_mapper" = xno ; then
1718 device_mapper_excuse="explicitly disabled"
1719 fi
1720
1721 if test x"$device_mapper_excuse" = x ; then
1722 # Check for device-mapper header.
1723 AC_CHECK_HEADER([libdevmapper.h], [],
1724 [device_mapper_excuse="need libdevmapper header"])
1725 fi
1726
1727 if test x"$device_mapper_excuse" = x ; then
1728 # Check for device-mapper library.
1729 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1730 [device_mapper_excuse="need devmapper library"])
1731 fi
1732
1733 if test x"$device_mapper_excuse" = x ; then
1734 # Check for device-mapper library.
1735 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1736 [],
1737 [device_mapper_excuse="need devmapper library"])
1738 fi
1739
1740 if test x"$device_mapper_excuse" = x ; then
1741 LIBDEVMAPPER="-ldevmapper"
1742 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1743 [Define to 1 if you have the devmapper library.])
1744 fi
1745
1746 AC_SUBST([LIBDEVMAPPER])
1747
1748 LIBGEOM=
1749 if test x$host_kernel = xkfreebsd; then
1750 AC_CHECK_LIB([geom], [geom_gettree], [],
1751 [AC_MSG_ERROR([Your platform requires libgeom])])
1752 LIBGEOM="-lgeom"
1753 fi
1754
1755 AC_SUBST([LIBGEOM])
1756
1757 AC_ARG_ENABLE([liblzma],
1758 [AS_HELP_STRING([--enable-liblzma],
1759 [enable liblzma integration (default=guessed)])])
1760 if test x"$enable_liblzma" = xno ; then
1761 liblzma_excuse="explicitly disabled"
1762 fi
1763
1764 if test x"$liblzma_excuse" = x ; then
1765 AC_CHECK_LIB([lzma], [lzma_code],
1766 [],[liblzma_excuse="need lzma library"])
1767 fi
1768 if test x"$liblzma_excuse" = x ; then
1769 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1770 fi
1771
1772 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1773 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)])
1774 fi
1775
1776
1777 if test x"$liblzma_excuse" = x ; then
1778 LIBLZMA="-llzma"
1779 AC_DEFINE([USE_LIBLZMA], [1],
1780 [Define to 1 if you have the LZMA library.])
1781 fi
1782
1783 AC_SUBST([LIBLZMA])
1784
1785 AC_ARG_ENABLE([libzfs],
1786 [AS_HELP_STRING([--enable-libzfs],
1787 [enable libzfs integration (default=guessed)])])
1788 if test x"$enable_libzfs" = xno ; then
1789 libzfs_excuse="explicitly disabled"
1790 fi
1791
1792 if test x"$libzfs_excuse" = x ; then
1793 # Only check for system headers if libzfs support has not been disabled.
1794 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1795 fi
1796
1797 if test x"$libzfs_excuse" = x ; then
1798 AC_CHECK_LIB([zfs], [libzfs_init],
1799 [],
1800 [libzfs_excuse="need zfs library"])
1801 fi
1802
1803 if test x"$libzfs_excuse" = x ; then
1804 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1805 [],
1806 [libzfs_excuse="need nvpair library"])
1807 fi
1808
1809 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1810 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)])
1811 fi
1812
1813 if test x"$libzfs_excuse" = x ; then
1814 # We need both libzfs and libnvpair for a successful build.
1815 LIBZFS="-lzfs"
1816 AC_DEFINE([HAVE_LIBZFS], [1],
1817 [Define to 1 if you have the ZFS library.])
1818 LIBNVPAIR="-lnvpair"
1819 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1820 [Define to 1 if you have the NVPAIR library.])
1821 fi
1822
1823 AC_SUBST([LIBZFS])
1824 AC_SUBST([LIBNVPAIR])
1825
1826 LIBS=""
1827
1828 AC_SUBST([FONT_SOURCE])
1829 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1830 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1831
1832 AC_SUBST(HAVE_ASM_USCORE)
1833 AC_SUBST(BSS_START_SYMBOL)
1834 AC_SUBST(END_SYMBOL)
1835 AC_SUBST(PACKAGE)
1836 AC_SUBST(VERSION)
1837
1838 AC_ARG_ENABLE([werror],
1839 [AS_HELP_STRING([--disable-werror],
1840 [do not use -Werror when building GRUB])])
1841 if test x"$enable_werror" != xno ; then
1842 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1843 HOST_CFLAGS="$HOST_CFLAGS -Werror"
1844 fi
1845
1846 TARGET_CPP="$TARGET_CC -E"
1847 TARGET_CCAS=$TARGET_CC
1848
1849 # Includes which include make-time substitutions. They must come last
1850 # as to avoid executing top_builddir in shell.
1851 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
1852 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
1853 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
1854
1855 GRUB_TARGET_CPU="${target_cpu}"
1856 GRUB_PLATFORM="${platform}"
1857
1858 AC_SUBST(GRUB_TARGET_CPU)
1859 AC_SUBST(GRUB_PLATFORM)
1860
1861 AC_SUBST(TARGET_OBJCONV)
1862 AC_SUBST(TARGET_CPP)
1863 AC_SUBST(TARGET_CCAS)
1864 AC_SUBST(TARGET_OBJ2ELF)
1865 AC_SUBST(TARGET_MODULE_FORMAT)
1866 AC_SUBST(TARGET_CC_VERSION)
1867
1868 AC_SUBST(TARGET_CFLAGS)
1869 AC_SUBST(TARGET_LDFLAGS)
1870 AC_SUBST(TARGET_CPPFLAGS)
1871 AC_SUBST(TARGET_CCASFLAGS)
1872
1873 AC_SUBST(TARGET_IMG_LDFLAGS)
1874 AC_SUBST(TARGET_IMG_CFLAGS)
1875 AC_SUBST(TARGET_IMG_BASE_LDOPT)
1876 AC_SUBST(TARGET_APPLE_LINKER)
1877
1878 AC_SUBST(HOST_CFLAGS)
1879 AC_SUBST(HOST_LDFLAGS)
1880 AC_SUBST(HOST_CPPFLAGS)
1881 AC_SUBST(HOST_CCASFLAGS)
1882
1883 AC_SUBST(BUILD_LIBM)
1884
1885 #
1886 # Automake conditionals
1887 #
1888
1889 AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
1890 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1891 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1892 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1893 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1894 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1895 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1896 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1897 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1898 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1899 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1900 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
1901 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1902 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1903 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1904 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1905 AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
1906 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1907 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1908 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1909 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1910 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1911 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1912 AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot])
1913 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1914 AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
1915 AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
1916
1917 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1918 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1919 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1920 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1921 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1922 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1923 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1924
1925 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1926 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1927 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1928 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1929 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1930 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1931 if test x$FONT_SOURCE != x ; then
1932 HAVE_FONT_SOURCE=1
1933 else
1934 HAVE_FONT_SOURCE=0
1935 fi
1936 AC_SUBST(HAVE_FONT_SOURCE)
1937 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
1938 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1939 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1940 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1941
1942 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1943
1944 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1945 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1946 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
1947
1948 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
1949 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
1950 datarootdir="$(eval echo "$datarootdir")"
1951 grub_libdir="$(eval echo "$libdir")"
1952 grub_localedir="$(eval echo "$localedir")"
1953 grub_datadir="$(eval echo "$datadir")"
1954 grub_sysconfdir="$(eval echo "$sysconfdir")"
1955 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
1956 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
1957 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
1958 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
1959
1960
1961 # Output files.
1962 if test "$platform" != none; then
1963 cpudir="${target_cpu}"
1964 if test x${cpudir} = xmipsel; then
1965 cpudir=mips;
1966 fi
1967 grub_CHECK_LINK_DIR
1968 if test x"$link_dir" = xyes ; then
1969 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1970 if test "$platform" != emu ; then
1971 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1972 fi
1973 else
1974 mkdir -p include/grub 2>/dev/null
1975 rm -rf include/grub/cpu
1976 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1977 if test "$platform" != emu ; then
1978 rm -rf include/grub/machine
1979 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1980 fi
1981 fi
1982 else
1983 # Just enough to stop the compiler failing with -I$(srcdir)/include.
1984 mkdir -p include 2>/dev/null
1985 rm -rf include/grub/cpu include/grub/machine
1986 fi
1987
1988 AC_CONFIG_FILES([Makefile])
1989 AC_CONFIG_FILES([grub-core/Makefile])
1990 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1991 AC_CONFIG_FILES([po/Makefile.in])
1992 AC_CONFIG_FILES([docs/Makefile])
1993 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1994 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1995 AC_CONFIG_FILES([config.h])
1996
1997 AC_OUTPUT
1998 [
1999 echo "*******************************************************"
2000 echo GRUB2 will be compiled with following components:
2001 echo Platform: "$target_cpu"-"$platform"
2002 if [ x"$platform" = xemu ]; then
2003 if [ x"$grub_emu_sdl_excuse" = x ]; then
2004 echo SDL support for grub-emu: Yes
2005 else
2006 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
2007 fi
2008 if [ x"$grub_emu_pci_excuse" = x ]; then
2009 echo PCI support for grub-emu: Yes
2010 else
2011 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
2012 fi
2013 fi
2014 if test x"$device_mapper_excuse" = x ; then
2015 echo With devmapper support: Yes
2016 else
2017 echo With devmapper support: No "($device_mapper_excuse)"
2018 fi
2019 if [ x"$enable_mm_debug" = xyes ]; then
2020 echo With memory debugging: Yes
2021 else
2022 echo With memory debugging: No
2023 fi
2024 if [ x"$enable_cache_stats" = xyes ]; then
2025 echo With disk cache statistics: Yes
2026 else
2027 echo With disk cache statistics: No
2028 fi
2029
2030 if [ x"$enable_boot_time" = xyes ]; then
2031 echo With boot time statistics: Yes
2032 else
2033 echo With boot time statistics: No
2034 fi
2035
2036 if [ x"$efiemu_excuse" = x ]; then
2037 echo efiemu runtime: Yes
2038 else
2039 echo efiemu runtime: No "($efiemu_excuse)"
2040 fi
2041 if [ x"$grub_mkfont_excuse" = x ]; then
2042 echo grub-mkfont: Yes
2043 else
2044 echo grub-mkfont: No "($grub_mkfont_excuse)"
2045 fi
2046 if [ x"$grub_mount_excuse" = x ]; then
2047 echo grub-mount: Yes
2048 else
2049 echo grub-mount: No "($grub_mount_excuse)"
2050 fi
2051 if [ x"$starfield_excuse" = x ]; then
2052 echo starfield theme: Yes
2053 echo With DejaVuSans font from $DJVU_FONT_SOURCE
2054 else
2055 echo starfield theme: No "($starfield_excuse)"
2056 fi
2057 if [ x"$libzfs_excuse" = x ]; then
2058 echo With libzfs support: Yes
2059 else
2060 echo With libzfs support: No "($libzfs_excuse)"
2061 fi
2062 if [ x"$grub_build_mkfont_excuse" = x ]; then
2063 echo Build-time grub-mkfont: Yes
2064 if test "x$FONT_SOURCE" = x ; then
2065 echo "Without unifont"
2066 else
2067 echo "With unifont from $FONT_SOURCE"
2068 fi
2069 else
2070 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
2071 echo "Without unifont (no build-time grub-mkfont)"
2072 fi
2073 if test x"$liblzma_excuse" != x ; then
2074 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
2075 else
2076 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
2077 fi
2078 echo "*******************************************************"
2079 ]