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