forked from davea42/libdwarf-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
436 lines (376 loc) · 12.1 KB
/
configure.ac
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
###Copyright (C) 2018 Vincent Torri <vincent dot torri at gmail dot com>
###This code is public domain and can be freely used or copied.
dnl defines the version name of the libdwarf.so
m4_define([v_maj], [0])
m4_define([v_min], [4])
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])
### Sets the release name.
###m4_define([v_date], [m4_esyscmd_s([date "+%Y%m%d"])])
###Also SET (VERSION ..) in CMakeLists.txt
AC_PREREQ([2.52])
### 2nd arg to AC_INIT is the version 'number'.
AC_INIT([libdwarf], [v_ver], [libdwarf-list -at- linuxmail -dot- org])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
### not yet, will be used before long.
###AM_PATH_PYTHON([3.0])
### Additional options to configure
AC_ARG_ENABLE([dwarfgen],
[AS_HELP_STRING([--enable-dwarfgen],
[enable dwarfgen compilation @<:@default=no@:>@])],
[
AS_IF(
[test "x${enableval}" = "xyes"],
[enable_dwarfgen="yes" ],
[enable_dwarfgen="no"])
],
[enable_dwarfgen="no"])
AM_CONDITIONAL([HAVE_DWARFGEN], [test "x${enable_dwarfgen}" = "xyes"])
AC_ARG_ENABLE([dwarfexample],
[AS_HELP_STRING([--enable-dwarfexample],
[enable dwarfexample compilation @<:@default=no@:>@])],
[
AS_IF(
[test "x${enableval}" = "xyes"],
[enable_dwarfexample="yes"],
[enable_dwarfexample="no"])
],
[enable_dwarfexample="no"])
AM_CONDITIONAL([HAVE_DWARFEXAMPLE], [test "x${enable_dwarfexample}" = "xyes"])
AC_ARG_ENABLE([sanitize],
[AS_HELP_STRING([--enable-sanitize],
[enable sanitize compiler option @<:@default=no@:>@])],
[
AS_IF(
[test "x${enableval}" = "xyes"],
[enable_sanitize="yes"],
[enable_sanitize="no"])
],
[enable_sanitize="no"])
AC_ARG_ENABLE([libelf],
[AS_HELP_STRING([--disable-libelf],
[disable use of libelf (default is enable (libdwarf does not use libelf)) @<:@default=yes@:>@])],
[ AS_IF(
[test "x${enableval}" = "xyes"],
[dwarf_with_libelf="yes"],
[dwarf_with_libelf="no"])
],
[dwarf_with_libelf="yes"])
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"])
AC_ARG_ENABLE([doc],
[AS_HELP_STRING([--enable-doc],
[build and install Doxygen documentation @<:@default=no@:>@])],
[
AS_IF(
[test "x${enableval}" = "xyes"],
[enable_doc="yes"],
[enable_doc="no"])
],
[enable_doc="no"])
### Default options with respect to host
AC_CANONICAL_HOST
have_win32="no"
case "$host_os" in
mingw*)
have_win32="yes"
;;
esac
### Checks for programs
AM_PROG_AR
### We don't use dist-xz *.xz output from make dist,
### so don't mention it.
AM_INIT_AUTOMAKE([1.6 dist-xz])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AS_IF(
[test "x${have_win32}" = "xyes"],
[lt_cv_deplibs_check_method=pass_all])
LT_INIT([win32-dll disable-shared static])
AS_IF(
[test "x${have_win32}" = "xyes" && test "x${enable_static}" = "xyes"],
[AC_MSG_ERROR([Static library is not supported on Windows])])
version_info="lt_cur:lt_rev:lt_age"
release_info="v_rel"
AC_SUBST([version_info])
AC_SUBST([release_info])
VMAJ=v_maj
AC_SUBST([VMAJ])
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CC_C_O
PKG_PROG_PKG_CONFIG
AC_ARG_VAR([DOXYGEN], [Doxygen documentation generation program])
AS_IF(
[test "x${enable_doc}" = "xyes"],
[
AC_CHECK_PROGS([DOXYGEN], [doxygen], [no])
AS_IF(
[test "x${DOXYGEN}" = "xno"],
[enable_doc="no" ],
[enable_doc="yes"])
],
[enable_doc="no"])
AM_CONDITIONAL([HAVE_DOC], [test "x${enable_doc}" = "xyes"])
### Checks for libraries
requirements_libdwarf_pc=
PKG_CHECK_MODULES([ZLIB], [zlib],
[
have_zlib="yes"
have_pc_zlib="yes"
requirements_libdwarf_pc=zlib
],
[
have_zlib="no"
have_pc_zlib="no"
])
AC_SUBST([requirements_libdwarf_pc])
AC_SUBST([DWARFGEN_LIBS])
AC_ARG_VAR([DWARFGEN_LIBS], [extra linker flags when linking dwarfgen])
AC_SUBST([DWARF_LIBS])
AC_ARG_VAR([DWARF_LIBS], [extra linker flags when linking dwarfdump])
### Checks for header files
### MacOS does not have malloc.h
AC_CHECK_HEADERS([unistd.h sys/types.h malloc.h])
### for uintptr_t and open and open argument defines
AC_CHECK_HEADERS([stdint.h inttypes.h stddef.h fcntl.h])
AS_IF(
[test "x${have_zlib}" = "xno"],
[AC_CHECK_HEADERS([zlib.h],
[have_zlib="yes"],
[have_zlib="no"])])
### for use in casts to uint to avoid 32bit warnings.
### Also needed by C++ cstdint
AC_TYPE_UINTPTR_T
AC_TYPE_INTPTR_T
AC_TYPE_UINT32_T dnl Needed for hash calculation
### Now we know uintptr_t is either in stdint.h or
### is defined in config.h by configure.
# test Elf headers in the preprocessor path search
# We need Elf.h defines like Ehdr32 and relocations
# to read them with our local elf-section reader code.
# On Solaris libelf.h has relocation defines we need.
# so we check for libelf.h too.
CPPFLAGS_save=${CPPFLAGS}
# dwarfgen needs an actual libelf else it cannot be built.
### we set $dwarf_with_libelf above.
if test "$dwarf_with_libelf" = "yes" ; then
AC_CHECK_HEADERS([libelf.h libelf/libelf.h])
AC_CHECK_HEADERS([elf.h])
### if no libelf.h add no -lelf and turn off
### libelf recognition.
### if no dwarfgen do not add -lelf
AS_IF([test "x${ac_cv_header_libelf_h}" != "xyes" -a "x${ac_cv_header_libelf_libelf_h}" != "xyes" ],
[ dwarf_with_libelf="no"
AC_MSG_NOTICE(["no libelf headers, so no libelf"]) ],
[ AS_IF([ test "x${enable_dwarfgen}" != "xyes" ],
[ dwarf_with_libelf="no"
AC_MSG_NOTICE(["dwarfgen not needed, so no libelf"])],
[ DWARFGEN_LIBS="${DWARFGEN_LIBS} -ldwarf -lelf"
dwarf_with_libelf="yes"
AC_MSG_NOTICE(["Allowing use of libelf for dwarfgen."])
AC_DEFINE([DWARF_WITH_LIBELF],[1],
[Set to 1 as we are building dwarfgen with libelf])])
])
fi
### Checks for compiler characteristics
AC_C_BIGENDIAN
AC_SUBST([DWARF_BIGENDIAN],[${ac_cv_c_bigendian}])
AC_ARG_VAR([DWARF_BIGENDIAN],
[big endian yes/no needed various places])
# gcc accepts even totally bogus -Wno flags. Other compilers..no
# -Wno-long-long suppresses warnings on 'long long'
# -Wno-pedantic-ms-format (which only exists in mingw)
# suppresses warnings about I64 printf format.
c_common_flags="-Wall -Wextra -Wpointer-arith -Wmissing-declarations -Wcomment -Wformat -Wpedantic -Wuninitialized -Wshadow -Werror -Wno-long-long"
AS_IF(
[ test "x$enable_wall" = "xyes" ],
[
cxx_compiler_flags="$c_common_flags -Wno-unused-private-field"
c_compiler_flags="$c_common_flags -Wmissing-prototypes -Wdeclaration-after-statement -Wbad-function-cast -Wmissing-parameter-type -Wnested-externs"
]
)
AS_IF(
[ test "x$have_win32" = "xyes" ],
[
cxx_compiler_flags="$cxx_compiler_flags -Wno-pedantic-ms-format"
c_compiler_flags="$c_compiler_flags -Wno-pedantic-ms-format"
]
)
DWARF_CHECK_CXX_COMPILER_FLAGS([${cxx_compiler_flags}])
DWARF_CHECK_C_COMPILER_FLAGS([${c_compiler_flags}])
# 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}])
# sanitize
AS_IF(
[test "x${enable_sanitize}" = "xyes"],
[
CFLAGS_save=${CFLAGS}
CFLAGS="${CFLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined -fno-omit-frame-pointer"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[
enable_sanitize="yes"
DWARF_CFLAGS="$DWARF_CFLAGS -fsanitize=address -fsanitize=leak -fsanitize=undefined -fno-omit-frame-pointer"
LDFLAGS="$LDFLAGS -fsanitize=address -fsanitize=leak -fsanitize=undefined -fno-omit-frame-pointer"
],
[enable_sanitize="no"])
CFLAGS="${CFLAGS_save} ${DWARF_CFLAGS}"
])
AC_MSG_CHECKING([whether sanitize options are used])
AC_MSG_RESULT([${enable_sanitize}])
# -fvisibility
AS_IF(
[test "x${enable_shared}" = "xyes" && test "x${have_win32}" = "xno"],
[
CFLAGS_save=${CFLAGS}
CFLAGS="${CFLAGS} -fvisibility=hidden -fno-omit-frame-pointer"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[
DWARF_CFLAGS="$DWARF_CFLAGS -fvisibility=hidden -fno-omit-frame-pointer"
LDFLAGS="$LDFLAGS -fvisibility=hidden -fno-omit-frame-pointer"
],
[AC_MSG_NOTICE([Option -fvisibility is ignored. Not supported.])])
CFLAGS="${CFLAGS_save} ${DWARF_CFLAGS}"
])
### Checks for linker characteristics
### Checks for library functions
AC_FUNC_ALLOCA
have_getehdr="no"
have_getshdr="no"
CPPFLAGS_save=${CPPFLAGS}
CPPFLAGS="${CPPFLAGS}"
LIBS_save=${LIBS}
LIBS="${LIBS} ${DWARF_LIBS}"
AC_SEARCH_LIBS(
[elf64_getehdr], [elf],
[
have_getehdr="yes"
AC_DEFINE(
[HAVE_ELF64_GETEHDR], [1],
[Set to 1 if the elf64_getehdr function is in libelf.])
],
[have_getehdr="no"])
AC_SEARCH_LIBS(
[elf64_getshdr], [elf],
[
have_getshdr="yes"
AC_DEFINE(
[HAVE_ELF64_GETSHDR], [1],
[Set to 1 if the elf64_getshdr function is in libelf.])
],
[have_getshdr="no"])
CPPFLAGS=${CPPFLAGS_save}
LIBS=${LIBS_save}
requirements_libdwarf_libs=
AS_IF(
[test "x${have_pc_zlib}" = "xno" -a "x${have_zlib}" = "xyes"],
[AC_SEARCH_LIBS(
[uncompress], [z],
[
ZLIB_LIBS="-lz"
requirements_libdwarf_libs="-lz"
],
[have_zlib="no"])
])
AC_SUBST([requirements_libdwarf_libs])
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.])
])
### Checks for system services
AC_CONFIG_FILES([
Makefile
src/lib/libdwarf/Makefile
src/lib/libdwarfp/Makefile
src/bin/dwarfdump/Makefile
src/bin/dwarfgen/Makefile
src/bin/dwarfexample/Makefile
src/bin/gennames/Makefile
src/bin/tag_attr/Makefile
src/bin/tag_tree/Makefile
src/bin/attr_form/Makefile
src/bin/buildopstab/Makefile
src/bin/builduritable/Makefile
test/Makefile
doc/Makefile
libdwarf.pc
libdwarfp.pc
])
AC_OUTPUT
echo
echo "$PACKAGE $VERSION"
echo
echo "Configuration Options Summary:"
echo
echo " BuildOS..............: ${build_os}"
echo " HostOS...............: ${host_os}"
echo
echo " shared library.......: ${enable_shared}"
echo " static library.......: ${enable_static}"
echo
echo " zlib support.........: ${have_zlib}"
echo " sanitize support.....: ${enable_sanitize}"
echo " documentation........: ${enable_doc}"
echo " BuildOS-BigEndian....: ${ac_cv_c_bigendian}"
echo
echo " libdwarf.............: always"
echo " elf64_getehdr......: ${have_getehdr}"
echo " elf64_getshdr......: ${have_getshdr}"
echo " libelf.............: ${dwarf_with_libelf}"
echo " dwarfdump............: always"
echo " dwarfgen.............: ${enable_dwarfgen}"
echo " dwarfexample.........: ${enable_dwarfexample}"
echo
echo "Compilation............: make (or gmake)"
echo " CPPFLAGS.............: $CPPFLAGS"
echo " CFLAGS...............: $CFLAGS ${c_compiler_flags}"
echo " LDFLAGS..............: $LDFLAGS"
echo " LIBS.................: $LIBS"
echo " ZLIB_LIBS............: $ZLIB_LIBS"
echo " DWARF_CFLAGS.........: $DWARF_CFLAGS"
echo " DWARF_LIBS...........: $DWARF_LIBS"
echo " DWARFGEN_LIBS........: $DWARFGEN_LIBS"
echo
echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
echo " prefix...............: $prefix"
echo