1 # configure.in - Configure template for libelf.
2 # Process this file with autoconf to produce a configure script.
3 # Copyright (C) 1995 - 2006 Michael Riepe
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Library General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Library General Public License for more details.
15 # You should have received a copy of the GNU Library General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 # @(#) $Id: configure.in,v 1.41 2008/05/23 08:17:56 michael Exp $
22 AC_CONFIG_HEADER(config.h lib/sys_elf.h)
28 dnl NOTE: there must be at least one .po file!
29 ALL_LINGUAS=`cd $srcdir/po && echo *.po | sed 's/\.po//g'`
31 dnl Assuming all arguments have already been processed...
32 set `echo $VERSION | sed 's/\./ /g'`
38 dnl Checks for programs.
46 dnl Checks for libraries.
48 dnl Checks for header files.
50 AC_CHECK_HEADERS(unistd.h stdint.h fcntl.h)
51 AC_CHECK_HEADERS(elf.h sys/elf.h link.h sys/link.h)
52 AC_CACHE_CHECK([if ${CC} can compile elf.h], libelf_cv_elf_h_works, [
60 [libelf_cv_elf_h_works=yes],
61 [libelf_cv_elf_h_works=no])
63 if test "$libelf_cv_elf_h_works" = no; then
65 ac_cv_header_sys_elf_h=no
67 if test "$ac_cv_header_elf_h" = yes; then
68 AC_DEFINE(__LIBELF_HEADER_ELF_H, [<elf.h>])
69 elif test "$ac_cv_header_sys_elf_h" = yes; then
70 AC_DEFINE(__LIBELF_HEADER_ELF_H, [<sys/elf.h>])
73 AC_CHECK_HEADERS(ar.h libelf.h nlist.h gelf.h)
74 AC_MSG_CHECKING([whether to install <libelf.h>, <nlist.h> and <gelf.h>])
76 [ --enable-compat install <libelf.h>, <nlist.h> and <gelf.h> (default: auto)],
77 [DO_COMPAT="$enableval"],
78 [if test "$ac_cv_header_libelf_h$ac_cv_header_nlist_h$ac_cv_header_gelf_h" = yesyesyes
82 AC_MSG_RESULT($DO_COMPAT)
85 dnl Checks for typedefs, structures, and compiler characteristics.
90 AC_CHECK_SIZEOF(short,2)
91 AC_CHECK_SIZEOF(int,4)
92 AC_CHECK_SIZEOF(long,4)
93 AC_CHECK_SIZEOF(long long,0)
95 AC_CHECK_SIZEOF(__int64, 0)
97 if test "$ac_cv_header_elf_h" = yes \
98 || test "$ac_cv_header_sys_elf_h" = yes; then
100 # Slowaris declares Elf32_Dyn in <link.h>.
101 # QNX declares Elf32_Dyn in <sys/link.h>.
102 AC_CACHE_CHECK([for struct Elf32_Dyn], libelf_cv_struct_elf32_dyn, [
103 AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], [Elf32_Dyn x],
104 [libelf_cv_struct_elf32_dyn=yes],
105 AC_TRY_COMPILE([#include <link.h>], [Elf32_Dyn x],
106 [libelf_cv_struct_elf32_dyn=link.h],
107 AC_TRY_COMPILE([#include <sys/link.h>], [Elf32_Dyn x],
108 [libelf_cv_struct_elf32_dyn=sys/link.h],
109 [libelf_cv_struct_elf32_dyn=no])))])
110 if test "$libelf_cv_struct_elf32_dyn" = link.h; then
111 AC_DEFINE(__LIBELF_NEED_LINK_H)
112 elif test "$libelf_cv_struct_elf32_dyn" = sys/link.h; then
113 AC_DEFINE(__LIBELF_NEED_SYS_LINK_H)
114 elif test "$libelf_cv_struct_elf32_dyn" = no; then
115 AC_MSG_ERROR([no declaration for Elf32_Dyn])
118 # Linux declares struct nlist in <elf.h>.
119 AC_CACHE_CHECK([for struct nlist in elf.h], libelf_cv_struct_nlist, [
120 AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], [struct nlist nl],
121 [libelf_cv_struct_nlist=yes],
122 [libelf_cv_struct_nlist=no])])
123 if test "$libelf_cv_struct_nlist" = yes; then
124 AC_DEFINE(HAVE_STRUCT_NLIST_DECLARATION)
127 # Check for 64-bit data types.
128 AC_CACHE_CHECK([for struct Elf64_Ehdr], libelf_cv_struct_elf64_ehdr,
129 AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
131 [libelf_cv_struct_elf64_ehdr=yes],
132 [libelf_cv_struct_elf64_ehdr=no]))
134 # Linux lacks typedefs for scalar ELF64_* types.
135 AC_CACHE_CHECK([for Elf64_Addr], libelf_cv_type_elf64_addr,
136 AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
138 [libelf_cv_type_elf64_addr=yes],
139 [libelf_cv_type_elf64_addr=no]))
141 # IRIX' struct Elf64_Rel is slightly different. Ugh.
142 AC_CACHE_CHECK([for struct Elf64_Rel], libelf_cv_struct_elf64_rel,
143 AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
144 [Elf64_Rel x; x.r_info = 1],
145 [libelf_cv_struct_elf64_rel=yes],
146 AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
147 [Elf64_Rel x; x.r_sym = 1],
148 [libelf_cv_struct_elf64_rel=irix],
149 [libelf_cv_struct_elf64_rel=no])))
151 case "$libelf_cv_struct_elf64_ehdr:\
152 $libelf_cv_type_elf64_addr:\
153 $libelf_cv_struct_elf64_rel" in
157 AC_DEFINE(__LIBELF64_IRIX)
160 AC_DEFINE(__LIBELF64_LINUX)
166 # Check for symbol versioning definitions
167 AC_CACHE_CHECK([for Elf32_Verdef], libelf_cv_verdef32,
169 [#include __LIBELF_HEADER_ELF_H
170 #if __LIBELF_NEED_LINK_H
171 #include <link.h> /* Solaris wants this */
179 [libelf_cv_verdef32=yes],
180 [libelf_cv_verdef32=no]))
182 AC_CACHE_CHECK([for Elf64_Verdef], libelf_cv_verdef64,
184 [#include __LIBELF_HEADER_ELF_H
185 #if __LIBELF_NEED_LINK_H
186 #include <link.h> /* Solaris wants this */
194 [libelf_cv_verdef64=yes],
195 [libelf_cv_verdef64=no]))
197 AC_CACHE_CHECK([for SHT_SUNW_verdef], libelf_cv_sun_verdef,
198 AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
199 [Elf32_Word x = SHT_SUNW_verdef + SHT_SUNW_verneed + SHT_SUNW_versym],
200 [libelf_cv_sun_verdef=yes],
201 [libelf_cv_sun_verdef=no]))
203 AC_CACHE_CHECK([for SHT_GNU_verdef], libelf_cv_gnu_verdef,
204 AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
205 [Elf32_Word x = SHT_GNU_verdef + SHT_GNU_verneed + SHT_GNU_versym],
206 [libelf_cv_gnu_verdef=yes],
207 [libelf_cv_gnu_verdef=no]))
209 # lib/elf_repl.h supports 64-bit
212 # lib/elf_repl.h supports symbol versioning
213 libelf_cv_verdef32=yes
214 libelf_cv_verdef64=yes
215 libelf_cv_sun_verdef=yes
216 libelf_cv_gnu_verdef=yes
219 AC_CACHE_CHECK([for 64-bit integer], libelf_cv_int64, [
220 if test "$ac_cv_sizeof_long" = 8; then
221 libelf_cv_int64='long'
222 elif test "$ac_cv_sizeof___int64" = 8; then
223 libelf_cv_int64='__int64'
224 elif test "$ac_cv_sizeof_long_long" = 8; then
225 libelf_cv_int64='long long'
229 if test "$libelf_cv_int64" = no; then
232 AC_DEFINE_UNQUOTED(__libelf_i64_t, [$libelf_cv_int64])
233 AC_DEFINE_UNQUOTED(__libelf_u64_t, [unsigned $libelf_cv_int64])
236 AC_CACHE_CHECK([for 32-bit integer], libelf_cv_int32, [
237 if test "$ac_cv_sizeof_int" = 4; then
238 libelf_cv_int32='int'
239 elif test "$ac_cv_sizeof_long" = 4; then
240 libelf_cv_int32='long'
244 if test "$libelf_cv_int32" = no; then
245 AC_MSG_ERROR([neither int nor long is 32-bit])
247 AC_DEFINE_UNQUOTED(__libelf_i32_t, [$libelf_cv_int32])
248 AC_DEFINE_UNQUOTED(__libelf_u32_t, [unsigned $libelf_cv_int32])
251 AC_CACHE_CHECK([for 16-bit integer], libelf_cv_int16, [
252 if test "$ac_cv_sizeof_short" = 2; then
253 libelf_cv_int16='short'
254 elif test "$ac_cv_sizeof_int" = 2; then
255 libelf_cv_int16='int'
259 if test "$libelf_cv_int16" = no; then
260 AC_MSG_ERROR([neither short nor int is 16-bit])
262 AC_DEFINE_UNQUOTED(__libelf_i16_t, [$libelf_cv_int16])
263 AC_DEFINE_UNQUOTED(__libelf_u16_t, [unsigned $libelf_cv_int16])
266 dnl Checks for library functions.
268 AC_CHECK_FUNCS(ftruncate memcmp memcpy memmove)
269 AC_REPLACE_FUNCS(memset)
270 if test "$ac_cv_func_memset" = yes; then
271 AC_DEFINE(HAVE_MEMSET)
274 AC_CACHE_CHECK([whether overlapping arrays are copied correctly],
275 libelf_cv_working_memmove,
276 [AC_TRY_RUN(changequote(<<, >>)dnl
277 <<#include "confdefs.h"
279 extern void *memmove();
282 #define memmove(d,s,n) bcopy((s),(d),(n))
286 char buf[] = "0123456789";
287 memmove(buf + 1, buf, 9);
288 if (strcmp(buf, "0012345678")) exit(1);
290 }>>, changequote([, ])dnl
291 libelf_cv_working_memmove=yes,
292 libelf_cv_working_memmove=no,
293 libelf_cv_working_memmove='maybe not')])
294 if test "$libelf_cv_working_memmove" != yes; then
295 AC_DEFINE(HAVE_BROKEN_MEMMOVE)
298 AC_CACHE_CHECK([the coffee machine], mr_cv_coffee_machine,
299 [mr_cv_coffee_machine='empty - operator may not work as expected'])
301 dnl Check for 64-bit support.
302 AC_MSG_CHECKING([whether 64-bit ELF support is sufficient])
303 AC_MSG_RESULT($libelf_64bit)
304 AC_MSG_CHECKING([whether to include 64-bit support])
305 if test "$libelf_64bit" = no; then
306 libelf_enable_64bit=no
309 [ --enable-elf64 compile in 64-bit support (default: auto)],
310 [libelf_enable_64bit="$enableval"],
311 [libelf_enable_64bit=yes])
313 AC_MSG_RESULT($libelf_enable_64bit)
314 if test "$libelf_enable_64bit" = yes; then
315 AC_DEFINE(__LIBELF64)
318 AC_MSG_CHECKING([whether versioning support is sufficient])
320 case "$libelf_enable_64bit:$libelf_cv_verdef32:$libelf_cv_verdef64" in
321 no:yes:* | yes:yes:yes)
322 if test "$libelf_cv_sun_verdef" = yes; then
323 AC_DEFINE(__LIBELF_SUN_SYMBOL_VERSIONS)
324 libelf_versioning=yes
325 elif test "$libelf_cv_gnu_verdef" = yes; then
326 AC_DEFINE(__LIBELF_GNU_SYMBOL_VERSIONS)
327 libelf_versioning=yes
330 AC_MSG_RESULT($libelf_versioning)
331 AC_MSG_CHECKING([whether to include versioning support])
332 if test "$libelf_versioning" = no; then
333 libelf_enable_versioning=no
335 AC_ARG_ENABLE(versioning,
336 [ --enable-versioning compile in versioning support (default: auto)],
337 [libelf_enable_versioning="$enableval"],
338 [libelf_enable_versioning=yes])
340 AC_MSG_RESULT($libelf_enable_versioning)
341 if test "$libelf_enable_versioning" = yes; then
342 AC_DEFINE(__LIBELF_SYMBOL_VERSIONS)
345 dnl Check for NLS support.
347 dnl this is for gmo2msg...
349 AC_CHECK_LIB(intl, gettext, [LIBINTL=-lintl])
352 dnl Check for shared library support.
355 dnl Check for extended ELF format support
356 AC_ARG_ENABLE(extended-format,
357 [ --enable-extended-format support extended file formats (default: no)],
358 [mr_enable_extended_format="$enableval"],
359 [mr_enable_extended_format=no])
360 if test "$mr_enable_extended_format" = yes; then
361 AC_DEFINE(ENABLE_EXTENDED_FORMAT)
364 dnl Check if ELF sanity checks should be enabled
365 AC_ARG_ENABLE(sanity-checks,
366 [ --enable-sanity-checks enable sanity checks by default (default: yes)],
367 [mr_enable_sanity_checks="$enableval"],
368 [mr_enable_sanity_checks=yes])
369 if test "$mr_enable_sanity_checks" = yes; then
370 AC_DEFINE(ENABLE_SANITY_CHECKS)
373 dnl Check for debug support.
376 AC_OUTPUT([Makefile lib/Makefile po/Makefile libelf.pc],
377 [echo timestamp > stamp-h; echo timestamp > lib/stamp-h])
379 # vi: set ts=8 sw=2 :