-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
configure: META.in template with no hardcoded version number #54
base: master
Are you sure you want to change the base?
Changes from all commits
eef8e57
2cb1a54
a282216
759bd60
7638418
ec21cf4
0516b05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,6 @@ Makefile.config | |
/src/glob_lexer.ml | ||
/ocamlbuild.byte | ||
/ocamlbuild.native | ||
|
||
# generated from META.in | ||
META |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#%% see META rule in Makefile | ||
# Specification for the "ocamlbuild" library | ||
requires = "unix" | ||
version = "0.9.0" | ||
version = "%%VERSION%%" | ||
description = "ocamlbuild support library" | ||
archive(byte) = "ocamlbuildlib.cma" | ||
archive(native) = "ocamlbuildlib.cmxa" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,15 +173,28 @@ beforedepend:: src/glob_lexer.ml | |
|
||
# The config file | ||
|
||
configure: Makefile.config src/ocamlbuild_config.ml | ||
|
||
Makefile.config src/ocamlbuild_config.ml: | ||
# we mark only the 'configure' rule PHONY, | ||
# not individual CONF_FILES, as all OCamlbuild | ||
# sources depend on ocamlbuild_config.ml, | ||
# so it would rebuild from scratch each time. | ||
# | ||
# The reason for marking PHONY is to let the user | ||
# explicitly re-configure; the --version answer | ||
# depends on the state of the git repository, so | ||
# it may change at any time. | ||
.PHONY: configure | ||
|
||
CONF_FILES=Makefile.config src/ocamlbuild_config.ml | ||
configure: | ||
$(MAKE) -f configure.make $(CONF_FILES) | ||
|
||
$(CONF_FILES): | ||
$(MAKE) -f configure.make $@ | ||
|
||
clean:: | ||
rm -f Makefile.config src/ocamlbuild_config.ml | ||
rm -f $(CONF_FILES) | ||
|
||
beforedepend:: src/ocamlbuild_config.ml | ||
beforedepend:: Makefile.config | ||
|
||
# Installation | ||
|
||
|
@@ -229,14 +242,22 @@ endif | |
echo ']' >> ocamlbuild.install | ||
echo >> ocamlbuild.install | ||
|
||
install-lib-basics: | ||
install-lib-basics: META | ||
mkdir -p $(INSTALL_LIBDIR)/ocamlbuild | ||
$(CP) META src/signatures.mli $(INSTALL_LIBDIR)/ocamlbuild | ||
|
||
install-lib-basics-opam: | ||
install-lib-basics-opam: META | ||
echo ' "META"' >> ocamlbuild.install | ||
echo ' "src/signatures.mli" {"signatures.mli"}' >> ocamlbuild.install | ||
|
||
# %%FOO%% are configuration variables (only %%VERSION%% currently), | ||
# and #%% comments are removed before installation | ||
META: META.in VERSION | ||
@cat META.in \ | ||
| sed s/%%VERSION%%/$$(cat VERSION)/ META.in \ | ||
| grep -v "#%%.*" \ | ||
> META | ||
|
||
install-lib-byte: | ||
mkdir -p $(INSTALL_LIBDIR)/ocamlbuild | ||
$(CP) $(INSTALL_LIB) $(INSTALL_LIBDIR)/ocamlbuild | ||
|
@@ -261,7 +282,7 @@ else | |
install-lib: install-lib-basics install-lib-byte | ||
endif | ||
|
||
install-lib-findlib: | ||
install-lib-findlib: META | ||
ifeq ($(OCAML_NATIVE), true) | ||
ocamlfind install ocamlbuild \ | ||
META src/signatures.mli $(INSTALL_LIB) $(INSTALL_LIB_OPT) | ||
|
@@ -339,6 +360,40 @@ ifeq ($(CHECK_IF_PREINSTALLED), true) | |
fi | ||
endif | ||
|
||
check-release: | ||
@echo "This Makefile rule checks that:" | ||
@echo "- the VERSION and 'git describe' values are consistent" | ||
@echo "- NEXT_RELEASE does not appear in the sources anymore" | ||
@echo "For any more serious release checking, see howto/release.adoc." | ||
@echo "(We only add output below when a check fails.)" | ||
@echo | ||
@$(MAKE) --silent check-release-VERSION-git-describe | ||
@$(MAKE) --silent check-release-NEXT_RELEASE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need recursive make? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use recursive make when I want to force ordering. My understanding of make semantics is that targets given in a single call may be executed in any order in presence of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use dependencies to enforce ordering. Or just use
|
||
|
||
check-release-VERSION-git-describe: | ||
ifeq ($(shell echo $(shell cat VERSION)),\ | ||
$(shell git describe --tags --always --dirty)) | ||
@ | ||
else | ||
@echo "Bad: VERSION ($(shell cat VERSION)) and"\ | ||
"'git describe --tags --always --dirty'"\ | ||
"($(shell git describe --tags --always --dirty))"\ | ||
"disagree." | ||
endif | ||
|
||
|
||
NEXT_RELEASE_EXCLUDE="(Makefile|howto)" | ||
NEXT_RELEASE_FILES=$(shell git grep --files-with-matches "NEXT_RELEASE" \ | ||
| grep -v -E $(NEXT_RELEASE_EXCLUDE)) | ||
check-release-NEXT_RELEASE: | ||
ifeq ($(strip $(NEXT_RELEASE_FILES)),) | ||
@ | ||
else | ||
@echo "The following occurrences of NEXT_RELEASE"\ | ||
"should probably be fixed:" | ||
@git grep "NEXT_RELEASE" -- $(NEXT_RELEASE_FILES) | ||
endif | ||
|
||
# The generic rules | ||
|
||
.SUFFIXES: .ml .mli .cmo .cmi .cmx | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,13 @@ OCAMLBUILD_LIBDIR ?= \ | |
# OCAMLBUILD_{PREFIX,BINDIR,LIBDIR}, which are the ones that should | ||
# generally be used, as the shorted names {PREFIX,BINDIR,LIBDIR}. | ||
|
||
# if run from a git development repository, | ||
# prefer $(git describe --always --dirty) | ||
# to the VERSION file. This trick comes from Daniel Bünzli. | ||
VERSION ?= \ | ||
$(or $(shell git describe --tags --always --dirty 2>/dev/null),\ | ||
$(shell ocaml scripts/cat.ml VERSION)) | ||
|
||
ifeq ($(ARCH), none) | ||
OCAML_NATIVE ?= false | ||
else | ||
|
@@ -76,6 +83,10 @@ Makefile.config: | |
echo "LIBDIR=$(OCAMLBUILD_LIBDIR)"; \ | ||
) > $@ | ||
|
||
# the configuration file depends on the git environment, | ||
# so it should be rebuilt each time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of rebuilding each time you can do that:
And make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However since it is in |
||
.PHONY: src/ocamlbuild_config.ml | ||
|
||
src/ocamlbuild_config.ml: | ||
(echo "(* This file was generated from ../configure.make *)"; \ | ||
echo ;\ | ||
|
@@ -87,5 +98,5 @@ src/ocamlbuild_config.ml: | |
echo 'let so = "$(SO)"'; \ | ||
echo 'let ext_dll = "$(EXT_DLL)"'; \ | ||
echo 'let exe = "$(EXE)"'; \ | ||
echo 'let version = "$(shell ocaml scripts/cat.ml VERSION)"'; \ | ||
echo 'let version = "$(VERSION)"'; \ | ||
) > $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The META should be created during compilation not during installation, since the installation can be done with
sudo
and it is inconvenient to create root file in the user directory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can take this commit bobot/ocamlbuild@a575494 if you want.