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