Skip to content

HTTPS clone URL

Subversion checkout URL

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