2010-05-18 Justus Winter <4winter@informatik.uni-hamburg.de>
[grub.git] / configure.ac
blobace6bd81d7868bb49aa38743a415c03b95827d20
1 # Process this file with autoconf to produce a configure script.
3 # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
5 # This configure.ac is free software; the author
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
14 dnl This configure script is complicated, because GRUB needs to deal
15 dnl with three potentially different types:
16 dnl
17 dnl   build  -- the environment for building GRUB
18 dnl   host   -- the environment for running utilities
19 dnl   target -- the environment for running GRUB
20 dnl
21 dnl In addition, GRUB needs to deal with a platform specification
22 dnl which specifies the system running GRUB, such as firmware.
23 dnl This is necessary because the target type in autoconf does not
24 dnl describe such a system very well.
25 dnl
26 dnl The current strategy is to use variables with no prefix (such as
27 dnl CC, CFLAGS, etc.) for the host type as well as the build type,
28 dnl because GRUB does not need to use those variables for the build
29 dnl type, so there is no conflict. Variables with the prefix "TARGET_"
30 dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
31 dnl type.
34 AC_INIT([GRUB],[1.98],[bug-grub@gnu.org])
35 AM_INIT_AUTOMAKE()
36 AC_PREREQ(2.60)
37 AC_CONFIG_SRCDIR([include/grub/dl.h])
38 AC_CONFIG_HEADER([config.h])
40 # Checks for host and target systems.
41 AC_CANONICAL_HOST
42 AC_CANONICAL_TARGET
44 # Program name transformations
45 AC_ARG_PROGRAM
47 # Optimization flag.  Allow user to override.
48 if test "x$TARGET_CFLAGS" = x; then
49   TARGET_CFLAGS="$TARGET_CFLAGS -Os"
52 case "$target_cpu" in
53   i[[3456]]86)  target_cpu=i386 ;;
54   amd64)        target_cpu=x86_64 ;;
55   sparc)        target_cpu=sparc64 ;;
56   mipsel|mips64el)
57                 target_cpu=mips;    
58                 TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPSEL=1"; 
59                 CFLAGS="$CFLAGS -DGRUB_CPU_MIPSEL=1";
60                 ;;
61   mips|mips64)
62                 target_cpu=mips;    
63                 TARGET_CFLAGS="$TARGET_CFLAGS -DGRUB_CPU_MIPS=1"; 
64                 CFLAGS="$CFLAGS -DGRUB_CPU_MIPS=1";
65                 ;;
66 esac
68 # Specify the platform (such as firmware).
69 AC_ARG_WITH([platform],
70             AS_HELP_STRING([--with-platform=PLATFORM],
71                            [select the host platform [[guessed]]]))
73 # Guess the platform if not specified.
74 if test "x$with_platform" = x; then
75   case "$target_cpu"-"$target_vendor" in
76     i386-apple) platform=efi ;;
77     i386-*) platform=pc ;;
78     x86_64-apple) platform=efi ;;
79     x86_64-*) platform=pc ;;
80     powerpc-*) platform=ieee1275 ;;
81     powerpc64-*) platform=ieee1275 ;;
82     sparc64-*) platform=ieee1275 ;;
83     mips-*) platform=yeeloong ;;
84     *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
85   esac
86 else
87   platform="$with_platform"
90 # Adjust CPU unless target was explicitly specified.
91 if test -z "$target_alias"; then
92   case "$target_cpu"-"$platform" in
93     x86_64-efi) ;;
94     x86_64-emu) ;;
95     x86_64-*) target_cpu=i386 ;;
96     powerpc64-ieee1275) target_cpu=powerpc ;;
97   esac
100 # Check if the platform is supported, make final adjustments.
101 case "$target_cpu"-"$platform" in
102   i386-efi) ;;
103   x86_64-efi) ;;
104   i386-pc) ;;
105   i386-multiboot) ;;
106   i386-coreboot) ;;
107   i386-linuxbios) platform=coreboot ;;
108   i386-ieee1275) ;;
109   i386-qemu) ;;
110   powerpc-ieee1275) ;;
111   sparc64-ieee1275) ;;
112   mips-qemu-mips) ;;
113   mips-yeeloong) ;;
114   *-emu) ;;
115   *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
116 esac
118 case "$target_cpu" in
119   i386 | powerpc) target_m32=1 ;;
120   x86_64 | sparc64) target_m64=1 ;;
121 esac
123 case "$host_os" in
124   mingw32*) host_os=cygwin ;;
125 esac
127 # This normalizes the names, and creates a new variable ("host_kernel")
128 # while at it, since the mapping is not always 1:1 (e.g. different OSes
129 # using the same kernel type).
130 case "$host_os" in
131   gnu*)                         host_kernel=hurd ;;
132   linux*)                       host_kernel=linux ;;
133   freebsd* | kfreebsd*-gnu)     host_kernel=kfreebsd ;;
134   netbsd*)                      host_kernel=netbsd ;;
135   cygwin)                       host_kernel=windows ;;
136 esac
138 case "$platform" in
139   coreboot)     machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
140   multiboot)    machine_CFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;;
141   efi)          machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
142   ieee1275)     machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
143   qemu)         machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
144   pc)           machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
145   emu)          machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
146   yeeloong)     machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
147   qemu-mips)    machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
148 esac
149 case "$target_cpu" in
150   mips)         machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
151   sparc64)      machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
152 esac
153 machine_CFLAGS="$machine_CFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
155 CFLAGS="$CFLAGS $machine_CFLAGS"
156 TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
157 TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
159 AC_SUBST(host_cpu)
160 AC_SUBST(host_os)
161 AC_SUBST(host_kernel)
163 AC_SUBST(target_cpu)
164 AC_SUBST(platform)
167 # Checks for build programs.
170 # Although cmp is listed in the GNU Coding Standards as a command which
171 # can used directly, OpenBSD lacks cmp in the default installation.
172 AC_CHECK_PROGS([CMP], [cmp])
173 if test "x$CMP" = x; then
174   AC_MSG_ERROR([cmp is not found])
177 AC_CHECK_PROGS([YACC], [bison])
178 if test "x$YACC" = x; then
179   AC_MSG_ERROR([bison is not found])
182 for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz /usr/share/fonts/unifont/unifont.pcf.gz; do
183   if test -e $file ; then
184     AC_SUBST([FONT_SOURCE], [$file])
185     break
186   fi
187 done
189 AC_PROG_INSTALL
190 AC_PROG_AWK
191 AC_PROG_LEX
192 AC_PROG_MAKE_SET
193 AC_PROG_MKDIR_P
195 if test "x$LEX" = x; then
196   AC_MSG_ERROR([flex is not found])
197 else
198   version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
199   if test -n "$version" -a "$version" -ge 20535; then
200     :
201   else
202     AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
203   fi
206 # These are not a "must".
207 AC_PATH_PROG(RUBY, ruby)
208 AC_PATH_PROG(MAKEINFO, makeinfo)
211 # Checks for host programs.
214 AC_PROG_CC
215 # Must be GCC.
216 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
218 AC_GNU_SOURCE
219 AM_GNU_GETTEXT([external])
220 AC_SYS_LARGEFILE
222 # Identify characteristics of the host architecture.
223 AC_C_BIGENDIAN
224 AC_CHECK_SIZEOF(void *)
225 AC_CHECK_SIZEOF(long)
227 grub_apple_cc
228 if test x$grub_cv_apple_cc = xyes ; then
229   CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
230   ASFLAGS="$ASFLAGS -DAPPLE_CC=1"
233 if test "x$cross_compiling" = xyes; then
234   AC_MSG_WARN([cannot generate manual pages while cross compiling])
235 else
236   AC_PATH_PROG(HELP2MAN, help2man)
239 # Check for functions.
240 AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf)
242 # For grub-mkisofs
243 AC_HEADER_MAJOR
244 AC_HEADER_DIRENT
245 AC_CHECK_FUNCS(memmove sbrk strdup lstat getuid getgid)
246 AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h)
247 AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h limits.h)
249 # For opendisk() and getrawpartition() on NetBSD.
250 # Used in util/deviceiter.c and in util/hostdisk.c.
251 AC_CHECK_HEADER([util.h], [
252   AC_CHECK_LIB([util], [opendisk], [
253     LIBUTIL="-lutil"
254     AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
255   ])
256   AC_CHECK_LIB([util], [getrawpartition], [
257     LIBUTIL="-lutil"
258     AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
259   ])
261 AC_SUBST([LIBUTIL])
264 # Check for target programs.
267 # Find tools for the target.
268 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
269   tmp_ac_tool_prefix="$ac_tool_prefix"
270   ac_tool_prefix=$target_alias-
272   AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
273                  [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
274   AC_CHECK_TOOL(OBJCOPY, objcopy)
275   AC_CHECK_TOOL(STRIP, strip)
276   AC_CHECK_TOOL(NM, nm)
278   ac_tool_prefix="$tmp_ac_tool_prefix"
279 else
280   if test "x$TARGET_CC" = x; then
281     TARGET_CC=$CC
282   fi
283   AC_CHECK_TOOL(OBJCOPY, objcopy)
284   AC_CHECK_TOOL(STRIP, strip)
285   AC_CHECK_TOOL(NM, nm)
287 AC_SUBST(TARGET_CC)
290 # Test the C compiler for the target environment.
291 tmp_CC="$CC"
292 tmp_CFLAGS="$CFLAGS"
293 tmp_LDFLAGS="$LDFLAGS"
294 tmp_CPPFLAGS="$CPPFLAGS"
295 tmp_LIBS="$LIBS"
296 CC="$TARGET_CC"
297 CFLAGS="$TARGET_CFLAGS"
298 CPPFLAGS="$TARGET_CPPFLAGS"
299 LDFLAGS="$TARGET_LDFLAGS"
300 LIBS=""
302 # debug flags.
303 TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
304                -Wundef -Wstrict-prototypes -g"
306 # Force no alignment to save space on i386.
307 if test "x$target_cpu" = xi386; then
308   AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
309     CFLAGS="$CFLAGS -falign-loops=1"
310     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
311         [grub_cv_cc_falign_loop=yes],
312         [grub_cv_cc_falign_loop=no])
313   ])
315   if test "x$grub_cv_cc_falign_loop" = xyes; then
316     TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
317   else
318     TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
319   fi
321   # Some toolchains enable these features by default, but they need
322   # registers that aren't set up properly in GRUB.
323   TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
326 # By default, GCC 4.4 generates .eh_frame sections containing unwind
327 # information in some cases where it previously did not. GRUB doesn't need
328 # these and they just use up vital space. Restore the old compiler
329 # behaviour.
330 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
331   SAVE_CFLAGS="$CFLAGS"
332   CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
333   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
334       [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
335       [grub_cv_cc_fno_dwarf2_cfi_asm=no])
336   CFLAGS="$SAVE_CFLAGS"
339 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
340   TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
343 grub_apple_target_cc
344 if test x$grub_cv_apple_target_cc = xyes ; then
345   TARGET_CFLAGS="$TARGET_CFLAGS -DAPPLE_CC=1 -fnested-functions"
346   CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
347   TARGET_ASFLAGS="$TARGET_ASFLAGS -DAPPLE_CC=1"
348   TARGET_APPLE_CC=1
349   AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
350   if test "x$OBJCONV" = x ; then
351      AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
352   fi
353   if test "x$OBJCONV" = x ; then
354     AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
355   fi
356   TARGET_IMG_LDSCRIPT=
357   TARGET_IMG_CFLAGS="-static"
358   TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
359   TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
360 else
361   TARGET_APPLE_CC=0
362 # Use linker script if present, otherwise use builtin -N script.
363 if test -f "${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
364   TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
365   TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}  -Wl,-Ttext,"
366   TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc  -Wl,-Ttext,"
367 else
368   TARGET_IMG_LDSCRIPT=
369   TARGET_IMG_LDFLAGS='-Wl,-N  -Wl,-Ttext,'
370   TARGET_IMG_LDFLAGS_AC='-Wl,-N  -Wl,-Ttext,'
372 TARGET_IMG_CFLAGS=
375 AC_SUBST(TARGET_IMG_LDSCRIPT)
376 AC_SUBST(TARGET_IMG_LDFLAGS)
377 AC_SUBST(TARGET_IMG_CFLAGS)
379 # For platforms where ELF is not the default link format.
380 AC_MSG_CHECKING([for command to convert module to ELF format])
381 case "${host_os}" in
382   cygwin) TARGET_OBJ2ELF='grub-pe2elf';
383 # FIXME: put proper test here
384   AC_DEFINE([NEED_REGISTER_FRAME_INFO], 1,
385             [Define to 1 if GCC generates calls to __register_frame_info()])
386   ;;
387   *) ;;
388 esac
389 AC_SUBST(TARGET_OBJ2ELF)
390 AC_MSG_RESULT([$TARGET_OBJ2ELF])
393 if test "x$target_m32" = x1; then
394   # Force 32-bit mode.
395   TARGET_CFLAGS="$TARGET_CFLAGS -m32"
396   TARGET_ASFLAGS="$TARGET_CFLAGS -m32"
397   TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
398   TARGET_MODULE_FORMAT="elf32"
401 if test "x$target_m64" = x1; then
402   # Force 64-bit mode.
403   TARGET_CFLAGS="$TARGET_CFLAGS -m64"
404   TARGET_ASFLAGS="$TARGET_ASFLAGS -m64"
405   TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
406   TARGET_MODULE_FORMAT="elf64"
409 if test "$target_cpu"-"$platform" = x86_64-efi; then
410   # Use large model to support 4G memory
411   AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
412     SAVED_CFLAGS=$CFLAGS
413     CFLAGS="$CFLAGS -m64 -mcmodel=large"
414     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
415                       [grub_cv_cc_mcmodel=yes],
416                       [grub_cv_cc_mcmodel=no])
417   ])
418   if test "x$grub_cv_cc_mcmodel" = xno; then
419     AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
420   else
421     TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
422   fi
424   # EFI writes to stack below %rsp, we must not use the red zone
425   AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
426     CFLAGS="$CFLAGS -m64 -mno-red-zone"
427     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
428                       [grub_cv_cc_no_red_zone=yes],
429                       [grub_cv_cc_no_red_zone=no])
430   ])
431   if test "x$grub_cv_cc_no_red_zone" = xno; then
432     AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
433   fi
435   TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
439 # Compiler features.
442 # Need __enable_execute_stack() for nested function trampolines?
443 grub_CHECK_ENABLE_EXECUTE_STACK
445 # Position independent executable.
446 grub_CHECK_PIE
447 [# Need that, because some distributions ship compilers that include
448 # `-fPIE' in the default specs.
449 if [ x"$pie_possible" = xyes ]; then
450   TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
453 # Smashing stack protector.
454 grub_CHECK_STACK_PROTECTOR
455 # Need that, because some distributions ship compilers that include
456 # `-fstack-protector' in the default specs.
457 if test "x$ssp_possible" = xyes; then
458   TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
460 grub_CHECK_STACK_ARG_PROBE
461 # Cygwin's GCC uses alloca() to probe the stackframe on static
462 # stack allocations above some threshold.
463 if test x"$sap_possible" = xyes; then
464   TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
467 AC_ARG_ENABLE([werror],
468               [AS_HELP_STRING([--disable-werror],
469                              [do not use -Werror when building GRUB])])
470 if test x"$enable_werror" != xno ; then
471   TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
474 AC_SUBST(TARGET_CFLAGS)
475 AC_SUBST(TARGET_MODULE_FORMAT)
476 AC_SUBST(OBJCONV)
477 AC_SUBST(TARGET_APPLE_CC)
478 AC_SUBST(TARGET_ASFLAGS)
479 AC_SUBST(TARGET_CPPFLAGS)
480 AC_SUBST(TARGET_LDFLAGS)
482 # Set them to their new values for the tests below.
483 CC="$TARGET_CC"
484 if test "x$TARGET_APPLE_CC" = x1 ; then
485 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
486 else
487 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
489 CPPFLAGS="$TARGET_CPPFLAGS"
490 LDFLAGS="$TARGET_LDFLAGS"
491 LIBS=-lgcc
493 grub_ASM_USCORE
494 if test x$grub_cv_asm_uscore = xyes; then
495 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
496 else
497 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
500 # Check for libgcc symbols
501 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
503 if test "x$TARGET_APPLE_CC" = x1 ; then
504 CFLAGS="$TARGET_CFLAGS -nostdlib"
505 else
506 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
508 LIBS=""
510 # Defined in aclocal.m4.
511 grub_PROG_TARGET_CC
512 if test "x$TARGET_APPLE_CC" != x1 ; then
513 grub_PROG_OBJCOPY_ABSOLUTE
515 grub_PROG_LD_BUILD_ID_NONE
516 if test "x$target_cpu" = xi386; then
517   if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
518     if test ! -z "$TARGET_IMG_LDSCRIPT"; then
519       # Check symbols provided by linker script.
520       CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC}8000 -Wl,--defsym,___main=0x8100"
521     fi
522     grub_CHECK_BSS_START_SYMBOL
523     grub_CHECK_END_SYMBOL
524   fi
525   CFLAGS="$TARGET_CFLAGS"
526   grub_I386_ASM_PREFIX_REQUIREMENT
527   grub_I386_ASM_ADDR32
528   grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
529 else
530   AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
533 AH_BOTTOM([#if defined(__i386__) && !defined(GRUB_UTIL)
534 #define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1)))
535 #else
536 #define NESTED_FUNC_ATTR
537 #endif])
539 AC_ARG_ENABLE([efiemu],
540               [AS_HELP_STRING([--enable-efiemu],
541                              [build and install the efiemu runtimes (default=guessed)])])
542 if test x"$enable_efiemu" = xno ; then
543   efiemu_excuse="explicitly disabled"
545 if test x"$efiemu_excuse" = x ; then
546   AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
547     CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
548     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
549                       [grub_cv_cc_efiemu=yes],
550                       [grub_cv_cc_efiemu=no])
551   ])
552   if test x$grub_cv_cc_efiemu = xno; then
553      efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
554   fi
556 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
557   AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
559 if test x"$efiemu_excuse" = x ; then
560 enable_efiemu=yes
561 else
562 enable_efiemu=no
564 AC_SUBST([enable_efiemu])
566 if test "$platform" != emu; then
567 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
568   SAVED_CPPFLAGS="$CPPFLAGS"
569   CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
570   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
571 int va_arg_func (int fixed, va_list args);]], [[]])],
572       [grub_cv_cc_isystem=yes],
573       [grub_cv_cc_isystem=no])
574   CPPFLAGS="$SAVED_CPPFLAGS"
577 if test x"$grub_cv_cc_isystem" = xyes ; then
578   TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
582 # Restore the flags.
583 CC="$tmp_CC"
584 CFLAGS="$tmp_CFLAGS"
585 CPPFLAGS="$tmp_CPPFLAGS"
586 LDFLAGS="$tmp_LDFLAGS"
587 LIBS="$tmp_LIBS"
590 # Check for options.
593 # Memory manager debugging.
594 AC_ARG_ENABLE([mm-debug],
595               AS_HELP_STRING([--enable-mm-debug],
596                              [include memory manager debugging]),
597               [AC_DEFINE([MM_DEBUG], [1],
598                          [Define to 1 if you enable memory manager debugging.])])
600 AC_ARG_ENABLE([grub-emu-usb],
601               [AS_HELP_STRING([--enable-grub-emu-usb],
602                              [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
604 AC_ARG_ENABLE([grub-emu-sdl],
605               [AS_HELP_STRING([--enable-grub-emu-sdl],
606                              [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
608 AC_ARG_ENABLE([grub-emu-pci],
609               [AS_HELP_STRING([--enable-grub-emu-pci],
610                              [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
612 AC_ARG_ENABLE([grub-emu-modules],
613               [AS_HELP_STRING([--enable-grub-emu-modules],
614                              [Support module loading in `grub-emu' debugging utility (default=no)])])
616 if test "$platform" = emu; then
617   missing_ncurses=
618 [# Check for curses libraries.]
619   AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
620     [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
621       [missing_ncurses=[true]])])
622   AC_SUBST([LIBCURSES])
623 [if [ x"$missing_ncurses" = x ]; then ]
624   [# Check for headers.]
625   AC_CHECK_HEADERS([ncurses/curses.h], [],
626     [AC_CHECK_HEADERS([ncurses.h], [],
627       [AC_CHECK_HEADERS([curses.h], [],
628         [missing_ncurses=[true]])])])
629 [fi]
630 if test x"$missing_ncurses" = xtrue ; then
631   AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
634 if test x"$enable_grub_emu_modules" = xyes ; then
635   TARGET_NO_MODULES=no
636 else
637   TARGET_NO_MODULES=yes
639 AC_SUBST(TARGET_NO_MODULES)
641 if test "$TARGET_NO_MODULES" = yes ; then
642   # Do not convert modules, otherwise linkage may fail (Cygwin only).
643   # FIXME: Should be checked above before TARGET_OBJ2ELF is set first.
644   TARGET_OBJ2ELF=
647 if test x"$enable_grub_emu_usb" = xno ; then
648   grub_emu_usb_excuse="explicitly disabled"
651 if test x"$enable_grub_emu_pci" = xyes ; then
652    grub_emu_usb_excuse="conflicts with PCI support"
655 [if [ x"$grub_emu_usb_excuse" = x ]; then
656     # Check for libusb libraries.]
657 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
658     [grub_emu_usb_excuse=["need libusb library"]])
659     AC_SUBST([LIBUSB])
660 [fi]
661 [if [ x"$grub_emu_usb_excuse" = x ]; then
662     # Check for headers.]
663     AC_CHECK_HEADERS([usb.h], [],
664       [grub_emu_usb_excuse=["need libusb headers"]])
665 [fi]
666 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
667   AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
669 if test x"$grub_emu_usb_excuse" = x ; then
670 enable_grub_emu_usb=yes
671 else
672 enable_grub_emu_usb=no
675 if test x"$enable_grub_emu_sdl" = xno ; then
676   grub_emu_sdl_excuse="explicitely disabled"
678 [if [ x"$grub_emu_sdl_excuse" = x ]; then
679     # Check for libSDL libraries.]
680 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
681     [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
682     AC_SUBST([LIBSDL])
683 [fi]
685 [if [ x"$grub_emu_sdl_excuse" = x ]; then
686     # Check for headers.]
687     AC_CHECK_HEADERS([SDL/SDL.h], [],
688       [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
689 [fi]
691 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
692   AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
694 if test x"$grub_emu_sdl_excuse" = x ; then
695 enable_grub_emu_sdl=yes
696 else
697 enable_grub_emu_sdl=no
700 if test x"$enable_grub_emu_pci" != xyes ; then
701    grub_emu_pci_excuse="not enabled"
704 if test x"$enable_grub_emu_usb" = xyes ; then
705    grub_emu_pci_excuse="conflicts with USB support"
708 [if [ x"$grub_emu_pci_excuse" = x ]; then
709       # Check for libpci libraries.]
710    AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
711       [grub_emu_pci_excuse=["need libpciaccess library"]])
712     AC_SUBST([LIBPCIACCESS])
713 [fi]
714 [if [ x"$grub_emu_pci_excuse" = x ]; then
715     # Check for headers.]
716     AC_CHECK_HEADERS([pci/pci.h], [],
717       [grub_emu_pci_excuse=["need libpciaccess headers"]])
718 [fi]
720 if test x"$grub_emu_pci_excuse" = x ; then
721 enable_grub_emu_pci=yes
722 else
724 enable_grub_emu_pci=no
727 AC_SUBST([enable_grub_emu_sdl])
728 AC_SUBST([enable_grub_emu_usb])
729 AC_SUBST([enable_grub_emu_pci])
732 AC_ARG_ENABLE([grub-fstest],
733               [AS_HELP_STRING([--enable-grub-fstest],
734                              [build and install the `grub-fstest' debugging utility (default=guessed)])])
735 if test x"$enable_grub_fstest" = xno ; then
736   grub_fstest_excuse="explicitly disabled"
738 if test x"$grub_fstest_excuse" = x ; then
739 enable_grub_fstest=yes
740 else
741 enable_grub_fstest=no
743 AC_SUBST([enable_grub_fstest])
745 AC_ARG_ENABLE([grub-mkfont],
746               [AS_HELP_STRING([--enable-grub-mkfont],
747                              [build and install the `grub-mkfont' utility (default=guessed)])])
748 if test x"$enable_grub_mkfont" = xno ; then
749   grub_mkfont_excuse="explicitly disabled"
752 if test x"$grub_mkfont_excuse" = x ; then
753   # Check for freetype libraries.
754   AC_CHECK_PROGS([FREETYPE], [freetype-config])
755   if test "x$FREETYPE" = x ; then
756     grub_mkfont_excuse=["need freetype2 library"]
757   fi
758   freetype_cflags=`freetype-config --cflags`
759   freetype_libs=`freetype-config --libs`
762 if test x"$grub_mkfont_excuse" = x ; then
763   # Check for freetype libraries.
764   SAVED_CPPFLAGS="$CPPFLAGS"
765   CPPFLAGS="$CPPFLAGS $freetype_cflags"
766   AC_CHECK_HEADERS([ft2build.h], [],
767         [grub_mkfont_excuse=["need freetype2 headers"]])
768   CPPFLAGS="$SAVED_CPPFLAGS"
771 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
772   AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
774 if test x"$grub_mkfont_excuse" = x ; then
775 enable_grub_mkfont=yes
776 else
777 enable_grub_mkfont=no
779 AC_SUBST([enable_grub_mkfont])
780 AC_SUBST([freetype_cflags])
781 AC_SUBST([freetype_libs])
783 AC_ARG_ENABLE([device-mapper],
784               [AS_HELP_STRING([--enable-device-mapper],
785                               [enable Linux device-mapper support (default=guessed)])])
786 if test x"$enable_device_mapper" = xno ; then
787   device_mapper_excuse="explicitly disabled"
790 if test x"$device_mapper_excuse" = x ; then
791   # Check for device-mapper library.
792   AC_CHECK_LIB([devmapper], [dm_task_create],
793                [LDFLAGS="$LDFLAGS -ldevmapper"
794                 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
795                           [Define to 1 if you have the devmapper library.])],
796                [device_mapper_excuse="need devmapper library"])
799 AC_SUBST(ASFLAGS)
801 # Output files.
802 grub_CHECK_LINK_DIR
803 if test x"$link_dir" = xyes ; then
804   AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu])
805   if test "$platform" != emu ; then
806     AC_CONFIG_LINKS([include/grub/machine:include/grub/$target_cpu/$platform])
807   fi
808 else
809   mkdir -p include/grub 2>/dev/null
810   rm -rf include/grub/cpu
811   cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null
812   if test "$platform" != emu ; then
813     rm -rf include/grub/machine
814     cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
815   fi
817 AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
818 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
819 AC_OUTPUT
821 echo "*******************************************************"
822 echo GRUB2 will be compiled with following components:
823 echo Platform: "$target_cpu"-"$platform"
824 if [ x"$platform" = xemu ]; then
825 if [ x"$grub_emu_usb_excuse" = x ]; then
826 echo USB support for grub-emu: Yes
827 else
828 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
830 if [ x"$grub_emu_sdl_excuse" = x ]; then
831 echo SDL support for grub-emu: Yes
832 else
833 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
835 if [ x"$grub_emu_pci_excuse" = x ]; then
836 echo PCI support for grub-emu: Yes
837 else
838 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
840 if [ x"$TARGET_NO_MODULES" = xno ]; then
841 echo Module support for grub-emu: Yes
842 else
843 echo Module support for grub-emu: No
846 if [ x"$enable_mm_debug" = xyes ]; then
847 echo With memory debugging: Yes
848 else
849 echo With memory debugging: No
851 if [ x"$efiemu_excuse" = x ]; then
852 echo efiemu runtime: Yes
853 else
854 echo efiemu runtime: No "($efiemu_excuse)"
856 if [ x"$grub_fstest_excuse" = x ]; then
857 echo grub-fstest: Yes
858 else
859 echo grub-fstest: No "($grub_fstest_excuse)"
861 if [ x"$grub_mkfont_excuse" = x ]; then
862 echo grub-mkfont: Yes
863 else
864 echo grub-mkfont: No "($grub_mkfont_excuse)"
866 echo "*******************************************************"