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