configure: regroup program checks
[lttng-ust.git] / configure.ac
index d46f8f5f75106fe5060ad4c3a5afca1b3dc8c0ff..998981ac1ec90bed41f74f189027761428baa0be 100644 (file)
@@ -1,41 +1,44 @@
-# SPDX-License-Identifier: LGPL-2.1-only
-
-dnl Version infos
-m4_define([V_MAJOR], [2])
-m4_define([V_MINOR], [13])
-m4_define([V_PATCH], [0])
-m4_define([V_EXTRA], [pre])
-m4_define([V_NAME], [[Codename TBD]])
-m4_define([V_DESC], [[Description TBD]])
-
-m4_define([V_STRING], [V_MAJOR.V_MINOR.V_PATCH])
-m4_ifdef([V_EXTRA], [m4_append([V_STRING], [-V_EXTRA])])
-
-AC_PREREQ([2.69])
-AC_INIT([lttng-ust], V_STRING, [mathieu dot desnoyers at efficios dot com], [], [https://lttng.org])
-
-dnl Substitute minor/major/patchlevel version numbers
-AC_SUBST([MAJOR_VERSION], [V_MAJOR])
-AC_SUBST([MINOR_VERSION], [V_MINOR])
-AC_SUBST([PATCHLEVEL_VERSION], [V_PATCH])
+dnl SPDX-License-Identifier: LGPL-2.1-only
+dnl
+dnl Copyright (C) 2021 EfficiOS, Inc.
+dnl
+dnl Process this file with autoconf to produce a configure script.
+
+
+# Project version information
+m4_define([ust_version_major], [2])
+m4_define([ust_version_minor], [13])
+m4_define([ust_version_patch], [0])
+m4_define([ust_version_dev_stage], [-pre])
+m4_define([ust_version], ust_version_major[.]ust_version_minor[.]ust_version_patch[]ust_version_dev_stage)
+m4_define([ust_version_name], [[Codename TBD]])
+m4_define([ust_version_description], [[Description TBD]])
+
+# Library version information of "liblttng-ust"
+# Following the numbering scheme proposed by libtool for the library version
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+m4_define([ust_lib_version_current], [1])
+m4_define([ust_lib_version_revision], [0])
+m4_define([ust_lib_version_age], [0])
+m4_define([ust_lib_version], ust_lib_version_current[:]ust_lib_version_revision[:]ust_lib_version_age)
 
+# Library version information of "liblttng-ust-ctl"
 # Following the numbering scheme proposed by libtool for the library version
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-# This is the library version of liblttng-ust.
-m4_define([UST_LIB_V_MAJOR], [1])
-m4_define([UST_LIB_V_MINOR], [0])
-m4_define([UST_LIB_V_PATCH], [0])
+m4_define([ust_ctl_lib_version_current], [5])
+m4_define([ust_ctl_lib_version_revision], [0])
+m4_define([ust_ctl_lib_version_age], [0])
+m4_define([ust_ctl_lib_version], ust_ctl_lib_version_current[:]ust_ctl_lib_version_revision[:]ust_ctl_lib_version_age)
 
-AC_SUBST([LTTNG_UST_LIBRARY_VERSION], [UST_LIB_V_MAJOR:UST_LIB_V_MINOR:UST_LIB_V_PATCH])
-AC_DEFINE([CONFIG_LTTNG_UST_LIBRARY_VERSION_MAJOR], [UST_LIB_V_MAJOR], [Major SONAME number of the ust library])
-# note: remember to update tracepoint.h dlopen() to match this version
-# number. TODO: eventually automate by exporting the major number.
 
-# This is the library version of liblttng-ust-ctl, used internally by
-# liblttng-ust, lttng-sessiond, and lttng-consumerd.
-AC_SUBST([LTTNG_UST_CTL_LIBRARY_VERSION], [5:0:0])
+##                     ##
+## Autoconf base setup ##
+##                     ##
 
-AC_CONFIG_HEADERS([include/config.h include/lttng/ust-config.h])
+AC_PREREQ([2.69])
+AC_INIT([lttng-ust],[ust_version],[mathieu dot desnoyers at efficios dot com],[],[https://lttng.org])
+
+AC_CONFIG_HEADERS([include/config.h include/lttng/ust-config.h include/lttng/ust-version.h])
 AC_CONFIG_AUX_DIR([config])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_SRCDIR([include/lttng/tracepoint.h])
@@ -43,97 +46,135 @@ AC_CONFIG_SRCDIR([include/lttng/tracepoint.h])
 AC_CANONICAL_TARGET
 AC_CANONICAL_HOST
 
+
+##                     ##
+## Automake base setup ##
+##                     ##
+
 AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip tar-ustar nostdinc -Wall -Wno-portability -Werror])
 AM_MAINTAINER_MODE([enable])
 
 # Enable silent rules by default
 AM_SILENT_RULES([yes])
 
-# Checks for C compiler
-AC_USE_SYSTEM_EXTENSIONS
-AC_SYS_LARGEFILE
+
+##                   ##
+## C compiler checks ##
+##                   ##
+
+# Choose the C compiler
 AC_PROG_CC
 # AC_PROG_CC_STDC was merged in AC_PROG_CC in autoconf 2.70
 m4_version_prereq([2.70], [], [AC_PROG_CC_STDC])
-AC_PROG_CXX
-AX_CXX_COMPILE_STDCXX([11])
-RW_PROG_CXX_WORKS
-AM_CONDITIONAL([HAVE_CXX], [test "x$rw_cv_prog_cxx_works" = "xyes"])
-
-# Check if the compiler support weak symbols
-AX_SYS_WEAK_ALIAS
 
-AS_IF([test "x${ax_cv_sys_weak_alias}" = "xno"], [
-       AC_MSG_ERROR([Your platform doesn't support weak symbols.])
-])
+# Make sure the C compiler supports C99
+AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])])
 
-# Checks for programs.
-AM_PROG_AR
-AC_PROG_SED
-AC_PROG_GREP
-AC_PROG_LN_S
-AC_PROG_MKDIR_P
-AC_PROG_MAKE_SET
-AC_CHECK_PROG([CMAKE], [cmake])
-AM_CONDITIONAL([HAVE_CMAKE], [test "x$CMAKE" != "x"])
-
-# libtool link_all_deplibs fixup. See http://bugs.lttng.org/issues/321.
-AC_ARG_ENABLE([libtool-linkdep-fixup], [
-AS_HELP_STRING([--disable-libtool-linkdep-fixup], [disable the libtool fixup for linking all dependent libraries (link_all_deplibs)])
-], [
-       libtool_fixup=$enableval
-], [
-       libtool_fixup=yes
-])
+# Enable available system extensions and LFS support
+AC_USE_SYSTEM_EXTENSIONS
+AC_SYS_LARGEFILE
 
-AS_IF([test "x$libtool_fixup" = "xyes"], [
-       libtool_m4="$srcdir/m4/libtool.m4"
-       libtool_flag_pattern=".*link_all_deplibs\s*,\s*\$1\s*)"
-       AC_MSG_CHECKING([for occurence(s) of link_all_deplibs = no in $libtool_m4])
-       libtool_flag_pattern_count=$(grep -c "$libtool_flag_pattern\s*=\s*no" $libtool_m4)
+# Make sure the C compiler supports __attribute__
+AX_C___ATTRIBUTE__
+AS_IF([test "x$ax_cv___attribute__" != "xyes"],
+  [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
 
-       AS_IF([test $libtool_flag_pattern_count -ne 0], [
-       AC_MSG_RESULT([$libtool_flag_pattern_count])
-       AC_MSG_WARN([the detected libtool will not link all dependencies, forcing link_all_deplibs = unknown])
-               $SED -i "s/\($libtool_flag_pattern\)\s*=\s*no/\1=unknown/g" $libtool_m4
-       ], [
-               AC_MSG_RESULT([none])
-       ])
-])
-LT_INIT([disable-static])
+# Make sure we have pthread support
+AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])])
 
-AC_MSG_CHECKING([whether shared libraries are enabled])
-AS_IF([test "x$enable_shared" = "xyes"], [
-       AC_MSG_RESULT([yes])
-], [
-       AC_MSG_RESULT([no])
-       AC_MSG_ERROR([LTTng-UST requires shared libraries to be enabled])
-])
+# Make sure the C compiler supports weak symbols
+AX_SYS_WEAK_ALIAS
+AS_IF([test "x$ax_cv_sys_weak_alias" = "xno"],
+  [AC_MSG_ERROR([Your platform doesn't support weak symbols.])])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
-AC_TYPE_INT8_T
+AC_C_TYPEOF
 AC_TYPE_INT16_T
 AC_TYPE_INT32_T
 AC_TYPE_INT64_T
+AC_TYPE_INT8_T
 AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_TYPE_SSIZE_T
 AC_TYPE_UID_T
-AC_TYPE_UINT8_T
 AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
 AC_CHECK_TYPES([ptrdiff_t])
 
-AX_C___ATTRIBUTE__
-AS_IF([test "x$ax_cv___attribute__" = "xyes"],
-       [:],
-       [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
 
-AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
+##                     ##
+## C++ compiler checks ##
+##                     ##
+
+# Find an optional C++11 compiler without GNU extensions (-std=c++11)
+AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
+AM_CONDITIONAL([HAVE_CXX], [test "$HAVE_CXX11" = "1"])
+
+
+##               ##
+## Header checks ##
+##               ##
+
+AC_HEADER_STDBOOL
+AC_CHECK_HEADERS([ \
+  arpa/inet.h \
+  dlfcn.h \
+  fcntl.h \
+  float.h \
+  limits.h \
+  linux/perf_event.h \
+  locale.h \
+  stddef.h \
+  sys/socket.h \
+  sys/time.h \
+  wchar.h \
+])
+
+# Check for dlinfo() by testing for RTLD_DI_LINKMAP in dlfcn.h
+AS_IF([test "x$ac_cv_header_dlfcn_h" = "xyes"], [
+  AC_CHECK_DECL([RTLD_DI_LINKMAP], [], [], [[#include <dlfcn.h>]])
+])
+
+
+##                 ##
+## Programs checks ##
+##                 ##
+
+AM_PROG_AR
+AC_PROG_SED
+AC_PROG_GREP
+AC_PROG_LN_S
+AC_PROG_MKDIR_P
+AC_PROG_MAKE_SET
+AC_CHECK_PROGS([ASCIIDOC], [asciidoc])
+AC_CHECK_PROGS([CMAKE], [cmake])
+AC_CHECK_PROGS([FOLD], [fold])
+AC_CHECK_PROGS([XMLTO], [xmlto])
+
+AM_PATH_PYTHON([2.7], [], [PYTHON=""])
+
+AX_PROG_JAVAC
+AX_PROG_JAVA
+AX_PROG_JAR
+
+# Initialize and configure libtool
+LT_INIT([disable-static])
+
+
+AM_CONDITIONAL([HAVE_CMAKE], [test "x$CMAKE" != "x"])
+
+AC_MSG_CHECKING([whether shared libraries are enabled])
+AS_IF([test "x$enable_shared" = "xyes"], [
+       AC_MSG_RESULT([yes])
+], [
+       AC_MSG_RESULT([no])
+       AC_MSG_ERROR([LTTng-UST requires shared libraries to be enabled])
+])
 
 # Checks for library functions.
 AC_FUNC_CHOWN
@@ -172,20 +213,6 @@ LTTNG_PTHREAD_GETNAME_NP
 # AC_FUNC_MALLOC causes problems when cross-compiling.
 #AC_FUNC_MALLOC
 
-# Checks for header files.
-AC_HEADER_STDBOOL
-AC_CHECK_HEADERS([ \
-       arpa/inet.h \
-       fcntl.h \
-       float.h \
-       limits.h \
-       locale.h \
-       stddef.h \
-       sys/socket.h \
-       sys/time.h \
-       wchar.h \
-])
-
 # Set architecture specific options
 AS_CASE([$host_cpu],
        [i[[3456]]86], [],
@@ -237,16 +264,6 @@ AC_CHECK_LIB([$libdl_name], [dlmopen],
        [AC_DEFINE([HAVE_DLMOPEN], [1])]
 )
 
-# Check for dlfcn.h
-AC_CHECK_HEADER([dlfcn.h])
-AS_IF([test "x${ac_cv_header_dlfcn_h}" = "xyes"], [
-       AC_CHECK_DECLS([RTLD_DI_LINKMAP], [], [], [
-               #include <dlfcn.h>
-       ])
-], [
-       ac_cv_have_decl_RTLD_DI_LINKMAP="no"
-])
-
 AM_CONDITIONAL([ENABLE_UST_DL], [test "x${ac_cv_have_decl_RTLD_DI_LINKMAP}" = "xyes"])
 
 # Require URCU >= 0.12 for DEFINE_URCU_TLS_INIT
@@ -273,17 +290,7 @@ AS_IF([test "x$enable_numa" = "xyes"], [
 ])
 AM_CONDITIONAL([ENABLE_NUMA], [test "x$have_libnuma" = "xyes"])
 
-# optional linux/perf_event.h
-AC_CHECK_HEADERS([linux/perf_event.h], [have_perf_event=yes], [])
-
-# Perf event counters are supported on all architectures supported by
-# perf, using the read system call as fallback.
-AM_CONDITIONAL([HAVE_PERF_EVENT], [test "x$have_perf_event" = "xyes"])
-
-AH_TEMPLATE([HAVE_PERF_EVENT], ["Perf event integration via perf_event.h"])
-AS_IF([test "x$have_perf_event" = "xyes"], [
-       AC_DEFINE([HAVE_PERF_EVENT], [1])
-])
+AM_CONDITIONAL([HAVE_PERF_EVENT], [test "x$ac_cv_header_linux_perf_event_h" = "xyes"])
 
 # Check for JNI header files if requested
 AC_ARG_ENABLE([jni-interface], [
@@ -326,9 +333,6 @@ AM_CONDITIONAL([ENABLE_JAVA_AGENT_WITH_LOG4J], [test "x$java_agent_log4j" = "xye
 
 AS_IF([test "x$jni_interface" = "xyes" || test "x$java_agent_jul" = "xyes" || test "x$java_agent_log4j" = "xyes"], [
        AX_JAVA_OPTIONS
-       AX_PROG_JAVAC
-       AX_PROG_JAVA
-       AX_PROG_JAR
        AC_ARG_VAR([CLASSPATH], [Java class path])
 
        AX_JNI_INCLUDE_DIR
@@ -360,9 +364,6 @@ AS_HELP_STRING([--enable-python-agent], [build the LTTng UST Python agent [defau
        python_agent=$enableval
 ], [:])
 AM_CONDITIONAL([ENABLE_PYTHON_AGENT], [test "x$python_agent" = "xyes"])
-AS_IF([test "x$python_agent" = "xyes"], [
-       AM_PATH_PYTHON([2.7])
-])
 
 # sdt.h integration
 AC_ARG_WITH([sdt], [
@@ -401,8 +402,7 @@ AS_HELP_STRING([--with-lttng-system-rundir], [Location of the system directory w
 AC_DEFINE_UNQUOTED([LTTNG_SYSTEM_RUNDIR], ["$lttng_system_rundir"],
                [LTTng system runtime directory])
 
-AC_CHECK_PROG([ENABLE_GEN_TP_EXAMPLES], [python], ["yes"])
-AM_CONDITIONAL([ENABLE_GEN_TP_EXAMPLES], [test "x$ENABLE_GEN_TP_EXAMPLES" = "xyes"])
+AM_CONDITIONAL([ENABLE_GEN_TP_EXAMPLES], [test "x$PYTHON" != "x"])
 
 # Enable building examples
 AC_ARG_ENABLE(
@@ -417,11 +417,6 @@ AC_ARG_ENABLE(
 
 AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" != "xno"])
 
-# Set $IN_GIT_REPO if we're in the Git repository; the `bootstrap` file
-# is not distributed in tarballs.
-AS_IF([test -f "$srcdir/bootstrap"], [in_git_repo=yes], [in_git_repo=no])
-AM_CONDITIONAL([IN_GIT_REPO], [test "x$in_git_repo" = "xyes"])
-
 # Enable building man pages (user's intention).
 AC_ARG_ENABLE(
        man-pages,
@@ -438,11 +433,8 @@ have_asciidoc_xmlto=no
 warn_prebuilt_man_pages=no
 
 AS_IF([test "x$man_pages_opt" = "xyes"], [
-       AC_PATH_PROG([ASCIIDOC], [asciidoc], [no])
-       AC_PATH_PROG([XMLTO], [xmlto], [no])
-
-       AS_IF([test "x$ASCIIDOC" = "xno" || test "x$XMLTO" = "xno"], [
-               AS_IF([test "x$in_git_repo" = "xyes"], [
+       AS_IF([test "x$ASCIIDOC" = "x" || test "x$XMLTO" = "x"], [
+               AE_IF_IN_GIT_REPO([
                        # This is an error because we're in the Git repo, which
                        # means the man pages are not already generated for us,
                        # thus asciidoc/xmlto are required because we were asked
@@ -468,6 +460,16 @@ they will not be installed.
 AM_CONDITIONAL([ENABLE_MAN_PAGES], [test "x$man_pages_opt" != "xno"])
 AM_CONDITIONAL([HAVE_ASCIIDOC_XMLTO], [test "x$have_asciidoc_xmlto" = "xyes"])
 
+
+# Defined in include/lttng/ust-version.h
+AC_DEFINE([LTTNG_UST_MAJOR_VERSION], ust_version_major, [LTTng UST major version])
+AC_DEFINE([LTTNG_UST_MINOR_VERSION], ust_version_minor, [LTTng UST minor version])
+AC_DEFINE([LTTNG_UST_PATCHLEVEL_VERSION], ust_version_patch, [LTTng UST patch version])
+AC_DEFINE([LTTNG_UST_VERSION], ["]ust_version["], [LTTng UST version string])
+AC_DEFINE([LTTNG_UST_LIB_SONAME_MAJOR], [ust_lib_version_current], [Major SONAME number of liblttng-ust])
+AC_DEFINE([LTTNG_UST_CTL_LIB_SONAME_MAJOR], [ust_ctl_lib_version_current], [Major SONAME number of liblttng-ust-ctl])
+
+
 AM_CFLAGS="-Wall $URCU_CFLAGS $PTHREAD_CFLAGS"
 AC_SUBST(AM_CFLAGS)
 
@@ -482,13 +484,18 @@ AC_SUBST(AM_CPPFLAGS)
 
 AC_SUBST(JNI_CPPFLAGS)
 
+
+##                                     ##
+## Output files generated by configure ##
+##                                     ##
+
+# List of files to be generated from '.in' templates by AC_OUTPUT
 AC_CONFIG_FILES([
        Makefile
        doc/Makefile
        doc/examples/Makefile
        doc/man/Makefile
        include/Makefile
-       include/lttng/ust-version.h
        snprintf/Makefile
        libcounter/Makefile
        libmsgpack/Makefile
@@ -541,21 +548,32 @@ AC_CONFIG_FILES([
 AC_OUTPUT
 
 
-#
-# Mini-report on what will be built.
-#
+##                                    ##
+## Mini-report on what will be built. ##
+##                                    ##
 
 PPRINT_INIT
 PPRINT_SET_INDENT(1)
 PPRINT_SET_TS(38)
 
 AS_ECHO
-AS_ECHO("${PPRINT_COLOR_BLDBLU}LTTng-ust $PACKAGE_VERSION \"V_NAME\"$PPRINT_COLOR_RST")
+AS_IF([test -n "ust_version_name"], [
+  AS_ECHO("${PPRINT_COLOR_BLDBLU}LTTng-ust $PACKAGE_VERSION \"ust_version_name\"$PPRINT_COLOR_RST")
+], [
+  AS_ECHO("${PPRINT_COLOR_BLDBLU}LTTng-ust $PACKAGE_VERSION")
+])
+
 AS_ECHO
 
-AS_ECHO("V_DESC")
+AS_IF([test -n "ust_version_description"], [
+  AS_IF([test -n "$FOLD"], [
+    AS_ECHO("`AS_ECHO("ust_version_description") | $FOLD -s`")
+  ], [
+    AS_ECHO("ust_version_description")
+  ])
+  AS_ECHO
+])
 
-AS_ECHO
 PPRINT_SUBTITLE([System])
 
 PPRINT_PROP_STRING([Target architecture], $host_cpu)
@@ -583,7 +601,7 @@ PPRINT_PROP_BOOL_CUSTOM([JNI interface (JNI)], $value, [use --enable-jni-interfa
 test "x$python_agent" = xyes && value=1 || value=0
 PPRINT_PROP_BOOL_CUSTOM([Python agent], $value, [use --enable-python-agent])
 
-test "x$have_perf_event" = "xyes" && value=1 || value=0
+test "x$ac_cv_header_linux_perf_event_h" = "xyes" && value=1 || value=0
 PPRINT_PROP_BOOL_CUSTOM([Perf event integration], $value)
 
 test "x$enable_numa" = xyes && value=1 || value=0
@@ -599,7 +617,7 @@ PPRINT_PROP_BOOL([Build and install examples], $value, $PPRINT_COLOR_SUBTITLE)
 m4_pushdef([build_man_pages_msg], [Build and install man pages])
 
 AS_IF([test "x$man_pages_opt" != "xno"], [
-       AS_IF([test "x$in_git_repo" = "xyes"], [
+       AE_IF_IN_GIT_REPO([
                PPRINT_PROP_BOOL([build_man_pages_msg], 1, $PPRINT_COLOR_SUBTITLE)
        ], [
                AS_IF([test "x$have_asciidoc_xmlto" = "xyes"], [
This page took 0.028416 seconds and 4 git commands to generate.