about summary refs log tree commit diff
path: root/configure.ac
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2019-07-03T02·28+0200
committerNiklas Hambüchen <mail@nh2.me>2019-07-03T02·32+0200
commit82b7f0e840983879a510245903ff7c917276f65d (patch)
treea623023dd02f41b74265c248405cd005f7a32457 /configure.ac
parentcd8bc06e8786018ddb16cea4cb10971b63d0efd2 (diff)
autoconf: Implement release tarball detection. Fixes #257.
This should finally allow us to address all cases of build errors due to
differences between release tarballs and building from git.

See also https://github.com/NixOS/nix/issues/506#issuecomment-507312587
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac27
1 files changed, 20 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac
index 1e3a8091cd52..8bc14d476d57 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,6 +5,19 @@ AC_CONFIG_AUX_DIR(config)
 
 AC_PROG_SED
 
+# Detect building from release tarballs (we need less dependencies then)
+# by checking for the `.dist-files` file present only in release tarballs
+# (created in release.nix).
+# For example, we don't need to build the manual or run bison/flex
+# parser generators for release tarballs, as those have them pre-generated.
+AC_MSG_CHECKING([whether we are building from a release tarball (.dist-files existence)])
+if test -f .dist-files; then
+  AC_MSG_RESULT(yes; will not require tools that are not needed for building from release tarballs)
+  building_from_release_tarball=yes;
+else
+  AC_MSG_RESULT(no)
+fi
+
 # Construct a Nix system name (like "i686-linux").
 AC_CANONICAL_HOST
 AC_MSG_CHECKING([for the canonical Nix system name])
@@ -119,14 +132,13 @@ if test -z "$$1"; then
 fi
 ])
 
-# Note: Usage of `AC_PATH_PROG(..., ..., false)` indicates that this program
-# is not required in all cases. (e.g. not when building from a release tarball).
-# The use of `false` isn't ideal, because when used somewhere in the build it
-# will silently fail without error message; this should be improved.
 NEED_PROG(bash, bash)
 NEED_PROG(patch, patch)
-AC_PATH_PROG(flex, flex, false)
-AC_PATH_PROG(bison, bison, false)
+if test "x$building_from_release_tarball" != x"yes"; then
+  # Parser generators are pre-built in release tarballs.
+  NEED_PROG(flex, flex)
+  NEED_PROG(bison, bison)
+fi
 NEED_PROG(sed, sed)
 NEED_PROG(tar, tar)
 NEED_PROG(bzip2, bzip2)
@@ -260,7 +272,8 @@ AC_ARG_ENABLE(doc-gen, AC_HELP_STRING([--disable-doc-gen],
   doc_generate=$enableval, doc_generate=yes)
 AC_SUBST(doc_generate)
 
-if test "$doc_generate" = yes; then
+# The manual is pre-generated in release tarballs.
+if test "$doc_generate" = yes && test "x$building_from_release_tarball" != x"yes"; then
   # Programs required to build the manual
   NEED_PROG(xmllint, xmllint)
   NEED_PROG(xsltproc, xsltproc)