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