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