]> Git — Sourcephile - ocaml/libocaml_make.git/blob - libocaml.GNUmakefile
Ajout : libocaml.GNUmakefile .
[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 archive/%
64 .PRECIOUS: lib/tool/pkg/archive/GNUmakefile
65 archive %.archive: lib/tool/pkg/archive/GNUmakefile
66 $(MAKE) -f $< $@
67 archive/%: lib/tool/pkg/archive/GNUmakefile
68 $(MAKE) -f $< $(patsubst archive/%,%,$@)
69 c clean: archive/clean
70
71 # ---
72 # src
73 # ---
74 .PHONY: c clean cc cleaner b byte n native src
75 .PRECIOUS: lib/libocaml/make/GNUmakefile
76 src/%: export SRCDIR:=src
77 src/%: lib/libocaml/make/GNUmakefile
78 $(MAKE) -f $< $@
79 src: src/all
80 c clean: src/clean
81 cc cleaner: src/cleaner
82 b byte: src/byte
83 n native: src/native
84 b/% byte/%: src/byte/%
85
86 n/% native/%: src/native/%
87
88
89 # ----
90 # test
91 # ----
92 .PHONY: test test/%
93 .PHONY: tc tcc tb tn txb txn t test
94 test/%: export SRCDIR:=test
95 test/%: lib/libocaml/make/GNUmakefile
96 $(MAKE) -f $< $@
97 c clean: test/clean
98 cc cleaner: test/cleaner
99 test/byte: src/byte
100 test/native: src/native
101 tc: test/clean
102 tcc: test/cleaner
103 tb: test/byte
104 tn: test/native
105 txb: test/exec-byte
106 txn: test/exec-native
107 t test: test/all
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) \