]> git.proxmox.com Git - grub2.git/blame - configure.ac
2006-05-08 Marco Gerards <marco@gnu.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
5f97350b 14AC_INIT(GRUB, 1.93, [bug-grub@gnu.org])
6a161fa9 15AC_PREREQ(2.53)
4b13b216 16AC_CONFIG_SRCDIR([include/grub/dl.h])
6a161fa9 17AC_CONFIG_HEADER([config.h])
18
19# Checks for build and host systems.
20AC_CANONICAL_BUILD
21AC_CANONICAL_HOST
22
23case "$host_cpu" in
24 i[[3456]]86) host_cpu=i386 ;;
be973c1b 25 x86_64) host_cpu=i386 biarch32=1 ;;
e56cdf21 26 powerpc) ;;
be973c1b 27 powerpc64) host_cpu=powerpc biarch32=1;;
e9211b5d 28 sparc64) ;;
6a161fa9 29 *) AC_MSG_ERROR([unsupported CPU type]) ;;
30esac
31
05568c2e 32# Specify the platform (such as firmware).
33AC_ARG_WITH([platform],
34 AS_HELP_STRING([--with-platform=PLATFORM],
35 [select the host platform [guessed]]))
36
37# Guess the platform if not specified.
38if test "x$with_platform" = x; then
39 case "$host_cpu"-"$host_vendor" in
40 i386-apple) platform=efi ;;
41 i386-*) platform=pc ;;
42 powerpc-*) platform=ieee1275 ;;
43 sparc64-*) platform=ieee1275 ;;
44 *) AC_MSG_ERROR([unsupported machine type]) ;;
45 esac
46else
47 platform="$with_platform"
48fi
49
50# Sanity check.
51case "$host_cpu"-"$platform" in
52 i386-efi) ;;
53 i386-pc) ;;
54 powerpc-ieee1275) ;;
55 sparc64-ieee1275) ;;
6a161fa9 56 *) AC_MSG_ERROR([unsupported machine type]) ;;
57esac
58
59AC_SUBST(host_cpu)
05568c2e 60AC_SUBST(platform)
6a161fa9 61
62# Checks for programs.
63if test "x$CFLAGS" = x; then
64 default_CFLAGS=yes
65fi
66
67AC_PROG_CC
144f1f98 68
69AC_CHECK_PROGS([YACC], [bison])
1569ec51 70if test "x$YACC" = x; then
144f1f98 71 AC_MSG_ERROR([Could not find bison.])
1569ec51 72fi
73
a35eed7c 74AC_SYS_LARGEFILE
6a161fa9 75
76# Must be GCC.
77test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
78
79if test "x$default_CFLAGS" = xyes; then
80 # debug flags.
a5ffe966 81 tmp_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
82 -Wundef -Wstrict-prototypes -g"
6a161fa9 83
84 # optimization flags.
85 AC_CACHE_CHECK([whether optimization for size works], size_flag, [
86 CFLAGS=-Os
87 AC_TRY_COMPILE(, , size_flag=yes, size_flag=no)
88 ])
89 if test "x$size_flag" = xyes; then
90 tmp_CFLAGS="$tmp_CFLAGS -Os"
91 else
92 tmp_CFLAGS="$tmp_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops"
93 fi
94
95 # Force no alignment to save space on i386.
96 if test "x$host_cpu" = xi386; then
97 AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [
98 CFLAGS="-falign-loops=1"
99 AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no])
100 ])
101
102 if test "x$falign_loop_flag" = xyes; then
103 tmp_CFLAGS="$tmp_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
104 else
105 tmp_CFLAGS="$tmp_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
106 fi
107 fi
108
be973c1b 109 if test "x$biarch32" = x1; then
59b8208a 110 tmp_CFLAGS="$tmp_CFLAGS -m32"
ff04ec24 111 LDFLAGS="$LDFLAGS -m32"
112 AC_SUBST(LDFLAGS)
59b8208a 113 fi
114
6a161fa9 115 CFLAGS="$tmp_CFLAGS"
116fi
117AC_SUBST(CFLAGS)
118
119# Defined in aclocal.m4.
4b13b216 120grub_ASM_USCORE
e56cdf21 121if test "x$host_cpu" = xi386; then
4b13b216 122 grub_CHECK_START_SYMBOL
123 grub_CHECK_BSS_START_SYMBOL
124 grub_CHECK_END_SYMBOL
e56cdf21 125fi
6a161fa9 126
127if test "x$host_cpu" = xi386; then
4b13b216 128 grub_I386_ASM_PREFIX_REQUIREMENT
129 grub_I386_ASM_ADDR32
130 grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
131 grub_I386_CHECK_REGPARM_BUG
5aded270 132else
f4917dfd 133 AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
6a161fa9 134fi
135
6a161fa9 136AC_PROG_INSTALL
137AC_PROG_MAKE_SET
138AC_CHECK_TOOL(OBJCOPY, objcopy)
4b13b216 139grub_PROG_OBJCOPY_ABSOLUTE
6a161fa9 140AC_CHECK_TOOL(STRIP, strip)
141AC_CHECK_TOOL(NM, nm)
9962ed99 142AC_CHECK_TOOL(LD, ld)
6a161fa9 143
144# This is not a "must".
145AC_PATH_PROG(RUBY, ruby)
146
147# For cross-compiling.
121c1d83 148if test "x$build" != "x$host"; then
6a161fa9 149 AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
150 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
e56cdf21 151else
152 BUILD_CC="$CC"
153 AC_SUBST(BUILD_CC)
6a161fa9 154fi
155
156# Test the C compiler for the build environment.
9962ed99 157tmp_CC="$CC"
158tmp_CFLAGS="$CFLAGS"
59b8208a 159tmp_LDFLAGS="$LDFLAGS"
9962ed99 160tmp_CPPFLAGS="$CPPFLAGS"
6a161fa9 161CC="$BUILD_CC"
9962ed99 162CFLAGS="$BUILD_CFLAGS"
163CPPFLAGS="$BUILD_CPPFLAGS"
c9a86192 164LDFLAGS="$BUILD_LDFLAGS"
1f5ab428 165
166# Identify characteristics of the build architecture.
6a161fa9 167AC_C_BIGENDIAN
168AC_CHECK_SIZEOF(void *)
169AC_CHECK_SIZEOF(long)
1f5ab428 170
e56cdf21 171# Check LZO when compiling for the i386.
172if test "x$host_cpu" = xi386; then
4ac9bd04 173 # There are three possibilities. LZO version 2 installed with the name
174 # liblzo2, with the name liblzo, and LZO version 1.
175 AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"],
176 AC_CHECK_LIB(lzo, __lzo_init_v2, [LIBLZO="-llzo"],
177 AC_CHECK_LIB(lzo, __lzo_init2, [LIBLZO="-llzo"],
178 AC_MSG_ERROR([LZO library version 1.02 or later is required]))))
179 AC_SUBST(LIBLZO)
180 LIBS="$LIBS $LIBLZO"
e56cdf21 181 AC_CHECK_FUNC(lzo1x_999_compress, ,
182 [AC_MSG_ERROR([LZO1X-999 must be enabled])])
4ac9bd04 183
184 # LZO version 2 uses lzo/lzo1x.h, while LZO version 1 uses lzo1x.h.
185 AC_CHECK_HEADERS(lzo/lzo1x.h lzo1x.h)
e56cdf21 186fi
1f5ab428 187
f4917dfd 188# Check for curses.
189AC_CHECK_LIB(ncurses, wgetch, [LIBCURSES="-lncurses"],
190 [AC_CHECK_LIB(curses, wgetch, [LIBCURSES="-lcurses"])])
191AC_SUBST(LIBCURSES)
192
193# Check for headers.
194AC_CHECK_HEADERS(ncurses/curses.h ncurses.h curses.h)
195
c9a86192 196# Restore the flags.
9962ed99 197CC="$tmp_CC"
198CFLAGS="$tmp_CFLAGS"
199CPPFLAGS="$tmp_CPPFLAGS"
c9a86192 200LDFLAGS="$tmp_LDFLAGS"
6a161fa9 201
2965c7cc 202# Check for options.
203AC_ARG_ENABLE([mm-debug],
204 AS_HELP_STRING([--enable-mm-debug],
205 [include memory manger debugging]),
206 [AC_DEFINE([MM_DEBUG], [1],
207 [Define to 1 if you enable memory manager debugging.])])
208
6a161fa9 209# Output files.
4b13b216 210AC_CONFIG_LINKS([include/grub/cpu:include/grub/$host_cpu
05568c2e 211 include/grub/machine:include/grub/$host_cpu/$platform])
7b455f4d 212AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
6a161fa9 213AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
214AC_OUTPUT