]> git.proxmox.com Git - grub2.git/blob - configure.ac
* configure.ac: Move -fnested-functions to CPPFLAGS to workaround
[grub2.git] / configure.ac
1 # -*- autoconf -*-
2
3 # Process this file with autoconf to produce a configure script.
4
5 # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
6 #
7 # This configure.ac is free software; the author
8 # gives unlimited permission to copy and/or distribute it,
9 # with or without modifications, as long as this notice is preserved.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 # PARTICULAR PURPOSE.
15
16 dnl This configure script is complicated, because GRUB needs to deal
17 dnl with three potentially different types:
18 dnl
19 dnl build -- the environment for building GRUB
20 dnl host -- the environment for running utilities
21 dnl target -- the environment for running GRUB
22 dnl
23 dnl In addition, GRUB needs to deal with a platform specification
24 dnl which specifies the system running GRUB, such as firmware.
25 dnl This is necessary because the target type in autoconf does not
26 dnl describe such a system very well.
27 dnl
28 dnl The current strategy is to use variables with no prefix (such as
29 dnl CC, CFLAGS, etc.) for the host type as well as the build type,
30 dnl because GRUB does not need to use those variables for the build
31 dnl type, so there is no conflict. Variables with the prefix "TARGET_"
32 dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
33 dnl type.
34
35 AC_INIT([GRUB],[2.00~beta0],[bug-grub@gnu.org])
36
37 AC_CONFIG_AUX_DIR([build-aux])
38
39 # We don't want -g -O2 by default in CFLAGS
40 : ${CFLAGS=""}
41
42 # Checks for host and target systems.
43 AC_CANONICAL_HOST
44 AC_CANONICAL_TARGET
45
46 AM_INIT_AUTOMAKE()
47 AC_PREREQ(2.60)
48 AC_CONFIG_SRCDIR([include/grub/dl.h])
49 AC_CONFIG_HEADER([config-util.h])
50
51 # Program name transformations
52 AC_ARG_PROGRAM
53
54 # Optimization flag. Allow user to override.
55 if test "x$TARGET_CFLAGS" = x; then
56 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
57 fi
58
59 # Default HOST_CPPFLAGS
60 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
61 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
62 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
63 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
64 HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
65
66 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
67 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
68 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
69
70 case "$target_cpu" in
71 i[[3456]]86) target_cpu=i386 ;;
72 amd64) target_cpu=x86_64 ;;
73 sparc) target_cpu=sparc64 ;;
74 mipsel|mips64el)
75 target_cpu=mipsel;
76 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
77 ;;
78 mips|mips64)
79 target_cpu=mips;
80 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
81 ;;
82 esac
83
84 # Specify the platform (such as firmware).
85 AC_ARG_WITH([platform],
86 AS_HELP_STRING([--with-platform=PLATFORM],
87 [select the host platform [[guessed]]]))
88
89 # Guess the platform if not specified.
90 if test "x$with_platform" = x; then
91 case "$target_cpu"-"$target_vendor" in
92 i386-apple) platform=efi ;;
93 i386-*) platform=pc ;;
94 x86_64-apple) platform=efi ;;
95 x86_64-*) platform=pc ;;
96 powerpc-*) platform=ieee1275 ;;
97 powerpc64-*) platform=ieee1275 ;;
98 sparc64-*) platform=ieee1275 ;;
99 mipsel-*) platform=loongson ;;
100 mips-*) platform=arc ;;
101 ia64-*) platform=efi ;;
102 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
103 esac
104 else
105 platform="$with_platform"
106 fi
107
108 case "$target_cpu"-"$platform" in
109 x86_64-efi) ;;
110 x86_64-emu) ;;
111 x86_64-*) target_cpu=i386 ;;
112 powerpc64-ieee1275) target_cpu=powerpc ;;
113 esac
114
115 # Check if the platform is supported, make final adjustments.
116 case "$target_cpu"-"$platform" in
117 i386-efi) ;;
118 x86_64-efi) ;;
119 i386-pc) ;;
120 i386-multiboot) ;;
121 i386-coreboot) ;;
122 i386-linuxbios) platform=coreboot ;;
123 i386-ieee1275) ;;
124 i386-qemu) ;;
125 powerpc-ieee1275) ;;
126 sparc64-ieee1275) ;;
127 ia64-efi) ;;
128 mips-qemu_mips) ;;
129 mips-qemu-mips) platform=qemu_mips;;
130 mips-arc) ;;
131 mipsel-qemu_mips) ;;
132 mipsel-qemu-mips) platform=qemu_mips;;
133 mipsel-yeeloong) platform=loongson ;;
134 mipsel-fuloong) platform=loongson ;;
135 mipsel-loongson) ;;
136 *-emu) ;;
137 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
138 esac
139
140 case "$target_cpu" in
141 i386 | powerpc) target_m32=1 ;;
142 x86_64 | sparc64) target_m64=1 ;;
143 esac
144
145 case "$host_os" in
146 mingw32*) host_os=cygwin ;;
147 esac
148
149 # This normalizes the names, and creates a new variable ("host_kernel")
150 # while at it, since the mapping is not always 1:1 (e.g. different OSes
151 # using the same kernel type).
152 case "$host_os" in
153 gnu*) host_kernel=hurd ;;
154 linux*) host_kernel=linux ;;
155 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
156 netbsd*) host_kernel=netbsd ;;
157 solaris*) host_kernel=illumos ;;
158 cygwin) host_kernel=windows ;;
159 esac
160
161 case "$platform" in
162 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
163 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
164 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
165 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
166 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
167 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
168 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
169 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
170 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
171 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
172 esac
173 case "$target_cpu" in
174 mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
175 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
176 esac
177 if test x${target_cpu} = xmipsel ; then
178 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
179 else
180 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,` -DGRUB_TARGET_CPU_`echo ${target_cpu} | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`=1"
181 fi
182
183 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
184
185 AC_SUBST(host_cpu)
186 AC_SUBST(host_os)
187 AC_SUBST(host_kernel)
188
189 AC_SUBST(target_cpu)
190 AC_SUBST(platform)
191
192 # Define default variables
193
194 have_with_bootdir=n
195 AC_ARG_WITH([bootdir],
196 AS_HELP_STRING([--with-bootdir=DIR],
197 [set the name of /boot directory [[guessed]]]),
198 [have_with_bootdir=y],
199 [have_with_bootdir=n])
200 if test x$have_with_bootdir = xy; then
201 bootdirname="$with_bootdir"
202 else
203 case "$host_os" in
204 netbsd* | openbsd*)
205 # Because /boot is used for the boot block in NetBSD and OpenBSD,
206 bootdirname='' ;;
207 *) bootdirname='boot' ;;
208 esac
209 fi
210
211 AC_SUBST(bootdirname)
212 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
213 [Default boot directory name]")
214
215 AC_ARG_WITH([grubdir],
216 AS_HELP_STRING([--with-grubdir=DIR],
217 [set the name of grub directory [[guessed]]]),
218 [grubdirname="$with_grubdir"],
219 [grubdirname="$PACKAGE"])
220
221 AC_SUBST(grubdirname)
222 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
223 [Default grub directory name])
224
225 #
226 # Checks for build programs.
227 #
228
229 # Although cmp is listed in the GNU Coding Standards as a command which
230 # can used directly, OpenBSD lacks cmp in the default installation.
231 AC_CHECK_PROGS([CMP], [cmp])
232 if test "x$CMP" = x; then
233 AC_MSG_ERROR([cmp is not found])
234 fi
235
236 AC_CHECK_PROGS([YACC], [bison])
237 if test "x$YACC" = x; then
238 AC_MSG_ERROR([bison is not found])
239 fi
240
241 FONT_SOURCE=
242
243 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
244 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
245 if test -f "$dir/unifont.$ext"; then
246 FONT_SOURCE="$dir/unifont.$ext"
247 break 2
248 fi
249 done
250 done
251
252 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips); then
253 AC_MSG_ERROR([qemu and loongson ports need unifont])
254 fi
255
256 AC_SUBST([FONT_SOURCE])
257
258 AC_PROG_RANLIB
259 AC_PROG_INSTALL
260 AC_PROG_AWK
261 AC_PROG_LEX
262 AC_PROG_YACC
263 AC_PROG_MAKE_SET
264 AC_PROG_MKDIR_P
265 AC_PROG_LN_S
266
267 if test "x$LEX" = "x:"; then
268 AC_MSG_ERROR([flex is not found])
269 else
270 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
271 if test -n "$version" -a "$version" -ge 20535; then
272 :
273 else
274 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
275 fi
276 fi
277
278 # These are not a "must".
279 AC_PATH_PROGS(MAKEINFO, makeinfo true)
280
281 #
282 # Checks for host programs.
283 #
284
285 AC_PROG_CC
286 gl_EARLY
287 AM_PROG_CC_C_O
288 AM_PROG_AS
289
290 # Must be GCC.
291 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
292
293 AC_GNU_SOURCE
294 AM_GNU_GETTEXT([external])
295 AC_SYS_LARGEFILE
296
297 # Identify characteristics of the host architecture.
298 AC_C_BIGENDIAN
299 AC_CHECK_SIZEOF(void *)
300 AC_CHECK_SIZEOF(long)
301
302 grub_apple_cc
303 if test x$grub_cv_apple_cc = xyes ; then
304 HOST_CPPFLAGS="$HOST_CPPFLAGS -DAPPLE_CC=1 -fnested-functions"
305 HOST_CFLAGS="$HOST_CFLAGS"
306 fi
307
308 if test x$USE_NLS = xno; then
309 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
310 fi
311
312 if test "x$cross_compiling" = xyes; then
313 AC_MSG_WARN([cannot generate manual pages while cross compiling])
314 else
315 AC_PATH_PROG(HELP2MAN, help2man)
316 fi
317
318 # Check for functions and headers.
319 AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
320 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
321
322 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
323 #include <sys/param.h>
324 #include <sys/mount.h>])
325
326 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
327 #include <sys/param.h>
328 #include <sys/mount.h>])
329
330 # For opendisk() and getrawpartition() on NetBSD.
331 # Used in util/deviceiter.c and in util/hostdisk.c.
332 AC_CHECK_HEADER([util.h], [
333 AC_CHECK_LIB([util], [opendisk], [
334 LIBUTIL="-lutil"
335 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
336 ])
337 AC_CHECK_LIB([util], [getrawpartition], [
338 LIBUTIL="-lutil"
339 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
340 ])
341 ])
342 AC_SUBST([LIBUTIL])
343
344 #
345 # Check for host and build compilers.
346 #
347 HOST_CC=$CC
348 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
349 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
350
351 # For gnulib.
352 gl_INIT
353
354 #
355 # Check for target programs.
356 #
357
358 # Find tools for the target.
359 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
360 tmp_ac_tool_prefix="$ac_tool_prefix"
361 ac_tool_prefix=$target_alias-
362
363 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
364 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
365 AC_CHECK_TOOL(OBJCOPY, objcopy)
366 AC_CHECK_TOOL(STRIP, strip)
367 AC_CHECK_TOOL(NM, nm)
368
369 ac_tool_prefix="$tmp_ac_tool_prefix"
370 else
371 if test "x$TARGET_CC" = x; then
372 TARGET_CC=$CC
373 fi
374 AC_CHECK_TOOL(OBJCOPY, objcopy)
375 AC_CHECK_TOOL(STRIP, strip)
376 AC_CHECK_TOOL(NM, nm)
377 fi
378 AC_SUBST(HOST_CC)
379 AC_SUBST(BUILD_CC)
380 AC_SUBST(TARGET_CC)
381
382 # Test the C compiler for the target environment.
383 tmp_CC="$CC"
384 tmp_CFLAGS="$CFLAGS"
385 tmp_LDFLAGS="$LDFLAGS"
386 tmp_CPPFLAGS="$CPPFLAGS"
387 tmp_LIBS="$LIBS"
388 CC="$TARGET_CC"
389 CFLAGS="$TARGET_CFLAGS"
390 CPPFLAGS="$TARGET_CPPFLAGS"
391 LDFLAGS="$TARGET_LDFLAGS"
392 LIBS=""
393
394 # debug flags.
395 WARN_FLAGS="-Wall -W -Wshadow -Wold-style-declaration -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Warray-bounds -Wattributes -Wbuiltin-macro-redefined -Wcast-align -Wchar-subscripts -Wclobbered -Wcomment -Wcoverage-mismatch -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-contains-nul -Wformat-extra-args -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wunsafe-loop-optimizations -Wlogical-op -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmudflap -Wmultichar -Wnonnull -Woverflow -Wpacked-bitfield-compat -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wsync-nand -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wmissing-parameter-type -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
396 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
397 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
398 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
399
400 # Force no alignment to save space on i386.
401 if test "x$target_cpu" = xi386; then
402 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
403 CFLAGS="$CFLAGS -falign-loops=1"
404 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
405 [grub_cv_cc_falign_loop=yes],
406 [grub_cv_cc_falign_loop=no])
407 ])
408
409 if test "x$grub_cv_cc_falign_loop" = xyes; then
410 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
411 else
412 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
413 fi
414
415 # Some toolchains enable these features by default, but they need
416 # registers that aren't set up properly in GRUB.
417 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
418 fi
419
420 # By default, GCC 4.4 generates .eh_frame sections containing unwind
421 # information in some cases where it previously did not. GRUB doesn't need
422 # these and they just use up vital space. Restore the old compiler
423 # behaviour.
424 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
425 SAVE_CFLAGS="$CFLAGS"
426 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
427 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
428 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
429 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
430 CFLAGS="$SAVE_CFLAGS"
431 ])
432
433 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
434 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
435 fi
436
437 # By default, GCC 4.6 generates .eh_frame sections containing unwind
438 # information in some cases where it previously did not. GRUB doesn't need
439 # these and they just use up vital space. Restore the old compiler
440 # behaviour.
441 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
442 SAVE_CFLAGS="$CFLAGS"
443 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
444 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
445 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
446 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
447 CFLAGS="$SAVE_CFLAGS"
448 ])
449
450 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
451 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
452 fi
453
454 grub_apple_target_cc
455 if test x$grub_cv_apple_target_cc = xyes ; then
456 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DAPPLE_CC=1"
457 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -fnested-functions"
458
459 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
460 TARGET_APPLE_CC=1
461 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
462 if test "x$OBJCONV" = x ; then
463 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
464 fi
465 if test "x$OBJCONV" = x ; then
466 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
467 fi
468 TARGET_IMG_LDSCRIPT=
469 TARGET_IMG_CFLAGS="-static"
470 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
471 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
472 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
473 else
474 TARGET_APPLE_CC=0
475 # Use linker script if present, otherwise use builtin -N script.
476 if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
477 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
478 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
479 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
480 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
481 else
482 TARGET_IMG_LDSCRIPT=
483 TARGET_IMG_LDFLAGS='-Wl,-N'
484 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
485 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
486 fi
487 TARGET_IMG_CFLAGS=
488 fi
489
490 # For platforms where ELF is not the default link format.
491 AC_MSG_CHECKING([for command to convert module to ELF format])
492 case "${host_os}" in
493 cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf';
494 # FIXME: put proper test here
495 NEED_REGISTER_FRAME_INFO=1
496 ;;
497 *) NEED_REGISTER_FRAME_INFO=0 ;;
498 esac
499 AC_MSG_RESULT([$TARGET_OBJ2ELF])
500
501
502 AC_ARG_ENABLE([efiemu],
503 [AS_HELP_STRING([--enable-efiemu],
504 [build and install the efiemu runtimes (default=guessed)])])
505 if test x"$enable_efiemu" = xno ; then
506 efiemu_excuse="explicitly disabled"
507 fi
508 if test x"$target_cpu" != xi386 ; then
509 efiemu_excuse="only available on i386"
510 fi
511 if test x"$platform" = xefi ; then
512 efiemu_excuse="not available on efi"
513 fi
514 if test x"$efiemu_excuse" = x ; then
515 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
516 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
517 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
518 [grub_cv_cc_efiemu=yes],
519 [grub_cv_cc_efiemu=no])
520 ])
521 if test x$grub_cv_cc_efiemu = xno; then
522 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
523 fi
524 fi
525 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
526 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
527 fi
528 if test x"$efiemu_excuse" = x ; then
529 enable_efiemu=yes
530 else
531 enable_efiemu=no
532 fi
533 AC_SUBST([enable_efiemu])
534
535 if test "x$target_m32" = x1; then
536 # Force 32-bit mode.
537 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
538 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
539 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
540 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
541 TARGET_MODULE_FORMAT="elf32"
542 fi
543
544 if test "x$target_m64" = x1; then
545 # Force 64-bit mode.
546 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
547 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
548 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
549 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
550 TARGET_MODULE_FORMAT="elf64"
551 fi
552
553 if test "$target_cpu"-"$platform" = x86_64-efi; then
554 # Use large model to support 4G memory
555 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
556 SAVED_CFLAGS=$CFLAGS
557 CFLAGS="$CFLAGS -m64 -mcmodel=large"
558 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
559 [grub_cv_cc_mcmodel=yes],
560 [grub_cv_cc_mcmodel=no])
561 ])
562 if test "x$grub_cv_cc_mcmodel" = xno; then
563 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
564 else
565 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
566 fi
567
568 # EFI writes to stack below %rsp, we must not use the red zone
569 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
570 CFLAGS="$CFLAGS -m64 -mno-red-zone"
571 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
572 [grub_cv_cc_no_red_zone=yes],
573 [grub_cv_cc_no_red_zone=no])
574 ])
575 if test "x$grub_cv_cc_no_red_zone" = xno; then
576 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
577 fi
578
579 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
580 fi
581
582 #
583 # Compiler features.
584 #
585
586 # Need __enable_execute_stack() for nested function trampolines?
587 grub_CHECK_ENABLE_EXECUTE_STACK
588
589 # Position independent executable.
590 grub_CHECK_PIE
591 [# Need that, because some distributions ship compilers that include
592 # `-fPIE' in the default specs.
593 if [ x"$pie_possible" = xyes ]; then
594 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
595 fi]
596
597 # Smashing stack protector.
598 grub_CHECK_STACK_PROTECTOR
599 # Need that, because some distributions ship compilers that include
600 # `-fstack-protector' in the default specs.
601 if test "x$ssp_possible" = xyes; then
602 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
603 fi
604 grub_CHECK_STACK_ARG_PROBE
605 # Cygwin's GCC uses alloca() to probe the stackframe on static
606 # stack allocations above some threshold.
607 if test x"$sap_possible" = xyes; then
608 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
609 fi
610
611 AC_ARG_ENABLE([werror],
612 [AS_HELP_STRING([--disable-werror],
613 [do not use -Werror when building GRUB])])
614 if test x"$enable_werror" != xno ; then
615 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
616 HOST_CFLAGS="$HOST_CFLAGS -Werror"
617 fi
618
619 TARGET_CPP="$TARGET_CC -E"
620 TARGET_CCAS=$TARGET_CC
621
622 GRUB_TARGET_CPU="${target_cpu}"
623 GRUB_PLATFORM="${platform}"
624
625 AC_SUBST(GRUB_TARGET_CPU)
626 AC_SUBST(GRUB_PLATFORM)
627
628 AC_SUBST(OBJCONV)
629 AC_SUBST(TARGET_CPP)
630 AC_SUBST(TARGET_CCAS)
631 AC_SUBST(TARGET_OBJ2ELF)
632 AC_SUBST(TARGET_APPLE_CC)
633 AC_SUBST(TARGET_MODULE_FORMAT)
634
635 AC_SUBST(TARGET_CFLAGS)
636 AC_SUBST(TARGET_LDFLAGS)
637 AC_SUBST(TARGET_CPPFLAGS)
638 AC_SUBST(TARGET_CCASFLAGS)
639
640 AC_SUBST(TARGET_IMG_LDSCRIPT)
641 AC_SUBST(TARGET_IMG_LDFLAGS)
642 AC_SUBST(TARGET_IMG_CFLAGS)
643 AC_SUBST(TARGET_IMG_BASE_LDOPT)
644
645 AC_SUBST(HOST_CFLAGS)
646 AC_SUBST(HOST_LDFLAGS)
647 AC_SUBST(HOST_CPPFLAGS)
648 AC_SUBST(HOST_CCASFLAGS)
649
650 # Set them to their new values for the tests below.
651 CC="$TARGET_CC"
652 if test "x$TARGET_APPLE_CC" = x1 ; then
653 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
654 else
655 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
656 fi
657 CPPFLAGS="$TARGET_CPPFLAGS"
658 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
659 LIBS=
660 else
661 LIBS=-lgcc
662 fi
663
664 grub_ASM_USCORE
665 if test x$grub_cv_asm_uscore = xyes; then
666 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
667 else
668 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
669 fi
670
671 # Check for libgcc symbols
672 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x __ia64_trampoline __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
673
674 if test "x$TARGET_APPLE_CC" = x1 ; then
675 CFLAGS="$TARGET_CFLAGS -nostdlib"
676 else
677 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
678 fi
679 LIBS=""
680
681 # Defined in aclocal.m4.
682 grub_PROG_TARGET_CC
683 if test "x$TARGET_APPLE_CC" != x1 ; then
684 grub_PROG_OBJCOPY_ABSOLUTE
685 fi
686 grub_PROG_LD_BUILD_ID_NONE
687 if test "x$target_cpu" = xi386; then
688 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
689 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
690 # Check symbols provided by linker script.
691 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
692 fi
693 grub_CHECK_BSS_START_SYMBOL
694 grub_CHECK_END_SYMBOL
695 fi
696 CFLAGS="$TARGET_CFLAGS"
697 grub_I386_ASM_PREFIX_REQUIREMENT
698 grub_I386_ASM_ADDR32
699 fi
700
701 if test "$platform" != emu; then
702 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
703 SAVED_CPPFLAGS="$CPPFLAGS"
704 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
705 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
706 int va_arg_func (int fixed, va_list args);]], [[]])],
707 [grub_cv_cc_isystem=yes],
708 [grub_cv_cc_isystem=no])
709 CPPFLAGS="$SAVED_CPPFLAGS"
710 ])
711
712 if test x"$grub_cv_cc_isystem" = xyes ; then
713 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
714 fi
715 fi
716
717 AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_cc_wnotrampolines], [
718 SAVED_CFLAGS="$CFLAGS"
719 # Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
720 # in the event of later failures (since -Wno-* is always accepted, but
721 # produces a diagnostic if something else is wrong).
722 CFLAGS="$TARGET_CFLAGS -Wtrampolines"
723 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
724 int va_arg_func (int fixed, va_list args);]], [[]])],
725 [grub_cv_cc_wnotrampolines=yes],
726 [grub_cv_cc_wnotrampolines=no])
727 CFLAGS="$SAVED_CFLAGS"
728 ])
729
730 if test x"$grub_cv_cc_wnotrampolines" = xyes ; then
731 TARGET_CFLAGS="$TARGET_CFLAGS -Wno-trampolines"
732 fi
733
734 # Restore the flags.
735 CC="$tmp_CC"
736 CFLAGS="$tmp_CFLAGS"
737 CPPFLAGS="$tmp_CPPFLAGS"
738 LDFLAGS="$tmp_LDFLAGS"
739 LIBS="$tmp_LIBS"
740
741 #
742 # Check for options.
743 #
744
745 # Memory manager debugging.
746 AC_ARG_ENABLE([mm-debug],
747 AS_HELP_STRING([--enable-mm-debug],
748 [include memory manager debugging]),
749 [AC_DEFINE([MM_DEBUG], [1],
750 [Define to 1 if you enable memory manager debugging.])])
751
752 AC_ARG_ENABLE([cache-stats],
753 AS_HELP_STRING([--enable-cache-stats],
754 [enable disk cache statistics collection]))
755
756 if test x$enable_cache_stats = xyes; then
757 DISK_CACHE_STATS=1
758 else
759 DISK_CACHE_STATS=0
760 fi
761 AC_SUBST([DISK_CACHE_STATS])
762
763 AC_ARG_ENABLE([grub-emu-usb],
764 [AS_HELP_STRING([--enable-grub-emu-usb],
765 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
766
767 AC_ARG_ENABLE([grub-emu-sdl],
768 [AS_HELP_STRING([--enable-grub-emu-sdl],
769 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
770
771 AC_ARG_ENABLE([grub-emu-pci],
772 [AS_HELP_STRING([--enable-grub-emu-pci],
773 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
774
775 if test "$platform" = emu; then
776 missing_ncurses=
777 [# Check for curses libraries.]
778 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
779 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
780 [missing_ncurses=[true]])])
781 AC_SUBST([LIBCURSES])
782 [if [ x"$missing_ncurses" = x ]; then ]
783 [# Check for headers.]
784 AC_CHECK_HEADERS([ncurses/curses.h], [],
785 [AC_CHECK_HEADERS([ncurses.h], [],
786 [AC_CHECK_HEADERS([curses.h], [],
787 [missing_ncurses=[true]])])])
788 [fi]
789 if test x"$missing_ncurses" = xtrue ; then
790 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
791 fi
792
793 if test x"$enable_grub_emu_usb" != xyes ; then
794 grub_emu_usb_excuse="not enabled"
795 fi
796
797 if test x"$enable_grub_emu_pci" = xyes ; then
798 grub_emu_usb_excuse="conflicts with PCI support"
799 fi
800
801 [if [ x"$grub_emu_usb_excuse" = x ]; then
802 # Check for libusb libraries.]
803 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
804 [grub_emu_usb_excuse=["need libusb library"]])
805 AC_SUBST([LIBUSB])
806 [fi]
807 [if [ x"$grub_emu_usb_excuse" = x ]; then
808 # Check for headers.]
809 AC_CHECK_HEADERS([usb.h], [],
810 [grub_emu_usb_excuse=["need libusb headers"]])
811 [fi]
812 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
813 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
814 fi
815 if test x"$grub_emu_usb_excuse" = x ; then
816 enable_grub_emu_usb=yes
817 else
818 enable_grub_emu_usb=no
819 fi
820
821 if test x"$enable_grub_emu_sdl" = xno ; then
822 grub_emu_sdl_excuse="explicitely disabled"
823 fi
824 [if [ x"$grub_emu_sdl_excuse" = x ]; then
825 # Check for libSDL libraries.]
826 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
827 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
828 AC_SUBST([LIBSDL])
829 [fi]
830
831 [if [ x"$grub_emu_sdl_excuse" = x ]; then
832 # Check for headers.]
833 AC_CHECK_HEADERS([SDL/SDL.h], [],
834 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
835 [fi]
836
837 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
838 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
839 fi
840 if test x"$grub_emu_sdl_excuse" = x ; then
841 enable_grub_emu_sdl=yes
842 else
843 enable_grub_emu_sdl=no
844 fi
845
846 if test x"$enable_grub_emu_pci" != xyes ; then
847 grub_emu_pci_excuse="not enabled"
848 fi
849
850 if test x"$enable_grub_emu_usb" = xyes ; then
851 grub_emu_pci_excuse="conflicts with USB support"
852 fi
853
854 [if [ x"$grub_emu_pci_excuse" = x ]; then
855 # Check for libpci libraries.]
856 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
857 [grub_emu_pci_excuse=["need libpciaccess library"]])
858 AC_SUBST([LIBPCIACCESS])
859 [fi]
860 [if [ x"$grub_emu_pci_excuse" = x ]; then
861 # Check for headers.]
862 AC_CHECK_HEADERS([pci/pci.h], [],
863 [grub_emu_pci_excuse=["need libpciaccess headers"]])
864 [fi]
865
866 if test x"$grub_emu_pci_excuse" = x ; then
867 enable_grub_emu_pci=yes
868 else
869
870 enable_grub_emu_pci=no
871 fi
872
873 AC_SUBST([enable_grub_emu_sdl])
874 AC_SUBST([enable_grub_emu_usb])
875 AC_SUBST([enable_grub_emu_pci])
876 fi
877
878 AC_ARG_ENABLE([grub-mkfont],
879 [AS_HELP_STRING([--enable-grub-mkfont],
880 [build and install the `grub-mkfont' utility (default=guessed)])])
881 if test x"$enable_grub_mkfont" = xno ; then
882 grub_mkfont_excuse="explicitly disabled"
883 fi
884
885 if test x"$grub_mkfont_excuse" = x ; then
886 # Check for freetype libraries.
887 AC_CHECK_PROGS([FREETYPE], [freetype-config])
888 if test "x$FREETYPE" = x ; then
889 grub_mkfont_excuse=["need freetype2 library"]
890 fi
891 fi
892
893 if test x"$grub_mkfont_excuse" = x ; then
894 # Check for freetype libraries.
895 freetype_cflags=`freetype-config --cflags`
896 freetype_libs=`freetype-config --libs`
897 SAVED_CPPFLAGS="$CPPFLAGS"
898 CPPFLAGS="$CPPFLAGS $freetype_cflags"
899 AC_CHECK_HEADERS([ft2build.h], [],
900 [grub_mkfont_excuse=["need freetype2 headers"]])
901 CPPFLAGS="$SAVED_CPPFLAGS"
902 fi
903
904 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
905 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
906 fi
907 if test x"$grub_mkfont_excuse" = x ; then
908 enable_grub_mkfont=yes
909 else
910 enable_grub_mkfont=no
911 fi
912 if test x"$enable_grub_mkfont" = xno && test "x$platform" = xloongson; then
913 AC_MSG_ERROR([loongson port needs grub-mkfont])
914 fi
915 AC_SUBST([enable_grub_mkfont])
916 AC_SUBST([freetype_cflags])
917 AC_SUBST([freetype_libs])
918
919 DJVU_FONT_SOURCE=
920
921 starfield_excuse=
922
923 if test x$enable_grub_mkfont = xno; then
924 starfield_excuse="No grub-mkfont"
925 fi
926
927 if test x"$starfield_excuse" != x; then
928 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
929 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu; do
930 if test -f "$dir/DejaVuSans.$ext"; then
931 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
932 break 2
933 fi
934 done
935 done
936
937 if test "x$DJVU_FONT_SOURCE" = x; then
938 starfield_excuse="No DejaVu found"
939 fi
940 fi
941
942 AC_SUBST([DJVU_FONT_SOURCE])
943
944 AC_ARG_ENABLE([grub-mount],
945 [AS_HELP_STRING([--enable-grub-mount],
946 [build and install the `grub-mount' utility (default=guessed)])])
947 if test x"$enable_grub_mount" = xno ; then
948 grub_mount_excuse="explicitly disabled"
949 fi
950
951 if test x"$grub_mount_excuse" = x ; then
952 AC_CHECK_LIB([fuse], [fuse_main_real], [],
953 [grub_mount_excuse="need FUSE library"])
954 fi
955
956 if test x"$grub_mount_excuse" = x ; then
957 # Check for fuse headers.
958 SAVED_CPPFLAGS="$CPPFLAGS"
959 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
960 AC_CHECK_HEADERS([fuse/fuse.h], [],
961 [grub_mount_excuse=["need FUSE headers"]])
962 CPPFLAGS="$SAVED_CPPFLAGS"
963 fi
964
965 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
966 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
967 fi
968 if test x"$grub_mount_excuse" = x ; then
969 enable_grub_mount=yes
970 else
971 enable_grub_mount=no
972 fi
973 AC_SUBST([enable_grub_mount])
974
975 AC_ARG_ENABLE([device-mapper],
976 [AS_HELP_STRING([--enable-device-mapper],
977 [enable Linux device-mapper support (default=guessed)])])
978 if test x"$enable_device_mapper" = xno ; then
979 device_mapper_excuse="explicitly disabled"
980 fi
981
982 if test x"$device_mapper_excuse" = x ; then
983 # Check for device-mapper header.
984 AC_CHECK_HEADER([libdevmapper.h], [],
985 [device_mapper_excuse="need libdevmapper header"])
986 fi
987
988 if test x"$device_mapper_excuse" = x ; then
989 # Check for device-mapper library.
990 AC_CHECK_LIB([devmapper], [dm_task_create], [],
991 [device_mapper_excuse="need devmapper library"])
992 fi
993
994 if test x"$device_mapper_excuse" = x ; then
995 # Check for device-mapper library.
996 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
997 [],
998 [device_mapper_excuse="need devmapper library"])
999 fi
1000
1001 if test x"$device_mapper_excuse" = x ; then
1002 LIBDEVMAPPER="-ldevmapper";
1003 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1004 [Define to 1 if you have the devmapper library.])
1005 fi
1006
1007 AC_SUBST([LIBDEVMAPPER])
1008
1009 LIBGEOM=
1010 if test x$host_kernel = xkfreebsd; then
1011 AC_CHECK_LIB([geom], [geom_gettree], [],
1012 [AC_MSG_ERROR([Your platform requires libgeom])])
1013 LIBGEOM="-lgeom"
1014 fi
1015
1016 AC_SUBST([LIBGEOM])
1017
1018 AC_CHECK_LIB([lzma], [lzma_code],
1019 [LIBLZMA="-llzma"
1020 AC_DEFINE([HAVE_LIBLZMA], [1],
1021 [Define to 1 if you have the LZMA library.])],)
1022 AC_SUBST([LIBLZMA])
1023
1024 AC_ARG_ENABLE([libzfs],
1025 [AS_HELP_STRING([--enable-libzfs],
1026 [enable libzfs integration (default=guessed)])])
1027 if test x"$enable_libzfs" = xno ; then
1028 libzfs_excuse="explicitly disabled"
1029 fi
1030
1031 if test x"$libzfs_excuse" = x ; then
1032 # Only check for system headers if libzfs support has not been disabled.
1033 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1034 fi
1035
1036 if test x"$libzfs_excuse" = x ; then
1037 AC_CHECK_LIB([zfs], [libzfs_init],
1038 [],
1039 [libzfs_excuse="need zfs library"])
1040 fi
1041
1042 if test x"$libzfs_excuse" = x ; then
1043 AC_CHECK_LIB([nvpair], [nvlist_print],
1044 [],
1045 [libzfs_excuse="need nvpair library"])
1046 fi
1047
1048 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1049 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1050 fi
1051
1052 if test x"$libzfs_excuse" = x ; then
1053 # We need both libzfs and libnvpair for a successful build.
1054 LIBZFS="-lzfs"
1055 AC_DEFINE([HAVE_LIBZFS], [1],
1056 [Define to 1 if you have the ZFS library.])
1057 LIBNVPAIR="-lnvpair"
1058 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1059 [Define to 1 if you have the NVPAIR library.])
1060 fi
1061
1062 AC_SUBST([LIBZFS])
1063 AC_SUBST([LIBNVPAIR])
1064
1065 LIBS=""
1066
1067 AC_SUBST([FONT_SOURCE])
1068 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1069 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1070 AS_IF([test x$TARGET_APPLE_CC = x1],
1071 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
1072
1073 AC_SUBST(HAVE_ASM_USCORE)
1074 AC_SUBST(ADDR32)
1075 AC_SUBST(DATA32)
1076 AC_SUBST(BSS_START_SYMBOL)
1077 AC_SUBST(END_SYMBOL)
1078 AC_SUBST(PACKAGE)
1079 AC_SUBST(VERSION)
1080 AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
1081 AC_SUBST(NEED_REGISTER_FRAME_INFO)
1082
1083 #
1084 # Automake conditionals
1085 #
1086
1087 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1088 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1089 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1090 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1091 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1092 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1093 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1094 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1095 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1096 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1097 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1098 AM_CONDITIONAL([COND_mips_arc], [test x$target_cpu = xmips -a x$platform = xarc])
1099 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1100 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1101 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1102
1103 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1104 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1105 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1106 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1107 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1108 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1109
1110 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1111 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1112 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1113 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1114 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1115 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1116 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1117 AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
1118 AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
1119 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1120 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1121
1122 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1123 AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin])
1124 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1125
1126 # Output files.
1127 cpudir="${target_cpu}"
1128 if test x${cpudir} = xmipsel; then
1129 cpudir=mips;
1130 fi
1131 grub_CHECK_LINK_DIR
1132 if test x"$link_dir" = xyes ; then
1133 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1134 if test "$platform" != emu ; then
1135 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1136 fi
1137 else
1138 mkdir -p include/grub 2>/dev/null
1139 rm -rf include/grub/cpu
1140 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1141 if test "$platform" != emu ; then
1142 rm -rf include/grub/machine
1143 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1144 fi
1145 fi
1146
1147 AC_CONFIG_FILES([Makefile])
1148 AC_CONFIG_FILES([grub-core/Makefile])
1149 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1150 AC_CONFIG_FILES([po/Makefile.in])
1151 AC_CONFIG_FILES([docs/Makefile])
1152 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1153 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1154 AC_CONFIG_FILES([config.h])
1155
1156 AC_OUTPUT
1157 [
1158 echo "*******************************************************"
1159 echo GRUB2 will be compiled with following components:
1160 echo Platform: "$target_cpu"-"$platform"
1161 if [ x"$platform" = xemu ]; then
1162 if [ x"$grub_emu_usb_excuse" = x ]; then
1163 echo USB support for grub-emu: Yes
1164 else
1165 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1166 fi
1167 if [ x"$grub_emu_sdl_excuse" = x ]; then
1168 echo SDL support for grub-emu: Yes
1169 else
1170 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1171 fi
1172 if [ x"$grub_emu_pci_excuse" = x ]; then
1173 echo PCI support for grub-emu: Yes
1174 else
1175 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1176 fi
1177 fi
1178 if test x"$device_mapper_excuse" = x ; then
1179 echo With devmapper support: Yes
1180 else
1181 echo With devmapper support: No "($device_mapper_excuse)"
1182 fi
1183 if [ x"$enable_mm_debug" = xyes ]; then
1184 echo With memory debugging: Yes
1185 else
1186 echo With memory debugging: No
1187 fi
1188 if [ x"$enable_cache_stats" = xyes ]; then
1189 echo With disk cache statistics: Yes
1190 else
1191 echo With disk cache statistics: No
1192 fi
1193 if [ x"$efiemu_excuse" = x ]; then
1194 echo efiemu runtime: Yes
1195 else
1196 echo efiemu runtime: No "($efiemu_excuse)"
1197 fi
1198 if [ x"$grub_mkfont_excuse" = x ]; then
1199 echo grub-mkfont: Yes
1200 else
1201 echo grub-mkfont: No "($grub_mkfont_excuse)"
1202 fi
1203 if [ x"$grub_mount_excuse" = x ]; then
1204 echo grub-mount: Yes
1205 else
1206 echo grub-mount: No "($grub_mount_excuse)"
1207 fi
1208 if [ x"$starfield_excuse" = x ]; then
1209 echo starfield theme: Yes
1210 else
1211 echo starfield theme: No "($starfield_excuse)"
1212 fi
1213 if [ x"$libzfs_excuse" = x ]; then
1214 echo With libzfs support: Yes
1215 else
1216 echo With libzfs support: No "($libzfs_excuse)"
1217 fi
1218 echo "*******************************************************"
1219 ]