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