]> git.proxmox.com Git - grub2.git/blob - configure.ac
* configure.ac: Use -melf_*_obsd on openbsd.
[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],[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 grub_TRANSFORM([grub-bios-setup])
54 grub_TRANSFORM([grub-editenv])
55 grub_TRANSFORM([grub-install])
56 grub_TRANSFORM([grub-mkconfig])
57 grub_TRANSFORM([grub-mkfont])
58 grub_TRANSFORM([grub-mkimage])
59 grub_TRANSFORM([grub-glue-efi])
60 grub_TRANSFORM([grub-mklayout])
61 grub_TRANSFORM([grub-mkpasswd-pbkdf2])
62 grub_TRANSFORM([grub-mkrelpath])
63 grub_TRANSFORM([grub-mkrescue])
64 grub_TRANSFORM([grub-probe])
65 grub_TRANSFORM([grub-reboot])
66 grub_TRANSFORM([grub-script-check])
67 grub_TRANSFORM([grub-set-default])
68 grub_TRANSFORM([grub-sparc64-setup])
69 grub_TRANSFORM([grub-render-label])
70
71 # Optimization flag. Allow user to override.
72 if test "x$TARGET_CFLAGS" = x; then
73 TARGET_CFLAGS="$TARGET_CFLAGS -Os"
74 fi
75
76 BUILD_CPPFLAGS="$BUILD_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
77
78 # Default HOST_CPPFLAGS
79 HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
80 HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
81 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
82 HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
83 HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
84
85 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
86 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
87 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
88
89 case "$target_cpu" in
90 i[[3456]]86) target_cpu=i386 ;;
91 amd64) target_cpu=x86_64 ;;
92 sparc) target_cpu=sparc64 ;;
93 mipsel|mips64el)
94 target_cpu=mipsel;
95 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
96 ;;
97 mips|mips64)
98 target_cpu=mips;
99 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
100 ;;
101 arm*)
102 target_cpu=arm;
103 ;;
104 esac
105
106 # Specify the platform (such as firmware).
107 AC_ARG_WITH([platform],
108 AS_HELP_STRING([--with-platform=PLATFORM],
109 [select the host platform [[guessed]]]))
110
111 # Guess the platform if not specified.
112 if test "x$with_platform" = x; then
113 case "$target_cpu"-"$target_vendor" in
114 i386-apple) platform=efi ;;
115 i386-*) platform=pc ;;
116 x86_64-apple) platform=efi ;;
117 x86_64-*) platform=pc ;;
118 powerpc-*) platform=ieee1275 ;;
119 powerpc64-*) platform=ieee1275 ;;
120 sparc64-*) platform=ieee1275 ;;
121 mipsel-*) platform=loongson ;;
122 mips-*) platform=arc ;;
123 ia64-*) platform=efi ;;
124 arm-*) platform=uboot ;;
125 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
126 esac
127 else
128 platform="$with_platform"
129 fi
130
131 case "$target_cpu"-"$platform" in
132 x86_64-efi) ;;
133 x86_64-emu) ;;
134 x86_64-*) target_cpu=i386 ;;
135 powerpc64-ieee1275) target_cpu=powerpc ;;
136 esac
137
138 # Check if the platform is supported, make final adjustments.
139 case "$target_cpu"-"$platform" in
140 i386-efi) ;;
141 x86_64-efi) ;;
142 i386-pc) ;;
143 i386-multiboot) ;;
144 i386-coreboot) ;;
145 i386-linuxbios) platform=coreboot ;;
146 i386-ieee1275) ;;
147 i386-qemu) ;;
148 powerpc-ieee1275) ;;
149 sparc64-ieee1275) ;;
150 ia64-efi) ;;
151 mips-qemu_mips) ;;
152 mips-qemu-mips) platform=qemu_mips;;
153 mips-arc) ;;
154 mipsel-arc) ;;
155 mipsel-qemu_mips) ;;
156 mipsel-qemu-mips) platform=qemu_mips;;
157 mipsel-yeeloong) platform=loongson ;;
158 mipsel-fuloong) platform=loongson ;;
159 mipsel-loongson) ;;
160 arm-uboot) ;;
161 arm-efi) ;;
162 *-emu) ;;
163 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
164 esac
165
166 case "$target_cpu" in
167 i386 | powerpc) target_m32=1 ;;
168 x86_64 | sparc64) target_m64=1 ;;
169 esac
170
171 case "$target_os" in
172 windows* | mingw32*) target_os=cygwin ;;
173 esac
174
175 # This normalizes the names, and creates a new variable ("host_kernel")
176 # while at it, since the mapping is not always 1:1 (e.g. different OSes
177 # using the same kernel type).
178 case "$host_os" in
179 gnu*) host_kernel=hurd ;;
180 linux*) host_kernel=linux ;;
181 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
182 netbsd*) host_kernel=netbsd ;;
183 solaris*) host_kernel=illumos ;;
184 darwin*) host_kernel=xnu ;;
185 cygwin | windows* | mingw32*) host_kernel=windows ;;
186 esac
187
188 case "$platform" in
189 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
190 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
191 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
192 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
193 uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;;
194 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
195 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
196 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
197 loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
198 qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
199 arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;;
200 esac
201 case "$target_cpu" in
202 arm) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARM=1" ;;
203 mips |mipsel) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
204 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
205 esac
206 if test x${target_cpu} = xmipsel ; then
207 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
208 else
209 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"
210 fi
211
212 case "${target_cpu}-$platform" in
213 mips-arc)
214 TARGET_LINK_ADDR=0x88200000
215 TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000
216 ;;
217 mipsel-arc)
218 TARGET_LINK_ADDR=0x80700000
219 TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000
220 ;;
221 mips*-qemu_mips | mips*-loongson)
222 TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000
223 ;;
224 esac
225
226 AC_SUBST(TARGET_LINK_ADDR)
227 AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR)
228
229 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
230
231 AC_SUBST(host_cpu)
232 AC_SUBST(host_os)
233 AC_SUBST(host_kernel)
234
235 AC_SUBST(target_cpu)
236 AC_SUBST(platform)
237
238 # Define default variables
239
240 have_with_bootdir=n
241 AC_ARG_WITH([bootdir],
242 AS_HELP_STRING([--with-bootdir=DIR],
243 [set the name of /boot directory [[guessed]]]),
244 [have_with_bootdir=y],
245 [have_with_bootdir=n])
246 if test x$have_with_bootdir = xy; then
247 bootdirname="$with_bootdir"
248 else
249 case "$host_os" in
250 netbsd* | openbsd*)
251 # Because /boot is used for the boot block in NetBSD and OpenBSD,
252 bootdirname='' ;;
253 *) bootdirname='boot' ;;
254 esac
255 fi
256
257 AC_SUBST(bootdirname)
258 AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname",
259 [Default boot directory name]")
260
261 AC_ARG_WITH([grubdir],
262 AS_HELP_STRING([--with-grubdir=DIR],
263 [set the name of grub directory [[guessed]]]),
264 [grubdirname="$with_grubdir"],
265 [grubdirname="$PACKAGE"])
266
267 AC_SUBST(grubdirname)
268 AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname",
269 [Default grub directory name])
270
271 #
272 # Checks for build programs.
273 #
274
275 # Although cmp is listed in the GNU Coding Standards as a command which
276 # can used directly, OpenBSD lacks cmp in the default installation.
277 AC_CHECK_PROGS([CMP], [cmp])
278 if test "x$CMP" = x; then
279 AC_MSG_ERROR([cmp is not found])
280 fi
281
282 AC_CHECK_PROGS([YACC], [bison])
283 if test "x$YACC" = x; then
284 AC_MSG_ERROR([bison is not found])
285 fi
286
287 AC_PROG_RANLIB
288 AC_PROG_INSTALL
289 AC_PROG_AWK
290 AC_PROG_LEX
291 AC_PROG_YACC
292 AC_PROG_MAKE_SET
293 AC_PROG_MKDIR_P
294 AC_PROG_LN_S
295
296 if test "x$LEX" = "x:"; then
297 AC_MSG_ERROR([flex is not found])
298 else
299 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
300 if test -n "$version" -a "$version" -ge 20535; then
301 :
302 else
303 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
304 fi
305 fi
306
307 # These are not a "must".
308 AC_PATH_PROGS(MAKEINFO, makeinfo true)
309
310 #
311 # Checks for host programs.
312 #
313
314 AC_PROG_CC
315 gl_EARLY
316 AC_PROG_CXX
317 AM_PROG_CC_C_O
318 AM_PROG_AS
319
320 # Must be GCC.
321 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
322
323 AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no)
324
325 AC_GNU_SOURCE
326 AM_GNU_GETTEXT([external])
327 AC_SYS_LARGEFILE
328
329 # Identify characteristics of the host architecture.
330 unset ac_cv_c_bigendian
331
332 AC_C_BIGENDIAN
333 AC_CHECK_SIZEOF(void *)
334 AC_CHECK_SIZEOF(long)
335
336 case "$host_os" in
337 cygwin | windows* | mingw32*)
338 HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
339 CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500"
340 AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>])
341 ;;
342 esac
343
344 grub_apple_cc
345 if test x$grub_cv_apple_cc = xyes ; then
346 HOST_CPPFLAGS="$HOST_CPPFLAGS -fnested-functions"
347 HOST_LDFLAGS="$HOST_LDFLAGS -Wl,-allow_stack_execute"
348 fi
349
350 if test x$USE_NLS = xno; then
351 HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
352 fi
353
354 if test "x$cross_compiling" = xyes; then
355 AC_MSG_WARN([cannot generate manual pages while cross compiling])
356 else
357 AC_PATH_PROG(HELP2MAN, help2man)
358 fi
359
360 # Check for functions and headers.
361 AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
362 AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h)
363
364 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
365 #include <sys/param.h>
366 #include <sys/mount.h>])
367
368 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
369 #include <sys/param.h>
370 #include <sys/mount.h>])
371
372 # For opendisk() and getrawpartition() on NetBSD.
373 # Used in util/deviceiter.c and in util/hostdisk.c.
374 AC_CHECK_HEADER([util.h], [
375 AC_CHECK_LIB([util], [opendisk], [
376 LIBUTIL="-lutil"
377 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
378 ])
379 AC_CHECK_LIB([util], [getrawpartition], [
380 LIBUTIL="-lutil"
381 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
382 ])
383 ])
384 AC_SUBST([LIBUTIL])
385
386 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
387 SAVED_CFLAGS="$CFLAGS"
388 CFLAGS="$HOST_CFLAGS -Wtrampolines"
389 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
390 int va_arg_func (int fixed, va_list args);]], [[]])],
391 [grub_cv_host_cc_wtrampolines=yes],
392 [grub_cv_host_cc_wtrampolines=no])
393 CFLAGS="$SAVED_CFLAGS"
394 ])
395
396 if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
397 HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
398 fi
399
400 #
401 # Check for host and build compilers.
402 #
403 HOST_CC=$CC
404 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc])
405 test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])
406 BUILD_CPP="$BUILD_CC -E"
407
408 # For gnulib.
409 gl_INIT
410
411 #
412 # Check for target programs.
413 #
414
415 # Find tools for the target.
416 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
417 tmp_ac_tool_prefix="$ac_tool_prefix"
418 ac_tool_prefix=$target_alias-
419
420 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
421 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
422 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
423 AC_CHECK_TOOL(TARGET_STRIP, strip)
424 AC_CHECK_TOOL(TARGET_NM, nm)
425 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
426
427 ac_tool_prefix="$tmp_ac_tool_prefix"
428 else
429 if test "x$TARGET_CC" = x; then
430 TARGET_CC=$CC
431 fi
432 AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy)
433 AC_CHECK_TOOL(TARGET_STRIP, strip)
434 AC_CHECK_TOOL(TARGET_NM, nm)
435 AC_CHECK_TOOL(TARGET_RANLIB, ranlib)
436 fi
437
438 AC_SUBST(HOST_CC)
439 AC_SUBST(BUILD_CC)
440 AC_SUBST(BUILD_CFLAGS)
441 AC_SUBST(BUILD_CPPFLAGS)
442 AC_SUBST(TARGET_CC)
443 AC_SUBST(TARGET_NM)
444 AC_SUBST(TARGET_RANLIB)
445 AC_SUBST(TARGET_STRIP)
446 AC_SUBST(TARGET_OBJCOPY)
447
448 # Test the C compiler for the target environment.
449 tmp_CC="$CC"
450 tmp_CFLAGS="$CFLAGS"
451 tmp_LDFLAGS="$LDFLAGS"
452 tmp_CPPFLAGS="$CPPFLAGS"
453 tmp_LIBS="$LIBS"
454 CC="$TARGET_CC"
455 CFLAGS="$TARGET_CFLAGS"
456 CPPFLAGS="$TARGET_CPPFLAGS"
457 LDFLAGS="$TARGET_LDFLAGS"
458 LIBS=""
459
460 grub_PROG_NM_MINUS_P
461 grub_PROG_NM_DEFINED_ONLY
462 AC_SUBST(TARGET_NMFLAGS_MINUS_P)
463 AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY)
464
465 # debug flags.
466 WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign"
467 HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
468 TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
469 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
470
471 # Force no alignment to save space on i386.
472 if test "x$target_cpu" = xi386; then
473 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
474 CFLAGS="$CFLAGS -falign-loops=1"
475 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
476 [grub_cv_cc_falign_loop=yes],
477 [grub_cv_cc_falign_loop=no])
478 ])
479
480 if test "x$grub_cv_cc_falign_loop" = xyes; then
481 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
482 else
483 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
484 fi
485 fi
486
487 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
488 # Some toolchains enable these features by default, but they need
489 # registers that aren't set up properly in GRUB.
490 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
491 fi
492
493 # By default, GCC 4.4 generates .eh_frame sections containing unwind
494 # information in some cases where it previously did not. GRUB doesn't need
495 # these and they just use up vital space. Restore the old compiler
496 # behaviour.
497 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
498 SAVE_CFLAGS="$CFLAGS"
499 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
500 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
501 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
502 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
503 CFLAGS="$SAVE_CFLAGS"
504 ])
505
506 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
507 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
508 fi
509
510 if test x"$target_os" = xcygwin; then
511 AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [
512 CFLAGS="$CFLAGS -fno-reorder-functions"
513 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
514 [grub_cv_cc_no_reorder_functions=yes],
515 [grub_cv_cc_no_reorder_functions=no])
516 ])
517 fi
518
519 if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then
520 TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
521 fi
522
523 # By default, GCC 4.6 generates .eh_frame sections containing unwind
524 # information in some cases where it previously did not. GRUB doesn't need
525 # these and they just use up vital space. Restore the old compiler
526 # behaviour.
527 AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [
528 SAVE_CFLAGS="$CFLAGS"
529 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
530 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
531 [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
532 [grub_cv_cc_fno_asynchronous_unwind_tables=no])
533 CFLAGS="$SAVE_CFLAGS"
534 ])
535
536 if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
537 TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
538 fi
539
540 grub_apple_target_cc
541 if test x$grub_cv_apple_target_cc = xyes ; then
542 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -fnested-functions"
543
544 CFLAGS="$CFLAGS -fnested-functions"
545 TARGET_APPLE_CC=1
546 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], [])
547 if test "x$TARGET_OBJCONV" = x ; then
548 AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.])
549 fi
550 if test "x$TARGET_OBJCONV" = x ; then
551 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
552 fi
553 TARGET_IMG_LDSCRIPT=
554 TARGET_IMG_CFLAGS="-static"
555 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
556 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
557 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
558 TARGET_LDFLAGS_OLDMAGIC=""
559 else
560 TARGET_APPLE_CC=0
561 TARGET_LDFLAGS_OLDMAGIC="-Wl,-N"
562 # Use linker script if present, otherwise use builtin -N script.
563 if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"; then
564 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"
565 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
566 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"
567 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
568 else
569 TARGET_IMG_LDSCRIPT=
570 TARGET_IMG_LDFLAGS='-Wl,-N'
571 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
572 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
573 fi
574 TARGET_IMG_CFLAGS=
575 fi
576
577 AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
578
579 # For platforms where ELF is not the default link format.
580 AC_MSG_CHECKING([for command to convert module to ELF format])
581 case "${target_os}" in
582 cygwin) TARGET_OBJ2ELF='./build-grub-pe2elf';
583 # FIXME: put proper test here
584 NEED_REGISTER_FRAME_INFO=1
585 ;;
586 *) NEED_REGISTER_FRAME_INFO=0 ;;
587 esac
588 AC_MSG_RESULT([$TARGET_OBJ2ELF])
589
590
591 AC_ARG_ENABLE([efiemu],
592 [AS_HELP_STRING([--enable-efiemu],
593 [build and install the efiemu runtimes (default=guessed)])])
594 if test x"$enable_efiemu" = xno ; then
595 efiemu_excuse="explicitly disabled"
596 fi
597 if test x"$target_os" = xcygwin ; then
598 efiemu_excuse="not available on cygwin"
599 fi
600 if test x"$target_cpu" != xi386 ; then
601 efiemu_excuse="only available on i386"
602 fi
603 if test x"$platform" = xefi ; then
604 efiemu_excuse="not available on efi"
605 fi
606 if test x"$efiemu_excuse" = x ; then
607 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
608 SAVED_CFLAGS="$CFLAGS"
609 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
610 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
611 [grub_cv_cc_efiemu=yes],
612 [grub_cv_cc_efiemu=no])
613 CFLAGS="$SAVED_CFLAGS"
614 ])
615 if test x$grub_cv_cc_efiemu = xno; then
616 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
617 fi
618 fi
619 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
620 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
621 fi
622 if test x"$efiemu_excuse" = x ; then
623 enable_efiemu=yes
624 else
625 enable_efiemu=no
626 fi
627 AC_SUBST([enable_efiemu])
628
629 if test "x$target_m32" = x1; then
630 # Force 32-bit mode.
631 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
632 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
633 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32"
634 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
635 TARGET_MODULE_FORMAT="elf32"
636 fi
637
638 if test "x$target_m64" = x1; then
639 # Force 64-bit mode.
640 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
641 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
642 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64"
643 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
644 TARGET_MODULE_FORMAT="elf64"
645 fi
646
647 case "$target_os" in
648 cygwin)
649 ;;
650 freebsd)
651 if test x"$target_cpu" = xi386; then
652 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_fbsd"
653 fi
654 if test x"$target_cpu" = xx86_64; then
655 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64_fbsd"
656 fi
657 ;;
658 openbsd*)
659 if test x"$target_cpu" = xi386; then
660 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386_obsd"
661 fi
662 if test x"$target_cpu" = xx86_64; then
663 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64_obsd"
664 fi
665 ;;
666 *)
667 if test x"$target_cpu" = xi386; then
668 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_i386"
669 fi
670 if test x"$target_cpu" = xx86_64; then
671 TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-melf_x86_64"
672 fi
673 ;;
674 esac
675
676 if test "$target_cpu" = x86_64; then
677 # Use large model to support 4G memory
678 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
679 SAVED_CFLAGS=$CFLAGS
680 CFLAGS="$CFLAGS -m64 -mcmodel=large"
681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
682 [grub_cv_cc_mcmodel=yes],
683 [grub_cv_cc_mcmodel=no])
684 ])
685 if test "x$grub_cv_cc_mcmodel" = xno; then
686 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
687 else
688 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
689 fi
690 fi
691
692 if test "$target_cpu"-"$platform" = x86_64-efi; then
693 # EFI writes to stack below %rsp, we must not use the red zone
694 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
695 CFLAGS="$CFLAGS -m64 -mno-red-zone"
696 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
697 [grub_cv_cc_no_red_zone=yes],
698 [grub_cv_cc_no_red_zone=no])
699 ])
700 if test "x$grub_cv_cc_no_red_zone" = xno; then
701 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
702 fi
703
704 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
705 fi
706
707 #
708 # Compiler features.
709 #
710
711 # Position independent executable.
712 grub_CHECK_PIE
713 [# Need that, because some distributions ship compilers that include
714 # `-fPIE' in the default specs.
715 if [ x"$pie_possible" = xyes ]; then
716 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
717 fi]
718
719 # Position independent executable.
720 grub_CHECK_PIC
721 [# Need that, because some distributions ship compilers that include
722 # `-fPIC' in the default specs.
723 if [ x"$pic_possible" = xyes ]; then
724 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC"
725 fi]
726
727 # Smashing stack protector.
728 grub_CHECK_STACK_PROTECTOR
729 # Need that, because some distributions ship compilers that include
730 # `-fstack-protector' in the default specs.
731 if test "x$ssp_possible" = xyes; then
732 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
733 fi
734 grub_CHECK_STACK_ARG_PROBE
735 # Cygwin's GCC uses alloca() to probe the stackframe on static
736 # stack allocations above some threshold.
737 if test x"$sap_possible" = xyes; then
738 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
739 fi
740
741 # -mno-unaligned-access
742 if test "$target_cpu" = arm; then
743 grub_CHECK_NO_UNALIGNED_ACCESS
744 if test x"$nua_possible" = xyes; then
745 TARGET_CFLAGS="$TARGET_CFLAGS -mno-unaligned-access"
746 fi
747 fi
748
749 AC_ARG_ENABLE([werror],
750 [AS_HELP_STRING([--disable-werror],
751 [do not use -Werror when building GRUB])])
752 if test x"$enable_werror" != xno ; then
753 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
754 HOST_CFLAGS="$HOST_CFLAGS -Werror"
755 fi
756
757 TARGET_CPP="$TARGET_CC -E"
758 TARGET_CCAS=$TARGET_CC
759
760 GRUB_TARGET_CPU="${target_cpu}"
761 GRUB_PLATFORM="${platform}"
762
763 AC_SUBST(GRUB_TARGET_CPU)
764 AC_SUBST(GRUB_PLATFORM)
765
766 AC_SUBST(TARGET_OBJCONV)
767 AC_SUBST(TARGET_CPP)
768 AC_SUBST(TARGET_CCAS)
769 AC_SUBST(TARGET_OBJ2ELF)
770 AC_SUBST(TARGET_APPLE_CC)
771 AC_SUBST(TARGET_MODULE_FORMAT)
772
773 AC_SUBST(TARGET_CFLAGS)
774 AC_SUBST(TARGET_LDFLAGS)
775 AC_SUBST(TARGET_CPPFLAGS)
776 AC_SUBST(TARGET_CCASFLAGS)
777
778 AC_SUBST(TARGET_IMG_LDSCRIPT)
779 AC_SUBST(TARGET_IMG_LDFLAGS)
780 AC_SUBST(TARGET_IMG_CFLAGS)
781 AC_SUBST(TARGET_IMG_BASE_LDOPT)
782
783 AC_SUBST(HOST_CFLAGS)
784 AC_SUBST(HOST_LDFLAGS)
785 AC_SUBST(HOST_CPPFLAGS)
786 AC_SUBST(HOST_CCASFLAGS)
787
788 # Set them to their new values for the tests below.
789 CC="$TARGET_CC"
790 if test "x$TARGET_APPLE_CC" = x1 ; then
791 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
792 else
793 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
794 fi
795 CPPFLAGS="$TARGET_CPPFLAGS"
796 if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
797 LIBS=
798 else
799 LIBS=-lgcc
800 fi
801
802 grub_ASM_USCORE
803 if test x$grub_cv_asm_uscore = xyes; then
804 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
805 else
806 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
807 fi
808
809 # Check for libgcc symbols
810 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
811
812 if test "x$TARGET_APPLE_CC" = x1 ; then
813 CFLAGS="$TARGET_CFLAGS -nostdlib"
814 else
815 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
816 fi
817 LIBS=""
818
819 # Defined in aclocal.m4.
820 grub_PROG_TARGET_CC
821 if test "x$TARGET_APPLE_CC" != x1 ; then
822 grub_PROG_OBJCOPY_ABSOLUTE
823 fi
824 grub_PROG_LD_BUILD_ID_NONE
825 if test "x$target_cpu" = xi386; then
826 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
827 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
828 # Check symbols provided by linker script.
829 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
830 fi
831 grub_CHECK_BSS_START_SYMBOL
832 grub_CHECK_END_SYMBOL
833 fi
834 CFLAGS="$TARGET_CFLAGS"
835 grub_I386_ASM_PREFIX_REQUIREMENT
836 grub_I386_ASM_ADDR32
837 fi
838
839 if test "$platform" != emu; then
840 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
841 SAVED_CPPFLAGS="$CPPFLAGS"
842 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
843 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
844 #include <stddef.h>
845 int va_arg_func (int fixed, va_list args);]], [[]])],
846 [grub_cv_cc_isystem=yes],
847 [grub_cv_cc_isystem=no])
848 CPPFLAGS="$SAVED_CPPFLAGS"
849 ])
850
851 if test x"$grub_cv_cc_isystem" = xyes ; then
852 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
853 fi
854 fi
855
856 AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
857 SAVED_CFLAGS="$CFLAGS"
858 CFLAGS="$TARGET_CFLAGS -Wtrampolines"
859 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
860 int va_arg_func (int fixed, va_list args);]], [[]])],
861 [grub_cv_cc_wtrampolines=yes],
862 [grub_cv_cc_wtrampolines=no])
863 CFLAGS="$SAVED_CFLAGS"
864 ])
865
866 if test x"$grub_cv_cc_wtrampolines" = xyes ; then
867 TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
868 fi
869
870 # Restore the flags.
871 CC="$tmp_CC"
872 CFLAGS="$tmp_CFLAGS"
873 CPPFLAGS="$tmp_CPPFLAGS"
874 LDFLAGS="$tmp_LDFLAGS"
875 LIBS="$tmp_LIBS"
876
877 #
878 # Check for options.
879 #
880
881 # Memory manager debugging.
882 AC_ARG_ENABLE([mm-debug],
883 AS_HELP_STRING([--enable-mm-debug],
884 [include memory manager debugging]),
885 [AC_DEFINE([MM_DEBUG], [1],
886 [Define to 1 if you enable memory manager debugging.])])
887
888 AC_ARG_ENABLE([cache-stats],
889 AS_HELP_STRING([--enable-cache-stats],
890 [enable disk cache statistics collection]))
891
892 if test x$enable_cache_stats = xyes; then
893 DISK_CACHE_STATS=1
894 else
895 DISK_CACHE_STATS=0
896 fi
897 AC_SUBST([DISK_CACHE_STATS])
898
899 AC_ARG_ENABLE([boot-time],
900 AS_HELP_STRING([--enable-boot-time],
901 [enable boot time statistics collection]))
902
903 if test x$enable_boot_time = xyes; then
904 BOOT_TIME_STATS=1
905 else
906 BOOT_TIME_STATS=0
907 fi
908 AC_SUBST([BOOT_TIME_STATS])
909
910 AC_ARG_ENABLE([grub-emu-usb],
911 [AS_HELP_STRING([--enable-grub-emu-usb],
912 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
913
914 AC_ARG_ENABLE([grub-emu-sdl],
915 [AS_HELP_STRING([--enable-grub-emu-sdl],
916 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
917
918 AC_ARG_ENABLE([grub-emu-pci],
919 [AS_HELP_STRING([--enable-grub-emu-pci],
920 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
921
922 if test "$platform" = emu; then
923
924 if test x"$enable_grub_emu_usb" != xyes ; then
925 grub_emu_usb_excuse="not enabled"
926 fi
927
928 if test x"$enable_grub_emu_pci" = xyes ; then
929 grub_emu_usb_excuse="conflicts with PCI support"
930 fi
931
932 [if [ x"$grub_emu_usb_excuse" = x ]; then
933 # Check for libusb libraries.]
934 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
935 [grub_emu_usb_excuse=["need libusb library"]])
936 AC_SUBST([LIBUSB])
937 [fi]
938 [if [ x"$grub_emu_usb_excuse" = x ]; then
939 # Check for headers.]
940 AC_CHECK_HEADERS([usb.h], [],
941 [grub_emu_usb_excuse=["need libusb headers"]])
942 [fi]
943 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
944 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
945 fi
946 if test x"$grub_emu_usb_excuse" = x ; then
947 enable_grub_emu_usb=yes
948 else
949 enable_grub_emu_usb=no
950 fi
951
952 if test x"$enable_grub_emu_sdl" = xno ; then
953 grub_emu_sdl_excuse="explicitely disabled"
954 fi
955 [if [ x"$grub_emu_sdl_excuse" = x ]; then
956 # Check for libSDL libraries.]
957 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
958 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
959 AC_SUBST([LIBSDL])
960 [fi]
961
962 [if [ x"$grub_emu_sdl_excuse" = x ]; then
963 # Check for headers.]
964 AC_CHECK_HEADERS([SDL/SDL.h], [],
965 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
966 [fi]
967
968 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
969 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
970 fi
971 if test x"$grub_emu_sdl_excuse" = x ; then
972 enable_grub_emu_sdl=yes
973 else
974 enable_grub_emu_sdl=no
975 fi
976
977 if test x"$enable_grub_emu_pci" != xyes ; then
978 grub_emu_pci_excuse="not enabled"
979 fi
980
981 if test x"$enable_grub_emu_usb" = xyes ; then
982 grub_emu_pci_excuse="conflicts with USB support"
983 fi
984
985 [if [ x"$grub_emu_pci_excuse" = x ]; then
986 # Check for libpci libraries.]
987 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
988 [grub_emu_pci_excuse=["need libpciaccess library"]])
989 AC_SUBST([LIBPCIACCESS])
990 [fi]
991 [if [ x"$grub_emu_pci_excuse" = x ]; then
992 # Check for headers.]
993 AC_CHECK_HEADERS([pci/pci.h], [],
994 [grub_emu_pci_excuse=["need libpciaccess headers"]])
995 [fi]
996
997 if test x"$grub_emu_pci_excuse" = x ; then
998 enable_grub_emu_pci=yes
999 else
1000
1001 enable_grub_emu_pci=no
1002 fi
1003
1004 AC_SUBST([enable_grub_emu_sdl])
1005 AC_SUBST([enable_grub_emu_usb])
1006 AC_SUBST([enable_grub_emu_pci])
1007 fi
1008
1009 AC_ARG_ENABLE([grub-mkfont],
1010 [AS_HELP_STRING([--enable-grub-mkfont],
1011 [build and install the `grub-mkfont' utility (default=guessed)])])
1012 if test x"$enable_grub_mkfont" = xno ; then
1013 grub_mkfont_excuse="explicitly disabled"
1014 fi
1015
1016 if test x"$grub_mkfont_excuse" = x ; then
1017 # Check for freetype libraries.
1018 AC_CHECK_TOOLS([FREETYPE], [freetype-config])
1019 if test "x$FREETYPE" = x ; then
1020 grub_mkfont_excuse=["need freetype2 library"]
1021 fi
1022 fi
1023
1024 unset ac_cv_header_ft2build_h
1025
1026 if test x"$grub_mkfont_excuse" = x ; then
1027 # Check for freetype libraries.
1028 freetype_cflags=`$FREETYPE --cflags`
1029 freetype_libs=`$FREETYPE --libs`
1030 SAVED_CPPFLAGS="$CPPFLAGS"
1031 CPPFLAGS="$CPPFLAGS $freetype_cflags"
1032 AC_CHECK_HEADERS([ft2build.h], [],
1033 [grub_mkfont_excuse=["need freetype2 headers"]])
1034 CPPFLAGS="$SAVED_CPPFLAGS"
1035 fi
1036
1037 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
1038 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
1039 fi
1040 if test x"$grub_mkfont_excuse" = x ; then
1041 enable_grub_mkfont=yes
1042 else
1043 enable_grub_mkfont=no
1044 fi
1045 AC_SUBST([enable_grub_mkfont])
1046 AC_SUBST([freetype_cflags])
1047 AC_SUBST([freetype_libs])
1048
1049 SAVED_CC="$CC"
1050 SAVED_CPP="$CPP"
1051 SAVED_CFLAGS="$CFLAGS"
1052 SAVED_CPPFLAGS="$CPPFLAGS"
1053 CC="$BUILD_CC"
1054 CPP="$BUILD_CPP"
1055 CFLAGS="$BUILD_CFLAGS"
1056 CPPFLAGS="$BUILD_CPPFLAGS"
1057
1058 unset ac_cv_c_bigendian
1059 unset ac_cv_header_ft2build_h
1060
1061 AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)])
1062 AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)])
1063 AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err])
1064
1065 if test x$BUILD_WORDS_BIGENDIAN = xerr ; then
1066 AC_MSG_ERROR([couldnt determine build endianness])
1067 fi
1068
1069 AC_SUBST([BUILD_SIZEOF_LONG])
1070 AC_SUBST([BUILD_SIZEOF_VOID_P])
1071 AC_SUBST([BUILD_WORDS_BIGENDIAN])
1072
1073 if test x"$grub_build_mkfont_excuse" = x ; then
1074 # Check for freetype libraries.
1075 AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config])
1076 if test "x$BUILD_FREETYPE" = x ; then
1077 grub_build_mkfont_excuse=["need freetype2 library"]
1078 fi
1079 fi
1080
1081 if test x"$grub_build_mkfont_excuse" = x ; then
1082 # Check for freetype libraries.
1083 build_freetype_cflags=`$BUILD_FREETYPE --cflags`
1084 build_freetype_libs=`$BUILD_FREETYPE --libs`
1085 SAVED_CPPFLAGS_2="$CPPFLAGS"
1086 CPPFLAGS="$CPPFLAGS $build_freetype_cflags"
1087 AC_CHECK_HEADERS([ft2build.h], [],
1088 [grub_build_mkfont_excuse=["need freetype2 headers"]])
1089 CPPFLAGS="$SAVED_CPPFLAGS_2"
1090 fi
1091
1092 if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then
1093 AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled])
1094 fi
1095 if test x"$grub_build_mkfont_excuse" = x ; then
1096 enable_build_grub_mkfont=yes
1097 else
1098 enable_build_grub_mkfont=no
1099 fi
1100 if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
1101 AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports needs build-time grub-mkfont])
1102 fi
1103
1104 AC_SUBST([build_freetype_cflags])
1105 AC_SUBST([build_freetype_libs])
1106
1107 CC="$SAVED_CC"
1108 CPP="$SAVED_CPP"
1109 CFLAGS="$SAVED_CFLAGS"
1110 CPPFLAGS="$SAVED_CPPFLAGS"
1111
1112
1113 DJVU_FONT_SOURCE=
1114
1115 starfield_excuse=
1116
1117 if test x"$enable_build_grub_mkfont" = xno ; then
1118 starfield_excuse="No build-time grub-mkfont"
1119 fi
1120
1121 if test x"$starfield_excuse" = x; then
1122 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1123 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
1124 if test -f "$dir/DejaVuSans.$ext"; then
1125 DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
1126 break 2
1127 fi
1128 done
1129 done
1130
1131 if test "x$DJVU_FONT_SOURCE" = x; then
1132 starfield_excuse="No DejaVu found"
1133 fi
1134 fi
1135
1136 AC_SUBST([DJVU_FONT_SOURCE])
1137
1138 FONT_SOURCE=
1139
1140 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
1141 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do
1142 if test -f "$dir/unifont.$ext"; then
1143 FONT_SOURCE="$dir/unifont.$ext"
1144 break 2
1145 fi
1146 done
1147 done
1148
1149 if test x"$enable_build_grub_mkfont" = xno ; then
1150 FONT_SOURCE=
1151 fi
1152
1153 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 ); then
1154 AC_MSG_ERROR([qemu, powerpc-ieee1275 and loongson ports need unifont])
1155 fi
1156
1157 AC_SUBST([FONT_SOURCE])
1158
1159 if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then
1160 grub_build_mkfont_excuse="no fonts"
1161 fi
1162
1163
1164 AC_ARG_ENABLE([grub-mount],
1165 [AS_HELP_STRING([--enable-grub-mount],
1166 [build and install the `grub-mount' utility (default=guessed)])])
1167 if test x"$enable_grub_mount" = xno ; then
1168 grub_mount_excuse="explicitly disabled"
1169 fi
1170
1171 if test x"$grub_mount_excuse" = x ; then
1172 AC_CHECK_LIB([fuse], [fuse_main_real], [],
1173 [grub_mount_excuse="need FUSE library"])
1174 fi
1175
1176 if test x"$grub_mount_excuse" = x ; then
1177 # Check for fuse headers.
1178 SAVED_CPPFLAGS="$CPPFLAGS"
1179 CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
1180 AC_CHECK_HEADERS([fuse/fuse.h], [],
1181 [grub_mount_excuse=["need FUSE headers"]])
1182 CPPFLAGS="$SAVED_CPPFLAGS"
1183 fi
1184
1185 if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then
1186 AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled])
1187 fi
1188 if test x"$grub_mount_excuse" = x ; then
1189 enable_grub_mount=yes
1190 else
1191 enable_grub_mount=no
1192 fi
1193 AC_SUBST([enable_grub_mount])
1194
1195 AC_ARG_ENABLE([device-mapper],
1196 [AS_HELP_STRING([--enable-device-mapper],
1197 [enable Linux device-mapper support (default=guessed)])])
1198 if test x"$enable_device_mapper" = xno ; then
1199 device_mapper_excuse="explicitly disabled"
1200 fi
1201
1202 if test x"$device_mapper_excuse" = x ; then
1203 # Check for device-mapper header.
1204 AC_CHECK_HEADER([libdevmapper.h], [],
1205 [device_mapper_excuse="need libdevmapper header"])
1206 fi
1207
1208 if test x"$device_mapper_excuse" = x ; then
1209 # Check for device-mapper library.
1210 AC_CHECK_LIB([devmapper], [dm_task_create], [],
1211 [device_mapper_excuse="need devmapper library"])
1212 fi
1213
1214 if test x"$device_mapper_excuse" = x ; then
1215 # Check for device-mapper library.
1216 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
1217 [],
1218 [device_mapper_excuse="need devmapper library"])
1219 fi
1220
1221 if test x"$device_mapper_excuse" = x ; then
1222 LIBDEVMAPPER="-ldevmapper";
1223 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
1224 [Define to 1 if you have the devmapper library.])
1225 fi
1226
1227 AC_SUBST([LIBDEVMAPPER])
1228
1229 LIBGEOM=
1230 if test x$host_kernel = xkfreebsd; then
1231 AC_CHECK_LIB([geom], [geom_gettree], [],
1232 [AC_MSG_ERROR([Your platform requires libgeom])])
1233 LIBGEOM="-lgeom"
1234 fi
1235
1236 AC_SUBST([LIBGEOM])
1237
1238 AC_CHECK_LIB([lzma], [lzma_code],
1239 [LIBLZMA="-llzma"
1240 AC_DEFINE([HAVE_LIBLZMA], [1],
1241 [Define to 1 if you have the LZMA library.])],)
1242 AC_SUBST([LIBLZMA])
1243
1244 AC_ARG_ENABLE([libzfs],
1245 [AS_HELP_STRING([--enable-libzfs],
1246 [enable libzfs integration (default=guessed)])])
1247 if test x"$enable_libzfs" = xno ; then
1248 libzfs_excuse="explicitly disabled"
1249 fi
1250
1251 if test x"$libzfs_excuse" = x ; then
1252 # Only check for system headers if libzfs support has not been disabled.
1253 AC_CHECK_HEADERS(libzfs.h libnvpair.h)
1254 fi
1255
1256 if test x"$libzfs_excuse" = x ; then
1257 AC_CHECK_LIB([zfs], [libzfs_init],
1258 [],
1259 [libzfs_excuse="need zfs library"])
1260 fi
1261
1262 if test x"$libzfs_excuse" = x ; then
1263 AC_CHECK_LIB([nvpair], [nvlist_print],
1264 [],
1265 [libzfs_excuse="need nvpair library"])
1266 fi
1267
1268 if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then
1269 AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied])
1270 fi
1271
1272 if test x"$libzfs_excuse" = x ; then
1273 # We need both libzfs and libnvpair for a successful build.
1274 LIBZFS="-lzfs"
1275 AC_DEFINE([HAVE_LIBZFS], [1],
1276 [Define to 1 if you have the ZFS library.])
1277 LIBNVPAIR="-lnvpair"
1278 AC_DEFINE([HAVE_LIBNVPAIR], [1],
1279 [Define to 1 if you have the NVPAIR library.])
1280 fi
1281
1282 AC_SUBST([LIBZFS])
1283 AC_SUBST([LIBNVPAIR])
1284
1285 LIBS=""
1286
1287 AC_SUBST([FONT_SOURCE])
1288 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
1289 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
1290 AS_IF([test x$TARGET_APPLE_CC = x1],
1291 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
1292
1293 AC_SUBST(HAVE_ASM_USCORE)
1294 AC_SUBST(ADDR32)
1295 AC_SUBST(DATA32)
1296 AC_SUBST(BSS_START_SYMBOL)
1297 AC_SUBST(END_SYMBOL)
1298 AC_SUBST(PACKAGE)
1299 AC_SUBST(VERSION)
1300 AC_SUBST(NEED_REGISTER_FRAME_INFO)
1301
1302 #
1303 # Automake conditionals
1304 #
1305
1306 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
1307 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
1308 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
1309 AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
1310 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
1311 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
1312 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
1313 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
1314 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
1315 AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson])
1316 AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips])
1317 AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc])
1318 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
1319 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
1320 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
1321 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
1322 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
1323 AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ])
1324 AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot])
1325 AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
1326
1327 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
1328 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
1329 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
1330 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
1331 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
1332 AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
1333 AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
1334
1335 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
1336 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
1337 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
1338 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
1339 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
1340 AM_CONDITIONAL([COND_BUILD_GRUB_MKFONT], [test x$enable_build_grub_mkfont = xyes])
1341 AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes])
1342 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
1343 AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
1344 AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
1345 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
1346 AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1])
1347 AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1])
1348
1349 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes])
1350
1351 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
1352 AM_CONDITIONAL([COND_CYGWIN], [test x$target_os = xcygwin])
1353 AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x])
1354
1355 # Output files.
1356 cpudir="${target_cpu}"
1357 if test x${cpudir} = xmipsel; then
1358 cpudir=mips;
1359 fi
1360 grub_CHECK_LINK_DIR
1361 if test x"$link_dir" = xyes ; then
1362 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
1363 if test "$platform" != emu ; then
1364 AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
1365 fi
1366 else
1367 mkdir -p include/grub 2>/dev/null
1368 rm -rf include/grub/cpu
1369 cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
1370 if test "$platform" != emu ; then
1371 rm -rf include/grub/machine
1372 cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
1373 fi
1374 fi
1375
1376 AC_CONFIG_FILES([Makefile])
1377 AC_CONFIG_FILES([grub-core/Makefile])
1378 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
1379 AC_CONFIG_FILES([po/Makefile.in])
1380 AC_CONFIG_FILES([docs/Makefile])
1381 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
1382 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
1383 AC_CONFIG_FILES([config.h])
1384
1385 AC_OUTPUT
1386 [
1387 echo "*******************************************************"
1388 echo GRUB2 will be compiled with following components:
1389 echo Platform: "$target_cpu"-"$platform"
1390 if [ x"$platform" = xemu ]; then
1391 if [ x"$grub_emu_usb_excuse" = x ]; then
1392 echo USB support for grub-emu: Yes
1393 else
1394 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
1395 fi
1396 if [ x"$grub_emu_sdl_excuse" = x ]; then
1397 echo SDL support for grub-emu: Yes
1398 else
1399 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
1400 fi
1401 if [ x"$grub_emu_pci_excuse" = x ]; then
1402 echo PCI support for grub-emu: Yes
1403 else
1404 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
1405 fi
1406 fi
1407 if test x"$device_mapper_excuse" = x ; then
1408 echo With devmapper support: Yes
1409 else
1410 echo With devmapper support: No "($device_mapper_excuse)"
1411 fi
1412 if [ x"$enable_mm_debug" = xyes ]; then
1413 echo With memory debugging: Yes
1414 else
1415 echo With memory debugging: No
1416 fi
1417 if [ x"$enable_cache_stats" = xyes ]; then
1418 echo With disk cache statistics: Yes
1419 else
1420 echo With disk cache statistics: No
1421 fi
1422
1423 if [ x"$enable_boot_time" = xyes ]; then
1424 echo With boot time statistics: Yes
1425 else
1426 echo With boot time statistics: No
1427 fi
1428
1429 if [ x"$efiemu_excuse" = x ]; then
1430 echo efiemu runtime: Yes
1431 else
1432 echo efiemu runtime: No "($efiemu_excuse)"
1433 fi
1434 if [ x"$grub_mkfont_excuse" = x ]; then
1435 echo grub-mkfont: Yes
1436 else
1437 echo grub-mkfont: No "($grub_mkfont_excuse)"
1438 fi
1439 if [ x"$grub_mount_excuse" = x ]; then
1440 echo grub-mount: Yes
1441 else
1442 echo grub-mount: No "($grub_mount_excuse)"
1443 fi
1444 if [ x"$starfield_excuse" = x ]; then
1445 echo starfield theme: Yes
1446 else
1447 echo starfield theme: No "($starfield_excuse)"
1448 fi
1449 if [ x"$libzfs_excuse" = x ]; then
1450 echo With libzfs support: Yes
1451 else
1452 echo With libzfs support: No "($libzfs_excuse)"
1453 fi
1454 if [ x"$grub_build_mkfont_excuse" = x ]; then
1455 echo Build-time grub-mkfont: Yes
1456 if test "x$FONT_SOURCE" = x ; then
1457 echo "Without unifont"
1458 else
1459 echo "With unifont from $FONT_SOURCE"
1460 fi
1461 else
1462 echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)"
1463 echo "Without unifont (no build-time grub-mkfont)"
1464 fi
1465 if test "x$LIBLZMA" = x ; then
1466 echo "Without liblzma (no support for XZ-compressed mips images)"
1467 else
1468 echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)"
1469 fi
1470 echo "*******************************************************"
1471 ]