Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 272 lines (214 sloc) 9.339 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
1321ba9 @fperrin On FreeBSD check and use gmake, use make elsewhere
fperrin authored
13 MAKE ?= $_
14 export MAKE
fccc685 Initial open-source release
MLstate authored
15
e7282e7 [enhance] make: do not rebuild opa packages if the variable is set
Louis Gesbert authored
16 ifndef NO_REBUILD_OPA_PACKAGES
8a40e70 [feature] build: support for optional libraries, enabled libnattraver…
Louis Gesbert authored
17 OPAOPT += "--rebuild"
e7282e7 [enhance] make: do not rebuild opa packages if the variable is set
Louis Gesbert authored
18 endif
8a40e70 [feature] build: support for optional libraries, enabled libnattraver…
Louis Gesbert authored
19
20 ifneq ($(HAS_CAMLIDL)$(HAS_LIBNATPMP)$(HAS_MINIUPNPC),111)
21 export DISABLED_LIBS = libnattraversal
22 endif
23
fccc685 Initial open-source release
MLstate authored
24 .PHONY: default
25 default: all
26
27 include build/Makefile.bld
28
29 export
30
31 ##
32 ## STANDARD TARGETS
33 ##
34
35 .PHONY: all
8c3019b [enhance] manpages: added target install-man to install manpages by d…
Mathieu Baudet authored
36 all: $(MYOCAMLBUILD) manpages
fccc685 Initial open-source release
MLstate authored
37 $(OCAMLBUILD) $(call target-tools,$(ALL_TOOLS)) opa-packages.stamp
38 @$(call copy-tools,$(ALL_TOOLS))
39
40 .PHONY: build
41 build: all
42
43 .PHONY: runtime-libs
44 runtime-libs: $(MYOCAMLBUILD)
45 $(OCAMLBUILD) runtime-libs.stamp
46
37c04ec [cleanup] Makefile,comments: tiny cleanup & fixes
Louis Gesbert authored
47 .PHONY: $(BUILD_DIR)/bin/opa
fccc685 Initial open-source release
MLstate authored
48 $(BUILD_DIR)/bin/opa: $(MYOCAMLBUILD)
49 $(OCAMLBUILD) opa-packages.stamp $(target-tool-opa-bin)
50 @$(copy-tool-opa-bin)
01242f2 [cleanup] Makefile: replaced calls to 'pwd' with make builtin command…
Mathieu Baudet authored
51 @utils/install.sh --quiet --dir $(realpath $(BUILD_DIR)) --ocaml-prefix $(OCAMLLIB)/../..
fccc685 Initial open-source release
MLstate authored
52
53 .PHONY: opa
54 opa: $(BUILD_DIR)/bin/opa
55
56 .PHONY: opa-packages
57 opa-packages: $(MYOCAMLBUILD)
58 $(OCAMLBUILD) opa-packages.stamp
59
60 .PHONY: stdlib
61 stdlib: opa-packages
62
3e9521d @Aqua-Ye [fix] Makefile: added opa-translate in the distribution package build…
Aqua-Ye authored
63 DISTRIB_TOOLS = opa-bin opadoc opa-plugin-builder-bin opa-plugin-browser-bin bslServerLib.ml opa-db-server opa-db-tool opa-cloud opatop opa-translate
fccc685 Initial open-source release
MLstate authored
64
65 .PHONY: distrib
66 distrib: $(MYOCAMLBUILD)
67 $(OCAMLBUILD) $(call target-tools,$(DISTRIB_TOOLS)) opa-packages.stamp
68 @$(call copy-tools,$(DISTRIB_TOOLS))
69
8c3019b [enhance] manpages: added target install-man to install manpages by d…
Mathieu Baudet authored
70 .PHONY: manpages
5baea24 [fix] manpages: when called from the main Makefile, do not assume 'in…
Mathieu Baudet authored
71 manpages: $(MYOCAMLBUILD)
ead3206 @jlmess77 [fix] Makefile: Use $(MAKE) instead of hardcore "make" to allow FreeB…
jlmess77 authored
72 $(MAKE) -C manpages OCAMLBUILD="$(OCAMLBUILD)" BLDDIR=../$(BUILD_DIR)
8c3019b [enhance] manpages: added target install-man to install manpages by d…
Mathieu Baudet authored
73
fccc685 Initial open-source release
MLstate authored
74 ##
75 ## INSTALLATION
76 ##
77
78 .PHONY: install*
79
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
80 STDLIB_DIR = $(INSTALL_DIR)/lib/opa/stdlib
fccc685 Initial open-source release
MLstate authored
81 define install-package
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
82 @printf "Installing into $(STDLIB_DIR)/$*.opx\r"
fccc685 Initial open-source release
MLstate authored
83 @mkdir -p "$(STDLIB_DIR)/$*.opx/_build"
84 @find "$(BUILD_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_DIR)/$*.opx/" \;
85 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.a "$(STDLIB_DIR)/$*.opx/_build/"
86 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmi "$(STDLIB_DIR)/$*.opx/_build/"
87 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmxa "$(STDLIB_DIR)/$*.opx/_build/"
88 endef
89
2f55085 @OpaOnWindowsNow [fix] Makefile: install plugins
OpaOnWindowsNow authored
90 define install-plugin
91 @printf "Installing into $(STDLIB_DIR)/$*.opp^[[K\r"
92 @mkdir -p "$(STDLIB_DIR)/$*.opp"
8371716 @BourgerieQuentin [fix] plugins: Install and searching
BourgerieQuentin authored
93 @$(INSTALL) $(BUILD_DIR)/$*.opp/*.bypass "$(STDLIB_DIR)/$*.opp/";
94 @$(INSTALL) $(BUILD_DIR)/$*.opp/*MLRuntime.* "$(STDLIB_DIR)/$*.opp/";
2f55085 @OpaOnWindowsNow [fix] Makefile: install plugins
OpaOnWindowsNow authored
95 endef
96
97
98
fccc685 Initial open-source release
MLstate authored
99 OPA_PACKAGES := $(shell cd stdlib && ./all_packages.sh)
2f55085 @OpaOnWindowsNow [fix] Makefile: install plugins
OpaOnWindowsNow authored
100 OPA_PLUGINS := $(shell cd stdlib && ./all_plugins.sh)
fccc685 Initial open-source release
MLstate authored
101
102 # Rules installing everything that has been compiled
103 #
104 # This doesn't rely on install rules generated by Makefile.bld ;
105 # instead it assumes that what you want to install has been properly
8c3019b [enhance] manpages: added target install-man to install manpages by d…
Mathieu Baudet authored
106 # put in $(BUILD_DIR)/{bin,lib/opa,share/opa,share/man}.
fccc685 Initial open-source release
MLstate authored
107 #
108 # This is the case of tools (because of Makefile.bld),
109 # and of opa runtime libs (because build rules copy them
110 # to $(BUILD_DIR)/lib/opa/static).
111 # This doesn't install the other libs though, use target install-libs
112 # for that
113
114 install-packageopt-%:
115 $(if $(wildcard $(BUILD_DIR)/$*.opx/_build/*),$(install-package))
116
117 install-package-%:
118 $(install-package)
119
120 install-packages: $(addprefix install-packageopt-,$(OPA_PACKAGES))
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
121 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
122
123 install-all-packages: $(addprefix install-package-,$(OPA_PACKAGES))
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
124 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
125
2f55085 @OpaOnWindowsNow [fix] Makefile: install plugins
OpaOnWindowsNow authored
126 install-pluginopt-%:
127 $(if $(wildcard $(BUILD_DIR)/$*.opp/),$(install-plugin))
128
129 install-plugin-%:
130 $(install-plugin)
131
132 install-plugins: $(addprefix install-pluginopt-,$(OPA_PLUGINS))
133 @printf "Installation to $(STDLIB_DIR) done.\n"
134
135 install-all-plugins: $(addprefix install-plugin-,$(OPA_PLUGINS))
136 @printf "Installation to $(STDLIB_DIR) done.\n"
137
138
139
fccc685 Initial open-source release
MLstate authored
140 install-bin:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
141 @printf "Installing into $(INSTALL_DIR)/bin\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
142 @mkdir -p $(INSTALL_DIR)/bin
143 @$(if $(wildcard $(BUILD_DIR)/bin/*),$(INSTALL) -r $(BUILD_DIR)/bin/* $(INSTALL_DIR)/bin)
144 @utils/install.sh --quiet --dir $(INSTALL_DIR) --ocamllib $(OCAMLLIB) --ocamlopt $(OCAMLOPT)
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
145 @printf "Installation to $(INSTALL_DIR)/bin done.\n"
fccc685 Initial open-source release
MLstate authored
146
147 install-lib:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
148 @printf "Installing into $(INSTALL_DIR)/lib/opa\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
149 @mkdir -p $(INSTALL_DIR)/lib/opa
150 @$(if $(wildcard $(BUILD_DIR)/lib/opa/*),$(INSTALL) -r $(BUILD_DIR)/lib/opa/* $(INSTALL_DIR)/lib/opa/)
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
151 @printf "Installation to $(INSTALL_DIR)/lib/opa done.\n"
fccc685 Initial open-source release
MLstate authored
152
153 install-share:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
154 @printf "Installing into $(INSTALL_DIR)/share/opa\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
155 @mkdir -p $(INSTALL_DIR)/share/opa
156 @$(if $(wildcard $(BUILD_DIR)/share/opa/*),$(INSTALL) -r $(BUILD_DIR)/share/opa/* $(INSTALL_DIR)/share/opa/)
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
157 @printf "Installation to $(INSTALL_DIR)/share/opa done.\n"
fccc685 Initial open-source release
MLstate authored
158
159 install-doc:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
160 @printf "Installing into $(INSTALL_DIR)/share/doc/opa\r"
fccc685 Initial open-source release
MLstate authored
161 @if [ -d $(BUILD_DIR)/opadoc/doc/ ]; then \
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
162 mkdir -p $(INSTALL_DIR)/share/doc/opa/api; \
163 $(INSTALL) -r $(BUILD_DIR)/opadoc/doc/* $(INSTALL_DIR)/share/doc/opa/api; \
fccc685 Initial open-source release
MLstate authored
164 fi
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
165 @printf "Installation to $(INSTALL_DIR)/share/doc/opa done.\n"
fccc685 Initial open-source release
MLstate authored
166
8c3019b [enhance] manpages: added target install-man to install manpages by d…
Mathieu Baudet authored
167 install-man:
168 @printf "Installing into $(INSTALL_DIR)/share/man\r"
169 @if [ -d $(BUILD_DIR)/man/man1 ]; then \
170 mkdir -p $(INSTALL_DIR)/share/man/man1; \
171 $(INSTALL) -r $(BUILD_DIR)/man/man1/*.1 $(INSTALL_DIR)/share/man/man1; \
172 fi
173 @printf "Installation to $(INSTALL_DIR)/share/man done.\n"
174
175 install: install-bin install-lib install-share install-plugins install-packages install-doc install-man
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
176 @printf "Installation into $(INSTALL_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
177
178 .PHONY: uninstall
179 uninstall:
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
180 rm -rf $(INSTALL_DIR)/lib/opa
181 @[ ! -d $(INSTALL_DIR)/lib ] || [ -n "`ls -A $(INSTALL_DIR)/lib`" ] || rmdir $(INSTALL_DIR)/lib
182 rm -rf $(INSTALL_DIR)/share/opa
183 rm -rf $(INSTALL_DIR)/share/doc/opa
184 @[ ! -d $(INSTALL_DIR)/share ] || [ -n "`ls -A $(INSTALL_DIR)/share`" ] || rmdir $(INSTALL_DIR)/share
1b2772b [fix] Makefile: zealous uninstall
Louis Gesbert authored
185 $(foreach file,$(wildcard $(BUILD_DIR)/bin/*),rm -f $(INSTALL_DIR)/bin/$(notdir $(file));)
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
186 @utils/install.sh --uninstall --dir $(INSTALL_DIR)
187 @[ ! -d $(INSTALL_DIR)/bin ] || [ -n "`ls -A $(INSTALL_DIR)/bin`" ] || rmdir $(INSTALL_DIR)/bin
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
188 @printf "Uninstall done.\n"
fccc685 Initial open-source release
MLstate authored
189
190 # Install our ocamlbuild-generation engine
191 install-bld:
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
192 @mkdir -p $(INSTALL_DIR)/bin
22b433a @fperrin Don't assume that bash is in /bin
fperrin authored
193 @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/bld
194 @echo "set -e" >> $(INSTALL_DIR)/bin/bld
195 @echo "set -u" >> $(INSTALL_DIR)/bin/bld
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
196 @chmod 755 $(INSTALL_DIR)/bin/bld
197 @echo "BLDDIR=$(PREFIX)/share/opa/bld $(PREFIX)/share/opa/bld/gen_myocamlbuild.sh" >> $(INSTALL_DIR)/bin/bld
198 @echo "_build/myocamlbuild -no-plugin -j 6 \"\$$@\"" >> $(INSTALL_DIR)/bin/bld
199 @mkdir -p $(INSTALL_DIR)/share/opa/bld
fccc685 Initial open-source release
MLstate authored
200 @$(INSTALL) build/gen_myocamlbuild.sh build/myocamlbuild_*fix.ml config.sh config.mli config.ml\
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
201 $(INSTALL_DIR)/share/opa/bld
fccc685 Initial open-source release
MLstate authored
202
203 # Install an opa wrapper with different stdlib and options (for some backwards-compatibility)
204 install-qmlflat: # depends on opabsl_for_compiler, but we don't want to run ocamlbuild twice
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
205 @mkdir -p $(INSTALL_DIR)/bin $(INSTALL_DIR)/share/opa/mlstatebsl
206 @$(INSTALL) $(BUILD_DIR)/opabsl/mlstatebsl/opabslgen_*.opa $(INSTALL_DIR)/share/opa/mlstatebsl
22b433a @fperrin Don't assume that bash is in /bin
fperrin authored
207 @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/qmlflat
208 @echo "set -e" >> $(INSTALL_DIR)/bin/qmlflat
209 @echo "set -u" >> $(INSTALL_DIR)/bin/qmlflat
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
210 @chmod 755 $(INSTALL_DIR)/bin/qmlflat
fccc685 Initial open-source release
MLstate authored
211 @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) "$$@"' \
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
212 >> $(INSTALL_DIR)/bin/qmlflat
fccc685 Initial open-source release
MLstate authored
213
214 # 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
215 install-all: install install-bld install-qmlflat utils/maxmem
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
216 @$(INSTALL) platform_helper.sh $(INSTALL_DIR)/bin/
776f981 [contrib] pull request #1 from git://github.com/delroth/opalang
François-Régis Sinot authored
217 @$(INSTALL) utils/maxmem $(INSTALL_DIR)/bin/
c2f0a5d [feature] make: installing more dev tools in the install-all target
Louis Gesbert authored
218 @rm utils/maxmem
776f981 [contrib] pull request #1 from git://github.com/delroth/opalang
François-Régis Sinot authored
219 @$(INSTALL) utils/plotmem $(INSTALL_DIR)/bin/
fccc685 Initial open-source release
MLstate authored
220
221 ##
222 ## DOCUMENTATION
223 ##
224 # (in this section, multiple calls to ocamlbuild are tolerated)
225
226 .PHONY: doc.jsbsl
227 doc.jsbsl: $(MYOCAMLBUILD)
228 $(OCAMLBUILD) $@/index.html
229
230 # this rules provides the doc.html target (from Makefile.bld)
231 # the sed are just there to help sorting by filename-within-directory
232 .PHONY: doc.odocl
233 doc.odocl:
234 echo $(foreach lib,$(ALL_LIBS),$(lib-cmi-$(lib):%.cmi=%)) \
235 | sed 's# \+#\n#g' \
236 | sed 's#\(.*\)/\([^/]*\)#\1 \2#' \
237 | sort -k 2 -u \
238 | sed 's#\(.*\) \([^ ]*\)#\1/\2#' \
239 >$@
240
241 .PHONY: packages-api
242 packages-api: $(MYOCAMLBUILD)
243 OPAOPT="$(OPAOPT) --rebuild --api" $(OCAMLBUILD) opa-packages.stamp
244
245 .PHONY: opadoc/doc
246 opadoc/doc: opadoc packages-api
247 @mkdir -p $(BUILD_DIR)/$@
dd1ec70 [fix] doc build: tweaked build of generated of opa doc for future cha…
François-Régis Sinot authored
248 cd $(BUILD_DIR) && ./bin/opadoc -o $@ stdlib && cd -
fccc685 Initial open-source release
MLstate authored
249
250 .PHONY: book
251 book:
252 $(MAKE) -C doc/book
253
254 .PHONY: examples
255 examples: $(MYOCAMLBUILD)
256 $(OCAMLBUILD) $(call target-tools,opa-bin opa-plugin-builder-bin) opa-packages.stamp
257 $(call copy-tools,opa-bin opa-plugin-builder-bin)
01242f2 [cleanup] Makefile: replaced calls to 'pwd' with make builtin command…
Mathieu Baudet authored
258 MLSTATELIBS=$(realpath $(BUILD_DIR)) \
259 OPA="$(realpath $(BUILD_DIR))/lib/opa/bin/opa-bin -I $(realpath $(BUILD_DIR))" \
260 OPA_PLUGIN_BUILDER=$(realpath $(BUILD_DIR))/lib/opa/bin/opa-plugin-builder-bin \
fccc685 Initial open-source release
MLstate authored
261 $(MAKE) -C doc/book examples
262
263 .PHONY: book-clean
264 book-clean:
265 $(MAKE) -C doc/book clean
266
e42280b [fix] Makefile: fixed global target clean by introducing '::'
Mathieu Baudet authored
267 #see also target clean in included Makefile build/Makefile.bld
268 clean:: book-clean
fccc685 Initial open-source release
MLstate authored
269
270 .PHONY: doc
271 doc: doc.html opadoc/doc book
Something went wrong with that request. Please try again.