Skip to content
This repository
Newer
Older
100644 259 lines (204 sloc) 8.799 kb
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
1321ba91 » Frédéric Perrin
2011-09-21 On FreeBSD check and use gmake, use make elsewhere
13 MAKE ?= $_
14 export MAKE
fccc6851 » MLstate
2011-06-21 Initial open-source release
15
e7282e73 » Louis Gesbert
2011-07-06 [enhance] make: do not rebuild opa packages if the variable is set
16 ifndef NO_REBUILD_OPA_PACKAGES
8a40e707 » Louis Gesbert
2011-06-24 [feature] build: support for optional libraries, enabled libnattraver…
17 OPAOPT += "--rebuild"
e7282e73 » Louis Gesbert
2011-07-06 [enhance] make: do not rebuild opa packages if the variable is set
18 endif
8a40e707 » Louis Gesbert
2011-06-24 [feature] build: support for optional libraries, enabled libnattraver…
19
20 ifneq ($(HAS_CAMLIDL)$(HAS_LIBNATPMP)$(HAS_MINIUPNPC),111)
21 export DISABLED_LIBS = libnattraversal
22 endif
23
fccc6851 » MLstate
2011-06-21 Initial open-source release
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
36 all: $(MYOCAMLBUILD)
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
37c04ece » Louis Gesbert
2011-06-28 [cleanup] Makefile,comments: tiny cleanup & fixes
47 .PHONY: $(BUILD_DIR)/bin/opa
fccc6851 » MLstate
2011-06-21 Initial open-source release
48 $(BUILD_DIR)/bin/opa: $(MYOCAMLBUILD)
49 $(OCAMLBUILD) opa-packages.stamp $(target-tool-opa-bin)
50 @$(copy-tool-opa-bin)
51 @utils/install.sh --quiet --dir $(PWD)/$(BUILD_DIR) --ocaml-prefix $(OCAMLLIB)/../..
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
9f7565a5 » OpaOnWindowsNow
2011-09-23 [enhance] distrib: add opatop binary
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
fccc6851 » MLstate
2011-06-21 Initial open-source release
64
65 .PHONY: distrib
66 distrib: $(MYOCAMLBUILD)
67 $(OCAMLBUILD) $(call target-tools,$(DISTRIB_TOOLS)) opa-packages.stamp
68 @$(call copy-tools,$(DISTRIB_TOOLS))
69
70 ##
71 ## INSTALLATION
72 ##
73
74 .PHONY: install*
75
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
76 STDLIB_DIR = $(INSTALL_DIR)/lib/opa/stdlib
fccc6851 » MLstate
2011-06-21 Initial open-source release
77 define install-package
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
78 @printf "Installing into $(STDLIB_DIR)/$*.opx\r"
fccc6851 » MLstate
2011-06-21 Initial open-source release
79 @mkdir -p "$(STDLIB_DIR)/$*.opx/_build"
80 @find "$(BUILD_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_DIR)/$*.opx/" \;
81 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.a "$(STDLIB_DIR)/$*.opx/_build/"
82 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmi "$(STDLIB_DIR)/$*.opx/_build/"
83 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmxa "$(STDLIB_DIR)/$*.opx/_build/"
84 endef
85
2f550855 » OpaOnWindowsNow
2011-10-21 [fix] Makefile: install plugins
86 define install-plugin
87 @printf "Installing into $(STDLIB_DIR)/$*.opp^[[K\r"
88 @mkdir -p "$(STDLIB_DIR)/$*.opp"
83717169 » BourgerieQuentin
2011-10-28 [fix] plugins: Install and searching
89 @$(INSTALL) $(BUILD_DIR)/$*.opp/*.bypass "$(STDLIB_DIR)/$*.opp/";
90 @$(INSTALL) $(BUILD_DIR)/$*.opp/*MLRuntime.* "$(STDLIB_DIR)/$*.opp/";
2f550855 » OpaOnWindowsNow
2011-10-21 [fix] Makefile: install plugins
91 endef
92
93
94
fccc6851 » MLstate
2011-06-21 Initial open-source release
95 OPA_PACKAGES := $(shell cd stdlib && ./all_packages.sh)
2f550855 » OpaOnWindowsNow
2011-10-21 [fix] Makefile: install plugins
96 OPA_PLUGINS := $(shell cd stdlib && ./all_plugins.sh)
fccc6851 » MLstate
2011-06-21 Initial open-source release
97
98 # Rules installing everything that has been compiled
99 #
100 # This doesn't rely on install rules generated by Makefile.bld ;
101 # instead it assumes that what you want to install has been properly
102 # put in $(BUILD_DIR)/{bin,lib/opa,share/opa}.
103 #
104 # This is the case of tools (because of Makefile.bld),
105 # and of opa runtime libs (because build rules copy them
106 # to $(BUILD_DIR)/lib/opa/static).
107 # This doesn't install the other libs though, use target install-libs
108 # for that
109
110 install-packageopt-%:
111 $(if $(wildcard $(BUILD_DIR)/$*.opx/_build/*),$(install-package))
112
113 install-package-%:
114 $(install-package)
115
116 install-packages: $(addprefix install-packageopt-,$(OPA_PACKAGES))
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
117 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc6851 » MLstate
2011-06-21 Initial open-source release
118
119 install-all-packages: $(addprefix install-package-,$(OPA_PACKAGES))
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
120 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc6851 » MLstate
2011-06-21 Initial open-source release
121
2f550855 » OpaOnWindowsNow
2011-10-21 [fix] Makefile: install plugins
122 install-pluginopt-%:
123 $(if $(wildcard $(BUILD_DIR)/$*.opp/),$(install-plugin))
124
125 install-plugin-%:
126 $(install-plugin)
127
128 install-plugins: $(addprefix install-pluginopt-,$(OPA_PLUGINS))
129 @printf "Installation to $(STDLIB_DIR) done.\n"
130
131 install-all-plugins: $(addprefix install-plugin-,$(OPA_PLUGINS))
132 @printf "Installation to $(STDLIB_DIR) done.\n"
133
134
135
fccc6851 » MLstate
2011-06-21 Initial open-source release
136 install-bin:
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
137 @printf "Installing into $(INSTALL_DIR)/bin\r"
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
138 @mkdir -p $(INSTALL_DIR)/bin
139 @$(if $(wildcard $(BUILD_DIR)/bin/*),$(INSTALL) -r $(BUILD_DIR)/bin/* $(INSTALL_DIR)/bin)
140 @utils/install.sh --quiet --dir $(INSTALL_DIR) --ocamllib $(OCAMLLIB) --ocamlopt $(OCAMLOPT)
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
141 @printf "Installation to $(INSTALL_DIR)/bin done.\n"
fccc6851 » MLstate
2011-06-21 Initial open-source release
142
143 install-lib:
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
144 @printf "Installing into $(INSTALL_DIR)/lib/opa\r"
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
145 @mkdir -p $(INSTALL_DIR)/lib/opa
146 @$(if $(wildcard $(BUILD_DIR)/lib/opa/*),$(INSTALL) -r $(BUILD_DIR)/lib/opa/* $(INSTALL_DIR)/lib/opa/)
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
147 @printf "Installation to $(INSTALL_DIR)/lib/opa done.\n"
fccc6851 » MLstate
2011-06-21 Initial open-source release
148
149 install-share:
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
150 @printf "Installing into $(INSTALL_DIR)/share/opa\r"
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
151 @mkdir -p $(INSTALL_DIR)/share/opa
152 @$(if $(wildcard $(BUILD_DIR)/share/opa/*),$(INSTALL) -r $(BUILD_DIR)/share/opa/* $(INSTALL_DIR)/share/opa/)
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
153 @printf "Installation to $(INSTALL_DIR)/share/opa done.\n"
fccc6851 » MLstate
2011-06-21 Initial open-source release
154
155 install-doc:
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
156 @printf "Installing into $(INSTALL_DIR)/share/doc/opa\r"
fccc6851 » MLstate
2011-06-21 Initial open-source release
157 @if [ -d $(BUILD_DIR)/opadoc/doc/ ]; then \
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
158 mkdir -p $(INSTALL_DIR)/share/doc/opa/api; \
159 $(INSTALL) -r $(BUILD_DIR)/opadoc/doc/* $(INSTALL_DIR)/share/doc/opa/api; \
fccc6851 » MLstate
2011-06-21 Initial open-source release
160 fi
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
161 @printf "Installation to $(INSTALL_DIR)/share/doc/opa done.\n"
fccc6851 » MLstate
2011-06-21 Initial open-source release
162
2f550855 » OpaOnWindowsNow
2011-10-21 [fix] Makefile: install plugins
163 install: install-bin install-lib install-share install-plugins install-packages install-doc
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
164 @printf "Installation into $(INSTALL_DIR) done.\n"
fccc6851 » MLstate
2011-06-21 Initial open-source release
165
166 .PHONY: uninstall
167 uninstall:
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
168 rm -rf $(INSTALL_DIR)/lib/opa
169 @[ ! -d $(INSTALL_DIR)/lib ] || [ -n "`ls -A $(INSTALL_DIR)/lib`" ] || rmdir $(INSTALL_DIR)/lib
170 rm -rf $(INSTALL_DIR)/share/opa
171 rm -rf $(INSTALL_DIR)/share/doc/opa
172 @[ ! -d $(INSTALL_DIR)/share ] || [ -n "`ls -A $(INSTALL_DIR)/share`" ] || rmdir $(INSTALL_DIR)/share
1b2772b4 » Louis Gesbert
2011-07-08 [fix] Makefile: zealous uninstall
173 $(foreach file,$(wildcard $(BUILD_DIR)/bin/*),rm -f $(INSTALL_DIR)/bin/$(notdir $(file));)
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
174 @utils/install.sh --uninstall --dir $(INSTALL_DIR)
175 @[ ! -d $(INSTALL_DIR)/bin ] || [ -n "`ls -A $(INSTALL_DIR)/bin`" ] || rmdir $(INSTALL_DIR)/bin
8037018e » Louis Gesbert
2011-06-23 [fix] Makefiles: using a more portable printf instead of echo
176 @printf "Uninstall done.\n"
fccc6851 » MLstate
2011-06-21 Initial open-source release
177
178 # Install our ocamlbuild-generation engine
179 install-bld:
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
180 @mkdir -p $(INSTALL_DIR)/bin
22b433a3 » Frédéric Perrin
2011-08-29 Don't assume that bash is in /bin
181 @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/bld
182 @echo "set -e" >> $(INSTALL_DIR)/bin/bld
183 @echo "set -u" >> $(INSTALL_DIR)/bin/bld
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
184 @chmod 755 $(INSTALL_DIR)/bin/bld
185 @echo "BLDDIR=$(PREFIX)/share/opa/bld $(PREFIX)/share/opa/bld/gen_myocamlbuild.sh" >> $(INSTALL_DIR)/bin/bld
186 @echo "_build/myocamlbuild -no-plugin -j 6 \"\$$@\"" >> $(INSTALL_DIR)/bin/bld
187 @mkdir -p $(INSTALL_DIR)/share/opa/bld
fccc6851 » MLstate
2011-06-21 Initial open-source release
188 @$(INSTALL) build/gen_myocamlbuild.sh build/myocamlbuild_*fix.ml config.sh config.mli config.ml\
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
189 $(INSTALL_DIR)/share/opa/bld
fccc6851 » MLstate
2011-06-21 Initial open-source release
190
191 # Install an opa wrapper with different stdlib and options (for some backwards-compatibility)
192 install-qmlflat: # depends on opabsl_for_compiler, but we don't want to run ocamlbuild twice
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
193 @mkdir -p $(INSTALL_DIR)/bin $(INSTALL_DIR)/share/opa/mlstatebsl
194 @$(INSTALL) $(BUILD_DIR)/opabsl/mlstatebsl/opabslgen_*.opa $(INSTALL_DIR)/share/opa/mlstatebsl
22b433a3 » Frédéric Perrin
2011-08-29 Don't assume that bash is in /bin
195 @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/qmlflat
196 @echo "set -e" >> $(INSTALL_DIR)/bin/qmlflat
197 @echo "set -u" >> $(INSTALL_DIR)/bin/qmlflat
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
198 @chmod 755 $(INSTALL_DIR)/bin/qmlflat
fccc6851 » MLstate
2011-06-21 Initial open-source release
199 @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) "$$@"' \
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
200 >> $(INSTALL_DIR)/bin/qmlflat
fccc6851 » MLstate
2011-06-21 Initial open-source release
201
202 # installs some dev tools on top of the normal install; these should not change often
c2f0a5d6 » Louis Gesbert
2011-06-22 [feature] make: installing more dev tools in the install-all target
203 install-all: install install-bld install-qmlflat utils/maxmem
894a7513 » delroth
2011-06-21 Support make DESTDIR=... install for easier packaging
204 @$(INSTALL) platform_helper.sh $(INSTALL_DIR)/bin/
776f9815 » François-Régis Sinot
2011-06-23 [contrib] pull request #1 from git://github.com/delroth/opalang
205 @$(INSTALL) utils/maxmem $(INSTALL_DIR)/bin/
c2f0a5d6 » Louis Gesbert
2011-06-22 [feature] make: installing more dev tools in the install-all target
206 @rm utils/maxmem
776f9815 » François-Régis Sinot
2011-06-23 [contrib] pull request #1 from git://github.com/delroth/opalang
207 @$(INSTALL) utils/plotmem $(INSTALL_DIR)/bin/
fccc6851 » MLstate
2011-06-21 Initial open-source release
208
209 ##
210 ## DOCUMENTATION
211 ##
212 # (in this section, multiple calls to ocamlbuild are tolerated)
213
214 .PHONY: doc.jsbsl
215 doc.jsbsl: $(MYOCAMLBUILD)
216 $(OCAMLBUILD) $@/index.html
217
218 # this rules provides the doc.html target (from Makefile.bld)
219 # the sed are just there to help sorting by filename-within-directory
220 .PHONY: doc.odocl
221 doc.odocl:
222 echo $(foreach lib,$(ALL_LIBS),$(lib-cmi-$(lib):%.cmi=%)) \
223 | sed 's# \+#\n#g' \
224 | sed 's#\(.*\)/\([^/]*\)#\1 \2#' \
225 | sort -k 2 -u \
226 | sed 's#\(.*\) \([^ ]*\)#\1/\2#' \
227 >$@
228
229 .PHONY: packages-api
230 packages-api: $(MYOCAMLBUILD)
231 OPAOPT="$(OPAOPT) --rebuild --api" $(OCAMLBUILD) opa-packages.stamp
232
233 .PHONY: opadoc/doc
234 opadoc/doc: opadoc packages-api
235 @mkdir -p $(BUILD_DIR)/$@
dd1ec702 » François-Régis Sinot
2011-08-23 [fix] doc build: tweaked build of generated of opa doc for future cha…
236 cd $(BUILD_DIR) && ./bin/opadoc -o $@ stdlib && cd -
fccc6851 » MLstate
2011-06-21 Initial open-source release
237
238 .PHONY: book
239 book:
240 $(MAKE) -C doc/book
241
242 .PHONY: examples
243 examples: $(MYOCAMLBUILD)
244 $(OCAMLBUILD) $(call target-tools,opa-bin opa-plugin-builder-bin) opa-packages.stamp
245 $(call copy-tools,opa-bin opa-plugin-builder-bin)
246 MLSTATELIBS=`pwd`/$(BUILD_DIR) \
247 OPA="`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-bin -I `pwd`/$(BUILD_DIR)" \
248 OPA_PLUGIN_BUILDER=`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-plugin-builder-bin \
249 $(MAKE) -C doc/book examples
250
251 .PHONY: book-clean
252 book-clean:
253 $(MAKE) -C doc/book clean
254
255 .PHONY: clean
256 clean: book-clean
257
258 .PHONY: doc
259 doc: doc.html opadoc/doc book
Something went wrong with that request. Please try again.