configure.in 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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
  4. #
  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.
  9. #
  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.
  14. #
  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
  18. # @(#) $Id: configure.in,v 1.41 2008/05/23 08:17:56 michael Exp $
  19. AC_INIT(VERSION)
  20. AC_CONFIG_HEADER(config.h lib/sys_elf.h)
  21. AC_PREREQ(2.13)
  22. mr_PACKAGE(libelf)
  23. dnl NOTE: there must be at least one .po file!
  24. ALL_LINGUAS=`cd $srcdir/po && echo *.po | sed 's/\.po//g'`
  25. dnl Assuming all arguments have already been processed...
  26. set `echo $VERSION | sed 's/\./ /g'`
  27. MAJOR=${1-1}
  28. MINOR=${2-0}
  29. PATCH=${3-0}
  30. AC_SUBST(MAJOR)
  31. dnl Checks for programs.
  32. AC_PROG_MAKE_SET
  33. AC_PROG_CC
  34. AC_PROG_CPP
  35. AC_PROG_INSTALL
  36. AC_PROG_RANLIB
  37. AC_PROG_LN_S
  38. dnl Checks for libraries.
  39. dnl Checks for header files.
  40. AC_HEADER_STDC
  41. AC_CHECK_HEADERS(unistd.h stdint.h fcntl.h)
  42. AC_CHECK_HEADERS(elf.h sys/elf.h link.h sys/link.h)
  43. AC_CACHE_CHECK([if ${CC} can compile elf.h], libelf_cv_elf_h_works, [
  44. AC_TRY_COMPILE(
  45. [#if HAVE_ELF_H
  46. #include <elf.h>
  47. #elif HAVE_SYS_ELF_H
  48. #include <sys/elf.h>
  49. #endif],
  50. [Elf32_Ehdr dummy],
  51. [libelf_cv_elf_h_works=yes],
  52. [libelf_cv_elf_h_works=no])
  53. ])
  54. if test "$libelf_cv_elf_h_works" = no; then
  55. ac_cv_header_elf_h=no
  56. ac_cv_header_sys_elf_h=no
  57. fi
  58. if test "$ac_cv_header_elf_h" = yes; then
  59. AC_DEFINE(__LIBELF_HEADER_ELF_H, [<elf.h>])
  60. elif test "$ac_cv_header_sys_elf_h" = yes; then
  61. AC_DEFINE(__LIBELF_HEADER_ELF_H, [<sys/elf.h>])
  62. fi
  63. AC_CHECK_HEADERS(ar.h libelf.h nlist.h gelf.h)
  64. AC_MSG_CHECKING([whether to install <libelf.h>, <nlist.h> and <gelf.h>])
  65. AC_ARG_ENABLE(compat,
  66. [ --enable-compat install <libelf.h>, <nlist.h> and <gelf.h> (default: auto)],
  67. [DO_COMPAT="$enableval"],
  68. [if test "$ac_cv_header_libelf_h$ac_cv_header_nlist_h$ac_cv_header_gelf_h" = yesyesyes
  69. then DO_COMPAT=no
  70. else DO_COMPAT=yes
  71. fi])
  72. AC_MSG_RESULT($DO_COMPAT)
  73. AC_SUBST(DO_COMPAT)
  74. dnl Checks for typedefs, structures, and compiler characteristics.
  75. AC_C_CONST
  76. AC_TYPE_OFF_T
  77. AC_TYPE_SIZE_T
  78. AC_CHECK_SIZEOF(short,2)
  79. AC_CHECK_SIZEOF(int,4)
  80. AC_CHECK_SIZEOF(long,4)
  81. AC_CHECK_SIZEOF(long long,0)
  82. # Windows port
  83. AC_CHECK_SIZEOF(__int64, 0)
  84. if test "$ac_cv_header_elf_h" = yes \
  85. || test "$ac_cv_header_sys_elf_h" = yes; then
  86. # Slowaris declares Elf32_Dyn in <link.h>.
  87. # QNX declares Elf32_Dyn in <sys/link.h>.
  88. AC_CACHE_CHECK([for struct Elf32_Dyn], libelf_cv_struct_elf32_dyn, [
  89. AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], [Elf32_Dyn x],
  90. [libelf_cv_struct_elf32_dyn=yes],
  91. AC_TRY_COMPILE([#include <link.h>], [Elf32_Dyn x],
  92. [libelf_cv_struct_elf32_dyn=link.h],
  93. AC_TRY_COMPILE([#include <sys/link.h>], [Elf32_Dyn x],
  94. [libelf_cv_struct_elf32_dyn=sys/link.h],
  95. [libelf_cv_struct_elf32_dyn=no])))])
  96. if test "$libelf_cv_struct_elf32_dyn" = link.h; then
  97. AC_DEFINE(__LIBELF_NEED_LINK_H)
  98. elif test "$libelf_cv_struct_elf32_dyn" = sys/link.h; then
  99. AC_DEFINE(__LIBELF_NEED_SYS_LINK_H)
  100. elif test "$libelf_cv_struct_elf32_dyn" = no; then
  101. AC_MSG_ERROR([no declaration for Elf32_Dyn])
  102. fi
  103. # Linux declares struct nlist in <elf.h>.
  104. AC_CACHE_CHECK([for struct nlist in elf.h], libelf_cv_struct_nlist, [
  105. AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H], [struct nlist nl],
  106. [libelf_cv_struct_nlist=yes],
  107. [libelf_cv_struct_nlist=no])])
  108. if test "$libelf_cv_struct_nlist" = yes; then
  109. AC_DEFINE(HAVE_STRUCT_NLIST_DECLARATION)
  110. fi
  111. # Check for 64-bit data types.
  112. AC_CACHE_CHECK([for struct Elf64_Ehdr], libelf_cv_struct_elf64_ehdr,
  113. AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
  114. [Elf64_Ehdr x],
  115. [libelf_cv_struct_elf64_ehdr=yes],
  116. [libelf_cv_struct_elf64_ehdr=no]))
  117. # Linux lacks typedefs for scalar ELF64_* types.
  118. AC_CACHE_CHECK([for Elf64_Addr], libelf_cv_type_elf64_addr,
  119. AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
  120. [Elf64_Addr x],
  121. [libelf_cv_type_elf64_addr=yes],
  122. [libelf_cv_type_elf64_addr=no]))
  123. # IRIX' struct Elf64_Rel is slightly different. Ugh.
  124. AC_CACHE_CHECK([for struct Elf64_Rel], libelf_cv_struct_elf64_rel,
  125. AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
  126. [Elf64_Rel x; x.r_info = 1],
  127. [libelf_cv_struct_elf64_rel=yes],
  128. AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
  129. [Elf64_Rel x; x.r_sym = 1],
  130. [libelf_cv_struct_elf64_rel=irix],
  131. [libelf_cv_struct_elf64_rel=no])))
  132. case "$libelf_cv_struct_elf64_ehdr:\
  133. $libelf_cv_type_elf64_addr:\
  134. $libelf_cv_struct_elf64_rel" in
  135. yes:yes:yes)
  136. libelf_64bit=yes;;
  137. yes:yes:irix)
  138. AC_DEFINE(__LIBELF64_IRIX)
  139. libelf_64bit=yes;;
  140. yes:no:yes)
  141. AC_DEFINE(__LIBELF64_LINUX)
  142. libelf_64bit=yes;;
  143. *)
  144. libelf_64bit=no;;
  145. esac
  146. # Check for symbol versioning definitions
  147. AC_CACHE_CHECK([for Elf32_Verdef], libelf_cv_verdef32,
  148. AC_TRY_COMPILE(
  149. [#include __LIBELF_HEADER_ELF_H
  150. #if __LIBELF_NEED_LINK_H
  151. #include <link.h> /* Solaris wants this */
  152. #endif],
  153. [struct {
  154. Elf32_Verdef vd;
  155. Elf32_Verdaux vda;
  156. Elf32_Verneed vn;
  157. Elf32_Vernaux vna;
  158. } x],
  159. [libelf_cv_verdef32=yes],
  160. [libelf_cv_verdef32=no]))
  161. AC_CACHE_CHECK([for Elf64_Verdef], libelf_cv_verdef64,
  162. AC_TRY_COMPILE(
  163. [#include __LIBELF_HEADER_ELF_H
  164. #if __LIBELF_NEED_LINK_H
  165. #include <link.h> /* Solaris wants this */
  166. #endif],
  167. [struct {
  168. Elf64_Verdef vd;
  169. Elf64_Verdaux vda;
  170. Elf64_Verneed vn;
  171. Elf64_Vernaux vna;
  172. } x],
  173. [libelf_cv_verdef64=yes],
  174. [libelf_cv_verdef64=no]))
  175. AC_CACHE_CHECK([for SHT_SUNW_verdef], libelf_cv_sun_verdef,
  176. AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
  177. [Elf32_Word x = SHT_SUNW_verdef + SHT_SUNW_verneed + SHT_SUNW_versym],
  178. [libelf_cv_sun_verdef=yes],
  179. [libelf_cv_sun_verdef=no]))
  180. AC_CACHE_CHECK([for SHT_GNU_verdef], libelf_cv_gnu_verdef,
  181. AC_TRY_COMPILE([#include __LIBELF_HEADER_ELF_H],
  182. [Elf32_Word x = SHT_GNU_verdef + SHT_GNU_verneed + SHT_GNU_versym],
  183. [libelf_cv_gnu_verdef=yes],
  184. [libelf_cv_gnu_verdef=no]))
  185. else
  186. # lib/elf_repl.h supports 64-bit
  187. libelf_64bit=yes
  188. # lib/elf_repl.h supports symbol versioning
  189. libelf_cv_verdef32=yes
  190. libelf_cv_verdef64=yes
  191. libelf_cv_sun_verdef=yes
  192. libelf_cv_gnu_verdef=yes
  193. fi
  194. AC_CACHE_CHECK([for 64-bit integer], libelf_cv_int64, [
  195. if test "$ac_cv_sizeof_long" = 8; then
  196. libelf_cv_int64='long'
  197. elif test "$ac_cv_sizeof___int64" = 8; then
  198. libelf_cv_int64='__int64'
  199. elif test "$ac_cv_sizeof_long_long" = 8; then
  200. libelf_cv_int64='long long'
  201. else
  202. libelf_cv_int64=no
  203. fi])
  204. if test "$libelf_cv_int64" = no; then
  205. libelf_64bit=no
  206. else
  207. AC_DEFINE_UNQUOTED(__libelf_i64_t, [$libelf_cv_int64])
  208. AC_DEFINE_UNQUOTED(__libelf_u64_t, [unsigned $libelf_cv_int64])
  209. fi
  210. AC_CACHE_CHECK([for 32-bit integer], libelf_cv_int32, [
  211. if test "$ac_cv_sizeof_int" = 4; then
  212. libelf_cv_int32='int'
  213. elif test "$ac_cv_sizeof_long" = 4; then
  214. libelf_cv_int32='long'
  215. else
  216. libelf_cv_int32=no
  217. fi])
  218. if test "$libelf_cv_int32" = no; then
  219. AC_MSG_ERROR([neither int nor long is 32-bit])
  220. else
  221. AC_DEFINE_UNQUOTED(__libelf_i32_t, [$libelf_cv_int32])
  222. AC_DEFINE_UNQUOTED(__libelf_u32_t, [unsigned $libelf_cv_int32])
  223. fi
  224. AC_CACHE_CHECK([for 16-bit integer], libelf_cv_int16, [
  225. if test "$ac_cv_sizeof_short" = 2; then
  226. libelf_cv_int16='short'
  227. elif test "$ac_cv_sizeof_int" = 2; then
  228. libelf_cv_int16='int'
  229. else
  230. libelf_cv_int16=no
  231. fi])
  232. if test "$libelf_cv_int16" = no; then
  233. AC_MSG_ERROR([neither short nor int is 16-bit])
  234. else
  235. AC_DEFINE_UNQUOTED(__libelf_i16_t, [$libelf_cv_int16])
  236. AC_DEFINE_UNQUOTED(__libelf_u16_t, [unsigned $libelf_cv_int16])
  237. fi
  238. dnl Checks for library functions.
  239. AC_FUNC_MMAP
  240. AC_CHECK_FUNCS(ftruncate memcmp memcpy memmove)
  241. AC_REPLACE_FUNCS(memset)
  242. if test "$ac_cv_func_memset" = yes; then
  243. AC_DEFINE(HAVE_MEMSET)
  244. fi
  245. AC_CACHE_CHECK([whether overlapping arrays are copied correctly],
  246. libelf_cv_working_memmove,
  247. [AC_TRY_RUN(changequote(<<, >>)dnl
  248. <<#include "confdefs.h"
  249. #if HAVE_MEMMOVE
  250. extern void *memmove();
  251. #else
  252. extern void bcopy();
  253. #define memmove(d,s,n) bcopy((s),(d),(n))
  254. #endif
  255. extern int strcmp();
  256. main() {
  257. char buf[] = "0123456789";
  258. memmove(buf + 1, buf, 9);
  259. if (strcmp(buf, "0012345678")) exit(1);
  260. exit(0);
  261. }>>, changequote([, ])dnl
  262. libelf_cv_working_memmove=yes,
  263. libelf_cv_working_memmove=no,
  264. libelf_cv_working_memmove='maybe not')])
  265. if test "$libelf_cv_working_memmove" != yes; then
  266. AC_DEFINE(HAVE_BROKEN_MEMMOVE)
  267. fi
  268. AC_CACHE_CHECK([the coffee machine], mr_cv_coffee_machine,
  269. [mr_cv_coffee_machine='empty - operator may not work as expected'])
  270. dnl Check for 64-bit support.
  271. AC_MSG_CHECKING([whether 64-bit ELF support is sufficient])
  272. AC_MSG_RESULT($libelf_64bit)
  273. AC_MSG_CHECKING([whether to include 64-bit support])
  274. if test "$libelf_64bit" = no; then
  275. libelf_enable_64bit=no
  276. else
  277. AC_ARG_ENABLE(elf64,
  278. [ --enable-elf64 compile in 64-bit support (default: auto)],
  279. [libelf_enable_64bit="$enableval"],
  280. [libelf_enable_64bit=yes])
  281. fi
  282. AC_MSG_RESULT($libelf_enable_64bit)
  283. if test "$libelf_enable_64bit" = yes; then
  284. AC_DEFINE(__LIBELF64)
  285. fi
  286. AC_MSG_CHECKING([whether versioning support is sufficient])
  287. libelf_versioning=no
  288. case "$libelf_enable_64bit:$libelf_cv_verdef32:$libelf_cv_verdef64" in
  289. no:yes:* | yes:yes:yes)
  290. if test "$libelf_cv_sun_verdef" = yes; then
  291. AC_DEFINE(__LIBELF_SUN_SYMBOL_VERSIONS)
  292. libelf_versioning=yes
  293. elif test "$libelf_cv_gnu_verdef" = yes; then
  294. AC_DEFINE(__LIBELF_GNU_SYMBOL_VERSIONS)
  295. libelf_versioning=yes
  296. fi;;
  297. esac
  298. AC_MSG_RESULT($libelf_versioning)
  299. AC_MSG_CHECKING([whether to include versioning support])
  300. if test "$libelf_versioning" = no; then
  301. libelf_enable_versioning=no
  302. else
  303. AC_ARG_ENABLE(versioning,
  304. [ --enable-versioning compile in versioning support (default: auto)],
  305. [libelf_enable_versioning="$enableval"],
  306. [libelf_enable_versioning=yes])
  307. fi
  308. AC_MSG_RESULT($libelf_enable_versioning)
  309. if test "$libelf_enable_versioning" = yes; then
  310. AC_DEFINE(__LIBELF_SYMBOL_VERSIONS)
  311. fi
  312. dnl Check for NLS support.
  313. mr_ENABLE_NLS
  314. dnl this is for gmo2msg...
  315. LIBINTL=
  316. AC_CHECK_LIB(intl, gettext, [LIBINTL=-lintl])
  317. AC_SUBST(LIBINTL)
  318. dnl Check for shared library support.
  319. mr_ENABLE_SHARED
  320. dnl Check for extended ELF format support
  321. AC_ARG_ENABLE(extended-format,
  322. [ --enable-extended-format support extended file formats (default: no)],
  323. [mr_enable_extended_format="$enableval"],
  324. [mr_enable_extended_format=no])
  325. if test "$mr_enable_extended_format" = yes; then
  326. AC_DEFINE(ENABLE_EXTENDED_FORMAT)
  327. fi
  328. dnl Check if ELF sanity checks should be enabled
  329. AC_ARG_ENABLE(sanity-checks,
  330. [ --enable-sanity-checks enable sanity checks by default (default: yes)],
  331. [mr_enable_sanity_checks="$enableval"],
  332. [mr_enable_sanity_checks=yes])
  333. if test "$mr_enable_sanity_checks" = yes; then
  334. AC_DEFINE(ENABLE_SANITY_CHECKS)
  335. fi
  336. dnl Check for debug support.
  337. mr_ENABLE_DEBUG
  338. AC_OUTPUT([Makefile lib/Makefile po/Makefile libelf.pc],
  339. [echo timestamp > stamp-h; echo timestamp > lib/stamp-h])
  340. # vi: set ts=8 sw=2 :