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