]> Git — Sourcephile - ocaml/libocaml_make.git/blob - libocaml.GNUmakefile
Correction : gère l’absence de test/ .
[ocaml/libocaml_make.git] / libocaml.GNUmakefile
1 export VERSION:=$(patsubst v%,%,$(shell \
2 test -e VERSION && cat VERSION || { \
3 test -e .git && which git >/dev/null && \
4 git describe --tags --match 'v[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]' --always || \
5 TZ=UTC date +'v%Y-%m-%d'; }))
6
7 .PHONY: all all/%
8 .DEFAULT_GOAL: all
9 all: src/all
10 all/%: src/all/%
11
12
13 # ----------
14 # gitmodules
15 # ----------
16 .gitmodules= \
17 $(patsubst %,$(if $1,$1/)%,$(shell \
18 $(if $1,cd $1 &&) \
19 if test -e .gitmodules && which git >/dev/null; \
20 then git config -f .gitmodules --get-regexp submodule'\..*\.'path | \
21 cut -d ' ' -f 2; fi))
22 gitmodules:=$(.gitmodules)
23
24 define gitmodules/.git
25 $1/.git:
26 git submodule update --init --recursive -- $$(@:/.git=)
27 cd $$(@:/.git=) && git checkout -f HEAD && git clean -dfx
28 $1/%: $1/.git
29
30 endef
31 $(if $(wildcard .git), \
32 $(foreach m,$(gitmodules), \
33 $(eval $(call gitmodules/.git,$m))))
34
35 # ------
36 # debian
37 # ------
38 .PHONY: debian debian/%
39 .PRECIOUS: lib/tool/pkg/debian/GNUmakefile
40 debian: debian/build
41 debian/%: export GIT_DCH_FLAGS+=--new-version \
42 $(shell printf %s '$(VERSION)' | sed -e s/-/./ -e s/-/./)
43 debian/%: lib/tool/pkg/debian/GNUmakefile
44 $(MAKE) -f $< $(patsubst debian/%,%,$@)
45
46 # ---
47 # doc
48 # ---
49 .PHONY: doc doc/%
50 .PRECIOUS: lib/tool/asciidoc/GNUmakefile
51 doc: doc/all
52 doc/%: export A2X_FLAGS+=-aname="$(package)"
53 doc/%: export A2X_FLAGS+=-aversion="$(VERSION)"
54 doc/%: export MANLEVELS+=$(package) 3cm
55 doc/%: export SRCDIR:=doc
56 doc/%: lib/tool/asciidoc/GNUmakefile
57 $(MAKE) -f $< $(patsubst doc/%,%,$@)
58 c clean: doc/clean
59
60 # -------
61 # archive
62 # -------
63 .PHONY: archive/%
64 .PRECIOUS: lib/tool/pkg/archive/GNUmakefile
65 archive/%: lib/tool/pkg/archive/GNUmakefile
66 $(MAKE) -f $< $(patsubst archive/%,%,$@)
67 c clean: archive/clean
68
69 # ---
70 # src
71 # ---
72 .PHONY: c clean cc cleaner b byte n native src
73 .PRECIOUS: lib/libocaml/make/GNUmakefile
74 src/%: export SRCDIR:=src
75 src/%: lib/libocaml/make/GNUmakefile
76 $(MAKE) -f $< $@
77 src: src/all
78 c clean: src/clean
79 cc cleaner: src/cleaner
80 b byte: src/byte
81 n native: src/native
82 b/% byte/%: src/byte/%
83
84 n/% native/%: src/native/%
85
86
87 # ----
88 # test
89 # ----
90 ifneq ($(wildcard test/),)
91 .PHONY: test test/%
92 .PHONY: tc tcc tb tn txb txn t test
93 test/%: export SRCDIR:=test
94 test/%: lib/libocaml/make/GNUmakefile
95 $(MAKE) -f $< $@
96 c clean: test/clean
97 cc cleaner: test/cleaner
98 test/byte: src/byte
99 test/native: src/native
100 tc: test/clean
101 tcc: test/cleaner
102 tb: test/byte
103 tn: test/native
104 txb: test/exec-byte
105 txn: test/exec-native
106 t test: test/all
107 endif
108
109 # -------
110 # install
111 # -------
112 .PHONY: u uninstall i install
113 install+=$(or $(filter i,$(MAKECMDGOALS)),$(filter install,$(MAKECMDGOALS)))
114 ifneq ($(install),)
115 include src/configure.make
116 endif
117 u uninstall:
118 ocamlfind remove \
119 $(if $(DESTDIR),-destdir $(DESTDIR)) \
120 $(OCAMLFIND_REMOVE_FLAGS) \
121 $(package)
122 i install: uninstall
123 $(if $(DESTDIR),mkdir -p $(DESTDIR))
124 ocamlfind install \
125 $(if $(DESTDIR),-destdir $(DESTDIR)) \
126 $(OCAMLFIND_INSTALL_FLAGS) \
127 $(package) \
128 src/META \
129 $(OCAMLFIND_INSTALL_FILES) \