Source

z3 / src / api / ml / Makefile

Full commit
# assumes that libz3.a is in the link path -L and that libz3.so
# is in the dynamic load libary path (LD_LIBRARY_PATH or
# DYLD_LIBRARY_PATH)

OCAMLMKLIB=ocamlmklib
OCAMLFIND=ocamlfind
OCAMLC=ocamlc
OCAMLOPT=ocamlopt

OCAML_LOC=$(shell ocamlc -where)
Z3_VERSION=$(shell ../../../build/z3 -version | sed 's/Z3 version //')

.PHONY: all install clean uninstall remove

LIBS=z3.cmi z3.cmo z3.cmx z3.o libz3caml.a
#dllz3caml.so z3caml.cma z3caml.cmxa z3caml.a 
all : $(LIBS)

install : META $(LIBS)
	$(OCAMLFIND) install z3 META $(LIBS)

# build the library
#$(OCAMLMKLIB) -custom -verbose z3_stubs.o z3_theory_stubs.o z3.mli z3.ml -cclib -L$(OCAML_LOC) -cclib -lz3caml -cclib -lcamlidl -cclib -lz3 -ccopt -fopenmp -o z3caml
$(LIBS) : z3_theory_stubs.o z3_stubs.o
	ar rc ./libz3caml.a  z3_stubs.o z3_theory_stubs.o; ranlib ./libz3caml.a
	$(OCAMLC) -custom -a -o z3caml.cma      -ccopt -fopenmp z3.mli z3.ml -cclib -lz3caml -cclib -lz3 -cclib -L/usr/local/lib/ocaml -cclib -lcamlidl 
	$(OCAMLOPT) -a -o z3caml.cmxa      -ccopt -fopenmp z3.mli z3.ml -cclib -lz3caml -cclib -lz3 -cclib -L/usr/local/lib/ocaml -cclib -lcamlidl 

# build the stubs
z3_theory_stubs.o z3_stubs.o : z3_theory_stubs.c z3_stubs.c
	$(OCAMLC) -verbose -c -I .. z3_theory_stubs.c z3_stubs.c > /dev/null 2>&1

# construct the meta file
META :
	@echo "version=\"$(Z3_VERSION)\"" > META
	@echo "description=\"Z3 Theorem Prover\"" >> META
	@echo "archive(byte)=\"z3.cmo\"" >> META
	@echo "archive(native)=\"z3.cmx\"" >> META
	@echo "linkopts(byte)=\"-custom -cclib -lz3caml -cclib -lz3 -cclib -L$(OCAML_LOC) -cclib -lcamlidl -cclib -fopenmp\"" >> META
	@echo "linkopts=\"-cclib -lz3caml -cclib -lz3 -cclib -L$(OCAML_LOC) -cclib -lcamlidl -cclib -fopenmp\"" >> META

clean :
	-rm -rf META $(LIBS) z3_theory_stubs.o z3_stubs.o

remove uninstall :
	$(OCAMLFIND) remove z3