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