-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconfigure.ac
More file actions
334 lines (300 loc) · 8.78 KB
/
configure.ac
File metadata and controls
334 lines (300 loc) · 8.78 KB
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
###Copyright (C) 2018 Vincent Torri <vincent dot torri at gmail dot com>
###Derived from Torri's work, but this is by David Anderson
###This code is public domain and can be freely used or copied.
# dnl defines the version name of the programs
### to match next libdwarf release
m4_define([v_maj], [2])
m4_define([v_min], [3])
m4_define([v_mic], [1])
m4_define([v_ver], [v_maj.v_min.v_mic])
m4_define([v_rel], [])
m4_define([lt_cur], [m4_eval(v_maj + v_min)])
m4_define([lt_rev], [v_mic])
m4_define([lt_age], [v_min])
AC_PREREQ([2.52])
### 2nd arg to AC_INIT is the version 'number'.
AC_INIT([readelfobj], [v_ver], [libdwarf -at- linuxmail -dot- org])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.6 dist-xz])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
LT_INIT([win32-dll disable-shared static])
version_info="lt_cur:lt_rev:lt_age"
release_info="v_rel"
AC_SUBST([version_info])
AC_SUBST([release_info])
AC_PROG_CC
### MacOS does not have/use malloc.h
AC_CHECK_HEADERS([unistd.h elf.h malloc.h stddef.h stdint.h])
### for use in casts to uint to avoid 32bit warnings.
### Also needed by C++ cstdint
AC_TYPE_UINTPTR_T
AC_TYPE_INTPTR_T
### Now we know uintptr_t is either in stdint.h or
### is defined in config.h by configure.
AC_ARG_ENABLE([wall],
[AS_HELP_STRING([--enable-wall],
[enable -Wall and other options @<:@default=no@:>@])],
[
AS_IF(
[test "x${enableval}" = "xyes"],
[enable_wall="yes"],
[enable_wall="no"])
],
[enable_wall="no"])
AS_IF(
[ test "x$enable_wall" = "xyes" ],
[
cxx_compiler_flags="-Wall -Wextra -Wpointer-arith -Wmissing-declarations -Wcomment -Wformat -Wpedantic -Wuninitialized -Wshadow -Wno-long-long -Werror"
c_compiler_flags="${cxx_compiler_flags} -Wmissing-prototypes -Wdeclaration-after-statement -Wbad-function-cast -Wmissing-parameter-type -Wnested-externs -Werror"
]
,
[
c_compiler_flags=""
cxx_compiler_flags=""
]
)
AC_ARG_ENABLE([decompression],
[AS_HELP_STRING([--enable-decompression],
[enable decompressing sections @<:@default=yes@:>@])],
[
AS_IF(
[test "x${enableval}" = "xno"],
[enable_decompression="no"],
[enable_decompression="yes"])
],
[enable_decompression="yes"])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_ELF_H
# include <elf.h>
#endif
]],
[[
Elf64_Rela p;
p.r_offset = 1;
]])
],
[
AC_DEFINE([HAVE_ELF64_RELA], [1], [Set to 1 if Elf64_Rela defined in elf.h.])
have_elf64_rela="yes"
],
[have_elf64_rela="no"])
AC_MSG_CHECKING([for Elf64_Rela in elf.h])
AC_MSG_RESULT([${have_elf64_rela}])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_ELF_H
# include <elf.h>
#endif
]],
[[
Elf64_Rel p;
Elf64_Sym s;
p.r_offset = 1;
s.st_name = 0;
]])
],
[ AC_DEFINE([HAVE_ELF64_REL], [1], [Set to 1 if Elf64_Rel defined.])
AC_DEFINE([HAVE_ELF64_SYM], [1], [Set to 1 if Elf64_Sym defined.])
have_elf64_rel="yes"
have_elf64_sym="yes"
],
[have_elf64_rel="no"
have_elf64_sym="no"])
AC_MSG_CHECKING([for Elf64_Rel in elf.h])
AC_MSG_RESULT([${have_elf64_rel}])
AC_C_BIGENDIAN([AC_DEFINE([WORDS_BIGENDIAN], [1], [Set to 1 if bigendian build])],,)
AC_CHECK_SIZEOF([unsigned long long])
AC_CHECK_SIZEOF([unsigned long])
# unused attribute
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[
static unsigned int foo(unsigned int x, __attribute__ ((unused)) int y){
unsigned int x2 = x + 1;
return x2;
}
int goo() {
unsigned int y = 0;
y = foo(12, y);
}
]],
[[
]])
],
[
have_unused="yes"
AC_DEFINE(
[HAVE_UNUSED_ATTRIBUTE], [1],
[Set to 1 if __attribute__ ((unused)) is available.])
],
[have_unused="no"])
AC_MSG_CHECKING([whether "unused" attribute is available])
AC_MSG_RESULT([${have_unused}])
AC_ARG_ENABLE(nonstandardprintf,AS_HELP_STRING([--enable-nonstandardprintf],
[Use a special printf format for 64bit (default is NO)]),
[ AC_DEFINE([HAVE_NONSTANDARD_PRINTF_64_FORMAT],[1],
[Define 1 if need nonstandard printf format for 64bit] )
[enable_nonstandardprintf="yes"]
],
[enable_nonstandardprintf="no"])
AS_IF(
[ test "x$enable_nonstandardprintf" = "xyes" ],
[
cxx_compiler_flags="${cxx_compiler_flags} -Wno-pedantic-ms-format"
c_compiler_flags="${c_compiler_flags} -Wno-pedantic-ms-format"
]
)
### Checks for libraries
requirements_libdwarf_pc=
AS_IF(
[test "x${enable_decompression}" = "xyes"],
[
PKG_CHECK_MODULES([ZLIB], [zlib],
[
have_zlib="yes"
have_pc_zlib="yes"
requirements_pc=zlib
],
[
have_zlib="no"
have_pc_zlib="no"
])
PKG_CHECK_MODULES([ZSTD], [libzstd],
[
have_zstd="yes"
have_pc_zstd="yes"
requirements_pc="${requirements_pc} libzstd"
],
[
have_zstd="no"
have_pc_zstd="no"
])
],
[
have_zstd="no"
have_pc_zstd="no"
have_zlib="no"
have_pc_zlib="no"
])
AC_SUBST([requirements_pc])
AS_IF(
[test "x${enable_decompression}" = "xyes"],
[
AS_IF(
[test "x${have_zlib}" = "xno"],
[AC_CHECK_HEADERS([zlib.h],
[have_zlib="yes"],
[have_zlib="no"])])
AS_IF(
[test "x${have_zstd}" = "xno"],
[AC_CHECK_HEADERS([zstd.h],
[have_zstd="yes"],
[have_zstd="no"])])
],
[
have_zstd="no"
have_pc_zstd="no"
have_zlib="no"
have_pc_zlib="no"
])
AS_IF(
[test "x${enable_decompression}" = "xyes"],
[
AS_IF(
echo "dadebug zstd ${have_pc_zstd} ${have_zstd}"
[test "x${have_pc_zstd}" = "xno" -a "x${have_zstd}" = "xyes"],
[
AC_SEARCH_LIBS(
[ZSTD_decompress], [zstd],
[
ZSTD_LIBS="-lzstd"
echo "dadebug req set zstd"
requirements_libdwarf_libs="${requirements_libdwarf_libs} -lzstd"
],
[have_zstd="no"])
])
],
[
have_zstd="no"
])
AS_IF(
[test "x${enable_decompression}" = "xyes"],
[
AS_IF(
echo "dadebug zlib ${have_pc_zlib} ${have_zlib}"
[test "x${have_pc_zlib}" = "xno" -a "x${have_zlib}" = "xyes"],
[
AC_SEARCH_LIBS(
[uncompress], [z],
[
ZLIB_LIBS="-lz"
requirements_libdwarf_libs="-lz"
echo "dadebug req set lz"
],
[have_zlib="no"])
])
],
[
have_zlib="no"
])
AS_IF(
[test "x${have_zlib}" = "xyes"],
[
AC_DEFINE([HAVE_ZLIB], [1], [Set to 1 if zlib decompression is available.])
AC_DEFINE([HAVE_ZLIB_H], [1], [Set to 1 if zlib.h header file is available.])
])
AS_IF(
[test "x${have_zstd}" = "xyes"],
[
AC_DEFINE([HAVE_ZSTD], [1], [Set to 1 if zstd decompression is available.])
AC_DEFINE([HAVE_ZSTD_H], [1], [Set to 1 if zstd.h header file is available.])
])
AC_SUBST([requirements_libdwarf_libs])
LIBS="$ZSTD_LIBS $ZLIB_LIBS"
RO_CHECK_C_COMPILER_FLAGS([${c_compiler_flags}])
AC_CONFIG_FILES([
Makefile
src/Makefile
test/Makefile
])
AC_OUTPUT
echo
echo "$PACKAGE $VERSION"
echo
echo "Configuration Options Summary:"
echo
echo " BuildOS..............: ${build_os}"
echo " HostOS...............: ${host_os}"
echo
echo " Elf64_Rel............: ${have_elf64_rel}"
echo " Elf64_Rela...........: ${have_elf64_rela}"
echo " Elf64_Sym............: ${have_elf64_sym}"
echo " sizeof unsigned long.: ${ac_cv_sizeof_unsigned_long}"
echo " sizeof unsigned ll...: ${ac_cv_sizeof_unsigned_long_long}"
echo " Elf64_Sym............: ${have_elf64_sym}"
echo " Nonstandardprintf....: ${enable_nonstandardprintf}"
echo " BuildOS-BigEndian....: ${ac_cv_c_bigendian}"
echo " Elf zstd decompress..: ${have_zstd}"
echo " Elf zlib decompress..: ${have_zlib}"
echo
echo " readelfobj,readobjpe, "
echo " readobjmacho, "
echo " object_detector : always"
echo
echo "Compilation............: make (or gmake)"
echo " CPPFLAGS.............: $CPPFLAGS"
echo " CFLAGS...............: $CFLAGS ${c_compiler_flags}"
echo " ZLIB_LIBS............: $ZLIB_LIBS"
echo " ZSTD_LIBS............: $ZSTD_LIBS"
echo " LDFLAGS..............: $LDFLAGS"
echo " LIBS.................: $LIBS"
echo
echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
echo " prefix...............: $prefix"
echo