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