Skip to content

Commit

Permalink
Determine build directory intelligently, based on current branch
Browse files Browse the repository at this point in the history
  • Loading branch information
billsacks committed May 21, 2018
1 parent 0be5662 commit eb9e1d0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# Minimal makefile for Sphinx documentation
#

# Possible ways to set the build directory:
# (1) Set BUILDDIR from the command line
# (2) Let BUILDDIR be determined as $(BUILDREPO)/cism-in-cesm/$(VERSION)
# (2a) Set both BUILDREPO and VERSION directly on the command line
# (2b) Set BUILDREPO on the command line, let VERSION be auto-determined,
# based on the current git branch name.
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = cismdoc
SOURCEDIR = source
BUILDDIR = build

ifndef BUILDDIR
# If version isn't set on the command-line, then we set it here, by
# getting the current git branch name.
VERSION ?= $(shell git symbolic-ref --short -q HEAD)
ifeq ($(VERSION),)
$(error Cannot determine version based on git branch; set VERSION on the command line)
endif
BUILDDIR = $(BUILDREPO)/cism-in-cesm/$(VERSION)
$(info Using build directory: $(BUILDDIR))
endif

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -17,4 +33,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

0 comments on commit eb9e1d0

Please sign in to comment.