configure: Introduce macro ae_in_git_repo
[lttng-ust.git] / configure.ac
index 9b6a3f1ceeb5e49eb80e19fa39faf5c7692a808f..1f80ffe0a952667b98e3beb10597a930e1d217a1 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.
+##                     ##
+## Autoconf base setup ##
+##                     ##
 
-# 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])
+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])
+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,6 +46,11 @@ 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])
 
@@ -415,11 +423,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 +443,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 +469,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 +493,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 +557,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 +626,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.024508 seconds and 4 git commands to generate.