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