Permalink
Browse files

Support building shared libraries.

  • Loading branch information...
1 parent 771bfc8 commit 92454590c55a907390ded5872cd2920e9aeb1997 @mdekstrand mdekstrand committed Apr 11, 2010
Showing with 28 additions and 2 deletions.
  1. +8 −2 Makefile
  2. +4 −0 README
  3. +14 −0 myocamlbuild.ml
  4. +2 −0 shared.itarget
View
@@ -9,13 +9,18 @@ BROWSER_COMMAND ?= x-www-browser %s
OCAMLBUILD ?= ocamlbuild
BATTERIES_NATIVE ?= yes
+BATTERIES_NATIVE_SHLIB ?= yes
.PHONY: all clean doc install uninstall reinstall
all: build/META
test ! -e src/batteries_config.ml || rm src/batteries_config.ml
$(OCAMLBUILD) syntax.otarget byte.otarget src/batteries_help.cmo
- test X$(BATTERIES_NATIVE) != Xyes || $(OCAMLBUILD) native.otarget
+ if test X$(BATTERIES_NATIVE_SHLIB) = Xyes; then \
+ $(OCAMLBUILD) shared.otarget; \
+ elif test X$(BATTERIES_NATIVE) = Xyes; then \
+ $(OCAMLBUILD) native.otarget; \
+ fi
clean:
rm -f build/META apidocs
@@ -31,7 +36,8 @@ install: all
_build/libs/estring/*.cmi \
_build/libs/estring/*.mli
ocamlfind install $(NAME) build/META \
- _build/src/*.cma _build/src/*.cmxa _build/src/*.a \
+ _build/src/*.cma _build/src/*.cmxa _build/src/*.cmxs \
+ _build/src/*.a \
_build/src/*.cmx _build/src/*.cmi _build/src/*.mli \
_build/src/syntax/pa_comprehension/pa_comprehension.cmo \
_build/src/syntax/pa_strings/pa_strings.cma
View
4 README
@@ -46,6 +46,10 @@ To disable native compilation:
$ export BATTERIES_NATIVE=false
+To disable building of native shared libraries:
+
+ $ export BATTERIES_NATIVE_SHLIB=false
+
*** Using Batteries ***
To get started using Batteries at the toplevel, copy the ocamlinit
View
@@ -24,7 +24,21 @@ let _ = dispatch begin function
~deps:["%.mlp"; "Makefile"]
begin fun env build ->
Cmd(S[A"make"; P(env "%.ml")])
+ end;
+
+ rule "build shared module"
+ ~prod:"%.cmxs"
+ ~dep:"%.cmxa"
+ begin fun env build ->
+ let tags = Tags.union
+ (tags_of_pathname (env "%.cmxs"))
+ (tags_of_pathname (env "%.cmxa"))
+ ++ "ocaml" ++ "link" ++ "module"
+ in
+ Cmd(S[!Options.ocamlopt; A"-shared"; A"-linkall";
+ T tags; A"-o"; P(env "%.cmxs"); P(env "%.cmxa")])
end
+
| After_rules ->
flag ["ocaml"; "compile"] & S[A"-package"; A packs];
flag ["ocaml"; "ocamldep"] & S[A"-package"; A packs];
View
@@ -0,0 +1,2 @@
+src/batteries_uni.cmxs
+src/batteries.cmxs

0 comments on commit 9245459

Please sign in to comment.