]>
Commit | Line | Data |
---|---|---|
6a161fa9 | 1 | # Process this file with autoconf to produce a configure script. |
2 | ||
c9a86192 | 3 | # Copyright (C) 2002,2003,2004,2005,2006 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 | ||
5d74d927 | 34 | AC_INIT(GRUB, 1.95, [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 | |
43 | case "$host_cpu" in | |
b977bf01 | 44 | powerpc64) host_m32=1 ;; |
45 | esac | |
46 | ||
47 | case "$target_cpu" in | |
48 | i[[3456]]86) target_cpu=i386 ;; | |
49 | x86_64) target_cpu=i386 target_m32=1 ;; | |
e56cdf21 | 50 | powerpc) ;; |
b977bf01 | 51 | powerpc64) target_cpu=powerpc target_m32=1;; |
e9211b5d | 52 | sparc64) ;; |
6a161fa9 | 53 | *) AC_MSG_ERROR([unsupported CPU type]) ;; |
54 | esac | |
55 | ||
05568c2e | 56 | # Specify the platform (such as firmware). |
57 | AC_ARG_WITH([platform], | |
58 | AS_HELP_STRING([--with-platform=PLATFORM], | |
83b984de | 59 | [select the host platform [[guessed]]])) |
05568c2e | 60 | |
61 | # Guess the platform if not specified. | |
62 | if test "x$with_platform" = x; then | |
b977bf01 | 63 | case "$target_cpu"-"$target_vendor" in |
05568c2e | 64 | i386-apple) platform=efi ;; |
65 | i386-*) platform=pc ;; | |
66 | powerpc-*) platform=ieee1275 ;; | |
67 | sparc64-*) platform=ieee1275 ;; | |
68 | *) AC_MSG_ERROR([unsupported machine type]) ;; | |
69 | esac | |
70 | else | |
71 | platform="$with_platform" | |
72 | fi | |
73 | ||
74 | # Sanity check. | |
b977bf01 | 75 | case "$target_cpu"-"$platform" in |
05568c2e | 76 | i386-efi) ;; |
77 | i386-pc) ;; | |
78 | powerpc-ieee1275) ;; | |
79 | sparc64-ieee1275) ;; | |
6a161fa9 | 80 | *) AC_MSG_ERROR([unsupported machine type]) ;; |
81 | esac | |
82 | ||
b977bf01 | 83 | AC_SUBST(target_cpu) |
05568c2e | 84 | AC_SUBST(platform) |
6a161fa9 | 85 | |
b977bf01 | 86 | # |
87 | # Checks for build programs. | |
88 | # | |
144f1f98 | 89 | |
6c826348 | 90 | # Although cmp is listed in the GNU Coding Standards as a command which |
91 | # can used directly, OpenBSD lacks cmp in the default installation. | |
92 | AC_CHECK_PROGS([CMP], [cmp]) | |
93 | if test "x$CMP" = x; then | |
94 | AC_MSG_ERROR([cmp is not found]) | |
95 | fi | |
96 | ||
144f1f98 | 97 | AC_CHECK_PROGS([YACC], [bison]) |
1569ec51 | 98 | if test "x$YACC" = x; then |
6c826348 | 99 | AC_MSG_ERROR([bison is not found]) |
1569ec51 | 100 | fi |
101 | ||
b977bf01 | 102 | AC_PROG_INSTALL |
103 | AC_PROG_AWK | |
104 | AC_PROG_MAKE_SET | |
105 | ||
106 | # This is not a "must". | |
107 | AC_PATH_PROG(RUBY, ruby) | |
6a161fa9 | 108 | |
b977bf01 | 109 | # |
110 | # Checks for host programs. | |
111 | # | |
112 | ||
113 | AC_PROG_CC | |
6a161fa9 | 114 | # Must be GCC. |
115 | test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) | |
116 | ||
4889bdec | 117 | AC_GNU_SOURCE |
b977bf01 | 118 | AC_SYS_LARGEFILE |
119 | ||
120 | # Identify characteristics of the host architecture. | |
121 | AC_C_BIGENDIAN | |
122 | AC_CHECK_SIZEOF(void *) | |
123 | AC_CHECK_SIZEOF(long) | |
124 | ||
125 | if test "x$host_m32" = x1; then | |
126 | # Force 32-bit mode. | |
127 | CFLAGS="$CFLAGS -m32" | |
128 | LDFLAGS="$LDFLAGS -m32" | |
129 | fi | |
130 | ||
131 | # Check LZO when compiling for the i386-pc. | |
132 | if test "$target_cpu"-"$platform" = i386-pc; then | |
133 | # There are three possibilities. LZO version 2 installed with the name | |
134 | # liblzo2, with the name liblzo, and LZO version 1. | |
135 | AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"], | |
136 | AC_CHECK_LIB(lzo, __lzo_init_v2, [LIBLZO="-llzo"], | |
137 | AC_CHECK_LIB(lzo, __lzo_init2, [LIBLZO="-llzo"], | |
138 | AC_MSG_ERROR([LZO library version 1.02 or later is required])))) | |
139 | AC_SUBST(LIBLZO) | |
140 | LIBS="$LIBS $LIBLZO" | |
141 | AC_CHECK_FUNC(lzo1x_999_compress, , | |
142 | [AC_MSG_ERROR([LZO1X-999 must be enabled])]) | |
143 | ||
144 | # LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h. | |
145 | AC_CHECK_HEADERS(lzo/lzo1x.h lzo1x.h) | |
146 | fi | |
147 | ||
148 | # Check for curses. | |
149 | AC_CHECK_LIB(ncurses, wgetch, [LIBCURSES="-lncurses"], | |
150 | [AC_CHECK_LIB(curses, wgetch, [LIBCURSES="-lcurses"])]) | |
151 | AC_SUBST(LIBCURSES) | |
152 | ||
153 | # Check for headers. | |
154 | AC_CHECK_HEADERS(ncurses/curses.h ncurses.h curses.h) | |
155 | ||
4889bdec | 156 | # Check for functions. |
157 | AC_CHECK_FUNCS(posix_memalign memalign) | |
158 | ||
b977bf01 | 159 | # |
160 | # Check for target programs. | |
161 | # | |
162 | ||
163 | # For cross-compiling. | |
164 | if test "x$target" != "x$host"; then | |
165 | # XXX this depends on the implementation of autoconf! | |
166 | tmp_ac_tool_prefix="$ac_tool_prefix" | |
167 | ac_tool_prefix=$target_alias- | |
168 | ||
169 | AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc], | |
170 | [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])]) | |
171 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
172 | AC_CHECK_TOOL(STRIP, strip) | |
173 | AC_CHECK_TOOL(NM, nm) | |
174 | ||
175 | ac_tool_prefix="$tmp_ac_tool_prefix" | |
176 | else | |
177 | if test "x$TARGET_CC" = x; then | |
178 | TARGET_CC=$CC | |
179 | fi | |
180 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
181 | AC_CHECK_TOOL(STRIP, strip) | |
182 | AC_CHECK_TOOL(NM, nm) | |
183 | fi | |
184 | AC_SUBST(TARGET_CC) | |
185 | ||
186 | ||
187 | # Test the C compiler for the target environment. | |
188 | tmp_CC="$CC" | |
189 | tmp_CFLAGS="$CFLAGS" | |
190 | tmp_LDFLAGS="$LDFLAGS" | |
191 | tmp_CPPFLAGS="$CPPFLAGS" | |
aa6d7826 | 192 | tmp_LIBS="$LIBS" |
b977bf01 | 193 | CC="$TARGET_CC" |
194 | CFLAGS="$TARGET_CFLAGS" | |
195 | CPPFLAGS="$TARGET_CPPFLAGS" | |
196 | LDFLAGS="$TARGET_LDFLAGS" | |
aa6d7826 | 197 | LIBS="" |
b977bf01 | 198 | |
199 | if test "x$TARGET_CFLAGS" = x; then | |
6a161fa9 | 200 | # debug flags. |
b977bf01 | 201 | TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \ |
202 | -Wundef -Wstrict-prototypes -g" | |
6a161fa9 | 203 | |
204 | # optimization flags. | |
205 | AC_CACHE_CHECK([whether optimization for size works], size_flag, [ | |
206 | CFLAGS=-Os | |
207 | AC_TRY_COMPILE(, , size_flag=yes, size_flag=no) | |
208 | ]) | |
209 | if test "x$size_flag" = xyes; then | |
b977bf01 | 210 | TARGET_CFLAGS="$TARGET_CFLAGS -Os" |
6a161fa9 | 211 | else |
b977bf01 | 212 | TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops" |
6a161fa9 | 213 | fi |
214 | ||
215 | # Force no alignment to save space on i386. | |
b977bf01 | 216 | if test "x$target_cpu" = xi386; then |
6a161fa9 | 217 | AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [ |
218 | CFLAGS="-falign-loops=1" | |
219 | AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no]) | |
220 | ]) | |
221 | ||
222 | if test "x$falign_loop_flag" = xyes; then | |
b977bf01 | 223 | TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" |
6a161fa9 | 224 | else |
b977bf01 | 225 | TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" |
6a161fa9 | 226 | fi |
227 | fi | |
b977bf01 | 228 | fi |
6a161fa9 | 229 | |
b977bf01 | 230 | if test "x$target_m32" = x1; then |
231 | # Force 32-bit mode. | |
232 | TARGET_CFLAGS="$TARGET_CFLAGS -m32" | |
233 | TARGET_LDFLAGS="$TARGET_LDFLAGS -m32" | |
6a161fa9 | 234 | fi |
b977bf01 | 235 | |
236 | AC_SUBST(TARGET_CFLAGS) | |
237 | AC_SUBST(TARGET_CPPFLAGS) | |
238 | AC_SUBST(TARGET_LDFLAGS) | |
6a161fa9 | 239 | |
aa6d7826 | 240 | # Set them to their new values for the tests below. |
241 | CC="$TARGET_CC" | |
242 | CFLAGS="$TARGET_CFLAGS" | |
243 | CPPFLAGS="$TARGET_CPPFLAGS" | |
244 | LDFLAGS="$TARGET_LDFLAGS" | |
245 | ||
6a161fa9 | 246 | # Defined in aclocal.m4. |
b977bf01 | 247 | grub_PROG_OBJCOPY_ABSOLUTE |
4b13b216 | 248 | grub_ASM_USCORE |
b977bf01 | 249 | if test "x$target_cpu" = xi386; then |
4b13b216 | 250 | grub_CHECK_START_SYMBOL |
251 | grub_CHECK_BSS_START_SYMBOL | |
252 | grub_CHECK_END_SYMBOL | |
4b13b216 | 253 | grub_I386_ASM_PREFIX_REQUIREMENT |
254 | grub_I386_ASM_ADDR32 | |
255 | grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK | |
256 | grub_I386_CHECK_REGPARM_BUG | |
5aded270 | 257 | else |
f4917dfd | 258 | AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug]) |
6a161fa9 | 259 | fi |
260 | ||
c9a86192 | 261 | # Restore the flags. |
9962ed99 | 262 | CC="$tmp_CC" |
263 | CFLAGS="$tmp_CFLAGS" | |
264 | CPPFLAGS="$tmp_CPPFLAGS" | |
c9a86192 | 265 | LDFLAGS="$tmp_LDFLAGS" |
aa6d7826 | 266 | LIBS="$tmp_LIBS" |
6a161fa9 | 267 | |
2965c7cc | 268 | # Check for options. |
269 | AC_ARG_ENABLE([mm-debug], | |
270 | AS_HELP_STRING([--enable-mm-debug], | |
90ce5d56 | 271 | [include memory manager debugging]), |
2965c7cc | 272 | [AC_DEFINE([MM_DEBUG], [1], |
273 | [Define to 1 if you enable memory manager debugging.])]) | |
274 | ||
6a161fa9 | 275 | # Output files. |
b977bf01 | 276 | AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu |
277 | include/grub/machine:include/grub/$target_cpu/$platform]) | |
7b455f4d | 278 | AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh]) |
6a161fa9 | 279 | AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) |
280 | AC_OUTPUT |