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