]> git.proxmox.com Git - grub2.git/blame - configure.ac
2009-12-06 David S. Miller <davem@sunset.davemloft.net>
[grub2.git] / configure.ac
CommitLineData
6a161fa9 1# Process this file with autoconf to produce a configure script.
2
1e901a75 3# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
6a161fa9 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
b977bf01 14dnl This configure script is complicated, because GRUB needs to deal
15dnl with three potentially different types:
16dnl
17dnl build -- the environment for building GRUB
18dnl host -- the environment for running utilities
19dnl target -- the environment for running GRUB
20dnl
21dnl In addition, GRUB needs to deal with a platform specification
22dnl which specifies the system running GRUB, such as firmware.
23dnl This is necessary because the target type in autoconf does not
24dnl describe such a system very well.
25dnl
26dnl The current strategy is to use variables with no prefix (such as
27dnl CC, CFLAGS, etc.) for the host type as well as the build type,
28dnl because GRUB does not need to use those variables for the build
29dnl type, so there is no conflict. Variables with the prefix "TARGET_"
30dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
31dnl type.
32
33
f1d29d87 34AC_INIT([GRUB],[1.97],[bug-grub@gnu.org])
fc22844e 35AM_INIT_AUTOMAKE()
f022876b 36AC_PREREQ(2.60)
4b13b216 37AC_CONFIG_SRCDIR([include/grub/dl.h])
6a161fa9 38AC_CONFIG_HEADER([config.h])
39
b977bf01 40# Checks for host and target systems.
6a161fa9 41AC_CANONICAL_HOST
b977bf01 42AC_CANONICAL_TARGET
6a161fa9 43
1d543c3e 44# Program name transformations
45AC_ARG_PROGRAM
46
b977bf01 47case "$target_cpu" in
02164e1b 48 i[[3456]]86) target_cpu=i386 ;;
49 sparc) target_cpu=sparc64 ;;
6a161fa9 50esac
51
05568c2e 52# Specify the platform (such as firmware).
53AC_ARG_WITH([platform],
54 AS_HELP_STRING([--with-platform=PLATFORM],
83b984de 55 [select the host platform [[guessed]]]))
05568c2e 56
57# Guess the platform if not specified.
58if test "x$with_platform" = x; then
b977bf01 59 case "$target_cpu"-"$target_vendor" in
05568c2e 60 i386-apple) platform=efi ;;
61 i386-*) platform=pc ;;
58393a2d 62 x86_64-apple) platform=efi ;;
737feb35 63 x86_64-*) platform=pc ;;
05568c2e 64 powerpc-*) platform=ieee1275 ;;
58393a2d 65 powerpc64-*) platform=ieee1275 ;;
05568c2e 66 sparc64-*) platform=ieee1275 ;;
58393a2d 67 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
05568c2e 68 esac
69else
70 platform="$with_platform"
71fi
72
58393a2d 73# Adjust CPU unless target was explicitly specified.
74if test -z "$target_alias"; then
75 case "$target_cpu"-"$platform" in
76 x86_64-efi) ;;
3f4ce737 77 x86_64-*) target_cpu=i386 ;;
78 powerpc64-ieee1275) target_cpu=powerpc ;;
20011694 79 esac
80fi
81
58393a2d 82# Check if the platform is supported, make final adjustments.
b977bf01 83case "$target_cpu"-"$platform" in
05568c2e 84 i386-efi) ;;
3f4ce737 85 x86_64-efi) ;;
05568c2e 86 i386-pc) ;;
546f966a 87 i386-coreboot) ;;
58393a2d 88 i386-linuxbios) platform=coreboot ;;
3d04eab8 89 i386-ieee1275) ;;
8231fb77 90 i386-qemu) ;;
05568c2e 91 powerpc-ieee1275) ;;
92 sparc64-ieee1275) ;;
f84b481b 93 *-emu) ;;
58393a2d 94 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
6a161fa9 95esac
96
3f4ce737 97case "$target_cpu" in
98 i386 | powerpc) target_m32=1 ;;
99 x86_64 | sparc64) target_m64=1 ;;
100esac
101
6e5a42fe 102case "$host_os" in
4825d790 103 mingw32*) host_os=cygwin ;;
6e5a42fe 104esac
105
9304eef1 106# This normalizes the names, and creates a new variable ("host_kernel")
107# while at it, since the mapping is not always 1:1 (e.g. different OSes
108# using the same kernel type).
109case "$host_os" in
110 gnu*) host_kernel=hurd ;;
111 linux*) host_kernel=linux ;;
67937d4d 112 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
9304eef1 113 cygwin) host_kernel=windows ;;
114esac
115
f84b481b
RM
116case "$platform" in
117 coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
118 efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
119 ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
120 qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
121 pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
122 emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
123esac
124CFLAGS="$CFLAGS $machine_CFLAGS"
f616f51c 125TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
f84b481b
RM
126TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
127
56978920 128AC_SUBST(host_cpu)
129AC_SUBST(host_os)
9304eef1 130AC_SUBST(host_kernel)
6e5a42fe 131
b977bf01 132AC_SUBST(target_cpu)
05568c2e 133AC_SUBST(platform)
6a161fa9 134
b977bf01 135#
136# Checks for build programs.
137#
144f1f98 138
6c826348 139# Although cmp is listed in the GNU Coding Standards as a command which
140# can used directly, OpenBSD lacks cmp in the default installation.
141AC_CHECK_PROGS([CMP], [cmp])
142if test "x$CMP" = x; then
143 AC_MSG_ERROR([cmp is not found])
144fi
145
144f1f98 146AC_CHECK_PROGS([YACC], [bison])
1569ec51 147if test "x$YACC" = x; then
6c826348 148 AC_MSG_ERROR([bison is not found])
1569ec51 149fi
150
a797824f 151for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz ; do
4931827f 152 if test -e $file ; then
6c09890c 153 AC_SUBST([FONT_SOURCE], [$file])
4931827f 154 break
155 fi
156done
157
b977bf01 158AC_PROG_INSTALL
159AC_PROG_AWK
160AC_PROG_MAKE_SET
ff420223 161AC_PROG_MKDIR_P
b977bf01 162
68807e5f 163# These are not a "must".
b977bf01 164AC_PATH_PROG(RUBY, ruby)
c44c90db 165AC_PATH_PROG(MAKEINFO, makeinfo)
6a161fa9 166
b977bf01 167#
168# Checks for host programs.
169#
170
171AC_PROG_CC
6a161fa9 172# Must be GCC.
173test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
174
4889bdec 175AC_GNU_SOURCE
6717926e 176AM_GNU_GETTEXT
b977bf01 177AC_SYS_LARGEFILE
178
179# Identify characteristics of the host architecture.
180AC_C_BIGENDIAN
181AC_CHECK_SIZEOF(void *)
182AC_CHECK_SIZEOF(long)
183
2b167a72 184grub_apple_cc
c9da87d0 185if test x$grub_cv_apple_cc = xyes ; then
2b167a72 186 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
187 ASFLAGS="$ASFLAGS -DAPPLE_CC=1"
188fi
b977bf01 189
86695375 190if test "x$cross_compiling" = xyes; then
191 AC_MSG_WARN([cannot generate manual pages while cross compiling])
192else
193 AC_PATH_PROG(HELP2MAN, help2man)
194fi
195
4889bdec 196# Check for functions.
df38d0bb 197AC_CHECK_FUNCS(posix_memalign memalign asprintf)
4889bdec 198
7c4e16ff
RM
199# For grub-mkisofs
200AC_HEADER_MAJOR
201AC_HEADER_DIRENT
4825d790 202AC_CHECK_FUNCS(memmove sbrk strdup lstat getuid getgid)
7c4e16ff
RM
203AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h)
204AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h)
205
b977bf01 206#
207# Check for target programs.
208#
209
5b5d4aa5 210# Find tools for the target.
211if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
b977bf01 212 tmp_ac_tool_prefix="$ac_tool_prefix"
213 ac_tool_prefix=$target_alias-
214
215 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
216 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
217 AC_CHECK_TOOL(OBJCOPY, objcopy)
218 AC_CHECK_TOOL(STRIP, strip)
219 AC_CHECK_TOOL(NM, nm)
220
221 ac_tool_prefix="$tmp_ac_tool_prefix"
222else
223 if test "x$TARGET_CC" = x; then
224 TARGET_CC=$CC
225 fi
226 AC_CHECK_TOOL(OBJCOPY, objcopy)
227 AC_CHECK_TOOL(STRIP, strip)
228 AC_CHECK_TOOL(NM, nm)
229fi
230AC_SUBST(TARGET_CC)
231
232
233# Test the C compiler for the target environment.
234tmp_CC="$CC"
235tmp_CFLAGS="$CFLAGS"
236tmp_LDFLAGS="$LDFLAGS"
237tmp_CPPFLAGS="$CPPFLAGS"
aa6d7826 238tmp_LIBS="$LIBS"
b977bf01 239CC="$TARGET_CC"
240CFLAGS="$TARGET_CFLAGS"
241CPPFLAGS="$TARGET_CPPFLAGS"
242LDFLAGS="$TARGET_LDFLAGS"
aa6d7826 243LIBS=""
b977bf01 244
245if test "x$TARGET_CFLAGS" = x; then
6a161fa9 246 # debug flags.
b977bf01 247 TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
248 -Wundef -Wstrict-prototypes -g"
6a161fa9 249
250 # optimization flags.
322562ea 251 AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [
6a161fa9 252 CFLAGS=-Os
eb73121d 253 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
254 [grub_cv_cc_Os=yes],
255 [grub_cv_cc_Os=no])
6a161fa9 256 ])
322562ea 257 if test "x$grub_cv_cc_Os" = xyes; then
b977bf01 258 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
6a161fa9 259 else
b977bf01 260 TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops"
6a161fa9 261 fi
262
263 # Force no alignment to save space on i386.
b977bf01 264 if test "x$target_cpu" = xi386; then
322562ea 265 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
2b167a72 266 CFLAGS="$CFLAGS -falign-loops=1"
eb73121d 267 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
268 [grub_cv_cc_falign_loop=yes],
269 [grub_cv_cc_falign_loop=no])
6a161fa9 270 ])
271
322562ea 272 if test "x$grub_cv_cc_falign_loop" = xyes; then
b977bf01 273 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
6a161fa9 274 else
b977bf01 275 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
6a161fa9 276 fi
6f3cd880 277
278 # Some toolchains enable these features by default, but they need
279 # registers that aren't set up properly in GRUB.
280 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
6a161fa9 281 fi
77c55a87 282
283 # By default, GCC 4.4 generates .eh_frame sections containing unwind
284 # information in some cases where it previously did not. GRUB doesn't need
285 # these and they just use up vital space. Restore the old compiler
286 # behaviour.
287 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
288 SAVE_CFLAGS="$CFLAGS"
289 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
290 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
291 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
292 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
293 CFLAGS="$SAVE_CFLAGS"
294 ])
295
296 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
297 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
298 fi
b977bf01 299fi
6a161fa9 300
2b167a72 301grub_apple_target_cc
c9da87d0 302if test x$grub_cv_apple_target_cc = xyes ; then
2b167a72 303 TARGET_CFLAGS="$TARGET_CFLAGS -DAPPLE_CC=1 -fnested-functions"
304 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
305 TARGET_ASFLAGS="$TARGET_ASFLAGS -DAPPLE_CC=1"
306 TARGET_APPLE_CC=1
cf00df31 307 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
308 if test "x$OBJCONV" = x ; then
309 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
310 fi
311 if test "x$OBJCONV" = x ; then
312 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
313 fi
2b167a72 314 TARGET_IMG_LDSCRIPT=
315 TARGET_IMG_CFLAGS="-static"
316 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
317 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
318else
319 TARGET_APPLE_CC=0
320# Use linker script if present, otherwise use builtin -N script.
2b167a72 321if test -f "${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
322 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
323 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT} -Wl,-Ttext,"
324 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
325else
326 TARGET_IMG_LDSCRIPT=
327 TARGET_IMG_LDFLAGS='-Wl,-N -Wl,-Ttext,'
328 TARGET_IMG_LDFLAGS_AC='-Wl,-N -Wl,-Ttext,'
329fi
330TARGET_IMG_CFLAGS=
331fi
332
333AC_SUBST(TARGET_IMG_LDSCRIPT)
334AC_SUBST(TARGET_IMG_LDFLAGS)
335AC_SUBST(TARGET_IMG_CFLAGS)
2b167a72 336
337# For platforms where ELF is not the default link format.
338AC_MSG_CHECKING([for command to convert module to ELF format])
339case "${host_os}" in
340 cygwin) TARGET_OBJ2ELF='grub-pe2elf' ;;
341 *) ;;
342esac
343AC_SUBST(TARGET_OBJ2ELF)
344AC_MSG_RESULT([$TARGET_OBJ2ELF])
345
346
b977bf01 347if test "x$target_m32" = x1; then
348 # Force 32-bit mode.
349 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
350 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
2b167a72 351 TARGET_MODULE_FORMAT="elf32"
6a161fa9 352fi
b977bf01 353
20011694 354if test "x$target_m64" = x1; then
355 # Force 64-bit mode.
7e9ca17a 356 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
357 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
2b167a72 358 TARGET_MODULE_FORMAT="elf64"
7e9ca17a 359fi
360
361if test "$target_cpu"-"$platform" = x86_64-efi; then
362 # Use large model to support 4G memory
6e09b8b7 363 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
c8600122 364 SAVED_CFLAGS=$CFLAGS
365 CFLAGS="$CFLAGS -m64 -mcmodel=large"
6e09b8b7 366 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
367 [grub_cv_cc_mcmodel=yes],
368 [grub_cv_cc_mcmodel=no])
369 ])
c8600122 370 if test "x$grub_cv_cc_mcmodel" = xno; then
371 CFLAGS="$SAVED_CFLAGS -m64 -DMCMODEL_SMALL=1"
b39f9d20 372 TARGET_CFLAGS="$TARGET_CFLAGS -DMCMODEL_SMALL=1"
ce7a733d 373 AC_MSG_WARN([-mcmodel=large not supported. You won't be able to use the memory over 4GiB. Upgrade your gcc])
c8600122 374 else
375 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
6e09b8b7 376 fi
7e9ca17a 377
378 # EFI writes to stack below %rsp, we must not use the red zone
379 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
c8600122 380 CFLAGS="$CFLAGS -m64 -mno-red-zone"
7e9ca17a 381 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
382 [grub_cv_cc_no_red_zone=yes],
383 [grub_cv_cc_no_red_zone=no])
384 ])
385 if test "x$grub_cv_cc_no_red_zone" = xno; then
386 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
387 fi
388
c8600122 389 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
20011694 390fi
391
baa2a121 392#
393# Compiler features.
394#
395
9035dce4 396# Need __enable_execute_stack() for nested function trampolines?
397grub_CHECK_ENABLE_EXECUTE_STACK
398
93a81088 399# Position independent executable.
400grub_CHECK_PIE
401[# Need that, because some distributions ship compilers that include
402# `-fPIE' in the default specs.
403if [ x"$pie_possible" = xyes ]; then
404 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
405fi]
406
baa2a121 407# Smashing stack protector.
408grub_CHECK_STACK_PROTECTOR
c3db8364 409# Need that, because some distributions ship compilers that include
baa2a121 410# `-fstack-protector' in the default specs.
c3db8364 411if test "x$ssp_possible" = xyes; then
412 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
413fi
2a8a80e4 414grub_CHECK_STACK_ARG_PROBE
415# Cygwin's GCC uses alloca() to probe the stackframe on static
416# stack allocations above some threshold.
417if test x"$sap_possible" = xyes; then
418 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
419fi
baa2a121 420
63f745e8 421AC_ARG_ENABLE([werror],
422 [AS_HELP_STRING([--disable-werror],
423 [do not use -Werror when building GRUB])])
424if test x"$enable_werror" != xno ; then
425 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
426fi
427
b977bf01 428AC_SUBST(TARGET_CFLAGS)
2b167a72 429AC_SUBST(TARGET_MODULE_FORMAT)
cf00df31 430AC_SUBST(OBJCONV)
2b167a72 431AC_SUBST(TARGET_APPLE_CC)
432AC_SUBST(TARGET_ASFLAGS)
b977bf01 433AC_SUBST(TARGET_CPPFLAGS)
434AC_SUBST(TARGET_LDFLAGS)
6a161fa9 435
3b2fe8c2 436# Check for libgcc symbols (must be performed before we add -nostdlib to LDFLAGS)
346e7fbe 437AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2)
3b2fe8c2 438
aa6d7826 439# Set them to their new values for the tests below.
440CC="$TARGET_CC"
26de2bcd 441if test "x$TARGET_APPLE_CC" = x1 ; then
442CFLAGS="$TARGET_CFLAGS -nostdlib"
443else
7d83bd47 444CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
26de2bcd 445fi
aa6d7826 446CPPFLAGS="$TARGET_CPPFLAGS"
447LDFLAGS="$TARGET_LDFLAGS"
448
6a161fa9 449# Defined in aclocal.m4.
f6130a12 450grub_PROG_TARGET_CC
2b167a72 451if test "x$TARGET_APPLE_CC" != x1 ; then
b977bf01 452grub_PROG_OBJCOPY_ABSOLUTE
2b167a72 453fi
cb71ba20 454grub_PROG_LD_BUILD_ID_NONE
4b13b216 455grub_ASM_USCORE
b977bf01 456if test "x$target_cpu" = xi386; then
2a8a80e4 457 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
458 # Check symbols provided by linker script.
459 CFLAGS="$TARGET_CFLAGS -nostdlib $TARGET_IMG_LDFLAGS_AC -Wl,-Ttext,8000,--defsym,___main=0x8100"
460 fi
58750afc 461 if test "x$TARGET_APPLE_CC" != x1 ; then
2a8a80e4 462 grub_CHECK_BSS_START_SYMBOL
463 grub_CHECK_END_SYMBOL
464 fi
465 CFLAGS="$TARGET_CFLAGS"
4b13b216 466 grub_I386_ASM_PREFIX_REQUIREMENT
467 grub_I386_ASM_ADDR32
468 grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
5aded270 469else
f4917dfd 470 AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
6a161fa9 471fi
472
bf6a5fb2 473AH_BOTTOM([#if defined(__i386__) && !defined(GRUB_UTIL)
474#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1)))
475#else
476#define NESTED_FUNC_ATTR
477#endif])
478
5ce5507f 479AC_ARG_ENABLE([efiemu],
480 [AS_HELP_STRING([--enable-efiemu],
481 [build and install the efiemu runtimes (default=guessed)])])
482if test x"$enable_efiemu" = xno ; then
ce7a733d 483 efiemu_excuse="explicitly disabled"
5ce5507f 484fi
485if test x"$efiemu_excuse" = x ; then
43e6200c 486 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
d2838156 487 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
5ce5507f 488 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
489 [grub_cv_cc_efiemu=yes],
490 [grub_cv_cc_efiemu=no])
491 ])
55c70904 492 if test x$grub_cv_cc_efiemu = xno; then
e98cd0c2 493 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
5ce5507f 494 fi
495fi
496if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
ce7a733d 497 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
5ce5507f 498fi
499if test x"$efiemu_excuse" = x ; then
500enable_efiemu=yes
501else
502enable_efiemu=no
503fi
504AC_SUBST([enable_efiemu])
505
506
c9a86192 507# Restore the flags.
9962ed99 508CC="$tmp_CC"
509CFLAGS="$tmp_CFLAGS"
510CPPFLAGS="$tmp_CPPFLAGS"
c9a86192 511LDFLAGS="$tmp_LDFLAGS"
aa6d7826 512LIBS="$tmp_LIBS"
6a161fa9 513
4fe9862e 514#
2965c7cc 515# Check for options.
4fe9862e 516#
517
518# Memory manager debugging.
b39f9d20 519AC_ARG_ENABLE([mm-debug],
2965c7cc 520 AS_HELP_STRING([--enable-mm-debug],
90ce5d56 521 [include memory manager debugging]),
2965c7cc 522 [AC_DEFINE([MM_DEBUG], [1],
523 [Define to 1 if you enable memory manager debugging.])])
524
d64399b5 525AC_ARG_ENABLE([grub-emu-usb],
526 [AS_HELP_STRING([--enable-grub-emu-usb],
5ce5507f 527 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
5ce5507f 528
f84b481b
RM
529if test "$platform" = emu; then
530 missing_ncurses=
531[# Check for curses libraries.]
4fe9862e 532 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
533 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
f84b481b 534 [missing_ncurses=[true]])])
4fe9862e 535 AC_SUBST([LIBCURSES])
f84b481b 536[if [ x"$missing_ncurses" = x ]; then ]
4fe9862e 537 [# Check for headers.]
538 AC_CHECK_HEADERS([ncurses/curses.h], [],
539 [AC_CHECK_HEADERS([ncurses.h], [],
540 [AC_CHECK_HEADERS([curses.h], [],
f84b481b 541 [missing_ncurses=[true]])])])
5ce5507f 542[fi]
f84b481b
RM
543if test x"$missing_ncurses" = xtrue ; then
544 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
5ce5507f 545fi
f84b481b 546
5ce5507f 547if test x"$enable_grub_emu_usb" = xno ; then
ce7a733d 548 grub_emu_usb_excuse="explicitly disabled"
5ce5507f 549fi
550[if [ x"$grub_emu_usb_excuse" = x ]; then
d64399b5 551 # Check for libusb libraries.]
5ce5507f 552AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
e98cd0c2 553 [grub_emu_usb_excuse=["need libusb library"]])
d64399b5 554 AC_SUBST([LIBUSB])
5ce5507f 555[fi]
556[if [ x"$grub_emu_usb_excuse" = x ]; then
557 # Check for headers.]
d64399b5 558 AC_CHECK_HEADERS([usb.h], [],
e98cd0c2 559 [grub_emu_usb_excuse=["need libusb headers"]])
4fe9862e 560[fi]
c6f3b249 561if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
ce7a733d 562 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
5ce5507f 563fi
564if test x"$grub_emu_usb_excuse" = x ; then
565enable_grub_emu_usb=yes
566else
567enable_grub_emu_usb=no
568fi
d64399b5 569AC_SUBST([enable_grub_emu_usb])
f84b481b 570fi
4fe9862e 571
99fadbaa 572AC_ARG_ENABLE([grub-fstest],
573 [AS_HELP_STRING([--enable-grub-fstest],
5ce5507f 574 [build and install the `grub-fstest' debugging utility (default=guessed)])])
575if test x"$enable_grub_fstest" = xno ; then
ce7a733d 576 grub_fstest_excuse="explicitly disabled"
5ce5507f 577fi
578if test x"$grub_fstest_excuse" = x ; then
579enable_grub_fstest=yes
580else
581enable_grub_fstest=no
582fi
99fadbaa 583AC_SUBST([enable_grub_fstest])
584
e52db1f7 585AC_ARG_ENABLE([grub-mkfont],
586 [AS_HELP_STRING([--enable-grub-mkfont],
5ce5507f 587 [build and install the `grub-mkfont' utility (default=guessed)])])
588if test x"$enable_grub_mkfont" = xno ; then
ce7a733d 589 grub_mkfont_excuse="explicitly disabled"
5ce5507f 590fi
591
592if test x"$grub_mkfont_excuse" = x ; then
e52db1f7 593 # Check for freetype libraries.
594 AC_CHECK_PROGS([FREETYPE], [freetype-config])
595 if test "x$FREETYPE" = x ; then
e98cd0c2 596 grub_mkfont_excuse=["need freetype2 library"]
e52db1f7 597 fi
598 freetype_cflags=`freetype-config --cflags`
599 freetype_libs=`freetype-config --libs`
600fi
5ce5507f 601if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
ce7a733d 602 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
5ce5507f 603fi
604if test x"$grub_mkfont_excuse" = x ; then
605enable_grub_mkfont=yes
606else
607enable_grub_mkfont=no
608fi
e52db1f7 609AC_SUBST([enable_grub_mkfont])
610AC_SUBST([freetype_cflags])
611AC_SUBST([freetype_libs])
612
2b167a72 613AC_SUBST(ASFLAGS)
fc45fb58 614
6a161fa9 615# Output files.
1f4147aa 616grub_CHECK_LINK_DIR
617if test x"$link_dir" = xyes ; then
f84b481b
RM
618 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu])
619 if test "$platform" != emu ; then
620 AC_CONFIG_LINKS([include/grub/machine:include/grub/$target_cpu/$platform])
621 fi
1f4147aa 622else
623 mkdir -p include/grub 2>/dev/null
624 rm -rf include/grub/cpu
625 cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null
f84b481b
RM
626 if test "$platform" != emu ; then
627 rm -rf include/grub/machine
628 cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
629 fi
1f4147aa 630fi
7b455f4d 631AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
6a161fa9 632AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
633AC_OUTPUT
5ce5507f 634[
635echo "*******************************************************"
636echo GRUB2 will be compiled with following components:
637echo Platform: "$target_cpu"-"$platform"
f84b481b 638if [ x"$platform" = xemu ]; then
5ce5507f 639if [ x"$grub_emu_usb_excuse" = x ]; then
640echo USB support for grub-emu: Yes
641else
642echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
643fi
f84b481b 644fi
5ce5507f 645if [ x"$enable_mm_debug" = xyes ]; then
646echo With memory debugging: Yes
647else
648echo With memory debugging: No
649fi
5ce5507f 650if [ x"$efiemu_excuse" = x ]; then
651echo efiemu runtime: Yes
652else
653echo efiemu runtime: No "($efiemu_excuse)"
654fi
655if [ x"$grub_fstest_excuse" = x ]; then
656echo grub-fstest: Yes
657else
658echo grub-fstest: No "($grub_fstest_excuse)"
659fi
660if [ x"$grub_mkfont_excuse" = x ]; then
661echo grub-mkfont: Yes
662else
663echo grub-mkfont: No "($grub_mkfont_excuse)"
664fi
665echo "*******************************************************"
666]