8977e8bd4bb985f6592903c79fd92f3270fa6964
[binutils-gdb.git] / gprofng / configure.ac
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/>.
18
19 m4_include([../bfd/version.m4])
20 AC_INIT([gprofng], BFD_VERSION)
21 AM_INIT_AUTOMAKE([subdir-objects])
22 AM_MAINTAINER_MODE
23
24 AC_USE_SYSTEM_EXTENSIONS
25 AC_PROG_CC
26 AC_PROG_CXX
27 AC_PROG_INSTALL
28 AC_PROG_RANLIB
29 AM_PROG_AR
30
31 AC_DISABLE_SHARED
32 LT_INIT
33
34 GPROFNG_LIBADD="-L../../libiberty -liberty"
35 if test "$enable_shared" = "yes"; then
36 GPROFNG_LIBADD="-L../../libiberty/pic -liberty"
37 fi
38 AC_SUBST(GPROFNG_LIBADD)
39
40 # Figure out what compiler warnings we can enable.
41 # See config/warnings.m4 for details.
42
43 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
44 ACX_PROG_CC_WARNING_OPTS([-Wall], [gprofng_cflags])
45 gprofng_cppflags="-U_ASM"
46 build_collector=
47 build_src=
48
49 # This is annoying: it means we have to pass --enable-shared explicitly to
50 # get gprofng, while the configure default is supposed to be that shared libs
51 # are on by default. But as long as libiberty has code like this, so must
52 # we...
53
54 case "${target}" in
55 x86_64-*-linux*)
56 build_src=true
57 build_collector=true
58 ;;
59 i?86-*-linux*)
60 build_collector=true
61 build_collector=true
62 ;;
63 aarch64-*-linux*)
64 build_src=true
65 build_collector=true
66 ;;
67 esac
68 AC_ARG_ENABLE(gprofng-tools,
69 AS_HELP_STRING([--disable-gprofng-tools], [do not build gprofng/src directory]),
70 build_src=$enableval)
71
72 AM_CONDITIONAL([BUILD_COLLECTOR], [test x$build_collector = xtrue])
73 AM_CONDITIONAL([BUILD_SRC], [test x$build_src = xtrue])
74
75 run_tests=false
76 if test x$build_collector = xtrue; then
77 AC_CONFIG_SUBDIRS([libcollector])
78 if test x${host} = x${target}; then
79 run_tests=true
80 fi
81 fi
82 AM_CONDITIONAL([RUN_TESTS], [test x$run_tests = xtrue])
83 AX_PTHREAD
84
85 # Specify a location for JDK
86 enable_gprofng_jp=
87 jdk_inc=
88 AC_ARG_WITH(jdk,
89 [AS_HELP_STRING([--with-jdk=PATH],
90 [specify prefix directory for installed JDK.])])
91
92 if test "x$with_jdk" != x; then
93 jdk_inc="-I$with_jdk/include -I$with_jdk/include/linux"
94 enable_gprofng_jp=yes
95 else
96 AC_PATH_PROG([JAVAC], [javac], [javac])
97 if test -f $JAVAC; then
98 x=`readlink -f $JAVAC`
99 x=`dirname $x`
100 x=`dirname $x`
101 if ! test -f $x/include/jni.h; then
102 x=`dirname $x`
103 fi
104 if test -f $x/include/jni.h; then
105 jdk_inc="-I$x/include -I$x/include/linux"
106 enable_gprofng_jp=yes
107 fi
108 fi
109 fi
110 if test "x$enable_gprofng_jp" = x; then
111 AC_PATH_PROG([JAVA], [java], [java])
112 if test -f $JAVA; then
113 x=`readlink -f $JAVA`
114 x=`dirname $x`
115 x=`dirname $x`
116 if ! test -f $x/include/jni.h; then
117 x=`dirname $x`
118 fi
119 if test -f $x/include/jni.h; then
120 jdk_inc="-I$x/include -I$x/include/linux"
121 enable_gprofng_jp=yes
122 fi
123 fi
124 fi
125 if test "x$enable_gprofng_jp" = x; then
126 AC_CHECK_HEADER([jni.h], [ enable_gprofng_jp=yes ], [], [] )
127 fi
128 if test "x$enable_gprofng_jp" = x; then
129 AC_MSG_WARN([ Cannot find the JDK include directory.
130 gprofng will be build without support for profiling Java applications.
131 Use --with-jdk=PATH to specify directory for the installed JDK])
132 else
133 AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling])
134 fi
135 AC_SUBST(jdk_inc)
136
137 DEBUG=
138 GCC_ENABLE([gprofng-debug], [no], [], [Enable debugging output])
139 if test "${enable_gprofng_debug}" = yes; then
140 AC_DEFINE(DEBUG, 1, [Enable debugging output.])
141 fi
142
143 # Check if linker supports --as-needed and --no-as-needed options.
144 AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
145 [bfd_cv_ld_as_needed=no
146 if $LD --help 2>/dev/null | grep as-needed > /dev/null; then
147 bfd_cv_ld_as_needed=yes
148 fi
149 ])
150
151 no_as_needed=
152 if test x"$bfd_cv_ld_as_needed" = xyes; then
153 no_as_needed='-Wl,--no-as-needed'
154 fi
155
156 AC_PATH_PROG([EXPECT], [expect])
157 AC_CACHE_CHECK([for Tcl supporting try/catch], [ac_cv_libctf_tcl_try],
158 [ac_cv_libctf_tcl_try=`if test -z $EXPECT; then echo no; else $EXPECT << EOF
159 if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
160 EOF
161 fi`
162 ])
163 AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
164
165
166 # Generate manpages, if possible.
167 if test $cross_compiling = no; then
168 AM_MISSING_PROG(HELP2MAN, help2man)
169 build_man=true
170 else
171 build_man=false
172 fi
173 AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])
174
175 AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
176 AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
177 AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
178 AC_SUBST(GPROFNG_LIBDIR, [${libdir}])
179
180 AC_CHECK_DECLS([basename])
181 AC_CHECK_FUNCS([strsignal])
182
183 AC_SUBST(BUILD_SUBDIRS)
184
185 AC_CONFIG_FILES([Makefile src/Makefile gp-display-html/Makefile doc/Makefile])
186 AC_CONFIG_HEADERS([config.h:common/config.h.in])
187
188 AC_OUTPUT
189