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