]>
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) ;; | |
79 | x86_64-*) target_cpu=i386 target_m32=1 ;; | |
80 | powerpc64-ieee1275) target_cpu=powerpc target_m32=1 ;; | |
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) ;; |
58393a2d | 87 | x86_64-efi) target_m64=1 ;; |
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 | ||
b977bf01 | 97 | AC_SUBST(target_cpu) |
05568c2e | 98 | AC_SUBST(platform) |
6a161fa9 | 99 | |
b977bf01 | 100 | # |
101 | # Checks for build programs. | |
102 | # | |
144f1f98 | 103 | |
6c826348 | 104 | # Although cmp is listed in the GNU Coding Standards as a command which |
105 | # can used directly, OpenBSD lacks cmp in the default installation. | |
106 | AC_CHECK_PROGS([CMP], [cmp]) | |
107 | if test "x$CMP" = x; then | |
108 | AC_MSG_ERROR([cmp is not found]) | |
109 | fi | |
110 | ||
144f1f98 | 111 | AC_CHECK_PROGS([YACC], [bison]) |
1569ec51 | 112 | if test "x$YACC" = x; then |
6c826348 | 113 | AC_MSG_ERROR([bison is not found]) |
1569ec51 | 114 | fi |
115 | ||
4931827f | 116 | for file in /usr/share/unifont/unifont.hex ; do |
117 | if test -e $file ; then | |
118 | AC_SUBST([UNIFONT_HEX], [$file]) | |
119 | break | |
120 | fi | |
121 | done | |
122 | ||
b977bf01 | 123 | AC_PROG_INSTALL |
124 | AC_PROG_AWK | |
125 | AC_PROG_MAKE_SET | |
126 | ||
68807e5f | 127 | # These are not a "must". |
b977bf01 | 128 | AC_PATH_PROG(RUBY, ruby) |
68807e5f | 129 | AC_PATH_PROG(HELP2MAN, help2man) |
6a161fa9 | 130 | |
b977bf01 | 131 | # |
132 | # Checks for host programs. | |
133 | # | |
134 | ||
135 | AC_PROG_CC | |
6a161fa9 | 136 | # Must be GCC. |
137 | test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) | |
138 | ||
4889bdec | 139 | AC_GNU_SOURCE |
b977bf01 | 140 | AC_SYS_LARGEFILE |
141 | ||
142 | # Identify characteristics of the host architecture. | |
143 | AC_C_BIGENDIAN | |
144 | AC_CHECK_SIZEOF(void *) | |
145 | AC_CHECK_SIZEOF(long) | |
146 | ||
147 | if test "x$host_m32" = x1; then | |
148 | # Force 32-bit mode. | |
149 | CFLAGS="$CFLAGS -m32" | |
150 | LDFLAGS="$LDFLAGS -m32" | |
151 | fi | |
152 | ||
153 | # Check LZO when compiling for the i386-pc. | |
154 | if test "$target_cpu"-"$platform" = i386-pc; then | |
aa24b516 | 155 | AC_ARG_ENABLE([lzo], |
156 | [AS_HELP_STRING([--enable-lzo], | |
157 | [use lzo to compress kernel (default is lzma)])]) | |
158 | [if [ x"$enable_lzo" = xyes ]; then | |
159 | # There are three possibilities. LZO version 2 installed with the name | |
160 | # liblzo2, with the name liblzo, and LZO version 1.] | |
161 | AC_DEFINE([ENABLE_LZO], [1], [Use lzo compression]) | |
162 | AC_CHECK_LIB([lzo2], [__lzo_init_v2], [LIBLZO="-llzo2"], | |
163 | [AC_CHECK_LIB([lzo], [__lzo_init_v2], [LIBLZO="-llzo"], | |
164 | [AC_CHECK_LIB([lzo], [__lzo_init2], [LIBLZO="-llzo"], | |
165 | [AC_MSG_ERROR([LZO library version 1.02 or later is required])])])]) | |
166 | AC_SUBST([LIBLZO]) | |
167 | [LIBS="$LIBS $LIBLZO"] | |
168 | AC_CHECK_FUNC([lzo1x_999_compress], , | |
b977bf01 | 169 | [AC_MSG_ERROR([LZO1X-999 must be enabled])]) |
170 | ||
aa24b516 | 171 | [# LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h.] |
172 | AC_CHECK_HEADERS([lzo/lzo1x.h lzo1x.h]) | |
173 | [else] | |
174 | AC_DEFINE([ENABLE_LZMA], [1], [Use lzma compression]) | |
175 | [fi] | |
176 | AC_SUBST([enable_lzo]) | |
b977bf01 | 177 | fi |
178 | ||
4889bdec | 179 | # Check for functions. |
180 | AC_CHECK_FUNCS(posix_memalign memalign) | |
181 | ||
b977bf01 | 182 | # |
183 | # Check for target programs. | |
184 | # | |
185 | ||
186 | # For cross-compiling. | |
187 | if test "x$target" != "x$host"; then | |
188 | # XXX this depends on the implementation of autoconf! | |
189 | tmp_ac_tool_prefix="$ac_tool_prefix" | |
190 | ac_tool_prefix=$target_alias- | |
191 | ||
192 | AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc], | |
193 | [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])]) | |
194 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
195 | AC_CHECK_TOOL(STRIP, strip) | |
196 | AC_CHECK_TOOL(NM, nm) | |
197 | ||
198 | ac_tool_prefix="$tmp_ac_tool_prefix" | |
199 | else | |
200 | if test "x$TARGET_CC" = x; then | |
201 | TARGET_CC=$CC | |
202 | fi | |
203 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
204 | AC_CHECK_TOOL(STRIP, strip) | |
205 | AC_CHECK_TOOL(NM, nm) | |
206 | fi | |
207 | AC_SUBST(TARGET_CC) | |
208 | ||
209 | ||
210 | # Test the C compiler for the target environment. | |
211 | tmp_CC="$CC" | |
212 | tmp_CFLAGS="$CFLAGS" | |
213 | tmp_LDFLAGS="$LDFLAGS" | |
214 | tmp_CPPFLAGS="$CPPFLAGS" | |
aa6d7826 | 215 | tmp_LIBS="$LIBS" |
b977bf01 | 216 | CC="$TARGET_CC" |
217 | CFLAGS="$TARGET_CFLAGS" | |
218 | CPPFLAGS="$TARGET_CPPFLAGS" | |
219 | LDFLAGS="$TARGET_LDFLAGS" | |
aa6d7826 | 220 | LIBS="" |
b977bf01 | 221 | |
222 | if test "x$TARGET_CFLAGS" = x; then | |
6a161fa9 | 223 | # debug flags. |
b977bf01 | 224 | TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \ |
225 | -Wundef -Wstrict-prototypes -g" | |
6a161fa9 | 226 | |
227 | # optimization flags. | |
322562ea | 228 | AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [ |
6a161fa9 | 229 | CFLAGS=-Os |
322562ea | 230 | AC_TRY_COMPILE(, , grub_cv_cc_Os=yes, grub_cv_cc_Os=no) |
6a161fa9 | 231 | ]) |
322562ea | 232 | if test "x$grub_cv_cc_Os" = xyes; then |
b977bf01 | 233 | TARGET_CFLAGS="$TARGET_CFLAGS -Os" |
6a161fa9 | 234 | else |
b977bf01 | 235 | TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops" |
6a161fa9 | 236 | fi |
237 | ||
238 | # Force no alignment to save space on i386. | |
b977bf01 | 239 | if test "x$target_cpu" = xi386; then |
322562ea | 240 | AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ |
6a161fa9 | 241 | CFLAGS="-falign-loops=1" |
322562ea | 242 | AC_TRY_COMPILE(, , [grub_cv_cc_falign_loop=yes], [grub_cv_cc_falign_loop=no]) |
6a161fa9 | 243 | ]) |
244 | ||
322562ea | 245 | if test "x$grub_cv_cc_falign_loop" = xyes; then |
b977bf01 | 246 | TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" |
6a161fa9 | 247 | else |
b977bf01 | 248 | TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" |
6a161fa9 | 249 | fi |
250 | fi | |
b977bf01 | 251 | fi |
6a161fa9 | 252 | |
b977bf01 | 253 | if test "x$target_m32" = x1; then |
254 | # Force 32-bit mode. | |
255 | TARGET_CFLAGS="$TARGET_CFLAGS -m32" | |
256 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" | |
6a161fa9 | 257 | fi |
b977bf01 | 258 | |
20011694 | 259 | if test "x$target_m64" = x1; then |
260 | # Force 64-bit mode. | |
261 | TARGET_CFLAGS="$TARGET_CFLAGS -m64" | |
262 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m64" | |
263 | fi | |
264 | ||
baa2a121 | 265 | # |
266 | # Compiler features. | |
267 | # | |
268 | ||
269 | # Smashing stack protector. | |
270 | grub_CHECK_STACK_PROTECTOR | |
c3db8364 | 271 | # Need that, because some distributions ship compilers that include |
baa2a121 | 272 | # `-fstack-protector' in the default specs. |
c3db8364 | 273 | if test "x$ssp_possible" = xyes; then |
274 | TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector" | |
275 | fi | |
baa2a121 | 276 | |
b977bf01 | 277 | AC_SUBST(TARGET_CFLAGS) |
278 | AC_SUBST(TARGET_CPPFLAGS) | |
279 | AC_SUBST(TARGET_LDFLAGS) | |
cb71ba20 | 280 | AC_SUBST(MODULE_LDFLAGS) |
6a161fa9 | 281 | |
aa6d7826 | 282 | # Set them to their new values for the tests below. |
283 | CC="$TARGET_CC" | |
284 | CFLAGS="$TARGET_CFLAGS" | |
285 | CPPFLAGS="$TARGET_CPPFLAGS" | |
286 | LDFLAGS="$TARGET_LDFLAGS" | |
287 | ||
6a161fa9 | 288 | # Defined in aclocal.m4. |
f6130a12 | 289 | grub_PROG_TARGET_CC |
b977bf01 | 290 | grub_PROG_OBJCOPY_ABSOLUTE |
cb71ba20 | 291 | grub_PROG_LD_BUILD_ID_NONE |
4b13b216 | 292 | grub_ASM_USCORE |
b977bf01 | 293 | if test "x$target_cpu" = xi386; then |
4b13b216 | 294 | grub_CHECK_START_SYMBOL |
295 | grub_CHECK_BSS_START_SYMBOL | |
296 | grub_CHECK_END_SYMBOL | |
4b13b216 | 297 | grub_I386_ASM_PREFIX_REQUIREMENT |
298 | grub_I386_ASM_ADDR32 | |
299 | grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK | |
300 | grub_I386_CHECK_REGPARM_BUG | |
5aded270 | 301 | else |
f4917dfd | 302 | AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug]) |
6a161fa9 | 303 | fi |
304 | ||
c9a86192 | 305 | # Restore the flags. |
9962ed99 | 306 | CC="$tmp_CC" |
307 | CFLAGS="$tmp_CFLAGS" | |
308 | CPPFLAGS="$tmp_CPPFLAGS" | |
c9a86192 | 309 | LDFLAGS="$tmp_LDFLAGS" |
aa6d7826 | 310 | LIBS="$tmp_LIBS" |
6a161fa9 | 311 | |
4fe9862e | 312 | # |
2965c7cc | 313 | # Check for options. |
4fe9862e | 314 | # |
315 | ||
316 | # Memory manager debugging. | |
2965c7cc | 317 | AC_ARG_ENABLE([mm-debug], |
318 | AS_HELP_STRING([--enable-mm-debug], | |
90ce5d56 | 319 | [include memory manager debugging]), |
2965c7cc | 320 | [AC_DEFINE([MM_DEBUG], [1], |
321 | [Define to 1 if you enable memory manager debugging.])]) | |
322 | ||
4fe9862e | 323 | AC_ARG_ENABLE([grub-emu], |
324 | [AS_HELP_STRING([--enable-grub-emu], | |
325 | [build and install the `grub-emu' debugging utility])]) | |
326 | [if [ x"$enable_grub_emu" = xyes ]; then | |
327 | # Check for curses libraries.] | |
328 | AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"], | |
329 | [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"], | |
330 | [AC_MSG_ERROR([(n)curses libraries are required to build `grub-emu'])])]) | |
331 | AC_SUBST([LIBCURSES]) | |
332 | ||
333 | [# Check for headers.] | |
334 | AC_CHECK_HEADERS([ncurses/curses.h], [], | |
335 | [AC_CHECK_HEADERS([ncurses.h], [], | |
336 | [AC_CHECK_HEADERS([curses.h], [], | |
337 | [AC_MSG_ERROR([(n)curses header files are required to build `grub-emu'])])])]) | |
338 | [fi] | |
339 | AC_SUBST([enable_grub_emu]) | |
340 | ||
99fadbaa | 341 | AC_ARG_ENABLE([grub-fstest], |
342 | [AS_HELP_STRING([--enable-grub-fstest], | |
343 | [build and install the `grub-fstest' debugging utility])]) | |
344 | AC_SUBST([enable_grub_fstest]) | |
345 | ||
6a161fa9 | 346 | # Output files. |
b977bf01 | 347 | AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu |
348 | include/grub/machine:include/grub/$target_cpu/$platform]) | |
7b455f4d | 349 | AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh]) |
6a161fa9 | 350 | AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) |
351 | AC_OUTPUT |