Skip to content
Newer
Older
100644 236 lines (189 sloc) 7.93 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
1321ba9 @fperrin On FreeBSD check and use gmake, use make elsewhere
fperrin authored Sep 21, 2011
13 MAKE ?= $_
14 export MAKE
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
15
e7282e7 [enhance] make: do not rebuild opa packages if the variable is set
Louis Gesbert authored Jul 6, 2011
16 ifndef NO_REBUILD_OPA_PACKAGES
8a40e70 [feature] build: support for optional libraries, enabled libnattraver…
Louis Gesbert authored Jun 24, 2011
17 OPAOPT += "--rebuild"
e7282e7 [enhance] make: do not rebuild opa packages if the variable is set
Louis Gesbert authored Jul 6, 2011
18 endif
8a40e70 [feature] build: support for optional libraries, enabled libnattraver…
Louis Gesbert authored Jun 24, 2011
19
20 ifneq ($(HAS_CAMLIDL)$(HAS_LIBNATPMP)$(HAS_MINIUPNPC),111)
21 export DISABLED_LIBS = libnattraversal
22 endif
23
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
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
37c04ec [cleanup] Makefile,comments: tiny cleanup & fixes
Louis Gesbert authored Jun 28, 2011
47 .PHONY: $(BUILD_DIR)/bin/opa
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
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
9f7565a @OpaOnWindowsNow [enhance] distrib: add opatop binary
OpaOnWindowsNow authored Sep 23, 2011
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
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
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
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
76 STDLIB_DIR = $(INSTALL_DIR)/lib/opa/stdlib
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
77 define install-package
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored Jun 23, 2011
78 @printf "Installing into $(STDLIB_DIR)/$*.opx\r"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
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
86 OPA_PACKAGES := $(shell cd stdlib && ./all_packages.sh)
87
88 # Rules installing everything that has been compiled
89 #
90 # This doesn't rely on install rules generated by Makefile.bld ;
91 # instead it assumes that what you want to install has been properly
92 # put in $(BUILD_DIR)/{bin,lib/opa,share/opa}.
93 #
94 # This is the case of tools (because of Makefile.bld),
95 # and of opa runtime libs (because build rules copy them
96 # to $(BUILD_DIR)/lib/opa/static).
97 # This doesn't install the other libs though, use target install-libs
98 # for that
99
100 install-packageopt-%:
101 $(if $(wildcard $(BUILD_DIR)/$*.opx/_build/*),$(install-package))
102
103 install-package-%:
104 $(install-package)
105
106 install-packages: $(addprefix install-packageopt-,$(OPA_PACKAGES))
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored Jun 23, 2011
107 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
108
109 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
110 @printf "Installation to $(STDLIB_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
111
112 install-bin:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored Jun 23, 2011
113 @printf "Installing into $(INSTALL_DIR)/bin\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
114 @mkdir -p $(INSTALL_DIR)/bin
115 @$(if $(wildcard $(BUILD_DIR)/bin/*),$(INSTALL) -r $(BUILD_DIR)/bin/* $(INSTALL_DIR)/bin)
116 @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
117 @printf "Installation to $(INSTALL_DIR)/bin done.\n"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
118
119 install-lib:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored Jun 23, 2011
120 @printf "Installing into $(INSTALL_DIR)/lib/opa\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
121 @mkdir -p $(INSTALL_DIR)/lib/opa
122 @$(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
123 @printf "Installation to $(INSTALL_DIR)/lib/opa done.\n"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
124
125 install-share:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored Jun 23, 2011
126 @printf "Installing into $(INSTALL_DIR)/share/opa\r"
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
127 @mkdir -p $(INSTALL_DIR)/share/opa
128 @$(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
129 @printf "Installation to $(INSTALL_DIR)/share/opa done.\n"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
130
131 install-doc:
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored Jun 23, 2011
132 @printf "Installing into $(INSTALL_DIR)/share/doc/opa\r"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
133 @if [ -d $(BUILD_DIR)/opadoc/doc/ ]; then \
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
134 mkdir -p $(INSTALL_DIR)/share/doc/opa/api; \
135 $(INSTALL) -r $(BUILD_DIR)/opadoc/doc/* $(INSTALL_DIR)/share/doc/opa/api; \
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
136 fi
8037018 [fix] Makefiles: using a more portable printf instead of echo
Louis Gesbert authored Jun 23, 2011
137 @printf "Installation to $(INSTALL_DIR)/share/doc/opa done.\n"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
138
139 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
140 @printf "Installation into $(INSTALL_DIR) done.\n"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
141
142 .PHONY: uninstall
143 uninstall:
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
144 rm -rf $(INSTALL_DIR)/lib/opa
145 @[ ! -d $(INSTALL_DIR)/lib ] || [ -n "`ls -A $(INSTALL_DIR)/lib`" ] || rmdir $(INSTALL_DIR)/lib
146 rm -rf $(INSTALL_DIR)/share/opa
147 rm -rf $(INSTALL_DIR)/share/doc/opa
148 @[ ! -d $(INSTALL_DIR)/share ] || [ -n "`ls -A $(INSTALL_DIR)/share`" ] || rmdir $(INSTALL_DIR)/share
1b2772b [fix] Makefile: zealous uninstall
Louis Gesbert authored Jul 8, 2011
149 $(foreach file,$(wildcard $(BUILD_DIR)/bin/*),rm -f $(INSTALL_DIR)/bin/$(notdir $(file));)
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
150 @utils/install.sh --uninstall --dir $(INSTALL_DIR)
151 @[ ! -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
152 @printf "Uninstall done.\n"
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
153
154 # Install our ocamlbuild-generation engine
155 install-bld:
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
156 @mkdir -p $(INSTALL_DIR)/bin
22b433a @fperrin Don't assume that bash is in /bin
fperrin authored Aug 29, 2011
157 @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/bld
158 @echo "set -e" >> $(INSTALL_DIR)/bin/bld
159 @echo "set -u" >> $(INSTALL_DIR)/bin/bld
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
160 @chmod 755 $(INSTALL_DIR)/bin/bld
161 @echo "BLDDIR=$(PREFIX)/share/opa/bld $(PREFIX)/share/opa/bld/gen_myocamlbuild.sh" >> $(INSTALL_DIR)/bin/bld
162 @echo "_build/myocamlbuild -no-plugin -j 6 \"\$$@\"" >> $(INSTALL_DIR)/bin/bld
163 @mkdir -p $(INSTALL_DIR)/share/opa/bld
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
164 @$(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
165 $(INSTALL_DIR)/share/opa/bld
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
166
167 # Install an opa wrapper with different stdlib and options (for some backwards-compatibility)
168 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
169 @mkdir -p $(INSTALL_DIR)/bin $(INSTALL_DIR)/share/opa/mlstatebsl
170 @$(INSTALL) $(BUILD_DIR)/opabsl/mlstatebsl/opabslgen_*.opa $(INSTALL_DIR)/share/opa/mlstatebsl
22b433a @fperrin Don't assume that bash is in /bin
fperrin authored Aug 29, 2011
171 @echo "#!/usr/bin/env bash" > $(INSTALL_DIR)/bin/qmlflat
172 @echo "set -e" >> $(INSTALL_DIR)/bin/qmlflat
173 @echo "set -u" >> $(INSTALL_DIR)/bin/qmlflat
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
174 @chmod 755 $(INSTALL_DIR)/bin/qmlflat
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
175 @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
176 >> $(INSTALL_DIR)/bin/qmlflat
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
177
178 # 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
179 install-all: install install-bld install-qmlflat utils/maxmem
894a751 @delroth Support make DESTDIR=... install for easier packaging
delroth authored Jun 21, 2011
180 @$(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
181 @$(INSTALL) utils/maxmem $(INSTALL_DIR)/bin/
c2f0a5d [feature] make: installing more dev tools in the install-all target
Louis Gesbert authored Jun 22, 2011
182 @rm utils/maxmem
776f981 [contrib] pull request #1 from git://github.com/delroth/opalang
François-Régis Sinot authored Jun 23, 2011
183 @$(INSTALL) utils/plotmem $(INSTALL_DIR)/bin/
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
184
185 ##
186 ## DOCUMENTATION
187 ##
188 # (in this section, multiple calls to ocamlbuild are tolerated)
189
190 .PHONY: doc.jsbsl
191 doc.jsbsl: $(MYOCAMLBUILD)
192 $(OCAMLBUILD) $@/index.html
193
194 # this rules provides the doc.html target (from Makefile.bld)
195 # the sed are just there to help sorting by filename-within-directory
196 .PHONY: doc.odocl
197 doc.odocl:
198 echo $(foreach lib,$(ALL_LIBS),$(lib-cmi-$(lib):%.cmi=%)) \
199 | sed 's# \+#\n#g' \
200 | sed 's#\(.*\)/\([^/]*\)#\1 \2#' \
201 | sort -k 2 -u \
202 | sed 's#\(.*\) \([^ ]*\)#\1/\2#' \
203 >$@
204
205 .PHONY: packages-api
206 packages-api: $(MYOCAMLBUILD)
207 OPAOPT="$(OPAOPT) --rebuild --api" $(OCAMLBUILD) opa-packages.stamp
208
209 .PHONY: opadoc/doc
210 opadoc/doc: opadoc packages-api
211 @mkdir -p $(BUILD_DIR)/$@
dd1ec70 [fix] doc build: tweaked build of generated of opa doc for future cha…
François-Régis Sinot authored Aug 23, 2011
212 cd $(BUILD_DIR) && ./bin/opadoc -o $@ stdlib && cd -
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
213
214 .PHONY: book
215 book:
216 $(MAKE) -C doc/book
217
218 .PHONY: examples
219 examples: $(MYOCAMLBUILD)
220 $(OCAMLBUILD) $(call target-tools,opa-bin opa-plugin-builder-bin) opa-packages.stamp
221 $(call copy-tools,opa-bin opa-plugin-builder-bin)
222 MLSTATELIBS=`pwd`/$(BUILD_DIR) \
223 OPA="`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-bin -I `pwd`/$(BUILD_DIR)" \
224 OPA_PLUGIN_BUILDER=`pwd`/$(BUILD_DIR)/lib/opa/bin/opa-plugin-builder-bin \
225 $(MAKE) -C doc/book examples
226
227 .PHONY: book-clean
228 book-clean:
229 $(MAKE) -C doc/book clean
230
231 .PHONY: clean
232 clean: book-clean
233
234 .PHONY: doc
235 doc: doc.html opadoc/doc book
Something went wrong with that request. Please try again.