[OCaml] Expose Llvm_executionengine.get_{global_value,function}_address.
[oota-llvm.git] / bindings / ocaml / Makefile.ocaml
index e466b2b2a90d603f675473b6f79bc520cfad1f70..ac719de3a5b62dbb9f98d0411daada2cf32e225b 100644 (file)
@@ -19,6 +19,9 @@
 
 include $(LEVEL)/Makefile.config
 
+# We have our own rules for building static libraries.
+NO_BUILD_ARCHIVE = 1
+
 # CFLAGS needs to be set before Makefile.rules is included.
 CXX.Flags += -I"$(shell $(OCAMLFIND) c -where)"
 C.Flags += -I"$(shell $(OCAMLFIND) c -where)"
@@ -50,12 +53,21 @@ endif
 #    from toplevels.
 ifneq ($(ObjectsO),)
 ifeq ($(ENABLE_SHARED),1)
-OCAMLSTUBS := 1
+OCAMLSTUBS     := 1
+OCAMLSTUBFLAGS := $(patsubst %,-cclib %, $(LLVMLibsOptions) -l$(LIBRARYNAME))
+endif
+endif
+
+# Avoid the need for LD_LIBRARY_PATH
+ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ifneq ($(HOST_OS),Darwin)
+OCAMLRPATH     := $(RPATH) -Wl,'$$ORIGIN/../../lib'
 endif
 endif
 
 # Tools
-OCAMLCFLAGS += -I $(OcamlDir)
+OCAMLCFLAGS += -I $(OcamlDir) $(addprefix -package ,$(FindlibPackages))
+
 ifndef IS_CLEANING_TARGET
 ifneq ($(ObjectsO),)
 OCAMLAFLAGS += $(patsubst %,-cclib %, \
@@ -69,7 +81,7 @@ OCAMLAFLAGS += $(patsubst %,-cclib %, \
 endif
 endif
 
-ifneq ($(ENABLE_OPTIMIZED),1)
+ifneq ($(DEBUG_SYMBOLS),1)
   OCAMLDEBUGFLAG := -g
 endif
 
@@ -78,27 +90,16 @@ Compile.CMO  := $(strip $(OCAMLFIND) c -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
 Compile.CMX  := $(strip $(OCAMLFIND) opt -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
 
 ifdef OCAMLSTUBS
-# Avoid the need for LD_LIBRARY_PATH
-ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
-ifneq ($(HOST_OS),Darwin)
-OCAMLRPATH   := $(RPATH) -Wl,'$(SharedLibDir)'
-endif
-endif
-endif
-
-ifdef OCAMLSTUBS
-Archive.CMA  := $(strip $(OCAMLFIND) c -a -dllib -l$(LIBRARYNAME) $(OCAMLDEBUGFLAG) \
-                                       -o)
+# -dllib is engaged with ocamlc builds, $(OCAMLSTUBFLAGS) in ocamlc -custom builds.
+Archive.CMA  := $(strip $(OCAMLFIND) c -a -dllib -l$(LIBRARYNAME) $(OCAMLSTUBFLAGS) \
+                                                                                                                                                        $(OCAMLDEBUGFLAG) -o)
 else
 Archive.CMA  := $(strip $(OCAMLFIND) c -a -custom $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) \
                                        -o)
 endif
 
 ifdef OCAMLSTUBS
-Archive.CMXA := $(strip $(OCAMLFIND) opt -a $(patsubst %,-cclib %, \
-                                    $(LLVMLibsOptions) -l$(LIBRARYNAME) \
-                                    -L$(SharedLibDir) $(OCAMLRPATH)) \
-                                    $(OCAMLDEBUGFLAG) -o)
+Archive.CMXA := $(strip $(OCAMLFIND) opt -a $(OCAMLSTUBFLAGS) $(OCAMLDEBUGFLAG) -o)
 else
 Archive.CMXA := $(strip $(OCAMLFIND) opt -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) -o)
 endif
@@ -236,8 +237,8 @@ uninstall-local:: uninstall-shared
 
 $(SharedLib): $(ObjectsO) $(OcamlDir)/.dir
        $(Echo) "Building $(BuildMode) $(notdir $@)"
-       $(Verb) $(Link) $(SharedLinkOptions) $(OCAMLRPATH) $(LLVMLibsOptions) \
-                       -o $@ $(ObjectsO)
+       $(Verb) $(Link) $(SharedLinkOptions) $(OCAMLRPATH) -o $@ $(ObjectsO) \
+                       $(LLVMLibsOptions)
 
 clean-shared::
        -$(Verb) $(RM) -f $(SharedLib)
@@ -427,6 +428,9 @@ printcamlvars::
        $(Echo) "LLVM_CONFIG  : " '$(LLVM_CONFIG)'
        $(Echo) "OCAMLCFLAGS  : " '$(OCAMLCFLAGS)'
        $(Echo) "OCAMLAFLAGS  : " '$(OCAMLAFLAGS)'
+       $(Echo) "OCAMLRPATH   : " '$(OCAMLRPATH)'
+       $(Echo) "OCAMLSTUBS   : " '$(OCAMLSTUBS)'
+       $(Echo) "OCAMLSTUBFLAGS : " '$(OCAMLSTUBFLAGS)'
        $(Echo) "OCAMLFIND    : " '$(OCAMLFIND)'
        $(Echo) "Compile.CMI  : " '$(Compile.CMI)'
        $(Echo) "Compile.CMO  : " '$(Compile.CMO)'
@@ -434,6 +438,7 @@ printcamlvars::
        $(Echo) "Compile.CMX  : " '$(Compile.CMX)'
        $(Echo) "Archive.CMXA : " '$(Archive.CMXA)'
        $(Echo) "CAML_LIBDIR  : " '$(CAML_LIBDIR)'
+       $(Echo) "LibraryA     : " '$(LibraryA)'
        $(Echo) "LibraryCMA   : " '$(LibraryCMA)'
        $(Echo) "LibraryCMXA  : " '$(LibraryCMXA)'
        $(Echo) "SharedLib    : " '$(SharedLib)'