Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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