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