Makefile.ocaml revision a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0
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 170908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Find the ocaml stdlib root. /usr/local/lib/ocaml is the default when built 180908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# from source; distros use something like /usr/lib/ocaml/3.10.0. 190908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenifndef OCAML_LIBDIR 200908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenOCAML_LIBDIR := $(shell $(OCAMLC) -where) 210908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenendif 220908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 230908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# CFLAGS needs to be set before Makefile.rules is included. Yes, ocaml puts its 240908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# includes under its libdir. 250908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCFLAGS += -I$(OCAML_LIBDIR) 260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 270908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninclude $(LEVEL)/Makefile.common 280908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 290908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Intentionally ignore PROJ_prefix here. We want the ocaml stdlib. However, the 300908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# user can override this with OCAML_LIBDIR. 310908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenPROJ_libocamldir := $(DESTDIR)$(OCAML_LIBDIR) 320908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenOcamlDir := $(LibDir)/ocaml 330908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 340908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Info from llvm-config and similar 350908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenifdef UsedComponents 360908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenUsedLibs = $(shell $(LLVM_CONFIG) --libs $(UsedComponents)) 370908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenUsedLibNames = $(shell $(LLVM_CONFIG) --libnames $(UsedComponents)) 380908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenendif 390908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 400908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Tools 41a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOCAMLCFLAGS += -I $(OcamlDir) -I $(ObjDir) 420908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenOCAMLAFLAGS += $(patsubst %,-cclib %, \ 430908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(filter-out -L$(LibDir),$(shell $(LLVM_CONFIG) --ldflags)) \ 440908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(UsedLibs) -l$(LIBRARYNAME)) 450908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 460908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMI := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) -o) 470908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) -o) 480908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenArchive.CMA := $(strip $(OCAMLC) -a -custom $(OCAMLAFLAGS) -o) 490908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 500908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) -o) 510908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenArchive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) -o) 520908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 530908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Source files 54a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlSources1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml)) 55a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlHeaders1 := $(OcamlSources1:.ml=.mli) 56a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 57a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlSources := $(OcamlSources1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) 58a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlHeaders := $(OcamlHeaders1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) 59a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 60a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Intermediate files 61a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryCMA := $(ObjDir)/$(LIBRARYNAME).cma 62a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryCMXA := $(ObjDir)/$(LIBRARYNAME).cmxa 63a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMI := $(OcamlSources:%.ml=%.cmi) 64a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMO := $(OcamlSources:%.ml=%.cmo) 65a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMX := $(OcamlSources:%.ml=%.cmx) 66a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 67a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Output files 68a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# The .cmo files are the only intermediates; all others are to be installed. 69a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryA := $(OcamlDir)/lib$(LIBRARYNAME).a 70a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputCMA := $(LibraryCMA:$(ObjDir)/%.cma=$(OcamlDir)/%.cma) 71a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputCMXA := $(LibraryCMXA:$(ObjDir)/%.cmxa=$(OcamlDir)/%.cmxa) 72a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputsCMI := $(ObjectsCMI:$(ObjDir)/%.cmi=$(OcamlDir)/%.cmi) 73a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputsCMX := $(ObjectsCMX:$(ObjDir)/%.cmx=$(OcamlDir)/%.cmx) 740908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 750908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Installation targets 760908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenDestA := $(PROJ_libocamldir)/lib$(LIBRARYNAME).a 770908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenDestCMA := $(PROJ_libocamldir)/$(LIBRARYNAME).cma 780908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenDestCMXA := $(PROJ_libocamldir)/$(LIBRARYNAME).cmxa 790908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 800908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 81a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen##===- Dependencies -------------------------------------------------------===## 82a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Copy the sources into the intermediate directory because older ocamlc doesn't 83a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# support -o except when linking (outputs are placed next to inputs). 84a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 85a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.mli: $(PROJ_SRC_DIR)/%.mli $(ObjDir)/.dir 86a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 87a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 88a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.ml: $(PROJ_SRC_DIR)/%.ml $(ObjDir)/.dir 89a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 90a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 91a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) 92a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeader) > $@ 93a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 94a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen-include $(ObjDir)/$(LIBRARYNAME).ocamldep 95a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 96a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 970908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build static library from C sources --------------------------------===## 980908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 990908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenall-local:: $(LibraryA) 1000908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-a 1010908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-a 1020908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-a 1030908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1040908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryA): $(ObjectsO) $(OcamlDir)/.dir 1050908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Building $(BuildMode) $(notdir $@)" 1060908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $@ 1070908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive) $@ $(ObjectsO) 1080908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Ranlib) $@ 1090908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1100908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-a:: 1110908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(LibraryA) 1120908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1130908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-a:: $(LibraryA) 1140908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestA)" 1150908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 1160908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(LTInstall) $(LibraryA) $(DestA) 1170908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) 1180908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1190908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-a:: 1200908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestA)" 1210908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(DestA) 1220908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1230908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1240908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build ocaml interfaces (.mli's -> .cmi's) --------------------------===## 1250908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenall-local:: build-cmis 1270908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cmis 1280908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cmis 1290908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cmis 1300908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 131a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenbuild-cmis: $(OutputsCMI) 132a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 133a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OcamlDir)/%.cmi: $(ObjDir)/%.cmi $(OcamlDir)/.dir 134a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 1350908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 136a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmi: $(ObjDir)/%.mli $(ObjDir)/.dir 1370908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" 1380908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMI) $@ $< 1390908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1400908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cmis:: 141a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen -$(Verb) $(RM) -f $(OutputsCMI) 1420908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1430908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Also install the .mli's (headers) as documentation. 144a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cmis: $(OutputsCMI) $(OcamlHeaders) 1450908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 146a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ 1470908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 1480908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 1490908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 150a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ 1510908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 152a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(DataInstall) $(ObjDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 1530908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1540908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1550908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-cmis:: 156a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ 1570908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 1580908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f "$(PROJ_libocamldir)/$$i"; \ 1590908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 160a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ 1610908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 1620908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f "$(PROJ_libocamldir)/$$i"; \ 1630908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1640908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1650908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1660908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build ocaml bytecode archive (.ml's -> .cmo's -> .cma) -------------===## 1670908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 168a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenall-local:: $(OutputCMA) 1690908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cma 1700908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cma 1710908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cma 1720908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 173a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OutputCMA): $(LibraryCMA) $(OcamlDir)/.dir 174a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 175a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 1760908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryCMA): $(ObjectsCMO) $(OcamlDir)/.dir 1770908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" 1780908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive.CMA) $@ $(ObjectsCMO) 1790908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) for i in $(UsedLibNames); do \ 1800908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen ln -sf "$(LibDir)/$$i" "$(OcamlDir)/$$i"; \ 1810908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1820908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 183a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmo: $(ObjDir)/%.ml 1840908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" 1850908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMO) $@ $< 1860908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1870908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cma:: 188a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(RM) -f $(OutputCMA) $(UsedLibNames:%=$(OcamlDir)/%) 1890908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 190a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cma:: $(OutputCMA) 1910908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMA)" 1920908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 193a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMA) "$(DestCMA)" 1940908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) for i in $(UsedLibNames); do \ 1950908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 1960908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen ln -sf "$(PROJ_libdir)/$$i" "$(PROJ_libocamldir)/$$i"; \ 1970908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1980908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1990908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-cma:: 2000908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMA)" 2010908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(DestCMA) 2020908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) for i in $(UsedLibNames); do \ 2030908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 2040908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f "$(PROJ_libocamldir)/$$i"; \ 2050908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 2060908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2070908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2080908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build optimized ocaml archive (.ml's -> .cmx's -> .cmxa, .a) -------===## 2090908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2100908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# The ocamlopt compiler is supported on a set of targets disjoint from LLVM's. 2110908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# If unavailable, 'configure' will not define OCAMLOPT in Makefile.config. 2120908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenifdef OCAMLOPT 2130908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 214a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenall-local:: $(OutputCMXA) $(OutputsCMX) 2150908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cmxa 2160908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cmxa 2170908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cmxa 2180908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 219a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OutputCMXA): $(LibraryCMXA) 220a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 221a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $(<:.cmxa=.a) $(@:.cmxa=.a) 222a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 223a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OcamlDir)/%.cmx: $(ObjDir)/%.cmx 224a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 225a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 2260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryCMXA): $(ObjectsCMX) 2270908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" 2280908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive.CMXA) $@ $(ObjectsCMX) 2290908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(@:.cmxa=.o) 2300908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 231a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmx: $(ObjDir)/%.ml 2320908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling optimized $(notdir $<) for $(BuildMode) build" 2330908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMX) $@ $< 2340908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2350908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cmxa:: 236a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.o) $(OutputsCMX) 2370908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 238a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cmxa:: $(OutputCMXA) $(OutputsCMX) 2390908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 2400908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMXA)" 241a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMXA) $(DestCMXA) 2420908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMXA:.cmxa=.a)" 243a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMXA:.cmxa=.a) $(DestCMXA:.cmxa=.a) 244a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \ 2450908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 2460908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 2470908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 2480908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 249a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenuninstall-cmxa:: 2500908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMXA)" 2510908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(DestCMXA) 2520908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMXA:.cmxa=.a)" 2530908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(DestCMXA:.cmxa=.a) 254a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \ 2550908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 2560908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f $(PROJ_libocamldir)/$$i; \ 2570908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 2580908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2590908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenendif 2600908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2610908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2620908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Debugging gunk -----------------------------------------------------===## 2630908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenprintvars:: printcamlvars 2640908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2650908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenprintcamlvars:: 2660908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LLVM_CONFIG : " '$(LLVM_CONFIG)' 2670908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLCFLAGS : " '$(OCAMLCFLAGS)' 2680908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLAFLAGS : " '$(OCAMLAFLAGS)' 2690908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLC : " '$(OCAMLC)' 2700908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLOPT : " '$(OCAMLOPT)' 271a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OCAMLDEP : " '$(OCAMLDEP)' 2720908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMI : " '$(Compile.CMI)' 2730908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMO : " '$(Compile.CMO)' 2740908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archive.CMA : " '$(Archive.CMA)' 2750908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMX : " '$(Compile.CMX)' 2760908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archive.CMXA : " '$(Archive.CMXA)' 2770908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "CAML_LIBDIR : " '$(CAML_LIBDIR)' 2780908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LibraryCMA : " '$(LibraryCMA)' 2790908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LibraryCMXA : " '$(LibraryCMXA)' 280a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OcamlSources1: " '$(OcamlSources1)' 2810908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OcamlSources : " '$(OcamlSources)' 282a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OcamlHeaders : " '$(OcamlHeaders)' 2830908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMI : " '$(ObjectsCMI)' 2840908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMO : " '$(ObjectsCMO)' 2850908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMX : " '$(ObjectsCMX)' 2860908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAML_LIBDIR : " '$(OCAML_LIBDIR)' 2870908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestA : " '$(DestA)' 2880908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestCMA : " '$(DestCMA)' 2890908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestCMXA : " '$(DestCMXA)' 2900908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "UsedLibs : " '$(UsedLibs)' 2910908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "UsedLibNames : " '$(UsedLibNames)' 2920908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2930908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen.PHONY: printcamlvars build-cmis \ 2940908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen clean-a clean-cmis clean-cma clean-cmxa \ 2950908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen install-a install-cmis install-cma install-cmxa \ 2960908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen uninstall-a uninstall-cmis uninstall-cma uninstall-cmxa 297