Makefile.ocaml revision 3b802476d24a6b8c7d1e645f99b4c25ef6e97809
10908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- tools/ml/Makefile -----------------------------------*- Makefile -*-===## 20908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# 30908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# The LLVM Compiler Infrastructure 40908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# 50908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# This file was developed by Gordon Henriksen and is distributed under the 60908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# University of Illinois Open Source License. See LICENSE.TXT for details. 70908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# 80908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===----------------------------------------------------------------------===## 90908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# 100908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# An ocaml library is a unique project type in the context of LLVM, so rules are 110908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# here rather than in Makefile.rules. 120908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# 130908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===----------------------------------------------------------------------===## 140908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 150908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninclude $(LEVEL)/Makefile.config 160908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 173b802476d24a6b8c7d1e645f99b4c25ef6e97809Gordon Henriksen# CFLAGS needs to be set before Makefile.rules is included. 183b802476d24a6b8c7d1e645f99b4c25ef6e97809Gordon HenriksenCFLAGS += -I$(shell $(OCAMLC) -where) 190908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 200908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninclude $(LEVEL)/Makefile.common 210908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 220908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Intentionally ignore PROJ_prefix here. We want the ocaml stdlib. However, the 231d4e0782ba9761e3c664de53b837b74c0c818ff1Gordon Henriksen# user can override this with OCAML_LIBDIR or configure --with-ocaml-libdir=. 240908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenPROJ_libocamldir := $(DESTDIR)$(OCAML_LIBDIR) 250908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenOcamlDir := $(LibDir)/ocaml 260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 270908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Info from llvm-config and similar 280908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenifdef UsedComponents 290908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenUsedLibs = $(shell $(LLVM_CONFIG) --libs $(UsedComponents)) 300908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenUsedLibNames = $(shell $(LLVM_CONFIG) --libnames $(UsedComponents)) 310908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenendif 320908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 330908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Tools 34a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOCAMLCFLAGS += -I $(OcamlDir) -I $(ObjDir) 350908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenOCAMLAFLAGS += $(patsubst %,-cclib %, \ 360908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(filter-out -L$(LibDir),$(shell $(LLVM_CONFIG) --ldflags)) \ 370908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(UsedLibs) -l$(LIBRARYNAME)) 380908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 390908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMI := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) -o) 400908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) -o) 410908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenArchive.CMA := $(strip $(OCAMLC) -a -custom $(OCAMLAFLAGS) -o) 420908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 430908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) -o) 440908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenArchive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) -o) 450908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 460908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Source files 47a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlSources1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml)) 48a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlHeaders1 := $(OcamlSources1:.ml=.mli) 49a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 50a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlSources := $(OcamlSources1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) 51a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlHeaders := $(OcamlHeaders1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) 52a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 53a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Intermediate files 54a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryCMA := $(ObjDir)/$(LIBRARYNAME).cma 55a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryCMXA := $(ObjDir)/$(LIBRARYNAME).cmxa 56a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMI := $(OcamlSources:%.ml=%.cmi) 57a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMO := $(OcamlSources:%.ml=%.cmo) 58a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMX := $(OcamlSources:%.ml=%.cmx) 59a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 60a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Output files 61a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# The .cmo files are the only intermediates; all others are to be installed. 62a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryA := $(OcamlDir)/lib$(LIBRARYNAME).a 63a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputCMA := $(LibraryCMA:$(ObjDir)/%.cma=$(OcamlDir)/%.cma) 64a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputCMXA := $(LibraryCMXA:$(ObjDir)/%.cmxa=$(OcamlDir)/%.cmxa) 65a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputsCMI := $(ObjectsCMI:$(ObjDir)/%.cmi=$(OcamlDir)/%.cmi) 66a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputsCMX := $(ObjectsCMX:$(ObjDir)/%.cmx=$(OcamlDir)/%.cmx) 670908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 680908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Installation targets 690908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenDestA := $(PROJ_libocamldir)/lib$(LIBRARYNAME).a 700908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenDestCMA := $(PROJ_libocamldir)/$(LIBRARYNAME).cma 710908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenDestCMXA := $(PROJ_libocamldir)/$(LIBRARYNAME).cmxa 720908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 730908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 74a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen##===- Dependencies -------------------------------------------------------===## 75a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Copy the sources into the intermediate directory because older ocamlc doesn't 76a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# support -o except when linking (outputs are placed next to inputs). 77a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 78a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.mli: $(PROJ_SRC_DIR)/%.mli $(ObjDir)/.dir 79a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 80a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 81a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.ml: $(PROJ_SRC_DIR)/%.ml $(ObjDir)/.dir 82a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 83a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 84ab4456f10a72f3a7c73dac0e95578b9b7e4250b8Gordon Henriksen$(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \ 85ab4456f10a72f3a7c73dac0e95578b9b7e4250b8Gordon Henriksen $(OcamlDir)/.dir $(ObjDir)/.dir 86a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeader) > $@ 87a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 8846abf91f7378fb7bb118d66fe6d69b5d3af1e9d5Gordon Henriksen$(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi) 8946abf91f7378fb7bb118d66fe6d69b5d3af1e9d5Gordon Henriksen 90a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen-include $(ObjDir)/$(LIBRARYNAME).ocamldep 91a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 92a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 930908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build static library from C sources --------------------------------===## 940908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 950908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenall-local:: $(LibraryA) 960908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-a 970908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-a 980908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-a 990908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1000908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryA): $(ObjectsO) $(OcamlDir)/.dir 1010908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Building $(BuildMode) $(notdir $@)" 1020908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $@ 1030908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive) $@ $(ObjectsO) 1040908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Ranlib) $@ 1050908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1060908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-a:: 1070908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(LibraryA) 1080908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1090908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-a:: $(LibraryA) 1100908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestA)" 1110908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 1120908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(LTInstall) $(LibraryA) $(DestA) 1130908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) 1140908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1150908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-a:: 1160908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestA)" 1170908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(DestA) 1180908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1190908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1200908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build ocaml interfaces (.mli's -> .cmi's) --------------------------===## 1210908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1220908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenall-local:: build-cmis 1230908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cmis 1240908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cmis 1250908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cmis 1260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 127a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenbuild-cmis: $(OutputsCMI) 128a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 129a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OcamlDir)/%.cmi: $(ObjDir)/%.cmi $(OcamlDir)/.dir 130a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 1310908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 132a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmi: $(ObjDir)/%.mli $(ObjDir)/.dir 1330908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" 1340908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMI) $@ $< 1350908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1360908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cmis:: 137a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen -$(Verb) $(RM) -f $(OutputsCMI) 1380908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1390908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Also install the .mli's (headers) as documentation. 140a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cmis: $(OutputsCMI) $(OcamlHeaders) 1410908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 142a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ 1430908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 1440908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 1450908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 146a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ 1470908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 148a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(DataInstall) $(ObjDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 1490908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1500908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1510908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-cmis:: 152a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ 1530908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 1540908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f "$(PROJ_libocamldir)/$$i"; \ 1550908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 156a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ 1570908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 1580908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f "$(PROJ_libocamldir)/$$i"; \ 1590908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1600908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1610908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1620908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build ocaml bytecode archive (.ml's -> .cmo's -> .cma) -------------===## 1630908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 164a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenall-local:: $(OutputCMA) 1650908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cma 1660908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cma 1670908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cma 1680908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 169a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OutputCMA): $(LibraryCMA) $(OcamlDir)/.dir 170a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 171a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 1720908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryCMA): $(ObjectsCMO) $(OcamlDir)/.dir 1730908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" 1740908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive.CMA) $@ $(ObjectsCMO) 1750908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) for i in $(UsedLibNames); do \ 1760908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen ln -sf "$(LibDir)/$$i" "$(OcamlDir)/$$i"; \ 1770908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1780908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 179a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmo: $(ObjDir)/%.ml 1800908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" 1810908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMO) $@ $< 1820908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1830908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cma:: 184a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(RM) -f $(OutputCMA) $(UsedLibNames:%=$(OcamlDir)/%) 1850908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 186a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cma:: $(OutputCMA) 1870908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMA)" 1880908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 189a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMA) "$(DestCMA)" 1900908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) for i in $(UsedLibNames); do \ 1910908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 1920908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen ln -sf "$(PROJ_libdir)/$$i" "$(PROJ_libocamldir)/$$i"; \ 1930908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1940908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1950908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-cma:: 1960908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMA)" 1970908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(DestCMA) 1980908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) for i in $(UsedLibNames); do \ 1990908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 2000908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f "$(PROJ_libocamldir)/$$i"; \ 2010908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 2020908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2030908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2040908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build optimized ocaml archive (.ml's -> .cmx's -> .cmxa, .a) -------===## 2050908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2060908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# The ocamlopt compiler is supported on a set of targets disjoint from LLVM's. 2070908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# If unavailable, 'configure' will not define OCAMLOPT in Makefile.config. 2080908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenifdef OCAMLOPT 2090908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 210a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenall-local:: $(OutputCMXA) $(OutputsCMX) 2110908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cmxa 2120908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cmxa 2130908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cmxa 2140908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 215a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OutputCMXA): $(LibraryCMXA) 216a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 217a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $(<:.cmxa=.a) $(@:.cmxa=.a) 218a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 219a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OcamlDir)/%.cmx: $(ObjDir)/%.cmx 220a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 221a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 2220908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryCMXA): $(ObjectsCMX) 2230908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" 2240908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive.CMXA) $@ $(ObjectsCMX) 2250908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(@:.cmxa=.o) 2260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 227a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmx: $(ObjDir)/%.ml 2280908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling optimized $(notdir $<) for $(BuildMode) build" 2290908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMX) $@ $< 2300908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2310908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cmxa:: 232a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.o) $(OutputsCMX) 2330908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 234a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cmxa:: $(OutputCMXA) $(OutputsCMX) 2350908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 2360908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMXA)" 237a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMXA) $(DestCMXA) 2380908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMXA:.cmxa=.a)" 239a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMXA:.cmxa=.a) $(DestCMXA:.cmxa=.a) 240a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \ 2410908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 2420908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 2430908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 2440908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 245a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenuninstall-cmxa:: 2460908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMXA)" 2470908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(DestCMXA) 2480908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMXA:.cmxa=.a)" 2490908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(DestCMXA:.cmxa=.a) 250a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \ 2510908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 2520908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f $(PROJ_libocamldir)/$$i; \ 2530908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 2540908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2550908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenendif 2560908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2570908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2580908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Debugging gunk -----------------------------------------------------===## 2590908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenprintvars:: printcamlvars 2600908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2610908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenprintcamlvars:: 2620908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LLVM_CONFIG : " '$(LLVM_CONFIG)' 2630908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLCFLAGS : " '$(OCAMLCFLAGS)' 2640908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLAFLAGS : " '$(OCAMLAFLAGS)' 2650908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLC : " '$(OCAMLC)' 2660908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLOPT : " '$(OCAMLOPT)' 267a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OCAMLDEP : " '$(OCAMLDEP)' 2680908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMI : " '$(Compile.CMI)' 2690908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMO : " '$(Compile.CMO)' 2700908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archive.CMA : " '$(Archive.CMA)' 2710908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMX : " '$(Compile.CMX)' 2720908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archive.CMXA : " '$(Archive.CMXA)' 2730908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "CAML_LIBDIR : " '$(CAML_LIBDIR)' 2740908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LibraryCMA : " '$(LibraryCMA)' 2750908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LibraryCMXA : " '$(LibraryCMXA)' 276a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OcamlSources1: " '$(OcamlSources1)' 2770908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OcamlSources : " '$(OcamlSources)' 278a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OcamlHeaders : " '$(OcamlHeaders)' 2790908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMI : " '$(ObjectsCMI)' 2800908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMO : " '$(ObjectsCMO)' 2810908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMX : " '$(ObjectsCMX)' 2820908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAML_LIBDIR : " '$(OCAML_LIBDIR)' 2830908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestA : " '$(DestA)' 2840908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestCMA : " '$(DestCMA)' 2850908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestCMXA : " '$(DestCMXA)' 2860908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "UsedLibs : " '$(UsedLibs)' 2870908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "UsedLibNames : " '$(UsedLibNames)' 2880908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2890908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen.PHONY: printcamlvars build-cmis \ 2900908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen clean-a clean-cmis clean-cma clean-cmxa \ 2910908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen install-a install-cmis install-cma install-cmxa \ 2920908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen uninstall-a uninstall-cmis uninstall-cma uninstall-cmxa 293