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