Commit | Line | Data |
---|---|---|
0e65dfba NA |
1 | dnl -*- Autoconf -*- |
2 | dnl Process this file with autoconf to produce a configure script. | |
3 | dnl | |
4 | dnl Copyright (C) 2019 Free Software Foundation, Inc. | |
5 | dnl | |
6 | dnl This file is free software; you can redistribute it and/or modify | |
7 | dnl it under the terms of the GNU General Public License as published by | |
8 | dnl the Free Software Foundation; either version 2 of the License, or | |
9 | dnl (at your option) any later version. | |
10 | dnl | |
11 | dnl This program is distributed in the hope that it will be useful, | |
12 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | dnl GNU General Public License for more details. | |
15 | dnl | |
16 | dnl You should have received a copy of the GNU General Public License | |
17 | dnl along with this program; see the file COPYING. If not see | |
18 | dnl <http://www.gnu.org/licenses/>. | |
19 | dnl | |
20 | ||
21 | AC_PREREQ(2.64) | |
22 | AC_INIT([libctf library], 1.2.0-pre) | |
23 | AC_CONFIG_SRCDIR(ctf-impl.h) | |
24 | AC_CONFIG_MACRO_DIR(../config) | |
25 | AC_USE_SYSTEM_EXTENSIONS | |
26 | AM_INIT_AUTOMAKE | |
27 | ||
28 | # Checks for programs. | |
29 | AC_PROG_MAKE_SET | |
30 | AC_PROG_CC | |
31 | AC_PROG_RANLIB | |
32 | AM_PROG_AR | |
33 | ||
34 | AC_SYS_LARGEFILE | |
35 | ||
36 | MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing | |
37 | AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal]) | |
38 | AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) | |
39 | AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) | |
40 | ||
41 | # Figure out what compiler warnings we can enable. | |
42 | # See config/warnings.m4 for details. | |
43 | ||
44 | ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \ | |
45 | -Wmissing-format-attribute], [warn]) | |
46 | ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \ | |
47 | -Wold-style-definition], [c_warn]) | |
48 | ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long]) | |
49 | ||
50 | # Only enable with --enable-werror-always until existing warnings are | |
51 | # corrected. | |
52 | ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual]) | |
53 | ||
54 | AM_MAINTAINER_MODE | |
55 | ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags]) | |
56 | ||
57 | AC_FUNC_MMAP | |
9698cf9b | 58 | AC_SEARCH_LIBS(dlopen, dl) |
a0486bac | 59 | AM_ZLIB |
9698cf9b NA |
60 | |
61 | # Similar to GDB_AC_CHECK_BFD. | |
62 | OLD_CFLAGS=$CFLAGS | |
63 | OLD_LDFLAGS=$LDFLAGS | |
64 | OLD_LIBS=$LIBS | |
65 | # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS | |
66 | # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We | |
67 | # always want our bfd. | |
68 | CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS" | |
69 | ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'` | |
70 | LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS" | |
71 | intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'` | |
72 | LIBS="-lbfd -liberty -lz $intl $LIBS" | |
73 | AC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf, | |
74 | [AC_TRY_LINK([#include <stdlib.h> | |
75 | #include "bfd.h" | |
76 | #include "elf-bfd.h"], | |
77 | [(void) bfd_section_from_elf_index (NULL, 0); | |
78 | return 0;], | |
79 | [ac_cv_libctf_bfd_elf=yes], | |
80 | [ac_cv_libctf_bfd_elf=no])]) | |
81 | CFLAGS=$OLD_CFLAGS | |
82 | LDFLAGS=$OLD_LDFLAGS | |
83 | LIBS=$OLD_LIBS | |
84 | ||
85 | if test $ac_cv_libctf_bfd_elf = yes; then | |
86 | AC_DEFINE([HAVE_BFD_ELF], 1, | |
87 | [Whether libbfd was configured for an ELF target.]) | |
88 | fi | |
89 | ||
a0486bac JM |
90 | AC_C_BIGENDIAN |
91 | AC_CHECK_HEADERS(byteswap.h endian.h) | |
0e65dfba | 92 | AC_CHECK_FUNCS(pread) |
6b22174f NA |
93 | |
94 | dnl Check for qsort_r. (Taken from gnulib.) | |
95 | AC_CHECK_FUNCS_ONCE([qsort_r]) | |
96 | if test $ac_cv_func_qsort_r = yes; then | |
97 | AC_CACHE_CHECK([for qsort_r signature], [ac_cv_libctf_qsort_r_signature], | |
98 | [AC_LINK_IFELSE( | |
99 | [AC_LANG_PROGRAM([[#undef qsort_r | |
100 | #include <stdlib.h> | |
101 | void qsort_r (void *, size_t, size_t, | |
102 | int (*) (void const *, void const *, | |
103 | void *), | |
104 | void *); | |
105 | void (*p) (void *, size_t, size_t, | |
106 | int (*) (void const *, void const *, | |
107 | void *), | |
108 | void *) = qsort_r; | |
109 | ]])], | |
110 | [ac_cv_libctf_qsort_r_signature=GNU], | |
111 | [AC_LINK_IFELSE( | |
112 | [AC_LANG_PROGRAM([[#undef qsort_r | |
113 | #include <stdlib.h> | |
114 | void qsort_r (void *, size_t, size_t, void *, | |
115 | int (*) (void *, | |
116 | void const *, | |
117 | void const *)); | |
118 | void (*p) (void *, size_t, size_t, void *, | |
119 | int (*) (void *, void const *, | |
120 | void const *)) = qsort_r; | |
121 | ]])], | |
122 | [ac_cv_libctf_qsort_r_signature=BSD], | |
123 | [ac_cv_libctf_qsort_r_signature=unknown])])]) | |
124 | fi | |
125 | ||
126 | case x$ac_cv_libctf_qsort_r_signature in | |
127 | xGNU) AC_DEFINE([HAVE_QSORT_R_ARG_LAST], 1, | |
128 | [Whether a qsort_r exists with a void *arg as its last arg.]);; | |
129 | xBSD) AC_DEFINE([HAVE_QSORT_R_COMPAR_LAST], 1, | |
130 | [Whether a qsort_r exists with the compar function as its last arg.]);; | |
131 | *) ac_cv_libctf_qsort_r_signature=unknown;; | |
132 | esac | |
133 | ||
134 | AM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown) | |
0e65dfba | 135 | |
ad118caa NA |
136 | AC_CACHE_CHECK([for O_CLOEXEC], [ac_cv_libctf_macro_O_CLOEXEC], |
137 | [AC_LINK_IFELSE( | |
138 | [AC_LANG_PROGRAM([[#include <fcntl.h> | |
139 | #ifndef O_CLOEXEC | |
140 | choke me; | |
141 | #endif | |
142 | ]], | |
143 | [[return O_CLOEXEC;]])], | |
144 | [ac_cv_libctf_macro_O_CLOEXEC=yes], | |
145 | [ac_cv_libctf_macro_O_CLOEXEC=no])]) | |
146 | ||
147 | if test $ac_cv_libctf_macro_O_CLOEXEC = yes; then | |
148 | AC_DEFINE([HAVE_O_CLOEXEC], 1, | |
149 | [Whether the platform has a definition of O_CLOEXEC.]) | |
150 | fi | |
151 | ||
0e65dfba NA |
152 | AC_CONFIG_FILES(Makefile) |
153 | AC_CONFIG_HEADERS(config.h) | |
154 | AC_OUTPUT |