]>
Commit | Line | Data |
---|---|---|
76ed06b9 BC |
1 | # -*- autoconf -*- |
2 | ||
6a161fa9 | 3 | # Process this file with autoconf to produce a configure script. |
4 | ||
2f1a3acf | 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 | ||
b977bf01 | 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 | |
dcecae1a AB |
29 | dnl CC, CFLAGS, etc.) for the host type, variables with prefix "BUILD_" |
30 | dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables | |
31 | dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are | |
32 | dnl used for the target type. See INSTALL for full list of variables. | |
b977bf01 | 33 | |
e8f07821 | 34 | AC_INIT([GRUB],[2.02~beta2],[bug-grub@gnu.org]) |
6a161fa9 | 35 | |
15c69261 YB |
36 | AC_CONFIG_AUX_DIR([build-aux]) |
37 | ||
76ed06b9 BC |
38 | # We don't want -g -O2 by default in CFLAGS |
39 | : ${CFLAGS=""} | |
6a161fa9 | 40 | |
1ecf96fc AB |
41 | # Checks for build, host and target systems. |
42 | AC_CANONICAL_BUILD | |
6a161fa9 | 43 | AC_CANONICAL_HOST |
ee7fb780 | 44 | save_program_prefix="${program_prefix}" |
b977bf01 | 45 | AC_CANONICAL_TARGET |
ee7fb780 | 46 | program_prefix="${save_program_prefix}" |
6a161fa9 | 47 | |
6fe506b0 | 48 | AM_INIT_AUTOMAKE([1.10.1]) |
8c411768 | 49 | AC_PREREQ(2.60) |
6304d292 | 50 | AC_CONFIG_SRCDIR([include/grub/dl.h]) |
742f9232 | 51 | AC_CONFIG_HEADER([config-util.h]) |
e52db1f7 | 52 | |
1d543c3e | 53 | # Program name transformations |
54 | AC_ARG_PROGRAM | |
fd49ceb3 CW |
55 | grub_TRANSFORM([grub-bios-setup]) |
56 | grub_TRANSFORM([grub-editenv]) | |
57 | grub_TRANSFORM([grub-install]) | |
58 | grub_TRANSFORM([grub-mkconfig]) | |
59 | grub_TRANSFORM([grub-mkfont]) | |
60 | grub_TRANSFORM([grub-mkimage]) | |
67ab8353 | 61 | grub_TRANSFORM([grub-glue-efi]) |
fd49ceb3 CW |
62 | grub_TRANSFORM([grub-mklayout]) |
63 | grub_TRANSFORM([grub-mkpasswd-pbkdf2]) | |
64 | grub_TRANSFORM([grub-mkrelpath]) | |
65 | grub_TRANSFORM([grub-mkrescue]) | |
66 | grub_TRANSFORM([grub-probe]) | |
67 | grub_TRANSFORM([grub-reboot]) | |
68 | grub_TRANSFORM([grub-script-check]) | |
69 | grub_TRANSFORM([grub-set-default]) | |
fd49ceb3 | 70 | grub_TRANSFORM([grub-sparc64-setup]) |
a79b8a15 | 71 | grub_TRANSFORM([grub-render-label]) |
ec824e0f | 72 | grub_TRANSFORM([grub-file]) |
1d543c3e | 73 | |
90d1e879 RM |
74 | # Optimization flag. Allow user to override. |
75 | if test "x$TARGET_CFLAGS" = x; then | |
76 | TARGET_CFLAGS="$TARGET_CFLAGS -Os" | |
77 | fi | |
78 | ||
76ed06b9 BC |
79 | # Default HOST_CPPFLAGS |
80 | HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W" | |
76ed06b9 | 81 | HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" |
76ed06b9 | 82 | HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1" |
76ed06b9 BC |
83 | |
84 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W" | |
85 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" | |
86 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" | |
87 | ||
b977bf01 | 88 | case "$target_cpu" in |
02164e1b | 89 | i[[3456]]86) target_cpu=i386 ;; |
c7ef54aa | 90 | amd64) target_cpu=x86_64 ;; |
02164e1b | 91 | sparc) target_cpu=sparc64 ;; |
ade85305 | 92 | mipsel|mips64el) |
4d94b2db CW |
93 | target_cpu=mipsel |
94 | machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1" | |
4a1eefb6 | 95 | ;; |
ade85305 | 96 | mips|mips64) |
4d94b2db CW |
97 | target_cpu=mips |
98 | machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1" | |
4a1eefb6 | 99 | ;; |
389b31cd | 100 | arm*) |
4d94b2db | 101 | target_cpu=arm |
389b31cd | 102 | ;; |
15a463d7 | 103 | aarch64*) |
4d94b2db | 104 | target_cpu=arm64 |
15a463d7 | 105 | ;; |
6a161fa9 | 106 | esac |
107 | ||
05568c2e | 108 | # Specify the platform (such as firmware). |
109 | AC_ARG_WITH([platform], | |
110 | AS_HELP_STRING([--with-platform=PLATFORM], | |
83b984de | 111 | [select the host platform [[guessed]]])) |
05568c2e | 112 | |
113 | # Guess the platform if not specified. | |
114 | if test "x$with_platform" = x; then | |
b977bf01 | 115 | case "$target_cpu"-"$target_vendor" in |
05568c2e | 116 | i386-apple) platform=efi ;; |
117 | i386-*) platform=pc ;; | |
58393a2d | 118 | x86_64-apple) platform=efi ;; |
737feb35 | 119 | x86_64-*) platform=pc ;; |
05568c2e | 120 | powerpc-*) platform=ieee1275 ;; |
58393a2d | 121 | powerpc64-*) platform=ieee1275 ;; |
05568c2e | 122 | sparc64-*) platform=ieee1275 ;; |
4959e111 VS |
123 | mipsel-*) platform=loongson ;; |
124 | mips-*) platform=arc ;; | |
e68d3b24 | 125 | ia64-*) platform=efi ;; |
389b31cd | 126 | arm-*) platform=uboot ;; |
15a463d7 | 127 | arm64-*) platform=efi ;; |
58393a2d | 128 | *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;; |
05568c2e | 129 | esac |
130 | else | |
131 | platform="$with_platform" | |
132 | fi | |
133 | ||
ec1dfd63 VS |
134 | case "$target_cpu"-"$platform" in |
135 | x86_64-efi) ;; | |
136 | x86_64-emu) ;; | |
9612ebc0 | 137 | x86_64-xen) ;; |
ec1dfd63 VS |
138 | x86_64-*) target_cpu=i386 ;; |
139 | powerpc64-ieee1275) target_cpu=powerpc ;; | |
140 | esac | |
20011694 | 141 | |
58393a2d | 142 | # Check if the platform is supported, make final adjustments. |
b977bf01 | 143 | case "$target_cpu"-"$platform" in |
05568c2e | 144 | i386-efi) ;; |
3f4ce737 | 145 | x86_64-efi) ;; |
9612ebc0 VS |
146 | i386-xen) ;; |
147 | x86_64-xen) ;; | |
05568c2e | 148 | i386-pc) ;; |
7210dca9 | 149 | i386-multiboot) ;; |
546f966a | 150 | i386-coreboot) ;; |
58393a2d | 151 | i386-linuxbios) platform=coreboot ;; |
3d04eab8 | 152 | i386-ieee1275) ;; |
8231fb77 | 153 | i386-qemu) ;; |
05568c2e | 154 | powerpc-ieee1275) ;; |
155 | sparc64-ieee1275) ;; | |
2c40cc78 | 156 | ia64-efi) ;; |
f440c33f | 157 | mips-qemu_mips) ;; |
3666d5f6 | 158 | mips-qemu-mips) platform=qemu_mips;; |
8906c3dd | 159 | mips-arc) ;; |
7f63a64f | 160 | mipsel-arc) ;; |
4959e111 VS |
161 | mipsel-qemu_mips) ;; |
162 | mipsel-qemu-mips) platform=qemu_mips;; | |
163 | mipsel-yeeloong) platform=loongson ;; | |
164 | mipsel-fuloong) platform=loongson ;; | |
165 | mipsel-loongson) ;; | |
389b31cd LL |
166 | arm-uboot) ;; |
167 | arm-efi) ;; | |
15a463d7 | 168 | arm64-efi) ;; |
f84b481b | 169 | *-emu) ;; |
58393a2d | 170 | *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;; |
6a161fa9 | 171 | esac |
172 | ||
48145ea3 | 173 | if test x$platform != xemu ; then |
dd614590 VS |
174 | case "$target_cpu" in |
175 | i386 | powerpc) target_m32=1 ;; | |
176 | x86_64 | sparc64) target_m64=1 ;; | |
177 | esac | |
178 | fi | |
3f4ce737 | 179 | |
eaf01c25 | 180 | if test x"$target_cpu-$platform" = xsparc64-emu ; then |
4d94b2db | 181 | target_m64=1 |
eaf01c25 VS |
182 | fi |
183 | ||
fc97214f | 184 | case "$target_os" in |
c3302aa5 | 185 | windows* | mingw32*) target_os=cygwin ;; |
fc97214f VS |
186 | esac |
187 | ||
9304eef1 | 188 | # This normalizes the names, and creates a new variable ("host_kernel") |
189 | # while at it, since the mapping is not always 1:1 (e.g. different OSes | |
190 | # using the same kernel type). | |
191 | case "$host_os" in | |
192 | gnu*) host_kernel=hurd ;; | |
193 | linux*) host_kernel=linux ;; | |
67937d4d | 194 | freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;; |
2c7031b1 | 195 | netbsd*) host_kernel=netbsd ;; |
958ee221 | 196 | solaris*) host_kernel=illumos ;; |
b105df76 | 197 | darwin*) host_kernel=xnu ;; |
7e518ca8 | 198 | cygwin | windows* | mingw32*) host_kernel=windows ;; |
9304eef1 | 199 | esac |
200 | ||
cd46aa6c VS |
201 | case "$host_os" in |
202 | cygwin | windows* | mingw32*) have_exec=n ;; | |
203 | aros*) have_exec=n ;; | |
204 | *) have_exec=y;; | |
205 | esac | |
206 | ||
f84b481b | 207 | case "$platform" in |
c721825b BC |
208 | coreboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_COREBOOT=1" ;; |
209 | multiboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MULTIBOOT=1" ;; | |
210 | efi) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EFI=1" ;; | |
9612ebc0 | 211 | xen) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_XEN=1" ;; |
c721825b | 212 | ieee1275) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_IEEE1275=1" ;; |
389b31cd | 213 | uboot) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_UBOOT=1" ;; |
c721825b BC |
214 | qemu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_QEMU=1" ;; |
215 | pc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_PCBIOS=1" ;; | |
216 | emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;; | |
0c930a84 VS |
217 | loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;; |
218 | qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;; | |
3666d5f6 | 219 | arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;; |
f84b481b | 220 | esac |
4959e111 VS |
221 | if test x${target_cpu} = xmipsel ; then |
222 | machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`" | |
223 | else | |
0c930a84 | 224 | machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`" |
4959e111 | 225 | fi |
6bea3f89 | 226 | |
7f63a64f VS |
227 | case "${target_cpu}-$platform" in |
228 | mips-arc) | |
229 | TARGET_LINK_ADDR=0x88200000 | |
230 | TARGET_DECOMPRESSOR_LINK_ADDR=0x88100000 | |
231 | ;; | |
232 | mipsel-arc) | |
233 | TARGET_LINK_ADDR=0x80700000 | |
234 | TARGET_DECOMPRESSOR_LINK_ADDR=0x80600000 | |
235 | ;; | |
5fe67f39 | 236 | mips*-qemu_mips | mips*-loongson) |
7f63a64f VS |
237 | TARGET_DECOMPRESSOR_LINK_ADDR=0x80100000 |
238 | ;; | |
239 | esac | |
240 | ||
241 | AC_SUBST(TARGET_LINK_ADDR) | |
242 | AC_SUBST(TARGET_DECOMPRESSOR_LINK_ADDR) | |
243 | ||
c721825b | 244 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS" |
f84b481b | 245 | |
56978920 | 246 | AC_SUBST(host_cpu) |
247 | AC_SUBST(host_os) | |
9304eef1 | 248 | AC_SUBST(host_kernel) |
6e5a42fe | 249 | |
071114bb VS |
250 | AC_SUBST(target_cpu) |
251 | AC_SUBST(platform) | |
252 | ||
d87aedff | 253 | # Define default variables |
7134247c VS |
254 | |
255 | have_with_bootdir=n | |
256 | AC_ARG_WITH([bootdir], | |
257 | AS_HELP_STRING([--with-bootdir=DIR], | |
258 | [set the name of /boot directory [[guessed]]]), | |
259 | [have_with_bootdir=y], | |
260 | [have_with_bootdir=n]) | |
261 | if test x$have_with_bootdir = xy; then | |
262 | bootdirname="$with_bootdir" | |
263 | else | |
264 | case "$host_os" in | |
265 | netbsd* | openbsd*) | |
d87aedff | 266 | # Because /boot is used for the boot block in NetBSD and OpenBSD, |
7134247c VS |
267 | bootdirname='' ;; |
268 | *) bootdirname='boot' ;; | |
269 | esac | |
270 | fi | |
271 | ||
d87aedff | 272 | AC_SUBST(bootdirname) |
a4c1d277 YB |
273 | AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname", |
274 | [Default boot directory name]") | |
d87aedff | 275 | |
7134247c VS |
276 | AC_ARG_WITH([grubdir], |
277 | AS_HELP_STRING([--with-grubdir=DIR], | |
278 | [set the name of grub directory [[guessed]]]), | |
279 | [grubdirname="$with_grubdir"], | |
280 | [grubdirname="$PACKAGE"]) | |
281 | ||
d87aedff | 282 | AC_SUBST(grubdirname) |
a4c1d277 YB |
283 | AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname", |
284 | [Default grub directory name]) | |
d87aedff | 285 | |
b977bf01 | 286 | # |
287 | # Checks for build programs. | |
288 | # | |
144f1f98 | 289 | |
6c826348 | 290 | # Although cmp is listed in the GNU Coding Standards as a command which |
291 | # can used directly, OpenBSD lacks cmp in the default installation. | |
292 | AC_CHECK_PROGS([CMP], [cmp]) | |
293 | if test "x$CMP" = x; then | |
294 | AC_MSG_ERROR([cmp is not found]) | |
295 | fi | |
296 | ||
144f1f98 | 297 | AC_CHECK_PROGS([YACC], [bison]) |
1569ec51 | 298 | if test "x$YACC" = x; then |
6c826348 | 299 | AC_MSG_ERROR([bison is not found]) |
1569ec51 | 300 | fi |
301 | ||
76ed06b9 | 302 | AC_PROG_RANLIB |
b977bf01 | 303 | AC_PROG_INSTALL |
304 | AC_PROG_AWK | |
09220190 | 305 | AC_PROG_LEX |
76ed06b9 | 306 | AC_PROG_YACC |
b977bf01 | 307 | AC_PROG_MAKE_SET |
ff420223 | 308 | AC_PROG_MKDIR_P |
e1fd1939 | 309 | AC_PROG_LN_S |
b977bf01 | 310 | |
c7c75cf4 | 311 | if test "x$LEX" = "x:"; then |
09220190 BC |
312 | AC_MSG_ERROR([flex is not found]) |
313 | else | |
2663fb5f | 314 | version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'` |
b777c18e | 315 | if test -n "$version" -a "$version" -ge 20535; then |
09220190 BC |
316 | : |
317 | else | |
318 | AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above]) | |
319 | fi | |
320 | fi | |
321 | ||
68807e5f | 322 | # These are not a "must". |
51fa856c | 323 | AC_PATH_PROGS(MAKEINFO, makeinfo true) |
6a161fa9 | 324 | |
b977bf01 | 325 | # |
326 | # Checks for host programs. | |
327 | # | |
328 | ||
329 | AC_PROG_CC | |
15c69261 | 330 | gl_EARLY |
1eed0e6e | 331 | AC_PROG_CXX |
76ed06b9 BC |
332 | AM_PROG_CC_C_O |
333 | AM_PROG_AS | |
334 | ||
6a161fa9 | 335 | # Must be GCC. |
336 | test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) | |
337 | ||
1eed0e6e VS |
338 | AC_CHECK_PROG(HAVE_CXX, $CXX, yes, no) |
339 | ||
4889bdec | 340 | AC_GNU_SOURCE |
2f1a3acf | 341 | AM_GNU_GETTEXT([external]) |
b977bf01 | 342 | AC_SYS_LARGEFILE |
343 | ||
344 | # Identify characteristics of the host architecture. | |
7b780018 VS |
345 | unset ac_cv_c_bigendian |
346 | ||
eaf01c25 VS |
347 | if test x"$target_cpu-$platform" = xsparc64-emu ; then |
348 | CFLAGS="$CFLAGS -m64" | |
349 | HOST_CFLAGS="$HOST_CFLAGS -m64" | |
350 | fi | |
351 | ||
b977bf01 | 352 | AC_C_BIGENDIAN |
353 | AC_CHECK_SIZEOF(void *) | |
354 | AC_CHECK_SIZEOF(long) | |
355 | ||
7e518ca8 VS |
356 | case "$host_os" in |
357 | cygwin | windows* | mingw32*) | |
358 | HOST_CPPFLAGS="$HOST_CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500" | |
359 | CPPFLAGS="$CPPFLAGS -DUNICODE=1 -D_WIN32_WINNT=0x0500" | |
360 | AC_CHECK_SIZEOF(TCHAR,,[#include <windows.h>]) | |
361 | ;; | |
362 | esac | |
363 | ||
aad32b14 VS |
364 | if test x$USE_NLS = xno; then |
365 | HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext" | |
366 | fi | |
367 | ||
86695375 | 368 | if test "x$cross_compiling" = xyes; then |
369 | AC_MSG_WARN([cannot generate manual pages while cross compiling]) | |
370 | else | |
371 | AC_PATH_PROG(HELP2MAN, help2man) | |
372 | fi | |
373 | ||
3169f4c7 | 374 | # Check for functions and headers. |
0f7e980b | 375 | AC_CHECK_FUNCS(posix_memalign memalign getextmntent) |
e4c498a1 | 376 | AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h) |
7c4e16ff | 377 | |
fb90b546 RM |
378 | AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default |
379 | #include <sys/param.h> | |
380 | #include <sys/mount.h>]) | |
381 | ||
382 | AC_CHECK_MEMBERS([struct statfs.f_mntfromname],,,[$ac_includes_default | |
383 | #include <sys/param.h> | |
384 | #include <sys/mount.h>]) | |
385 | ||
2c7031b1 GS |
386 | # For opendisk() and getrawpartition() on NetBSD. |
387 | # Used in util/deviceiter.c and in util/hostdisk.c. | |
388 | AC_CHECK_HEADER([util.h], [ | |
389 | AC_CHECK_LIB([util], [opendisk], [ | |
390 | LIBUTIL="-lutil" | |
391 | AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used]) | |
392 | ]) | |
393 | AC_CHECK_LIB([util], [getrawpartition], [ | |
394 | LIBUTIL="-lutil" | |
395 | AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used]) | |
396 | ]) | |
397 | ]) | |
398 | AC_SUBST([LIBUTIL]) | |
399 | ||
19ce697d | 400 | AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [ |
00c05e22 | 401 | SAVED_CFLAGS="$CFLAGS" |
b35ec299 | 402 | CFLAGS="$HOST_CFLAGS -Wtrampolines -Werror" |
00c05e22 VS |
403 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> |
404 | int va_arg_func (int fixed, va_list args);]], [[]])], | |
19ce697d VS |
405 | [grub_cv_host_cc_wtrampolines=yes], |
406 | [grub_cv_host_cc_wtrampolines=no]) | |
00c05e22 VS |
407 | CFLAGS="$SAVED_CFLAGS" |
408 | ]) | |
409 | ||
19ce697d VS |
410 | if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then |
411 | HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines" | |
00c05e22 VS |
412 | fi |
413 | ||
76ed06b9 BC |
414 | # |
415 | # Check for host and build compilers. | |
416 | # | |
417 | HOST_CC=$CC | |
816719c8 VS |
418 | AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc]) |
419 | test -z "$BUILD_CC" && AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.]) | |
b224c266 | 420 | BUILD_CPP="$BUILD_CC -E" |
76ed06b9 | 421 | |
29013cba VS |
422 | case "$build_os" in |
423 | haiku*) BUILD_LIBM= ;; | |
424 | *) BUILD_LIBM=-lm ;; | |
425 | esac | |
1ecf96fc AB |
426 | |
427 | dnl FIXME proper test seems to require too deep dive into Autoconf internals. | |
428 | dnl For now just list known platforms that we support. | |
429 | ||
430 | case "$build_os" in | |
431 | cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;; | |
432 | *) BUILD_EXEEXT= ;; | |
433 | esac | |
434 | AC_SUBST(BUILD_EXEEXT) | |
435 | ||
15c69261 YB |
436 | # For gnulib. |
437 | gl_INIT | |
438 | ||
93bf55e6 | 439 | WARN_FLAGS="-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes" |
ae558c2c | 440 | EXTRA_WARN_FLAGS="-Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2" |
60d5e9cb VS |
441 | |
442 | HOST_CFLAGS="$HOST_CFLAGS $WARN_FLAGS -Wcast-align" | |
443 | ||
444 | AC_CACHE_CHECK([which extra warnings work], [grub_cv_cc_w_extra_flags], [ | |
445 | SAVED_CFLAGS="$CFLAGS" | |
446 | grub_cv_cc_w_extra_flags= | |
447 | for x in $EXTRA_WARN_FLAGS; do | |
448 | CFLAGS="$HOST_CFLAGS $x -Werror" | |
449 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0]) | |
450 | if test x$flag = x1 ; then | |
451 | grub_cv_cc_w_extra_flags="$grub_cv_cc_w_extra_flags $x" | |
452 | fi | |
453 | done | |
454 | CFLAGS="$SAVED_CFLAGS" | |
455 | ]) | |
456 | ||
457 | HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" | |
458 | ||
b977bf01 | 459 | # |
460 | # Check for target programs. | |
461 | # | |
462 | ||
5b5d4aa5 | 463 | # Find tools for the target. |
464 | if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then | |
b977bf01 | 465 | tmp_ac_tool_prefix="$ac_tool_prefix" |
466 | ac_tool_prefix=$target_alias- | |
467 | ||
468 | AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc], | |
469 | [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])]) | |
fc97214f VS |
470 | AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy) |
471 | AC_CHECK_TOOL(TARGET_STRIP, strip) | |
472 | AC_CHECK_TOOL(TARGET_NM, nm) | |
0e8daad0 | 473 | AC_CHECK_TOOL(TARGET_RANLIB, ranlib) |
b977bf01 | 474 | |
475 | ac_tool_prefix="$tmp_ac_tool_prefix" | |
476 | else | |
477 | if test "x$TARGET_CC" = x; then | |
478 | TARGET_CC=$CC | |
479 | fi | |
fc97214f VS |
480 | AC_CHECK_TOOL(TARGET_OBJCOPY, objcopy) |
481 | AC_CHECK_TOOL(TARGET_STRIP, strip) | |
482 | AC_CHECK_TOOL(TARGET_NM, nm) | |
0e8daad0 | 483 | AC_CHECK_TOOL(TARGET_RANLIB, ranlib) |
b977bf01 | 484 | fi |
fc97214f | 485 | |
76ed06b9 BC |
486 | AC_SUBST(HOST_CC) |
487 | AC_SUBST(BUILD_CC) | |
7c9d0c39 VS |
488 | AC_SUBST(BUILD_CFLAGS) |
489 | AC_SUBST(BUILD_CPPFLAGS) | |
dcecae1a | 490 | AC_SUBST(BUILD_LDFLAGS) |
b977bf01 | 491 | AC_SUBST(TARGET_CC) |
fc97214f | 492 | AC_SUBST(TARGET_NM) |
1bd73025 | 493 | AC_SUBST(TARGET_RANLIB) |
fc97214f VS |
494 | AC_SUBST(TARGET_STRIP) |
495 | AC_SUBST(TARGET_OBJCOPY) | |
b977bf01 | 496 | |
b977bf01 | 497 | # Test the C compiler for the target environment. |
498 | tmp_CC="$CC" | |
499 | tmp_CFLAGS="$CFLAGS" | |
500 | tmp_LDFLAGS="$LDFLAGS" | |
501 | tmp_CPPFLAGS="$CPPFLAGS" | |
aa6d7826 | 502 | tmp_LIBS="$LIBS" |
b977bf01 | 503 | CC="$TARGET_CC" |
504 | CFLAGS="$TARGET_CFLAGS" | |
505 | CPPFLAGS="$TARGET_CPPFLAGS" | |
506 | LDFLAGS="$TARGET_LDFLAGS" | |
aa6d7826 | 507 | LIBS="" |
b977bf01 | 508 | |
90d1e879 | 509 | # debug flags. |
4e27343f | 510 | TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations" |
76ed06b9 | 511 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g" |
6a161fa9 | 512 | |
c12936c5 VS |
513 | if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then |
514 | TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align" | |
515 | fi | |
516 | ||
6a7957f9 VS |
517 | TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)" |
518 | ||
60d5e9cb VS |
519 | AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [ |
520 | LDFLAGS="$TARGET_LDFLAGS -nostdlib -static" | |
521 | ||
522 | grub_cv_target_cc_w_extra_flags= | |
523 | for x in $EXTRA_WARN_FLAGS; do | |
524 | CFLAGS="$TARGET_CFLAGS $x -Werror" | |
37378f74 VS |
525 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
526 | asm (".globl start; start:"); | |
527 | void __main (void); | |
528 | void __main (void) {} | |
529 | int main (void); | |
530 | ]], [[]])], [flag=1], [flag=0]) | |
60d5e9cb VS |
531 | if test x$flag = x1 ; then |
532 | grub_cv_target_cc_w_extra_flags="$grub_cv_target_cc_w_extra_flags $x" | |
533 | fi | |
534 | done | |
535 | ]) | |
536 | ||
537 | TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags" | |
538 | ||
60375a88 | 539 | AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang] |
b73b70eb VS |
540 | [ |
541 | CFLAGS="$TARGET_CFLAGS" | |
542 | AC_COMPILE_IFELSE( | |
60375a88 VS |
543 | [AC_LANG_PROGRAM([], [[ |
544 | #ifdef __clang__ | |
545 | #error "is clang" | |
546 | #endif | |
547 | ]])], | |
548 | [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) | |
549 | ||
2312f06c VS |
550 | # on x86 clang doesn't support .code16 |
551 | # on arm clang doesn't support .arch directive | |
63a45330 VS |
552 | # on mips clang doesn't support privilegied instructions, doubleword store/load |
553 | # and crashes with hand-written assembly | |
554 | if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \ | |
555 | || test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \ | |
556 | || test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then | |
60375a88 VS |
557 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" |
558 | fi | |
559 | ||
b73b70eb VS |
560 | if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then |
561 | AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame] | |
562 | [ | |
563 | CFLAGS="$TARGET_CFLAGS" | |
564 | AC_COMPILE_IFELSE( | |
565 | [AC_LANG_PROGRAM([], [[ | |
566 | unsigned int a = 0, b = 0; | |
567 | asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b)); | |
568 | if (a) | |
569 | return 1; | |
570 | ]])], | |
571 | [grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])]) | |
572 | # clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly | |
573 | # used by gcrypt | |
574 | if test x$grub_cv_cc_target_clang_ame = xno ; then | |
575 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" | |
896f483d | 576 | TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as" |
b73b70eb VS |
577 | fi |
578 | fi | |
579 | ||
60375a88 VS |
580 | if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then |
581 | TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" | |
582 | fi | |
583 | ||
584 | if test "x$target_m32" = x1; then | |
585 | # Force 32-bit mode. | |
586 | TARGET_CFLAGS="$TARGET_CFLAGS -m32" | |
587 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32" | |
588 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m32" | |
589 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" | |
590 | TARGET_MODULE_FORMAT="elf32" | |
591 | fi | |
592 | ||
593 | if test "x$target_m64" = x1; then | |
594 | # Force 64-bit mode. | |
595 | TARGET_CFLAGS="$TARGET_CFLAGS -m64" | |
596 | TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64" | |
597 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -m64" | |
598 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" | |
599 | TARGET_MODULE_FORMAT="elf64" | |
600 | fi | |
601 | ||
602 | if test "x$grub_cv_cc_target_clang" = xno && test "x$target_cpu" = xi386 && test "x$platform" != xemu && test "x$platform" != xefi; then | |
603 | TARGET_CFLAGS="$TARGET_CFLAGS -mrtd -mregparm=3" | |
604 | fi | |
605 | ||
f93ddcfd VS |
606 | # on mips redirect cache flushing function to non-existant one. |
607 | if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then | |
608 | AC_CACHE_CHECK([whether -mflush-func=grub_red_herring works], [grub_cv_cc_mflush_func], [ | |
609 | CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring -Werror" | |
610 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
611 | [grub_cv_cc_mflush_func=yes], | |
612 | [grub_cv_cc_mflush_func=no]) | |
613 | ]) | |
614 | ||
615 | if test "x$grub_cv_cc_mflush_func" = xyes; then | |
616 | TARGET_CFLAGS="$TARGET_CFLAGS -mflush-func=grub_red_herring" | |
617 | fi | |
618 | fi | |
619 | ||
620 | ||
90d1e879 RM |
621 | # Force no alignment to save space on i386. |
622 | if test "x$target_cpu" = xi386; then | |
623 | AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ | |
b35ec299 | 624 | CFLAGS="$TARGET_CFLAGS -falign-loops=1 -Werror" |
eb73121d | 625 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
90d1e879 RM |
626 | [grub_cv_cc_falign_loop=yes], |
627 | [grub_cv_cc_falign_loop=no]) | |
6a161fa9 | 628 | ]) |
6a161fa9 | 629 | |
c966a489 | 630 | AC_CACHE_CHECK([whether -malign-loops works], [grub_cv_cc_malign_loop], [ |
b35ec299 | 631 | CFLAGS="$TARGET_CFLAGS -malign-loops=1 -Werror" |
c966a489 VS |
632 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
633 | [grub_cv_cc_malign_loop=yes], | |
634 | [grub_cv_cc_malign_loop=no]) | |
635 | ]) | |
636 | ||
90d1e879 RM |
637 | if test "x$grub_cv_cc_falign_loop" = xyes; then |
638 | TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" | |
c966a489 | 639 | elif test "x$grub_cv_cc_malign_loop" = xyes; then |
90d1e879 | 640 | TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" |
6a161fa9 | 641 | fi |
89e0240c | 642 | fi |
6a161fa9 | 643 | |
cdc17f60 VS |
644 | AC_CACHE_CHECK([whether -freg-struct-return works], [grub_cv_cc_freg_struct_return], [ |
645 | CFLAGS="$TARGET_CFLAGS -freg-struct-return -Werror" | |
646 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
647 | [grub_cv_cc_freg_struct_return=yes], | |
648 | [grub_cv_cc_freg_struct_return=no]) | |
649 | ]) | |
650 | ||
651 | if test "x$grub_cv_cc_freg_struct_return" = xyes; then | |
652 | TARGET_CFLAGS="$TARGET_CFLAGS -freg-struct-return" | |
653 | fi | |
654 | ||
ee0220bc | 655 | if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then |
90d1e879 RM |
656 | # Some toolchains enable these features by default, but they need |
657 | # registers that aren't set up properly in GRUB. | |
658 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" | |
659 | fi | |
77c55a87 | 660 | |
90d1e879 RM |
661 | # By default, GCC 4.4 generates .eh_frame sections containing unwind |
662 | # information in some cases where it previously did not. GRUB doesn't need | |
663 | # these and they just use up vital space. Restore the old compiler | |
664 | # behaviour. | |
665 | AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [ | |
24f4e57c | 666 | CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" |
90d1e879 RM |
667 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
668 | [grub_cv_cc_fno_dwarf2_cfi_asm=yes], | |
669 | [grub_cv_cc_fno_dwarf2_cfi_asm=no]) | |
90d1e879 | 670 | ]) |
77c55a87 | 671 | |
90d1e879 RM |
672 | if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then |
673 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" | |
b977bf01 | 674 | fi |
6a161fa9 | 675 | |
1c1f31e5 VS |
676 | if test x"$target_os" = xcygwin; then |
677 | AC_CACHE_CHECK([whether option -fno-reorder-functions works], grub_cv_cc_no_reorder_functions, [ | |
24f4e57c | 678 | CFLAGS="$TARGET_CFLAGS -fno-reorder-functions" |
1c1f31e5 VS |
679 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
680 | [grub_cv_cc_no_reorder_functions=yes], | |
681 | [grub_cv_cc_no_reorder_functions=no]) | |
682 | ]) | |
683 | fi | |
684 | ||
685 | if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xyes; then | |
686 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions" | |
687 | fi | |
688 | ||
e9d3421c VS |
689 | # By default, GCC 4.6 generates .eh_frame sections containing unwind |
690 | # information in some cases where it previously did not. GRUB doesn't need | |
691 | # these and they just use up vital space. Restore the old compiler | |
692 | # behaviour. | |
693 | AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [ | |
24f4e57c | 694 | CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" |
e9d3421c VS |
695 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
696 | [grub_cv_cc_fno_asynchronous_unwind_tables=yes], | |
697 | [grub_cv_cc_fno_asynchronous_unwind_tables=no]) | |
e9d3421c VS |
698 | ]) |
699 | ||
700 | if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then | |
701 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables" | |
702 | fi | |
703 | ||
30c7d3ce VS |
704 | AC_ARG_ENABLE([efiemu], |
705 | [AS_HELP_STRING([--enable-efiemu], | |
706 | [build and install the efiemu runtimes (default=guessed)])]) | |
707 | if test x"$enable_efiemu" = xno ; then | |
708 | efiemu_excuse="explicitly disabled" | |
709 | fi | |
6f1f6a0c | 710 | if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then |
1c1f31e5 VS |
711 | efiemu_excuse="not available on cygwin" |
712 | fi | |
30c7d3ce VS |
713 | if test x"$target_cpu" != xi386 ; then |
714 | efiemu_excuse="only available on i386" | |
715 | fi | |
716 | if test x"$platform" = xefi ; then | |
717 | efiemu_excuse="not available on efi" | |
718 | fi | |
719 | if test x"$efiemu_excuse" = x ; then | |
720 | AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [ | |
3c2304d5 | 721 | CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" |
30c7d3ce VS |
722 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
723 | [grub_cv_cc_efiemu=yes], | |
724 | [grub_cv_cc_efiemu=no]) | |
725 | ]) | |
726 | if test x$grub_cv_cc_efiemu = xno; then | |
727 | efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" | |
728 | fi | |
729 | fi | |
c2b70d09 AB |
730 | if test x"$efiemu_excuse" = x ; then |
731 | AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [ | |
732 | grub_cv_target_cc_efiemu64_link_format=unknown | |
733 | for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do | |
734 | CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" | |
735 | LDFLAGS="-m64 -Wl,$format -nostdlib -static" | |
736 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
737 | asm (".globl start; start:"); | |
738 | asm (".globl _start; _start:"); | |
739 | asm (".globl __start; __start:"); | |
740 | void __main (void); | |
741 | void __main (void) {} | |
742 | ]], [[]])], [flag=1], [flag=0]) | |
743 | if test x"$flag" = x1; then | |
744 | grub_cv_target_cc_efiemu64_link_format="$format" | |
4d94b2db | 745 | break |
c2b70d09 AB |
746 | fi |
747 | done]) | |
748 | if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then | |
749 | efiemu_excuse="no suitable link format for efiemu64 found" | |
750 | else | |
751 | EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format" | |
752 | fi | |
753 | fi | |
30c7d3ce | 754 | if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then |
d642d761 | 755 | AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)]) |
30c7d3ce VS |
756 | fi |
757 | if test x"$efiemu_excuse" = x ; then | |
758 | enable_efiemu=yes | |
759 | else | |
760 | enable_efiemu=no | |
761 | fi | |
762 | AC_SUBST([enable_efiemu]) | |
c2b70d09 | 763 | AC_SUBST([EFIEMU64_LINK_FORMAT]) |
30c7d3ce | 764 | |
a9f25a08 VS |
765 | CFLAGS="$TARGET_CFLAGS" |
766 | ||
bf082198 VS |
767 | |
768 | if test x"$platform" = xemu ; then | |
769 | TARGET_OBJ2ELF= | |
770 | grub_cv_target_cc_link_format= | |
771 | case "$host_os" in | |
772 | *darwin* | *mac*) | |
773 | grub_cv_target_cc_link_format="-arch,${target_cpu}" | |
774 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" | |
775 | ;; | |
776 | *windows* | *cygwin* | *mingw*) | |
777 | if test x${target_cpu} = xi386 ; then | |
4d94b2db CW |
778 | grub_cv_target_cc_link_format=-mi386pe |
779 | TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)' | |
bf082198 VS |
780 | fi |
781 | if test x${target_cpu} = xx86_64 ; then | |
4d94b2db CW |
782 | grub_cv_target_cc_link_format=-mi386pep |
783 | TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)' | |
bf082198 VS |
784 | fi |
785 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" | |
786 | ;; | |
787 | esac | |
788 | elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then | |
c2b70d09 | 789 | AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [ |
a9f25a08 | 790 | grub_cv_target_cc_link_format=unknown |
6f1f6a0c | 791 | for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -mi386pe -mi386pep -arch,${target_cpu}; do |
bf082198 | 792 | if test x${target_cpu} != xi386 && test x$format = x-mi386pe; then |
6f1f6a0c VS |
793 | continue |
794 | fi | |
bf082198 | 795 | if test x${target_cpu} != xx86_64 && test x$format = x-mi386pep; then |
a9f25a08 VS |
796 | continue |
797 | fi | |
246a434f VS |
798 | CFLAGS="$TARGET_CFLAGS" |
799 | LDFLAGS="$TARGET_LDFLAGS -Wl,$format -nostdlib -static" | |
a9f25a08 VS |
800 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
801 | asm (".globl start; start:"); | |
802 | asm (".globl _start; _start:"); | |
803 | asm (".globl __start; __start:"); | |
804 | void __main (void); | |
805 | void __main (void) {} | |
c2b70d09 | 806 | ]], [[]])], [flag=1], [flag=0]) |
a9f25a08 VS |
807 | if test x"$flag" = x1; then |
808 | grub_cv_target_cc_link_format="$format" | |
4d94b2db | 809 | break |
a9f25a08 VS |
810 | fi |
811 | done]) | |
812 | if test x"$grub_cv_target_cc_link_format" = xunknown; then | |
813 | AC_MSG_ERROR([no suitable link format found]) | |
814 | fi | |
815 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" | |
6f1f6a0c | 816 | if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then |
4d94b2db | 817 | TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)' |
a9f25a08 | 818 | fi |
6f1f6a0c | 819 | if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then |
4d94b2db | 820 | TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)' |
6f1f6a0c | 821 | fi |
a9f25a08 VS |
822 | fi |
823 | ||
824 | if test x$grub_cv_target_cc_link_format = x-arch,i386 || test x$grub_cv_target_cc_link_format = x-arch,x86_64; then | |
825 | TARGET_APPLE_LINKER=1 | |
826 | AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [objconv], []) | |
827 | if test "x$TARGET_OBJCONV" = x ; then | |
828 | AC_CHECK_PROG([TARGET_OBJCONV], [objconv], [./objconv], [], [.]) | |
829 | fi | |
830 | if test "x$TARGET_OBJCONV" = x ; then | |
831 | AC_MSG_ERROR([objconv not found which is required when building with apple compiler]) | |
832 | fi | |
833 | TARGET_IMG_LDSCRIPT= | |
834 | TARGET_IMG_CFLAGS="-static" | |
835 | TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20' | |
836 | TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20' | |
837 | TARGET_IMG_BASE_LDOPT="-Wl,-image_base" | |
838 | TARGET_LDFLAGS_OLDMAGIC="" | |
6f1f6a0c | 839 | elif test x$grub_cv_target_cc_link_format = x-mi386pe || test x$grub_cv_target_cc_link_format = x-mi386pep ; then |
a9f25a08 VS |
840 | TARGET_APPLE_LINKER=0 |
841 | TARGET_LDFLAGS_OLDMAGIC="-Wl,-N" | |
60b967be | 842 | TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/${grub_coredir}/conf/i386-cygwin-img-ld.sc" |
a9f25a08 | 843 | TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}" |
60b967be | 844 | TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/${grub_coredir}/conf/i386-cygwin-img-ld.sc" |
a9f25a08 VS |
845 | TARGET_IMG_BASE_LDOPT="-Wl,-Ttext" |
846 | TARGET_IMG_CFLAGS= | |
847 | else | |
848 | TARGET_APPLE_LINKER=0 | |
849 | TARGET_LDFLAGS_OLDMAGIC="-Wl,-N" | |
850 | TARGET_IMG_LDSCRIPT= | |
851 | TARGET_IMG_LDFLAGS='-Wl,-N' | |
852 | TARGET_IMG_LDFLAGS_AC='-Wl,-N' | |
853 | TARGET_IMG_BASE_LDOPT="-Wl,-Ttext" | |
854 | TARGET_IMG_CFLAGS= | |
855 | fi | |
856 | ||
857 | AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) | |
858 | ||
859 | ||
860 | LDFLAGS="$TARGET_LDFLAGS" | |
8f0baaac | 861 | |
eaf01c25 | 862 | if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; then |
7e9ca17a | 863 | # Use large model to support 4G memory |
6e09b8b7 | 864 | AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ |
2a5a532c | 865 | CFLAGS="$TARGET_CFLAGS -mcmodel=large" |
6e09b8b7 | 866 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
867 | [grub_cv_cc_mcmodel=yes], | |
868 | [grub_cv_cc_mcmodel=no]) | |
869 | ]) | |
a3ba7410 | 870 | if test "x$grub_cv_cc_mcmodel" = xyes; then |
c8600122 | 871 | TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large" |
eaf01c25 VS |
872 | elif test "$target_cpu-$platform" = sparc64-emu; then |
873 | TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany" | |
6e09b8b7 | 874 | fi |
46546fc5 | 875 | fi |
7e9ca17a | 876 | |
46546fc5 | 877 | if test "$target_cpu"-"$platform" = x86_64-efi; then |
7e9ca17a | 878 | # EFI writes to stack below %rsp, we must not use the red zone |
879 | AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [ | |
2a5a532c | 880 | CFLAGS="$TARGET_CFLAGS -mno-red-zone" |
7e9ca17a | 881 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
882 | [grub_cv_cc_no_red_zone=yes], | |
883 | [grub_cv_cc_no_red_zone=no]) | |
884 | ]) | |
885 | if test "x$grub_cv_cc_no_red_zone" = xno; then | |
886 | AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc]) | |
887 | fi | |
888 | ||
c8600122 | 889 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone" |
20011694 | 890 | fi |
891 | ||
41822625 VS |
892 | if test "x$target_cpu" = xarm; then |
893 | AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [ | |
894 | CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror" | |
895 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
896 | [grub_cv_cc_mlong_calls=yes], | |
897 | [grub_cv_cc_mlong_calls=no]) | |
898 | ]) | |
899 | if test "x$grub_cv_cc_mlong_calls" = xyes; then | |
900 | TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls" | |
901 | fi | |
a29f317a VS |
902 | AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [ |
903 | CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror" | |
904 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
905 | [grub_cv_cc_mthumb_interwork=yes], | |
906 | [grub_cv_cc_mthumb_interwork=no]) | |
907 | ]) | |
908 | if test "x$grub_cv_cc_mthumb_interwork" = xyes; then | |
909 | TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork" | |
910 | elif test "x$grub_cv_cc_target_clang" = xno ; then | |
911 | AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork]) | |
912 | else | |
913 | CFLAGS="$TARGET_CFLAGS" | |
914 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ | |
915 | #if defined (__thumb__) && !defined (__thumb2__) | |
916 | #error thumb without interworking | |
917 | #endif | |
918 | ]])], | |
919 | [no_interwork_ok=yes], | |
920 | [no_interwork_ok=no]) | |
921 | if test x$no_interwork_ok = xno ; then | |
922 | AC_MSG_ERROR([attempt to compile to thumb with no thumb interwork]) | |
923 | fi | |
924 | fi | |
41822625 VS |
925 | fi |
926 | ||
57bc5d43 VS |
927 | AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [ |
928 | CFLAGS="$TARGET_CFLAGS -Qn -Werror" | |
929 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
930 | [grub_cv_target_cc_qn=yes], | |
931 | [grub_cv_target_cc_qn=no])]) | |
932 | if test "x$grub_cv_target_cc_qn" = xyes; then | |
933 | TARGET_CFLAGS="$TARGET_CFLAGS -Qn" | |
934 | fi | |
935 | ||
baa2a121 | 936 | # |
937 | # Compiler features. | |
938 | # | |
939 | ||
28668d80 VS |
940 | CFLAGS="$TARGET_CFLAGS" |
941 | ||
93a81088 | 942 | # Position independent executable. |
943 | grub_CHECK_PIE | |
944 | [# Need that, because some distributions ship compilers that include | |
945 | # `-fPIE' in the default specs. | |
946 | if [ x"$pie_possible" = xyes ]; then | |
947 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" | |
948 | fi] | |
949 | ||
28668d80 VS |
950 | CFLAGS="$TARGET_CFLAGS" |
951 | ||
7bd8b0c7 VS |
952 | # Position independent executable. |
953 | grub_CHECK_PIC | |
9cf12b20 VS |
954 | [# On most platforms we don't want PIC as it only makes relocations harder |
955 | # and code less efficient. On mips we want to have one got table per module | |
956 | # and reload $gp in every function. | |
957 | # GCC implements it using symbol __gnu_local_gp in non-PIC as well. | |
958 | # However with clang we need PIC for this reloading to happen. | |
959 | # Since default varies across dictributions use either -fPIC or -fno-PIC | |
960 | # explicitly. | |
961 | if ( test x$target_cpu = xmips || test x$target_cpu = xmipsel ) && test "x$grub_cv_cc_target_clang" = xyes ; then | |
962 | TARGET_CFLAGS="$TARGET_CFLAGS -fPIC" | |
963 | elif [ x"$pic_possible" = xyes ]; then | |
964 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIC" | |
7bd8b0c7 VS |
965 | fi] |
966 | ||
28668d80 VS |
967 | CFLAGS="$TARGET_CFLAGS" |
968 | ||
baa2a121 | 969 | # Smashing stack protector. |
970 | grub_CHECK_STACK_PROTECTOR | |
c3db8364 | 971 | # Need that, because some distributions ship compilers that include |
baa2a121 | 972 | # `-fstack-protector' in the default specs. |
c3db8364 | 973 | if test "x$ssp_possible" = xyes; then |
974 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector" | |
975 | fi | |
28668d80 VS |
976 | |
977 | CFLAGS="$TARGET_CFLAGS" | |
978 | ||
2a8a80e4 | 979 | grub_CHECK_STACK_ARG_PROBE |
980 | # Cygwin's GCC uses alloca() to probe the stackframe on static | |
981 | # stack allocations above some threshold. | |
982 | if test x"$sap_possible" = xyes; then | |
983 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" | |
984 | fi | |
baa2a121 | 985 | |
28668d80 VS |
986 | CFLAGS="$TARGET_CFLAGS" |
987 | ||
d74b9a1d | 988 | # -mno-unaligned-access -mstrict-align |
bb9f92b9 | 989 | if test "$target_cpu" = arm; then |
d74b9a1d | 990 | AC_CACHE_CHECK([for compile options to get strict alignment], [grub_cv_target_cc_strict_align], [ |
bdb6090d | 991 | grub_cv_target_cc_strict_align= |
d74b9a1d VS |
992 | for arg in -mno-unaligned-access "-Xclang -mstrict-align" -mstrict-align; do |
993 | CFLAGS="$TARGET_CFLAGS $arg -Werror" | |
994 | LDFLAGS="$TARGET_LDFLAGS" | |
995 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0]) | |
996 | if test x"$flag" = x1; then | |
997 | grub_cv_target_cc_strict_align="$arg" | |
4d94b2db | 998 | break |
d74b9a1d VS |
999 | fi |
1000 | done]) | |
1001 | ||
d74b9a1d VS |
1002 | TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_strict_align" |
1003 | if test x"$grub_cv_target_cc_strict_align" = x"-Xclang -mstrict-align"; then | |
1004 | TARGET_LDFLAGS="$TARGET_LDFLAGS -Qunused-arguments" | |
bb9f92b9 | 1005 | fi |
bdb6090d VS |
1006 | AC_CACHE_CHECK([if compiler generates unaligned accesses], [grub_cv_cc_target_emits_unaligned], |
1007 | [CFLAGS="$TARGET_CFLAGS" | |
1008 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ | |
1009 | #ifdef __ARM_FEATURE_UNALIGNED | |
1010 | #error "unaligned" | |
1011 | #endif | |
1012 | ]])], | |
1013 | [grub_cv_cc_target_emits_unaligned=no], [grub_cv_cc_target_emits_unaligned=yes])]) | |
1014 | if test x$grub_cv_cc_target_emits_unaligned = xyes; then | |
1015 | AC_MSG_ERROR([compiler generates unaligned accesses]) | |
1016 | fi | |
bb9f92b9 LL |
1017 | fi |
1018 | ||
aa6d7826 | 1019 | # Set them to their new values for the tests below. |
1020 | CC="$TARGET_CC" | |
a9f25a08 | 1021 | if test "x$TARGET_APPLE_LINKER" = x1 ; then |
246a434f | 1022 | CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error" |
26de2bcd | 1023 | else |
37378f74 | 1024 | CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" |
26de2bcd | 1025 | fi |
aa6d7826 | 1026 | CPPFLAGS="$TARGET_CPPFLAGS" |
d5524ca8 VS |
1027 | if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then |
1028 | TARGET_LIBGCC= | |
03f80960 | 1029 | else |
d5524ca8 | 1030 | TARGET_LIBGCC=-lgcc |
03f80960 | 1031 | fi |
69be5b74 | 1032 | |
d5524ca8 VS |
1033 | LIBS="$TARGET_LIBGCC" |
1034 | ||
01fcf061 | 1035 | grub_ASM_USCORE |
a9f25a08 | 1036 | if test "x$TARGET_APPLE_LINKER" = x0 ; then |
01fcf061 | 1037 | if test x$grub_cv_asm_uscore = xyes; then |
37378f74 | 1038 | DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main" |
01fcf061 | 1039 | else |
37378f74 | 1040 | DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main" |
01fcf061 | 1041 | fi |
37378f74 | 1042 | CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM" |
a9f25a08 | 1043 | fi |
01fcf061 | 1044 | |
69be5b74 | 1045 | # Check for libgcc symbols |
6fcec439 | 1046 | AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x) |
69be5b74 | 1047 | |
a9f25a08 | 1048 | if test "x$TARGET_APPLE_LINKER" = x1 ; then |
246a434f | 1049 | CFLAGS="$TARGET_CFLAGS -nostdlib -static" |
69be5b74 | 1050 | else |
37378f74 | 1051 | CFLAGS="$TARGET_CFLAGS -nostdlib" |
69be5b74 | 1052 | fi |
42e0cba3 | 1053 | LIBS="" |
aa6d7826 | 1054 | |
6a161fa9 | 1055 | # Defined in aclocal.m4. |
f6130a12 | 1056 | grub_PROG_TARGET_CC |
a9f25a08 | 1057 | if test "x$TARGET_APPLE_LINKER" != x1 ; then |
b977bf01 | 1058 | grub_PROG_OBJCOPY_ABSOLUTE |
2b167a72 | 1059 | fi |
cb71ba20 | 1060 | grub_PROG_LD_BUILD_ID_NONE |
b977bf01 | 1061 | if test "x$target_cpu" = xi386; then |
a9f25a08 | 1062 | if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then |
2aec1692 CF |
1063 | if test ! -z "$TARGET_IMG_LDSCRIPT"; then |
1064 | # Check symbols provided by linker script. | |
37378f74 | 1065 | CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},0x8000" |
2aec1692 | 1066 | fi |
2a8a80e4 | 1067 | grub_CHECK_BSS_START_SYMBOL |
1068 | grub_CHECK_END_SYMBOL | |
1069 | fi | |
1070 | CFLAGS="$TARGET_CFLAGS" | |
4b13b216 | 1071 | grub_I386_ASM_PREFIX_REQUIREMENT |
1072 | grub_I386_ASM_ADDR32 | |
6a161fa9 | 1073 | fi |
1074 | ||
20aea949 VS |
1075 | grub_PROG_NM_WORKS |
1076 | grub_PROG_NM_MINUS_P | |
1077 | grub_PROG_NM_DEFINED_ONLY | |
1078 | AC_SUBST(TARGET_NMFLAGS_MINUS_P) | |
1079 | AC_SUBST(TARGET_NMFLAGS_DEFINED_ONLY) | |
1080 | ||
016a671b | 1081 | if test "$platform" != emu; then |
8f9a632b VS |
1082 | AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [ |
1083 | SAVED_CPPFLAGS="$CPPFLAGS" | |
1084 | CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`" | |
1085 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> | |
ce938140 | 1086 | #include <stddef.h> |
8f9a632b VS |
1087 | int va_arg_func (int fixed, va_list args);]], [[]])], |
1088 | [grub_cv_cc_isystem=yes], | |
1089 | [grub_cv_cc_isystem=no]) | |
1090 | CPPFLAGS="$SAVED_CPPFLAGS" | |
1091 | ]) | |
1092 | ||
1093 | if test x"$grub_cv_cc_isystem" = xyes ; then | |
1094 | TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`" | |
1095 | fi | |
dae79b6b | 1096 | fi |
5ce5507f | 1097 | |
19ce697d | 1098 | AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [ |
24f4e57c | 1099 | CFLAGS="$TARGET_CFLAGS -Wtrampolines -Werror" |
779dc15b VS |
1100 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h> |
1101 | int va_arg_func (int fixed, va_list args);]], [[]])], | |
19ce697d VS |
1102 | [grub_cv_cc_wtrampolines=yes], |
1103 | [grub_cv_cc_wtrampolines=no]) | |
779dc15b VS |
1104 | ]) |
1105 | ||
19ce697d VS |
1106 | if test x"$grub_cv_cc_wtrampolines" = xyes ; then |
1107 | TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines" | |
779dc15b VS |
1108 | fi |
1109 | ||
c9a86192 | 1110 | # Restore the flags. |
9962ed99 | 1111 | CC="$tmp_CC" |
1112 | CFLAGS="$tmp_CFLAGS" | |
1113 | CPPFLAGS="$tmp_CPPFLAGS" | |
c9a86192 | 1114 | LDFLAGS="$tmp_LDFLAGS" |
aa6d7826 | 1115 | LIBS="$tmp_LIBS" |
6a161fa9 | 1116 | |
4fe9862e | 1117 | # |
2965c7cc | 1118 | # Check for options. |
4fe9862e | 1119 | # |
1120 | ||
1121 | # Memory manager debugging. | |
b39f9d20 | 1122 | AC_ARG_ENABLE([mm-debug], |
2965c7cc | 1123 | AS_HELP_STRING([--enable-mm-debug], |
90ce5d56 | 1124 | [include memory manager debugging]), |
2965c7cc | 1125 | [AC_DEFINE([MM_DEBUG], [1], |
1126 | [Define to 1 if you enable memory manager debugging.])]) | |
1127 | ||
c5dc1690 SJ |
1128 | AC_ARG_ENABLE([cache-stats], |
1129 | AS_HELP_STRING([--enable-cache-stats], | |
055e2b8b | 1130 | [enable disk cache statistics collection])) |
c5dc1690 SJ |
1131 | |
1132 | if test x$enable_cache_stats = xyes; then | |
1133 | DISK_CACHE_STATS=1 | |
1134 | else | |
1135 | DISK_CACHE_STATS=0 | |
1136 | fi | |
1137 | AC_SUBST([DISK_CACHE_STATS]) | |
1138 | ||
e744219b VS |
1139 | AC_ARG_ENABLE([boot-time], |
1140 | AS_HELP_STRING([--enable-boot-time], | |
1141 | [enable boot time statistics collection])) | |
1142 | ||
1143 | if test x$enable_boot_time = xyes; then | |
1144 | BOOT_TIME_STATS=1 | |
1145 | else | |
1146 | BOOT_TIME_STATS=0 | |
1147 | fi | |
1148 | AC_SUBST([BOOT_TIME_STATS]) | |
1149 | ||
d64399b5 | 1150 | AC_ARG_ENABLE([grub-emu-usb], |
1151 | [AS_HELP_STRING([--enable-grub-emu-usb], | |
5ce5507f | 1152 | [build and install the `grub-emu' debugging utility with USB support (default=guessed)])]) |
5ce5507f | 1153 | |
927d0134 VS |
1154 | AC_ARG_ENABLE([grub-emu-sdl], |
1155 | [AS_HELP_STRING([--enable-grub-emu-sdl], | |
1156 | [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])]) | |
1157 | ||
3affd0ec | 1158 | AC_ARG_ENABLE([grub-emu-pci], |
1159 | [AS_HELP_STRING([--enable-grub-emu-pci], | |
1160 | [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])]) | |
1161 | ||
f84b481b | 1162 | if test "$platform" = emu; then |
f84b481b | 1163 | |
62a747cb VS |
1164 | if test x"$enable_grub_emu_usb" != xyes ; then |
1165 | grub_emu_usb_excuse="not enabled" | |
5ce5507f | 1166 | fi |
325c8258 | 1167 | |
0e848909 VS |
1168 | if test x"$enable_grub_emu_pci" = xyes ; then |
1169 | grub_emu_usb_excuse="conflicts with PCI support" | |
1170 | fi | |
1171 | ||
5ce5507f | 1172 | [if [ x"$grub_emu_usb_excuse" = x ]; then |
d64399b5 | 1173 | # Check for libusb libraries.] |
5ce5507f | 1174 | AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"], |
e98cd0c2 | 1175 | [grub_emu_usb_excuse=["need libusb library"]]) |
d64399b5 | 1176 | AC_SUBST([LIBUSB]) |
5ce5507f | 1177 | [fi] |
1178 | [if [ x"$grub_emu_usb_excuse" = x ]; then | |
1179 | # Check for headers.] | |
d64399b5 | 1180 | AC_CHECK_HEADERS([usb.h], [], |
e98cd0c2 | 1181 | [grub_emu_usb_excuse=["need libusb headers"]]) |
4fe9862e | 1182 | [fi] |
c6f3b249 | 1183 | if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then |
d642d761 | 1184 | AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled ($grub_emu_usb_excuse)]) |
5ce5507f | 1185 | fi |
1186 | if test x"$grub_emu_usb_excuse" = x ; then | |
1187 | enable_grub_emu_usb=yes | |
1188 | else | |
1189 | enable_grub_emu_usb=no | |
1190 | fi | |
1191 | ||
927d0134 | 1192 | if test x"$enable_grub_emu_sdl" = xno ; then |
16f7455b | 1193 | grub_emu_sdl_excuse="explicitly disabled" |
927d0134 VS |
1194 | fi |
1195 | [if [ x"$grub_emu_sdl_excuse" = x ]; then | |
1196 | # Check for libSDL libraries.] | |
1197 | AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"], | |
1198 | [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]]) | |
1199 | AC_SUBST([LIBSDL]) | |
1200 | [fi] | |
9f293ab0 | 1201 | |
927d0134 VS |
1202 | [if [ x"$grub_emu_sdl_excuse" = x ]; then |
1203 | # Check for headers.] | |
1204 | AC_CHECK_HEADERS([SDL/SDL.h], [], | |
1205 | [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]]) | |
1206 | [fi] | |
9f293ab0 | 1207 | |
927d0134 | 1208 | if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then |
16f7455b | 1209 | AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)]) |
927d0134 VS |
1210 | fi |
1211 | if test x"$grub_emu_sdl_excuse" = x ; then | |
1212 | enable_grub_emu_sdl=yes | |
1213 | else | |
1214 | enable_grub_emu_sdl=no | |
1215 | fi | |
1216 | ||
3affd0ec | 1217 | if test x"$enable_grub_emu_pci" != xyes ; then |
325c8258 | 1218 | grub_emu_pci_excuse="not enabled" |
1219 | fi | |
1220 | ||
1221 | if test x"$enable_grub_emu_usb" = xyes ; then | |
1222 | grub_emu_pci_excuse="conflicts with USB support" | |
1223 | fi | |
1224 | ||
1225 | [if [ x"$grub_emu_pci_excuse" = x ]; then | |
1226 | # Check for libpci libraries.] | |
459fed4b | 1227 | AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"], |
1228 | [grub_emu_pci_excuse=["need libpciaccess library"]]) | |
1229 | AC_SUBST([LIBPCIACCESS]) | |
325c8258 | 1230 | [fi] |
1231 | [if [ x"$grub_emu_pci_excuse" = x ]; then | |
1232 | # Check for headers.] | |
1233 | AC_CHECK_HEADERS([pci/pci.h], [], | |
459fed4b | 1234 | [grub_emu_pci_excuse=["need libpciaccess headers"]]) |
325c8258 | 1235 | [fi] |
1236 | ||
1237 | if test x"$grub_emu_pci_excuse" = x ; then | |
1238 | enable_grub_emu_pci=yes | |
1239 | else | |
9f293ab0 | 1240 | |
325c8258 | 1241 | enable_grub_emu_pci=no |
3affd0ec | 1242 | fi |
1243 | ||
927d0134 | 1244 | AC_SUBST([enable_grub_emu_sdl]) |
d64399b5 | 1245 | AC_SUBST([enable_grub_emu_usb]) |
3affd0ec | 1246 | AC_SUBST([enable_grub_emu_pci]) |
e7d09ac4 AB |
1247 | |
1248 | else | |
1249 | ||
1250 | # Ignore --enable-emu-* if platform is not emu | |
1251 | enable_grub_emu_sdl=no | |
1252 | enable_grub_emu_usb=no | |
1253 | enable_grub_emu_pci=no | |
f84b481b | 1254 | fi |
4fe9862e | 1255 | |
e52db1f7 | 1256 | AC_ARG_ENABLE([grub-mkfont], |
1257 | [AS_HELP_STRING([--enable-grub-mkfont], | |
5ce5507f | 1258 | [build and install the `grub-mkfont' utility (default=guessed)])]) |
1259 | if test x"$enable_grub_mkfont" = xno ; then | |
ce7a733d | 1260 | grub_mkfont_excuse="explicitly disabled" |
5ce5507f | 1261 | fi |
1262 | ||
1263 | if test x"$grub_mkfont_excuse" = x ; then | |
e52db1f7 | 1264 | # Check for freetype libraries. |
a5b55c4b | 1265 | AC_CHECK_TOOLS([FREETYPE], [freetype-config]) |
e52db1f7 | 1266 | if test "x$FREETYPE" = x ; then |
e98cd0c2 | 1267 | grub_mkfont_excuse=["need freetype2 library"] |
e52db1f7 | 1268 | fi |
e52db1f7 | 1269 | fi |
660960d6 | 1270 | |
7b780018 VS |
1271 | unset ac_cv_header_ft2build_h |
1272 | ||
660960d6 VS |
1273 | if test x"$grub_mkfont_excuse" = x ; then |
1274 | # Check for freetype libraries. | |
a5b55c4b DM |
1275 | freetype_cflags=`$FREETYPE --cflags` |
1276 | freetype_libs=`$FREETYPE --libs` | |
d1e8a02f | 1277 | SAVED_CPPFLAGS="$CPPFLAGS" |
b75db69a | 1278 | SAVED_LIBS="$LIBS" |
d1e8a02f | 1279 | CPPFLAGS="$CPPFLAGS $freetype_cflags" |
b75db69a | 1280 | LIBS="$LIBS $freetype_libs" |
660960d6 VS |
1281 | AC_CHECK_HEADERS([ft2build.h], [], |
1282 | [grub_mkfont_excuse=["need freetype2 headers"]]) | |
b75db69a | 1283 | AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_mkfont_excuse=["freetype2 library unusable"]]) |
d1e8a02f | 1284 | CPPFLAGS="$SAVED_CPPFLAGS" |
b75db69a | 1285 | LIBS="$SAVED_LIBS" |
660960d6 VS |
1286 | fi |
1287 | ||
5ce5507f | 1288 | if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then |
d642d761 | 1289 | AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)]) |
5ce5507f | 1290 | fi |
1291 | if test x"$grub_mkfont_excuse" = x ; then | |
1292 | enable_grub_mkfont=yes | |
1293 | else | |
1294 | enable_grub_mkfont=no | |
1295 | fi | |
e52db1f7 | 1296 | AC_SUBST([enable_grub_mkfont]) |
1297 | AC_SUBST([freetype_cflags]) | |
1298 | AC_SUBST([freetype_libs]) | |
1299 | ||
7c9d0c39 | 1300 | SAVED_CC="$CC" |
b224c266 | 1301 | SAVED_CPP="$CPP" |
7c9d0c39 VS |
1302 | SAVED_CFLAGS="$CFLAGS" |
1303 | SAVED_CPPFLAGS="$CPPFLAGS" | |
dcecae1a | 1304 | SAVED_LDFLAGS="$LDFLAGS" |
7c9d0c39 | 1305 | CC="$BUILD_CC" |
b224c266 | 1306 | CPP="$BUILD_CPP" |
7c9d0c39 | 1307 | CFLAGS="$BUILD_CFLAGS" |
7b780018 | 1308 | CPPFLAGS="$BUILD_CPPFLAGS" |
dcecae1a | 1309 | LDFLAGS="$BUILD_LDFAGS" |
7b780018 VS |
1310 | |
1311 | unset ac_cv_c_bigendian | |
1312 | unset ac_cv_header_ft2build_h | |
1313 | ||
1314 | AC_COMPUTE_INT([BUILD_SIZEOF_VOID_P], [sizeof (void *)]) | |
1315 | AC_COMPUTE_INT([BUILD_SIZEOF_LONG], [sizeof (long)]) | |
1316 | AC_C_BIGENDIAN([BUILD_WORDS_BIGENDIAN=1], [BUILD_WORDS_BIGENDIAN=0], [BUILD_WORDS_BIGENDIAN=err], [BUILD_WORDS_BIGENDIAN=err]) | |
1317 | ||
1318 | if test x$BUILD_WORDS_BIGENDIAN = xerr ; then | |
1319 | AC_MSG_ERROR([couldnt determine build endianness]) | |
1320 | fi | |
1321 | ||
1322 | AC_SUBST([BUILD_SIZEOF_LONG]) | |
1323 | AC_SUBST([BUILD_SIZEOF_VOID_P]) | |
1324 | AC_SUBST([BUILD_WORDS_BIGENDIAN]) | |
c5884973 | 1325 | |
7c9d0c39 VS |
1326 | if test x"$grub_build_mkfont_excuse" = x ; then |
1327 | # Check for freetype libraries. | |
7b780018 | 1328 | AC_CHECK_PROGS([BUILD_FREETYPE], [freetype-config]) |
7c9d0c39 VS |
1329 | if test "x$BUILD_FREETYPE" = x ; then |
1330 | grub_build_mkfont_excuse=["need freetype2 library"] | |
1331 | fi | |
1332 | fi | |
c5884973 | 1333 | |
7c9d0c39 VS |
1334 | if test x"$grub_build_mkfont_excuse" = x ; then |
1335 | # Check for freetype libraries. | |
1336 | build_freetype_cflags=`$BUILD_FREETYPE --cflags` | |
1337 | build_freetype_libs=`$BUILD_FREETYPE --libs` | |
1338 | SAVED_CPPFLAGS_2="$CPPFLAGS" | |
b75db69a | 1339 | SAVED_LIBS="$LIBS" |
7c9d0c39 | 1340 | CPPFLAGS="$CPPFLAGS $build_freetype_cflags" |
b75db69a | 1341 | LIBS="$LIBS $build_freetype_libs" |
7c9d0c39 VS |
1342 | AC_CHECK_HEADERS([ft2build.h], [], |
1343 | [grub_build_mkfont_excuse=["need freetype2 headers"]]) | |
b75db69a VS |
1344 | AC_LINK_IFELSE([AC_LANG_CALL([], [FT_Load_Glyph])], [], [grub_build_mkfont_excuse=["freetype2 library unusable"]]) |
1345 | LIBS="$SAVED_LIBS" | |
7c9d0c39 VS |
1346 | CPPFLAGS="$SAVED_CPPFLAGS_2" |
1347 | fi | |
1348 | ||
1349 | if test x"$enable_build_grub_mkfont" = xyes && test x"$grub_build_mkfont_excuse" != x ; then | |
d642d761 | 1350 | AC_MSG_ERROR([build-grub-mkfont was explicitly requested but can't be compiled ($grub_build_mkfont_excuse)]) |
7c9d0c39 VS |
1351 | fi |
1352 | if test x"$grub_build_mkfont_excuse" = x ; then | |
1353 | enable_build_grub_mkfont=yes | |
1354 | else | |
1355 | enable_build_grub_mkfont=no | |
c5884973 | 1356 | fi |
72c9a507 | 1357 | 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 || test "x$platform" = xcoreboot ); then |
d642d761 CW |
1358 | if test x"$grub_build_mkfont_excuse" = x ; then |
1359 | AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont]) | |
1360 | else | |
1361 | AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont ($grub_build_mkfont_excuse)]) | |
1362 | fi | |
7c9d0c39 VS |
1363 | fi |
1364 | ||
1365 | AC_SUBST([build_freetype_cflags]) | |
1366 | AC_SUBST([build_freetype_libs]) | |
1367 | ||
1368 | CC="$SAVED_CC" | |
b224c266 | 1369 | CPP="$SAVED_CPP" |
7c9d0c39 VS |
1370 | CFLAGS="$SAVED_CFLAGS" |
1371 | CPPFLAGS="$SAVED_CPPFLAGS" | |
dcecae1a | 1372 | LDFLAGS="$SAVED_LDFLAGS" |
7c9d0c39 VS |
1373 | |
1374 | ||
1375 | DJVU_FONT_SOURCE= | |
1376 | ||
1377 | starfield_excuse= | |
c5884973 | 1378 | |
300f48c5 VS |
1379 | AC_ARG_ENABLE([grub-themes], |
1380 | [AS_HELP_STRING([--enable-grub-themes], | |
1381 | [build and install GRUB themes (default=guessed)])]) | |
1382 | if test x"$enable_grub_themes" = xno ; then | |
1383 | starfield_excuse="explicitly disabled" | |
1384 | fi | |
1385 | ||
1386 | if test x"$starfield_excuse" = x && test x"$enable_build_grub_mkfont" = xno ; then | |
7b966834 VS |
1387 | starfield_excuse="No build-time grub-mkfont" |
1388 | fi | |
1389 | ||
501b9e4b | 1390 | if test x"$starfield_excuse" = x; then |
c5884973 | 1391 | for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do |
36387ece | 1392 | for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do |
c5884973 DO |
1393 | if test -f "$dir/DejaVuSans.$ext"; then |
1394 | DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext" | |
1395 | break 2 | |
1396 | fi | |
1397 | done | |
1398 | done | |
1399 | ||
1400 | if test "x$DJVU_FONT_SOURCE" = x; then | |
1401 | starfield_excuse="No DejaVu found" | |
1402 | fi | |
1403 | fi | |
1404 | ||
300f48c5 | 1405 | if test x"$enable_grub_themes" = xyes && test x"$starfield_excuse" != x; then |
d642d761 | 1406 | AC_MSG_ERROR([themes were explicitly requested but requirements are not satisfied ($starfield_excuse)]) |
300f48c5 VS |
1407 | fi |
1408 | ||
c5884973 DO |
1409 | AC_SUBST([DJVU_FONT_SOURCE]) |
1410 | ||
7c9d0c39 VS |
1411 | FONT_SOURCE= |
1412 | ||
1413 | for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do | |
1414 | 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 | |
1415 | if test -f "$dir/unifont.$ext"; then | |
0277eab7 VS |
1416 | md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')" |
1417 | # PCF and BDF from version 6.3 isn't hanled properly by libfreetype. | |
1418 | if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then | |
4d94b2db | 1419 | continue |
0277eab7 | 1420 | fi |
7c9d0c39 VS |
1421 | FONT_SOURCE="$dir/unifont.$ext" |
1422 | break 2 | |
1423 | fi | |
1424 | done | |
1425 | done | |
1426 | ||
7b966834 VS |
1427 | if test x"$enable_build_grub_mkfont" = xno ; then |
1428 | FONT_SOURCE= | |
1429 | fi | |
1430 | ||
72c9a507 | 1431 | 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 || test "x$platform" = xcoreboot ); then |
d642d761 CW |
1432 | if test x"$grub_build_mkfont_excuse" = x ; then |
1433 | AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont]) | |
1434 | else | |
1435 | AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)]) | |
1436 | fi | |
7c9d0c39 VS |
1437 | fi |
1438 | ||
1439 | AC_SUBST([FONT_SOURCE]) | |
1440 | ||
7b780018 | 1441 | if test x"$FONT_SOURCE" = x && test x"$DJVU_FONT_SOURCE" = x && test x"$grub_build_mkfont_excuse" = x; then |
7c9d0c39 VS |
1442 | grub_build_mkfont_excuse="no fonts" |
1443 | fi | |
1444 | ||
1445 | ||
897e6207 CW |
1446 | AC_ARG_ENABLE([grub-mount], |
1447 | [AS_HELP_STRING([--enable-grub-mount], | |
1448 | [build and install the `grub-mount' utility (default=guessed)])]) | |
1449 | if test x"$enable_grub_mount" = xno ; then | |
1450 | grub_mount_excuse="explicitly disabled" | |
92bb0786 VS |
1451 | fi |
1452 | ||
897e6207 | 1453 | if test x"$grub_mount_excuse" = x ; then |
92bb0786 | 1454 | AC_CHECK_LIB([fuse], [fuse_main_real], [], |
897e6207 | 1455 | [grub_mount_excuse="need FUSE library"]) |
92bb0786 VS |
1456 | fi |
1457 | ||
897e6207 | 1458 | if test x"$grub_mount_excuse" = x ; then |
92bb0786 VS |
1459 | # Check for fuse headers. |
1460 | SAVED_CPPFLAGS="$CPPFLAGS" | |
338c7fab | 1461 | CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" |
92bb0786 | 1462 | AC_CHECK_HEADERS([fuse/fuse.h], [], |
897e6207 | 1463 | [grub_mount_excuse=["need FUSE headers"]]) |
92bb0786 VS |
1464 | CPPFLAGS="$SAVED_CPPFLAGS" |
1465 | fi | |
1466 | ||
897e6207 | 1467 | if test x"$enable_grub_mount" = xyes && test x"$grub_mount_excuse" != x ; then |
d642d761 | 1468 | AC_MSG_ERROR([grub-mount was explicitly requested but can't be compiled ($grub_mount_excuse)]) |
92bb0786 | 1469 | fi |
897e6207 CW |
1470 | if test x"$grub_mount_excuse" = x ; then |
1471 | enable_grub_mount=yes | |
92bb0786 | 1472 | else |
897e6207 | 1473 | enable_grub_mount=no |
92bb0786 | 1474 | fi |
897e6207 | 1475 | AC_SUBST([enable_grub_mount]) |
92bb0786 | 1476 | |
7181e228 CW |
1477 | AC_ARG_ENABLE([device-mapper], |
1478 | [AS_HELP_STRING([--enable-device-mapper], | |
1479 | [enable Linux device-mapper support (default=guessed)])]) | |
1480 | if test x"$enable_device_mapper" = xno ; then | |
1481 | device_mapper_excuse="explicitly disabled" | |
1482 | fi | |
1483 | ||
53798c4b GS |
1484 | if test x"$device_mapper_excuse" = x ; then |
1485 | # Check for device-mapper header. | |
1486 | AC_CHECK_HEADER([libdevmapper.h], [], | |
1487 | [device_mapper_excuse="need libdevmapper header"]) | |
1488 | fi | |
1489 | ||
7181e228 CW |
1490 | if test x"$device_mapper_excuse" = x ; then |
1491 | # Check for device-mapper library. | |
61d720e5 | 1492 | AC_CHECK_LIB([devmapper], [dm_task_create], [], |
7181e228 | 1493 | [device_mapper_excuse="need devmapper library"]) |
7181e228 | 1494 | fi |
61d720e5 VS |
1495 | |
1496 | if test x"$device_mapper_excuse" = x ; then | |
1497 | # Check for device-mapper library. | |
1498 | AC_CHECK_LIB([devmapper], [dm_log_with_errno_init], | |
1499 | [], | |
1500 | [device_mapper_excuse="need devmapper library"]) | |
1501 | fi | |
1502 | ||
1503 | if test x"$device_mapper_excuse" = x ; then | |
4d94b2db | 1504 | LIBDEVMAPPER="-ldevmapper" |
61d720e5 VS |
1505 | AC_DEFINE([HAVE_DEVICE_MAPPER], [1], |
1506 | [Define to 1 if you have the devmapper library.]) | |
1507 | fi | |
1508 | ||
62f7d208 | 1509 | AC_SUBST([LIBDEVMAPPER]) |
76ed06b9 | 1510 | |
f4727da9 VS |
1511 | LIBGEOM= |
1512 | if test x$host_kernel = xkfreebsd; then | |
1513 | AC_CHECK_LIB([geom], [geom_gettree], [], | |
1514 | [AC_MSG_ERROR([Your platform requires libgeom])]) | |
1515 | LIBGEOM="-lgeom" | |
1516 | fi | |
1517 | ||
1518 | AC_SUBST([LIBGEOM]) | |
1519 | ||
0d2d30bb VS |
1520 | AC_ARG_ENABLE([liblzma], |
1521 | [AS_HELP_STRING([--enable-liblzma], | |
1522 | [enable liblzma integration (default=guessed)])]) | |
1523 | if test x"$enable_liblzma" = xno ; then | |
1524 | liblzma_excuse="explicitly disabled" | |
1525 | fi | |
1526 | ||
1527 | if test x"$liblzma_excuse" = x ; then | |
2c44e493 | 1528 | AC_CHECK_LIB([lzma], [lzma_code], |
0d2d30bb VS |
1529 | [],[liblzma_excuse="need lzma library"]) |
1530 | fi | |
1531 | if test x"$liblzma_excuse" = x ; then | |
1532 | AC_CHECK_HEADER([lzma.h], [], [liblzma_excuse="need lzma header"]) | |
1533 | fi | |
1534 | ||
1535 | if test x"$enable_liblzma" = xyes && test x"$liblzma_excuse" != x ; then | |
d642d761 | 1536 | AC_MSG_ERROR([liblzma support was explicitly requested but requirements are not satisfied ($liblzma_excuse)]) |
0d2d30bb VS |
1537 | fi |
1538 | ||
1539 | ||
1540 | if test x"$liblzma_excuse" = x ; then | |
1541 | LIBLZMA="-llzma" | |
1542 | AC_DEFINE([USE_LIBLZMA], [1], | |
1543 | [Define to 1 if you have the LZMA library.]) | |
1544 | fi | |
1545 | ||
2c44e493 VS |
1546 | AC_SUBST([LIBLZMA]) |
1547 | ||
e4c498a1 MG |
1548 | AC_ARG_ENABLE([libzfs], |
1549 | [AS_HELP_STRING([--enable-libzfs], | |
1550 | [enable libzfs integration (default=guessed)])]) | |
1551 | if test x"$enable_libzfs" = xno ; then | |
1552 | libzfs_excuse="explicitly disabled" | |
1553 | fi | |
16c7cb32 | 1554 | |
e4c498a1 MG |
1555 | if test x"$libzfs_excuse" = x ; then |
1556 | # Only check for system headers if libzfs support has not been disabled. | |
1557 | AC_CHECK_HEADERS(libzfs.h libnvpair.h) | |
1558 | fi | |
1559 | ||
1560 | if test x"$libzfs_excuse" = x ; then | |
1561 | AC_CHECK_LIB([zfs], [libzfs_init], | |
1562 | [], | |
1563 | [libzfs_excuse="need zfs library"]) | |
1564 | fi | |
1565 | ||
1566 | if test x"$libzfs_excuse" = x ; then | |
27f9d02e | 1567 | AC_CHECK_LIB([nvpair], [nvlist_lookup_string], |
e4c498a1 MG |
1568 | [], |
1569 | [libzfs_excuse="need nvpair library"]) | |
1570 | fi | |
1571 | ||
1572 | if test x"$enable_libzfs" = xyes && test x"$libzfs_excuse" != x ; then | |
d642d761 | 1573 | AC_MSG_ERROR([libzfs support was explicitly requested but requirements are not satisfied ($libzfs_excuse)]) |
e4c498a1 MG |
1574 | fi |
1575 | ||
1576 | if test x"$libzfs_excuse" = x ; then | |
1577 | # We need both libzfs and libnvpair for a successful build. | |
1578 | LIBZFS="-lzfs" | |
1579 | AC_DEFINE([HAVE_LIBZFS], [1], | |
1580 | [Define to 1 if you have the ZFS library.]) | |
1581 | LIBNVPAIR="-lnvpair" | |
1582 | AC_DEFINE([HAVE_LIBNVPAIR], [1], | |
1583 | [Define to 1 if you have the NVPAIR library.]) | |
1584 | fi | |
1585 | ||
1586 | AC_SUBST([LIBZFS]) | |
16c7cb32 BC |
1587 | AC_SUBST([LIBNVPAIR]) |
1588 | ||
9f915872 VS |
1589 | LIBS="" |
1590 | ||
76ed06b9 | 1591 | AC_SUBST([FONT_SOURCE]) |
76ed06b9 BC |
1592 | AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu], |
1593 | [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)]) | |
7181e228 | 1594 | |
742f9232 VS |
1595 | AC_SUBST(HAVE_ASM_USCORE) |
1596 | AC_SUBST(ADDR32) | |
1597 | AC_SUBST(DATA32) | |
1598 | AC_SUBST(BSS_START_SYMBOL) | |
1599 | AC_SUBST(END_SYMBOL) | |
1600 | AC_SUBST(PACKAGE) | |
1601 | AC_SUBST(VERSION) | |
742f9232 | 1602 | |
d5524ca8 VS |
1603 | AC_ARG_ENABLE([werror], |
1604 | [AS_HELP_STRING([--disable-werror], | |
1605 | [do not use -Werror when building GRUB])]) | |
1606 | if test x"$enable_werror" != xno ; then | |
1607 | TARGET_CFLAGS="$TARGET_CFLAGS -Werror" | |
1608 | HOST_CFLAGS="$HOST_CFLAGS -Werror" | |
1609 | fi | |
1610 | ||
1611 | if test "x$grub_cv_cc_target_clang" = xno; then | |
1612 | TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc" | |
1613 | else | |
1614 | TARGET_LDFLAGS_STATIC_LIBGCC= | |
1615 | fi | |
1616 | ||
1617 | TARGET_CPP="$TARGET_CC -E" | |
1618 | TARGET_CCAS=$TARGET_CC | |
1619 | ||
1620 | GRUB_TARGET_CPU="${target_cpu}" | |
1621 | GRUB_PLATFORM="${platform}" | |
1622 | ||
1623 | AC_SUBST(GRUB_TARGET_CPU) | |
1624 | AC_SUBST(GRUB_PLATFORM) | |
1625 | ||
1626 | AC_SUBST(TARGET_OBJCONV) | |
1627 | AC_SUBST(TARGET_LIBGCC) | |
1628 | AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC) | |
1629 | AC_SUBST(TARGET_CPP) | |
1630 | AC_SUBST(TARGET_CCAS) | |
1631 | AC_SUBST(TARGET_OBJ2ELF) | |
d5524ca8 | 1632 | AC_SUBST(TARGET_MODULE_FORMAT) |
6a7957f9 | 1633 | AC_SUBST(TARGET_CC_VERSION) |
d5524ca8 VS |
1634 | |
1635 | AC_SUBST(TARGET_CFLAGS) | |
1636 | AC_SUBST(TARGET_LDFLAGS) | |
1637 | AC_SUBST(TARGET_CPPFLAGS) | |
1638 | AC_SUBST(TARGET_CCASFLAGS) | |
1639 | ||
d5524ca8 VS |
1640 | AC_SUBST(TARGET_IMG_LDFLAGS) |
1641 | AC_SUBST(TARGET_IMG_CFLAGS) | |
1642 | AC_SUBST(TARGET_IMG_BASE_LDOPT) | |
a9f25a08 | 1643 | AC_SUBST(TARGET_APPLE_LINKER) |
d5524ca8 VS |
1644 | |
1645 | AC_SUBST(HOST_CFLAGS) | |
1646 | AC_SUBST(HOST_LDFLAGS) | |
1647 | AC_SUBST(HOST_CPPFLAGS) | |
1648 | AC_SUBST(HOST_CCASFLAGS) | |
1649 | ||
1650 | AC_SUBST(BUILD_LIBM) | |
1651 | ||
76ed06b9 BC |
1652 | # |
1653 | # Automake conditionals | |
1654 | # | |
8c411768 | 1655 | |
76ed06b9 | 1656 | AM_CONDITIONAL([COND_emu], [test x$platform = xemu]) |
d59849b2 | 1657 | AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes]) |
76ed06b9 BC |
1658 | AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc]) |
1659 | AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi]) | |
6585de4c | 1660 | AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi]) |
76ed06b9 BC |
1661 | AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu]) |
1662 | AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275]) | |
1663 | AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot]) | |
1664 | AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot]) | |
1665 | AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi]) | |
9612ebc0 VS |
1666 | AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen]) |
1667 | AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen]) | |
4959e111 VS |
1668 | AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson]) |
1669 | AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips]) | |
7f63a64f | 1670 | AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc]) |
76ed06b9 | 1671 | AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) |
eaf01c25 | 1672 | AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu]) |
76ed06b9 | 1673 | AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) |
4959e111 | 1674 | AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel]) |
37ba07eb VS |
1675 | AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel]) |
1676 | AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips]) | |
389b31cd LL |
1677 | AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ]) |
1678 | AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot]) | |
1679 | AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi]) | |
15a463d7 LL |
1680 | AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) |
1681 | AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) | |
f7711f5e | 1682 | |
faf4a65e VS |
1683 | AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd]) |
1684 | AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux]) | |
1685 | AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd]) | |
f7711f5e | 1686 | AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows]) |
faf4a65e VS |
1687 | AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd]) |
1688 | AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu]) | |
1689 | AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos]) | |
2d465fb0 | 1690 | |
76ed06b9 BC |
1691 | AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x]) |
1692 | AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes]) | |
1693 | AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes]) | |
1694 | AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes]) | |
1695 | AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes]) | |
897e6207 | 1696 | AM_CONDITIONAL([COND_GRUB_MOUNT], [test x$enable_grub_mount = xyes]) |
76ed06b9 | 1697 | AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x]) |
6f07c4e4 VS |
1698 | if test x$FONT_SOURCE != x ; then |
1699 | HAVE_FONT_SOURCE=1 | |
1700 | else | |
1701 | HAVE_FONT_SOURCE=0 | |
1702 | fi | |
1703 | AC_SUBST(HAVE_FONT_SOURCE) | |
a9f25a08 | 1704 | AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1]) |
76ed06b9 | 1705 | AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes]) |
c5dc1690 | 1706 | AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1]) |
e744219b | 1707 | AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1]) |
fc45fb58 | 1708 | |
1eed0e6e VS |
1709 | AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes]) |
1710 | ||
742f9232 | 1711 | AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1]) |
c5884973 | 1712 | AM_CONDITIONAL([COND_STARFIELD], [test "x$starfield_excuse" = x]) |
cd46aa6c VS |
1713 | AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy]) |
1714 | ||
1715 | test "x$prefix" = xNONE && prefix="$ac_default_prefix" | |
1716 | test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" | |
1717 | datarootdir="$(eval echo "$datarootdir")" | |
1718 | grub_libdir="$(eval echo "$libdir")" | |
1719 | grub_localedir="$(eval echo "$localedir")" | |
1720 | grub_datadir="$(eval echo "$datadir")" | |
1721 | grub_sysconfdir="$(eval echo "$sysconfdir")" | |
1722 | AC_DEFINE_UNQUOTED(LOCALEDIR, "$grub_localedir", [Locale dir]) | |
1723 | AC_DEFINE_UNQUOTED(GRUB_LIBDIR, "$grub_libdir", [Library dir]) | |
1724 | AC_DEFINE_UNQUOTED(GRUB_DATADIR, "$grub_datadir", [Data dir]) | |
1725 | AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir]) | |
1726 | ||
742f9232 | 1727 | |
6a161fa9 | 1728 | # Output files. |
4959e111 VS |
1729 | cpudir="${target_cpu}" |
1730 | if test x${cpudir} = xmipsel; then | |
1731 | cpudir=mips; | |
1732 | fi | |
1f4147aa | 1733 | grub_CHECK_LINK_DIR |
1734 | if test x"$link_dir" = xyes ; then | |
4959e111 | 1735 | AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir]) |
f84b481b | 1736 | if test "$platform" != emu ; then |
4959e111 | 1737 | AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform]) |
f84b481b | 1738 | fi |
1f4147aa | 1739 | else |
1740 | mkdir -p include/grub 2>/dev/null | |
1741 | rm -rf include/grub/cpu | |
4959e111 | 1742 | cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null |
f84b481b RM |
1743 | if test "$platform" != emu ; then |
1744 | rm -rf include/grub/machine | |
4959e111 | 1745 | cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null |
f84b481b | 1746 | fi |
1f4147aa | 1747 | fi |
6304d292 | 1748 | |
8c411768 | 1749 | AC_CONFIG_FILES([Makefile]) |
6304d292 | 1750 | AC_CONFIG_FILES([grub-core/Makefile]) |
15c69261 | 1751 | AC_CONFIG_FILES([grub-core/gnulib/Makefile]) |
269004c1 | 1752 | AC_CONFIG_FILES([po/Makefile.in]) |
8c411768 | 1753 | AC_CONFIG_FILES([docs/Makefile]) |
b23ffd70 | 1754 | AC_CONFIG_FILES([util/bash-completion.d/Makefile]) |
6a161fa9 | 1755 | AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) |
742f9232 | 1756 | AC_CONFIG_FILES([config.h]) |
8c411768 | 1757 | |
6a161fa9 | 1758 | AC_OUTPUT |
5ce5507f | 1759 | [ |
1760 | echo "*******************************************************" | |
1761 | echo GRUB2 will be compiled with following components: | |
1762 | echo Platform: "$target_cpu"-"$platform" | |
f84b481b | 1763 | if [ x"$platform" = xemu ]; then |
5ce5507f | 1764 | if [ x"$grub_emu_usb_excuse" = x ]; then |
1765 | echo USB support for grub-emu: Yes | |
1766 | else | |
1767 | echo USB support for grub-emu: No "($grub_emu_usb_excuse)" | |
1768 | fi | |
927d0134 VS |
1769 | if [ x"$grub_emu_sdl_excuse" = x ]; then |
1770 | echo SDL support for grub-emu: Yes | |
1771 | else | |
1772 | echo SDL support for grub-emu: No "($grub_emu_sdl_excuse)" | |
1773 | fi | |
325c8258 | 1774 | if [ x"$grub_emu_pci_excuse" = x ]; then |
1775 | echo PCI support for grub-emu: Yes | |
1776 | else | |
1777 | echo PCI support for grub-emu: No "($grub_emu_pci_excuse)" | |
1778 | fi | |
f84b481b | 1779 | fi |
61d720e5 VS |
1780 | if test x"$device_mapper_excuse" = x ; then |
1781 | echo With devmapper support: Yes | |
1782 | else | |
1783 | echo With devmapper support: No "($device_mapper_excuse)" | |
1784 | fi | |
5ce5507f | 1785 | if [ x"$enable_mm_debug" = xyes ]; then |
1786 | echo With memory debugging: Yes | |
1787 | else | |
1788 | echo With memory debugging: No | |
1789 | fi | |
c5dc1690 SJ |
1790 | if [ x"$enable_cache_stats" = xyes ]; then |
1791 | echo With disk cache statistics: Yes | |
1792 | else | |
1793 | echo With disk cache statistics: No | |
1794 | fi | |
e744219b VS |
1795 | |
1796 | if [ x"$enable_boot_time" = xyes ]; then | |
1797 | echo With boot time statistics: Yes | |
1798 | else | |
1799 | echo With boot time statistics: No | |
1800 | fi | |
1801 | ||
5ce5507f | 1802 | if [ x"$efiemu_excuse" = x ]; then |
1803 | echo efiemu runtime: Yes | |
1804 | else | |
1805 | echo efiemu runtime: No "($efiemu_excuse)" | |
1806 | fi | |
5ce5507f | 1807 | if [ x"$grub_mkfont_excuse" = x ]; then |
1808 | echo grub-mkfont: Yes | |
1809 | else | |
1810 | echo grub-mkfont: No "($grub_mkfont_excuse)" | |
1811 | fi | |
897e6207 | 1812 | if [ x"$grub_mount_excuse" = x ]; then |
89644ef1 | 1813 | echo grub-mount: Yes |
92bb0786 | 1814 | else |
897e6207 | 1815 | echo grub-mount: No "($grub_mount_excuse)" |
92bb0786 | 1816 | fi |
c5884973 DO |
1817 | if [ x"$starfield_excuse" = x ]; then |
1818 | echo starfield theme: Yes | |
443b3222 | 1819 | echo With DejaVuSans font from $DJVU_FONT_SOURCE |
c5884973 DO |
1820 | else |
1821 | echo starfield theme: No "($starfield_excuse)" | |
1822 | fi | |
e4c498a1 MG |
1823 | if [ x"$libzfs_excuse" = x ]; then |
1824 | echo With libzfs support: Yes | |
1825 | else | |
1826 | echo With libzfs support: No "($libzfs_excuse)" | |
1827 | fi | |
7b780018 | 1828 | if [ x"$grub_build_mkfont_excuse" = x ]; then |
7c9d0c39 VS |
1829 | echo Build-time grub-mkfont: Yes |
1830 | if test "x$FONT_SOURCE" = x ; then | |
1831 | echo "Without unifont" | |
1832 | else | |
1833 | echo "With unifont from $FONT_SOURCE" | |
1834 | fi | |
4b80e43c | 1835 | else |
7b780018 | 1836 | echo Build-time grub-mkfont: No "($grub_build_mkfont_excuse)" |
7c9d0c39 | 1837 | echo "Without unifont (no build-time grub-mkfont)" |
4b80e43c | 1838 | fi |
0d2d30bb VS |
1839 | if test x"$liblzma_excuse" != x ; then |
1840 | echo "Without liblzma (no support for XZ-compressed mips images) ($liblzma_excuse)" | |
64fce2d8 VS |
1841 | else |
1842 | echo "With liblzma from $LIBLZMA (support for XZ-compressed mips images)" | |
1843 | fi | |
5ce5507f | 1844 | echo "*******************************************************" |
1845 | ] |