Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 237 lines (186 sloc) 8.271 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
a54a2d4 @OpaOnWindowsNow [enhance] Makefile: manpages should be the first thing we build
OpaOnWindowsNow authored
36 all: $(MYOCAMLBUILD)
fccc685 Initial open-source release
MLstate authored
37 $(OCAMLBUILD) $(call target-tools,$(ALL_TOOLS)) opa-packages.stamp
38 @$(call copy-tools,$(ALL_TOOLS))
3e3c2e6 @jlmess77 [fix] Makefile: Use $(MAKE) instead of hardcore "make".
jlmess77 authored
39 $(MAKE) manpages
fccc685 Initial open-source release
MLstate authored
40
41 .PHONY: build
42 build: all
43
44 .PHONY: runtime-libs
45 runtime-libs: $(MYOCAMLBUILD)
46 $(OCAMLBUILD) runtime-libs.stamp
47
37c04ec [cleanup] Makefile,comments: tiny cleanup & fixes
Louis Gesbert authored
48 .PHONY: $(BUILD_DIR)/bin/opa
fccc685 Initial open-source release
MLstate authored
49 $(BUILD_DIR)/bin/opa: $(MYOCAMLBUILD)
50 $(OCAMLBUILD) opa-packages.stamp $(target-tool-opa-bin)
51 @$(copy-tool-opa-bin)
01242f2 [cleanup] Makefile: replaced calls to 'pwd' with make builtin command…
Mathieu Baudet authored
52 @utils/install.sh --quiet --dir $(realpath $(BUILD_DIR)) --ocaml-prefix $(OCAMLLIB)/../..
fccc685 Initial open-source release
MLstate authored
53
54 .PHONY: opa
55 opa: $(BUILD_DIR)/bin/opa
56
57 .PHONY: opa-packages
58 opa-packages: $(MYOCAMLBUILD)
59 $(OCAMLBUILD) opa-packages.stamp
60
61 .PHONY: stdlib
62 stdlib: opa-packages
63
796accf @OpaOnWindowsNow [cleanup] opadoc: remove dead code
OpaOnWindowsNow authored
64 DISTRIB_TOOLS = opa-bin 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
65
66 .PHONY: distrib
67 distrib: $(MYOCAMLBUILD)
68 $(OCAMLBUILD) $(call target-tools,$(DISTRIB_TOOLS)) opa-packages.stamp
69 @$(call copy-tools,$(DISTRIB_TOOLS))
70
8c3019b [enhance] manpages: added target install-man to install manpages by d…
Mathieu Baudet authored
71 .PHONY: manpages
5baea24 [fix] manpages: when called from the main Makefile, do not assume 'in…
Mathieu Baudet authored
72 manpages: $(MYOCAMLBUILD)
ead3206 @jlmess77 [fix] Makefile: Use $(MAKE) instead of hardcore "make" to allow FreeB…
jlmess77 authored
73 $(MAKE) -C manpages OCAMLBUILD="$(OCAMLBUILD)" BLDDIR=../$(BUILD_DIR)
8c3019b [enhance] manpages: added target install-man to install manpages by d…
Mathieu Baudet authored
74
fccc685 Initial open-source release
MLstate authored
75 ##
76 ## INSTALLATION
77 ##
78
79 .PHONY: install*
80
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
81 STDLIB_DIR = $(INSTALL_DIR)/lib/opa/stdlib
fccc685 Initial open-source release
MLstate authored
82 define install-package
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
83 @printf "Installing into $(STDLIB_DIR)/$*.opx\r"
fccc685 Initial open-source release
MLstate authored
84 @mkdir -p "$(STDLIB_DIR)/$*.opx/_build"
85 @find "$(BUILD_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_DIR)/$*.opx/" \;
86 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.a "$(STDLIB_DIR)/$*.opx/_build/"
87 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmi "$(STDLIB_DIR)/$*.opx/_build/"
88 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmxa "$(STDLIB_DIR)/$*.opx/_build/"
89 endef
90
2f55085 @OpaOnWindowsNow [fix] Makefile: install plugins
OpaOnWindowsNow authored
91 define install-plugin
92 @printf "Installing into $(STDLIB_DIR)/$*.opp^[[K\r"
93 @mkdir -p "$(STDLIB_DIR)/$*.opp"
8371716 @BourgerieQuentin [fix] plugins: Install and searching
BourgerieQuentin authored
94 @$(INSTALL) $(BUILD_DIR)/$*.opp/*.bypass "$(STDLIB_DIR)/$*.opp/";
95 @$(INSTALL) $(BUILD_DIR)/$*.opp/*MLRuntime.* "$(STDLIB_DIR)/$*.opp/";
2f55085 @OpaOnWindowsNow [fix] Makefile: install plugins
OpaOnWindowsNow authored
96 endef
97
98
99
fccc685 Initial open-source release
MLstate authored
100 OPA_PACKAGES := $(shell cd stdlib && ./all_packages.sh)
2f55085 @OpaOnWindowsNow [fix] Makefile: install plugins
OpaOnWindowsNow authored
101 OPA_PLUGINS := $(shell cd stdlib && ./all_plugins.sh)
fccc685 Initial open-source release
MLstate authored
102
103 # Rules installing everything that has been compiled
104 #
105 # This doesn't rely on install rules generated by Makefile.bld ;
106 # 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
107 # put in $(BUILD_DIR)/{bin,lib/opa,share/opa,share/man}.
fccc685 Initial open-source release
MLstate authored
108 #
109 # This is the case of tools (because of Makefile.bld),
110 # and of opa runtime libs (because build rules copy them
111 # to $(BUILD_DIR)/lib/opa/static).
112 # This doesn't install the other libs though, use target install-libs
113 # for that
114
115 install-packageopt-%:
116 $(if $(wildcard $(BUILD_DIR)/$*.opx/_build/*),$(install-package))
117
118 install-package-%:
119 $(install-package)
120
121 install-packages: $(addprefix install-packageopt-,$(OPA_PACKAGES))
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
122 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
123
124 install-all-packages: $(addprefix install-package-,$(OPA_PACKAGES))
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
125 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
126
2f55085 @OpaOnWindowsNow [fix] Makefile: install plugins
OpaOnWindowsNow authored
127 install-pluginopt-%:
128 $(if $(wildcard $(BUILD_DIR)/$*.opp/),$(install-plugin))
129
130 install-plugin-%:
131 $(install-plugin)
132
133 install-plugins: $(addprefix install-pluginopt-,$(OPA_PLUGINS))
134 @printf "Installation to $(STDLIB_DIR) done.\n"
135
136 install-all-plugins: $(addprefix install-plugin-,$(OPA_PLUGINS))
137 @printf "Installation to $(STDLIB_DIR) done.\n"
138
139
140
fccc685 Initial open-source release
MLstate authored
141 install-bin:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
142 @printf "Installing into $(INSTALL_DIR)/bin\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
143 @mkdir -p $(INSTALL_DIR)/bin
144 @$(if $(wildcard $(BUILD_DIR)/bin/*),$(INSTALL) -r $(BUILD_DIR)/bin/* $(INSTALL_DIR)/bin)
145 @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
146 @printf "Installation to $(INSTALL_DIR)/bin done.\n"
fccc685 Initial open-source release
MLstate authored
147
148 install-lib:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
149 @printf "Installing into $(INSTALL_DIR)/lib/opa\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
150 @mkdir -p $(INSTALL_DIR)/lib/opa
151 @$(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
152 @printf "Installation to $(INSTALL_DIR)/lib/opa done.\n"
fccc685 Initial open-source release
MLstate authored
153
154 install-share:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
155 @printf "Installing into $(INSTALL_DIR)/share/opa\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
156 @mkdir -p $(INSTALL_DIR)/share/opa
157 @$(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
158 @printf "Installation to $(INSTALL_DIR)/share/opa done.\n"
fccc685 Initial open-source release
MLstate authored
159
8c3019b [enhance] manpages: added target install-man to install manpages by d…
Mathieu Baudet authored
160 install-man:
161 @printf "Installing into $(INSTALL_DIR)/share/man\r"
162 @if [ -d $(BUILD_DIR)/man/man1 ]; then \
163 mkdir -p $(INSTALL_DIR)/share/man/man1; \
164 $(INSTALL) -r $(BUILD_DIR)/man/man1/*.1 $(INSTALL_DIR)/share/man/man1; \
165 fi
166 @printf "Installation to $(INSTALL_DIR)/share/man done.\n"
167
d4f157d @BourgerieQuentin [fix] build: No more install-doc
BourgerieQuentin authored
168 install: install-bin install-lib install-share install-plugins install-packages install-man
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
169 @printf "Installation into $(INSTALL_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
170
171 .PHONY: uninstall
172 uninstall:
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
173 rm -rf $(INSTALL_DIR)/lib/opa
174 @[ ! -d $(INSTALL_DIR)/lib ] || [ -n "`ls -A $(INSTALL_DIR)/lib`" ] || rmdir $(INSTALL_DIR)/lib
175 rm -rf $(INSTALL_DIR)/share/opa
176 rm -rf $(INSTALL_DIR)/share/doc/opa
177 @[ ! -d $(INSTALL_DIR)/share ] || [ -n "`ls -A $(INSTALL_DIR)/share`" ] || rmdir $(INSTALL_DIR)/share
1b2772b [fix] Makefile: zealous uninstall
Louis Gesbert authored
178 $(foreach file,$(wildcard $(BUILD_DIR)/bin/*),rm -f $(INSTALL_DIR)/bin/$(notdir $(file));)
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
179 @utils/install.sh --uninstall --dir $(INSTALL_DIR)
180 @[ ! -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
181 @printf "Uninstall done.\n"
fccc685 Initial open-source release
MLstate authored
182
183 # Install our ocamlbuild-generation engine
184 install-bld:
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
185 @mkdir -p $(INSTALL_DIR)/bin
22b433a @fperrin Don't assume that bash is in /bin
fperrin authored
186 @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/bld
187 @echo "set -e" >> $(INSTALL_DIR)/bin/bld
188 @echo "set -u" >> $(INSTALL_DIR)/bin/bld
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
189 @chmod 755 $(INSTALL_DIR)/bin/bld
190 @echo "BLDDIR=$(PREFIX)/share/opa/bld $(PREFIX)/share/opa/bld/gen_myocamlbuild.sh" >> $(INSTALL_DIR)/bin/bld
191 @echo "_build/myocamlbuild -no-plugin -j 6 \"\$$@\"" >> $(INSTALL_DIR)/bin/bld
192 @mkdir -p $(INSTALL_DIR)/share/opa/bld
fccc685 Initial open-source release
MLstate authored
193 @$(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
194 $(INSTALL_DIR)/share/opa/bld
fccc685 Initial open-source release
MLstate authored
195
196 # Install an opa wrapper with different stdlib and options (for some backwards-compatibility)
197 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
198 @mkdir -p $(INSTALL_DIR)/bin $(INSTALL_DIR)/share/opa/mlstatebsl
199 @$(INSTALL) $(BUILD_DIR)/opabsl/mlstatebsl/opabslgen_*.opa $(INSTALL_DIR)/share/opa/mlstatebsl
22b433a @fperrin Don't assume that bash is in /bin
fperrin authored
200 @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/qmlflat
201 @echo "set -e" >> $(INSTALL_DIR)/bin/qmlflat
202 @echo "set -u" >> $(INSTALL_DIR)/bin/qmlflat
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
203 @chmod 755 $(INSTALL_DIR)/bin/qmlflat
84c2f7f @BourgerieQuentin [fix] compilers: derived compiler should also handle syntax options.
BourgerieQuentin authored
204 @echo 'exec opa --parser classic --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
205 >> $(INSTALL_DIR)/bin/qmlflat
fccc685 Initial open-source release
MLstate authored
206
207 # 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
208 install-all: install install-bld install-qmlflat utils/maxmem
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored
209 @$(INSTALL) platform_helper.sh $(INSTALL_DIR)/bin/
776f981 [contrib] pull request #1 from git://github.com/delroth/opalang
François-Régis Sinot authored
210 @$(INSTALL) utils/maxmem $(INSTALL_DIR)/bin/
c2f0a5d [feature] make: installing more dev tools in the install-all target
Louis Gesbert authored
211 @rm utils/maxmem
776f981 [contrib] pull request #1 from git://github.com/delroth/opalang
François-Régis Sinot authored
212 @$(INSTALL) utils/plotmem $(INSTALL_DIR)/bin/
fccc685 Initial open-source release
MLstate authored
213
214 ##
215 ## DOCUMENTATION
216 ##
217 # (in this section, multiple calls to ocamlbuild are tolerated)
218
219 .PHONY: doc.jsbsl
220 doc.jsbsl: $(MYOCAMLBUILD)
221 $(OCAMLBUILD) $@/index.html
222
223 # this rules provides the doc.html target (from Makefile.bld)
224 # the sed are just there to help sorting by filename-within-directory
225 .PHONY: doc.odocl
226 doc.odocl:
227 echo $(foreach lib,$(ALL_LIBS),$(lib-cmi-$(lib):%.cmi=%)) \
228 | sed 's# \+#\n#g' \
229 | sed 's#\(.*\)/\([^/]*\)#\1 \2#' \
230 | sort -k 2 -u \
231 | sed 's#\(.*\) \([^ ]*\)#\1/\2#' \
232 >$@
233
234 .PHONY: packages-api
235 packages-api: $(MYOCAMLBUILD)
5e9da00 @BourgerieQuentin [enhance] compiler, syntax: Default syntax is now js-like
BourgerieQuentin authored
236 OPAOPT="$(OPAOPT) --rebuild --api --parser classic" $(OCAMLBUILD) opa-packages.stamp
Something went wrong with that request. Please try again.