PR29991, MicroMIPS flag erased after align directives
[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-2023 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 m4_include([../config/zlib.m4])
21 AC_INIT([gprofng], BFD_VERSION)
22 AC_CANONICAL_TARGET
23 AM_INIT_AUTOMAKE([subdir-objects])
24 AM_MAINTAINER_MODE
25
26 AC_USE_SYSTEM_EXTENSIONS
27 AC_PROG_CC
28 AC_PROG_CXX
29 AC_PROG_INSTALL
30 AC_PROG_RANLIB
31 AM_PROG_AR
32 gl_PROG_BISON([BISON],[3.0.4])
33 if test x$BISON = "x:"; then
34 AC_MSG_ERROR([Building gprofng requires bison 3.0.4 or later.])
35 fi
36
37 AC_DISABLE_SHARED
38 LT_INIT
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 ACX_PROG_CC_WARNING_OPTS([-Wno-switch], [GPROFNG_NO_SWITCH_CFLAGS])
46 gprofng_cppflags="-U_ASM"
47 build_collector=
48 build_src=
49
50 case "${host}" in
51 x86_64-*-linux*)
52 build_src=true
53 build_collector=true
54 ;;
55 i?86-*-linux*)
56 build_src=true
57 build_collector=true
58 ;;
59 aarch64-*-linux*)
60 build_src=true
61 build_collector=true
62 ;;
63 esac
64 AC_ARG_ENABLE(gprofng-tools,
65 AS_HELP_STRING([--disable-gprofng-tools], [do not build gprofng/src directory]),
66 build_src=$enableval)
67
68 AM_CONDITIONAL([BUILD_COLLECTOR], [test x$build_collector = xtrue])
69 AM_CONDITIONAL([BUILD_SRC], [test x$build_src = xtrue])
70
71 run_tests=false
72 if test x$build_collector = xtrue; then
73 AC_CONFIG_SUBDIRS([libcollector])
74 if test x${host} = x${target}; then
75 run_tests=true
76 fi
77 fi
78 AM_CONDITIONAL([RUN_TESTS], [test x$run_tests = xtrue])
79 AX_PTHREAD
80
81 # Specify a location for JDK
82 enable_gprofng_jp=
83 jdk_inc=
84 AC_ARG_WITH(jdk,
85 [AS_HELP_STRING([--with-jdk=PATH],
86 [specify prefix directory for installed JDK.])])
87
88 if test "x$with_jdk" != x; then
89 jdk_inc="-I$with_jdk/include -I$with_jdk/include/linux"
90 enable_gprofng_jp=yes
91 else
92 AC_PATH_PROG([JAVAC], [javac], [javac])
93 if test -f $JAVAC; then
94 x=`readlink -f $JAVAC`
95 x=`dirname $x`
96 x=`dirname $x`
97 if ! test -f $x/include/jni.h; then
98 x=`dirname $x`
99 fi
100 if test -f $x/include/jni.h; then
101 jdk_inc="-I$x/include -I$x/include/linux"
102 enable_gprofng_jp=yes
103 fi
104 fi
105 fi
106 if test "x$enable_gprofng_jp" = x; then
107 AC_PATH_PROG([JAVA], [java], [java])
108 if test -f $JAVA; then
109 x=`readlink -f $JAVA`
110 x=`dirname $x`
111 x=`dirname $x`
112 if ! test -f $x/include/jni.h; then
113 x=`dirname $x`
114 fi
115 if test -f $x/include/jni.h; then
116 jdk_inc="-I$x/include -I$x/include/linux"
117 enable_gprofng_jp=yes
118 fi
119 fi
120 fi
121 if test "x$enable_gprofng_jp" = x; then
122 AC_CHECK_HEADER([jni.h], [ enable_gprofng_jp=yes ], [], [] )
123 fi
124 GPROFNG_BROKEN_JAVAC=no
125 if test "x$enable_gprofng_jp" = x; then
126 AC_MSG_WARN([ Cannot find the JDK include directory.
127 gprofng will be build without support for profiling Java applications.
128 Use --with-jdk=PATH to specify directory for the installed JDK])
129 else
130 AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling])
131 if test "x$JAVAC" != x; then
132 cat > configtest.java << EOF
133 class Simple{
134 public static void main(String args[]){
135 System.out.println("Hello Java");
136 }
137 }
138 EOF
139 if AC_TRY_COMMAND($JAVAC configtest.java >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD); then
140 GPROFNG_BROKEN_JAVAC=no
141 else
142 GPROFNG_BROKEN_JAVAC=yes
143 fi
144 rm -f configtest.*
145 fi
146 fi
147 AC_SUBST(GPROFNG_BROKEN_JAVAC)
148 AC_SUBST(jdk_inc)
149
150 DEBUG=
151 GCC_ENABLE([gprofng-debug], [no], [], [Enable debugging output])
152 if test "${enable_gprofng_debug}" = yes; then
153 AC_DEFINE(DEBUG, 1, [Enable debugging output.])
154 fi
155
156 cat > "dummy.c" << EOF
157 #include <features.h>
158 #if defined(__UCLIBC__)
159 LIBC=uclibc
160 #elif defined(__dietlibc__)
161 LIBC=dietlibc
162 #elif defined(__GLIBC__)
163 LIBC=gnu
164 #else
165 #include <stdarg.h>
166 /* First heuristic to detect musl libc. */
167 #ifdef __DEFINED_va_list
168 LIBC=musl
169 #else
170 LIBC=gnu
171 #endif
172 #endif
173 EOF
174 cc_set_libc=`$CC -E "dummy.c" 2>/dev/null | grep '^LIBC=' | sed 's, ,,g'`
175 eval "$cc_set_libc"
176 if test "$LIBC" = musl; then
177 AC_DEFINE(__MUSL_LIBC, 1, [Build with musl-libc.])
178 fi
179
180
181 # Check if linker supports --as-needed and --no-as-needed options.
182 AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
183 [bfd_cv_ld_as_needed=no
184 if $LD --help 2>/dev/null | grep as-needed > /dev/null; then
185 bfd_cv_ld_as_needed=yes
186 fi
187 ])
188
189 no_as_needed=
190 if test x"$bfd_cv_ld_as_needed" = xyes; then
191 no_as_needed='-Wl,--no-as-needed'
192 fi
193
194 AC_PATH_PROG([EXPECT], [expect])
195 AC_CACHE_CHECK([for Tcl supporting try/catch], [ac_cv_libctf_tcl_try],
196 [ac_cv_libctf_tcl_try=`if test -z $EXPECT; then echo no; else $EXPECT << EOF
197 if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
198 EOF
199 fi`
200 ])
201 AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
202
203 AM_ZLIB
204
205 # Generate manpages, if possible.
206 build_man=false
207 if test $cross_compiling = no; then
208 AM_MISSING_PROG(HELP2MAN, help2man)
209 AC_CHECK_PROGS([MAKEINFO], makeinfo, ["@echo makeinfo missing; true"])
210 case "$MAKEINFO" in
211 *true)
212 AC_MSG_WARN([gprofng: makeinfo is missing. Info documentation will not be built.])
213 ;;
214 *)
215 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
216 x*\ [[1-5]].*|x*\ 6.[[0-4]].* )
217 AC_MSG_WARN([gprofng: $MAKEINFO is too old. Info documentation will not be built.])
218 MAKEINFO="@echo $MAKEINFO is too old, 6.5 or newer required; true"
219 ;;
220 x* )
221 build_man=true
222 ;;
223 esac
224 ;;
225 esac
226 AC_SUBST(MAKEINFO)
227 fi
228 AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])
229
230 AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
231 AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
232 AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS)
233 AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
234 AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
235
236 AC_CHECK_DECLS([basename])
237 AC_CHECK_FUNCS(clock_gettime strsignal)
238
239 clock_gettime_link=
240 # At least for glibc, clock_gettime is in librt. But don't
241 # pull that in if it still doesn't give us the function we want. This
242 # test is copied from libgomp, and modified to not link in -lrt as
243 # we're using this for test timing only.
244 if test "$ac_cv_func_clock_gettime" = no; then
245 AC_CHECK_LIB(rt, clock_gettime,
246 [CLOCK_GETTIME_LINK=-lrt
247 AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
248 [Define to 1 if you have the `clock_gettime' function.])])
249 fi
250 AC_SUBST(CLOCK_GETTIME_LINK)
251
252 AC_SUBST(BUILD_SUBDIRS)
253
254 AC_CONFIG_FILES([Makefile src/Makefile gp-display-html/Makefile doc/Makefile])
255 AC_CONFIG_HEADERS([config.h:common/config.h.in])
256
257 AC_OUTPUT
258