diff --git a/libelf/configure.ac b/libelf/configure.ac new file mode 100755 index 000000000..5da5d2464 --- /dev/null +++ b/libelf/configure.ac @@ -0,0 +1,358 @@ +# configure.in - Configure template for libelf. +# Copyright (C) 1995 - 2001 Michael Riepe +# Process this file with autoconf to produce a configure script. + +# @(#) Id: configure.in,v 1.22 2001/10/15 21:36:40 michael Exp + +AC_INIT(libelf, 0.8.2) +AC_CANONICAL_TARGET +AM_INIT_AUTOMAKE +AC_CONFIG_SRCDIR([VERSION]) +AM_CONFIG_HEADER(config.h lib/sys_elf.h) + +AM_DISABLE_SHARED + +AC_PREREQ(2.12) + +VERSION=`cat $srcdir/VERSION` + +dnl NOTE: there must be at least one .po file! +ALL_LINGUAS=`cd $srcdir/po && echo *.po | sed 's/\.po//g'` + +dnl Assuming all arguments have already been processed... +set `echo $VERSION | sed 's/\./ /g'` +MAJOR=${1-1} +MINOR=${2-0} +PATCH=${3-0} +AC_SUBST(MAJOR) + +dnl Checks for programs. +AC_PROG_MAKE_SET +AC_PROG_CC +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_LIBTOOL +AC_PROG_LN_S + +dnl Checks for libraries. + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(unistd.h fcntl.h elf.h sys/elf.h link.h sys/link.h) +if test "$ac_cv_header_elf_h" = yes; then + AC_DEFINE(__LIBELF_HEADER_ELF_H, [], [Define to `' or `' if one of them is present.]) +elif test "$ac_cv_header_sys_elf_h" = yes; then + AC_DEFINE(__LIBELF_HEADER_ELF_H, [], [Define to `' or `' if one of them is present.]) +fi + +AC_CHECK_HEADERS(ar.h libelf.h nlist.h gelf.h) +AC_MSG_CHECKING([whether to install , and ]) +AC_ARG_ENABLE(compat, + [ --enable-compat install , and (default: auto)], + [libelf_enable_compat="$enableval"], + [AC_SUBST(DO_COMPAT) + if test "$ac_cv_header_libelf_h$ac_cv_header_nlist_h$ac_cv_header_gelf_h" = yesyesyes + then DO_COMPAT=no + else DO_COMPAT=yes + fi]) +AC_MSG_RESULT($DO_COMPAT) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_OFF_T +AC_TYPE_SIZE_T + +AC_CHECK_SIZEOF(short,2) +AC_CHECK_SIZEOF(int,4) +AC_CHECK_SIZEOF(long,4) +AC_CHECK_SIZEOF(long long,0) + +if test "$ac_cv_header_elf_h" = yes \ +|| test "$ac_cv_header_sys_elf_h" = yes; then + + # Slowaris declares Elf32_Dyn in . + AC_CACHE_CHECK([for struct Elf32_Dyn], libelf_cv_struct_elf32_dyn, [ + AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], [Elf32_Dyn x], + [libelf_cv_struct_elf32_dyn=yes], + AC_TRY_COMPILE([#include ], [Elf32_Dyn x], + [libelf_cv_struct_elf32_dyn=link.h], + [libelf_cv_struct_elf32_dyn=no]))]) + if test "$libelf_cv_struct_elf32_dyn" = link.h; then + AC_DEFINE(__LIBELF_NEED_LINK_H, 1, [Define if Elf32_Dyn is declared in .]) + elif test "$libelf_cv_struct_elf32_dyn" = no; then + AC_MSG_ERROR([no declaration for Elf32_Dyn]) + fi + + # Linux declares struct nlist in . + AC_CACHE_CHECK([for struct nlist in elf.h], libelf_cv_struct_nlist, [ + AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], [struct nlist nl], + [libelf_cv_struct_nlist=yes], + [libelf_cv_struct_nlist=no])]) + if test "$libelf_cv_struct_nlist" = yes; then + AC_DEFINE(HAVE_STRUCT_NLIST_DECLARATION, 1, [Define if struct nlist is declared in or .]) + fi + + # Check for 64-bit data types. + AC_CACHE_CHECK([for struct Elf64_Ehdr], libelf_cv_struct_elf64_ehdr, + AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], + [Elf64_Ehdr x], + [libelf_cv_struct_elf64_ehdr=yes], + [libelf_cv_struct_elf64_ehdr=no])) + + # Linux lacks typedefs for scalar ELF64_* types. + AC_CACHE_CHECK([for Elf64_Addr], libelf_cv_type_elf64_addr, + AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], + [Elf64_Addr x], + [libelf_cv_type_elf64_addr=yes], + [libelf_cv_type_elf64_addr=no])) + + # IRIX' struct Elf64_Rel is slightly different. Ugh. + AC_CACHE_CHECK([for struct Elf64_Rel], libelf_cv_struct_elf64_rel, + AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], + [Elf64_Rel x; x.r_info = 1], + [libelf_cv_struct_elf64_rel=yes], + AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], + [Elf64_Rel x; x.r_sym = 1], + [libelf_cv_struct_elf64_rel=irix], + [libelf_cv_struct_elf64_rel=no]))) + + case "$libelf_cv_struct_elf64_ehdr:\ +$libelf_cv_type_elf64_addr:\ +$libelf_cv_struct_elf64_rel" in + yes:yes:yes) + libelf_64bit=yes;; + yes:yes:irix) + AC_DEFINE(__LIBELF64_IRIX, 1, [Define if you want 64-bit support, and are running IRIX.]) + libelf_64bit=yes;; + yes:no:yes) + AC_DEFINE(__LIBELF64_LINUX, 1, [Define if you want 64-bit support, and are running Linux.]) + libelf_64bit=yes;; + *) + libelf_64bit=no;; + esac + + # Check for symbol versioning definitions + AC_CACHE_CHECK([for Elf32_Verdef], libelf_cv_verdef32, + AC_TRY_COMPILE( + [#include __LIBELF_HEADER_ELF_H + #if __LIBELF_NEED_LINK_H + #include /* Solaris wants this */ + #endif], + [struct { + Elf32_Verdef vd; + Elf32_Verdaux vda; + Elf32_Verneed vn; + Elf32_Vernaux vna; + } x], + [libelf_cv_verdef32=yes], + [libelf_cv_verdef32=no])) + + AC_CACHE_CHECK([for Elf64_Verdef], libelf_cv_verdef64, + AC_TRY_COMPILE( + [#include __LIBELF_HEADER_ELF_H + #if __LIBELF_NEED_LINK_H + #include /* Solaris wants this */ + #endif], + [struct { + Elf64_Verdef vd; + Elf64_Verdaux vda; + Elf64_Verneed vn; + Elf64_Vernaux vna; + } x], + [libelf_cv_verdef64=yes], + [libelf_cv_verdef64=no])) + + AC_CACHE_CHECK([for SHT_SUNW_verdef], libelf_cv_sun_verdef, + AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], + [Elf32_Word x = SHT_SUNW_verdef + SHT_SUNW_verneed + SHT_SUNW_versym], + [libelf_cv_sun_verdef=yes], + [libelf_cv_sun_verdef=no])) + + AC_CACHE_CHECK([for SHT_GNU_verdef], libelf_cv_gnu_verdef, + AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], + [Elf32_Word x = SHT_GNU_verdef + SHT_GNU_verneed + SHT_GNU_versym], + [libelf_cv_gnu_verdef=yes], + [libelf_cv_gnu_verdef=no])) +else + # lib/elf_repl.h supports 64-bit + libelf_64bit=yes + + # lib/elf_repl.h supports symbol versioning + libelf_cv_verdef32=yes + libelf_cv_verdef64=yes + libelf_cv_sun_verdef=yes + libelf_cv_gnu_verdef=yes +fi + +AC_CACHE_CHECK([for 64-bit integer], libelf_cv_int64, [ + if test "$ac_cv_sizeof_long" = 8; then + libelf_cv_int64='long' + elif test "$ac_cv_sizeof_long_long" = 8; then + libelf_cv_int64='long long' + else + libelf_cv_int64=no + fi]) +if test "$libelf_cv_int64" = no; then + libelf_64bit=no +else + AC_DEFINE_UNQUOTED(__libelf_i64_t, [$libelf_cv_int64], [Define to a 64-bit signed integer type if one exists.]) + AC_DEFINE_UNQUOTED(__libelf_u64_t, [unsigned $libelf_cv_int64], [Define to a 64-bit unsigned integer type if one exists.]) +fi + +AC_CACHE_CHECK([for 32-bit integer], libelf_cv_int32, [ + if test "$ac_cv_sizeof_long" = 4; then + libelf_cv_int32='long' + elif test "$ac_cv_sizeof_int" = 4; then + libelf_cv_int32='int' + else + libelf_cv_int32=no + fi]) +if test "$libelf_cv_int32" = no; then + AC_MSG_ERROR([neither int nor long is 32-bit]) +else + AC_DEFINE_UNQUOTED(__libelf_i32_t, [$libelf_cv_int32], [Define to a 32-bit signed integer type if one exists.]) + AC_DEFINE_UNQUOTED(__libelf_u32_t, [unsigned $libelf_cv_int32], [Define to a 32-bit unsigned integer type if one exists.]) +fi + +AC_CACHE_CHECK([for 16-bit integer], libelf_cv_int16, [ + if test "$ac_cv_sizeof_short" = 2; then + libelf_cv_int16='short' + elif test "$ac_cv_sizeof_int" = 2; then + libelf_cv_int16='int' + else + libelf_cv_int16=no + fi]) +if test "$libelf_cv_int16" = no; then + AC_MSG_ERROR([neither short nor int is 16-bit]) +else + AC_DEFINE_UNQUOTED(__libelf_i16_t, [$libelf_cv_int16], [Define to a 16-bit signed integer type if one exists.]) + AC_DEFINE_UNQUOTED(__libelf_u16_t, [unsigned $libelf_cv_int16], [Define to a 16-bit unsigned integer type if one exists.]) +fi + +dnl Checks for library functions. +AC_FUNC_MMAP +AC_CHECK_FUNCS(ftruncate memcmp memcpy memmove) +AC_REPLACE_FUNCS(memset) +if test "$ac_cv_func_memset" = yes; then + AC_DEFINE(HAVE_MEMSET, 1, [Define if you have the memset function.]) +fi + +AC_CACHE_CHECK([whether overlapping arrays are copied correctly], + libelf_cv_working_memmove, + [AC_TRY_RUN(changequote(<<, >>)dnl +<<#include "confdefs.h" +#if HAVE_MEMMOVE +extern void *memmove(); +#else +extern void bcopy(); +#define memmove(d,s,n) bcopy((s),(d),(n)) +#endif +extern int strcmp(); +main() { + char buf[] = "0123456789"; + memmove(buf + 1, buf, 9); + if (strcmp(buf, "0012345678")) exit(1); + exit(0); +}>>, changequote([, ])dnl + libelf_cv_working_memmove=yes, + libelf_cv_working_memmove=no, + libelf_cv_working_memmove='maybe not')]) +if test "$libelf_cv_working_memmove" != yes; then + AC_DEFINE(HAVE_BROKEN_MEMMOVE, 1, [Define if memmove() does not copy overlapping arrays correctly.]) +fi + +AC_CACHE_CHECK([the coffee machine], mr_cv_coffee_machine, + [mr_cv_coffee_machine='empty - operator may not work as expected']) + +dnl Check for 64-bit support. +AC_MSG_CHECKING([whether 64-bit ELF support is sufficient]) +AC_MSG_RESULT($libelf_64bit) +AC_MSG_CHECKING([whether to include 64-bit support]) +if test "$libelf_64bit" = no; then + libelf_enable_64bit=no +else + AC_ARG_ENABLE(elf64, + [ --enable-elf64 compile in 64-bit support (default: auto)], + [libelf_enable_64bit="$enableval"], + [libelf_enable_64bit=yes]) +fi +AC_MSG_RESULT($libelf_enable_64bit) +if test "$libelf_enable_64bit" = yes; then + AC_DEFINE(__LIBELF64, 1, [Define if you want 64-bit support (and your system supports it).]) +fi + +AC_MSG_CHECKING([whether versioning support is sufficient]) +libelf_versioning=no +case "$libelf_enable_64bit:$libelf_cv_verdef32:$libelf_cv_verdef64" in + no:yes:* | yes:yes:yes) + if test "$libelf_cv_sun_verdef" = yes; then + AC_DEFINE(__LIBELF_SUN_SYMBOL_VERSIONS, 1, [Define if symbol versioning uses Sun section type (SHT_SUNW_*).]) + libelf_versioning=yes + elif test "$libelf_cv_gnu_verdef" = yes; then + AC_DEFINE(__LIBELF_GNU_SYMBOL_VERSIONS, 1, [Define if symbol versioning uses GNU section types (SHT_GNU_*).]) + libelf_versioning=yes + fi;; +esac +AC_MSG_RESULT($libelf_versioning) +AC_MSG_CHECKING([whether to include versioning support]) +if test "$libelf_versioning" = no; then + libelf_enable_versioning=no +else + AC_ARG_ENABLE(versioning, + [ --enable-versioning compile in versioning support (default: auto)], + [libelf_enable_versioning="$enableval"], + [libelf_enable_versioning=yes]) +fi +AC_MSG_RESULT($libelf_enable_versioning) +if test "$libelf_enable_versioning" = yes; then + AC_DEFINE(__LIBELF_SYMBOL_VERSIONS, 1, [Define if you want symbol versioning (and your system supports it).]) +fi + +dnl Check for NLS support. +dnl mr_ENABLE_NLS +POSUB= +AC_SUBST(POSUB) + +dnl Check for shared library support. +dnl mr_ENABLE_SHARED +AC_PATH_PROG(LD, ld, /usr/bin/ld) +DEPSHLIBS="-lc" +AC_SUBST(DEPSHLIBS) +DO_SHLIB=yes +AC_SUBST(DO_SHLIB) +PICFLAGS="-fPIC -DPIC" +AC_SUBST(PICFLAGS) +SHLIB="\$(PACKAGE).so.\$(VERSION)" +AC_SUBST(SHLIB) +SHLINK="\$(PACKAGE).so" +AC_SUBST(SHLINK) +SONAME="\$(PACKAGE).so.\$(MAJOR)" +AC_SUBST(SONAME) +LINK_SHLIB="\$(CC) -shared -Wl,-soname,\$(SONAME)" +AC_SUBST(LINK_SHLIB) +INSTALL_SHLIB="\$(INSTALL_PROGRAM)" +AC_SUBST(INSTALL_SHLIB) + +dnl Check for debug support. +dnl mr_ENABLE_DEBUG +AC_DEFINE(ENABLE_DEBUG, 0, [Define if you want to include extra debugging code.]) + +dnl Check for maintainer mode. +AC_ARG_ENABLE(maintainer-mode, + [ --enable-maintainer-mode (default: no)], + [libelf_enable_maintainer_mode="$enableval"], + [libelf_enable_maintainer_mode=no]) +if test x"$libelf_enable_maintainer_mode" = x"yes"; then +MAINT= +else +MAINT='maintainer-only-' +fi +AC_SUBST(MAINT) + +# create directory for position-independent .o files +AC_OUTPUT_COMMANDS([test -d pic || mkdir pic]) + +AC_OUTPUT([Makefile lib/Makefile po/Makefile], [echo timestamp > stamp-h +echo timestamp > lib/stamp-h]) + +# vi: set ts=8 sw=2 :