Makefile.ocaml revision 516276edd4adadf8d521ae6ba29713dacc353c0a
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# 13c0491ac8b6c24a7d0db8c0a60f76cfb1d66f84abGordon Henriksen# Reference materials on installing ocaml libraries: 14c0491ac8b6c24a7d0db8c0a60f76cfb1d66f84abGordon Henriksen# 15c0491ac8b6c24a7d0db8c0a60f76cfb1d66f84abGordon Henriksen# https://fedoraproject.org/wiki/Packaging/OCaml 16c0491ac8b6c24a7d0db8c0a60f76cfb1d66f84abGordon Henriksen# http://pkg-ocaml-maint.alioth.debian.org/ocaml_packaging_policy.txt 17c0491ac8b6c24a7d0db8c0a60f76cfb1d66f84abGordon Henriksen# 180908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===----------------------------------------------------------------------===## 190908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 200908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninclude $(LEVEL)/Makefile.config 210908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 223b802476d24a6b8c7d1e645f99b4c25ef6e97809Gordon Henriksen# CFLAGS needs to be set before Makefile.rules is included. 233b802476d24a6b8c7d1e645f99b4c25ef6e97809Gordon HenriksenCFLAGS += -I$(shell $(OCAMLC) -where) 240908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 250908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninclude $(LEVEL)/Makefile.common 260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 270908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Intentionally ignore PROJ_prefix here. We want the ocaml stdlib. However, the 281d4e0782ba9761e3c664de53b837b74c0c818ff1Gordon Henriksen# user can override this with OCAML_LIBDIR or configure --with-ocaml-libdir=. 290908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenPROJ_libocamldir := $(DESTDIR)$(OCAML_LIBDIR) 300908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenOcamlDir := $(LibDir)/ocaml 310908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 320908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Info from llvm-config and similar 330908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenifdef UsedComponents 340908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenUsedLibs = $(shell $(LLVM_CONFIG) --libs $(UsedComponents)) 350908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenUsedLibNames = $(shell $(LLVM_CONFIG) --libnames $(UsedComponents)) 360908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenendif 370908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 380908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Tools 39a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOCAMLCFLAGS += -I $(OcamlDir) -I $(ObjDir) 400908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenOCAMLAFLAGS += $(patsubst %,-cclib %, \ 41ed29a28464d1b19d3e043a4cf1e95eedca745842Gordon Henriksen $(filter-out -L$(LibDir),-l$(LIBRARYNAME) \ 42ed29a28464d1b19d3e043a4cf1e95eedca745842Gordon Henriksen $(shell $(LLVM_CONFIG) --ldflags)) \ 43ed29a28464d1b19d3e043a4cf1e95eedca745842Gordon Henriksen $(UsedLibs)) 440908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 450908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMI := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) -o) 460908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) -o) 470908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenArchive.CMA := $(strip $(OCAMLC) -a -custom $(OCAMLAFLAGS) -o) 480908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 490908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenCompile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) -o) 500908d49c22775d20a88f595845b515f669d528f7Gordon HenriksenArchive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) -o) 510908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 520908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Source files 53a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlSources1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml)) 54a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlHeaders1 := $(OcamlSources1:.ml=.mli) 55a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 56a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlSources := $(OcamlSources1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) 57a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOcamlHeaders := $(OcamlHeaders1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) 58a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 59a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Intermediate files 60a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryCMA := $(ObjDir)/$(LIBRARYNAME).cma 61a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryCMXA := $(ObjDir)/$(LIBRARYNAME).cmxa 62a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMI := $(OcamlSources:%.ml=%.cmi) 63a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMO := $(OcamlSources:%.ml=%.cmo) 64a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenObjectsCMX := $(OcamlSources:%.ml=%.cmx) 65a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 66a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Output files 67a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# The .cmo files are the only intermediates; all others are to be installed. 68a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenLibraryA := $(OcamlDir)/lib$(LIBRARYNAME).a 69a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputCMA := $(LibraryCMA:$(ObjDir)/%.cma=$(OcamlDir)/%.cma) 70a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputCMXA := $(LibraryCMXA:$(ObjDir)/%.cmxa=$(OcamlDir)/%.cmxa) 71a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputsCMI := $(ObjectsCMI:$(ObjDir)/%.cmi=$(OcamlDir)/%.cmi) 72a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon HenriksenOutputsCMX := $(ObjectsCMX:$(ObjDir)/%.cmx=$(OcamlDir)/%.cmx) 73516276edd4adadf8d521ae6ba29713dacc353c0aGordon HenriksenOutputLibs := $(UsedLibNames:%=$(OcamlDir)/%) 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 79516276edd4adadf8d521ae6ba29713dacc353c0aGordon HenriksenDestLibs := $(UsedLibNames:%=$(PROJ_libocamldir)/%) 800908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 810908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 82a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen##===- Dependencies -------------------------------------------------------===## 83a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# Copy the sources into the intermediate directory because older ocamlc doesn't 84a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen# support -o except when linking (outputs are placed next to inputs). 85a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 86a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.mli: $(PROJ_SRC_DIR)/%.mli $(ObjDir)/.dir 87a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 88a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 89a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.ml: $(PROJ_SRC_DIR)/%.ml $(ObjDir)/.dir 90a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 91a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 92ab4456f10a72f3a7c73dac0e95578b9b7e4250b8Gordon Henriksen$(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \ 93ab4456f10a72f3a7c73dac0e95578b9b7e4250b8Gordon Henriksen $(OcamlDir)/.dir $(ObjDir)/.dir 94a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeader) > $@ 95a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 9646abf91f7378fb7bb118d66fe6d69b5d3af1e9d5Gordon Henriksen$(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi) 9746abf91f7378fb7bb118d66fe6d69b5d3af1e9d5Gordon Henriksen 98a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen-include $(ObjDir)/$(LIBRARYNAME).ocamldep 99a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 100a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 1010908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build static library from C sources --------------------------------===## 1020908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1030908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenall-local:: $(LibraryA) 1040908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-a 1050908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-a 1060908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-a 1070908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1080908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryA): $(ObjectsO) $(OcamlDir)/.dir 1090908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Building $(BuildMode) $(notdir $@)" 1100908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $@ 1110908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive) $@ $(ObjectsO) 1120908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Ranlib) $@ 1130908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1140908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-a:: 1150908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(LibraryA) 1160908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1170908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-a:: $(LibraryA) 1180908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestA)" 1190908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 1200908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(LTInstall) $(LibraryA) $(DestA) 1210908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) 1220908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1230908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-a:: 1240908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestA)" 1250908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(DestA) 1260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1270908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 128516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen##===- Deposit dependent libraries adjacent to Ocaml libs -----------------===## 129516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen 130516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksenall-local:: build-deplibs 131516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksenclean-local:: clean-deplibs 132516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henrikseninstall-local:: install-deplibs 133516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksenuninstall-local:: uninstall-deplibs 134516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen 135516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksenbuild-deplibs: $(OutputLibs) 136516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen 137516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen$(OcamlDir)/%.a: $(LibDir)/%.a 138516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen $(Verb) ln -sf $< $@ 139516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen 140516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksenclean-deplibs: 141516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen $(Verb) rm -f $(OutputLibs) 142516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen 143516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henrikseninstall-deplibs: 144516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen $(Verb) for i in $(DestLibs:$(PROJ_libocamldir)/%=%); do \ 145516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen ln -sf "$(PROJ_libdir)/$$i" "$(PROJ_libocamldir)/$$i"; \ 146516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen done 147516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen 148516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksenuninstall-deplibs: 149516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen $(Verb) rm -f $(DestLibs) 150516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen 151516276edd4adadf8d521ae6ba29713dacc353c0aGordon Henriksen 1520908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build ocaml interfaces (.mli's -> .cmi's) --------------------------===## 1530908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1540908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenall-local:: build-cmis 1550908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cmis 1560908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cmis 1570908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cmis 1580908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 159a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenbuild-cmis: $(OutputsCMI) 160a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 161a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OcamlDir)/%.cmi: $(ObjDir)/%.cmi $(OcamlDir)/.dir 162a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 1630908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 164a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmi: $(ObjDir)/%.mli $(ObjDir)/.dir 1650908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" 1660908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMI) $@ $< 1670908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1680908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cmis:: 169a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen -$(Verb) $(RM) -f $(OutputsCMI) 1700908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1710908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# Also install the .mli's (headers) as documentation. 172a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cmis: $(OutputsCMI) $(OcamlHeaders) 1730908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 174a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ 1750908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 1760908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 1770908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 178a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ 1790908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 180a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(DataInstall) $(ObjDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 1810908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1820908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1830908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-cmis:: 184a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ 1850908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 1860908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f "$(PROJ_libocamldir)/$$i"; \ 1870908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 188a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ 1890908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 1900908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f "$(PROJ_libocamldir)/$$i"; \ 1910908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 1920908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1930908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 1940908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build ocaml bytecode archive (.ml's -> .cmo's -> .cma) -------------===## 1950908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 196a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenall-local:: $(OutputCMA) 1970908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cma 1980908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cma 1990908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cma 2000908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 201a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OutputCMA): $(LibraryCMA) $(OcamlDir)/.dir 202a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 203a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 2040908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryCMA): $(ObjectsCMO) $(OcamlDir)/.dir 2050908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" 2060908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive.CMA) $@ $(ObjectsCMO) 2070908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 208a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmo: $(ObjDir)/%.ml 2090908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" 2100908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMO) $@ $< 2110908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2120908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cma:: 213a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(RM) -f $(OutputCMA) $(UsedLibNames:%=$(OcamlDir)/%) 2140908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 215a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cma:: $(OutputCMA) 2160908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMA)" 2170908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 218a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMA) "$(DestCMA)" 2190908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2200908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-cma:: 2210908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMA)" 2220908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen -$(Verb) $(RM) -f $(DestCMA) 2230908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2240908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2250908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Build optimized ocaml archive (.ml's -> .cmx's -> .cmxa, .a) -------===## 2260908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2270908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# The ocamlopt compiler is supported on a set of targets disjoint from LLVM's. 2280908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen# If unavailable, 'configure' will not define OCAMLOPT in Makefile.config. 2290908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenifdef OCAMLOPT 2300908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 231a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenall-local:: $(OutputCMXA) $(OutputsCMX) 2320908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-local:: clean-cmxa 2330908d49c22775d20a88f595845b515f669d528f7Gordon Henrikseninstall-local:: install-cmxa 2340908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenuninstall-local:: uninstall-cmxa 2350908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 236a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OutputCMXA): $(LibraryCMXA) 237a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 238a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $(<:.cmxa=.a) $(@:.cmxa=.a) 239a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 240a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(OcamlDir)/%.cmx: $(ObjDir)/%.cmx 241a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(CP) -f $< $@ 242a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen 2430908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen$(LibraryCMXA): $(ObjectsCMX) 2440908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" 2450908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Archive.CMXA) $@ $(ObjectsCMX) 2460908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(@:.cmxa=.o) 2470908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 248a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen$(ObjDir)/%.cmx: $(ObjDir)/%.ml 2490908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compiling optimized $(notdir $<) for $(BuildMode) build" 2500908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(Compile.CMX) $@ $< 2510908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2520908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenclean-cmxa:: 253a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.o) $(OutputsCMX) 2540908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 255a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henrikseninstall-cmxa:: $(OutputCMXA) $(OutputsCMX) 2560908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(MKDIR) $(PROJ_libocamldir) 2570908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMXA)" 258a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMXA) $(DestCMXA) 2590908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Installing $(BuildMode) $(DestCMXA:.cmxa=.a)" 260a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) $(DataInstall) $(OutputCMXA:.cmxa=.a) $(DestCMXA:.cmxa=.a) 261a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \ 2620908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ 2630908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ 2640908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 2650908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 266a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksenuninstall-cmxa:: 2670908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMXA)" 2680908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(DestCMXA) 2690908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Uninstalling $(DestCMXA:.cmxa=.a)" 2700908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Verb) $(RM) -f $(DestCMXA:.cmxa=.a) 271a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \ 2720908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ 2730908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(RM) -f $(PROJ_libocamldir)/$$i; \ 2740908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen done 2750908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2760908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenendif 2770908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2780908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2790908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen##===- Debugging gunk -----------------------------------------------------===## 2800908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenprintvars:: printcamlvars 2810908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 2820908d49c22775d20a88f595845b515f669d528f7Gordon Henriksenprintcamlvars:: 2830908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LLVM_CONFIG : " '$(LLVM_CONFIG)' 2840908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLCFLAGS : " '$(OCAMLCFLAGS)' 2850908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLAFLAGS : " '$(OCAMLAFLAGS)' 2860908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLC : " '$(OCAMLC)' 2870908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAMLOPT : " '$(OCAMLOPT)' 288a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OCAMLDEP : " '$(OCAMLDEP)' 2890908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMI : " '$(Compile.CMI)' 2900908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMO : " '$(Compile.CMO)' 2910908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archive.CMA : " '$(Archive.CMA)' 2920908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Compile.CMX : " '$(Compile.CMX)' 2930908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "Archive.CMXA : " '$(Archive.CMXA)' 2940908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "CAML_LIBDIR : " '$(CAML_LIBDIR)' 2950908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LibraryCMA : " '$(LibraryCMA)' 2960908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "LibraryCMXA : " '$(LibraryCMXA)' 297a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OcamlSources1: " '$(OcamlSources1)' 2980908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OcamlSources : " '$(OcamlSources)' 299a8c3660c1a4be5d4887f1899bc3c8e62b875c6c0Gordon Henriksen $(Echo) "OcamlHeaders : " '$(OcamlHeaders)' 3000908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMI : " '$(ObjectsCMI)' 3010908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMO : " '$(ObjectsCMO)' 3020908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "ObjectsCMX : " '$(ObjectsCMX)' 3030908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "OCAML_LIBDIR : " '$(OCAML_LIBDIR)' 3040908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestA : " '$(DestA)' 3050908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestCMA : " '$(DestCMA)' 3060908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "DestCMXA : " '$(DestCMXA)' 3070908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "UsedLibs : " '$(UsedLibs)' 3080908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen $(Echo) "UsedLibNames : " '$(UsedLibNames)' 3090908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen 3100908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen.PHONY: printcamlvars build-cmis \ 3110908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen clean-a clean-cmis clean-cma clean-cmxa \ 3120908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen install-a install-cmis install-cma install-cmxa \ 3130908d49c22775d20a88f595845b515f669d528f7Gordon Henriksen uninstall-a uninstall-cmis uninstall-cma uninstall-cmxa 314