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