2022-03-11 16:58:31 +08:00
|
|
|
dnl Process this file with autoconf to produce a configure script.
|
|
|
|
dnl
|
2024-01-04 19:52:08 +08:00
|
|
|
dnl Copyright (C) 2021-2024 Free Software Foundation, Inc.
|
2022-03-11 16:58:31 +08:00
|
|
|
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])
|
2022-04-07 06:31:27 +08:00
|
|
|
m4_include([../config/zlib.m4])
|
2024-05-28 17:49:47 +08:00
|
|
|
AC_INIT([gprofng], [BFD_VERSION])
|
2022-03-17 12:10:23 +08:00
|
|
|
AC_CANONICAL_TARGET
|
2022-03-11 16:58:31 +08:00
|
|
|
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
|
2022-04-10 15:59:06 +08:00
|
|
|
gl_PROG_BISON([BISON],[3.0.4])
|
2022-03-11 16:58:31 +08:00
|
|
|
|
|
|
|
AC_DISABLE_SHARED
|
|
|
|
LT_INIT
|
|
|
|
|
2023-01-18 10:53:38 +08:00
|
|
|
GPROFNG_LIBADD="-L../../libiberty -liberty"
|
|
|
|
if test "$enable_shared" = "yes"; then
|
|
|
|
GPROFNG_LIBADD="-L../../libiberty/pic -liberty"
|
|
|
|
fi
|
|
|
|
AC_SUBST(GPROFNG_LIBADD)
|
|
|
|
|
2022-03-11 16:58:31 +08:00
|
|
|
# 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])
|
2022-03-15 23:56:39 +08:00
|
|
|
ACX_PROG_CC_WARNING_OPTS([-Wno-switch], [GPROFNG_NO_SWITCH_CFLAGS])
|
2022-03-11 16:58:31 +08:00
|
|
|
gprofng_cppflags="-U_ASM"
|
|
|
|
build_collector=
|
|
|
|
build_src=
|
|
|
|
|
2022-05-05 15:08:19 +08:00
|
|
|
case "${host}" in
|
2022-03-11 16:58:31 +08:00
|
|
|
x86_64-*-linux*)
|
|
|
|
build_src=true
|
|
|
|
build_collector=true
|
|
|
|
;;
|
|
|
|
i?86-*-linux*)
|
2022-05-05 15:08:19 +08:00
|
|
|
build_src=true
|
2022-03-11 16:58:31 +08:00
|
|
|
build_collector=true
|
|
|
|
;;
|
|
|
|
aarch64-*-linux*)
|
|
|
|
build_src=true
|
|
|
|
build_collector=true
|
|
|
|
;;
|
2024-07-04 17:16:59 +08:00
|
|
|
riscv*-*-linux*)
|
|
|
|
build_src=true
|
|
|
|
build_collector=true
|
|
|
|
;;
|
2022-03-11 16:58:31 +08:00
|
|
|
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])
|
|
|
|
|
|
|
|
if test x$build_collector = xtrue; then
|
|
|
|
AC_CONFIG_SUBDIRS([libcollector])
|
|
|
|
fi
|
|
|
|
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
|
2022-03-15 06:38:04 +08:00
|
|
|
GPROFNG_BROKEN_JAVAC=no
|
2022-03-11 16:58:31 +08:00
|
|
|
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])
|
2022-03-15 06:38:04 +08:00
|
|
|
if test "x$JAVAC" != x; then
|
2023-10-04 14:53:01 +08:00
|
|
|
cat > Simple.java << EOF
|
2022-03-15 06:38:04 +08:00
|
|
|
class Simple{
|
|
|
|
public static void main(String args[]){
|
|
|
|
System.out.println("Hello Java");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
2023-10-04 14:53:01 +08:00
|
|
|
if AC_TRY_COMMAND($JAVAC Simple.java >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD); then
|
2022-03-15 06:38:04 +08:00
|
|
|
GPROFNG_BROKEN_JAVAC=no
|
|
|
|
else
|
|
|
|
GPROFNG_BROKEN_JAVAC=yes
|
|
|
|
fi
|
2023-10-04 14:53:01 +08:00
|
|
|
rm -f Simple.*
|
2022-03-15 06:38:04 +08:00
|
|
|
fi
|
2022-03-11 16:58:31 +08:00
|
|
|
fi
|
2022-03-15 06:38:04 +08:00
|
|
|
AC_SUBST(GPROFNG_BROKEN_JAVAC)
|
2022-03-11 16:58:31 +08:00
|
|
|
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
|
|
|
|
|
2022-09-14 16:11:45 +08:00
|
|
|
cat > "dummy.c" << EOF
|
|
|
|
#include <features.h>
|
|
|
|
#if defined(__UCLIBC__)
|
|
|
|
LIBC=uclibc
|
|
|
|
#elif defined(__dietlibc__)
|
|
|
|
LIBC=dietlibc
|
|
|
|
#elif defined(__GLIBC__)
|
|
|
|
LIBC=gnu
|
|
|
|
#else
|
|
|
|
#include <stdarg.h>
|
|
|
|
/* First heuristic to detect musl libc. */
|
|
|
|
#ifdef __DEFINED_va_list
|
|
|
|
LIBC=musl
|
|
|
|
#else
|
|
|
|
LIBC=gnu
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
EOF
|
|
|
|
cc_set_libc=`$CC -E "dummy.c" 2>/dev/null | grep '^LIBC=' | sed 's, ,,g'`
|
|
|
|
eval "$cc_set_libc"
|
|
|
|
if test "$LIBC" = musl; then
|
|
|
|
AC_DEFINE(__MUSL_LIBC, 1, [Build with musl-libc.])
|
|
|
|
fi
|
2023-10-04 14:53:01 +08:00
|
|
|
rm -f dummy.c
|
2022-09-14 16:11:45 +08:00
|
|
|
|
2022-03-11 16:58:31 +08:00
|
|
|
# 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`
|
|
|
|
])
|
2023-07-13 06:03:28 +08:00
|
|
|
|
|
|
|
# Only native testing and only on supported platforms:
|
|
|
|
AM_CONDITIONAL(TCL_TRY, [test "${ac_cv_libctf_tcl_try}" = yes \
|
|
|
|
-a "x${build_src}" = xtrue -a "x${build_collector}" = xtrue \
|
|
|
|
-a "x${host}" = "x${target}"])
|
2022-03-11 16:58:31 +08:00
|
|
|
|
2022-04-07 06:31:27 +08:00
|
|
|
AM_ZLIB
|
2022-03-11 16:58:31 +08:00
|
|
|
|
|
|
|
# Generate manpages, if possible.
|
2022-07-26 14:57:46 +08:00
|
|
|
build_man=false
|
2023-01-21 07:39:55 +08:00
|
|
|
build_doc=false
|
2022-03-11 16:58:31 +08:00
|
|
|
if test $cross_compiling = no; then
|
2023-01-21 07:39:55 +08:00
|
|
|
AC_CHECK_PROGS([MAKEINFO], makeinfo, [$MISSING makeinfo])
|
|
|
|
case "x$MAKEINFO" in
|
|
|
|
x | */missing\ makeinfo*)
|
2022-07-26 14:57:46 +08:00
|
|
|
AC_MSG_WARN([gprofng: makeinfo is missing. Info documentation will not be built.])
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
|
|
|
|
x*\ [[1-5]].*|x*\ 6.[[0-4]].* )
|
|
|
|
AC_MSG_WARN([gprofng: $MAKEINFO is too old. Info documentation will not be built.])
|
|
|
|
MAKEINFO="@echo $MAKEINFO is too old, 6.5 or newer required; true"
|
|
|
|
;;
|
2023-01-21 07:39:55 +08:00
|
|
|
x* ) build_doc=true ;;
|
2022-07-26 14:57:46 +08:00
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
AC_SUBST(MAKEINFO)
|
2022-03-11 16:58:31 +08:00
|
|
|
fi
|
|
|
|
AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])
|
2023-01-21 07:39:55 +08:00
|
|
|
AM_CONDITIONAL([BUILD_DOC], [test x$build_doc = xtrue])
|
2022-03-11 16:58:31 +08:00
|
|
|
|
2024-05-03 09:29:28 +08:00
|
|
|
AC_PATH_PROG([BASH], [bash])
|
|
|
|
AC_SUBST([BASH])
|
|
|
|
|
2022-03-11 16:58:31 +08:00
|
|
|
AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
|
|
|
|
AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
|
2022-03-15 23:56:39 +08:00
|
|
|
AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS)
|
|
|
|
AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
|
2022-03-11 16:58:31 +08:00
|
|
|
AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
|
|
|
|
|
|
|
|
AC_CHECK_DECLS([basename])
|
2022-03-15 23:21:56 +08:00
|
|
|
AC_CHECK_FUNCS(clock_gettime strsignal)
|
2022-03-11 16:58:31 +08:00
|
|
|
|
2022-03-18 23:45:34 +08:00
|
|
|
clock_gettime_link=
|
|
|
|
# At least for glibc, clock_gettime is in librt. But don't
|
|
|
|
# pull that in if it still doesn't give us the function we want. This
|
|
|
|
# test is copied from libgomp, and modified to not link in -lrt as
|
|
|
|
# we're using this for test timing only.
|
|
|
|
if test "$ac_cv_func_clock_gettime" = no; then
|
|
|
|
AC_CHECK_LIB(rt, clock_gettime,
|
|
|
|
[CLOCK_GETTIME_LINK=-lrt
|
|
|
|
AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
|
|
|
|
[Define to 1 if you have the `clock_gettime' function.])])
|
|
|
|
fi
|
|
|
|
AC_SUBST(CLOCK_GETTIME_LINK)
|
|
|
|
|
2022-03-11 16:58:31 +08:00
|
|
|
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
|
|
|
|
|