Skip to content

Commit

Permalink
GNUmakefile: Check for .git/ and git before trying to run git
Browse files Browse the repository at this point in the history
Only have make consider the rule and variable definitions using
git if

  * the build happens in a git source tree and
  * git has been found or the user has explictly set GIT

This prevents git from being run when it cannot succeed and
thus avoids error messages at build time like

    fatal: not a git repository (or any parent up to mount point /)
    Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

when building outside a git source tree or

    /bin/sh: describe: command not found

when git is not in PATH.

Fixes: #10
  • Loading branch information
ndim committed Feb 6, 2020
1 parent b27273a commit afe0d29
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ uninstall:
# Development helpers
########################################################################

# Only have make deal with those variables and rules if this is a git
# repo, and if the git executable has been found.
GIT_INFO_EXCLUDE = $(firstword $(wildcard .git/info/exclude))
ifneq ($(strip $(GIT_INFO_EXCLUDE)),)
ifdef GIT

# List all references to documentation in the git repo
.PHONY: refs
refs:
Expand All @@ -443,6 +449,9 @@ PACKAGE_TARBASE := $(PACKAGE_TARNAME)-$(shell $(GIT) describe --tags | $(SED) 's
dist:
$(GIT) archive --format=tar.gz --verbose --prefix=$(PACKAGE_TARBASE)/ --output=$(PACKAGE_TARBASE).tar.gz HEAD

endif
endif


########################################################################
# End of GNUmakefile
Expand Down

0 comments on commit afe0d29

Please sign in to comment.