]>
Commit | Line | Data |
---|---|---|
6a161fa9 | 1 | # Process this file with autoconf to produce a configure script. |
2 | ||
3d04eab8 | 3 | # Copyright (C) 2002,2003,2004,2005,2006,2007,2008 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 | ||
f2a76e1d | 34 | AC_INIT(GRUB, 1.96, [bug-grub@gnu.org]) |
6a161fa9 | 35 | AC_PREREQ(2.53) |
4b13b216 | 36 | AC_CONFIG_SRCDIR([include/grub/dl.h]) |
6a161fa9 | 37 | AC_CONFIG_HEADER([config.h]) |
38 | ||
b977bf01 | 39 | # Checks for host and target systems. |
6a161fa9 | 40 | AC_CANONICAL_HOST |
b977bf01 | 41 | AC_CANONICAL_TARGET |
6a161fa9 | 42 | |
1d543c3e | 43 | # Program name transformations |
44 | AC_ARG_PROGRAM | |
45 | ||
6a161fa9 | 46 | case "$host_cpu" in |
b977bf01 | 47 | powerpc64) host_m32=1 ;; |
48 | esac | |
49 | ||
50 | case "$target_cpu" in | |
51 | i[[3456]]86) target_cpu=i386 ;; | |
6a161fa9 | 52 | esac |
53 | ||
05568c2e | 54 | # Specify the platform (such as firmware). |
55 | AC_ARG_WITH([platform], | |
56 | AS_HELP_STRING([--with-platform=PLATFORM], | |
83b984de | 57 | [select the host platform [[guessed]]])) |
05568c2e | 58 | |
59 | # Guess the platform if not specified. | |
60 | if test "x$with_platform" = x; then | |
b977bf01 | 61 | case "$target_cpu"-"$target_vendor" in |
05568c2e | 62 | i386-apple) platform=efi ;; |
63 | i386-*) platform=pc ;; | |
58393a2d | 64 | x86_64-apple) platform=efi ;; |
737feb35 | 65 | x86_64-*) platform=pc ;; |
05568c2e | 66 | powerpc-*) platform=ieee1275 ;; |
58393a2d | 67 | powerpc64-*) platform=ieee1275 ;; |
05568c2e | 68 | sparc64-*) platform=ieee1275 ;; |
58393a2d | 69 | *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;; |
05568c2e | 70 | esac |
71 | else | |
72 | platform="$with_platform" | |
73 | fi | |
74 | ||
58393a2d | 75 | # Adjust CPU unless target was explicitly specified. |
76 | if test -z "$target_alias"; then | |
77 | case "$target_cpu"-"$platform" in | |
78 | x86_64-efi) ;; | |
3f4ce737 | 79 | x86_64-*) target_cpu=i386 ;; |
80 | powerpc64-ieee1275) target_cpu=powerpc ;; | |
20011694 | 81 | esac |
82 | fi | |
83 | ||
58393a2d | 84 | # Check if the platform is supported, make final adjustments. |
b977bf01 | 85 | case "$target_cpu"-"$platform" in |
05568c2e | 86 | i386-efi) ;; |
3f4ce737 | 87 | x86_64-efi) ;; |
05568c2e | 88 | i386-pc) ;; |
546f966a | 89 | i386-coreboot) ;; |
58393a2d | 90 | i386-linuxbios) platform=coreboot ;; |
3d04eab8 | 91 | i386-ieee1275) ;; |
05568c2e | 92 | powerpc-ieee1275) ;; |
93 | sparc64-ieee1275) ;; | |
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 | ||
b977bf01 | 102 | AC_SUBST(target_cpu) |
05568c2e | 103 | AC_SUBST(platform) |
6a161fa9 | 104 | |
b977bf01 | 105 | # |
106 | # Checks for build programs. | |
107 | # | |
144f1f98 | 108 | |
6c826348 | 109 | # Although cmp is listed in the GNU Coding Standards as a command which |
110 | # can used directly, OpenBSD lacks cmp in the default installation. | |
111 | AC_CHECK_PROGS([CMP], [cmp]) | |
112 | if test "x$CMP" = x; then | |
113 | AC_MSG_ERROR([cmp is not found]) | |
114 | fi | |
115 | ||
144f1f98 | 116 | AC_CHECK_PROGS([YACC], [bison]) |
1569ec51 | 117 | if test "x$YACC" = x; then |
6c826348 | 118 | AC_MSG_ERROR([bison is not found]) |
1569ec51 | 119 | fi |
120 | ||
4931827f | 121 | for file in /usr/share/unifont/unifont.hex ; do |
122 | if test -e $file ; then | |
123 | AC_SUBST([UNIFONT_HEX], [$file]) | |
124 | break | |
125 | fi | |
126 | done | |
127 | ||
b977bf01 | 128 | AC_PROG_INSTALL |
129 | AC_PROG_AWK | |
130 | AC_PROG_MAKE_SET | |
131 | ||
68807e5f | 132 | # These are not a "must". |
b977bf01 | 133 | AC_PATH_PROG(RUBY, ruby) |
68807e5f | 134 | AC_PATH_PROG(HELP2MAN, help2man) |
6a161fa9 | 135 | |
b977bf01 | 136 | # |
137 | # Checks for host programs. | |
138 | # | |
139 | ||
140 | AC_PROG_CC | |
6a161fa9 | 141 | # Must be GCC. |
142 | test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) | |
143 | ||
4889bdec | 144 | AC_GNU_SOURCE |
b977bf01 | 145 | AC_SYS_LARGEFILE |
146 | ||
147 | # Identify characteristics of the host architecture. | |
148 | AC_C_BIGENDIAN | |
149 | AC_CHECK_SIZEOF(void *) | |
150 | AC_CHECK_SIZEOF(long) | |
151 | ||
152 | if test "x$host_m32" = x1; then | |
153 | # Force 32-bit mode. | |
154 | CFLAGS="$CFLAGS -m32" | |
155 | LDFLAGS="$LDFLAGS -m32" | |
156 | fi | |
157 | ||
158 | # Check LZO when compiling for the i386-pc. | |
159 | if test "$target_cpu"-"$platform" = i386-pc; then | |
aa24b516 | 160 | AC_ARG_ENABLE([lzo], |
161 | [AS_HELP_STRING([--enable-lzo], | |
162 | [use lzo to compress kernel (default is lzma)])]) | |
163 | [if [ x"$enable_lzo" = xyes ]; then | |
164 | # There are three possibilities. LZO version 2 installed with the name | |
165 | # liblzo2, with the name liblzo, and LZO version 1.] | |
166 | AC_DEFINE([ENABLE_LZO], [1], [Use lzo compression]) | |
167 | AC_CHECK_LIB([lzo2], [__lzo_init_v2], [LIBLZO="-llzo2"], | |
168 | [AC_CHECK_LIB([lzo], [__lzo_init_v2], [LIBLZO="-llzo"], | |
169 | [AC_CHECK_LIB([lzo], [__lzo_init2], [LIBLZO="-llzo"], | |
170 | [AC_MSG_ERROR([LZO library version 1.02 or later is required])])])]) | |
171 | AC_SUBST([LIBLZO]) | |
172 | [LIBS="$LIBS $LIBLZO"] | |
173 | AC_CHECK_FUNC([lzo1x_999_compress], , | |
b977bf01 | 174 | [AC_MSG_ERROR([LZO1X-999 must be enabled])]) |
175 | ||
aa24b516 | 176 | [# LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h.] |
177 | AC_CHECK_HEADERS([lzo/lzo1x.h lzo1x.h]) | |
178 | [else] | |
179 | AC_DEFINE([ENABLE_LZMA], [1], [Use lzma compression]) | |
180 | [fi] | |
181 | AC_SUBST([enable_lzo]) | |
b977bf01 | 182 | fi |
183 | ||
4889bdec | 184 | # Check for functions. |
185 | AC_CHECK_FUNCS(posix_memalign memalign) | |
186 | ||
b977bf01 | 187 | # |
188 | # Check for target programs. | |
189 | # | |
190 | ||
2a8a80e4 | 191 | |
192 | # Use linker script if present, otherwise use builtin -N script. | |
193 | AC_MSG_CHECKING([for option to link raw image]) | |
194 | if test -f "${srcdir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc"; then | |
195 | TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc" | |
196 | TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}" | |
197 | TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${target_os}-img-ld.sc" | |
198 | else | |
199 | TARGET_IMG_LDSCRIPT= | |
200 | TARGET_IMG_LDFLAGS='-Wl,-N' | |
201 | TARGET_IMG_LDFLAGS_AC='-Wl,-N' | |
202 | fi | |
203 | AC_SUBST(TARGET_IMG_LDSCRIPT) | |
204 | AC_SUBST(TARGET_IMG_LDFLAGS) | |
205 | AC_MSG_RESULT([$TARGET_IMG_LDFLAGS_AC]) | |
206 | ||
207 | # For platforms where ELF is not the default link format. | |
208 | AC_MSG_CHECKING([for command to convert module to ELF format]) | |
209 | if test "$host_os" = cygwin; then | |
210 | TARGET_OBJ2ELF='grub-pe2elf.exe' | |
211 | fi | |
212 | AC_SUBST(TARGET_OBJ2ELF) | |
213 | AC_MSG_RESULT([$TARGET_OBJ2ELF]) | |
214 | ||
b977bf01 | 215 | # For cross-compiling. |
216 | if test "x$target" != "x$host"; then | |
217 | # XXX this depends on the implementation of autoconf! | |
218 | tmp_ac_tool_prefix="$ac_tool_prefix" | |
219 | ac_tool_prefix=$target_alias- | |
220 | ||
221 | AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc], | |
222 | [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])]) | |
223 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
224 | AC_CHECK_TOOL(STRIP, strip) | |
225 | AC_CHECK_TOOL(NM, nm) | |
226 | ||
227 | ac_tool_prefix="$tmp_ac_tool_prefix" | |
228 | else | |
229 | if test "x$TARGET_CC" = x; then | |
230 | TARGET_CC=$CC | |
231 | fi | |
232 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
233 | AC_CHECK_TOOL(STRIP, strip) | |
234 | AC_CHECK_TOOL(NM, nm) | |
235 | fi | |
236 | AC_SUBST(TARGET_CC) | |
237 | ||
238 | ||
239 | # Test the C compiler for the target environment. | |
240 | tmp_CC="$CC" | |
241 | tmp_CFLAGS="$CFLAGS" | |
242 | tmp_LDFLAGS="$LDFLAGS" | |
243 | tmp_CPPFLAGS="$CPPFLAGS" | |
aa6d7826 | 244 | tmp_LIBS="$LIBS" |
b977bf01 | 245 | CC="$TARGET_CC" |
246 | CFLAGS="$TARGET_CFLAGS" | |
247 | CPPFLAGS="$TARGET_CPPFLAGS" | |
248 | LDFLAGS="$TARGET_LDFLAGS" | |
aa6d7826 | 249 | LIBS="" |
b977bf01 | 250 | |
251 | if test "x$TARGET_CFLAGS" = x; then | |
6a161fa9 | 252 | # debug flags. |
b977bf01 | 253 | TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \ |
254 | -Wundef -Wstrict-prototypes -g" | |
6a161fa9 | 255 | |
256 | # optimization flags. | |
322562ea | 257 | AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [ |
6a161fa9 | 258 | CFLAGS=-Os |
322562ea | 259 | AC_TRY_COMPILE(, , grub_cv_cc_Os=yes, grub_cv_cc_Os=no) |
6a161fa9 | 260 | ]) |
322562ea | 261 | if test "x$grub_cv_cc_Os" = xyes; then |
b977bf01 | 262 | TARGET_CFLAGS="$TARGET_CFLAGS -Os" |
6a161fa9 | 263 | else |
b977bf01 | 264 | TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops" |
6a161fa9 | 265 | fi |
266 | ||
267 | # Force no alignment to save space on i386. | |
b977bf01 | 268 | if test "x$target_cpu" = xi386; then |
322562ea | 269 | AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ |
6a161fa9 | 270 | CFLAGS="-falign-loops=1" |
322562ea | 271 | AC_TRY_COMPILE(, , [grub_cv_cc_falign_loop=yes], [grub_cv_cc_falign_loop=no]) |
6a161fa9 | 272 | ]) |
273 | ||
322562ea | 274 | if test "x$grub_cv_cc_falign_loop" = xyes; then |
b977bf01 | 275 | TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" |
6a161fa9 | 276 | else |
b977bf01 | 277 | TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" |
6a161fa9 | 278 | fi |
279 | fi | |
b977bf01 | 280 | fi |
6a161fa9 | 281 | |
b977bf01 | 282 | if test "x$target_m32" = x1; then |
283 | # Force 32-bit mode. | |
284 | TARGET_CFLAGS="$TARGET_CFLAGS -m32" | |
285 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" | |
6a161fa9 | 286 | fi |
b977bf01 | 287 | |
20011694 | 288 | if test "x$target_m64" = x1; then |
289 | # Force 64-bit mode. | |
290 | TARGET_CFLAGS="$TARGET_CFLAGS -m64" | |
291 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" | |
292 | fi | |
293 | ||
baa2a121 | 294 | # |
295 | # Compiler features. | |
296 | # | |
297 | ||
298 | # Smashing stack protector. | |
299 | grub_CHECK_STACK_PROTECTOR | |
c3db8364 | 300 | # Need that, because some distributions ship compilers that include |
baa2a121 | 301 | # `-fstack-protector' in the default specs. |
c3db8364 | 302 | if test "x$ssp_possible" = xyes; then |
303 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector" | |
304 | fi | |
2a8a80e4 | 305 | grub_CHECK_STACK_ARG_PROBE |
306 | # Cygwin's GCC uses alloca() to probe the stackframe on static | |
307 | # stack allocations above some threshold. | |
308 | if test x"$sap_possible" = xyes; then | |
309 | TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" | |
310 | fi | |
baa2a121 | 311 | |
b977bf01 | 312 | AC_SUBST(TARGET_CFLAGS) |
313 | AC_SUBST(TARGET_CPPFLAGS) | |
314 | AC_SUBST(TARGET_LDFLAGS) | |
cb71ba20 | 315 | AC_SUBST(MODULE_LDFLAGS) |
6a161fa9 | 316 | |
aa6d7826 | 317 | # Set them to their new values for the tests below. |
318 | CC="$TARGET_CC" | |
319 | CFLAGS="$TARGET_CFLAGS" | |
320 | CPPFLAGS="$TARGET_CPPFLAGS" | |
321 | LDFLAGS="$TARGET_LDFLAGS" | |
322 | ||
6a161fa9 | 323 | # Defined in aclocal.m4. |
f6130a12 | 324 | grub_PROG_TARGET_CC |
b977bf01 | 325 | grub_PROG_OBJCOPY_ABSOLUTE |
cb71ba20 | 326 | grub_PROG_LD_BUILD_ID_NONE |
4b13b216 | 327 | grub_ASM_USCORE |
b977bf01 | 328 | if test "x$target_cpu" = xi386; then |
2a8a80e4 | 329 | if test ! -z "$TARGET_IMG_LDSCRIPT"; then |
330 | # Check symbols provided by linker script. | |
331 | CFLAGS="$TARGET_CFLAGS -nostdlib $TARGET_IMG_LDFLAGS_AC -Wl,-Ttext,8000,--defsym,___main=0x8100" | |
332 | fi | |
7810e747 | 333 | if test "x$platform" = xpc; then |
2a8a80e4 | 334 | grub_CHECK_START_SYMBOL |
335 | grub_CHECK_BSS_START_SYMBOL | |
336 | grub_CHECK_END_SYMBOL | |
337 | fi | |
338 | CFLAGS="$TARGET_CFLAGS" | |
4b13b216 | 339 | grub_I386_ASM_PREFIX_REQUIREMENT |
340 | grub_I386_ASM_ADDR32 | |
341 | grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK | |
342 | grub_I386_CHECK_REGPARM_BUG | |
5aded270 | 343 | else |
f4917dfd | 344 | AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug]) |
6a161fa9 | 345 | fi |
346 | ||
c9a86192 | 347 | # Restore the flags. |
9962ed99 | 348 | CC="$tmp_CC" |
349 | CFLAGS="$tmp_CFLAGS" | |
350 | CPPFLAGS="$tmp_CPPFLAGS" | |
c9a86192 | 351 | LDFLAGS="$tmp_LDFLAGS" |
aa6d7826 | 352 | LIBS="$tmp_LIBS" |
6a161fa9 | 353 | |
4fe9862e | 354 | # |
2965c7cc | 355 | # Check for options. |
4fe9862e | 356 | # |
357 | ||
358 | # Memory manager debugging. | |
2965c7cc | 359 | AC_ARG_ENABLE([mm-debug], |
360 | AS_HELP_STRING([--enable-mm-debug], | |
90ce5d56 | 361 | [include memory manager debugging]), |
2965c7cc | 362 | [AC_DEFINE([MM_DEBUG], [1], |
363 | [Define to 1 if you enable memory manager debugging.])]) | |
364 | ||
4fe9862e | 365 | AC_ARG_ENABLE([grub-emu], |
366 | [AS_HELP_STRING([--enable-grub-emu], | |
367 | [build and install the `grub-emu' debugging utility])]) | |
368 | [if [ x"$enable_grub_emu" = xyes ]; then | |
369 | # Check for curses libraries.] | |
370 | AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"], | |
371 | [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"], | |
372 | [AC_MSG_ERROR([(n)curses libraries are required to build `grub-emu'])])]) | |
373 | AC_SUBST([LIBCURSES]) | |
374 | ||
375 | [# Check for headers.] | |
376 | AC_CHECK_HEADERS([ncurses/curses.h], [], | |
377 | [AC_CHECK_HEADERS([ncurses.h], [], | |
378 | [AC_CHECK_HEADERS([curses.h], [], | |
379 | [AC_MSG_ERROR([(n)curses header files are required to build `grub-emu'])])])]) | |
380 | [fi] | |
381 | AC_SUBST([enable_grub_emu]) | |
382 | ||
99fadbaa | 383 | AC_ARG_ENABLE([grub-fstest], |
384 | [AS_HELP_STRING([--enable-grub-fstest], | |
385 | [build and install the `grub-fstest' debugging utility])]) | |
386 | AC_SUBST([enable_grub_fstest]) | |
387 | ||
6a161fa9 | 388 | # Output files. |
b977bf01 | 389 | AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu |
390 | include/grub/machine:include/grub/$target_cpu/$platform]) | |
7b455f4d | 391 | AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh]) |
6a161fa9 | 392 | AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) |
393 | AC_OUTPUT |