#
# 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.
#
##===----------------------------------------------------------------------===##
#
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
# Tools
OCAMLCFLAGS += -I $(OcamlDir) -I $(ObjDir)
+ifneq ($(ObjectsO),)
OCAMLAFLAGS += $(patsubst %,-cclib %, \
$(filter-out -L$(LibDir),-l$(LIBRARYNAME) \
$(shell $(LLVM_CONFIG) --ldflags)) \
$(UsedLibs))
+else
+OCAMLAFLAGS += $(patsubst %,-cclib %, \
+ $(filter-out -L$(LibDir),$(shell $(LLVM_CONFIG) --ldflags)) \
+ $(UsedLibs))
+endif
+
+# -g was introduced in 3.10.0.
+#ifneq ($(ENABLE_OPTIMIZED),1)
+# OCAMLDEBUGFLAG := -g
+#endif
-Compile.CMI := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) -o)
-Compile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) -o)
-Archive.CMA := $(strip $(OCAMLC) -a -custom $(OCAMLAFLAGS) -o)
+Compile.CMI := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
+Compile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
+Archive.CMA := $(strip $(OCAMLC) -a -custom $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) \
+ -o)
-Compile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) -o)
-Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) -o)
+Compile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o)
+Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) -o)
# Source files
OcamlSources1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml))
$(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \
$(OcamlDir)/.dir $(ObjDir)/.dir
- $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeader) > $@
+ $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeaders) > $@
$(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi)
##===- Build static library from C sources --------------------------------===##
+ifneq ($(ObjectsO),)
all-local:: $(LibraryA)
clean-local:: clean-a
install-local:: install-a
uninstall-a::
$(Echo) "Uninstalling $(DestA)"
-$(Verb) $(RM) -f $(DestA)
+endif
##===- Deposit dependent libraries adjacent to Ocaml libs -----------------===##
$(OcamlDir)/%.a: $(LibDir)/%.a
$(Verb) ln -sf $< $@
+$(OcamlDir)/%.o: $(LibDir)/%.o
+ $(Verb) ln -sf $< $@
+
clean-deplibs:
$(Verb) rm -f $(OutputLibs)
$(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)
endif
+##===- Generate documentation ---------------------------------------------===##
+
+$(ObjDir)/$(LIBRARYNAME).odoc: $(ObjectsCMI)
+ $(Echo) "Documenting $(notdir $@)"
+ $(Verb) $(OCAMLDOC) -I $(OcamlDir) -I $(ObjDir) -dump $@ $(OcamlHeaders)
+
+ocamldoc: $(ObjDir)/$(LIBRARYNAME).odoc
##===- Debugging gunk -----------------------------------------------------===##
printvars:: printcamlvars