]> git.proxmox.com Git - grub2.git/blame - configure.ac
Typo fix
[grub2.git] / configure.ac
CommitLineData
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 14dnl This configure script is complicated, because GRUB needs to deal
15dnl with three potentially different types:
16dnl
17dnl build -- the environment for building GRUB
18dnl host -- the environment for running utilities
19dnl target -- the environment for running GRUB
20dnl
21dnl In addition, GRUB needs to deal with a platform specification
22dnl which specifies the system running GRUB, such as firmware.
23dnl This is necessary because the target type in autoconf does not
24dnl describe such a system very well.
25dnl
26dnl The current strategy is to use variables with no prefix (such as
27dnl CC, CFLAGS, etc.) for the host type as well as the build type,
28dnl because GRUB does not need to use those variables for the build
29dnl type, so there is no conflict. Variables with the prefix "TARGET_"
30dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
31dnl type.
32
33
f2a76e1d 34AC_INIT(GRUB, 1.96, [bug-grub@gnu.org])
6a161fa9 35AC_PREREQ(2.53)
4b13b216 36AC_CONFIG_SRCDIR([include/grub/dl.h])
6a161fa9 37AC_CONFIG_HEADER([config.h])
38
b977bf01 39# Checks for host and target systems.
6a161fa9 40AC_CANONICAL_HOST
b977bf01 41AC_CANONICAL_TARGET
6a161fa9 42
1d543c3e 43# Program name transformations
44AC_ARG_PROGRAM
45
6a161fa9 46case "$host_cpu" in
b977bf01 47 powerpc64) host_m32=1 ;;
48esac
49
50case "$target_cpu" in
51 i[[3456]]86) target_cpu=i386 ;;
6a161fa9 52esac
53
05568c2e 54# Specify the platform (such as firmware).
55AC_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.
60if 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
71else
72 platform="$with_platform"
73fi
74
58393a2d 75# Adjust CPU unless target was explicitly specified.
76if 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
82fi
83
58393a2d 84# Check if the platform is supported, make final adjustments.
b977bf01 85case "$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 95esac
96
b977bf01 97AC_SUBST(target_cpu)
05568c2e 98AC_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.
106AC_CHECK_PROGS([CMP], [cmp])
107if test "x$CMP" = x; then
108 AC_MSG_ERROR([cmp is not found])
109fi
110
144f1f98 111AC_CHECK_PROGS([YACC], [bison])
1569ec51 112if test "x$YACC" = x; then
6c826348 113 AC_MSG_ERROR([bison is not found])
1569ec51 114fi
115
4931827f 116for file in /usr/share/unifont/unifont.hex ; do
117 if test -e $file ; then
118 AC_SUBST([UNIFONT_HEX], [$file])
119 break
120 fi
121done
122
b977bf01 123AC_PROG_INSTALL
124AC_PROG_AWK
125AC_PROG_MAKE_SET
126
68807e5f 127# These are not a "must".
b977bf01 128AC_PATH_PROG(RUBY, ruby)
68807e5f 129AC_PATH_PROG(HELP2MAN, help2man)
6a161fa9 130
b977bf01 131#
132# Checks for host programs.
133#
134
135AC_PROG_CC
6a161fa9 136# Must be GCC.
137test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
138
4889bdec 139AC_GNU_SOURCE
b977bf01 140AC_SYS_LARGEFILE
141
142# Identify characteristics of the host architecture.
143AC_C_BIGENDIAN
144AC_CHECK_SIZEOF(void *)
145AC_CHECK_SIZEOF(long)
146
147if test "x$host_m32" = x1; then
148 # Force 32-bit mode.
149 CFLAGS="$CFLAGS -m32"
150 LDFLAGS="$LDFLAGS -m32"
151fi
152
153# Check LZO when compiling for the i386-pc.
154if 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 177fi
178
4889bdec 179# Check for functions.
180AC_CHECK_FUNCS(posix_memalign memalign)
181
b977bf01 182#
183# Check for target programs.
184#
185
186# For cross-compiling.
187if 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"
199else
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)
206fi
207AC_SUBST(TARGET_CC)
208
209
210# Test the C compiler for the target environment.
211tmp_CC="$CC"
212tmp_CFLAGS="$CFLAGS"
213tmp_LDFLAGS="$LDFLAGS"
214tmp_CPPFLAGS="$CPPFLAGS"
aa6d7826 215tmp_LIBS="$LIBS"
b977bf01 216CC="$TARGET_CC"
217CFLAGS="$TARGET_CFLAGS"
218CPPFLAGS="$TARGET_CPPFLAGS"
219LDFLAGS="$TARGET_LDFLAGS"
aa6d7826 220LIBS=""
b977bf01 221
222if 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 251fi
6a161fa9 252
b977bf01 253if test "x$target_m32" = x1; then
254 # Force 32-bit mode.
255 TARGET_CFLAGS="$TARGET_CFLAGS -m32"
256 TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
6a161fa9 257fi
b977bf01 258
20011694 259if test "x$target_m64" = x1; then
260 # Force 64-bit mode.
261 TARGET_CFLAGS="$TARGET_CFLAGS -m64"
262 TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
263fi
264
baa2a121 265#
266# Compiler features.
267#
268
269# Smashing stack protector.
270grub_CHECK_STACK_PROTECTOR
c3db8364 271# Need that, because some distributions ship compilers that include
baa2a121 272# `-fstack-protector' in the default specs.
c3db8364 273if test "x$ssp_possible" = xyes; then
274 TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
275fi
baa2a121 276
b977bf01 277AC_SUBST(TARGET_CFLAGS)
278AC_SUBST(TARGET_CPPFLAGS)
279AC_SUBST(TARGET_LDFLAGS)
cb71ba20 280AC_SUBST(MODULE_LDFLAGS)
6a161fa9 281
aa6d7826 282# Set them to their new values for the tests below.
283CC="$TARGET_CC"
284CFLAGS="$TARGET_CFLAGS"
285CPPFLAGS="$TARGET_CPPFLAGS"
286LDFLAGS="$TARGET_LDFLAGS"
287
6a161fa9 288# Defined in aclocal.m4.
f6130a12 289grub_PROG_TARGET_CC
b977bf01 290grub_PROG_OBJCOPY_ABSOLUTE
cb71ba20 291grub_PROG_LD_BUILD_ID_NONE
4b13b216 292grub_ASM_USCORE
b977bf01 293if 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 301else
f4917dfd 302 AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
6a161fa9 303fi
304
c9a86192 305# Restore the flags.
9962ed99 306CC="$tmp_CC"
307CFLAGS="$tmp_CFLAGS"
308CPPFLAGS="$tmp_CPPFLAGS"
c9a86192 309LDFLAGS="$tmp_LDFLAGS"
aa6d7826 310LIBS="$tmp_LIBS"
6a161fa9 311
4fe9862e 312#
2965c7cc 313# Check for options.
4fe9862e 314#
315
316# Memory manager debugging.
2965c7cc 317AC_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 323AC_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]
339AC_SUBST([enable_grub_emu])
340
99fadbaa 341AC_ARG_ENABLE([grub-fstest],
342 [AS_HELP_STRING([--enable-grub-fstest],
343 [build and install the `grub-fstest' debugging utility])])
344AC_SUBST([enable_grub_fstest])
345
6a161fa9 346# Output files.
b977bf01 347AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu
348 include/grub/machine:include/grub/$target_cpu/$platform])
7b455f4d 349AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
6a161fa9 350AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
351AC_OUTPUT