Skip to content

Commit a282216

Browse files
committed
configure: when in git repo, use $(git describe) instead of VERSION
1 parent 2cb1a54 commit a282216

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ beforedepend:: src/glob_lexer.ml
175175

176176
configure: Makefile.config src/ocamlbuild_config.ml
177177

178-
Makefile.config src/ocamlbuild_config.ml:
178+
Makefile.config src/ocamlbuild_config.ml: configure.make
179179
$(MAKE) -f configure.make $@
180180

181181
clean::

configure.make

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ OCAMLBUILD_LIBDIR ?= \
4545
# OCAMLBUILD_{PREFIX,BINDIR,LIBDIR}, which are the ones that should
4646
# generally be used, as the shorted names {PREFIX,BINDIR,LIBDIR}.
4747

48+
# if run from a git development repository,
49+
# prefer $(git describe --always --dirty)
50+
# to the VERSION file. This trick comes from Daniel Bünzli.
51+
VERSION ?= \
52+
$(or $(shell git describe --always --dirty 2>/dev/null),\
53+
$(shell ocaml scripts/cat.ml VERSION))
54+
4855
ifeq ($(ARCH), none)
4956
OCAML_NATIVE ?= false
5057
else
@@ -87,5 +94,5 @@ src/ocamlbuild_config.ml:
8794
echo 'let so = "$(SO)"'; \
8895
echo 'let ext_dll = "$(EXT_DLL)"'; \
8996
echo 'let exe = "$(EXE)"'; \
90-
echo 'let version = "$(shell ocaml scripts/cat.ml VERSION)"'; \
97+
echo 'let version = "$(VERSION)"'; \
9198
) > $@

0 commit comments

Comments
 (0)