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