1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
# configure.in - Configure template for libelf.
# Copyright (C) 1995 - 2001 Michael Riepe <michael@stud.uni-hannover.de>
# 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, [<elf.h>], [Define to `<elf.h>' or `<sys/elf.h>' if one of them is present.])
elif test "$ac_cv_header_sys_elf_h" = yes; then
AC_DEFINE(__LIBELF_HEADER_ELF_H, [<sys/elf.h>], [Define to `<elf.h>' or `<sys/elf.h>' if one of them is present.])
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)],
[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 <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],
[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 <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, 1, [Define if struct nlist is declared in <elf.h> or <sys/elf.h>.])
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 <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_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 :
|