configure: Introduce macro ae_in_git_repo
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 19 Mar 2021 19:29:18 +0000 (15:29 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 18 Nov 2021 18:49:18 +0000 (13:49 -0500)
This is part of an effort to standardize our autotools setup across
projects to simplify maintenance.

Change-Id: I03cb700240b24bbd7146f40b6634db11fe1d17c3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5272
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
configure.ac
m4/ae_in_git_repo.m4 [new file with mode: 0644]

index bf6c5471aeacd77de44f35b40f5bf0afbce5d50a..ca24ee79f7e25bb4c7ebb592236ac3b4691b0661 100644 (file)
@@ -204,17 +204,12 @@ AC_CHECK_PROGS([FOLD], [fold])
 AC_CHECK_PROGS([ASCIIDOC], [asciidoc])
 AC_CHECK_PROGS([XMLTO], [xmlto])
 
-# 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"])
-
 # check for bison
 AC_PROG_YACC
 AX_PROG_BISON_VERSION([2.5], [have_bison=yes])
 
 AS_IF([test "x$have_bison" != "xyes"], [
-  AS_IF([test "x$in_git_repo" = "xyes"], [
+  AE_IF_IN_GIT_REPO([
     AC_MSG_FAILURE([dnl
 Bison >= 2.4 is required when building from the Git repository. You can
 set the YACC variable to override automatic detection.
@@ -237,7 +232,7 @@ AC_PROG_LEX([noyywrap])
 AX_PROG_FLEX_VERSION([2.5.35], [have_flex=yes])
 
 AS_IF([test "x$have_flex" != "xyes"], [
-  AS_IF([test "x$in_git_repo" = "xyes"], [
+  AE_IF_IN_GIT_REPO([
     AC_MSG_FAILURE([dnl
 Flex >= 2.5.35 is required when building from the Git repository. You can
 set the LEX variable to override automatic detection.
@@ -601,7 +596,7 @@ warn_prebuilt_man_pages=no
 
 AE_IF_FEATURE_ENABLED([man-pages], [
   AS_IF([test "x$ASCIIDOC" = "x" || test "x$XMLTO" = "x"], [
-    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 asciixmlto are required because we were asked
@@ -950,8 +945,8 @@ PPRINT_SUBTITLE([Documentation])
 # man pages build enabled/disabled
 m4_pushdef([build_man_pages_msg], [Build and install man pages])
 
-AS_IF([test "x$enable_man_pages" != "xno"], [
-  AS_IF([test "x$in_git_repo" = "xyes"], [
+AE_IF_FEATURE_ENABLED([man-pages], [
+  AE_IF_IN_GIT_REPO([
     PPRINT_PROP_BOOL([build_man_pages_msg], 1)
   ], [
     AS_IF([test "x$have_asciidoc_xmlto" = "xyes"], [
diff --git a/m4/ae_in_git_repo.m4 b/m4/ae_in_git_repo.m4
new file mode 100644 (file)
index 0000000..2e370fb
--- /dev/null
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: MIT
+#
+# Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+#
+# ae_in_git_repo.m4 -- Check if we are building from the git repo
+#
+# The cache variable for this test is `ae_cv_in_git_repo`.
+#
+# AE_IF_IN_GIT_REPO(ACTION-IF-TRUE, [ACTION-IF-FALSE])
+# ---------------------------------------------------------------------------
+AC_DEFUN([AE_IF_IN_GIT_REPO], [
+  AC_CACHE_VAL([ae_cv_in_git_repo], [
+
+      dnl We're in the Git repository; the `bootstrap` file
+      dnl is not distributed in tarballs
+      AS_IF([test -f "$srcdir/bootstrap"],
+        [ae_cv_in_git_repo=yes],
+        [ae_cv_in_git_repo=no])
+  ])
+
+  AS_IF([test "x$ae_cv_in_git_repo" = "xyes"], [dnl
+    $1
+  ], [: dnl
+    $2
+  ])
+])
This page took 0.025988 seconds and 4 git commands to generate.