]> git.proxmox.com Git - grub2.git/blob - configure.ac
* configure.ac: Make unifont mandatory on coreboot.
[grub2.git] / configure.ac
1 # -*- autoconf -*-
2
3 # Process this file with autoconf to produce a configure script.
4
5 # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
6 #
7 # This configure.ac is free software; the author
8 # gives unlimited permission to copy and/or distribute it,
9 # with or without modifications, as long as this notice is preserved.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 # PARTICULAR PURPOSE.
15
16 dnl This configure script is complicated, because GRUB needs to deal
17 dnl with three potentially different types:
18 dnl
19 dnl build -- the environment for building GRUB
20 dnl host -- the environment for running utilities
21 dnl target -- the environment for running GRUB
22 dnl
23 dnl In addition, GRUB needs to deal with a platform specification
24 dnl which specifies the system running GRUB, such as firmware.
25 dnl This is necessary because the target type in autoconf does not
26 dnl describe such a system very well.
27 dnl
28 dnl The current strategy is to use variables with no prefix (such as
29 dnl CC, CFLAGS, etc.) for the host type as well as the build type,
30 dnl because GRUB does not need to use those variables for the build
31 dnl type, so there is no conflict. Variables with the prefix "TARGET_"
32 dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
33 dnl type.
34
35 AC_INIT([GRUB],[2.00],[bug-grub@gnu.org])
36
37 AC_CONFIG_AUX_DIR([build-aux])
38
39 # We don't want -g -O2 by default in CFLAGS
40 : ${CFLAGS=""}
41
42 # Checks for host and target systems.
43 AC_CANONICAL_HOST
44 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 # Program name transformations
54 AC_ARG_PROGRAM
55 grub_TRANSFORM([grub-bios-setup])
56 grub_TRANSFORM([grub-editenv])
57 grub_TRANSFORM([grub-install])
58 grub_TRANSFORM([grub-mkconfig])
59 grub_TRANSFORM([grub-mkfont])
60 grub_TRANSFORM([grub-mkimage])
61 grub_TRANSFORM([grub-glue-efi])
62 grub_TRANSFORM([grub-mklayout])
63 grub_TRANSFORM([grub-mkpasswd-pbkdf2])
64 grub_TRANSFORM([grub-mkrelpath])
65 grub_TRANSFORM([grub-mkrescue])
66 grub_TRANSFORM([grub-probe])
67 grub_TRANSFORM([grub-reboot])
68 grub_TRANSFORM([grub-script-check])
69 grub_TRANSFORM([grub-set-default])
70 grub_TRANSFORM([grub-sparc64-setup])
71 grub_TRANSFORM([grub-render-label])
72
73 # Optimization flag. Allow user to override.
74 if test "x$TARGET_CFLAGS" = x; then
75 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
76 fi
77
78 # Default HOST_CPPFLAGS
79 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
80 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
81 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
82
83 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
84 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
85 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
86
87 case "$target_cpu" in
88 i[[3456]]86) target_cpu=i386 ;;
89 amd64) target_cpu=x86_64 ;;
90 sparc) target_cpu=sparc64 ;;
91 mipsel|mips64el)
92 target_cpu=mipsel;
93 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
94 ;;
95 mips|mips64)
96 target_cpu=mips;
97 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
98 ;;
99 arm*)
100 target_cpu=arm;
101 ;;
102 aarch64*)
103 target_cpu=arm64;
104 ;;
105 esac
106
107 # Specify the platform (such as firmware).
108 AC_ARG_WITH([platform],
109 AS_HELP_STRING([--with-platform=PLATFORM],
110 [select the host platform [[guessed]]]))
111
112 # Guess the platform if not specified.
113 if test "x$with_platform" = x; then
114 case "$target_cpu"-"$target_vendor" in
115 i386-apple) platform=efi ;;
116 i386-*) platform=pc ;;
117 x86_64-apple) platform=efi ;;
118 x86_64-*) platform=pc ;;
119 powerpc-*) platform=ieee1275 ;;
120 powerpc64-*) platform=ieee1275 ;;
121 sparc64-*) platform=ieee1275 ;;
122 mipsel-*) platform=loongson ;;
123 mips-*) platform=arc ;;
124 ia64-*) platform=efi ;;
125 arm-*) platform=uboot ;;
126 arm64-*) platform=efi ;;
127 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
128 esac
129 else
130 platform="$with_platform"
131 fi
132
133 case "$target_cpu"-"$platform" in
134 x86_64-efi) ;;
135 x86_64-emu) ;;
136 x86_64-xen) ;;
137 x86_64-*) target_cpu=i386 ;;
138 powerpc64-ieee1275) target_cpu=powerpc ;;
139 esac
140
141 # Check if the platform is supported, make final adjustments.
142 case "$target_cpu"-"$platform" in
143 i386-efi) ;;
144 x86_64-efi) ;;
145 i386-xen) ;;
146 x86_64-xen) ;;
147 i386-pc) ;;
148 i386-multiboot) ;;
149 i386-coreboot) ;;
150 i386-linuxbios) platform=coreboot ;;
151 i386-ieee1275) ;;
152 i386-qemu) ;;
153 powerpc-ieee1275) ;;
154 sparc64-ieee1275) ;;
155 ia64-efi) ;;
156 mips-qemu_mips) ;;
157 mips-qemu-mips) platform=qemu_mips;;
158 mips-arc) ;;
159 mipsel-arc) ;;
160 mipsel-qemu_mips) ;;
161 mipsel-qemu-mips) platform=qemu_mips;;
162 mipsel-yeeloong) platform=loongson ;;
163 mipsel-fuloong) platform=loongson ;;
164 mipsel-loongson) ;;
165 arm-uboot) ;;
166 arm-efi) ;;
167 arm64-efi) ;;
168 *-emu) ;;
169 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
170 esac
171
172 if test x$platform != xemu ; then
173 case "$target_cpu" in
174 i386 | powerpc) target_m32=1 ;;
175 x86_64 | sparc64) target_m64=1 ;;
176 esac
177 fi
178
179 case "$target_os" in
180 windows* | mingw32*) target_os=cygwin ;;
181 esac
182
183 # This normalizes the names, and creates a new variable ("host_kernel")
184 # while at it, since the mapping is not always 1:1 (e.g. different OSes
185 # using the same kernel type).
186 case "$host_os" in
187 gnu*) host_kernel=hurd ;;
188 linux*) host_kernel=linux ;;
189 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
190 netbsd*) host_kernel=netbsd ;;
191 solaris*) host_kernel=illumos ;;
192 darwin*) host_kernel=xnu ;;
193 cygwin | windows* | mingw32*) host_kernel=windows ;;
194 esac
195
196 case "$host_os" in
197 cygwin | windows* | mingw32*) have_exec=n ;;
198 aros*) have_exec=n ;;
199 *) have_exec=y;;
200 esac
201
202 case "$platform" in
203 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
204 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
205 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
206 xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;;
207 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
208 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
209 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
210 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
211 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
212 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
213 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
214 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
215 esac
216 case "$target_cpu" in
217 arm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
218 arm64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM64=1" ;;
219 mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
220 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
221 esac
222 if test x${target_cpu} = xmipsel ; then
223 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
224 else
225 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,` -DGRUB_TARGET_CPU_`echo ${target_cpu} | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`=1"
226 fi
227
228 case "${target_cpu}-$platform" in
229 mips-arc)
230 TARGET_LINK_ADDR=0x88200000
231 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
232 ;;
233 mipsel-arc)
234 TARGET_LINK_ADDR=0x80700000
235 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
236 ;;
237 mips*-qemu_mips | mips*-loongson)
238 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
239 ;;
240 esac
241
242 AC_SUBST(TARGET_LINK_ADDR)
243 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
244
245 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
246
247 AC_SUBST(host_cpu)
248 AC_SUBST(host_os)
249 AC_SUBST(host_kernel)
250
251 AC_SUBST(target_cpu)
252 AC_SUBST(platform)
253
254 # Define default variables
255
256 have_with_bootdir=n
257 AC_ARG_WITH([bootdir],
258 AS_HELP_STRING([--with-bootdir=DIR],
259 [set the name of /boot directory [[guessed]]]),
260 [have_with_bootdir=y],
261 [have_with_bootdir=n])
262 if test x$have_with_bootdir = xy; then
263 bootdirname="$with_bootdir"
264 else
265 case "$host_os" in
266 netbsd* | openbsd*)
267 # Because /boot is used for the boot block in NetBSD and OpenBSD,
268 bootdirname='' ;;
269 *) bootdirname='boot' ;;
270 esac
271 fi
272
273 AC_SUBST(bootdirname)
274 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
275 [Default boot directory name]")
276
277 AC_ARG_WITH([grubdir],
278 AS_HELP_STRING([--with-grubdir=DIR],
279 [set the name of grub directory [[guessed]]]),
280 [grubdirname="$with_grubdir"],
281 [grubdirname="$PACKAGE"])
282
283 AC_SUBST(grubdirname)
284 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
285 [Default grub directory name])
286
287 #
288 # Checks for build programs.
289 #
290
291 # Although cmp is listed in the GNU Coding Standards as a command which
292 # can used directly, OpenBSD lacks cmp in the default installation.
293 AC_CHECK_PROGS([CMP], [cmp])
294 if test "x$CMP" = x; then
295 AC_MSG_ERROR([cmp is not found])
296 fi
297
298 AC_CHECK_PROGS([YACC], [bison])
299 if test "x$YACC" = x; then
300 AC_MSG_ERROR([bison is not found])
301 fi
302
303 AC_PROG_RANLIB
304 AC_PROG_INSTALL
305 AC_PROG_AWK
306 AC_PROG_LEX
307 AC_PROG_YACC
308 AC_PROG_MAKE_SET
309 AC_PROG_MKDIR_P
310 AC_PROG_LN_S
311
312 if test "x$LEX" = "x:"; then
313 AC_MSG_ERROR([flex is not found])
314 else
315 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
316 if test -n "$version" -a "$version" -ge 20535; then
317 :
318 else
319 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
320 fi
321 fi
322
323 # These are not a "must".
324 AC_PATH_PROGS(MAKEINFO, makeinfo true)
325
326 #
327 # Checks for host programs.
328 #
329
330 AC_PROG_CC
331 gl_EARLY
332 AC_PROG_CXX
333 AM_PROG_CC_C_O
334 AM_PROG_AS
335
336 # Must be GCC.
337 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
338
339 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
340
341 AC_GNU_SOURCE
342 AM_GNU_GETTEXT([external])
343 AC_SYS_LARGEFILE
344
345 # Identify characteristics of the host architecture.
346 unset ac_cv_c_bigendian
347
348 AC_C_BIGENDIAN
349 AC_CHECK_SIZEOF(void *)
350 AC_CHECK_SIZEOF(long)
351
352 case "$host_os" in
353 cygwin | windows* | mingw32*)
354 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
355 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
356 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
357 ;;
358 esac
359
360 if test x$USE_NLS = xno; then
361 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
362 fi
363
364 if test "x$cross_compiling" = xyes; then
365 AC_MSG_WARN([cannot generate manual pages while cross compiling])
366 else
367 AC_PATH_PROG(HELP2MAN, help2man)
368 fi
369
370 # Check for functions and headers.
371 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
372 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
373
374 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
375 #include <sys/param.h>
376 #include <sys/mount.h>])
377
378 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
379 #include <sys/param.h>
380 #include <sys/mount.h>])
381
382 # For opendisk() and getrawpartition() on NetBSD.
383 # Used in util/deviceiter.c and in util/hostdisk.c.
384 AC_CHECK_HEADER([util.h], [
385 AC_CHECK_LIB([util], [opendisk], [
386 LIBUTIL="-lutil"
387 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
388 ])
389 AC_CHECK_LIB([util], [getrawpartition], [
390 LIBUTIL="-lutil"
391 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
392 ])
393 ])
394 AC_SUBST([LIBUTIL])
395
396 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
397 SAVED_CFLAGS="$CFLAGS"
398 CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror"
399 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
400 int va_arg_func (int fixed, va_list args);]], [[]])],
401 [grub_cv_host_cc_wtrampolines=yes],
402 [grub_cv_host_cc_wtrampolines=no])
403 CFLAGS="$SAVED_CFLAGS"
404 ])
405
406 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
407 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
408 fi
409
410 #
411 # Check for host and build compilers.
412 #
413 HOST_CC=$CC
414 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
415 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
416 BUILD_CPP="$BUILD_CC -E"
417
418 case "$build_os" in
419 haiku*) BUILD_LIBM= ;;
420 *) BUILD_LIBM=-lm ;;
421 esac
422 # For gnulib.
423 gl_INIT
424
425 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 -Wpointer-arith -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes"
426 EXTRA_WARN_FLAGS="-Wold-style-definition -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"
427
428 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align"
429
430 AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [
431 SAVED_CFLAGS="$CFLAGS"
432 grub_cv_cc_w_extra_flags=
433 for x in $EXTRA_WARN_FLAGS; do
434 CFLAGS="$HOST_CFLAGS $x -Werror"
435 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
436 if test x$flag = x1 ; then
437 grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x"
438 fi
439 done
440 CFLAGS="$SAVED_CFLAGS"
441 ])
442
443 HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags"
444
445 #
446 # Check for target programs.
447 #
448
449 # Find tools for the target.
450 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
451 tmp_ac_tool_prefix="$ac_tool_prefix"
452 ac_tool_prefix=$target_alias-
453
454 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
455 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
456 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
457 AC_CHECK_TOOL(TARGET_STRIP, strip)
458 AC_CHECK_TOOL(TARGET_NM, nm)
459 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
460
461 ac_tool_prefix="$tmp_ac_tool_prefix"
462 else
463 if test "x$TARGET_CC" = x; then
464 TARGET_CC=$CC
465 fi
466 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
467 AC_CHECK_TOOL(TARGET_STRIP, strip)
468 AC_CHECK_TOOL(TARGET_NM, nm)
469 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
470 fi
471
472 AC_SUBST(HOST_CC)
473 AC_SUBST(BUILD_CC)
474 AC_SUBST(BUILD_CFLAGS)
475 AC_SUBST(BUILD_CPPFLAGS)
476 AC_SUBST(TARGET_CC)
477 AC_SUBST(TARGET_NM)
478 AC_SUBST(TARGET_RANLIB)
479 AC_SUBST(TARGET_STRIP)
480 AC_SUBST(TARGET_OBJCOPY)
481
482 # Test the C compiler for the target environment.
483 tmp_CC="$CC"
484 tmp_CFLAGS="$CFLAGS"
485 tmp_LDFLAGS="$LDFLAGS"
486 tmp_CPPFLAGS="$CPPFLAGS"
487 tmp_LIBS="$LIBS"
488 CC="$TARGET_CC"
489 CFLAGS="$TARGET_CFLAGS"
490 CPPFLAGS="$TARGET_CPPFLAGS"
491 LDFLAGS="$TARGET_LDFLAGS"
492 LIBS=""
493
494 # debug flags.
495 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
496 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
497
498 if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
499 TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
500 fi
501
502 AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
503 LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
504
505 grub_cv_target_cc_w_extra_flags=
506 for x in $EXTRA_WARN_FLAGS; do
507 CFLAGS="$TARGET_CFLAGS $x -Werror"
508 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
509 if test x$flag = x1 ; then
510 grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x"
511 fi
512 done
513 ])
514
515 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
516
517 AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
518 [
519 CFLAGS="$TARGET_CFLAGS"
520 AC_COMPILE_IFELSE(
521 [AC_LANG_PROGRAM([], [[
522 #ifdef __clang__
523 #error "is clang"
524 #endif
525 ]])],
526 [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
527
528 # on x86 clang doesn't support .code16
529 # on arm clang doesn't support .arch directive
530 # on mips clang doesn't support privilegied instructions, doubleword store/load
531 # and crashes with hand-written assembly
532 if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
533 || test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \
534 || test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then
535 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
536 fi
537
538 if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then
539 AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame]
540 [
541 CFLAGS="$TARGET_CFLAGS"
542 AC_COMPILE_IFELSE(
543 [AC_LANG_PROGRAM([], [[
544 unsigned int a = 0, b = 0;
545 asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b));
546 if (a)
547 return 1;
548 ]])],
549 [grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])])
550 # clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
551 # used by gcrypt
552 if test x$grub_cv_cc_target_clang_ame = xno ; then
553 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
554 TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as"
555 fi
556 fi
557
558 if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
559 TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
560 fi
561
562 if test "x$target_m32" = x1; then
563 # Force 32-bit mode.
564 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
565 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
566 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
567 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
568 TARGET_MODULE_FORMAT="elf32"
569 fi
570
571 if test "x$target_m64" = x1; then
572 # Force 64-bit mode.
573 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
574 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
575 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
576 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
577 TARGET_MODULE_FORMAT="elf64"
578 fi
579
580 if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then
581 TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3"
582 fi
583
584 # on mips redirect cache flushing function to non-existant one.
585 if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
586 AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [
587 CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror"
588 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
589 [grub_cv_cc_mflush_func=yes],
590 [grub_cv_cc_mflush_func=no])
591 ])
592
593 if test "x$grub_cv_cc_mflush_func" = xyes; then
594 TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring"
595 fi
596 fi
597
598
599 # Force no alignment to save space on i386.
600 if test "x$target_cpu" = xi386; then
601 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
602 CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror"
603 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
604 [grub_cv_cc_falign_loop=yes],
605 [grub_cv_cc_falign_loop=no])
606 ])
607
608 AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [
609 CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror"
610 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
611 [grub_cv_cc_malign_loop=yes],
612 [grub_cv_cc_malign_loop=no])
613 ])
614
615 if test "x$grub_cv_cc_falign_loop" = xyes; then
616 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
617 elif test "x$grub_cv_cc_malign_loop" = xyes; then
618 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
619 fi
620 fi
621
622 AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [
623 CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror"
624 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
625 [grub_cv_cc_freg_struct_return=yes],
626 [grub_cv_cc_freg_struct_return=no])
627 ])
628
629 if test "x$grub_cv_cc_freg_struct_return" = xyes; then
630 TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return"
631 fi
632
633 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
634 # Some toolchains enable these features by default, but they need
635 # registers that aren't set up properly in GRUB.
636 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
637 fi
638
639 # By default, GCC 4.4 generates .eh_frame sections containing unwind
640 # information in some cases where it previously did not. GRUB doesn't need
641 # these and they just use up vital space. Restore the old compiler
642 # behaviour.
643 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
644 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
645 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
646 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
647 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
648 ])
649
650 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
651 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
652 fi
653
654 if test x"$target_os" = xcygwin; then
655 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
656 CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
657 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
658 [grub_cv_cc_no_reorder_functions=yes],
659 [grub_cv_cc_no_reorder_functions=no])
660 ])
661 fi
662
663 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
664 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
665 fi
666
667 # By default, GCC 4.6 generates .eh_frame sections containing unwind
668 # information in some cases where it previously did not. GRUB doesn't need
669 # these and they just use up vital space. Restore the old compiler
670 # behaviour.
671 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
672 CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
673 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
674 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
675 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
676 ])
677
678 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
679 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
680 fi
681
682 # For platforms where ELF is not the default link format.
683 case "${target_os}" in
684 cygwin)
685 # FIXME: put proper test here
686 NEED_REGISTER_FRAME_INFO=1
687 ;;
688 *) NEED_REGISTER_FRAME_INFO=0 ;;
689 esac
690
691
692 AC_ARG_ENABLE([efiemu],
693 [AS_HELP_STRING([--enable-efiemu],
694 [build and install the efiemu runtimes (default=guessed)])])
695 if test x"$enable_efiemu" = xno ; then
696 efiemu_excuse="explicitly disabled"
697 fi
698 if test x"$target_os" = xcygwin ; then
699 efiemu_excuse="not available on cygwin"
700 fi
701 if test x"$target_cpu" != xi386 ; then
702 efiemu_excuse="only available on i386"
703 fi
704 if test x"$platform" = xefi ; then
705 efiemu_excuse="not available on efi"
706 fi
707 if test x"$efiemu_excuse" = x ; then
708 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
709 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
710 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
711 [grub_cv_cc_efiemu=yes],
712 [grub_cv_cc_efiemu=no])
713 ])
714 if test x$grub_cv_cc_efiemu = xno; then
715 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
716 fi
717 fi
718 if test x"$efiemu_excuse" = x ; then
719 AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
720 grub_cv_target_cc_efiemu64_link_format=unknown
721 for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do
722 CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
723 LDFLAGS="-m64 -Wl,$format -nostdlib -static"
724 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
725 asm (".globl start; start:");
726 asm (".globl _start; _start:");
727 asm (".globl __start; __start:");
728 void __main (void);
729 void __main (void) {}
730 ]], [[]])], [flag=1], [flag=0])
731 if test x"$flag" = x1; then
732 grub_cv_target_cc_efiemu64_link_format="$format"
733 break;
734 fi
735 done])
736 if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
737 efiemu_excuse="no suitable link format for efiemu64 found"
738 else
739 EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
740 fi
741 fi
742 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
743 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
744 fi
745 if test x"$efiemu_excuse" = x ; then
746 enable_efiemu=yes
747 else
748 enable_efiemu=no
749 fi
750 AC_SUBST([enable_efiemu])
751 AC_SUBST([EFIEMU64_LINK_FORMAT])
752
753 CFLAGS="$TARGET_CFLAGS"
754
755 if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
756 AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
757 grub_cv_target_cc_link_format=unknown
758 for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do
759 if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
760 continue
761 fi
762 CFLAGS="$TARGET_CFLAGS"
763 LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static"
764 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
765 asm (".globl start; start:");
766 asm (".globl _start; _start:");
767 asm (".globl __start; __start:");
768 void __main (void);
769 void __main (void) {}
770 ]], [[]])], [flag=1], [flag=0])
771 if test x"$flag" = x1; then
772 grub_cv_target_cc_link_format="$format"
773 break;
774 fi
775 done])
776 if test x"$grub_cv_target_cc_link_format" = xunknown; then
777 AC_MSG_ERROR([no suitable link format found])
778 fi
779 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
780 if test x"$grub_cv_target_cc_link_format" = x-mi386pe; then
781 TARGET_OBJ2ELF='./build-grub-pe2elf';
782 fi
783 fi
784
785 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
786 TARGET_APPLE_LINKER=1
787 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
788 if test "x$TARGET_OBJCONV" = x ; then
789 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
790 fi
791 if test "x$TARGET_OBJCONV" = x ; then
792 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
793 fi
794 TARGET_IMG_LDSCRIPT=
795 TARGET_IMG_CFLAGS="-static"
796 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
797 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
798 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
799 TARGET_LDFLAGS_OLDMAGIC=""
800 elif test x$grub_cv_target_cc_link_format = x-mi386pe && test x$platform = xpc; then
801 TARGET_APPLE_LINKER=0
802 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
803 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
804 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
805 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-pc-cygwin-img-ld.sc"
806 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
807 TARGET_IMG_CFLAGS=
808 else
809 TARGET_APPLE_LINKER=0
810 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
811 TARGET_IMG_LDSCRIPT=
812 TARGET_IMG_LDFLAGS='-Wl,-N'
813 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
814 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
815 TARGET_IMG_CFLAGS=
816 fi
817
818 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
819
820
821 LDFLAGS="$TARGET_LDFLAGS"
822
823 if test "$target_cpu" = x86_64; then
824 # Use large model to support 4G memory
825 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
826 CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
827 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
828 [grub_cv_cc_mcmodel=yes],
829 [grub_cv_cc_mcmodel=no])
830 ])
831 if test "x$grub_cv_cc_mcmodel" = xyes; then
832 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
833 fi
834 fi
835
836 if test "$target_cpu"-"$platform" = x86_64-efi; then
837 # EFI writes to stack below %rsp, we must not use the red zone
838 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
839 CFLAGS="$TARGET_CFLAGS -m64 -mno-red-zone"
840 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
841 [grub_cv_cc_no_red_zone=yes],
842 [grub_cv_cc_no_red_zone=no])
843 ])
844 if test "x$grub_cv_cc_no_red_zone" = xno; then
845 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
846 fi
847
848 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
849 fi
850
851 if test "x$target_cpu" = xarm; then
852 AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [
853 CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror"
854 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
855 [grub_cv_cc_mlong_calls=yes],
856 [grub_cv_cc_mlong_calls=no])
857 ])
858 if test "x$grub_cv_cc_mlong_calls" = xyes; then
859 TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls"
860 fi
861 fi
862
863 #
864 # Compiler features.
865 #
866
867 CFLAGS="$TARGET_CFLAGS"
868
869 # Position independent executable.
870 grub_CHECK_PIE
871 [# Need that, because some distributions ship compilers that include
872 # `-fPIE' in the default specs.
873 if [ x"$pie_possible" = xyes ]; then
874 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
875 fi]
876
877 CFLAGS="$TARGET_CFLAGS"
878
879 # Position independent executable.
880 grub_CHECK_PIC
881 [# On most platforms we don't want PIC as it only makes relocations harder
882 # and code less efficient. On mips we want to have one got table per module
883 # and reload $gp in every function.
884 # GCC implements it using symbol __gnu_local_gp in non-PIC as well.
885 # However with clang we need PIC for this reloading to happen.
886 # Since default varies across dictributions use either -fPIC or -fno-PIC
887 # explicitly.
888 if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then
889 TARGET_CFLAGS="$TARGET_CFLAGS -fPIC"
890 elif [ x"$pic_possible" = xyes ]; then
891 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
892 fi]
893
894 CFLAGS="$TARGET_CFLAGS"
895
896 # Smashing stack protector.
897 grub_CHECK_STACK_PROTECTOR
898 # Need that, because some distributions ship compilers that include
899 # `-fstack-protector' in the default specs.
900 if test "x$ssp_possible" = xyes; then
901 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
902 fi
903
904 CFLAGS="$TARGET_CFLAGS"
905
906 grub_CHECK_STACK_ARG_PROBE
907 # Cygwin's GCC uses alloca() to probe the stackframe on static
908 # stack allocations above some threshold.
909 if test x"$sap_possible" = xyes; then
910 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
911 fi
912
913 CFLAGS="$TARGET_CFLAGS"
914
915 # -mno-unaligned-access -mstrict-align
916 if test "$target_cpu" = arm; then
917 AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [
918 grub_cv_target_cc_strict_align=
919 for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do
920 CFLAGS="$TARGET_CFLAGS $arg -Werror"
921 LDFLAGS="$TARGET_LDFLAGS"
922 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
923 if test x"$flag" = x1; then
924 grub_cv_target_cc_strict_align="$arg"
925 break;
926 fi
927 done])
928
929 TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align"
930 if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then
931 TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments"
932 fi
933 AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned],
934 [CFLAGS="$TARGET_CFLAGS"
935 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
936 #ifdef __ARM_FEATURE_UNALIGNED
937 #error "unaligned"
938 #endif
939 ]])],
940 [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])])
941 if test x$grub_cv_cc_target_emits_unaligned = xyes; then
942 AC_MSG_ERROR([compiler generates unaligned accesses])
943 fi
944 fi
945
946 # Set them to their new values for the tests below.
947 CC="$TARGET_CC"
948 if test "x$TARGET_APPLE_LINKER" = x1 ; then
949 CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
950 else
951 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
952 fi
953 CPPFLAGS="$TARGET_CPPFLAGS"
954 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
955 TARGET_LIBGCC=
956 else
957 TARGET_LIBGCC=-lgcc
958 fi
959
960 LIBS="$TARGET_LIBGCC"
961
962 grub_ASM_USCORE
963 if test "x$TARGET_APPLE_LINKER" = x0 ; then
964 if test x$grub_cv_asm_uscore = xyes; then
965 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,_abort=_main"
966 else
967 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,abort=main"
968 fi
969 fi
970
971 # Check for libgcc symbols
972 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
973
974 if test "x$TARGET_APPLE_LINKER" = x1 ; then
975 CFLAGS="$TARGET_CFLAGS -nostdlib -static"
976 else
977 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
978 fi
979 LIBS=""
980
981 # Defined in aclocal.m4.
982 grub_PROG_TARGET_CC
983 if test "x$TARGET_APPLE_LINKER" != x1 ; then
984 grub_PROG_OBJCOPY_ABSOLUTE
985 fi
986 grub_PROG_LD_BUILD_ID_NONE
987 if test "x$target_cpu" = xi386; then
988 if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then
989 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
990 # Check symbols provided by linker script.
991 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000 -Wl,--defsym,___main=0x8100"
992 fi
993 grub_CHECK_BSS_START_SYMBOL
994 grub_CHECK_END_SYMBOL
995 fi
996 CFLAGS="$TARGET_CFLAGS"
997 grub_I386_ASM_PREFIX_REQUIREMENT
998 grub_I386_ASM_ADDR32
999 fi
1000
1001 grub_PROG_NM_WORKS
1002 grub_PROG_NM_MINUS_P
1003 grub_PROG_NM_DEFINED_ONLY
1004 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
1005 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
1006
1007 if test "$platform" != emu; then
1008 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
1009 SAVED_CPPFLAGS="$CPPFLAGS"
1010 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1011 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1012 #include <stddef.h>
1013 int va_arg_func (int fixed, va_list args);]], [[]])],
1014 [grub_cv_cc_isystem=yes],
1015 [grub_cv_cc_isystem=no])
1016 CPPFLAGS="$SAVED_CPPFLAGS"
1017 ])
1018
1019 if test x"$grub_cv_cc_isystem" = xyes ; then
1020 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
1021 fi
1022 fi
1023
1024 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
1025 CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror"
1026 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
1027 int va_arg_func (int fixed, va_list args);]], [[]])],
1028 [grub_cv_cc_wtrampolines=yes],
1029 [grub_cv_cc_wtrampolines=no])
1030 ])
1031
1032 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
1033 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
1034 fi
1035
1036 # Restore the flags.
1037 CC="$tmp_CC"
1038 CFLAGS="$tmp_CFLAGS"
1039 CPPFLAGS="$tmp_CPPFLAGS"
1040 LDFLAGS="$tmp_LDFLAGS"
1041 LIBS="$tmp_LIBS"
1042
1043 #
1044 # Check for options.
1045 #
1046
1047 # Memory manager debugging.
1048 AC_ARG_ENABLE([mm-debug],
1049 AS_HELP_STRING([--enable-mm-debug],
1050 [include memory manager debugging]),
1051 [AC_DEFINE([MM_DEBUG], [1],
1052 [Define to 1 if you enable memory manager debugging.])])
1053
1054 AC_ARG_ENABLE([cache-stats],
1055 AS_HELP_STRING([--enable-cache-stats],
1056 [enable disk cache statistics collection]))
1057
1058 if test x$enable_cache_stats = xyes; then
1059 DISK_CACHE_STATS=1
1060 else
1061 DISK_CACHE_STATS=0
1062 fi
1063 AC_SUBST([DISK_CACHE_STATS])
1064
1065 AC_ARG_ENABLE([boot-time],
1066 AS_HELP_STRING([--enable-boot-time],
1067 [enable boot time statistics collection]))
1068
1069 if test x$enable_boot_time = xyes; then
1070 BOOT_TIME_STATS=1
1071 else
1072 BOOT_TIME_STATS=0
1073 fi
1074 AC_SUBST([BOOT_TIME_STATS])
1075
1076 AC_ARG_ENABLE([grub-emu-usb],
1077 [AS_HELP_STRING([--enable-grub-emu-usb],
1078 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
1079
1080 AC_ARG_ENABLE([grub-emu-sdl],
1081 [AS_HELP_STRING([--enable-grub-emu-sdl],
1082 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
1083
1084 AC_ARG_ENABLE([grub-emu-pci],
1085 [AS_HELP_STRING([--enable-grub-emu-pci],
1086 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
1087
1088 if test "$platform" = emu; then
1089
1090 if test x"$enable_grub_emu_usb" != xyes ; then
1091 grub_emu_usb_excuse="not enabled"
1092 fi
1093
1094 if test x"$enable_grub_emu_pci" = xyes ; then
1095 grub_emu_usb_excuse="conflicts with PCI support"
1096 fi
1097
1098 [if [ x"$grub_emu_usb_excuse" = x ]; then
1099 # Check for libusb libraries.]
1100 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
1101 [grub_emu_usb_excuse=["need libusb library"]])
1102 AC_SUBST([LIBUSB])
1103 [fi]
1104 [if [ x"$grub_emu_usb_excuse" = x ]; then
1105 # Check for headers.]
1106 AC_CHECK_HEADERS([usb.h], [],
1107 [grub_emu_usb_excuse=["need libusb headers"]])
1108 [fi]
1109 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
1110 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
1111 fi
1112 if test x"$grub_emu_usb_excuse" = x ; then
1113 enable_grub_emu_usb=yes
1114 else
1115 enable_grub_emu_usb=no
1116 fi
1117
1118 if test x"$enable_grub_emu_sdl" = xno ; then
1119 grub_emu_sdl_excuse="explicitely disabled"
1120 fi
1121 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1122 # Check for libSDL libraries.]
1123 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
1124 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
1125 AC_SUBST([LIBSDL])
1126 [fi]
1127
1128 [if [ x"$grub_emu_sdl_excuse" = x ]; then
1129 # Check for headers.]
1130 AC_CHECK_HEADERS([SDL/SDL.h], [],
1131 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
1132 [fi]
1133
1134 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
1135 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
1136 fi
1137 if test x"$grub_emu_sdl_excuse" = x ; then
1138 enable_grub_emu_sdl=yes
1139 else
1140 enable_grub_emu_sdl=no
1141 fi
1142
1143 if test x"$enable_grub_emu_pci" != xyes ; then
1144 grub_emu_pci_excuse="not enabled"
1145 fi
1146
1147 if test x"$enable_grub_emu_usb" = xyes ; then
1148 grub_emu_pci_excuse="conflicts with USB support"
1149 fi
1150
1151 [if [ x"$grub_emu_pci_excuse" = x ]; then
1152 # Check for libpci libraries.]
1153 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
1154 [grub_emu_pci_excuse=["need libpciaccess library"]])
1155 AC_SUBST([LIBPCIACCESS])
1156 [fi]
1157 [if [ x"$grub_emu_pci_excuse" = x ]; then
1158 # Check for headers.]
1159 AC_CHECK_HEADERS([pci/pci.h], [],
1160 [grub_emu_pci_excuse=["need libpciaccess headers"]])
1161 [fi]
1162
1163 if test x"$grub_emu_pci_excuse" = x ; then
1164 enable_grub_emu_pci=yes
1165 else
1166
1167 enable_grub_emu_pci=no
1168 fi
1169
1170 AC_SUBST([enable_grub_emu_sdl])
1171 AC_SUBST([enable_grub_emu_usb])
1172 AC_SUBST([enable_grub_emu_pci])
1173
1174 else
1175
1176 # Ignore --enable-emu-* if platform is not emu
1177 enable_grub_emu_sdl=no
1178 enable_grub_emu_usb=no
1179 enable_grub_emu_pci=no
1180 fi
1181
1182 AC_ARG_ENABLE([grub-mkfont],
1183 [AS_HELP_STRING([--enable-grub-mkfont],
1184 [build and install the `grub-mkfont' utility (default=guessed)])])
1185 if test x"$enable_grub_mkfont" = xno ; then
1186 grub_mkfont_excuse="explicitly disabled"
1187 fi
1188
1189 if test x"$grub_mkfont_excuse" = x ; then
1190 # Check for freetype libraries.
1191 AC_CHECK_TOOLS([FREETYPE], [freetype-config])
1192 if test "x$FREETYPE" = x ; then
1193 grub_mkfont_excuse=["need freetype2 library"]
1194 fi
1195 fi
1196
1197 unset ac_cv_header_ft2build_h
1198
1199 if test x"$grub_mkfont_excuse" = x ; then
1200 # Check for freetype libraries.
1201 freetype_cflags=`$FREETYPE --cflags`
1202 freetype_libs=`$FREETYPE --libs`
1203 SAVED_CPPFLAGS="$CPPFLAGS"
1204 CPPFLAGS="$CPPFLAGS $freetype_cflags"
1205 AC_CHECK_HEADERS([ft2build.h], [],
1206 [grub_mkfont_excuse=["need freetype2 headers"]])
1207 CPPFLAGS="$SAVED_CPPFLAGS"
1208 fi
1209
1210 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1211 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
1212 fi
1213 if test x"$grub_mkfont_excuse" = x ; then
1214 enable_grub_mkfont=yes
1215 else
1216 enable_grub_mkfont=no
1217 fi
1218 AC_SUBST([enable_grub_mkfont])
1219 AC_SUBST([freetype_cflags])
1220 AC_SUBST([freetype_libs])
1221
1222 SAVED_CC="$CC"
1223 SAVED_CPP="$CPP"
1224 SAVED_CFLAGS="$CFLAGS"
1225 SAVED_CPPFLAGS="$CPPFLAGS"
1226 CC="$BUILD_CC"
1227 CPP="$BUILD_CPP"
1228 CFLAGS="$BUILD_CFLAGS"
1229 CPPFLAGS="$BUILD_CPPFLAGS"
1230
1231 unset ac_cv_c_bigendian
1232 unset ac_cv_header_ft2build_h
1233
1234 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1235 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1236 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1237
1238 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1239 AC_MSG_ERROR([couldnt determine build endianness])
1240 fi
1241
1242 AC_SUBST([BUILD_SIZEOF_LONG])
1243 AC_SUBST([BUILD_SIZEOF_VOID_P])
1244 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1245
1246 if test x"$grub_build_mkfont_excuse" = x ; then
1247 # Check for freetype libraries.
1248 AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config])
1249 if test "x$BUILD_FREETYPE" = x ; then
1250 grub_build_mkfont_excuse=["need freetype2 library"]
1251 fi
1252 fi
1253
1254 if test x"$grub_build_mkfont_excuse" = x ; then
1255 # Check for freetype libraries.
1256 build_freetype_cflags=`$BUILD_FREETYPE --cflags`
1257 build_freetype_libs=`$BUILD_FREETYPE --libs`
1258 SAVED_CPPFLAGS_2="$CPPFLAGS"
1259 CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
1260 AC_CHECK_HEADERS([ft2build.h], [],
1261 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1262 CPPFLAGS="$SAVED_CPPFLAGS_2"
1263 fi
1264
1265 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1266 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled])
1267 fi
1268 if test x"$grub_build_mkfont_excuse" = x ; then
1269 enable_build_grub_mkfont=yes
1270 else
1271 enable_build_grub_mkfont=no
1272 fi
1273 if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
1274 AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont])
1275 fi
1276
1277 AC_SUBST([build_freetype_cflags])
1278 AC_SUBST([build_freetype_libs])
1279
1280 CC="$SAVED_CC"
1281 CPP="$SAVED_CPP"
1282 CFLAGS="$SAVED_CFLAGS"
1283 CPPFLAGS="$SAVED_CPPFLAGS"
1284
1285
1286 DJVU_FONT_SOURCE=
1287
1288 starfield_excuse=
1289
1290 AC_ARG_ENABLE([grub-themes],
1291 [AS_HELP_STRING([--enable-grub-themes],
1292 [build and install GRUB themes (default=guessed)])])
1293 if test x"$enable_grub_themes" = xno ; then
1294 starfield_excuse="explicitly disabled"
1295 fi
1296
1297 if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then
1298 starfield_excuse="No build-time grub-mkfont"
1299 fi
1300
1301 if test x"$starfield_excuse" = x; then
1302 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1303 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
1304 if test -f "$dir/DejaVuSans.$ext"; then
1305 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1306 break 2
1307 fi
1308 done
1309 done
1310
1311 if test "x$DJVU_FONT_SOURCE" = x; then
1312 starfield_excuse="No DejaVu found"
1313 fi
1314 fi
1315
1316 if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then
1317 AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied])
1318 fi
1319
1320 AC_SUBST([DJVU_FONT_SOURCE])
1321
1322 FONT_SOURCE=
1323
1324 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1325 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
1326 if test -f "$dir/unifont.$ext"; then
1327 md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
1328 # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
1329 if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
1330 continue;
1331 fi
1332 FONT_SOURCE="$dir/unifont.$ext"
1333 break 2
1334 fi
1335 done
1336 done
1337
1338 if test x"$enable_build_grub_mkfont" = xno ; then
1339 FONT_SOURCE=
1340 fi
1341
1342 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
1343 AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont])
1344 fi
1345
1346 AC_SUBST([FONT_SOURCE])
1347
1348 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1349 grub_build_mkfont_excuse="no fonts"
1350 fi
1351
1352
1353 AC_ARG_ENABLE([grub-mount],
1354 [AS_HELP_STRING([--enable-grub-mount],
1355 [build and install the `grub-mount' utility (default=guessed)])])
1356 if test x"$enable_grub_mount" = xno ; then
1357 grub_mount_excuse="explicitly disabled"
1358 fi
1359
1360 if test x"$grub_mount_excuse" = x ; then
1361 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1362 [grub_mount_excuse="need FUSE library"])
1363 fi
1364
1365 if test x"$grub_mount_excuse" = x ; then
1366 # Check for fuse headers.
1367 SAVED_CPPFLAGS="$CPPFLAGS"
1368 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
1369 AC_CHECK_HEADERS([fuse/fuse.h], [],
1370 [grub_mount_excuse=["need FUSE headers"]])
1371 CPPFLAGS="$SAVED_CPPFLAGS"
1372 fi
1373
1374 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1375 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
1376 fi
1377 if test x"$grub_mount_excuse" = x ; then
1378 enable_grub_mount=yes
1379 else
1380 enable_grub_mount=no
1381 fi
1382 AC_SUBST([enable_grub_mount])
1383
1384 AC_ARG_ENABLE([device-mapper],
1385 [AS_HELP_STRING([--enable-device-mapper],
1386 [enable Linux device-mapper support (default=guessed)])])
1387 if test x"$enable_device_mapper" = xno ; then
1388 device_mapper_excuse="explicitly disabled"
1389 fi
1390
1391 if test x"$device_mapper_excuse" = x ; then
1392 # Check for device-mapper header.
1393 AC_CHECK_HEADER([libdevmapper.h], [],
1394 [device_mapper_excuse="need libdevmapper header"])
1395 fi
1396
1397 if test x"$device_mapper_excuse" = x ; then
1398 # Check for device-mapper library.
1399 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1400 [device_mapper_excuse="need devmapper library"])
1401 fi
1402
1403 if test x"$device_mapper_excuse" = x ; then
1404 # Check for device-mapper library.
1405 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1406 [],
1407 [device_mapper_excuse="need devmapper library"])
1408 fi
1409
1410 if test x"$device_mapper_excuse" = x ; then
1411 LIBDEVMAPPER="-ldevmapper";
1412 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1413 [Define to 1 if you have the devmapper library.])
1414 fi
1415
1416 AC_SUBST([LIBDEVMAPPER])
1417
1418 LIBGEOM=
1419 if test x$host_kernel = xkfreebsd; then
1420 AC_CHECK_LIB([geom], [geom_gettree], [],
1421 [AC_MSG_ERROR([Your platform requires libgeom])])
1422 LIBGEOM="-lgeom"
1423 fi
1424
1425 AC_SUBST([LIBGEOM])
1426
1427 AC_ARG_ENABLE([liblzma],
1428 [AS_HELP_STRING([--enable-liblzma],
1429 [enable liblzma integration (default=guessed)])])
1430 if test x"$enable_liblzma" = xno ; then
1431 liblzma_excuse="explicitly disabled"
1432 fi
1433
1434 if test x"$liblzma_excuse" = x ; then
1435 AC_CHECK_LIB([lzma], [lzma_code],
1436 [],[liblzma_excuse="need lzma library"])
1437 fi
1438 if test x"$liblzma_excuse" = x ; then
1439 AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"])
1440 fi
1441
1442 if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then
1443 AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied])
1444 fi
1445
1446
1447 if test x"$liblzma_excuse" = x ; then
1448 LIBLZMA="-llzma"
1449 AC_DEFINE([USE_LIBLZMA], [1],
1450 [Define to 1 if you have the LZMA library.])
1451 fi
1452
1453 AC_SUBST([LIBLZMA])
1454
1455 AC_ARG_ENABLE([libzfs],
1456 [AS_HELP_STRING([--enable-libzfs],
1457 [enable libzfs integration (default=guessed)])])
1458 if test x"$enable_libzfs" = xno ; then
1459 libzfs_excuse="explicitly disabled"
1460 fi
1461
1462 if test x"$libzfs_excuse" = x ; then
1463 # Only check for system headers if libzfs support has not been disabled.
1464 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1465 fi
1466
1467 if test x"$libzfs_excuse" = x ; then
1468 AC_CHECK_LIB([zfs], [libzfs_init],
1469 [],
1470 [libzfs_excuse="need zfs library"])
1471 fi
1472
1473 if test x"$libzfs_excuse" = x ; then
1474 AC_CHECK_LIB([nvpair], [nvlist_lookup_string],
1475 [],
1476 [libzfs_excuse="need nvpair library"])
1477 fi
1478
1479 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1480 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1481 fi
1482
1483 if test x"$libzfs_excuse" = x ; then
1484 # We need both libzfs and libnvpair for a successful build.
1485 LIBZFS="-lzfs"
1486 AC_DEFINE([HAVE_LIBZFS], [1],
1487 [Define to 1 if you have the ZFS library.])
1488 LIBNVPAIR="-lnvpair"
1489 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1490 [Define to 1 if you have the NVPAIR library.])
1491 fi
1492
1493 AC_SUBST([LIBZFS])
1494 AC_SUBST([LIBNVPAIR])
1495
1496 LIBS=""
1497
1498 AC_SUBST([FONT_SOURCE])
1499 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1500 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1501
1502 AC_SUBST(HAVE_ASM_USCORE)
1503 AC_SUBST(ADDR32)
1504 AC_SUBST(DATA32)
1505 AC_SUBST(BSS_START_SYMBOL)
1506 AC_SUBST(END_SYMBOL)
1507 AC_SUBST(PACKAGE)
1508 AC_SUBST(VERSION)
1509 AC_SUBST(NEED_REGISTER_FRAME_INFO)
1510
1511 AC_ARG_ENABLE([werror],
1512 [AS_HELP_STRING([--disable-werror],
1513 [do not use -Werror when building GRUB])])
1514 if test x"$enable_werror" != xno ; then
1515 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
1516 HOST_CFLAGS="$HOST_CFLAGS -Werror"
1517 fi
1518
1519 if test "x$grub_cv_cc_target_clang" = xno; then
1520 TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
1521 else
1522 TARGET_LDFLAGS_STATIC_LIBGCC=
1523 fi
1524
1525 TARGET_CPP="$TARGET_CC -E"
1526 TARGET_CCAS=$TARGET_CC
1527
1528 GRUB_TARGET_CPU="${target_cpu}"
1529 GRUB_PLATFORM="${platform}"
1530
1531 AC_SUBST(GRUB_TARGET_CPU)
1532 AC_SUBST(GRUB_PLATFORM)
1533
1534 AC_SUBST(TARGET_OBJCONV)
1535 AC_SUBST(TARGET_LIBGCC)
1536 AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
1537 AC_SUBST(TARGET_CPP)
1538 AC_SUBST(TARGET_CCAS)
1539 AC_SUBST(TARGET_OBJ2ELF)
1540 AC_SUBST(TARGET_MODULE_FORMAT)
1541
1542 AC_SUBST(TARGET_CFLAGS)
1543 AC_SUBST(TARGET_LDFLAGS)
1544 AC_SUBST(TARGET_CPPFLAGS)
1545 AC_SUBST(TARGET_CCASFLAGS)
1546
1547 AC_SUBST(TARGET_IMG_LDSCRIPT)
1548 AC_SUBST(TARGET_IMG_LDFLAGS)
1549 AC_SUBST(TARGET_IMG_CFLAGS)
1550 AC_SUBST(TARGET_IMG_BASE_LDOPT)
1551 AC_SUBST(TARGET_APPLE_LINKER)
1552
1553 AC_SUBST(HOST_CFLAGS)
1554 AC_SUBST(HOST_LDFLAGS)
1555 AC_SUBST(HOST_CPPFLAGS)
1556 AC_SUBST(HOST_CCASFLAGS)
1557
1558 AC_SUBST(BUILD_LIBM)
1559
1560 #
1561 # Automake conditionals
1562 #
1563
1564 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1565 AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
1566 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1567 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1568 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1569 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1570 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1571 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1572 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1573 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1574 AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen])
1575 AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen])
1576 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1577 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1578 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1579 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1580 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1581 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1582 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1583 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1584 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1585 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1586 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1587 AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
1588 AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
1589
1590 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1591 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1592 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1593 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1594 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1595 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1596 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1597
1598 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1599 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1600 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1601 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1602 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1603 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1604 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1605 if test x$FONT_SOURCE != x ; then
1606 HAVE_FONT_SOURCE=1
1607 else
1608 HAVE_FONT_SOURCE=0
1609 fi
1610 AC_SUBST(HAVE_FONT_SOURCE)
1611 AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1])
1612 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1613 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1614 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1615
1616 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1617
1618 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1619 AM_CONDITIONAL([COND_CYGWIN], [test x$target_os = xcygwin])
1620 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1621 AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
1622
1623 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
1624 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
1625 datarootdir="$(eval echo "$datarootdir")"
1626 grub_libdir="$(eval echo "$libdir")"
1627 grub_localedir="$(eval echo "$localedir")"
1628 grub_datadir="$(eval echo "$datadir")"
1629 grub_sysconfdir="$(eval echo "$sysconfdir")"
1630 AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir])
1631 AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir])
1632 AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir])
1633 AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
1634
1635
1636 # Output files.
1637 cpudir="${target_cpu}"
1638 if test x${cpudir} = xmipsel; then
1639 cpudir=mips;
1640 fi
1641 grub_CHECK_LINK_DIR
1642 if test x"$link_dir" = xyes ; then
1643 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1644 if test "$platform" != emu ; then
1645 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1646 fi
1647 else
1648 mkdir -p include/grub 2>/dev/null
1649 rm -rf include/grub/cpu
1650 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1651 if test "$platform" != emu ; then
1652 rm -rf include/grub/machine
1653 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1654 fi
1655 fi
1656
1657 AC_CONFIG_FILES([Makefile])
1658 AC_CONFIG_FILES([grub-core/Makefile])
1659 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1660 AC_CONFIG_FILES([po/Makefile.in])
1661 AC_CONFIG_FILES([docs/Makefile])
1662 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1663 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1664 AC_CONFIG_FILES([config.h])
1665
1666 AC_OUTPUT
1667 [
1668 echo "*******************************************************"
1669 echo GRUB2 will be compiled with following components:
1670 echo Platform: "$target_cpu"-"$platform"
1671 if [ x"$platform" = xemu ]; then
1672 if [ x"$grub_emu_usb_excuse" = x ]; then
1673 echo USB support for grub-emu: Yes
1674 else
1675 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1676 fi
1677 if [ x"$grub_emu_sdl_excuse" = x ]; then
1678 echo SDL support for grub-emu: Yes
1679 else
1680 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1681 fi
1682 if [ x"$grub_emu_pci_excuse" = x ]; then
1683 echo PCI support for grub-emu: Yes
1684 else
1685 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1686 fi
1687 fi
1688 if test x"$device_mapper_excuse" = x ; then
1689 echo With devmapper support: Yes
1690 else
1691 echo With devmapper support: No "($device_mapper_excuse)"
1692 fi
1693 if [ x"$enable_mm_debug" = xyes ]; then
1694 echo With memory debugging: Yes
1695 else
1696 echo With memory debugging: No
1697 fi
1698 if [ x"$enable_cache_stats" = xyes ]; then
1699 echo With disk cache statistics: Yes
1700 else
1701 echo With disk cache statistics: No
1702 fi
1703
1704 if [ x"$enable_boot_time" = xyes ]; then
1705 echo With boot time statistics: Yes
1706 else
1707 echo With boot time statistics: No
1708 fi
1709
1710 if [ x"$efiemu_excuse" = x ]; then
1711 echo efiemu runtime: Yes
1712 else
1713 echo efiemu runtime: No "($efiemu_excuse)"
1714 fi
1715 if [ x"$grub_mkfont_excuse" = x ]; then
1716 echo grub-mkfont: Yes
1717 else
1718 echo grub-mkfont: No "($grub_mkfont_excuse)"
1719 fi
1720 if [ x"$grub_mount_excuse" = x ]; then
1721 echo grub-mount: Yes
1722 else
1723 echo grub-mount: No "($grub_mount_excuse)"
1724 fi
1725 if [ x"$starfield_excuse" = x ]; then
1726 echo starfield theme: Yes
1727 else
1728 echo starfield theme: No "($starfield_excuse)"
1729 fi
1730 if [ x"$libzfs_excuse" = x ]; then
1731 echo With libzfs support: Yes
1732 else
1733 echo With libzfs support: No "($libzfs_excuse)"
1734 fi
1735 if [ x"$grub_build_mkfont_excuse" = x ]; then
1736 echo Build-time grub-mkfont: Yes
1737 if test "x$FONT_SOURCE" = x ; then
1738 echo "Without unifont"
1739 else
1740 echo "With unifont from $FONT_SOURCE"
1741 fi
1742 else
1743 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
1744 echo "Without unifont (no build-time grub-mkfont)"
1745 fi
1746 if test x"$liblzma_excuse" != x ; then
1747 echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)"
1748 else
1749 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
1750 fi
1751 echo "*******************************************************"
1752 ]