Fix pr4820: Don't run llvm-config during "make clean" since it may have
[oota-llvm.git] / bindings / ocaml / Makefile.ocaml
index 6008c3a083121a1b232aad13c865bc4ebd26f4e9..c46f6027cf634696c165ffe895a6fd3db6985d44 100644 (file)
@@ -2,8 +2,8 @@
 # 
 #                     The LLVM Compiler Infrastructure
 #
-# This file was developed by Gordon Henriksen and is distributed under the
-# University of Illinois Open Source License. See LICENSE.TXT for details.
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
 # 
 ##===----------------------------------------------------------------------===##
 # 
@@ -20,7 +20,8 @@
 include $(LEVEL)/Makefile.config
 
 # CFLAGS needs to be set before Makefile.rules is included.
-CFLAGS += -I$(shell $(OCAMLC) -where)
+CXX.Flags += -I"$(shell $(OCAMLC) -where)"
+C.Flags += -I"$(shell $(OCAMLC) -where)"
 
 include $(LEVEL)/Makefile.common
 
@@ -30,21 +31,32 @@ PROJ_libocamldir := $(DESTDIR)$(OCAML_LIBDIR)
 OcamlDir := $(LibDir)/ocaml
 
 # Info from llvm-config and similar
+ifndef IS_CLEANING_TARGET
 ifdef UsedComponents
 UsedLibs = $(shell $(LLVM_CONFIG) --libs $(UsedComponents))
 UsedLibNames = $(shell $(LLVM_CONFIG) --libnames $(UsedComponents))
 endif
+endif
 
 # Tools
-OCAMLCFLAGS += -I $(OcamlDir) -I $(ObjDir)
+OCAMLCFLAGS += -I $(ObjDir) -I $(OcamlDir)
+ifndef IS_CLEANING_TARGET
+ifneq ($(ObjectsO),)
 OCAMLAFLAGS += $(patsubst %,-cclib %, \
                  $(filter-out -L$(LibDir),-l$(LIBRARYNAME) \
                                           $(shell $(LLVM_CONFIG) --ldflags)) \
                                           $(UsedLibs))
-ifneq ($(ENABLE_OPTIMIZED),1)
-  OCAMLDEBUGFLAG := -g
+else
+OCAMLAFLAGS += $(patsubst %,-cclib %, \
+                 $(filter-out -L$(LibDir),$(shell $(LLVM_CONFIG) --ldflags)) \
+                                          $(UsedLibs))
+endif
 endif
+# -g was introduced in 3.10.0.
+#ifneq ($(ENABLE_OPTIMIZED),1)
+#  OCAMLDEBUGFLAG := -g
+#endif
 
 Compile.CMI  := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
 Compile.CMO  := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
@@ -96,7 +108,7 @@ $(ObjDir)/%.ml: $(PROJ_SRC_DIR)/%.ml $(ObjDir)/.dir
 
 $(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \
                                    $(OcamlDir)/.dir $(ObjDir)/.dir
-       $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeader) > $@
+       $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeaders) > $@
 
 $(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi)
 
@@ -105,6 +117,7 @@ $(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi)
 
 ##===- Build static library from C sources --------------------------------===##
 
+ifneq ($(ObjectsO),)
 all-local:: $(LibraryA)
 clean-local:: clean-a
 install-local:: install-a
@@ -122,12 +135,13 @@ clean-a::
 install-a:: $(LibraryA)
        $(Echo) "Installing $(BuildMode) $(DestA)"
        $(Verb) $(MKDIR) $(PROJ_libocamldir)
-       $(Verb) $(LTInstall) $(LibraryA) $(DestA)
+       $(Verb) $(INSTALL) $(LibraryA) $(DestA)
        $(Verb) 
 
 uninstall-a::
        $(Echo) "Uninstalling $(DestA)"
        -$(Verb) $(RM) -f $(DestA)
+endif
 
 
 ##===- Deposit dependent libraries adjacent to Ocaml libs -----------------===##
@@ -258,7 +272,7 @@ $(ObjDir)/%.cmx: $(ObjDir)/%.ml
        $(Verb) $(Compile.CMX) $@ $<
 
 clean-cmxa::
-       $(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.o) $(OutputsCMX)
+       $(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.a) $(OutputsCMX)
 
 install-cmxa:: $(OutputCMXA) $(OutputsCMX)
        $(Verb) $(MKDIR) $(PROJ_libocamldir)
@@ -283,6 +297,13 @@ uninstall-cmxa::
 
 endif
 
+##===- Generate documentation ---------------------------------------------===##
+
+$(ObjDir)/$(LIBRARYNAME).odoc: $(ObjectsCMI)
+       $(Echo) "Documenting $(notdir $@)"
+       $(Verb) $(OCAMLDOC) -I $(ObjDir) -I $(OcamlDir) -dump $@ $(OcamlHeaders)
+
+ocamldoc: $(ObjDir)/$(LIBRARYNAME).odoc
 
 ##===- Debugging gunk -----------------------------------------------------===##
 printvars:: printcamlvars