Automatic date update in version.in
[binutils-gdb.git] / gprofng / configure.ac
bloba4da4e0f6f8515b3a1799bb014eeae5240e6b054
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl   Copyright (C) 2021 Free Software Foundation, Inc.
4 dnl
5 dnl This file is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
9 dnl
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; see the file COPYING3.  If not see
17 dnl <http://www.gnu.org/licenses/>.
19 m4_include([../bfd/version.m4])
20 AC_INIT([gprofng], BFD_VERSION)
21 AC_CANONICAL_TARGET
22 AM_INIT_AUTOMAKE([subdir-objects])
23 AM_MAINTAINER_MODE
25 AC_USE_SYSTEM_EXTENSIONS
26 AC_PROG_CC
27 AC_PROG_CXX
28 AC_PROG_INSTALL
29 AC_PROG_RANLIB
30 AM_PROG_AR
32 AC_DISABLE_SHARED
33 LT_INIT
35 GPROFNG_LIBADD="-L../../libiberty -liberty"
36 if test "$enable_shared" = "yes"; then
37   GPROFNG_LIBADD="-L../../libiberty/pic -liberty"
39 AC_SUBST(GPROFNG_LIBADD)
41 # Figure out what compiler warnings we can enable.
42 # See config/warnings.m4 for details.
44 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
45 ACX_PROG_CC_WARNING_OPTS([-Wall], [gprofng_cflags])
46 ACX_PROG_CC_WARNING_OPTS([-Wno-format-truncation], [GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS])
47 ACX_PROG_CC_WARNING_OPTS([-Wno-switch], [GPROFNG_NO_SWITCH_CFLAGS])
48 gprofng_cppflags="-U_ASM"
49 build_collector=
50 build_src=
52 # This is annoying: it means we have to pass --enable-shared explicitly to
53 # get gprofng, while the configure default is supposed to be that shared libs
54 # are on by default.  But as long as libiberty has code like this, so must
55 # we...
57   case "${target}" in
58     x86_64-*-linux*)
59       build_src=true
60       build_collector=true
61       ;;
62     i?86-*-linux*)
63       build_collector=true
64       build_collector=true
65       ;;
66     aarch64-*-linux*)
67       build_src=true
68       build_collector=true
69       ;;
70   esac
71   AC_ARG_ENABLE(gprofng-tools,
72     AS_HELP_STRING([--disable-gprofng-tools], [do not build gprofng/src directory]),
73     build_src=$enableval)
75 AM_CONDITIONAL([BUILD_COLLECTOR], [test x$build_collector = xtrue])
76 AM_CONDITIONAL([BUILD_SRC], [test x$build_src = xtrue])
78 run_tests=false
79 if test x$build_collector = xtrue; then
80   AC_CONFIG_SUBDIRS([libcollector])
81   if test x${host} = x${target}; then
82     run_tests=true
83   fi
85 AM_CONDITIONAL([RUN_TESTS], [test x$run_tests = xtrue])
86 AX_PTHREAD
88 # Specify a location for JDK
89 enable_gprofng_jp=
90 jdk_inc=
91 AC_ARG_WITH(jdk,
92 [AS_HELP_STRING([--with-jdk=PATH],
93                 [specify prefix directory for installed JDK.])])
95 if test "x$with_jdk" != x; then
96   jdk_inc="-I$with_jdk/include -I$with_jdk/include/linux"
97   enable_gprofng_jp=yes
98 else
99   AC_PATH_PROG([JAVAC], [javac], [javac])
100   if test -f $JAVAC; then
101     x=`readlink -f $JAVAC`
102     x=`dirname $x`
103     x=`dirname $x`
104     if ! test -f $x/include/jni.h; then
105       x=`dirname $x`
106     fi
107     if test -f $x/include/jni.h; then
108       jdk_inc="-I$x/include -I$x/include/linux"
109       enable_gprofng_jp=yes
110     fi
111   fi
113 if test "x$enable_gprofng_jp" = x; then
114   AC_PATH_PROG([JAVA], [java], [java])
115   if test -f $JAVA; then
116     x=`readlink -f $JAVA`
117     x=`dirname $x`
118     x=`dirname $x`
119     if ! test -f $x/include/jni.h; then
120       x=`dirname $x`
121     fi
122     if test -f $x/include/jni.h; then
123       jdk_inc="-I$x/include -I$x/include/linux"
124       enable_gprofng_jp=yes
125     fi
126   fi
128 if test "x$enable_gprofng_jp" = x; then
129   AC_CHECK_HEADER([jni.h], [ enable_gprofng_jp=yes ], [], [] )
131 GPROFNG_BROKEN_JAVAC=no
132 if test "x$enable_gprofng_jp" = x; then
133     AC_MSG_WARN([ Cannot find the JDK include directory.
134       gprofng will be build without support for profiling Java applications.
135       Use --with-jdk=PATH to specify directory for the installed JDK])
136 else
137     AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling])
138     if test "x$JAVAC" != x; then
139       cat > configtest.java << EOF
140 class Simple{
141   public static void main(String args[]){
142     System.out.println("Hello Java");
143   }
146       if AC_TRY_COMMAND($JAVAC conftest.java &AS_MESSAGE_LOG_FD 2>&1); then
147         GPROFNG_BROKEN_JAVAC=no
148       else
149         GPROFNG_BROKEN_JAVAC=yes
150       fi
151       rm -f configtest.*
152     fi
154 AC_SUBST(GPROFNG_BROKEN_JAVAC)
155 AC_SUBST(jdk_inc)
157 DEBUG=
158 GCC_ENABLE([gprofng-debug], [no], [], [Enable debugging output])
159 if test "${enable_gprofng_debug}" = yes; then
160     AC_DEFINE(DEBUG, 1, [Enable debugging output.])
163 # Check if linker supports --as-needed and --no-as-needed options.
164 AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
165         [bfd_cv_ld_as_needed=no
166         if $LD --help 2>/dev/null | grep as-needed > /dev/null; then
167                 bfd_cv_ld_as_needed=yes
168         fi
169         ])
171 no_as_needed=
172 if test x"$bfd_cv_ld_as_needed" = xyes; then
173     no_as_needed='-Wl,--no-as-needed'
176 AC_PATH_PROG([EXPECT], [expect])
177 AC_CACHE_CHECK([for Tcl supporting try/catch], [ac_cv_libctf_tcl_try],
178   [ac_cv_libctf_tcl_try=`if test -z $EXPECT; then echo no; else $EXPECT << EOF
179 if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
183 AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
186 # Generate manpages, if possible.
187 if test $cross_compiling = no; then
188   AM_MISSING_PROG(HELP2MAN, help2man)
189   build_man=true
190 else
191   build_man=false
193 AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])
195 AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
196 AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
197 AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS)
198 AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
199 AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
200 AC_SUBST(GPROFNG_LIBDIR, [${libdir}])
202 AC_CHECK_DECLS([basename])
203 AC_CHECK_FUNCS(clock_gettime strsignal)
205 clock_gettime_link=
206 # At least for glibc, clock_gettime is in librt.  But don't
207 # pull that in if it still doesn't give us the function we want.  This
208 # test is copied from libgomp, and modified to not link in -lrt as
209 # we're using this for test timing only.
210 if test "$ac_cv_func_clock_gettime" = no; then
211   AC_CHECK_LIB(rt, clock_gettime,
212     [CLOCK_GETTIME_LINK=-lrt
213      AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
214                [Define to 1 if you have the `clock_gettime' function.])])
216 AC_SUBST(CLOCK_GETTIME_LINK)
218 AC_SUBST(BUILD_SUBDIRS)
220 AC_CONFIG_FILES([Makefile src/Makefile gp-display-html/Makefile doc/Makefile])
221 AC_CONFIG_HEADERS([config.h:common/config.h.in])
223 AC_OUTPUT