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