Commit | Line | Data |
---|---|---|
0e65dfba NA |
1 | dnl -*- Autoconf -*- |
2 | dnl Process this file with autoconf to produce a configure script. | |
3 | dnl | |
b3adc24a | 4 | dnl Copyright (C) 2019-2020 Free Software Foundation, Inc. |
0e65dfba NA |
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) | |
87279e3c | 25 | AC_CONFIG_MACRO_DIR(../bfd) |
0e65dfba NA |
26 | AC_USE_SYSTEM_EXTENSIONS |
27 | AM_INIT_AUTOMAKE | |
28 | ||
29 | # Checks for programs. | |
30 | AC_PROG_MAKE_SET | |
31 | AC_PROG_CC | |
32 | AC_PROG_RANLIB | |
33 | AM_PROG_AR | |
8e6635bd | 34 | ZW_GNU_GETTEXT_SISTER_DIR |
0e65dfba | 35 | |
87279e3c NA |
36 | dnl Default to a non shared library. This may be overridden by the |
37 | dnl configure option --enable-shared. | |
38 | AC_DISABLE_SHARED | |
39 | ||
40 | LT_INIT | |
0e65dfba NA |
41 | AC_SYS_LARGEFILE |
42 | ||
43 | MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing | |
44 | AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal]) | |
45 | AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) | |
46 | AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) | |
47 | ||
48 | # Figure out what compiler warnings we can enable. | |
49 | # See config/warnings.m4 for details. | |
50 | ||
51 | ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \ | |
52 | -Wmissing-format-attribute], [warn]) | |
53 | ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \ | |
54 | -Wold-style-definition], [c_warn]) | |
55 | ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long]) | |
56 | ||
57 | # Only enable with --enable-werror-always until existing warnings are | |
58 | # corrected. | |
59 | ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual]) | |
60 | ||
61 | AM_MAINTAINER_MODE | |
87279e3c | 62 | AM_INSTALL_LIBBFD |
0e65dfba NA |
63 | ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags]) |
64 | ||
65 | AC_FUNC_MMAP | |
87279e3c | 66 | # Needed for BFD capability checks. |
9698cf9b | 67 | AC_SEARCH_LIBS(dlopen, dl) |
a0486bac | 68 | AM_ZLIB |
9698cf9b NA |
69 | |
70 | # Similar to GDB_AC_CHECK_BFD. | |
71 | OLD_CFLAGS=$CFLAGS | |
72 | OLD_LDFLAGS=$LDFLAGS | |
73 | OLD_LIBS=$LIBS | |
74 | # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS | |
75 | # points somewhere with bfd, with -I/foo/lib and -L/foo/lib. We | |
76 | # always want our bfd. | |
77 | CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS" | |
78 | ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'` | |
79 | LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS" | |
80 | intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'` | |
81 | LIBS="-lbfd -liberty -lz $intl $LIBS" | |
82 | AC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf, | |
83 | [AC_TRY_LINK([#include <stdlib.h> | |
84 | #include "bfd.h" | |
85 | #include "elf-bfd.h"], | |
86 | [(void) bfd_section_from_elf_index (NULL, 0); | |
87 | return 0;], | |
88 | [ac_cv_libctf_bfd_elf=yes], | |
89 | [ac_cv_libctf_bfd_elf=no])]) | |
90 | CFLAGS=$OLD_CFLAGS | |
91 | LDFLAGS=$OLD_LDFLAGS | |
92 | LIBS=$OLD_LIBS | |
93 | ||
94 | if test $ac_cv_libctf_bfd_elf = yes; then | |
95 | AC_DEFINE([HAVE_BFD_ELF], 1, | |
96 | [Whether libbfd was configured for an ELF target.]) | |
97 | fi | |
98 | ||
a0486bac JM |
99 | AC_C_BIGENDIAN |
100 | AC_CHECK_HEADERS(byteswap.h endian.h) | |
0e65dfba | 101 | AC_CHECK_FUNCS(pread) |
6b22174f | 102 | |
3a657c60 | 103 | AC_CHECK_DECLS([asprintf]) |
e755667f NA |
104 | dnl Check for bswap_{16,32,64} |
105 | AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64], [], [], [[#include <byteswap.h>]]) | |
3a657c60 | 106 | |
6b22174f NA |
107 | dnl Check for qsort_r. (Taken from gnulib.) |
108 | AC_CHECK_FUNCS_ONCE([qsort_r]) | |
109 | if test $ac_cv_func_qsort_r = yes; then | |
110 | AC_CACHE_CHECK([for qsort_r signature], [ac_cv_libctf_qsort_r_signature], | |
111 | [AC_LINK_IFELSE( | |
112 | [AC_LANG_PROGRAM([[#undef qsort_r | |
113 | #include <stdlib.h> | |
114 | void qsort_r (void *, size_t, size_t, | |
115 | int (*) (void const *, void const *, | |
116 | void *), | |
117 | void *); | |
118 | void (*p) (void *, size_t, size_t, | |
119 | int (*) (void const *, void const *, | |
120 | void *), | |
121 | void *) = qsort_r; | |
122 | ]])], | |
123 | [ac_cv_libctf_qsort_r_signature=GNU], | |
124 | [AC_LINK_IFELSE( | |
125 | [AC_LANG_PROGRAM([[#undef qsort_r | |
126 | #include <stdlib.h> | |
127 | void qsort_r (void *, size_t, size_t, void *, | |
128 | int (*) (void *, | |
129 | void const *, | |
130 | void const *)); | |
131 | void (*p) (void *, size_t, size_t, void *, | |
132 | int (*) (void *, void const *, | |
133 | void const *)) = qsort_r; | |
134 | ]])], | |
135 | [ac_cv_libctf_qsort_r_signature=BSD], | |
136 | [ac_cv_libctf_qsort_r_signature=unknown])])]) | |
137 | fi | |
138 | ||
139 | case x$ac_cv_libctf_qsort_r_signature in | |
140 | xGNU) AC_DEFINE([HAVE_QSORT_R_ARG_LAST], 1, | |
141 | [Whether a qsort_r exists with a void *arg as its last arg.]);; | |
142 | xBSD) AC_DEFINE([HAVE_QSORT_R_COMPAR_LAST], 1, | |
143 | [Whether a qsort_r exists with the compar function as its last arg.]);; | |
144 | *) ac_cv_libctf_qsort_r_signature=unknown;; | |
145 | esac | |
146 | ||
147 | AM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown) | |
0e65dfba | 148 | |
ad118caa NA |
149 | AC_CACHE_CHECK([for O_CLOEXEC], [ac_cv_libctf_macro_O_CLOEXEC], |
150 | [AC_LINK_IFELSE( | |
151 | [AC_LANG_PROGRAM([[#include <fcntl.h> | |
152 | #ifndef O_CLOEXEC | |
153 | choke me; | |
154 | #endif | |
155 | ]], | |
156 | [[return O_CLOEXEC;]])], | |
157 | [ac_cv_libctf_macro_O_CLOEXEC=yes], | |
158 | [ac_cv_libctf_macro_O_CLOEXEC=no])]) | |
159 | ||
160 | if test $ac_cv_libctf_macro_O_CLOEXEC = yes; then | |
161 | AC_DEFINE([HAVE_O_CLOEXEC], 1, | |
162 | [Whether the platform has a definition of O_CLOEXEC.]) | |
163 | fi | |
164 | ||
87279e3c NA |
165 | # Horrible hacks to build DLLs on Windows and a shared library elsewhere. |
166 | SHARED_LIBADD= | |
167 | SHARED_LDFLAGS= | |
168 | BFD_LIBADD= | |
169 | BFD_DEPENDENCIES= | |
170 | if test "$enable_shared" = "yes"; then | |
171 | # When building a shared libctf, link against the pic version of libiberty | |
172 | # so that apps that use libctf won't need libiberty just to satisfy any | |
173 | # libctf references. | |
174 | # We can't do that if a pic libiberty is unavailable since including non-pic | |
175 | # code would insert text relocations into libctf. | |
176 | # Note that linking against libbfd as we do here, which is itself linked | |
177 | # against libiberty, may not satisfy all the libctf libiberty references | |
178 | # since libbfd may not pull in the entirety of libiberty. | |
179 | changequote(,)dnl | |
180 | x=`sed -n -e 's/^[ ]*PICFLAG[ ]*=[ ]*//p' < ../libiberty/Makefile | sed -n '$p'` | |
181 | changequote([,])dnl | |
182 | if test -n "$x"; then | |
183 | SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty" | |
184 | fi | |
185 | ||
186 | case "${host}" in | |
187 | # More hacks to build DLLs on Windows. | |
188 | *-*-cygwin*) | |
189 | SHARED_LDFLAGS="-no-undefined" | |
190 | SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin" | |
191 | BFD_LIBADD="-L`pwd`/../bfd -lbfd" | |
192 | ;; | |
193 | ||
194 | *-*-darwin*) | |
195 | BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.dylib" | |
196 | BFD_DEPENDENCIES="../bfd/libbfd.la" | |
197 | ;; | |
198 | *) | |
199 | case "$host_vendor" in | |
200 | hp) | |
201 | BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.sl" | |
202 | ;; | |
203 | *) | |
204 | BFD_LIBADD="-Wl,`pwd`/../bfd/.libs/libbfd.so" | |
205 | ;; | |
206 | esac | |
207 | BFD_DEPENDENCIES="../bfd/libbfd.la" | |
208 | ;; | |
209 | esac | |
210 | fi | |
211 | AC_SUBST(SHARED_LDFLAGS) | |
212 | AC_SUBST(SHARED_LIBADD) | |
213 | AC_SUBST(BFD_LIBADD) | |
214 | AC_SUBST(BFD_DEPENDENCIES) | |
215 | ||
216 | # Use a version script, if possible, or an -export-symbols-regex otherwise. | |
217 | VERSION_FLAGS='-export-symbols-regex ctf_.*' | |
218 | if $LD --help 2>&1 | grep -- --version-script >/dev/null; then | |
219 | VERSION_FLAGS="-Wl,--version-script='$srcdir/libctf.ver'" | |
220 | fi | |
221 | AC_SUBST(VERSION_FLAGS) | |
222 | ||
0e65dfba NA |
223 | AC_CONFIG_FILES(Makefile) |
224 | AC_CONFIG_HEADERS(config.h) | |
225 | AC_OUTPUT |