configure: regroup and expand C compiler checks
[lttng-ust.git] / configure.ac
index 9b6a3f1ceeb5e49eb80e19fa39faf5c7692a808f..685e6fe496bcbf5c298d20fff48d2d1e9b3801b0 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,27 +46,75 @@ 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])
-AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
-AM_CONDITIONAL([HAVE_CXX], [test "$HAVE_CXX11" = "1"])
 
-# Check if the compiler 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])])
+
+# Enable available system extensions and LFS support
+AC_USE_SYSTEM_EXTENSIONS
+AC_SYS_LARGEFILE
+
+# 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])])
+
+# Make sure we have pthread support
+AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])])
+
+# 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_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_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
+AC_CHECK_TYPES([ptrdiff_t])
+
+
+##                     ##
+## 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"])
 
-AS_IF([test "x${ax_cv_sys_weak_alias}" = "xno"], [
-       AC_MSG_ERROR([Your platform doesn't support weak symbols.])
-])
 
 # Checks for programs.
 AM_PROG_AR
@@ -108,31 +159,6 @@ AS_IF([test "x$enable_shared" = "xyes"], [
        AC_MSG_ERROR([LTTng-UST requires shared libraries to be enabled])
 ])
 
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_INLINE
-AC_TYPE_INT8_T
-AC_TYPE_INT16_T
-AC_TYPE_INT32_T
-AC_TYPE_INT64_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_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])])
-
 # Checks for library functions.
 AC_FUNC_CHOWN
 AC_FUNC_FORK
@@ -415,11 +441,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,
@@ -440,7 +461,7 @@ AS_IF([test "x$man_pages_opt" = "xyes"], [
        AC_PATH_PROG([XMLTO], [xmlto], [no])
 
        AS_IF([test "x$ASCIIDOC" = "xno" || test "x$XMLTO" = "xno"], [
-               AS_IF([test "x$in_git_repo" = "xyes"], [
+               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
@@ -466,6 +487,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)
 
@@ -480,13 +511,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
@@ -539,21 +575,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)
@@ -597,7 +644,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.026398 seconds and 4 git commands to generate.