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