export VERSION:=$(patsubst v%,%,$(shell \ test -e VERSION && cat VERSION || { \ test -e .git && which git >/dev/null && \ git describe --tags --match 'v[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' --always || \ TZ=UTC date +'v%Y-%m-%d'; })) .PHONY: all all/% .DEFAULT_GOAL: all all: src/all all/%: src/all/% # ---------- # gitmodules # ---------- .gitmodules= \ $(patsubst %,$(if $1,$1/)%,$(shell \ $(if $1,cd $1 &&) \ if test -e .gitmodules && which git >/dev/null; \ then git config -f .gitmodules --get-regexp submodule'\..*\.'path | \ cut -d ' ' -f 2; fi)) gitmodules:=$(.gitmodules) define gitmodules/.git $1/.git: git submodule update --init --recursive -- $$(@:/.git=) cd $$(@:/.git=) && git checkout -f HEAD && git clean -dfx $1/%: $1/.git endef $(if $(wildcard .git), \ $(foreach m,$(gitmodules), \ $(eval $(call gitmodules/.git,$m)))) # ------ # debian # ------ .PHONY: debian debian/% .PRECIOUS: lib/tool/pkg/debian/GNUmakefile debian: debian/build debian/%: export GIT_DCH_FLAGS+=--new-version \ $(shell printf %s '$(VERSION)' | sed -e s/-/./ -e s/-/./) debian/%: lib/tool/pkg/debian/GNUmakefile $(MAKE) -f $< $(patsubst debian/%,%,$@) # --- # doc # --- .PHONY: doc doc/% .PRECIOUS: lib/tool/asciidoc/GNUmakefile doc: doc/all doc/%: export A2X_FLAGS+=-aname="$(package)" doc/%: export A2X_FLAGS+=-aversion="$(VERSION)" doc/%: export MANLEVELS+=$(package) 3cm doc/%: export SRCDIR:=doc doc/%: lib/tool/asciidoc/GNUmakefile $(MAKE) -f $< $(patsubst doc/%,%,$@) c clean: doc/clean # ------- # archive # ------- .PHONY: archive/% .PRECIOUS: lib/tool/pkg/archive/GNUmakefile archive/%: lib/tool/pkg/archive/GNUmakefile $(MAKE) -f $< $(patsubst archive/%,%,$@) c clean: archive/clean # --- # src # --- .PHONY: c clean cc cleaner b byte n native src .PRECIOUS: lib/libocaml/make/GNUmakefile src/%: export SRCDIR:=src src/%: lib/libocaml/make/GNUmakefile $(MAKE) -f $< $@ src: src/all c clean: src/clean cc cleaner: src/cleaner b byte: src/byte n native: src/native b/% byte/%: src/byte/% n/% native/%: src/native/% # ---- # test # ---- .PHONY: test test/% .PHONY: tc tcc tb tn txb txn t test test/%: export SRCDIR:=test test/%: lib/libocaml/make/GNUmakefile $(MAKE) -f $< $@ c clean: test/clean cc cleaner: test/cleaner test/byte: src/byte test/native: src/native tc: test/clean tcc: test/cleaner tb: test/byte tn: test/native txb: test/exec-byte txn: test/exec-native t test: test/all # ------- # install # ------- .PHONY: u uninstall i install install+=$(or $(filter i,$(MAKECMDGOALS)),$(filter install,$(MAKECMDGOALS))) ifneq ($(install),) include src/configure.make endif u uninstall: ocamlfind remove \ $(if $(DESTDIR),-destdir $(DESTDIR)) \ $(OCAMLFIND_REMOVE_FLAGS) \ $(package) i install: uninstall $(if $(DESTDIR),mkdir -p $(DESTDIR)) ocamlfind install \ $(if $(DESTDIR),-destdir $(DESTDIR)) \ $(OCAMLFIND_INSTALL_FLAGS) \ $(package) \ src/META \ $(OCAMLFIND_INSTALL_FILES) \