blob: c05e98192f36007893069c7f02e27d1f90127d14 [file] [log] [blame]
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Copyright (C) 2021 Free Software Foundation, Inc.
dnl
dnl This file is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; see the file COPYING3. If not see
dnl <http://www.gnu.org/licenses/>.
m4_include([../bfd/version.m4])
AC_INIT([gprofng], BFD_VERSION)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([subdir-objects])
AM_MAINTAINER_MODE
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_RANLIB
AM_PROG_AR
AC_DISABLE_SHARED
LT_INIT
GPROFNG_LIBADD="-L../../libiberty -liberty"
if test "$enable_shared" = "yes"; then
GPROFNG_LIBADD="-L../../libiberty/pic -liberty"
fi
AC_SUBST(GPROFNG_LIBADD)
# Figure out what compiler warnings we can enable.
# See config/warnings.m4 for details.
ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
ACX_PROG_CC_WARNING_OPTS([-Wall], [gprofng_cflags])
ACX_PROG_CC_WARNING_OPTS([-Wno-format-truncation], [GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS])
ACX_PROG_CC_WARNING_OPTS([-Wno-switch], [GPROFNG_NO_SWITCH_CFLAGS])
gprofng_cppflags="-U_ASM"
build_collector=
build_src=
# This is annoying: it means we have to pass --enable-shared explicitly to
# get gprofng, while the configure default is supposed to be that shared libs
# are on by default. But as long as libiberty has code like this, so must
# we...
case "${target}" in
x86_64-*-linux*)
build_src=true
build_collector=true
;;
i?86-*-linux*)
build_collector=true
build_collector=true
;;
aarch64-*-linux*)
build_src=true
build_collector=true
;;
esac
AC_ARG_ENABLE(gprofng-tools,
AS_HELP_STRING([--disable-gprofng-tools], [do not build gprofng/src directory]),
build_src=$enableval)
AM_CONDITIONAL([BUILD_COLLECTOR], [test x$build_collector = xtrue])
AM_CONDITIONAL([BUILD_SRC], [test x$build_src = xtrue])
run_tests=false
if test x$build_collector = xtrue; then
AC_CONFIG_SUBDIRS([libcollector])
if test x${host} = x${target}; then
run_tests=true
fi
fi
AM_CONDITIONAL([RUN_TESTS], [test x$run_tests = xtrue])
AX_PTHREAD
# Specify a location for JDK
enable_gprofng_jp=
jdk_inc=
AC_ARG_WITH(jdk,
[AS_HELP_STRING([--with-jdk=PATH],
[specify prefix directory for installed JDK.])])
if test "x$with_jdk" != x; then
jdk_inc="-I$with_jdk/include -I$with_jdk/include/linux"
enable_gprofng_jp=yes
else
AC_PATH_PROG([JAVAC], [javac], [javac])
if test -f $JAVAC; then
x=`readlink -f $JAVAC`
x=`dirname $x`
x=`dirname $x`
if ! test -f $x/include/jni.h; then
x=`dirname $x`
fi
if test -f $x/include/jni.h; then
jdk_inc="-I$x/include -I$x/include/linux"
enable_gprofng_jp=yes
fi
fi
fi
if test "x$enable_gprofng_jp" = x; then
AC_PATH_PROG([JAVA], [java], [java])
if test -f $JAVA; then
x=`readlink -f $JAVA`
x=`dirname $x`
x=`dirname $x`
if ! test -f $x/include/jni.h; then
x=`dirname $x`
fi
if test -f $x/include/jni.h; then
jdk_inc="-I$x/include -I$x/include/linux"
enable_gprofng_jp=yes
fi
fi
fi
if test "x$enable_gprofng_jp" = x; then
AC_CHECK_HEADER([jni.h], [ enable_gprofng_jp=yes ], [], [] )
fi
if test "x$enable_gprofng_jp" = x; then
AC_MSG_WARN([ Cannot find the JDK include directory.
gprofng will be build without support for profiling Java applications.
Use --with-jdk=PATH to specify directory for the installed JDK])
else
AC_DEFINE(GPROFNG_JAVA_PROFILING, 1, [Enable java profiling])
fi
AC_SUBST(jdk_inc)
DEBUG=
GCC_ENABLE([gprofng-debug], [no], [], [Enable debugging output])
if test "${enable_gprofng_debug}" = yes; then
AC_DEFINE(DEBUG, 1, [Enable debugging output.])
fi
# Check if linker supports --as-needed and --no-as-needed options.
AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
[bfd_cv_ld_as_needed=no
if $LD --help 2>/dev/null | grep as-needed > /dev/null; then
bfd_cv_ld_as_needed=yes
fi
])
no_as_needed=
if test x"$bfd_cv_ld_as_needed" = xyes; then
no_as_needed='-Wl,--no-as-needed'
fi
AC_PATH_PROG([EXPECT], [expect])
AC_CACHE_CHECK([for Tcl supporting try/catch], [ac_cv_libctf_tcl_try],
[ac_cv_libctf_tcl_try=`if test -z $EXPECT; then echo no; else $EXPECT << EOF
if @<:@llength @<:@info commands try@:>@@:>@ then { puts yes } else { puts no }
EOF
fi`
])
AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
# Generate manpages, if possible.
if test $cross_compiling = no; then
AM_MISSING_PROG(HELP2MAN, help2man)
build_man=true
else
build_man=false
fi
AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])
AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS)
AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
AC_SUBST(GPROFNG_LIBDIR, [${libdir}])
AC_CHECK_DECLS([basename])
AC_CHECK_FUNCS(clock_gettime strsignal)
AC_SUBST(BUILD_SUBDIRS)
AC_CONFIG_FILES([Makefile src/Makefile gp-display-html/Makefile doc/Makefile])
AC_CONFIG_HEADERS([config.h:common/config.h.in])
AC_OUTPUT