Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 223 lines (177 sloc) 7.464 kB
fccc685 Initial open-source release
MLstate authored
1 #!/usr/bin/make
2
3 # [ Warning ] don't use make to solve dependencies !!
4 #
5 # we rely on ocamlbuild which already handles them ; every rule should
6 # call it only once (no recursion)
7 #
8 # More info in build/Makefile.bld
9
10 include config.make
11
12 INSTALL ?= cp -u -L
13
14 .PHONY: default
15 default: all
16
17 include build/Makefile.bld
18
19 OPAOPT += "--rebuild"
20
21 export
22
23 ##
24 ## STANDARD TARGETS
25 ##
26
27 .PHONY: all
28 all: $(MYOCAMLBUILD)
29 $(OCAMLBUILD) $(call target-tools,$(ALL_TOOLS)) opa-packages.stamp
30 @$(call copy-tools,$(ALL_TOOLS))
31
32 .PHONY: build
33 build: all
34
35 .PHONY: runtime-libs
36 runtime-libs: $(MYOCAMLBUILD)
37 $(OCAMLBUILD) runtime-libs.stamp
38
39 $(BUILD_DIR)/bin/opa: $(MYOCAMLBUILD)
40 $(OCAMLBUILD) opa-packages.stamp $(target-tool-opa-bin)
41 @$(copy-tool-opa-bin)
42 @utils/install.sh --quiet --dir $(PWD)/$(BUILD_DIR) --ocaml-prefix $(OCAMLLIB)/../..
43
44 .PHONY: opa
45 opa: $(BUILD_DIR)/bin/opa
46
47 .PHONY: opa-packages
48 opa-packages: $(MYOCAMLBUILD)
49 $(OCAMLBUILD) opa-packages.stamp
50
51 .PHONY: stdlib
52 stdlib: opa-packages
53
54 DISTRIB_TOOLS = opa-bin opadoc opa-plugin-builder-bin opa-plugin-browser-bin bslServerLib.ml opa-db-server opa-db-tool opa-cloud
55
56 .PHONY: distrib
57 distrib: $(MYOCAMLBUILD)
58 $(OCAMLBUILD) $(call target-tools,$(DISTRIB_TOOLS)) opa-packages.stamp
59 @$(call copy-tools,$(DISTRIB_TOOLS))
60
61 ##
62 ## INSTALLATION
63 ##
64
65 .PHONY: install*
66
67 STDLIB_DIR = $(PREFIX)/lib/opa/stdlib
68 define install-package
69 @echo "Installing into $(STDLIB_DIR)/$*.opx\r\c"
70 @mkdir -p "$(STDLIB_DIR)/$*.opx/_build"
71 @find "$(BUILD_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_DIR)/$*.opx/" \;
72 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.a "$(STDLIB_DIR)/$*.opx/_build/"
73 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmi "$(STDLIB_DIR)/$*.opx/_build/"
74 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmxa "$(STDLIB_DIR)/$*.opx/_build/"
75 endef
76
77 OPA_PACKAGES := $(shell cd stdlib && ./all_packages.sh)
78
79 # Rules installing everything that has been compiled
80 #
81 # This doesn't rely on install rules generated by Makefile.bld ;
82 # instead it assumes that what you want to install has been properly
83 # put in $(BUILD_DIR)/{bin,lib/opa,share/opa}.
84 #
85 # This is the case of tools (because of Makefile.bld),
86 # and of opa runtime libs (because build rules copy them
87 # to $(BUILD_DIR)/lib/opa/static).
88 # This doesn't install the other libs though, use target install-libs
89 # for that
90
91 install-packageopt-%:
92 $(if $(wildcard $(BUILD_DIR)/$*.opx/_build/*),$(install-package))
93
94 install-package-%:
95 $(install-package)
96
97 install-packages: $(addprefix install-packageopt-,$(OPA_PACKAGES))
98 @echo "Installation to $(STDLIB_DIR) done."
99
100 install-all-packages: $(addprefix install-package-,$(OPA_PACKAGES))
101 @echo "Installation to $(STDLIB_DIR) done."
102
103 install-bin:
104 @echo "Installing into $(PREFIX)/bin\r\c"
105 @mkdir -p $(PREFIX)/bin
106 @$(if $(wildcard $(BUILD_DIR)/bin/*),$(INSTALL) -r $(BUILD_DIR)/bin/* $(PREFIX)/bin)
107 @utils/install.sh --quiet --dir $(PREFIX) --ocamllib $(OCAMLLIB) --ocamlopt $(OCAMLOPT)
108 @echo "Installation to $(PREFIX)/bin done."
109
110 install-lib:
111 @echo "Installing into $(PREFIX)/lib/opa\r\c"
112 @mkdir -p $(PREFIX)/lib/opa
113 @$(if $(wildcard $(BUILD_DIR)/lib/opa/*),$(INSTALL) -r $(BUILD_DIR)/lib/opa/* $(PREFIX)/lib/opa/)
114 @echo "Installation to $(PREFIX)/lib/opa done."
115
116 install-share:
117 @echo "Installing into $(PREFIX)/share/opa\r\c"
118 @mkdir -p $(PREFIX)/share/opa
119 @$(if $(wildcard $(BUILD_DIR)/share/opa/*),$(INSTALL) -r $(BUILD_DIR)/share/opa/* $(PREFIX)/share/opa/)
120 @echo "Installation to $(PREFIX)/share/opa done."
121
122 install-doc:
123 @echo "Installing into $(PREFIX)/share/doc/opa\r\c"
124 @if [ -d $(BUILD_DIR)/opadoc/doc/ ]; then \
125 mkdir -p $(PREFIX)/share/doc/opa/api; \
126 $(INSTALL) -r $(BUILD_DIR)/opadoc/doc/* $(PREFIX)/share/doc/opa/api; \
127 fi
128 @echo "Installation to $(PREFIX)/share/doc/opa done."
129
130 install: install-bin install-lib install-share install-packages install-doc
131 @echo "Installation under prefix $(PREFIX) done."
132
133 .PHONY: uninstall
134 uninstall:
135 rm -rf $(PREFIX)/lib/opa
136 @[ ! -d $(PREFIX)/lib ] || [ -n "`ls -A $(PREFIX)/lib`" ] || rmdir $(PREFIX)/lib
137 rm -rf $(PREFIX)/share/opa
138 rm -rf $(PREFIX)/share/doc/opa
139 @[ ! -d $(PREFIX)/share ] || [ -n "`ls -A $(PREFIX)/share`" ] || rmdir $(PREFIX)/share
140 $(foreach file,$(BUILD_DIR)/bin/*,rm -f $(PREFIX)/bin/$(notdir $(file));)
141 @utils/install.sh --uninstall --dir $(PREFIX)
142 @[ ! -d $(PREFIX)/bin ] || [ -n "`ls -A $(PREFIX)/bin`" ] || rmdir $(PREFIX)/bin
143 @echo "Uninstall done."
144
145 # Install our ocamlbuild-generation engine
146 install-bld:
147 @mkdir -p $(PREFIX)/bin
148 @echo "#!/bin/bash -ue" > $(PREFIX)/bin/bld
149 @chmod 755 $(PREFIX)/bin/bld
150 @echo "BLDDIR=$(PREFIX)/share/opa/bld $(PREFIX)/share/opa/bld/gen_myocamlbuild.sh" >> $(PREFIX)/bin/bld
151 @echo "_build/myocamlbuild -no-plugin -j 6 \"\$$@\"" >> $(PREFIX)/bin/bld
152 @mkdir -p $(PREFIX)/share/opa/bld
153 @$(INSTALL) build/gen_myocamlbuild.sh build/myocamlbuild_*fix.ml config.sh config.mli config.ml\
154 $(PREFIX)/share/opa/bld
155
156 # Install an opa wrapper with different stdlib and options (for some backwards-compatibility)
157 install-qmlflat: # depends on opabsl_for_compiler, but we don't want to run ocamlbuild twice
158 @mkdir -p $(PREFIX)/bin $(PREFIX)/share/opa/mlstatebsl
159 @$(INSTALL) $(BUILD_DIR)/opabsl/mlstatebsl/opabslgen_*.opa $(PREFIX)/share/opa/mlstatebsl
160 @echo "#!/bin/bash -ue" > $(PREFIX)/bin/qmlflat
161 @chmod 755 $(PREFIX)/bin/qmlflat
162 @echo 'exec opa --no-stdlib --no-server --no-cps --no-closure --no-ei --no-constant-sharing --no-undot --separated off --value-restriction disabled --no-warn duplicateL0 --no-warn typer.warncoerce --no-warn unused --no-discard-of-unused-stdlib --no-warn pattern $$(if ! grep -qE "(^| )--no-stdlib( |$$)" <<<"$$*"; then echo $(shell sed "s%^[^# ]\+%$(PREFIX)/share/opa/mlstatebsl/opabslgen_&%; t OK; d; :OK" opabsl/mlstatebsl/bsl-sources); fi) "$$@"' \
163 >> $(PREFIX)/bin/qmlflat
164
165 # installs some dev tools on top of the normal install; these should not change often
c2f0a5d [feature] make: installing more dev tools in the install-all target
Louis Gesbert authored
166 install-all: install install-bld install-qmlflat utils/maxmem
fccc685 Initial open-source release
MLstate authored
167 @$(INSTALL) platform_helper.sh $(PREFIX)/bin/
c2f0a5d [feature] make: installing more dev tools in the install-all target
Louis Gesbert authored
168 @$(INSTALL) utils/maxmem $(PREFIX)/bin/
169 @rm utils/maxmem
170 @$(INSTALL) utils/plotmem $(PREFIX)/bin/
fccc685 Initial open-source release
MLstate authored
171
172 ##
173 ## DOCUMENTATION
174 ##
175 # (in this section, multiple calls to ocamlbuild are tolerated)
176
177 .PHONY: doc.jsbsl
178 doc.jsbsl: $(MYOCAMLBUILD)
179 $(OCAMLBUILD) $@/index.html
180
181 # this rules provides the doc.html target (from Makefile.bld)
182 # the sed are just there to help sorting by filename-within-directory
183 .PHONY: doc.odocl
184 doc.odocl:
185 echo $(foreach lib,$(ALL_LIBS),$(lib-cmi-$(lib):%.cmi=%)) \
186 | sed 's# \+#\n#g' \
187 | sed 's#\(.*\)/\([^/]*\)#\1 \2#' \
188 | sort -k 2 -u \
189 | sed 's#\(.*\) \([^ ]*\)#\1/\2#' \
190 >$@
191
192 .PHONY: packages-api
193 packages-api: $(MYOCAMLBUILD)
194 OPAOPT="$(OPAOPT) --rebuild --api" $(OCAMLBUILD) opa-packages.stamp
195
196 .PHONY: opadoc/doc
197 opadoc/doc: opadoc packages-api
198 @mkdir -p $(BUILD_DIR)/$@
199 $(BUILD_DIR)/bin/opadoc -o $(BUILD_DIR)/$@ $(BUILD_DIR)/stdlib
200
201 .PHONY: book
202 book:
203 $(MAKE) -C doc/book
204
205 .PHONY: examples
206 examples: $(MYOCAMLBUILD)
207 $(OCAMLBUILD) $(call target-tools,opa-bin opa-plugin-builder-bin) opa-packages.stamp
208 $(call copy-tools,opa-bin opa-plugin-builder-bin)
209 MLSTATELIBS=`pwd`/$(BUILD_DIR) \
210 OPA="`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-bin -I `pwd`/$(BUILD_DIR)" \
211 OPA_PLUGIN_BUILDER=`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-plugin-builder-bin \
212 $(MAKE) -C doc/book examples
213
214 .PHONY: book-clean
215 book-clean:
216 $(MAKE) -C doc/book clean
217
218 .PHONY: clean
219 clean: book-clean
220
221 .PHONY: doc
222 doc: doc.html opadoc/doc book
Something went wrong with that request. Please try again.