]>
Commit | Line | Data |
---|---|---|
6a161fa9 | 1 | # Process this file with autoconf to produce a configure script. |
2 | ||
1e901a75 | 3 | # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. |
6a161fa9 | 4 | # |
5 | # This configure.ac is free software; the author | |
6 | # gives unlimited permission to copy and/or distribute it, | |
7 | # with or without modifications, as long as this notice is preserved. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without | |
11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
12 | # PARTICULAR PURPOSE. | |
13 | ||
b977bf01 | 14 | dnl This configure script is complicated, because GRUB needs to deal |
15 | dnl with three potentially different types: | |
16 | dnl | |
17 | dnl build -- the environment for building GRUB | |
18 | dnl host -- the environment for running utilities | |
19 | dnl target -- the environment for running GRUB | |
20 | dnl | |
21 | dnl In addition, GRUB needs to deal with a platform specification | |
22 | dnl which specifies the system running GRUB, such as firmware. | |
23 | dnl This is necessary because the target type in autoconf does not | |
24 | dnl describe such a system very well. | |
25 | dnl | |
26 | dnl The current strategy is to use variables with no prefix (such as | |
27 | dnl CC, CFLAGS, etc.) for the host type as well as the build type, | |
28 | dnl because GRUB does not need to use those variables for the build | |
29 | dnl type, so there is no conflict. Variables with the prefix "TARGET_" | |
30 | dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target | |
31 | dnl type. | |
32 | ||
33 | ||
f1d29d87 | 34 | AC_INIT([GRUB],[1.97],[bug-grub@gnu.org]) |
fc22844e | 35 | AM_INIT_AUTOMAKE() |
f022876b | 36 | AC_PREREQ(2.60) |
4b13b216 | 37 | AC_CONFIG_SRCDIR([include/grub/dl.h]) |
6a161fa9 | 38 | AC_CONFIG_HEADER([config.h]) |
39 | ||
b977bf01 | 40 | # Checks for host and target systems. |
6a161fa9 | 41 | AC_CANONICAL_HOST |
b977bf01 | 42 | AC_CANONICAL_TARGET |
6a161fa9 | 43 | |
1d543c3e | 44 | # Program name transformations |
45 | AC_ARG_PROGRAM | |
46 | ||
b977bf01 | 47 | case "$target_cpu" in |
02164e1b | 48 | i[[3456]]86) target_cpu=i386 ;; |
49 | sparc) target_cpu=sparc64 ;; | |
6a161fa9 | 50 | esac |
51 | ||
05568c2e | 52 | # Specify the platform (such as firmware). |
53 | AC_ARG_WITH([platform], | |
54 | AS_HELP_STRING([--with-platform=PLATFORM], | |
83b984de | 55 | [select the host platform [[guessed]]])) |
05568c2e | 56 | |
57 | # Guess the platform if not specified. | |
58 | if test "x$with_platform" = x; then | |
b977bf01 | 59 | case "$target_cpu"-"$target_vendor" in |
05568c2e | 60 | i386-apple) platform=efi ;; |
61 | i386-*) platform=pc ;; | |
58393a2d | 62 | x86_64-apple) platform=efi ;; |
737feb35 | 63 | x86_64-*) platform=pc ;; |
05568c2e | 64 | powerpc-*) platform=ieee1275 ;; |
58393a2d | 65 | powerpc64-*) platform=ieee1275 ;; |
05568c2e | 66 | sparc64-*) platform=ieee1275 ;; |
58393a2d | 67 | *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;; |
05568c2e | 68 | esac |
69 | else | |
70 | platform="$with_platform" | |
71 | fi | |
72 | ||
58393a2d | 73 | # Adjust CPU unless target was explicitly specified. |
74 | if test -z "$target_alias"; then | |
75 | case "$target_cpu"-"$platform" in | |
76 | x86_64-efi) ;; | |
3f4ce737 | 77 | x86_64-*) target_cpu=i386 ;; |
78 | powerpc64-ieee1275) target_cpu=powerpc ;; | |
20011694 | 79 | esac |
80 | fi | |
81 | ||
58393a2d | 82 | # Check if the platform is supported, make final adjustments. |
b977bf01 | 83 | case "$target_cpu"-"$platform" in |
05568c2e | 84 | i386-efi) ;; |
3f4ce737 | 85 | x86_64-efi) ;; |
05568c2e | 86 | i386-pc) ;; |
546f966a | 87 | i386-coreboot) ;; |
58393a2d | 88 | i386-linuxbios) platform=coreboot ;; |
3d04eab8 | 89 | i386-ieee1275) ;; |
8231fb77 | 90 | i386-qemu) ;; |
05568c2e | 91 | powerpc-ieee1275) ;; |
92 | sparc64-ieee1275) ;; | |
f84b481b | 93 | *-emu) ;; |
58393a2d | 94 | *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;; |
6a161fa9 | 95 | esac |
96 | ||
3f4ce737 | 97 | case "$target_cpu" in |
98 | i386 | powerpc) target_m32=1 ;; | |
99 | x86_64 | sparc64) target_m64=1 ;; | |
100 | esac | |
101 | ||
6e5a42fe | 102 | case "$host_os" in |
4825d790 | 103 | mingw32*) host_os=cygwin ;; |
6e5a42fe | 104 | esac |
105 | ||
9304eef1 | 106 | # This normalizes the names, and creates a new variable ("host_kernel") |
107 | # while at it, since the mapping is not always 1:1 (e.g. different OSes | |
108 | # using the same kernel type). | |
109 | case "$host_os" in | |
110 | gnu*) host_kernel=hurd ;; | |
111 | linux*) host_kernel=linux ;; | |
67937d4d | 112 | freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;; |
9304eef1 | 113 | cygwin) host_kernel=windows ;; |
114 | esac | |
115 | ||
f84b481b RM |
116 | case "$platform" in |
117 | coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;; | |
118 | efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;; | |
119 | ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;; | |
120 | qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;; | |
121 | pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;; | |
122 | emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;; | |
123 | esac | |
124 | CFLAGS="$CFLAGS $machine_CFLAGS" | |
f616f51c | 125 | TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS" |
f84b481b RM |
126 | TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS" |
127 | ||
56978920 | 128 | AC_SUBST(host_cpu) |
129 | AC_SUBST(host_os) | |
9304eef1 | 130 | AC_SUBST(host_kernel) |
6e5a42fe | 131 | |
b977bf01 | 132 | AC_SUBST(target_cpu) |
05568c2e | 133 | AC_SUBST(platform) |
6a161fa9 | 134 | |
b977bf01 | 135 | # |
136 | # Checks for build programs. | |
137 | # | |
144f1f98 | 138 | |
6c826348 | 139 | # Although cmp is listed in the GNU Coding Standards as a command which |
140 | # can used directly, OpenBSD lacks cmp in the default installation. | |
141 | AC_CHECK_PROGS([CMP], [cmp]) | |
142 | if test "x$CMP" = x; then | |
143 | AC_MSG_ERROR([cmp is not found]) | |
144 | fi | |
145 | ||
144f1f98 | 146 | AC_CHECK_PROGS([YACC], [bison]) |
1569ec51 | 147 | if test "x$YACC" = x; then |
6c826348 | 148 | AC_MSG_ERROR([bison is not found]) |
1569ec51 | 149 | fi |
150 | ||
a797824f | 151 | for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz ; do |
4931827f | 152 | if test -e $file ; then |
6c09890c | 153 | AC_SUBST([FONT_SOURCE], [$file]) |
4931827f | 154 | break |
155 | fi | |
156 | done | |
157 | ||
b977bf01 | 158 | AC_PROG_INSTALL |
159 | AC_PROG_AWK | |
160 | AC_PROG_MAKE_SET | |
ff420223 | 161 | AC_PROG_MKDIR_P |
b977bf01 | 162 | |
68807e5f | 163 | # These are not a "must". |
b977bf01 | 164 | AC_PATH_PROG(RUBY, ruby) |
c44c90db | 165 | AC_PATH_PROG(MAKEINFO, makeinfo) |
6a161fa9 | 166 | |
b977bf01 | 167 | # |
168 | # Checks for host programs. | |
169 | # | |
170 | ||
171 | AC_PROG_CC | |
6a161fa9 | 172 | # Must be GCC. |
173 | test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) | |
174 | ||
4889bdec | 175 | AC_GNU_SOURCE |
6717926e | 176 | AM_GNU_GETTEXT |
b977bf01 | 177 | AC_SYS_LARGEFILE |
178 | ||
179 | # Identify characteristics of the host architecture. | |
180 | AC_C_BIGENDIAN | |
181 | AC_CHECK_SIZEOF(void *) | |
182 | AC_CHECK_SIZEOF(long) | |
183 | ||
2b167a72 | 184 | grub_apple_cc |
c9da87d0 | 185 | if test x$grub_cv_apple_cc = xyes ; then |
2b167a72 | 186 | CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions" |
187 | ASFLAGS="$ASFLAGS -DAPPLE_CC=1" | |
188 | fi | |
b977bf01 | 189 | |
86695375 | 190 | if test "x$cross_compiling" = xyes; then |
191 | AC_MSG_WARN([cannot generate manual pages while cross compiling]) | |
192 | else | |
193 | AC_PATH_PROG(HELP2MAN, help2man) | |
194 | fi | |
195 | ||
4889bdec | 196 | # Check for functions. |
df38d0bb | 197 | AC_CHECK_FUNCS(posix_memalign memalign asprintf) |
4889bdec | 198 | |
7c4e16ff RM |
199 | # For grub-mkisofs |
200 | AC_HEADER_MAJOR | |
201 | AC_HEADER_DIRENT | |
4825d790 | 202 | AC_CHECK_FUNCS(memmove sbrk strdup lstat getuid getgid) |
7c4e16ff RM |
203 | AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h) |
204 | AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h) | |
205 | ||
b977bf01 | 206 | # |
207 | # Check for target programs. | |
208 | # | |
209 | ||
5b5d4aa5 | 210 | # Find tools for the target. |
211 | if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then | |
b977bf01 | 212 | tmp_ac_tool_prefix="$ac_tool_prefix" |
213 | ac_tool_prefix=$target_alias- | |
214 | ||
215 | AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc], | |
216 | [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])]) | |
217 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
218 | AC_CHECK_TOOL(STRIP, strip) | |
219 | AC_CHECK_TOOL(NM, nm) | |
220 | ||
221 | ac_tool_prefix="$tmp_ac_tool_prefix" | |
222 | else | |
223 | if test "x$TARGET_CC" = x; then | |
224 | TARGET_CC=$CC | |
225 | fi | |
226 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
227 | AC_CHECK_TOOL(STRIP, strip) | |
228 | AC_CHECK_TOOL(NM, nm) | |
229 | fi | |
230 | AC_SUBST(TARGET_CC) | |
231 | ||
232 | ||
233 | # Test the C compiler for the target environment. | |
234 | tmp_CC="$CC" | |
235 | tmp_CFLAGS="$CFLAGS" | |
236 | tmp_LDFLAGS="$LDFLAGS" | |
237 | tmp_CPPFLAGS="$CPPFLAGS" | |
aa6d7826 | 238 | tmp_LIBS="$LIBS" |
b977bf01 | 239 | CC="$TARGET_CC" |
240 | CFLAGS="$TARGET_CFLAGS" | |
241 | CPPFLAGS="$TARGET_CPPFLAGS" | |
242 | LDFLAGS="$TARGET_LDFLAGS" | |
aa6d7826 | 243 | LIBS="" |
b977bf01 | 244 | |
245 | if test "x$TARGET_CFLAGS" = x; then | |
6a161fa9 | 246 | # debug flags. |
b977bf01 | 247 | TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \ |
248 | -Wundef -Wstrict-prototypes -g" | |
6a161fa9 | 249 | |
250 | # optimization flags. | |
322562ea | 251 | AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [ |
6a161fa9 | 252 | CFLAGS=-Os |
eb73121d | 253 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
254 | [grub_cv_cc_Os=yes], | |
255 | [grub_cv_cc_Os=no]) | |
6a161fa9 | 256 | ]) |
322562ea | 257 | if test "x$grub_cv_cc_Os" = xyes; then |
b977bf01 | 258 | TARGET_CFLAGS="$TARGET_CFLAGS -Os" |
6a161fa9 | 259 | else |
b977bf01 | 260 | TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops" |
6a161fa9 | 261 | fi |
262 | ||
263 | # Force no alignment to save space on i386. | |
b977bf01 | 264 | if test "x$target_cpu" = xi386; then |
322562ea | 265 | AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ |
2b167a72 | 266 | CFLAGS="$CFLAGS -falign-loops=1" |
eb73121d | 267 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
268 | [grub_cv_cc_falign_loop=yes], | |
269 | [grub_cv_cc_falign_loop=no]) | |
6a161fa9 | 270 | ]) |
271 | ||
322562ea | 272 | if test "x$grub_cv_cc_falign_loop" = xyes; then |
b977bf01 | 273 | TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" |
6a161fa9 | 274 | else |
b977bf01 | 275 | TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" |
6a161fa9 | 276 | fi |
6f3cd880 | 277 | |
278 | # Some toolchains enable these features by default, but they need | |
279 | # registers that aren't set up properly in GRUB. | |
280 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" | |
6a161fa9 | 281 | fi |
77c55a87 | 282 | |
283 | # By default, GCC 4.4 generates .eh_frame sections containing unwind | |
284 | # information in some cases where it previously did not. GRUB doesn't need | |
285 | # these and they just use up vital space. Restore the old compiler | |
286 | # behaviour. | |
287 | AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [ | |
288 | SAVE_CFLAGS="$CFLAGS" | |
289 | CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm" | |
290 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], | |
291 | [grub_cv_cc_fno_dwarf2_cfi_asm=yes], | |
292 | [grub_cv_cc_fno_dwarf2_cfi_asm=no]) | |
293 | CFLAGS="$SAVE_CFLAGS" | |
294 | ]) | |
295 | ||
296 | if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then | |
297 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" | |
298 | fi | |
b977bf01 | 299 | fi |
6a161fa9 | 300 | |
2b167a72 | 301 | grub_apple_target_cc |
c9da87d0 | 302 | if test x$grub_cv_apple_target_cc = xyes ; then |
2b167a72 | 303 | TARGET_CFLAGS="$TARGET_CFLAGS -DAPPLE_CC=1 -fnested-functions" |
304 | CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions" | |
305 | TARGET_ASFLAGS="$TARGET_ASFLAGS -DAPPLE_CC=1" | |
306 | TARGET_APPLE_CC=1 | |
cf00df31 | 307 | AC_CHECK_PROG([OBJCONV], [objconv], [objconv], []) |
308 | if test "x$OBJCONV" = x ; then | |
309 | AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.]) | |
310 | fi | |
311 | if test "x$OBJCONV" = x ; then | |
312 | AC_MSG_ERROR([objconv not found which is required when building with apple compiler]) | |
313 | fi | |
2b167a72 | 314 | TARGET_IMG_LDSCRIPT= |
315 | TARGET_IMG_CFLAGS="-static" | |
316 | TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,' | |
317 | TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,' | |
318 | else | |
319 | TARGET_APPLE_CC=0 | |
320 | # Use linker script if present, otherwise use builtin -N script. | |
2b167a72 | 321 | if test -f "${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then |
322 | TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc" | |
323 | TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT} -Wl,-Ttext," | |
324 | TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc" | |
325 | else | |
326 | TARGET_IMG_LDSCRIPT= | |
327 | TARGET_IMG_LDFLAGS='-Wl,-N -Wl,-Ttext,' | |
328 | TARGET_IMG_LDFLAGS_AC='-Wl,-N -Wl,-Ttext,' | |
329 | fi | |
330 | TARGET_IMG_CFLAGS= | |
331 | fi | |
332 | ||
333 | AC_SUBST(TARGET_IMG_LDSCRIPT) | |
334 | AC_SUBST(TARGET_IMG_LDFLAGS) | |
335 | AC_SUBST(TARGET_IMG_CFLAGS) | |
2b167a72 | 336 | |
337 | # For platforms where ELF is not the default link format. | |
338 | AC_MSG_CHECKING([for command to convert module to ELF format]) | |
339 | case "${host_os}" in | |
340 | cygwin) TARGET_OBJ2ELF='grub-pe2elf' ;; | |
341 | *) ;; | |
342 | esac | |
343 | AC_SUBST(TARGET_OBJ2ELF) | |
344 | AC_MSG_RESULT([$TARGET_OBJ2ELF]) | |
345 | ||
346 | ||
b977bf01 | 347 | if test "x$target_m32" = x1; then |
348 | # Force 32-bit mode. | |
349 | TARGET_CFLAGS="$TARGET_CFLAGS -m32" | |
350 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" | |
2b167a72 | 351 | TARGET_MODULE_FORMAT="elf32" |
6a161fa9 | 352 | fi |
b977bf01 | 353 | |
20011694 | 354 | if test "x$target_m64" = x1; then |
355 | # Force 64-bit mode. | |
7e9ca17a | 356 | TARGET_CFLAGS="$TARGET_CFLAGS -m64" |
357 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" | |
2b167a72 | 358 | TARGET_MODULE_FORMAT="elf64" |
7e9ca17a | 359 | fi |
360 | ||
361 | if test "$target_cpu"-"$platform" = x86_64-efi; then | |
362 | # Use large model to support 4G memory | |
6e09b8b7 | 363 | AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ |
c8600122 | 364 | SAVED_CFLAGS=$CFLAGS |
365 | CFLAGS="$CFLAGS -m64 -mcmodel=large" | |
6e09b8b7 | 366 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
367 | [grub_cv_cc_mcmodel=yes], | |
368 | [grub_cv_cc_mcmodel=no]) | |
369 | ]) | |
c8600122 | 370 | if test "x$grub_cv_cc_mcmodel" = xno; then |
371 | CFLAGS="$SAVED_CFLAGS -m64 -DMCMODEL_SMALL=1" | |
b39f9d20 | 372 | TARGET_CFLAGS="$TARGET_CFLAGS -DMCMODEL_SMALL=1" |
ce7a733d | 373 | AC_MSG_WARN([-mcmodel=large not supported. You won't be able to use the memory over 4GiB. Upgrade your gcc]) |
c8600122 | 374 | else |
375 | TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large" | |
6e09b8b7 | 376 | fi |
7e9ca17a | 377 | |
378 | # EFI writes to stack below %rsp, we must not use the red zone | |
379 | AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [ | |
c8600122 | 380 | CFLAGS="$CFLAGS -m64 -mno-red-zone" |
7e9ca17a | 381 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
382 | [grub_cv_cc_no_red_zone=yes], | |
383 | [grub_cv_cc_no_red_zone=no]) | |
384 | ]) | |
385 | if test "x$grub_cv_cc_no_red_zone" = xno; then | |
386 | AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc]) | |
387 | fi | |
388 | ||
c8600122 | 389 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone" |
20011694 | 390 | fi |
391 | ||
baa2a121 | 392 | # |
393 | # Compiler features. | |
394 | # | |
395 | ||
9035dce4 | 396 | # Need __enable_execute_stack() for nested function trampolines? |
397 | grub_CHECK_ENABLE_EXECUTE_STACK | |
398 | ||
93a81088 | 399 | # Position independent executable. |
400 | grub_CHECK_PIE | |
401 | [# Need that, because some distributions ship compilers that include | |
402 | # `-fPIE' in the default specs. | |
403 | if [ x"$pie_possible" = xyes ]; then | |
404 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" | |
405 | fi] | |
406 | ||
baa2a121 | 407 | # Smashing stack protector. |
408 | grub_CHECK_STACK_PROTECTOR | |
c3db8364 | 409 | # Need that, because some distributions ship compilers that include |
baa2a121 | 410 | # `-fstack-protector' in the default specs. |
c3db8364 | 411 | if test "x$ssp_possible" = xyes; then |
412 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector" | |
413 | fi | |
2a8a80e4 | 414 | grub_CHECK_STACK_ARG_PROBE |
415 | # Cygwin's GCC uses alloca() to probe the stackframe on static | |
416 | # stack allocations above some threshold. | |
417 | if test x"$sap_possible" = xyes; then | |
418 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" | |
419 | fi | |
baa2a121 | 420 | |
63f745e8 | 421 | AC_ARG_ENABLE([werror], |
422 | [AS_HELP_STRING([--disable-werror], | |
423 | [do not use -Werror when building GRUB])]) | |
424 | if test x"$enable_werror" != xno ; then | |
425 | TARGET_CFLAGS="$TARGET_CFLAGS -Werror" | |
426 | fi | |
427 | ||
b977bf01 | 428 | AC_SUBST(TARGET_CFLAGS) |
2b167a72 | 429 | AC_SUBST(TARGET_MODULE_FORMAT) |
cf00df31 | 430 | AC_SUBST(OBJCONV) |
2b167a72 | 431 | AC_SUBST(TARGET_APPLE_CC) |
432 | AC_SUBST(TARGET_ASFLAGS) | |
b977bf01 | 433 | AC_SUBST(TARGET_CPPFLAGS) |
434 | AC_SUBST(TARGET_LDFLAGS) | |
6a161fa9 | 435 | |
3b2fe8c2 | 436 | # Check for libgcc symbols (must be performed before we add -nostdlib to LDFLAGS) |
346e7fbe | 437 | AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2) |
3b2fe8c2 | 438 | |
aa6d7826 | 439 | # Set them to their new values for the tests below. |
440 | CC="$TARGET_CC" | |
26de2bcd | 441 | if test "x$TARGET_APPLE_CC" = x1 ; then |
442 | CFLAGS="$TARGET_CFLAGS -nostdlib" | |
443 | else | |
7d83bd47 | 444 | CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100" |
26de2bcd | 445 | fi |
aa6d7826 | 446 | CPPFLAGS="$TARGET_CPPFLAGS" |
447 | LDFLAGS="$TARGET_LDFLAGS" | |
448 | ||
6a161fa9 | 449 | # Defined in aclocal.m4. |
f6130a12 | 450 | grub_PROG_TARGET_CC |
2b167a72 | 451 | if test "x$TARGET_APPLE_CC" != x1 ; then |
b977bf01 | 452 | grub_PROG_OBJCOPY_ABSOLUTE |
2b167a72 | 453 | fi |
cb71ba20 | 454 | grub_PROG_LD_BUILD_ID_NONE |
4b13b216 | 455 | grub_ASM_USCORE |
b977bf01 | 456 | if test "x$target_cpu" = xi386; then |
2a8a80e4 | 457 | if test ! -z "$TARGET_IMG_LDSCRIPT"; then |
458 | # Check symbols provided by linker script. | |
459 | CFLAGS="$TARGET_CFLAGS -nostdlib $TARGET_IMG_LDFLAGS_AC -Wl,-Ttext,8000,--defsym,___main=0x8100" | |
460 | fi | |
58750afc | 461 | if test "x$TARGET_APPLE_CC" != x1 ; then |
2a8a80e4 | 462 | grub_CHECK_BSS_START_SYMBOL |
463 | grub_CHECK_END_SYMBOL | |
464 | fi | |
465 | CFLAGS="$TARGET_CFLAGS" | |
4b13b216 | 466 | grub_I386_ASM_PREFIX_REQUIREMENT |
467 | grub_I386_ASM_ADDR32 | |
468 | grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK | |
5aded270 | 469 | else |
f4917dfd | 470 | AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug]) |
6a161fa9 | 471 | fi |
472 | ||
bf6a5fb2 | 473 | AH_BOTTOM([#if defined(__i386__) && !defined(GRUB_UTIL) |
474 | #define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1))) | |
475 | #else | |
476 | #define NESTED_FUNC_ATTR | |
477 | #endif]) | |
478 | ||
5ce5507f | 479 | AC_ARG_ENABLE([efiemu], |
480 | [AS_HELP_STRING([--enable-efiemu], | |
481 | [build and install the efiemu runtimes (default=guessed)])]) | |
482 | if test x"$enable_efiemu" = xno ; then | |
ce7a733d | 483 | efiemu_excuse="explicitly disabled" |
5ce5507f | 484 | fi |
485 | if test x"$efiemu_excuse" = x ; then | |
43e6200c | 486 | AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [ |
d2838156 | 487 | CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib" |
5ce5507f | 488 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], |
489 | [grub_cv_cc_efiemu=yes], | |
490 | [grub_cv_cc_efiemu=no]) | |
491 | ]) | |
55c70904 | 492 | if test x$grub_cv_cc_efiemu = xno; then |
e98cd0c2 | 493 | efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" |
5ce5507f | 494 | fi |
495 | fi | |
496 | if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then | |
ce7a733d | 497 | AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled]) |
5ce5507f | 498 | fi |
499 | if test x"$efiemu_excuse" = x ; then | |
500 | enable_efiemu=yes | |
501 | else | |
502 | enable_efiemu=no | |
503 | fi | |
504 | AC_SUBST([enable_efiemu]) | |
505 | ||
506 | ||
c9a86192 | 507 | # Restore the flags. |
9962ed99 | 508 | CC="$tmp_CC" |
509 | CFLAGS="$tmp_CFLAGS" | |
510 | CPPFLAGS="$tmp_CPPFLAGS" | |
c9a86192 | 511 | LDFLAGS="$tmp_LDFLAGS" |
aa6d7826 | 512 | LIBS="$tmp_LIBS" |
6a161fa9 | 513 | |
4fe9862e | 514 | # |
2965c7cc | 515 | # Check for options. |
4fe9862e | 516 | # |
517 | ||
518 | # Memory manager debugging. | |
b39f9d20 | 519 | AC_ARG_ENABLE([mm-debug], |
2965c7cc | 520 | AS_HELP_STRING([--enable-mm-debug], |
90ce5d56 | 521 | [include memory manager debugging]), |
2965c7cc | 522 | [AC_DEFINE([MM_DEBUG], [1], |
523 | [Define to 1 if you enable memory manager debugging.])]) | |
524 | ||
d64399b5 | 525 | AC_ARG_ENABLE([grub-emu-usb], |
526 | [AS_HELP_STRING([--enable-grub-emu-usb], | |
5ce5507f | 527 | [build and install the `grub-emu' debugging utility with USB support (default=guessed)])]) |
5ce5507f | 528 | |
f84b481b RM |
529 | if test "$platform" = emu; then |
530 | missing_ncurses= | |
531 | [# Check for curses libraries.] | |
4fe9862e | 532 | AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"], |
533 | [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"], | |
f84b481b | 534 | [missing_ncurses=[true]])]) |
4fe9862e | 535 | AC_SUBST([LIBCURSES]) |
f84b481b | 536 | [if [ x"$missing_ncurses" = x ]; then ] |
4fe9862e | 537 | [# Check for headers.] |
538 | AC_CHECK_HEADERS([ncurses/curses.h], [], | |
539 | [AC_CHECK_HEADERS([ncurses.h], [], | |
540 | [AC_CHECK_HEADERS([curses.h], [], | |
f84b481b | 541 | [missing_ncurses=[true]])])]) |
5ce5507f | 542 | [fi] |
f84b481b RM |
543 | if test x"$missing_ncurses" = xtrue ; then |
544 | AC_MSG_ERROR([grub-emu can't be compiled without ncurses]) | |
5ce5507f | 545 | fi |
f84b481b | 546 | |
5ce5507f | 547 | if test x"$enable_grub_emu_usb" = xno ; then |
ce7a733d | 548 | grub_emu_usb_excuse="explicitly disabled" |
5ce5507f | 549 | fi |
550 | [if [ x"$grub_emu_usb_excuse" = x ]; then | |
d64399b5 | 551 | # Check for libusb libraries.] |
5ce5507f | 552 | AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"], |
e98cd0c2 | 553 | [grub_emu_usb_excuse=["need libusb library"]]) |
d64399b5 | 554 | AC_SUBST([LIBUSB]) |
5ce5507f | 555 | [fi] |
556 | [if [ x"$grub_emu_usb_excuse" = x ]; then | |
557 | # Check for headers.] | |
d64399b5 | 558 | AC_CHECK_HEADERS([usb.h], [], |
e98cd0c2 | 559 | [grub_emu_usb_excuse=["need libusb headers"]]) |
4fe9862e | 560 | [fi] |
c6f3b249 | 561 | if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then |
ce7a733d | 562 | AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled]) |
5ce5507f | 563 | fi |
564 | if test x"$grub_emu_usb_excuse" = x ; then | |
565 | enable_grub_emu_usb=yes | |
566 | else | |
567 | enable_grub_emu_usb=no | |
568 | fi | |
d64399b5 | 569 | AC_SUBST([enable_grub_emu_usb]) |
f84b481b | 570 | fi |
4fe9862e | 571 | |
99fadbaa | 572 | AC_ARG_ENABLE([grub-fstest], |
573 | [AS_HELP_STRING([--enable-grub-fstest], | |
5ce5507f | 574 | [build and install the `grub-fstest' debugging utility (default=guessed)])]) |
575 | if test x"$enable_grub_fstest" = xno ; then | |
ce7a733d | 576 | grub_fstest_excuse="explicitly disabled" |
5ce5507f | 577 | fi |
578 | if test x"$grub_fstest_excuse" = x ; then | |
579 | enable_grub_fstest=yes | |
580 | else | |
581 | enable_grub_fstest=no | |
582 | fi | |
99fadbaa | 583 | AC_SUBST([enable_grub_fstest]) |
584 | ||
e52db1f7 | 585 | AC_ARG_ENABLE([grub-mkfont], |
586 | [AS_HELP_STRING([--enable-grub-mkfont], | |
5ce5507f | 587 | [build and install the `grub-mkfont' utility (default=guessed)])]) |
588 | if test x"$enable_grub_mkfont" = xno ; then | |
ce7a733d | 589 | grub_mkfont_excuse="explicitly disabled" |
5ce5507f | 590 | fi |
591 | ||
592 | if test x"$grub_mkfont_excuse" = x ; then | |
e52db1f7 | 593 | # Check for freetype libraries. |
594 | AC_CHECK_PROGS([FREETYPE], [freetype-config]) | |
595 | if test "x$FREETYPE" = x ; then | |
e98cd0c2 | 596 | grub_mkfont_excuse=["need freetype2 library"] |
e52db1f7 | 597 | fi |
598 | freetype_cflags=`freetype-config --cflags` | |
599 | freetype_libs=`freetype-config --libs` | |
600 | fi | |
5ce5507f | 601 | if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then |
ce7a733d | 602 | AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled]) |
5ce5507f | 603 | fi |
604 | if test x"$grub_mkfont_excuse" = x ; then | |
605 | enable_grub_mkfont=yes | |
606 | else | |
607 | enable_grub_mkfont=no | |
608 | fi | |
e52db1f7 | 609 | AC_SUBST([enable_grub_mkfont]) |
610 | AC_SUBST([freetype_cflags]) | |
611 | AC_SUBST([freetype_libs]) | |
612 | ||
2b167a72 | 613 | AC_SUBST(ASFLAGS) |
fc45fb58 | 614 | |
6a161fa9 | 615 | # Output files. |
1f4147aa | 616 | grub_CHECK_LINK_DIR |
617 | if test x"$link_dir" = xyes ; then | |
f84b481b RM |
618 | AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu]) |
619 | if test "$platform" != emu ; then | |
620 | AC_CONFIG_LINKS([include/grub/machine:include/grub/$target_cpu/$platform]) | |
621 | fi | |
1f4147aa | 622 | else |
623 | mkdir -p include/grub 2>/dev/null | |
624 | rm -rf include/grub/cpu | |
625 | cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null | |
f84b481b RM |
626 | if test "$platform" != emu ; then |
627 | rm -rf include/grub/machine | |
628 | cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null | |
629 | fi | |
1f4147aa | 630 | fi |
7b455f4d | 631 | AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh]) |
6a161fa9 | 632 | AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) |
633 | AC_OUTPUT | |
5ce5507f | 634 | [ |
635 | echo "*******************************************************" | |
636 | echo GRUB2 will be compiled with following components: | |
637 | echo Platform: "$target_cpu"-"$platform" | |
f84b481b | 638 | if [ x"$platform" = xemu ]; then |
5ce5507f | 639 | if [ x"$grub_emu_usb_excuse" = x ]; then |
640 | echo USB support for grub-emu: Yes | |
641 | else | |
642 | echo USB support for grub-emu: No "($grub_emu_usb_excuse)" | |
643 | fi | |
f84b481b | 644 | fi |
5ce5507f | 645 | if [ x"$enable_mm_debug" = xyes ]; then |
646 | echo With memory debugging: Yes | |
647 | else | |
648 | echo With memory debugging: No | |
649 | fi | |
5ce5507f | 650 | if [ x"$efiemu_excuse" = x ]; then |
651 | echo efiemu runtime: Yes | |
652 | else | |
653 | echo efiemu runtime: No "($efiemu_excuse)" | |
654 | fi | |
655 | if [ x"$grub_fstest_excuse" = x ]; then | |
656 | echo grub-fstest: Yes | |
657 | else | |
658 | echo grub-fstest: No "($grub_fstest_excuse)" | |
659 | fi | |
660 | if [ x"$grub_mkfont_excuse" = x ]; then | |
661 | echo grub-mkfont: Yes | |
662 | else | |
663 | echo grub-mkfont: No "($grub_mkfont_excuse)" | |
664 | fi | |
665 | echo "*******************************************************" | |
666 | ] |