Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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