X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=bindings%2Focaml%2FMakefile.ocaml;h=a2a8b02eac7d33bfda52183cc4ac9feaa381626d;hb=71857ccdb83b6374f7a791c2dae45ce9934a85af;hp=4e5de8026409d83bdc352b41a52003d016676f7a;hpb=3994b4b05e02736c98744647d1d495e77c844413;p=oota-llvm.git diff --git a/bindings/ocaml/Makefile.ocaml b/bindings/ocaml/Makefile.ocaml index 4e5de802640..a2a8b02eac7 100644 --- a/bindings/ocaml/Makefile.ocaml +++ b/bindings/ocaml/Makefile.ocaml @@ -66,35 +66,69 @@ Archive.CMA := $(strip $(OCAMLC) -a -custom $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) \ Compile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o) Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) -o) +ifdef OCAMLOPT +Archive.EXE := $(strip $(OCAMLOPT) -cc $(CXX) $(OCAMLCFLAGS) $(UsedOcamLibs:%=%.cmxa) $(OCAMLDEBUGFLAG) -o) +else +Archive.EXE := $(strip $(OCAMLC) -cc $(CXX) $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG:%=%.cma) -o) +endif + # Source files +ifndef OcamlSources1 OcamlSources1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml)) -OcamlHeaders1 := $(OcamlSources1:.ml=.mli) +endif -OcamlSources := $(OcamlSources1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) -OcamlHeaders := $(OcamlHeaders1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) +ifndef OcamlHeaders1 +OcamlHeaders1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.mli)) +endif + +OcamlSources2 := $(filter-out $(ExcludeSources),$(OcamlSources1)) +OcamlHeaders2 := $(filter-out $(ExcludeHeaders),$(OcamlHeaders1)) + +OcamlSources := $(OcamlSources2:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) +OcamlHeaders := $(OcamlHeaders2:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) # Intermediate files -LibraryCMA := $(ObjDir)/$(LIBRARYNAME).cma -LibraryCMXA := $(ObjDir)/$(LIBRARYNAME).cmxa ObjectsCMI := $(OcamlSources:%.ml=%.cmi) ObjectsCMO := $(OcamlSources:%.ml=%.cmo) ObjectsCMX := $(OcamlSources:%.ml=%.cmx) +ifdef LIBRARYNAME +LibraryCMA := $(ObjDir)/$(LIBRARYNAME).cma +LibraryCMXA := $(ObjDir)/$(LIBRARYNAME).cmxa +endif + +ifdef TOOLNAME +ToolEXE := $(ObjDir)/$(TOOLNAME)$(EXEEXT) +endif + # Output files # The .cmo files are the only intermediates; all others are to be installed. -LibraryA := $(OcamlDir)/lib$(LIBRARYNAME).a -OutputCMA := $(LibraryCMA:$(ObjDir)/%.cma=$(OcamlDir)/%.cma) -OutputCMXA := $(LibraryCMXA:$(ObjDir)/%.cmxa=$(OcamlDir)/%.cmxa) OutputsCMI := $(ObjectsCMI:$(ObjDir)/%.cmi=$(OcamlDir)/%.cmi) OutputsCMX := $(ObjectsCMX:$(ObjDir)/%.cmx=$(OcamlDir)/%.cmx) OutputLibs := $(UsedLibNames:%=$(OcamlDir)/%) +ifdef LIBRARYNAME +LibraryA := $(OcamlDir)/lib$(LIBRARYNAME).a +OutputCMA := $(LibraryCMA:$(ObjDir)/%.cma=$(OcamlDir)/%.cma) +OutputCMXA := $(LibraryCMXA:$(ObjDir)/%.cmxa=$(OcamlDir)/%.cmxa) +endif + +ifdef TOOLNAME +ifdef EXAMPLE_TOOL +OutputEXE := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT) +else +OutputEXE := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT) +endif +endif + # Installation targets +DestLibs := $(UsedLibNames:%=$(PROJ_libocamldir)/%) + +ifdef LIBRARYNAME DestA := $(PROJ_libocamldir)/lib$(LIBRARYNAME).a DestCMA := $(PROJ_libocamldir)/$(LIBRARYNAME).cma DestCMXA := $(PROJ_libocamldir)/$(LIBRARYNAME).cmxa -DestLibs := $(UsedLibNames:%=$(PROJ_libocamldir)/%) - +endif ##===- Dependencies -------------------------------------------------------===## # Copy the sources into the intermediate directory because older ocamlc doesn't @@ -106,18 +140,27 @@ $(ObjDir)/%.mli: $(PROJ_SRC_DIR)/%.mli $(ObjDir)/.dir $(ObjDir)/%.ml: $(PROJ_SRC_DIR)/%.ml $(ObjDir)/.dir $(Verb) $(CP) -f $< $@ +$(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi) + +ifdef LIBRARYNAME $(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \ $(OcamlDir)/.dir $(ObjDir)/.dir $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeaders) > $@ -$(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi) - -include $(ObjDir)/$(LIBRARYNAME).ocamldep +endif +ifdef TOOLNAME +$(ObjDir)/$(TOOLNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \ + $(OcamlDir)/.dir $(ObjDir)/.dir + $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeaders) > $@ + +-include $(ObjDir)/$(TOOLNAME).ocamldep +endif ##===- Build static library from C sources --------------------------------===## -ifneq ($(ObjectsO),) +ifdef LibraryA all-local:: $(LibraryA) clean-local:: clean-a install-local:: install-a @@ -160,7 +203,7 @@ $(OcamlDir)/%.o: $(LibDir)/%.o $(Verb) ln -sf $< $@ clean-deplibs: - $(Verb) rm -f $(OutputLibs) + $(Verb) $(RM) -f $(OutputLibs) install-deplibs: $(Verb) $(MKDIR) $(PROJ_libocamldir) @@ -169,11 +212,12 @@ install-deplibs: done uninstall-deplibs: - $(Verb) rm -f $(DestLibs) + $(Verb) $(RM) -f $(DestLibs) ##===- Build ocaml interfaces (.mli's -> .cmi's) --------------------------===## +ifneq ($(OcamlHeaders),) all-local:: build-cmis clean-local:: clean-cmis install-local:: install-cmis @@ -194,14 +238,14 @@ clean-cmis:: # Also install the .mli's (headers) as documentation. install-cmis: $(OutputsCMI) $(OcamlHeaders) $(Verb) $(MKDIR) $(PROJ_libocamldir) - $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ - $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ - $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ - done $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ $(DataInstall) $(ObjDir)/$$i "$(PROJ_libocamldir)/$$i"; \ done + $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ + $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ + $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ + done uninstall-cmis:: $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ @@ -212,10 +256,16 @@ uninstall-cmis:: $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ $(RM) -f "$(PROJ_libocamldir)/$$i"; \ done +endif ##===- Build ocaml bytecode archive (.ml's -> .cmo's -> .cma) -------------===## +$(ObjDir)/%.cmo: $(ObjDir)/%.ml + $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" + $(Verb) $(Compile.CMO) $@ $< + +ifdef LIBRARYNAME all-local:: $(OutputCMA) clean-local:: clean-cma install-local:: install-cma @@ -228,10 +278,6 @@ $(LibraryCMA): $(ObjectsCMO) $(OcamlDir)/.dir $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" $(Verb) $(Archive.CMA) $@ $(ObjectsCMO) -$(ObjDir)/%.cmo: $(ObjDir)/%.ml - $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" - $(Verb) $(Compile.CMO) $@ $< - clean-cma:: $(Verb) $(RM) -f $(OutputCMA) $(UsedLibNames:%=$(OcamlDir)/%) @@ -243,7 +289,7 @@ install-cma:: $(OutputCMA) uninstall-cma:: $(Echo) "Uninstalling $(DestCMA)" -$(Verb) $(RM) -f $(DestCMA) - +endif ##===- Build optimized ocaml archive (.ml's -> .cmx's -> .cmxa, .a) -------===## @@ -251,6 +297,14 @@ uninstall-cma:: # If unavailable, 'configure' will not define OCAMLOPT in Makefile.config. ifdef OCAMLOPT +$(OcamlDir)/%.cmx: $(ObjDir)/%.cmx + $(Verb) $(CP) -f $< $@ + +$(ObjDir)/%.cmx: $(ObjDir)/%.ml + $(Echo) "Compiling optimized $(notdir $<) for $(BuildMode) build" + $(Verb) $(Compile.CMX) $@ $< + +ifdef LIBRARYNAME all-local:: $(OutputCMXA) $(OutputsCMX) clean-local:: clean-cmxa install-local:: install-cmxa @@ -260,18 +314,11 @@ $(OutputCMXA): $(LibraryCMXA) $(Verb) $(CP) -f $< $@ $(Verb) $(CP) -f $(<:.cmxa=.a) $(@:.cmxa=.a) -$(OcamlDir)/%.cmx: $(ObjDir)/%.cmx - $(Verb) $(CP) -f $< $@ - $(LibraryCMXA): $(ObjectsCMX) $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" $(Verb) $(Archive.CMXA) $@ $(ObjectsCMX) $(Verb) $(RM) -f $(@:.cmxa=.o) -$(ObjDir)/%.cmx: $(ObjDir)/%.ml - $(Echo) "Compiling optimized $(notdir $<) for $(BuildMode) build" - $(Verb) $(Compile.CMX) $@ $< - clean-cmxa:: $(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.a) $(OutputsCMX) @@ -295,7 +342,27 @@ uninstall-cmxa:: $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ $(RM) -f $(PROJ_libocamldir)/$$i; \ done +endif +endif + +##===- Build executables --------------------------------------------------===## + +ifdef TOOLNAME +all-local:: $(OutputEXE) +clean-local:: clean-exe + +$(OutputEXE): $(ToolEXE) $(OcamlDir)/.dir + $(Verb) $(CP) -f $< $@ +ifndef OCAMLOPT +$(ToolEXE): $(ObjectsCMO) $(OcamlDir)/.dir + $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" + $(Verb) $(Archive.EXE) $@ $(ObjectsCMO) +else +$(ToolEXE): $(ObjectsCMX) $(OcamlDir)/.dir + $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" + $(Verb) $(Archive.EXE) $@ $(ObjectsCMX) +endif endif ##===- Generate documentation ---------------------------------------------===## @@ -325,7 +392,10 @@ printcamlvars:: $(Echo) "LibraryCMA : " '$(LibraryCMA)' $(Echo) "LibraryCMXA : " '$(LibraryCMXA)' $(Echo) "OcamlSources1: " '$(OcamlSources1)' + $(Echo) "OcamlSources2: " '$(OcamlSources2)' $(Echo) "OcamlSources : " '$(OcamlSources)' + $(Echo) "OcamlHeaders1: " '$(OcamlHeaders1)' + $(Echo) "OcamlHeaders2: " '$(OcamlHeaders2)' $(Echo) "OcamlHeaders : " '$(OcamlHeaders)' $(Echo) "ObjectsCMI : " '$(ObjectsCMI)' $(Echo) "ObjectsCMO : " '$(ObjectsCMO)' @@ -340,4 +410,6 @@ printcamlvars:: .PHONY: printcamlvars build-cmis \ clean-a clean-cmis clean-cma clean-cmxa \ install-a install-cmis install-cma install-cmxa \ - uninstall-a uninstall-cmis uninstall-cma uninstall-cmxa + install-exe \ + uninstall-a uninstall-cmis uninstall-cma uninstall-cmxa \ + uninstall-exe