configure: Introduce macro ae_in_git_repo
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 22 Mar 2021 18:44:35 +0000 (14:44 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 23 Mar 2021 15:14:56 +0000 (11:14 -0400)
This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: Ifffade15ac4a15823be8ab1b6c8232624a89ab7c
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
configure.ac
m4/ae_in_git_repo.m4 [new file with mode: 0644]

index d5ea3ee94708b7d9b592067b6963391ea11320e4..1f80ffe0a952667b98e3beb10597a930e1d217a1 100644 (file)
@@ -423,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,
@@ -448,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
@@ -631,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"], [
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.025685 seconds and 4 git commands to generate.