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