Automatic date update in version.in
[binutils-gdb.git] / gprofng / configure.ac
index 8977e8bd4bb985f6592903c79fd92f3270fa6964..e945310960289d5cb67d79f35364876c689190ce 100644 (file)
@@ -17,7 +17,9 @@ dnl along with this program; see the file COPYING3.  If not see
 dnl <http://www.gnu.org/licenses/>.
 
 m4_include([../bfd/version.m4])
+m4_include([../config/zlib.m4])
 AC_INIT([gprofng], BFD_VERSION)
+AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE([subdir-objects])
 AM_MAINTAINER_MODE
 
@@ -27,6 +29,10 @@ AC_PROG_CXX
 AC_PROG_INSTALL
 AC_PROG_RANLIB
 AM_PROG_AR
+gl_PROG_BISON([BISON],[3.0.4])
+if test x$BISON = "x:"; then
+  AC_MSG_ERROR([Building gprofng requires bison 3.0.4 or later.])
+fi
 
 AC_DISABLE_SHARED
 LT_INIT
@@ -42,22 +48,18 @@ AC_SUBST(GPROFNG_LIBADD)
 
 ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual])
 ACX_PROG_CC_WARNING_OPTS([-Wall], [gprofng_cflags])
+ACX_PROG_CC_WARNING_OPTS([-Wno-switch], [GPROFNG_NO_SWITCH_CFLAGS])
 gprofng_cppflags="-U_ASM"
 build_collector=
 build_src=
 
-# This is annoying: it means we have to pass --enable-shared explicitly to
-# get gprofng, while the configure default is supposed to be that shared libs
-# are on by default.  But as long as libiberty has code like this, so must
-# we...
-
-  case "${target}" in
+  case "${host}" in
     x86_64-*-linux*)
       build_src=true
       build_collector=true
       ;;
     i?86-*-linux*)
-      build_collector=true
+      build_src=true
       build_collector=true
       ;;
     aarch64-*-linux*)
@@ -125,13 +127,30 @@ fi
 if test "x$enable_gprofng_jp" = x; then
   AC_CHECK_HEADER([jni.h], [ enable_gprofng_jp=yes ], [], [] )
 fi
+GPROFNG_BROKEN_JAVAC=no
 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])
+    if test "x$JAVAC" != x; then
+      cat > configtest.java << EOF
+class Simple{
+  public static void main(String args[]){
+    System.out.println("Hello Java");
+  }
+}
+EOF
+      if AC_TRY_COMMAND($JAVAC conftest.java &AS_MESSAGE_LOG_FD 2>&1); then
+       GPROFNG_BROKEN_JAVAC=no
+      else
+       GPROFNG_BROKEN_JAVAC=yes
+      fi
+      rm -f configtest.*
+    fi
 fi
+AC_SUBST(GPROFNG_BROKEN_JAVAC)
 AC_SUBST(jdk_inc)
 
 DEBUG=
@@ -162,23 +181,54 @@ fi`
 ])
 AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes)
 
+AM_ZLIB
 
 # Generate manpages, if possible.
+build_man=false
 if test $cross_compiling = no; then
   AM_MISSING_PROG(HELP2MAN, help2man)
-  build_man=true
-else
-  build_man=false
+  AC_CHECK_PROGS([MAKEINFO], makeinfo, ["@echo makeinfo missing; true"])
+  case "$MAKEINFO" in
+    *true)
+      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"
+         ;;
+       x* )
+         build_man=true
+         ;;
+       esac
+      ;;
+    esac
+  AC_SUBST(MAKEINFO)
 fi
 AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue])
 
 AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}])
 AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}])
+AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS)
+AC_SUBST(GPROFNG_NO_SWITCH_CFLAGS)
 AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
-AC_SUBST(GPROFNG_LIBDIR, [${libdir}])
 
 AC_CHECK_DECLS([basename])
-AC_CHECK_FUNCS([strsignal])
+AC_CHECK_FUNCS(clock_gettime strsignal)
+
+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)
 
 AC_SUBST(BUILD_SUBDIRS)