tools/elf4rom/libs/libelf-0.8.10/configure.in
author Martin Trojer <martin.trojer@nokia.com>
Fri, 15 Jan 2010 09:07:44 +0000
changeset 34 92d87f2e53c2
permissions -rwxr-xr-x
Added ELF4ROM and e32test-driver

# configure.in - Configure template for libelf.
# Process this file with autoconf to produce a configure script.
# Copyright (C) 1995 - 2006 Michael Riepe
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# @(#) $Id: configure.in,v 1.40 2007/09/07 12:07:59 michael Exp $

AC_INIT(VERSION)
AC_CONFIG_HEADER(config.h lib/sys_elf.h)

AC_PREREQ(2.13)

mr_PACKAGE(libelf)

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_RANLIB
AC_PROG_LN_S

dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h stdint.h fcntl.h)
AC_CHECK_HEADERS(elf.h sys/elf.h link.h sys/link.h)
AC_CACHE_CHECK([if ${CC} can compile elf.h], libelf_cv_elf_h_works, [
  AC_TRY_COMPILE(
    [#if HAVE_ELF_H
    #include <elf.h>
    #elif HAVE_SYS_ELF_H
    #include <sys/elf.h>
    #endif],
    [Elf32_Ehdr dummy],
    [libelf_cv_elf_h_works=yes],
    [libelf_cv_elf_h_works=no])
])
if test "$libelf_cv_elf_h_works" = no; then
  ac_cv_header_elf_h=no
  ac_cv_header_sys_elf_h=no
fi
if test "$ac_cv_header_elf_h" = yes; then
  AC_DEFINE(__LIBELF_HEADER_ELF_H, [<elf.h>])
elif test "$ac_cv_header_sys_elf_h" = yes; then
  AC_DEFINE(__LIBELF_HEADER_ELF_H, [<sys/elf.h>])
fi

AC_CHECK_HEADERS(ar.h libelf.h nlist.h gelf.h)
AC_MSG_CHECKING([whether to install <libelf.h>, <nlist.h> and <gelf.h>])
AC_ARG_ENABLE(compat,
  [  --enable-compat         install <libelf.h>, <nlist.h> and <gelf.h> (default: auto)],
  [DO_COMPAT="$enableval"],
  [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)
AC_SUBST(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)
# Windows port
AC_CHECK_SIZEOF(__int64, 0)

if test "$ac_cv_header_elf_h" = yes \
|| test "$ac_cv_header_sys_elf_h" = yes; then

  # Slowaris declares Elf32_Dyn in <link.h>.
  # QNX declares Elf32_Dyn in <sys/link.h>.
  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 <link.h>], [Elf32_Dyn x],
	[libelf_cv_struct_elf32_dyn=link.h],
	AC_TRY_COMPILE([#include <sys/link.h>], [Elf32_Dyn x],
	  [libelf_cv_struct_elf32_dyn=sys/link.h],
	  [libelf_cv_struct_elf32_dyn=no])))])
  if test "$libelf_cv_struct_elf32_dyn" = link.h; then
    AC_DEFINE(__LIBELF_NEED_LINK_H)
  elif test "$libelf_cv_struct_elf32_dyn" = sys/link.h; then
    AC_DEFINE(__LIBELF_NEED_SYS_LINK_H)
  elif test "$libelf_cv_struct_elf32_dyn" = no; then
    AC_MSG_ERROR([no declaration for Elf32_Dyn])
  fi

  # Linux declares struct nlist in <elf.h>.
  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)
  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)
      libelf_64bit=yes;;
    yes:no:yes)
      AC_DEFINE(__LIBELF64_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 <link.h>	/* 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 <link.h>	/* 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___int64" = 8; then
    libelf_cv_int64='__int64'
  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])
  AC_DEFINE_UNQUOTED(__libelf_u64_t, [unsigned $libelf_cv_int64])
fi

AC_CACHE_CHECK([for 32-bit integer], libelf_cv_int32, [
  if test "$ac_cv_sizeof_int" = 4; then
    libelf_cv_int32='int'
  elif test "$ac_cv_sizeof_long" = 4; then
    libelf_cv_int32='long'
  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])
  AC_DEFINE_UNQUOTED(__libelf_u32_t, [unsigned $libelf_cv_int32])
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])
  AC_DEFINE_UNQUOTED(__libelf_u16_t, [unsigned $libelf_cv_int16])
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)
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)
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)
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)
      libelf_versioning=yes
    elif test "$libelf_cv_gnu_verdef" = yes; then
      AC_DEFINE(__LIBELF_GNU_SYMBOL_VERSIONS)
      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)
fi

dnl Check for NLS support.
mr_ENABLE_NLS
dnl this is for gmo2msg...
LIBINTL=
AC_CHECK_LIB(intl, gettext, [LIBINTL=-lintl])
AC_SUBST(LIBINTL)

dnl Check for shared library support.
mr_ENABLE_SHARED

dnl Check for extended ELF format support
AC_ARG_ENABLE(extended-format,
  [  --enable-extended-format    support extended file formats (default: no)],
  [mr_enable_extended_format="$enableval"],
  [mr_enable_extended_format=no])
if test "$mr_enable_extended_format" = yes; then
  AC_DEFINE(ENABLE_EXTENDED_FORMAT)
fi

dnl Check if ELF sanity checks should be enabled
AC_ARG_ENABLE(sanity-checks,
  [  --enable-sanity-checks      enable sanity checks by default (default: yes)],
  [mr_enable_sanity_checks="$enableval"],
  [mr_enable_sanity_checks=yes])
if test "$mr_enable_sanity_checks" = yes; then
  AC_DEFINE(ENABLE_SANITY_CHECKS)
fi

dnl Check for debug support.
mr_ENABLE_DEBUG

AC_OUTPUT([Makefile lib/Makefile po/Makefile libelf.pc],
  [echo timestamp > stamp-h; echo timestamp > lib/stamp-h])

# vi: set ts=8 sw=2 :