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