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