]> git.proxmox.com Git - grub2.git/blob - configure.ac
Fix po directory handling.
[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],[1.98],[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=mips;
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 mips-*) platform=yeeloong ;;
100 *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
101 esac
102 else
103 platform="$with_platform"
104 fi
105
106 # Adjust CPU unless target was explicitly specified.
107 if test -z "$target_alias"; then
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 fi
115
116 # Check if the platform is supported, make final adjustments.
117 case "$target_cpu"-"$platform" in
118 i386-efi) ;;
119 x86_64-efi) ;;
120 i386-pc) ;;
121 i386-multiboot) ;;
122 i386-coreboot) ;;
123 i386-linuxbios) platform=coreboot ;;
124 i386-ieee1275) ;;
125 i386-qemu) ;;
126 powerpc-ieee1275) ;;
127 sparc64-ieee1275) ;;
128 mips-qemu-mips) ;;
129 mips-yeeloong) ;;
130 *-emu) ;;
131 *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
132 esac
133
134 case "$target_cpu" in
135 i386 | powerpc) target_m32=1 ;;
136 x86_64 | sparc64) target_m64=1 ;;
137 esac
138
139 case "$host_os" in
140 mingw32*) host_os=cygwin ;;
141 esac
142
143 # This normalizes the names, and creates a new variable ("host_kernel")
144 # while at it, since the mapping is not always 1:1 (e.g. different OSes
145 # using the same kernel type).
146 case "$host_os" in
147 gnu*) host_kernel=hurd ;;
148 linux*) host_kernel=linux ;;
149 freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
150 netbsd*) host_kernel=netbsd ;;
151 cygwin) host_kernel=windows ;;
152 esac
153
154 case "$platform" in
155 coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;;
156 multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;;
157 efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;;
158 ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;;
159 qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;;
160 pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;;
161 emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;;
162 yeeloong) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
163 qemu-mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
164 esac
165 case "$target_cpu" in
166 mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;;
167 sparc64) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
168 esac
169 machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
170
171 HOST_CPPFLAGS="$HOST_CPPFLAGS $machine_CPPFLAGS"
172 TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
173
174 AC_SUBST(host_cpu)
175 AC_SUBST(host_os)
176 AC_SUBST(host_kernel)
177
178 AC_SUBST(target_cpu)
179 AC_SUBST(platform)
180
181 # Define default variables
182 case "$host_os" in
183 netbsd* | openbsd*)
184 # Because /boot is used for the boot block in NetBSD and OpenBSD,
185 bootdirname='' ;;
186 *) bootdirname='boot' ;;
187 esac
188 bootdirname=`echo "$bootdirname" | sed "$program_transform_name"`
189 AC_SUBST(bootdirname)
190
191 grubdirname=`echo "$PACKAGE" | sed "$program_transform_name"`
192 AC_SUBST(grubdirname)
193
194 #
195 # Checks for build programs.
196 #
197
198 # Although cmp is listed in the GNU Coding Standards as a command which
199 # can used directly, OpenBSD lacks cmp in the default installation.
200 AC_CHECK_PROGS([CMP], [cmp])
201 if test "x$CMP" = x; then
202 AC_MSG_ERROR([cmp is not found])
203 fi
204
205 AC_CHECK_PROGS([YACC], [bison])
206 if test "x$YACC" = x; then
207 AC_MSG_ERROR([bison is not found])
208 fi
209
210 FONT_SOURCE=
211
212 for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
213 for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
214 if test -f "$dir/unifont.$ext"; then
215 FONT_SOURCE="$dir/unifont.$ext"
216 break 2
217 fi
218 done
219 done
220
221 if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xyeeloong ); then
222 AC_MSG_ERROR([qemu and yeeloong ports need unifont])
223 fi
224
225 AC_SUBST([FONT_SOURCE])
226
227 AC_PROG_RANLIB
228 AC_PROG_INSTALL
229 AC_PROG_AWK
230 AC_PROG_LEX
231 AC_PROG_YACC
232 AC_PROG_MAKE_SET
233 AC_PROG_MKDIR_P
234
235 if test "x$LEX" = "x:"; then
236 AC_MSG_ERROR([flex is not found])
237 else
238 version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
239 if test -n "$version" -a "$version" -ge 20535; then
240 :
241 else
242 AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
243 fi
244 fi
245
246 # These are not a "must".
247 AC_PATH_PROG(MAKEINFO, makeinfo)
248
249 #
250 # Checks for host programs.
251 #
252
253 AC_PROG_CC
254 gl_EARLY
255 AM_PROG_CC_C_O
256 AM_PROG_AS
257
258 # Must be GCC.
259 test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
260
261 AC_GNU_SOURCE
262 AM_GNU_GETTEXT([external])
263 AC_SYS_LARGEFILE
264
265 # Identify characteristics of the host architecture.
266 AC_C_BIGENDIAN
267 AC_CHECK_SIZEOF(void *)
268 AC_CHECK_SIZEOF(long)
269
270 grub_apple_cc
271 if test x$grub_cv_apple_cc = xyes ; then
272 HOST_CPPFLAGS="$HOST_CPPFLAGS -DAPPLE_CC=1"
273 HOST_CFLAGS="$HOST_CFLAGS -fnested-functions"
274 fi
275
276 if test "x$cross_compiling" = xyes; then
277 AC_MSG_WARN([cannot generate manual pages while cross compiling])
278 else
279 AC_PATH_PROG(HELP2MAN, help2man)
280 fi
281
282 # Check for functions and headers.
283 AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf getextmntent)
284 AC_CHECK_HEADERS(libzfs.h libnvpair.h sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h)
285
286 AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
287 #include <sys/param.h>
288 #include <sys/mount.h>])
289
290 AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default
291 #include <sys/param.h>
292 #include <sys/mount.h>])
293
294 # For opendisk() and getrawpartition() on NetBSD.
295 # Used in util/deviceiter.c and in util/hostdisk.c.
296 AC_CHECK_HEADER([util.h], [
297 AC_CHECK_LIB([util], [opendisk], [
298 LIBUTIL="-lutil"
299 AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
300 ])
301 AC_CHECK_LIB([util], [getrawpartition], [
302 LIBUTIL="-lutil"
303 AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
304 ])
305 ])
306 AC_SUBST([LIBUTIL])
307
308 #
309 # Check for host and build compilers.
310 #
311 HOST_CC=$CC
312 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
313 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
314
315 # For gnulib.
316 gl_INIT
317
318 #
319 # Check for target programs.
320 #
321
322 # Find tools for the target.
323 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
324 tmp_ac_tool_prefix="$ac_tool_prefix"
325 ac_tool_prefix=$target_alias-
326
327 AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
328 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
329 AC_CHECK_TOOL(OBJCOPY, objcopy)
330 AC_CHECK_TOOL(STRIP, strip)
331 AC_CHECK_TOOL(NM, nm)
332
333 ac_tool_prefix="$tmp_ac_tool_prefix"
334 else
335 if test "x$TARGET_CC" = x; then
336 TARGET_CC=$CC
337 fi
338 AC_CHECK_TOOL(OBJCOPY, objcopy)
339 AC_CHECK_TOOL(STRIP, strip)
340 AC_CHECK_TOOL(NM, nm)
341 fi
342 AC_SUBST(HOST_CC)
343 AC_SUBST(BUILD_CC)
344 AC_SUBST(TARGET_CC)
345
346 # Test the C compiler for the target environment.
347 tmp_CC="$CC"
348 tmp_CFLAGS="$CFLAGS"
349 tmp_LDFLAGS="$LDFLAGS"
350 tmp_CPPFLAGS="$CPPFLAGS"
351 tmp_LIBS="$LIBS"
352 CC="$TARGET_CC"
353 CFLAGS="$TARGET_CFLAGS"
354 CPPFLAGS="$TARGET_CPPFLAGS"
355 LDFLAGS="$TARGET_LDFLAGS"
356 LIBS=""
357
358 # debug flags.
359 TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g"
360 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
361
362 # Force no alignment to save space on i386.
363 if test "x$target_cpu" = xi386; then
364 AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
365 CFLAGS="$CFLAGS -falign-loops=1"
366 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
367 [grub_cv_cc_falign_loop=yes],
368 [grub_cv_cc_falign_loop=no])
369 ])
370
371 if test "x$grub_cv_cc_falign_loop" = xyes; then
372 TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
373 else
374 TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
375 fi
376
377 # Some toolchains enable these features by default, but they need
378 # registers that aren't set up properly in GRUB.
379 TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
380 fi
381
382 # By default, GCC 4.4 generates .eh_frame sections containing unwind
383 # information in some cases where it previously did not. GRUB doesn't need
384 # these and they just use up vital space. Restore the old compiler
385 # behaviour.
386 AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
387 SAVE_CFLAGS="$CFLAGS"
388 CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
389 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
390 [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
391 [grub_cv_cc_fno_dwarf2_cfi_asm=no])
392 CFLAGS="$SAVE_CFLAGS"
393 ])
394
395 if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
396 TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
397 fi
398
399 grub_apple_target_cc
400 if test x$grub_cv_apple_target_cc = xyes ; then
401 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DAPPLE_CC=1"
402 TARGET_CFLAGS="$TARGET_CFLAGS -fnested-functions"
403
404 CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
405 TARGET_APPLE_CC=1
406 AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
407 if test "x$OBJCONV" = x ; then
408 AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
409 fi
410 if test "x$OBJCONV" = x ; then
411 AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
412 fi
413 TARGET_IMG_LDSCRIPT=
414 TARGET_IMG_CFLAGS="-static"
415 TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
416 TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20'
417 TARGET_IMG_BASE_LDOPT="-Wl,-image_base"
418 else
419 TARGET_APPLE_CC=0
420 # Use linker script if present, otherwise use builtin -N script.
421 if test -f "${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
422 TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
423 TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}"
424 TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
425 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
426 else
427 TARGET_IMG_LDSCRIPT=
428 TARGET_IMG_LDFLAGS='-Wl,-N'
429 TARGET_IMG_LDFLAGS_AC='-Wl,-N'
430 TARGET_IMG_BASE_LDOPT="-Wl,-Ttext"
431 fi
432 TARGET_IMG_CFLAGS=
433 fi
434
435 # For platforms where ELF is not the default link format.
436 AC_MSG_CHECKING([for command to convert module to ELF format])
437 case "${host_os}" in
438 cygwin) TARGET_OBJ2ELF='$(grub_utildir)/grub-pe2elf';
439 # FIXME: put proper test here
440 NEED_REGISTER_FRAME_INFO=1
441 ;;
442 *) NEED_REGISTER_FRAME_INFO=0 ;;
443 esac
444 AC_MSG_RESULT([$TARGET_OBJ2ELF])
445
446 if test "x$target_m32" = x1; then
447 # Force 32-bit mode.
448 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
449 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
450 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
451 TARGET_MODULE_FORMAT="elf32"
452 fi
453
454 if test "x$target_m64" = x1; then
455 # Force 64-bit mode.
456 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
457 TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
458 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
459 TARGET_MODULE_FORMAT="elf64"
460 fi
461
462 if test "$target_cpu"-"$platform" = x86_64-efi; then
463 # Use large model to support 4G memory
464 AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
465 SAVED_CFLAGS=$CFLAGS
466 CFLAGS="$CFLAGS -m64 -mcmodel=large"
467 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
468 [grub_cv_cc_mcmodel=yes],
469 [grub_cv_cc_mcmodel=no])
470 ])
471 if test "x$grub_cv_cc_mcmodel" = xno; then
472 AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
473 else
474 TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
475 fi
476
477 # EFI writes to stack below %rsp, we must not use the red zone
478 AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
479 CFLAGS="$CFLAGS -m64 -mno-red-zone"
480 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
481 [grub_cv_cc_no_red_zone=yes],
482 [grub_cv_cc_no_red_zone=no])
483 ])
484 if test "x$grub_cv_cc_no_red_zone" = xno; then
485 AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
486 fi
487
488 TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
489 fi
490
491 #
492 # Compiler features.
493 #
494
495 # Need __enable_execute_stack() for nested function trampolines?
496 grub_CHECK_ENABLE_EXECUTE_STACK
497
498 # Position independent executable.
499 grub_CHECK_PIE
500 [# Need that, because some distributions ship compilers that include
501 # `-fPIE' in the default specs.
502 if [ x"$pie_possible" = xyes ]; then
503 TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
504 fi]
505
506 # Smashing stack protector.
507 grub_CHECK_STACK_PROTECTOR
508 # Need that, because some distributions ship compilers that include
509 # `-fstack-protector' in the default specs.
510 if test "x$ssp_possible" = xyes; then
511 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
512 fi
513 grub_CHECK_STACK_ARG_PROBE
514 # Cygwin's GCC uses alloca() to probe the stackframe on static
515 # stack allocations above some threshold.
516 if test x"$sap_possible" = xyes; then
517 TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
518 fi
519
520 AC_ARG_ENABLE([werror],
521 [AS_HELP_STRING([--disable-werror],
522 [do not use -Werror when building GRUB])])
523 if test x"$enable_werror" != xno ; then
524 TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
525 fi
526
527 TARGET_CPP="$TARGET_CC -E"
528 TARGET_CCAS=$TARGET_CC
529
530 AC_SUBST(OBJCONV)
531 AC_SUBST(TARGET_CPP)
532 AC_SUBST(TARGET_CCAS)
533 AC_SUBST(TARGET_OBJ2ELF)
534 AC_SUBST(TARGET_APPLE_CC)
535 AC_SUBST(TARGET_MODULE_FORMAT)
536
537 AC_SUBST(TARGET_CFLAGS)
538 AC_SUBST(TARGET_LDFLAGS)
539 AC_SUBST(TARGET_CPPFLAGS)
540 AC_SUBST(TARGET_CCASFLAGS)
541
542 AC_SUBST(TARGET_IMG_LDSCRIPT)
543 AC_SUBST(TARGET_IMG_LDFLAGS)
544 AC_SUBST(TARGET_IMG_CFLAGS)
545 AC_SUBST(TARGET_IMG_BASE_LDOPT)
546
547 AC_SUBST(HOST_CFLAGS)
548 AC_SUBST(HOST_LDFLAGS)
549 AC_SUBST(HOST_CPPFLAGS)
550 AC_SUBST(HOST_CCASFLAGS)
551
552 # Set them to their new values for the tests below.
553 CC="$TARGET_CC"
554 if test "x$TARGET_APPLE_CC" = x1 ; then
555 CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
556 else
557 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
558 fi
559 CPPFLAGS="$TARGET_CPPFLAGS"
560 LDFLAGS="$TARGET_LDFLAGS"
561 LIBS=-lgcc
562
563 grub_ASM_USCORE
564 if test x$grub_cv_asm_uscore = xyes; then
565 CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
566 else
567 CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
568 fi
569
570 # Check for libgcc symbols
571 AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
572
573 if test "x$TARGET_APPLE_CC" = x1 ; then
574 CFLAGS="$TARGET_CFLAGS -nostdlib"
575 else
576 CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
577 fi
578 LIBS=""
579
580 # Defined in aclocal.m4.
581 grub_PROG_TARGET_CC
582 if test "x$TARGET_APPLE_CC" != x1 ; then
583 grub_PROG_OBJCOPY_ABSOLUTE
584 fi
585 grub_PROG_LD_BUILD_ID_NONE
586 if test "x$target_cpu" = xi386; then
587 if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
588 if test ! -z "$TARGET_IMG_LDSCRIPT"; then
589 # Check symbols provided by linker script.
590 CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"
591 fi
592 grub_CHECK_BSS_START_SYMBOL
593 grub_CHECK_END_SYMBOL
594 fi
595 CFLAGS="$TARGET_CFLAGS"
596 grub_I386_ASM_PREFIX_REQUIREMENT
597 grub_I386_ASM_ADDR32
598 fi
599
600 AC_ARG_ENABLE([efiemu],
601 [AS_HELP_STRING([--enable-efiemu],
602 [build and install the efiemu runtimes (default=guessed)])])
603 if test x"$enable_efiemu" = xno ; then
604 efiemu_excuse="explicitly disabled"
605 fi
606 if test x"$target_cpu" != xi386 ; then
607 efiemu_excuse="only available on i386"
608 fi
609 if test x"$platform" = xefi ; then
610 efiemu_excuse="not available on efi"
611 fi
612 if test x"$efiemu_excuse" = x ; then
613 AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
614 CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
615 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
616 [grub_cv_cc_efiemu=yes],
617 [grub_cv_cc_efiemu=no])
618 ])
619 if test x$grub_cv_cc_efiemu = xno; then
620 efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
621 fi
622 fi
623 if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
624 AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
625 fi
626 if test x"$efiemu_excuse" = x ; then
627 enable_efiemu=yes
628 else
629 enable_efiemu=no
630 fi
631 AC_SUBST([enable_efiemu])
632
633 if test "$platform" != emu; then
634 AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
635 SAVED_CPPFLAGS="$CPPFLAGS"
636 CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
637 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
638 int va_arg_func (int fixed, va_list args);]], [[]])],
639 [grub_cv_cc_isystem=yes],
640 [grub_cv_cc_isystem=no])
641 CPPFLAGS="$SAVED_CPPFLAGS"
642 ])
643
644 if test x"$grub_cv_cc_isystem" = xyes ; then
645 TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
646 fi
647 fi
648
649 # Restore the flags.
650 CC="$tmp_CC"
651 CFLAGS="$tmp_CFLAGS"
652 CPPFLAGS="$tmp_CPPFLAGS"
653 LDFLAGS="$tmp_LDFLAGS"
654 LIBS="$tmp_LIBS"
655
656 #
657 # Check for options.
658 #
659
660 # Memory manager debugging.
661 AC_ARG_ENABLE([mm-debug],
662 AS_HELP_STRING([--enable-mm-debug],
663 [include memory manager debugging]),
664 [AC_DEFINE([MM_DEBUG], [1],
665 [Define to 1 if you enable memory manager debugging.])])
666
667 AC_ARG_ENABLE([grub-emu-usb],
668 [AS_HELP_STRING([--enable-grub-emu-usb],
669 [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
670
671 AC_ARG_ENABLE([grub-emu-sdl],
672 [AS_HELP_STRING([--enable-grub-emu-sdl],
673 [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
674
675 AC_ARG_ENABLE([grub-emu-pci],
676 [AS_HELP_STRING([--enable-grub-emu-pci],
677 [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
678
679 if test "$platform" = emu; then
680 missing_ncurses=
681 [# Check for curses libraries.]
682 AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
683 [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
684 [missing_ncurses=[true]])])
685 AC_SUBST([LIBCURSES])
686 [if [ x"$missing_ncurses" = x ]; then ]
687 [# Check for headers.]
688 AC_CHECK_HEADERS([ncurses/curses.h], [],
689 [AC_CHECK_HEADERS([ncurses.h], [],
690 [AC_CHECK_HEADERS([curses.h], [],
691 [missing_ncurses=[true]])])])
692 [fi]
693 if test x"$missing_ncurses" = xtrue ; then
694 AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
695 fi
696
697 if test x"$enable_grub_emu_usb" != xyes ; then
698 grub_emu_usb_excuse="not enabled"
699 fi
700
701 if test x"$enable_grub_emu_pci" = xyes ; then
702 grub_emu_usb_excuse="conflicts with PCI support"
703 fi
704
705 [if [ x"$grub_emu_usb_excuse" = x ]; then
706 # Check for libusb libraries.]
707 AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
708 [grub_emu_usb_excuse=["need libusb library"]])
709 AC_SUBST([LIBUSB])
710 [fi]
711 [if [ x"$grub_emu_usb_excuse" = x ]; then
712 # Check for headers.]
713 AC_CHECK_HEADERS([usb.h], [],
714 [grub_emu_usb_excuse=["need libusb headers"]])
715 [fi]
716 if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
717 AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
718 fi
719 if test x"$grub_emu_usb_excuse" = x ; then
720 enable_grub_emu_usb=yes
721 else
722 enable_grub_emu_usb=no
723 fi
724
725 if test x"$enable_grub_emu_sdl" = xno ; then
726 grub_emu_sdl_excuse="explicitely disabled"
727 fi
728 [if [ x"$grub_emu_sdl_excuse" = x ]; then
729 # Check for libSDL libraries.]
730 AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
731 [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
732 AC_SUBST([LIBSDL])
733 [fi]
734
735 [if [ x"$grub_emu_sdl_excuse" = x ]; then
736 # Check for headers.]
737 AC_CHECK_HEADERS([SDL/SDL.h], [],
738 [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
739 [fi]
740
741 if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
742 AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
743 fi
744 if test x"$grub_emu_sdl_excuse" = x ; then
745 enable_grub_emu_sdl=yes
746 else
747 enable_grub_emu_sdl=no
748 fi
749
750 if test x"$enable_grub_emu_pci" != xyes ; then
751 grub_emu_pci_excuse="not enabled"
752 fi
753
754 if test x"$enable_grub_emu_usb" = xyes ; then
755 grub_emu_pci_excuse="conflicts with USB support"
756 fi
757
758 [if [ x"$grub_emu_pci_excuse" = x ]; then
759 # Check for libpci libraries.]
760 AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
761 [grub_emu_pci_excuse=["need libpciaccess library"]])
762 AC_SUBST([LIBPCIACCESS])
763 [fi]
764 [if [ x"$grub_emu_pci_excuse" = x ]; then
765 # Check for headers.]
766 AC_CHECK_HEADERS([pci/pci.h], [],
767 [grub_emu_pci_excuse=["need libpciaccess headers"]])
768 [fi]
769
770 if test x"$grub_emu_pci_excuse" = x ; then
771 enable_grub_emu_pci=yes
772 else
773
774 enable_grub_emu_pci=no
775 fi
776
777 AC_SUBST([enable_grub_emu_sdl])
778 AC_SUBST([enable_grub_emu_usb])
779 AC_SUBST([enable_grub_emu_pci])
780 fi
781
782 AC_ARG_ENABLE([grub-mkfont],
783 [AS_HELP_STRING([--enable-grub-mkfont],
784 [build and install the `grub-mkfont' utility (default=guessed)])])
785 if test x"$enable_grub_mkfont" = xno ; then
786 grub_mkfont_excuse="explicitly disabled"
787 fi
788
789 if test x"$grub_mkfont_excuse" = x ; then
790 # Check for freetype libraries.
791 AC_CHECK_PROGS([FREETYPE], [freetype-config])
792 if test "x$FREETYPE" = x ; then
793 grub_mkfont_excuse=["need freetype2 library"]
794 fi
795 fi
796
797 if test x"$grub_mkfont_excuse" = x ; then
798 # Check for freetype libraries.
799 freetype_cflags=`freetype-config --cflags`
800 freetype_libs=`freetype-config --libs`
801 SAVED_CPPFLAGS="$CPPFLAGS"
802 CPPFLAGS="$CPPFLAGS $freetype_cflags"
803 AC_CHECK_HEADERS([ft2build.h], [],
804 [grub_mkfont_excuse=["need freetype2 headers"]])
805 CPPFLAGS="$SAVED_CPPFLAGS"
806 fi
807
808 if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
809 AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
810 fi
811 if test x"$grub_mkfont_excuse" = x ; then
812 enable_grub_mkfont=yes
813 else
814 enable_grub_mkfont=no
815 fi
816 AC_SUBST([enable_grub_mkfont])
817 AC_SUBST([freetype_cflags])
818 AC_SUBST([freetype_libs])
819
820 AC_ARG_ENABLE([device-mapper],
821 [AS_HELP_STRING([--enable-device-mapper],
822 [enable Linux device-mapper support (default=guessed)])])
823 if test x"$enable_device_mapper" = xno ; then
824 device_mapper_excuse="explicitly disabled"
825 fi
826
827 if test x"$device_mapper_excuse" = x ; then
828 # Check for device-mapper library.
829 AC_CHECK_LIB([devmapper], [dm_task_create], [],
830 [device_mapper_excuse="need devmapper library"])
831 fi
832
833 if test x"$device_mapper_excuse" = x ; then
834 # Check for device-mapper library.
835 AC_CHECK_LIB([devmapper], [dm_log_with_errno_init],
836 [],
837 [device_mapper_excuse="need devmapper library"])
838 fi
839
840 if test x"$device_mapper_excuse" = x ; then
841 LIBDEVMAPPER="-ldevmapper";
842 AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
843 [Define to 1 if you have the devmapper library.])
844 fi
845
846 AC_SUBST([LIBDEVMAPPER])
847
848 AC_CHECK_LIB([zfs], [libzfs_init],
849 [LIBZFS="-lzfs"
850 AC_DEFINE([HAVE_LIBZFS], [1],
851 [Define to 1 if you have the ZFS library.])],)
852 AC_SUBST([LIBZFS])
853
854 AC_CHECK_LIB([nvpair], [nvlist_print],
855 [LIBNVPAIR="-lnvpair"
856 AC_DEFINE([HAVE_LIBNVPAIR], [1],
857 [Define to 1 if you have the NVPAIR library.])],)
858 AC_SUBST([LIBNVPAIR])
859
860 LIBS=""
861
862 pkglibrootdir='$(libdir)'/`echo $PACKAGE | sed "$program_transform_name"`
863 AC_SUBST(pkglibrootdir)
864
865 AC_SUBST([FONT_SOURCE])
866 AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
867 [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
868 AS_IF([test x$TARGET_APPLE_CC = x1],
869 [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
870
871 AC_SUBST(HAVE_ASM_USCORE)
872 AC_SUBST(ADDR32)
873 AC_SUBST(DATA32)
874 AC_SUBST(BSS_START_SYMBOL)
875 AC_SUBST(END_SYMBOL)
876 AC_SUBST(PACKAGE)
877 AC_SUBST(VERSION)
878 AC_SUBST(NEED_ENABLE_EXECUTE_STACK)
879 AC_SUBST(NEED_REGISTER_FRAME_INFO)
880
881 #
882 # Automake conditionals
883 #
884
885 AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
886 AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
887 AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
888 AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
889 AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
890 AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
891 AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
892 AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
893 AM_CONDITIONAL([COND_mips_yeeloong], [test x$target_cpu = xmips -a x$platform = xyeeloong])
894 AM_CONDITIONAL([COND_mips_qemu_mips], [test x$target_cpu = xmips -a x$platform = xqemu_mips])
895 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
896 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
897 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips])
898
899 AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
900 AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
901 AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
902 AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
903 AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
904
905 AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
906 AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
907 AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
908 AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
909 AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
910 AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
911 AM_CONDITIONAL([COND_GRUB_PE2ELF], [test x$TARGET_OBJ2ELF != x])
912 AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
913 AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
914
915 AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
916
917 # Output files.
918 grub_CHECK_LINK_DIR
919 if test x"$link_dir" = xyes ; then
920 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu])
921 if test "$platform" != emu ; then
922 AC_CONFIG_LINKS([include/grub/machine:include/grub/$target_cpu/$platform])
923 fi
924 else
925 mkdir -p include/grub 2>/dev/null
926 rm -rf include/grub/cpu
927 cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null
928 if test "$platform" != emu ; then
929 rm -rf include/grub/machine
930 cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
931 fi
932 fi
933
934 AC_CONFIG_FILES([Makefile])
935 AC_CONFIG_FILES([grub-core/Makefile])
936 AC_CONFIG_FILES([grub-core/gnulib/Makefile])
937 AC_CONFIG_FILES([po/Makefile.in])
938 AC_CONFIG_FILES([docs/Makefile])
939 AC_CONFIG_FILES([util/bash-completion.d/Makefile])
940 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
941 AC_CONFIG_FILES([config.h])
942
943 AC_OUTPUT
944 [
945 echo "*******************************************************"
946 echo GRUB2 will be compiled with following components:
947 echo Platform: "$target_cpu"-"$platform"
948 if [ x"$platform" = xemu ]; then
949 if [ x"$grub_emu_usb_excuse" = x ]; then
950 echo USB support for grub-emu: Yes
951 else
952 echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
953 fi
954 if [ x"$grub_emu_sdl_excuse" = x ]; then
955 echo SDL support for grub-emu: Yes
956 else
957 echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)"
958 fi
959 if [ x"$grub_emu_pci_excuse" = x ]; then
960 echo PCI support for grub-emu: Yes
961 else
962 echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
963 fi
964 fi
965 if test x"$device_mapper_excuse" = x ; then
966 echo With devmapper support: Yes
967 else
968 echo With devmapper support: No "($device_mapper_excuse)"
969 fi
970 if [ x"$enable_mm_debug" = xyes ]; then
971 echo With memory debugging: Yes
972 else
973 echo With memory debugging: No
974 fi
975 if [ x"$efiemu_excuse" = x ]; then
976 echo efiemu runtime: Yes
977 else
978 echo efiemu runtime: No "($efiemu_excuse)"
979 fi
980 if [ x"$grub_mkfont_excuse" = x ]; then
981 echo grub-mkfont: Yes
982 else
983 echo grub-mkfont: No "($grub_mkfont_excuse)"
984 fi
985 echo "*******************************************************"
986 ]