summaryrefslogtreecommitdiff
path: root/bindings/ocaml/backends/Makefile.common
blob: be65dd0f861cd561b99cfff2110dad83df88b557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
##===- bindings/ocaml/backends/Makefile.common -------------*- Makefile -*-===##
#
#                     The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
##===----------------------------------------------------------------------===##
#
# This is the slave makefile for backend-specific bindings. This makefile should
# be included after defining TARGET. It will then substitute @TARGET@ for
# the value of TARGET in various *.in files and build an OCaml library in
# a regular way.
#
##===----------------------------------------------------------------------===##

LEVEL := ../../..
LIBRARYNAME := llvm_$(TARGET)
UsedComponents := $(TARGET)
UsedOcamlInterfaces := llvm

include $(LEVEL)/Makefile.config

SOURCES       := $(TARGET)_ocaml.c
OcamlHeaders1 := $(PROJ_SRC_DIR)/llvm_$(TARGET).mli
OcamlSources1 := $(PROJ_SRC_DIR)/llvm_$(TARGET).ml

include ../Makefile.ocaml

$(ObjDir)/llvm_$(TARGET).ml: $(PROJ_SRC_DIR)/llvm_backend.ml.in $(ObjDir)/.dir
	$(Verb) $(SED) -e 's/@TARGET@/$(TARGET)/' $< > $@

$(ObjDir)/llvm_$(TARGET).mli: $(PROJ_SRC_DIR)/llvm_backend.mli.in $(ObjDir)/.dir
	$(Verb) $(SED) -e 's/@TARGET@/$(TARGET)/' $< > $@

$(ObjDir)/$(TARGET)_ocaml.o: $(PROJ_SRC_DIR)/backend_ocaml.c $(ObjDir)/.dir
	$(Echo) "Compiling $*.c for $(BuildMode) build" $(PIC_FLAG)
	$(Verb) $(Compile.C) -DTARGET=$(TARGET) $< -o $@


##===- OCamlFind Package --------------------------------------------------===##

all-local:: copy-meta
install-local:: install-meta
uninstall-local:: uninstall-meta

DestMETA := $(PROJ_libocamldir)/META.llvm_$(TARGET)

# Easy way of generating META in the objdir
copy-meta: $(OcamlDir)/META.llvm_$(TARGET)

$(OcamlDir)/META.llvm_$(TARGET): META.llvm_backend.in
	$(Verb) $(SED) -e 's/@TARGET@/$(TARGET)/' \
								 -e 's/@PACKAGE_VERSION@/$(LLVMVersion)/' $< > $@

install-meta:: $(OcamlDir)/META.llvm_$(TARGET)
	$(Echo) "Install $(BuildMode) $(DestMETA)"
	$(Verb) $(MKDIR) $(PROJ_libocamldir)
	$(Verb) $(DataInstall) $< "$(DestMETA)"

uninstall-meta::
	$(Echo) "Uninstalling $(DestMETA)"
	-$(Verb) $(RM) -f "$(DestMETA)"

.PHONY: copy-meta install-meta uninstall-meta