forked from ocaml-multicore/ocaml-multicore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.otherlibs.common
146 lines (121 loc) · 4.2 KB
/
Makefile.otherlibs.common
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#**************************************************************************
#* *
#* OCaml *
#* *
#* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
#* *
#* Copyright 1999 Institut National de Recherche en Informatique et *
#* en Automatique. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
# Common Makefile for otherlibs
ROOTDIR=../..
include $(ROOTDIR)/Makefile.common
include $(ROOTDIR)/Makefile.best_binaries
CAMLC := $(BEST_OCAMLC) -nostdlib -I $(ROOTDIR)/stdlib
CAMLOPT := $(BEST_OCAMLOPT) -nostdlib -I $(ROOTDIR)/stdlib
ifneq "$(CCOMPTYPE)" "msvc"
OC_CFLAGS += -g
endif
OC_CFLAGS += $(SHAREDLIB_CFLAGS) $(EXTRACFLAGS)
OC_CPPFLAGS += -I$(ROOTDIR)/runtime $(EXTRACPPFLAGS)
# Compilation options
COMPFLAGS=-absname -w +a-4-9-41-42-44-45-48 -warn-error +A -bin-annot -g \
-safe-string -strict-sequence -strict-formats $(EXTRACAMLFLAGS)
ifeq "$(FLAMBDA)" "true"
OPTCOMPFLAGS += -O3
endif
MKLIB=$(OCAMLRUN) $(ROOTDIR)/tools/ocamlmklib
# Variables that must be defined by individual libraries:
# LIBNAME
# CAMLOBJS
# Variables that can be defined by individual libraries,
# but have sensible default values:
COBJS ?=
EXTRACFLAGS ?=
EXTRACPPFLAGS ?=
EXTRACAMLFLAGS ?=
LINKOPTS ?=
LDOPTS ?=
HEADERS ?=
CMIFILES ?= $(CAMLOBJS:.cmo=.cmi)
CAMLOBJS_NAT ?= $(CAMLOBJS:.cmo=.cmx)
CLIBNAME ?= $(LIBNAME)
ifeq "$(COBJS)" ""
STUBSLIB=
else
STUBSLIB=lib$(CLIBNAME).$(A)
endif
.PHONY: all allopt opt.opt # allopt and opt.opt are synonyms
all: $(STUBSLIB) $(LIBNAME).cma $(CMIFILES)
allopt: $(STUBSLIB) $(LIBNAME).cmxa $(LIBNAME).$(CMXS) $(CMIFILES)
opt.opt: allopt
$(LIBNAME).cma: $(CAMLOBJS)
ifeq "$(COBJS)" ""
$(CAMLC) -o $@ -a -linkall $(CAMLOBJS) $(LINKOPTS)
else
$(MKLIB) -o $(LIBNAME) -oc $(CLIBNAME) -ocamlc '$(CAMLC)' -linkall \
$(CAMLOBJS) $(LINKOPTS)
endif
$(LIBNAME).cmxa: $(CAMLOBJS_NAT)
ifeq "$(COBJS)" ""
$(CAMLOPT) -o $@ -a -linkall $(CAMLOBJS_NAT) $(LINKOPTS)
else
$(MKLIB) -o $(LIBNAME) -oc $(CLIBNAME) -ocamlopt '$(CAMLOPT)' -linkall \
$(CAMLOBJS_NAT) $(LINKOPTS)
endif
$(LIBNAME).cmxs: $(LIBNAME).cmxa $(STUBSLIB)
$(CAMLOPT_CMD) -shared -o $(LIBNAME).cmxs -I . $(LIBNAME).cmxa
lib$(CLIBNAME).$(A): $(COBJS)
$(MKLIB_CMD) -oc $(CLIBNAME) $(COBJS) $(LDOPTS)
install::
if test -f dll$(CLIBNAME)$(EXT_DLL); then \
$(INSTALL_PROG) \
dll$(CLIBNAME)$(EXT_DLL) "$(INSTALL_STUBLIBDIR)"; \
fi
ifneq "$(STUBSLIB)" ""
$(INSTALL_DATA) $(STUBSLIB) "$(INSTALL_LIBDIR)/"
cd "$(INSTALL_LIBDIR)"; $(RANLIB) lib$(CLIBNAME).$(A)
endif
$(INSTALL_DATA) \
$(LIBNAME).cma $(CMIFILES) \
"$(INSTALL_LIBDIR)/"
ifeq "$(INSTALL_SOURCE_ARTIFACTS)" "true"
$(INSTALL_DATA) \
$(CMIFILES:.cmi=.mli) \
$(CMIFILES:.cmi=.cmti) \
"$(INSTALL_LIBDIR)/"
endif
if test -n "$(HEADERS)"; then \
$(INSTALL_DATA) $(HEADERS) "$(INSTALL_LIBDIR)/caml/"; \
fi
installopt:
$(INSTALL_DATA) \
$(CAMLOBJS_NAT) $(LIBNAME).cmxa $(LIBNAME).$(A) \
"$(INSTALL_LIBDIR)/"
cd "$(INSTALL_LIBDIR)"; $(RANLIB) $(LIBNAME).a
if test -f $(LIBNAME).cmxs; then \
$(INSTALL_PROG) $(LIBNAME).cmxs "$(INSTALL_LIBDIR)"; \
fi
partialclean:
rm -f *.cm*
clean:: partialclean
rm -f *.dll *.so *.a *.lib *.o *.obj
rm -rf $(DEPDIR)
%.cmi: %.mli
$(CAMLC) -c $(COMPFLAGS) $<
%.cmo: %.ml
$(CAMLC) -c $(COMPFLAGS) $<
%.cmx: %.ml
$(CAMLOPT) -c $(COMPFLAGS) $(OPTCOMPFLAGS) $<
ifeq "$(COMPUTE_DEPS)" "true"
ifneq "$(COBJS)" ""
include $(addprefix $(DEPDIR)/, $(COBJS:.$(O)=.$(D)))
endif
endif
$(DEPDIR)/%.$(D): %.c | $(DEPDIR)
$(DEP_CC) $(OC_CPPFLAGS) $(CPPFLAGS) $< -MT '$*.$(O)' -MF $@