]> git.proxmox.com Git - grub2.git/blob - configure.ac
grub-emu module load support.
[grub2.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2
3 # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
4 #
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.
8 #
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.
13
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.
32
33
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])
39
40 # Checks for host and target systems.
41 AC_CANONICAL_HOST
42 AC_CANONICAL_TARGET
43
44 # Program name transformations
45 AC_ARG_PROGRAM
46
47 # Optimization flag. Allow user to override.
48 if test "x$TARGET_CFLAGS" = x; then
49 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
50 fi
51
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
67
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]]]))
72
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"
88 fi
89
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
98 fi
99
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-coreboot) ;;
106 i386-linuxbios) platform=coreboot ;;
107 i386-ieee1275) ;;
108 i386-qemu) ;;
109 powerpc-ieee1275) ;;
110 sparc64-ieee1275) ;;
111 mips-qemu-mips) ;;
112 mips-yeeloong) ;;
113 *-emu) ;;
114 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
115 esac
116
117 case "$target_cpu" in
118 i386 | powerpc) target_m32=1 ;;
119 x86_64 | sparc64) target_m64=1 ;;
120 esac
121
122 case "$host_os" in
123 mingw32*) host_os=cygwin ;;
124 esac
125
126 # This normalizes the names, and creates a new variable ("host_kernel")
127 # while at it, since the mapping is not always 1:1 (e.g. different OSes
128 # using the same kernel type).
129 case "$host_os" in
130 gnu*) host_kernel=hurd ;;
131 linux*) host_kernel=linux ;;
132 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
133 cygwin) host_kernel=windows ;;
134 esac
135
136 case "$platform" in
137 coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
138 efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
139 ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
140 qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
141 pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
142 emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
143 yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
144 qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
145 esac
146 case "$target_cpu" in
147 mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
148 sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
149 esac
150
151 CFLAGS="$CFLAGS $machine_CFLAGS"
152 TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
153 TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
154
155 AC_SUBST(host_cpu)
156 AC_SUBST(host_os)
157 AC_SUBST(host_kernel)
158
159 AC_SUBST(target_cpu)
160 AC_SUBST(platform)
161
162 #
163 # Checks for build programs.
164 #
165
166 # Although cmp is listed in the GNU Coding Standards as a command which
167 # can used directly, OpenBSD lacks cmp in the default installation.
168 AC_CHECK_PROGS([CMP], [cmp])
169 if test "x$CMP" = x; then
170 AC_MSG_ERROR([cmp is not found])
171 fi
172
173 AC_CHECK_PROGS([LEX], [flex])
174 if test "x$LEX" = x; then
175 AC_MSG_ERROR([flex is not found])
176 fi
177
178 AC_CHECK_PROGS([YACC], [bison])
179 if test "x$YACC" = x; then
180 AC_MSG_ERROR([bison is not found])
181 fi
182
183 for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz /usr/share/fonts/unifont/unifont.pcf.gz; do
184 if test -e $file ; then
185 AC_SUBST([FONT_SOURCE], [$file])
186 break
187 fi
188 done
189
190 AC_PROG_INSTALL
191 AC_PROG_AWK
192 AC_PROG_MAKE_SET
193 AC_PROG_MKDIR_P
194
195 # These are not a "must".
196 AC_PATH_PROG(RUBY, ruby)
197 AC_PATH_PROG(MAKEINFO, makeinfo)
198
199 #
200 # Checks for host programs.
201 #
202
203 AC_PROG_CC
204 # Must be GCC.
205 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
206
207 AC_GNU_SOURCE
208 AM_GNU_GETTEXT([external])
209 AC_SYS_LARGEFILE
210
211 # Identify characteristics of the host architecture.
212 AC_C_BIGENDIAN
213 AC_CHECK_SIZEOF(void *)
214 AC_CHECK_SIZEOF(long)
215
216 grub_apple_cc
217 if test x$grub_cv_apple_cc = xyes ; then
218 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
219 ASFLAGS="$ASFLAGS -DAPPLE_CC=1"
220 fi
221
222 if test "x$cross_compiling" = xyes; then
223 AC_MSG_WARN([cannot generate manual pages while cross compiling])
224 else
225 AC_PATH_PROG(HELP2MAN, help2man)
226 fi
227
228 # Check for functions.
229 AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf)
230
231 # For grub-mkisofs
232 AC_HEADER_MAJOR
233 AC_HEADER_DIRENT
234 AC_CHECK_FUNCS(memmove sbrk strdup lstat getuid getgid)
235 AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h)
236 AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h limits.h)
237
238 #
239 # Check for target programs.
240 #
241
242 # Find tools for the target.
243 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
244 tmp_ac_tool_prefix="$ac_tool_prefix"
245 ac_tool_prefix=$target_alias-
246
247 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
248 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
249 AC_CHECK_TOOL(OBJCOPY, objcopy)
250 AC_CHECK_TOOL(STRIP, strip)
251 AC_CHECK_TOOL(NM, nm)
252
253 ac_tool_prefix="$tmp_ac_tool_prefix"
254 else
255 if test "x$TARGET_CC" = x; then
256 TARGET_CC=$CC
257 fi
258 AC_CHECK_TOOL(OBJCOPY, objcopy)
259 AC_CHECK_TOOL(STRIP, strip)
260 AC_CHECK_TOOL(NM, nm)
261 fi
262 AC_SUBST(TARGET_CC)
263
264
265 # Test the C compiler for the target environment.
266 tmp_CC="$CC"
267 tmp_CFLAGS="$CFLAGS"
268 tmp_LDFLAGS="$LDFLAGS"
269 tmp_CPPFLAGS="$CPPFLAGS"
270 tmp_LIBS="$LIBS"
271 CC="$TARGET_CC"
272 CFLAGS="$TARGET_CFLAGS"
273 CPPFLAGS="$TARGET_CPPFLAGS"
274 LDFLAGS="$TARGET_LDFLAGS"
275 LIBS=""
276
277 # debug flags.
278 TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
279 -Wundef -Wstrict-prototypes -g"
280
281 # Force no alignment to save space on i386.
282 if test "x$target_cpu" = xi386; then
283 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
284 CFLAGS="$CFLAGS -falign-loops=1"
285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
286 [grub_cv_cc_falign_loop=yes],
287 [grub_cv_cc_falign_loop=no])
288 ])
289
290 if test "x$grub_cv_cc_falign_loop" = xyes; then
291 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
292 else
293 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
294 fi
295
296 # Some toolchains enable these features by default, but they need
297 # registers that aren't set up properly in GRUB.
298 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
299 fi
300
301 # By default, GCC 4.4 generates .eh_frame sections containing unwind
302 # information in some cases where it previously did not. GRUB doesn't need
303 # these and they just use up vital space. Restore the old compiler
304 # behaviour.
305 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
306 SAVE_CFLAGS="$CFLAGS"
307 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
308 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
309 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
310 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
311 CFLAGS="$SAVE_CFLAGS"
312 ])
313
314 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
315 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
316 fi
317
318 grub_apple_target_cc
319 if test x$grub_cv_apple_target_cc = xyes ; then
320 TARGET_CFLAGS="$TARGET_CFLAGS -DAPPLE_CC=1 -fnested-functions"
321 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
322 TARGET_ASFLAGS="$TARGET_ASFLAGS -DAPPLE_CC=1"
323 TARGET_APPLE_CC=1
324 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
325 if test "x$OBJCONV" = x ; then
326 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
327 fi
328 if test "x$OBJCONV" = x ; then
329 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
330 fi
331 TARGET_IMG_LDSCRIPT=
332 TARGET_IMG_CFLAGS="-static"
333 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
334 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
335 else
336 TARGET_APPLE_CC=0
337 # Use linker script if present, otherwise use builtin -N script.
338 if test -f "${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
339 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
340 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT} -Wl,-Ttext,"
341 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
342 else
343 TARGET_IMG_LDSCRIPT=
344 TARGET_IMG_LDFLAGS='-Wl,-N -Wl,-Ttext,'
345 TARGET_IMG_LDFLAGS_AC='-Wl,-N -Wl,-Ttext,'
346 fi
347 TARGET_IMG_CFLAGS=
348 fi
349
350 AC_SUBST(TARGET_IMG_LDSCRIPT)
351 AC_SUBST(TARGET_IMG_LDFLAGS)
352 AC_SUBST(TARGET_IMG_CFLAGS)
353
354 # For platforms where ELF is not the default link format.
355 AC_MSG_CHECKING([for command to convert module to ELF format])
356 case "${host_os}" in
357 cygwin) TARGET_OBJ2ELF='grub-pe2elf' ;;
358 *) ;;
359 esac
360 AC_SUBST(TARGET_OBJ2ELF)
361 AC_MSG_RESULT([$TARGET_OBJ2ELF])
362
363
364 if test "x$target_m32" = x1; then
365 # Force 32-bit mode.
366 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
367 TARGET_ASFLAGS="$TARGET_CFLAGS -m32"
368 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
369 TARGET_MODULE_FORMAT="elf32"
370 fi
371
372 if test "x$target_m64" = x1; then
373 # Force 64-bit mode.
374 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
375 TARGET_ASFLAGS="$TARGET_ASFLAGS -m64"
376 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
377 TARGET_MODULE_FORMAT="elf64"
378 fi
379
380 if test "$target_cpu"-"$platform" = x86_64-efi; then
381 # Use large model to support 4G memory
382 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
383 SAVED_CFLAGS=$CFLAGS
384 CFLAGS="$CFLAGS -m64 -mcmodel=large"
385 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
386 [grub_cv_cc_mcmodel=yes],
387 [grub_cv_cc_mcmodel=no])
388 ])
389 if test "x$grub_cv_cc_mcmodel" = xno; then
390 CFLAGS="$SAVED_CFLAGS -m64 -DMCMODEL_SMALL=1"
391 TARGET_CFLAGS="$TARGET_CFLAGS -DMCMODEL_SMALL=1"
392 AC_MSG_WARN([-mcmodel=large not supported. You won't be able to use the memory over 4GiB. Upgrade your gcc])
393 else
394 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
395 fi
396
397 # EFI writes to stack below %rsp, we must not use the red zone
398 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
399 CFLAGS="$CFLAGS -m64 -mno-red-zone"
400 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
401 [grub_cv_cc_no_red_zone=yes],
402 [grub_cv_cc_no_red_zone=no])
403 ])
404 if test "x$grub_cv_cc_no_red_zone" = xno; then
405 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
406 fi
407
408 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
409 fi
410
411 #
412 # Compiler features.
413 #
414
415 # Need __enable_execute_stack() for nested function trampolines?
416 grub_CHECK_ENABLE_EXECUTE_STACK
417
418 # Position independent executable.
419 grub_CHECK_PIE
420 [# Need that, because some distributions ship compilers that include
421 # `-fPIE' in the default specs.
422 if [ x"$pie_possible" = xyes ]; then
423 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
424 fi]
425
426 # Smashing stack protector.
427 grub_CHECK_STACK_PROTECTOR
428 # Need that, because some distributions ship compilers that include
429 # `-fstack-protector' in the default specs.
430 if test "x$ssp_possible" = xyes; then
431 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
432 fi
433 grub_CHECK_STACK_ARG_PROBE
434 # Cygwin's GCC uses alloca() to probe the stackframe on static
435 # stack allocations above some threshold.
436 if test x"$sap_possible" = xyes; then
437 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
438 fi
439
440 AC_ARG_ENABLE([werror],
441 [AS_HELP_STRING([--disable-werror],
442 [do not use -Werror when building GRUB])])
443 if test x"$enable_werror" != xno ; then
444 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
445 fi
446
447 AC_SUBST(TARGET_CFLAGS)
448 AC_SUBST(TARGET_MODULE_FORMAT)
449 AC_SUBST(OBJCONV)
450 AC_SUBST(TARGET_APPLE_CC)
451 AC_SUBST(TARGET_ASFLAGS)
452 AC_SUBST(TARGET_CPPFLAGS)
453 AC_SUBST(TARGET_LDFLAGS)
454
455 # Set them to their new values for the tests below.
456 CC="$TARGET_CC"
457 if test "x$TARGET_APPLE_CC" = x1 ; then
458 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
459 else
460 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wl,--defsym,abort=main -Wno-error"
461 fi
462 CPPFLAGS="$TARGET_CPPFLAGS"
463 LDFLAGS="$TARGET_LDFLAGS"
464 LIBS=-lgcc
465
466 # Check for libgcc symbols
467 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
468
469 if test "x$TARGET_APPLE_CC" = x1 ; then
470 CFLAGS="$TARGET_CFLAGS -nostdlib"
471 else
472 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
473 fi
474 LIBS=""
475
476 # Defined in aclocal.m4.
477 grub_PROG_TARGET_CC
478 if test "x$TARGET_APPLE_CC" != x1 ; then
479 grub_PROG_OBJCOPY_ABSOLUTE
480 fi
481 grub_PROG_LD_BUILD_ID_NONE
482 grub_ASM_USCORE
483 if test "x$target_cpu" = xi386; then
484 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
485 # Check symbols provided by linker script.
486 CFLAGS="$TARGET_CFLAGS -nostdlib $TARGET_IMG_LDFLAGS_AC -Wl,-Ttext,8000,--defsym,___main=0x8100"
487 fi
488 if test "x$TARGET_APPLE_CC" != x1 ; then
489 grub_CHECK_BSS_START_SYMBOL
490 grub_CHECK_END_SYMBOL
491 fi
492 CFLAGS="$TARGET_CFLAGS"
493 grub_I386_ASM_PREFIX_REQUIREMENT
494 grub_I386_ASM_ADDR32
495 grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
496 else
497 AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
498 fi
499
500 AH_BOTTOM([#if defined(__i386__) && !defined(GRUB_UTIL)
501 #define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1)))
502 #else
503 #define NESTED_FUNC_ATTR
504 #endif])
505
506 AC_ARG_ENABLE([efiemu],
507 [AS_HELP_STRING([--enable-efiemu],
508 [build and install the efiemu runtimes (default=guessed)])])
509 if test x"$enable_efiemu" = xno ; then
510 efiemu_excuse="explicitly disabled"
511 fi
512 if test x"$efiemu_excuse" = x ; then
513 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
514 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
515 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
516 [grub_cv_cc_efiemu=yes],
517 [grub_cv_cc_efiemu=no])
518 ])
519 if test x$grub_cv_cc_efiemu = xno; then
520 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
521 fi
522 fi
523 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
524 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
525 fi
526 if test x"$efiemu_excuse" = x ; then
527 enable_efiemu=yes
528 else
529 enable_efiemu=no
530 fi
531 AC_SUBST([enable_efiemu])
532
533 if test "$platform" != emu; then
534 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
535 SAVED_CPPFLAGS="$CPPFLAGS"
536 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
537 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
538 int va_arg_func (int fixed, va_list args);]], [[]])],
539 [grub_cv_cc_isystem=yes],
540 [grub_cv_cc_isystem=no])
541 CPPFLAGS="$SAVED_CPPFLAGS"
542 ])
543
544 if test x"$grub_cv_cc_isystem" = xyes ; then
545 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
546 fi
547 fi
548
549 # Restore the flags.
550 CC="$tmp_CC"
551 CFLAGS="$tmp_CFLAGS"
552 CPPFLAGS="$tmp_CPPFLAGS"
553 LDFLAGS="$tmp_LDFLAGS"
554 LIBS="$tmp_LIBS"
555
556 #
557 # Check for options.
558 #
559
560 # Memory manager debugging.
561 AC_ARG_ENABLE([mm-debug],
562 AS_HELP_STRING([--enable-mm-debug],
563 [include memory manager debugging]),
564 [AC_DEFINE([MM_DEBUG], [1],
565 [Define to 1 if you enable memory manager debugging.])])
566
567 AC_ARG_ENABLE([grub-emu-usb],
568 [AS_HELP_STRING([--enable-grub-emu-usb],
569 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
570
571 AC_ARG_ENABLE([grub-emu-sdl],
572 [AS_HELP_STRING([--enable-grub-emu-sdl],
573 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
574
575 AC_ARG_ENABLE([grub-emu-pci],
576 [AS_HELP_STRING([--enable-grub-emu-pci],
577 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
578
579 AC_ARG_ENABLE([grub-emu-modules],
580 [AS_HELP_STRING([--enable-grub-emu-modules],
581 [Support module loading in `grub-emu' debugging utility (default=no)])])
582
583 if test "$platform" = emu; then
584 missing_ncurses=
585 [# Check for curses libraries.]
586 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
587 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
588 [missing_ncurses=[true]])])
589 AC_SUBST([LIBCURSES])
590 [if [ x"$missing_ncurses" = x ]; then ]
591 [# Check for headers.]
592 AC_CHECK_HEADERS([ncurses/curses.h], [],
593 [AC_CHECK_HEADERS([ncurses.h], [],
594 [AC_CHECK_HEADERS([curses.h], [],
595 [missing_ncurses=[true]])])])
596 [fi]
597 if test x"$missing_ncurses" = xtrue ; then
598 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
599 fi
600
601 if test x"$enable_grub_emu_modules" = xyes ; then
602 TARGET_NO_MODULES=no
603 else
604 TARGET_NO_MODULES=yes
605 fi
606 AC_SUBST(TARGET_NO_MODULES)
607
608 if test x"$enable_grub_emu_usb" = xno ; then
609 grub_emu_usb_excuse="explicitly disabled"
610 fi
611
612 if test x"$enable_grub_emu_pci" = xyes ; then
613 grub_emu_usb_excuse="conflicts with PCI support"
614 fi
615
616 [if [ x"$grub_emu_usb_excuse" = x ]; then
617 # Check for libusb libraries.]
618 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
619 [grub_emu_usb_excuse=["need libusb library"]])
620 AC_SUBST([LIBUSB])
621 [fi]
622 [if [ x"$grub_emu_usb_excuse" = x ]; then
623 # Check for headers.]
624 AC_CHECK_HEADERS([usb.h], [],
625 [grub_emu_usb_excuse=["need libusb headers"]])
626 [fi]
627 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
628 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
629 fi
630 if test x"$grub_emu_usb_excuse" = x ; then
631 enable_grub_emu_usb=yes
632 else
633 enable_grub_emu_usb=no
634 fi
635
636 if test x"$enable_grub_emu_sdl" = xno ; then
637 grub_emu_sdl_excuse="explicitely disabled"
638 fi
639 [if [ x"$grub_emu_sdl_excuse" = x ]; then
640 # Check for libSDL libraries.]
641 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
642 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
643 AC_SUBST([LIBSDL])
644 [fi]
645
646 [if [ x"$grub_emu_sdl_excuse" = x ]; then
647 # Check for headers.]
648 AC_CHECK_HEADERS([SDL/SDL.h], [],
649 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
650 [fi]
651
652 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
653 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
654 fi
655 if test x"$grub_emu_sdl_excuse" = x ; then
656 enable_grub_emu_sdl=yes
657 else
658 enable_grub_emu_sdl=no
659 fi
660
661 if test x"$enable_grub_emu_pci" != xyes ; then
662 grub_emu_pci_excuse="not enabled"
663 fi
664
665 if test x"$enable_grub_emu_usb" = xyes ; then
666 grub_emu_pci_excuse="conflicts with USB support"
667 fi
668
669 [if [ x"$grub_emu_pci_excuse" = x ]; then
670 # Check for libpci libraries.]
671 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
672 [grub_emu_pci_excuse=["need libpciaccess library"]])
673 AC_SUBST([LIBPCIACCESS])
674 [fi]
675 [if [ x"$grub_emu_pci_excuse" = x ]; then
676 # Check for headers.]
677 AC_CHECK_HEADERS([pci/pci.h], [],
678 [grub_emu_pci_excuse=["need libpciaccess headers"]])
679 [fi]
680
681 if test x"$grub_emu_pci_excuse" = x ; then
682 enable_grub_emu_pci=yes
683 else
684
685 enable_grub_emu_pci=no
686 fi
687
688 AC_SUBST([enable_grub_emu_sdl])
689 AC_SUBST([enable_grub_emu_usb])
690 AC_SUBST([enable_grub_emu_pci])
691 fi
692
693 AC_ARG_ENABLE([grub-fstest],
694 [AS_HELP_STRING([--enable-grub-fstest],
695 [build and install the `grub-fstest' debugging utility (default=guessed)])])
696 if test x"$enable_grub_fstest" = xno ; then
697 grub_fstest_excuse="explicitly disabled"
698 fi
699 if test x"$grub_fstest_excuse" = x ; then
700 enable_grub_fstest=yes
701 else
702 enable_grub_fstest=no
703 fi
704 AC_SUBST([enable_grub_fstest])
705
706 AC_ARG_ENABLE([grub-mkfont],
707 [AS_HELP_STRING([--enable-grub-mkfont],
708 [build and install the `grub-mkfont' utility (default=guessed)])])
709 if test x"$enable_grub_mkfont" = xno ; then
710 grub_mkfont_excuse="explicitly disabled"
711 fi
712
713 if test x"$grub_mkfont_excuse" = x ; then
714 # Check for freetype libraries.
715 AC_CHECK_PROGS([FREETYPE], [freetype-config])
716 if test "x$FREETYPE" = x ; then
717 grub_mkfont_excuse=["need freetype2 library"]
718 fi
719 freetype_cflags=`freetype-config --cflags`
720 freetype_libs=`freetype-config --libs`
721 fi
722
723 if test x"$grub_mkfont_excuse" = x ; then
724 # Check for freetype libraries.
725 SAVED_CPPFLAGS="$CPPFLAGS"
726 CPPFLAGS="$CPPFLAGS $freetype_cflags"
727 AC_CHECK_HEADERS([ft2build.h], [],
728 [grub_mkfont_excuse=["need freetype2 headers"]])
729 CPPFLAGS="$SAVED_CPPFLAGS"
730 fi
731
732 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
733 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
734 fi
735 if test x"$grub_mkfont_excuse" = x ; then
736 enable_grub_mkfont=yes
737 else
738 enable_grub_mkfont=no
739 fi
740 AC_SUBST([enable_grub_mkfont])
741 AC_SUBST([freetype_cflags])
742 AC_SUBST([freetype_libs])
743
744 AC_SUBST(ASFLAGS)
745
746 # Output files.
747 grub_CHECK_LINK_DIR
748 if test x"$link_dir" = xyes ; then
749 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu])
750 if test "$platform" != emu ; then
751 AC_CONFIG_LINKS([include/grub/machine:include/grub/$target_cpu/$platform])
752 fi
753 else
754 mkdir -p include/grub 2>/dev/null
755 rm -rf include/grub/cpu
756 cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null
757 if test "$platform" != emu ; then
758 rm -rf include/grub/machine
759 cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
760 fi
761 fi
762 AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
763 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
764 AC_OUTPUT
765 [
766 echo "*******************************************************"
767 echo GRUB2 will be compiled with following components:
768 echo Platform: "$target_cpu"-"$platform"
769 if [ x"$platform" = xemu ]; then
770 if [ x"$grub_emu_usb_excuse" = x ]; then
771 echo USB support for grub-emu: Yes
772 else
773 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
774 fi
775 if [ x"$grub_emu_sdl_excuse" = x ]; then
776 echo SDL support for grub-emu: Yes
777 else
778 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
779 fi
780 if [ x"$grub_emu_pci_excuse" = x ]; then
781 echo PCI support for grub-emu: Yes
782 else
783 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
784 fi
785 if [ x"$TARGET_NO_MODULES" = xno ]; then
786 echo Module support for grub-emu: Yes
787 else
788 echo Module support for grub-emu: No
789 fi
790 fi
791 if [ x"$enable_mm_debug" = xyes ]; then
792 echo With memory debugging: Yes
793 else
794 echo With memory debugging: No
795 fi
796 if [ x"$efiemu_excuse" = x ]; then
797 echo efiemu runtime: Yes
798 else
799 echo efiemu runtime: No "($efiemu_excuse)"
800 fi
801 if [ x"$grub_fstest_excuse" = x ]; then
802 echo grub-fstest: Yes
803 else
804 echo grub-fstest: No "($grub_fstest_excuse)"
805 fi
806 if [ x"$grub_mkfont_excuse" = x ]; then
807 echo grub-mkfont: Yes
808 else
809 echo grub-mkfont: No "($grub_mkfont_excuse)"
810 fi
811 echo "*******************************************************"
812 ]