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