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