Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 1 | ##===- tools/ml/Makefile -----------------------------------*- Makefile -*-===## |
| 2 | # |
| 3 | # The LLVM Compiler Infrastructure |
| 4 | # |
Chris Lattner | 57360d1 | 2007-12-29 20:11:13 +0000 | [diff] [blame] | 5 | # This file is distributed under the University of Illinois Open Source |
| 6 | # License. See LICENSE.TXT for details. |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 7 | # |
| 8 | ##===----------------------------------------------------------------------===## |
| 9 | # |
| 10 | # An ocaml library is a unique project type in the context of LLVM, so rules are |
| 11 | # here rather than in Makefile.rules. |
| 12 | # |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 13 | # Reference materials on installing ocaml libraries: |
| 14 | # |
| 15 | # https://fedoraproject.org/wiki/Packaging/OCaml |
| 16 | # http://pkg-ocaml-maint.alioth.debian.org/ocaml_packaging_policy.txt |
| 17 | # |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 18 | ##===----------------------------------------------------------------------===## |
| 19 | |
| 20 | include $(LEVEL)/Makefile.config |
| 21 | |
Gordon Henriksen | 3b80247 | 2007-10-04 00:07:50 +0000 | [diff] [blame] | 22 | # CFLAGS needs to be set before Makefile.rules is included. |
Gordon Henriksen | 9e7aba2 | 2008-01-06 21:54:35 +0000 | [diff] [blame] | 23 | CXX.Flags += -I"$(shell $(OCAMLC) -where)" |
| 24 | C.Flags += -I"$(shell $(OCAMLC) -where)" |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 25 | |
| 26 | include $(LEVEL)/Makefile.common |
| 27 | |
| 28 | # Intentionally ignore PROJ_prefix here. We want the ocaml stdlib. However, the |
Gordon Henriksen | 1d4e078 | 2007-10-02 16:42:10 +0000 | [diff] [blame] | 29 | # user can override this with OCAML_LIBDIR or configure --with-ocaml-libdir=. |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 30 | PROJ_libocamldir := $(DESTDIR)$(OCAML_LIBDIR) |
| 31 | OcamlDir := $(LibDir)/ocaml |
| 32 | |
| 33 | # Info from llvm-config and similar |
| 34 | ifdef UsedComponents |
| 35 | UsedLibs = $(shell $(LLVM_CONFIG) --libs $(UsedComponents)) |
| 36 | UsedLibNames = $(shell $(LLVM_CONFIG) --libnames $(UsedComponents)) |
| 37 | endif |
| 38 | |
| 39 | # Tools |
Bob Wilson | 46c95bb | 2009-03-06 00:00:58 +0000 | [diff] [blame] | 40 | OCAMLCFLAGS += -I $(ObjDir) -I $(OcamlDir) |
Gordon Henriksen | f368dad | 2008-03-10 16:15:32 +0000 | [diff] [blame] | 41 | ifneq ($(ObjectsO),) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 42 | OCAMLAFLAGS += $(patsubst %,-cclib %, \ |
Gordon Henriksen | ed29a28 | 2007-10-12 19:48:13 +0000 | [diff] [blame] | 43 | $(filter-out -L$(LibDir),-l$(LIBRARYNAME) \ |
| 44 | $(shell $(LLVM_CONFIG) --ldflags)) \ |
| 45 | $(UsedLibs)) |
Gordon Henriksen | f368dad | 2008-03-10 16:15:32 +0000 | [diff] [blame] | 46 | else |
| 47 | OCAMLAFLAGS += $(patsubst %,-cclib %, \ |
| 48 | $(filter-out -L$(LibDir),$(shell $(LLVM_CONFIG) --ldflags)) \ |
| 49 | $(UsedLibs)) |
| 50 | endif |
Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 51 | |
Gordon Henriksen | 4e20a09 | 2007-12-25 08:37:43 +0000 | [diff] [blame] | 52 | # -g was introduced in 3.10.0. |
| 53 | #ifneq ($(ENABLE_OPTIMIZED),1) |
| 54 | # OCAMLDEBUGFLAG := -g |
| 55 | #endif |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 56 | |
Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 57 | Compile.CMI := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o) |
| 58 | Compile.CMO := $(strip $(OCAMLC) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o) |
| 59 | Archive.CMA := $(strip $(OCAMLC) -a -custom $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) \ |
| 60 | -o) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 61 | |
Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 62 | Compile.CMX := $(strip $(OCAMLOPT) -c $(OCAMLCFLAGS) $(OCAMLDEBUGFLAG) -o) |
| 63 | Archive.CMXA := $(strip $(OCAMLOPT) -a $(OCAMLAFLAGS) $(OCAMLDEBUGFLAG) -o) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 64 | |
| 65 | # Source files |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 66 | OcamlSources1 := $(sort $(wildcard $(PROJ_SRC_DIR)/*.ml)) |
| 67 | OcamlHeaders1 := $(OcamlSources1:.ml=.mli) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 68 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 69 | OcamlSources := $(OcamlSources1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) |
| 70 | OcamlHeaders := $(OcamlHeaders1:$(PROJ_SRC_DIR)/%=$(ObjDir)/%) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 71 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 72 | # Intermediate files |
| 73 | LibraryCMA := $(ObjDir)/$(LIBRARYNAME).cma |
| 74 | LibraryCMXA := $(ObjDir)/$(LIBRARYNAME).cmxa |
| 75 | ObjectsCMI := $(OcamlSources:%.ml=%.cmi) |
| 76 | ObjectsCMO := $(OcamlSources:%.ml=%.cmo) |
| 77 | ObjectsCMX := $(OcamlSources:%.ml=%.cmx) |
| 78 | |
| 79 | # Output files |
| 80 | # The .cmo files are the only intermediates; all others are to be installed. |
| 81 | LibraryA := $(OcamlDir)/lib$(LIBRARYNAME).a |
| 82 | OutputCMA := $(LibraryCMA:$(ObjDir)/%.cma=$(OcamlDir)/%.cma) |
| 83 | OutputCMXA := $(LibraryCMXA:$(ObjDir)/%.cmxa=$(OcamlDir)/%.cmxa) |
| 84 | OutputsCMI := $(ObjectsCMI:$(ObjDir)/%.cmi=$(OcamlDir)/%.cmi) |
| 85 | OutputsCMX := $(ObjectsCMX:$(ObjDir)/%.cmx=$(OcamlDir)/%.cmx) |
Gordon Henriksen | 516276e | 2007-12-03 21:15:53 +0000 | [diff] [blame] | 86 | OutputLibs := $(UsedLibNames:%=$(OcamlDir)/%) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 87 | |
| 88 | # Installation targets |
| 89 | DestA := $(PROJ_libocamldir)/lib$(LIBRARYNAME).a |
| 90 | DestCMA := $(PROJ_libocamldir)/$(LIBRARYNAME).cma |
| 91 | DestCMXA := $(PROJ_libocamldir)/$(LIBRARYNAME).cmxa |
Gordon Henriksen | 516276e | 2007-12-03 21:15:53 +0000 | [diff] [blame] | 92 | DestLibs := $(UsedLibNames:%=$(PROJ_libocamldir)/%) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 93 | |
| 94 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 95 | ##===- Dependencies -------------------------------------------------------===## |
| 96 | # Copy the sources into the intermediate directory because older ocamlc doesn't |
| 97 | # support -o except when linking (outputs are placed next to inputs). |
| 98 | |
| 99 | $(ObjDir)/%.mli: $(PROJ_SRC_DIR)/%.mli $(ObjDir)/.dir |
| 100 | $(Verb) $(CP) -f $< $@ |
| 101 | |
| 102 | $(ObjDir)/%.ml: $(PROJ_SRC_DIR)/%.ml $(ObjDir)/.dir |
| 103 | $(Verb) $(CP) -f $< $@ |
| 104 | |
Gordon Henriksen | ab4456f | 2007-09-23 13:37:44 +0000 | [diff] [blame] | 105 | $(ObjDir)/$(LIBRARYNAME).ocamldep: $(OcamlSources) $(OcamlHeaders) \ |
| 106 | $(OcamlDir)/.dir $(ObjDir)/.dir |
Gordon Henriksen | e6074a0 | 2008-03-04 14:52:05 +0000 | [diff] [blame] | 107 | $(Verb) $(OCAMLDEP) $(OCAMLCFLAGS) $(OcamlSources) $(OcamlHeaders) > $@ |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 108 | |
Gordon Henriksen | 46abf91 | 2007-09-26 20:56:12 +0000 | [diff] [blame] | 109 | $(ObjectsCMI): $(UsedOcamlInterfaces:%=$(OcamlDir)/%.cmi) |
| 110 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 111 | -include $(ObjDir)/$(LIBRARYNAME).ocamldep |
| 112 | |
| 113 | |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 114 | ##===- Build static library from C sources --------------------------------===## |
| 115 | |
Gordon Henriksen | f368dad | 2008-03-10 16:15:32 +0000 | [diff] [blame] | 116 | ifneq ($(ObjectsO),) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 117 | all-local:: $(LibraryA) |
| 118 | clean-local:: clean-a |
| 119 | install-local:: install-a |
| 120 | uninstall-local:: uninstall-a |
| 121 | |
| 122 | $(LibraryA): $(ObjectsO) $(OcamlDir)/.dir |
| 123 | $(Echo) "Building $(BuildMode) $(notdir $@)" |
| 124 | -$(Verb) $(RM) -f $@ |
| 125 | $(Verb) $(Archive) $@ $(ObjectsO) |
| 126 | $(Verb) $(Ranlib) $@ |
| 127 | |
| 128 | clean-a:: |
| 129 | -$(Verb) $(RM) -f $(LibraryA) |
| 130 | |
| 131 | install-a:: $(LibraryA) |
| 132 | $(Echo) "Installing $(BuildMode) $(DestA)" |
| 133 | $(Verb) $(MKDIR) $(PROJ_libocamldir) |
Nick Lewycky | a15dc03 | 2009-02-26 07:44:16 +0000 | [diff] [blame] | 134 | $(Verb) $(INSTALL) $(LibraryA) $(DestA) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 135 | $(Verb) |
| 136 | |
| 137 | uninstall-a:: |
| 138 | $(Echo) "Uninstalling $(DestA)" |
| 139 | -$(Verb) $(RM) -f $(DestA) |
Gordon Henriksen | f368dad | 2008-03-10 16:15:32 +0000 | [diff] [blame] | 140 | endif |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 141 | |
| 142 | |
Gordon Henriksen | 516276e | 2007-12-03 21:15:53 +0000 | [diff] [blame] | 143 | ##===- Deposit dependent libraries adjacent to Ocaml libs -----------------===## |
| 144 | |
| 145 | all-local:: build-deplibs |
| 146 | clean-local:: clean-deplibs |
| 147 | install-local:: install-deplibs |
| 148 | uninstall-local:: uninstall-deplibs |
| 149 | |
| 150 | build-deplibs: $(OutputLibs) |
| 151 | |
| 152 | $(OcamlDir)/%.a: $(LibDir)/%.a |
| 153 | $(Verb) ln -sf $< $@ |
| 154 | |
Gordon Henriksen | 2e855e6 | 2007-12-23 16:59:28 +0000 | [diff] [blame] | 155 | $(OcamlDir)/%.o: $(LibDir)/%.o |
| 156 | $(Verb) ln -sf $< $@ |
| 157 | |
Gordon Henriksen | 516276e | 2007-12-03 21:15:53 +0000 | [diff] [blame] | 158 | clean-deplibs: |
| 159 | $(Verb) rm -f $(OutputLibs) |
| 160 | |
| 161 | install-deplibs: |
| 162 | $(Verb) for i in $(DestLibs:$(PROJ_libocamldir)/%=%); do \ |
| 163 | ln -sf "$(PROJ_libdir)/$$i" "$(PROJ_libocamldir)/$$i"; \ |
| 164 | done |
| 165 | |
| 166 | uninstall-deplibs: |
| 167 | $(Verb) rm -f $(DestLibs) |
| 168 | |
| 169 | |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 170 | ##===- Build ocaml interfaces (.mli's -> .cmi's) --------------------------===## |
| 171 | |
| 172 | all-local:: build-cmis |
| 173 | clean-local:: clean-cmis |
| 174 | install-local:: install-cmis |
| 175 | uninstall-local:: uninstall-cmis |
| 176 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 177 | build-cmis: $(OutputsCMI) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 178 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 179 | $(OcamlDir)/%.cmi: $(ObjDir)/%.cmi $(OcamlDir)/.dir |
| 180 | $(Verb) $(CP) -f $< $@ |
| 181 | |
| 182 | $(ObjDir)/%.cmi: $(ObjDir)/%.mli $(ObjDir)/.dir |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 183 | $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" |
| 184 | $(Verb) $(Compile.CMI) $@ $< |
| 185 | |
| 186 | clean-cmis:: |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 187 | -$(Verb) $(RM) -f $(OutputsCMI) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 188 | |
| 189 | # Also install the .mli's (headers) as documentation. |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 190 | install-cmis: $(OutputsCMI) $(OcamlHeaders) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 191 | $(Verb) $(MKDIR) $(PROJ_libocamldir) |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 192 | $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 193 | $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ |
| 194 | $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ |
| 195 | done |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 196 | $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 197 | $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 198 | $(DataInstall) $(ObjDir)/$$i "$(PROJ_libocamldir)/$$i"; \ |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 199 | done |
| 200 | |
| 201 | uninstall-cmis:: |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 202 | $(Verb) for i in $(OutputsCMI:$(OcamlDir)/%=%); do \ |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 203 | $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ |
| 204 | $(RM) -f "$(PROJ_libocamldir)/$$i"; \ |
| 205 | done |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 206 | $(Verb) for i in $(OcamlHeaders:$(ObjDir)/%=%); do \ |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 207 | $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ |
| 208 | $(RM) -f "$(PROJ_libocamldir)/$$i"; \ |
| 209 | done |
| 210 | |
| 211 | |
| 212 | ##===- Build ocaml bytecode archive (.ml's -> .cmo's -> .cma) -------------===## |
| 213 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 214 | all-local:: $(OutputCMA) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 215 | clean-local:: clean-cma |
| 216 | install-local:: install-cma |
| 217 | uninstall-local:: uninstall-cma |
| 218 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 219 | $(OutputCMA): $(LibraryCMA) $(OcamlDir)/.dir |
| 220 | $(Verb) $(CP) -f $< $@ |
| 221 | |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 222 | $(LibraryCMA): $(ObjectsCMO) $(OcamlDir)/.dir |
| 223 | $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" |
| 224 | $(Verb) $(Archive.CMA) $@ $(ObjectsCMO) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 225 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 226 | $(ObjDir)/%.cmo: $(ObjDir)/%.ml |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 227 | $(Echo) "Compiling $(notdir $<) for $(BuildMode) build" |
| 228 | $(Verb) $(Compile.CMO) $@ $< |
| 229 | |
| 230 | clean-cma:: |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 231 | $(Verb) $(RM) -f $(OutputCMA) $(UsedLibNames:%=$(OcamlDir)/%) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 232 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 233 | install-cma:: $(OutputCMA) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 234 | $(Echo) "Installing $(BuildMode) $(DestCMA)" |
| 235 | $(Verb) $(MKDIR) $(PROJ_libocamldir) |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 236 | $(Verb) $(DataInstall) $(OutputCMA) "$(DestCMA)" |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 237 | |
| 238 | uninstall-cma:: |
| 239 | $(Echo) "Uninstalling $(DestCMA)" |
| 240 | -$(Verb) $(RM) -f $(DestCMA) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 241 | |
| 242 | |
| 243 | ##===- Build optimized ocaml archive (.ml's -> .cmx's -> .cmxa, .a) -------===## |
| 244 | |
| 245 | # The ocamlopt compiler is supported on a set of targets disjoint from LLVM's. |
| 246 | # If unavailable, 'configure' will not define OCAMLOPT in Makefile.config. |
| 247 | ifdef OCAMLOPT |
| 248 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 249 | all-local:: $(OutputCMXA) $(OutputsCMX) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 250 | clean-local:: clean-cmxa |
| 251 | install-local:: install-cmxa |
| 252 | uninstall-local:: uninstall-cmxa |
| 253 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 254 | $(OutputCMXA): $(LibraryCMXA) |
| 255 | $(Verb) $(CP) -f $< $@ |
| 256 | $(Verb) $(CP) -f $(<:.cmxa=.a) $(@:.cmxa=.a) |
| 257 | |
| 258 | $(OcamlDir)/%.cmx: $(ObjDir)/%.cmx |
| 259 | $(Verb) $(CP) -f $< $@ |
| 260 | |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 261 | $(LibraryCMXA): $(ObjectsCMX) |
| 262 | $(Echo) "Archiving $(notdir $@) for $(BuildMode) build" |
| 263 | $(Verb) $(Archive.CMXA) $@ $(ObjectsCMX) |
| 264 | $(Verb) $(RM) -f $(@:.cmxa=.o) |
| 265 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 266 | $(ObjDir)/%.cmx: $(ObjDir)/%.ml |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 267 | $(Echo) "Compiling optimized $(notdir $<) for $(BuildMode) build" |
| 268 | $(Verb) $(Compile.CMX) $@ $< |
| 269 | |
| 270 | clean-cmxa:: |
Gordon Henriksen | 4b169cd | 2008-03-07 18:43:51 +0000 | [diff] [blame] | 271 | $(Verb) $(RM) -f $(OutputCMXA) $(OutputCMXA:.cmxa=.a) $(OutputsCMX) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 272 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 273 | install-cmxa:: $(OutputCMXA) $(OutputsCMX) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 274 | $(Verb) $(MKDIR) $(PROJ_libocamldir) |
| 275 | $(Echo) "Installing $(BuildMode) $(DestCMXA)" |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 276 | $(Verb) $(DataInstall) $(OutputCMXA) $(DestCMXA) |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 277 | $(Echo) "Installing $(BuildMode) $(DestCMXA:.cmxa=.a)" |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 278 | $(Verb) $(DataInstall) $(OutputCMXA:.cmxa=.a) $(DestCMXA:.cmxa=.a) |
| 279 | $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \ |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 280 | $(EchoCmd) "Installing $(BuildMode) $(PROJ_libocamldir)/$$i"; \ |
| 281 | $(DataInstall) $(OcamlDir)/$$i "$(PROJ_libocamldir)/$$i"; \ |
| 282 | done |
| 283 | |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 284 | uninstall-cmxa:: |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 285 | $(Echo) "Uninstalling $(DestCMXA)" |
| 286 | $(Verb) $(RM) -f $(DestCMXA) |
| 287 | $(Echo) "Uninstalling $(DestCMXA:.cmxa=.a)" |
| 288 | $(Verb) $(RM) -f $(DestCMXA:.cmxa=.a) |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 289 | $(Verb) for i in $(OutputsCMX:$(OcamlDir)/%=%); do \ |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 290 | $(EchoCmd) "Uninstalling $(PROJ_libocamldir)/$$i"; \ |
| 291 | $(RM) -f $(PROJ_libocamldir)/$$i; \ |
| 292 | done |
| 293 | |
| 294 | endif |
| 295 | |
Gordon Henriksen | b047766 | 2008-03-10 15:49:16 +0000 | [diff] [blame] | 296 | ##===- Generate documentation ---------------------------------------------===## |
| 297 | |
| 298 | $(ObjDir)/$(LIBRARYNAME).odoc: $(ObjectsCMI) |
| 299 | $(Echo) "Documenting $(notdir $@)" |
Bob Wilson | 46c95bb | 2009-03-06 00:00:58 +0000 | [diff] [blame] | 300 | $(Verb) $(OCAMLDOC) -I $(ObjDir) -I $(OcamlDir) -dump $@ $(OcamlHeaders) |
Gordon Henriksen | b047766 | 2008-03-10 15:49:16 +0000 | [diff] [blame] | 301 | |
| 302 | ocamldoc: $(ObjDir)/$(LIBRARYNAME).odoc |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 303 | |
| 304 | ##===- Debugging gunk -----------------------------------------------------===## |
| 305 | printvars:: printcamlvars |
| 306 | |
| 307 | printcamlvars:: |
| 308 | $(Echo) "LLVM_CONFIG : " '$(LLVM_CONFIG)' |
| 309 | $(Echo) "OCAMLCFLAGS : " '$(OCAMLCFLAGS)' |
| 310 | $(Echo) "OCAMLAFLAGS : " '$(OCAMLAFLAGS)' |
| 311 | $(Echo) "OCAMLC : " '$(OCAMLC)' |
| 312 | $(Echo) "OCAMLOPT : " '$(OCAMLOPT)' |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 313 | $(Echo) "OCAMLDEP : " '$(OCAMLDEP)' |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 314 | $(Echo) "Compile.CMI : " '$(Compile.CMI)' |
| 315 | $(Echo) "Compile.CMO : " '$(Compile.CMO)' |
| 316 | $(Echo) "Archive.CMA : " '$(Archive.CMA)' |
| 317 | $(Echo) "Compile.CMX : " '$(Compile.CMX)' |
| 318 | $(Echo) "Archive.CMXA : " '$(Archive.CMXA)' |
| 319 | $(Echo) "CAML_LIBDIR : " '$(CAML_LIBDIR)' |
| 320 | $(Echo) "LibraryCMA : " '$(LibraryCMA)' |
| 321 | $(Echo) "LibraryCMXA : " '$(LibraryCMXA)' |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 322 | $(Echo) "OcamlSources1: " '$(OcamlSources1)' |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 323 | $(Echo) "OcamlSources : " '$(OcamlSources)' |
Gordon Henriksen | a8c3660 | 2007-09-20 16:47:41 +0000 | [diff] [blame] | 324 | $(Echo) "OcamlHeaders : " '$(OcamlHeaders)' |
Gordon Henriksen | 0908d49 | 2007-09-18 12:26:17 +0000 | [diff] [blame] | 325 | $(Echo) "ObjectsCMI : " '$(ObjectsCMI)' |
| 326 | $(Echo) "ObjectsCMO : " '$(ObjectsCMO)' |
| 327 | $(Echo) "ObjectsCMX : " '$(ObjectsCMX)' |
| 328 | $(Echo) "OCAML_LIBDIR : " '$(OCAML_LIBDIR)' |
| 329 | $(Echo) "DestA : " '$(DestA)' |
| 330 | $(Echo) "DestCMA : " '$(DestCMA)' |
| 331 | $(Echo) "DestCMXA : " '$(DestCMXA)' |
| 332 | $(Echo) "UsedLibs : " '$(UsedLibs)' |
| 333 | $(Echo) "UsedLibNames : " '$(UsedLibNames)' |
| 334 | |
| 335 | .PHONY: printcamlvars build-cmis \ |
| 336 | clean-a clean-cmis clean-cma clean-cmxa \ |
| 337 | install-a install-cmis install-cma install-cmxa \ |
| 338 | uninstall-a uninstall-cmis uninstall-cma uninstall-cmxa |