|
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 |
|
19 # @(#) $Id: configure.in,v 1.40 2007/09/07 12:07:59 michael Exp $ |
|
20 |
|
21 AC_INIT(VERSION) |
|
22 AC_CONFIG_HEADER(config.h lib/sys_elf.h) |
|
23 |
|
24 AC_PREREQ(2.13) |
|
25 |
|
26 mr_PACKAGE(libelf) |
|
27 |
|
28 dnl NOTE: there must be at least one .po file! |
|
29 ALL_LINGUAS=`cd $srcdir/po && echo *.po | sed 's/\.po//g'` |
|
30 |
|
31 dnl Assuming all arguments have already been processed... |
|
32 set `echo $VERSION | sed 's/\./ /g'` |
|
33 MAJOR=${1-1} |
|
34 MINOR=${2-0} |
|
35 PATCH=${3-0} |
|
36 AC_SUBST(MAJOR) |
|
37 |
|
38 dnl Checks for programs. |
|
39 AC_PROG_MAKE_SET |
|
40 AC_PROG_CC |
|
41 AC_PROG_CPP |
|
42 AC_PROG_INSTALL |
|
43 AC_PROG_RANLIB |
|
44 AC_PROG_LN_S |
|
45 |
|
46 dnl Checks for libraries. |
|
47 |
|
48 dnl Checks for header files. |
|
49 AC_HEADER_STDC |
|
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, [ |
|
53 AC_TRY_COMPILE( |
|
54 [#if HAVE_ELF_H |
|
55 #include <elf.h> |
|
56 #elif HAVE_SYS_ELF_H |
|
57 #include <sys/elf.h> |
|
58 #endif], |
|
59 [Elf32_Ehdr dummy], |
|
60 [libelf_cv_elf_h_works=yes], |
|
61 [libelf_cv_elf_h_works=no]) |
|
62 ]) |
|
63 if test "$libelf_cv_elf_h_works" = no; then |
|
64 ac_cv_header_elf_h=no |
|
65 ac_cv_header_sys_elf_h=no |
|
66 fi |
|
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>]) |
|
71 fi |
|
72 |
|
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>]) |
|
75 AC_ARG_ENABLE(compat, |
|
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 |
|
79 then DO_COMPAT=no |
|
80 else DO_COMPAT=yes |
|
81 fi]) |
|
82 AC_MSG_RESULT($DO_COMPAT) |
|
83 AC_SUBST(DO_COMPAT) |
|
84 |
|
85 dnl Checks for typedefs, structures, and compiler characteristics. |
|
86 AC_C_CONST |
|
87 AC_TYPE_OFF_T |
|
88 AC_TYPE_SIZE_T |
|
89 |
|
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) |
|
94 # Windows port |
|
95 AC_CHECK_SIZEOF(__int64, 0) |
|
96 |
|
97 if test "$ac_cv_header_elf_h" = yes \ |
|
98 || test "$ac_cv_header_sys_elf_h" = yes; then |
|
99 |
|
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]) |
|
116 fi |
|
117 |
|
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) |
|
125 fi |
|
126 |
|
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], |
|
130 [Elf64_Ehdr x], |
|
131 [libelf_cv_struct_elf64_ehdr=yes], |
|
132 [libelf_cv_struct_elf64_ehdr=no])) |
|
133 |
|
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], |
|
137 [Elf64_Addr x], |
|
138 [libelf_cv_type_elf64_addr=yes], |
|
139 [libelf_cv_type_elf64_addr=no])) |
|
140 |
|
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]))) |
|
150 |
|
151 case "$libelf_cv_struct_elf64_ehdr:\ |
|
152 $libelf_cv_type_elf64_addr:\ |
|
153 $libelf_cv_struct_elf64_rel" in |
|
154 yes:yes:yes) |
|
155 libelf_64bit=yes;; |
|
156 yes:yes:irix) |
|
157 AC_DEFINE(__LIBELF64_IRIX) |
|
158 libelf_64bit=yes;; |
|
159 yes:no:yes) |
|
160 AC_DEFINE(__LIBELF64_LINUX) |
|
161 libelf_64bit=yes;; |
|
162 *) |
|
163 libelf_64bit=no;; |
|
164 esac |
|
165 |
|
166 # Check for symbol versioning definitions |
|
167 AC_CACHE_CHECK([for Elf32_Verdef], libelf_cv_verdef32, |
|
168 AC_TRY_COMPILE( |
|
169 [#include __LIBELF_HEADER_ELF_H |
|
170 #if __LIBELF_NEED_LINK_H |
|
171 #include <link.h> /* Solaris wants this */ |
|
172 #endif], |
|
173 [struct { |
|
174 Elf32_Verdef vd; |
|
175 Elf32_Verdaux vda; |
|
176 Elf32_Verneed vn; |
|
177 Elf32_Vernaux vna; |
|
178 } x], |
|
179 [libelf_cv_verdef32=yes], |
|
180 [libelf_cv_verdef32=no])) |
|
181 |
|
182 AC_CACHE_CHECK([for Elf64_Verdef], libelf_cv_verdef64, |
|
183 AC_TRY_COMPILE( |
|
184 [#include __LIBELF_HEADER_ELF_H |
|
185 #if __LIBELF_NEED_LINK_H |
|
186 #include <link.h> /* Solaris wants this */ |
|
187 #endif], |
|
188 [struct { |
|
189 Elf64_Verdef vd; |
|
190 Elf64_Verdaux vda; |
|
191 Elf64_Verneed vn; |
|
192 Elf64_Vernaux vna; |
|
193 } x], |
|
194 [libelf_cv_verdef64=yes], |
|
195 [libelf_cv_verdef64=no])) |
|
196 |
|
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])) |
|
202 |
|
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])) |
|
208 else |
|
209 # lib/elf_repl.h supports 64-bit |
|
210 libelf_64bit=yes |
|
211 |
|
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 |
|
217 fi |
|
218 |
|
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' |
|
226 else |
|
227 libelf_cv_int64=no |
|
228 fi]) |
|
229 if test "$libelf_cv_int64" = no; then |
|
230 libelf_64bit=no |
|
231 else |
|
232 AC_DEFINE_UNQUOTED(__libelf_i64_t, [$libelf_cv_int64]) |
|
233 AC_DEFINE_UNQUOTED(__libelf_u64_t, [unsigned $libelf_cv_int64]) |
|
234 fi |
|
235 |
|
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' |
|
241 else |
|
242 libelf_cv_int32=no |
|
243 fi]) |
|
244 if test "$libelf_cv_int32" = no; then |
|
245 AC_MSG_ERROR([neither int nor long is 32-bit]) |
|
246 else |
|
247 AC_DEFINE_UNQUOTED(__libelf_i32_t, [$libelf_cv_int32]) |
|
248 AC_DEFINE_UNQUOTED(__libelf_u32_t, [unsigned $libelf_cv_int32]) |
|
249 fi |
|
250 |
|
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' |
|
256 else |
|
257 libelf_cv_int16=no |
|
258 fi]) |
|
259 if test "$libelf_cv_int16" = no; then |
|
260 AC_MSG_ERROR([neither short nor int is 16-bit]) |
|
261 else |
|
262 AC_DEFINE_UNQUOTED(__libelf_i16_t, [$libelf_cv_int16]) |
|
263 AC_DEFINE_UNQUOTED(__libelf_u16_t, [unsigned $libelf_cv_int16]) |
|
264 fi |
|
265 |
|
266 dnl Checks for library functions. |
|
267 AC_FUNC_MMAP |
|
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) |
|
272 fi |
|
273 |
|
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" |
|
278 #if HAVE_MEMMOVE |
|
279 extern void *memmove(); |
|
280 #else |
|
281 extern void bcopy(); |
|
282 #define memmove(d,s,n) bcopy((s),(d),(n)) |
|
283 #endif |
|
284 extern int strcmp(); |
|
285 main() { |
|
286 char buf[] = "0123456789"; |
|
287 memmove(buf + 1, buf, 9); |
|
288 if (strcmp(buf, "0012345678")) exit(1); |
|
289 exit(0); |
|
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) |
|
296 fi |
|
297 |
|
298 AC_CACHE_CHECK([the coffee machine], mr_cv_coffee_machine, |
|
299 [mr_cv_coffee_machine='empty - operator may not work as expected']) |
|
300 |
|
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 |
|
307 else |
|
308 AC_ARG_ENABLE(elf64, |
|
309 [ --enable-elf64 compile in 64-bit support (default: auto)], |
|
310 [libelf_enable_64bit="$enableval"], |
|
311 [libelf_enable_64bit=yes]) |
|
312 fi |
|
313 AC_MSG_RESULT($libelf_enable_64bit) |
|
314 if test "$libelf_enable_64bit" = yes; then |
|
315 AC_DEFINE(__LIBELF64) |
|
316 fi |
|
317 |
|
318 AC_MSG_CHECKING([whether versioning support is sufficient]) |
|
319 libelf_versioning=no |
|
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 |
|
328 fi;; |
|
329 esac |
|
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 |
|
334 else |
|
335 AC_ARG_ENABLE(versioning, |
|
336 [ --enable-versioning compile in versioning support (default: auto)], |
|
337 [libelf_enable_versioning="$enableval"], |
|
338 [libelf_enable_versioning=yes]) |
|
339 fi |
|
340 AC_MSG_RESULT($libelf_enable_versioning) |
|
341 if test "$libelf_enable_versioning" = yes; then |
|
342 AC_DEFINE(__LIBELF_SYMBOL_VERSIONS) |
|
343 fi |
|
344 |
|
345 dnl Check for NLS support. |
|
346 mr_ENABLE_NLS |
|
347 dnl this is for gmo2msg... |
|
348 LIBINTL= |
|
349 AC_CHECK_LIB(intl, gettext, [LIBINTL=-lintl]) |
|
350 AC_SUBST(LIBINTL) |
|
351 |
|
352 dnl Check for shared library support. |
|
353 mr_ENABLE_SHARED |
|
354 |
|
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) |
|
362 fi |
|
363 |
|
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) |
|
371 fi |
|
372 |
|
373 dnl Check for debug support. |
|
374 mr_ENABLE_DEBUG |
|
375 |
|
376 AC_OUTPUT([Makefile lib/Makefile po/Makefile libelf.pc], |
|
377 [echo timestamp > stamp-h; echo timestamp > lib/stamp-h]) |
|
378 |
|
379 # vi: set ts=8 sw=2 : |