Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 230 lines (183 sloc) 7.906 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
13
e7282e7 [enhance] make: do not rebuild opa packages if the variable is set
Louis Gesbert authored
14 ifndef NO_REBUILD_OPA_PACKAGES
8a40e70 [feature] build: support for optional libraries, enabled libnattraversal...
Louis Gesbert authored
15 OPAOPT += "--rebuild"
e7282e7 [enhance] make: do not rebuild opa packages if the variable is set
Louis Gesbert authored
16 endif
8a40e70 [feature] build: support for optional libraries, enabled libnattraversal...
Louis Gesbert authored
17
18 ifneq ($(HAS_CAMLIDL)$(HAS_LIBNATPMP)$(HAS_MINIUPNPC),111)
19 export DISABLED_LIBS = libnattraversal
20 endif
21
fccc685 Initial open-source release
MLstate authored
22 .PHONY: default
23 default: all
24
25 include build/Makefile.bld
26
27 export
28
29 ##
30 ## STANDARD TARGETS
31 ##
32
33 .PHONY: all
34 all: $(MYOCAMLBUILD)
35 $(OCAMLBUILD) $(call target-tools,$(ALL_TOOLS)) opa-packages.stamp
36 @$(call copy-tools,$(ALL_TOOLS))
37
38 .PHONY: build
39 build: all
40
41 .PHONY: runtime-libs
42 runtime-libs: $(MYOCAMLBUILD)
43 $(OCAMLBUILD) runtime-libs.stamp
44
37c04ec [cleanup] Makefile,comments: tiny cleanup & fixes
Louis Gesbert authored
45 .PHONY: $(BUILD_DIR)/bin/opa
fccc685 Initial open-source release
MLstate authored
46 $(BUILD_DIR)/bin/opa: $(MYOCAMLBUILD)
47 $(OCAMLBUILD) opa-packages.stamp $(target-tool-opa-bin)
48 @$(copy-tool-opa-bin)
49 @utils/install.sh --quiet --dir $(PWD)/$(BUILD_DIR) --ocaml-prefix $(OCAMLLIB)/../..
50
51 .PHONY: opa
52 opa: $(BUILD_DIR)/bin/opa
53
54 .PHONY: opa-packages
55 opa-packages: $(MYOCAMLBUILD)
56 $(OCAMLBUILD) opa-packages.stamp
57
58 .PHONY: stdlib
59 stdlib: opa-packages
60
61 DISTRIB_TOOLS = opa-bin opadoc opa-plugin-builder-bin opa-plugin-browser-bin bslServerLib.ml opa-db-server opa-db-tool opa-cloud
62
63 .PHONY: distrib
64 distrib: $(MYOCAMLBUILD)
65 $(OCAMLBUILD) $(call target-tools,$(DISTRIB_TOOLS)) opa-packages.stamp
66 @$(call copy-tools,$(DISTRIB_TOOLS))
67
68 ##
69 ## INSTALLATION
70 ##
71
72 .PHONY: install*
73
894a751 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
74 STDLIB_DIR = $(INSTALL_DIR)/lib/opa/stdlib
fccc685 Initial open-source release
MLstate authored
75 define install-package
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
76 @printf "Installing into $(STDLIB_DIR)/$*.opx\r"
fccc685 Initial open-source release
MLstate authored
77 @mkdir -p "$(STDLIB_DIR)/$*.opx/_build"
78 @find "$(BUILD_DIR)/$*.opx" -maxdepth 1 ! -type d -exec $(INSTALL) {} "$(STDLIB_DIR)/$*.opx/" \;
79 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.a "$(STDLIB_DIR)/$*.opx/_build/"
80 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmi "$(STDLIB_DIR)/$*.opx/_build/"
81 @$(INSTALL) $(BUILD_DIR)/$*.opx/_build/*.cmxa "$(STDLIB_DIR)/$*.opx/_build/"
82 endef
83
84 OPA_PACKAGES := $(shell cd stdlib && ./all_packages.sh)
85
86 # Rules installing everything that has been compiled
87 #
88 # This doesn't rely on install rules generated by Makefile.bld ;
89 # instead it assumes that what you want to install has been properly
90 # put in $(BUILD_DIR)/{bin,lib/opa,share/opa}.
91 #
92 # This is the case of tools (because of Makefile.bld),
93 # and of opa runtime libs (because build rules copy them
94 # to $(BUILD_DIR)/lib/opa/static).
95 # This doesn't install the other libs though, use target install-libs
96 # for that
97
98 install-packageopt-%:
99 $(if $(wildcard $(BUILD_DIR)/$*.opx/_build/*),$(install-package))
100
101 install-package-%:
102 $(install-package)
103
104 install-packages: $(addprefix install-packageopt-,$(OPA_PACKAGES))
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
105 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
106
107 install-all-packages: $(addprefix install-package-,$(OPA_PACKAGES))
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
108 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
109
110 install-bin:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
111 @printf "Installing into $(INSTALL_DIR)/bin\r"
894a751 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
112 @mkdir -p $(INSTALL_DIR)/bin
113 @$(if $(wildcard $(BUILD_DIR)/bin/*),$(INSTALL) -r $(BUILD_DIR)/bin/* $(INSTALL_DIR)/bin)
114 @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
115 @printf "Installation to $(INSTALL_DIR)/bin done.\n"
fccc685 Initial open-source release
MLstate authored
116
117 install-lib:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
118 @printf "Installing into $(INSTALL_DIR)/lib/opa\r"
894a751 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
119 @mkdir -p $(INSTALL_DIR)/lib/opa
120 @$(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
121 @printf "Installation to $(INSTALL_DIR)/lib/opa done.\n"
fccc685 Initial open-source release
MLstate authored
122
123 install-share:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
124 @printf "Installing into $(INSTALL_DIR)/share/opa\r"
894a751 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
125 @mkdir -p $(INSTALL_DIR)/share/opa
126 @$(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
127 @printf "Installation to $(INSTALL_DIR)/share/opa done.\n"
fccc685 Initial open-source release
MLstate authored
128
129 install-doc:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
130 @printf "Installing into $(INSTALL_DIR)/share/doc/opa\r"
fccc685 Initial open-source release
MLstate authored
131 @if [ -d $(BUILD_DIR)/opadoc/doc/ ]; then \
894a751 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
132 mkdir -p $(INSTALL_DIR)/share/doc/opa/api; \
133 $(INSTALL) -r $(BUILD_DIR)/opadoc/doc/* $(INSTALL_DIR)/share/doc/opa/api; \
fccc685 Initial open-source release
MLstate authored
134 fi
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
135 @printf "Installation to $(INSTALL_DIR)/share/doc/opa done.\n"
fccc685 Initial open-source release
MLstate authored
136
137 install: install-bin install-lib install-share install-packages install-doc
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored
138 @printf "Installation into $(INSTALL_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored
139
140 .PHONY: uninstall
141 uninstall:
894a751 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
142 rm -rf $(INSTALL_DIR)/lib/opa
143 @[ ! -d $(INSTALL_DIR)/lib ] || [ -n "`ls -A $(INSTALL_DIR)/lib`" ] || rmdir $(INSTALL_DIR)/lib
144 rm -rf $(INSTALL_DIR)/share/opa
145 rm -rf $(INSTALL_DIR)/share/doc/opa
146 @[ ! -d $(INSTALL_DIR)/share ] || [ -n "`ls -A $(INSTALL_DIR)/share`" ] || rmdir $(INSTALL_DIR)/share
1b2772b [fix] Makefile: zealous uninstall
Louis Gesbert authored
147 $(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
148 @utils/install.sh --uninstall --dir $(INSTALL_DIR)
149 @[ ! -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
150 @printf "Uninstall done.\n"
fccc685 Initial open-source release
MLstate authored
151
152 # Install our ocamlbuild-generation engine
153 install-bld:
894a751 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
154 @mkdir -p $(INSTALL_DIR)/bin
155 @echo "#!/bin/bash -ue" > $(INSTALL_DIR)/bin/bld
156 @chmod 755 $(INSTALL_DIR)/bin/bld
157 @echo "BLDDIR=$(PREFIX)/share/opa/bld $(PREFIX)/share/opa/bld/gen_myocamlbuild.sh" >> $(INSTALL_DIR)/bin/bld
158 @echo "_build/myocamlbuild -no-plugin -j 6 \"\$$@\"" >> $(INSTALL_DIR)/bin/bld
159 @mkdir -p $(INSTALL_DIR)/share/opa/bld
fccc685 Initial open-source release
MLstate authored
160 @$(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
161 $(INSTALL_DIR)/share/opa/bld
fccc685 Initial open-source release
MLstate authored
162
163 # Install an opa wrapper with different stdlib and options (for some backwards-compatibility)
164 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
165 @mkdir -p $(INSTALL_DIR)/bin $(INSTALL_DIR)/share/opa/mlstatebsl
166 @$(INSTALL) $(BUILD_DIR)/opabsl/mlstatebsl/opabslgen_*.opa $(INSTALL_DIR)/share/opa/mlstatebsl
167 @echo "#!/bin/bash -ue" > $(INSTALL_DIR)/bin/qmlflat
168 @chmod 755 $(INSTALL_DIR)/bin/qmlflat
fccc685 Initial open-source release
MLstate authored
169 @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 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
170 >> $(INSTALL_DIR)/bin/qmlflat
fccc685 Initial open-source release
MLstate authored
171
172 # 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
173 install-all: install install-bld install-qmlflat utils/maxmem
894a751 Pierre Bourdon Support make DESTDIR=... install for easier packaging
delroth authored
174 @$(INSTALL) platform_helper.sh $(INSTALL_DIR)/bin/
776f981 [contrib] pull request #1 from git://github.com/delroth/opalang
François-Régis Sinot authored
175 @$(INSTALL) utils/maxmem $(INSTALL_DIR)/bin/
c2f0a5d [feature] make: installing more dev tools in the install-all target
Louis Gesbert authored
176 @rm utils/maxmem
776f981 [contrib] pull request #1 from git://github.com/delroth/opalang
François-Régis Sinot authored
177 @$(INSTALL) utils/plotmem $(INSTALL_DIR)/bin/
fccc685 Initial open-source release
MLstate authored
178
179 ##
180 ## DOCUMENTATION
181 ##
182 # (in this section, multiple calls to ocamlbuild are tolerated)
183
184 .PHONY: doc.jsbsl
185 doc.jsbsl: $(MYOCAMLBUILD)
186 $(OCAMLBUILD) $@/index.html
187
188 # this rules provides the doc.html target (from Makefile.bld)
189 # the sed are just there to help sorting by filename-within-directory
190 .PHONY: doc.odocl
191 doc.odocl:
192 echo $(foreach lib,$(ALL_LIBS),$(lib-cmi-$(lib):%.cmi=%)) \
193 | sed 's# \+#\n#g' \
194 | sed 's#\(.*\)/\([^/]*\)#\1 \2#' \
195 | sort -k 2 -u \
196 | sed 's#\(.*\) \([^ ]*\)#\1/\2#' \
197 >$@
198
199 .PHONY: packages-api
200 packages-api: $(MYOCAMLBUILD)
201 OPAOPT="$(OPAOPT) --rebuild --api" $(OCAMLBUILD) opa-packages.stamp
202
203 .PHONY: opadoc/doc
204 opadoc/doc: opadoc packages-api
205 @mkdir -p $(BUILD_DIR)/$@
dd1ec70 [fix] doc build: tweaked build of generated of opa doc for future change...
François-Régis Sinot authored
206 cd $(BUILD_DIR) && ./bin/opadoc -o $@ stdlib && cd -
fccc685 Initial open-source release
MLstate authored
207
208 .PHONY: book
209 book:
210 $(MAKE) -C doc/book
211
212 .PHONY: examples
213 examples: $(MYOCAMLBUILD)
214 $(OCAMLBUILD) $(call target-tools,opa-bin opa-plugin-builder-bin) opa-packages.stamp
215 $(call copy-tools,opa-bin opa-plugin-builder-bin)
216 MLSTATELIBS=`pwd`/$(BUILD_DIR) \
217 OPA="`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-bin -I `pwd`/$(BUILD_DIR)" \
218 OPA_PLUGIN_BUILDER=`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-plugin-builder-bin \
219 $(MAKE) -C doc/book examples
220
221 .PHONY: book-clean
222 book-clean:
223 $(MAKE) -C doc/book clean
224
225 .PHONY: clean
226 clean: book-clean
227
228 .PHONY: doc
229 doc: doc.html opadoc/doc book
Something went wrong with that request. Please try again.