bfd, ld: add CTF section linking
[deliverable/binutils-gdb.git] / libctf / configure.ac
CommitLineData
0e65dfba
NA
1dnl -*- Autoconf -*-
2dnl Process this file with autoconf to produce a configure script.
3dnl
4dnl Copyright (C) 2019 Free Software Foundation, Inc.
5dnl
6dnl This file is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 2 of the License, or
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program; see the file COPYING. If not see
18dnl <http://www.gnu.org/licenses/>.
19dnl
20
21AC_PREREQ(2.64)
22AC_INIT([libctf library], 1.2.0-pre)
23AC_CONFIG_SRCDIR(ctf-impl.h)
24AC_CONFIG_MACRO_DIR(../config)
25AC_USE_SYSTEM_EXTENSIONS
26AM_INIT_AUTOMAKE
27
28# Checks for programs.
29AC_PROG_MAKE_SET
30AC_PROG_CC
31AC_PROG_RANLIB
32AM_PROG_AR
33
34AC_SYS_LARGEFILE
35
36MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
37AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal])
38AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf])
39AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
40
41# Figure out what compiler warnings we can enable.
42# See config/warnings.m4 for details.
43
44ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wno-narrowing -Wwrite-strings \
45 -Wmissing-format-attribute], [warn])
46ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \
47 -Wold-style-definition], [c_warn])
48ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
49
50# Only enable with --enable-werror-always until existing warnings are
51# corrected.
52ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
53
54AM_MAINTAINER_MODE
55ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags])
56
57AC_FUNC_MMAP
9698cf9b 58AC_SEARCH_LIBS(dlopen, dl)
a0486bac 59AM_ZLIB
9698cf9b
NA
60
61# Similar to GDB_AC_CHECK_BFD.
62OLD_CFLAGS=$CFLAGS
63OLD_LDFLAGS=$LDFLAGS
64OLD_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.
68CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
69ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
70LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
71intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
72LIBS="-lbfd -liberty -lz $intl $LIBS"
73AC_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])])
81CFLAGS=$OLD_CFLAGS
82LDFLAGS=$OLD_LDFLAGS
83LIBS=$OLD_LIBS
84
85if test $ac_cv_libctf_bfd_elf = yes; then
86 AC_DEFINE([HAVE_BFD_ELF], 1,
87 [Whether libbfd was configured for an ELF target.])
88fi
89
a0486bac
JM
90AC_C_BIGENDIAN
91AC_CHECK_HEADERS(byteswap.h endian.h)
0e65dfba 92AC_CHECK_FUNCS(pread)
6b22174f
NA
93
94dnl Check for qsort_r. (Taken from gnulib.)
95AC_CHECK_FUNCS_ONCE([qsort_r])
96if 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])])])
124fi
125
126case 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;;
132esac
133
134AM_CONDITIONAL(NEED_CTF_QSORT_R, test "${ac_cv_libctf_qsort_r_signature}" = unknown)
0e65dfba 135
ad118caa
NA
136AC_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
147if 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.])
150fi
151
0e65dfba
NA
152AC_CONFIG_FILES(Makefile)
153AC_CONFIG_HEADERS(config.h)
154AC_OUTPUT
This page took 0.044437 seconds and 4 git commands to generate.