Debian Codegraph @

otherlibs/systhreads/Makefile

raw
1 #**************************************************************************
2 #* *
3 #* OCaml *
4 #* *
5 #* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
6 #* *
7 #* Copyright 1999 Institut National de Recherche en Informatique et *
8 #* en Automatique. *
9 #* *
10 #* All rights reserved. This file is distributed under the terms of *
11 #* the GNU Lesser General Public License version 2.1, with the *
12 #* special exception on linking described in the file LICENSE. *
13 #* *
14 #**************************************************************************
15
16 ROOTDIR=../..
17
18 include $(ROOTDIR)/Makefile.common
19 include $(ROOTDIR)/Makefile.best_binaries
20
21 OC_BYTECODE_CFLAGS += $(SHAREDLIB_CFLAGS)
22 OC_NATIVE_CFLAGS += $(SHAREDLIB_CFLAGS)
23
24 LIBS = $(STDLIBFLAGS) -I $(ROOTDIR)/otherlibs/unix
25
26 CAMLC=$(BEST_OCAMLC) $(LIBS)
27 CAMLOPT=$(BEST_OCAMLOPT) $(LIBS)
28
29 MKLIB=$(OCAMLRUN) $(ROOTDIR)/tools/ocamlmklib$(EXE)
30 COMPFLAGS=-w +33..39 -warn-error +A -g -bin-annot
31 ifeq "$(FLAMBDA)" "true"
32 OPTCOMPFLAGS += -O3
33 endif
34
35 LIBNAME=threads
36
37 # Note: the header on which object files produced from st_stubs.c
38 # should actually depend is known for sure only at compile-time.
39 # That's why this dependency is handled in the Makefile directly
40 # and removed from the output of the C compiler during make depend
41
42 BYTECODE_C_OBJS=st_stubs.b.$(O)
43 NATIVECODE_C_OBJS=st_stubs.n.$(O)
44
45 THREADS_SOURCES = thread.ml event.ml
46
47 THREADS_BCOBJS = $(THREADS_SOURCES:.ml=.cmo)
48 THREADS_NCOBJS = $(THREADS_SOURCES:.ml=.cmx)
49
50 MLIFILES=thread.mli event.mli
51
52 CMIFILES=$(MLIFILES:.mli=.cmi)
53
54 all: lib$(LIBNAME).$(A) $(LIBNAME).cma $(CMIFILES)
55
56 allopt: lib$(LIBNAME)nat.$(A) $(LIBNAME).cmxa $(CMIFILES)
57
58 lib$(LIBNAME).$(A): OC_CFLAGS = $(OC_BYTECODE_CFLAGS)
59
60 lib$(LIBNAME).$(A): $(BYTECODE_C_OBJS)
61 $(V_OCAMLMKLIB)$(MKLIB) -o $(LIBNAME) $(BYTECODE_C_OBJS)
62
63 lib$(LIBNAME)nat.$(A): OC_CFLAGS = $(OC_NATIVE_CFLAGS)
64
65 lib$(LIBNAME)nat.$(A): $(NATIVECODE_C_OBJS)
66 $(V_OCAMLMKLIB)$(MKLIB) -o $(LIBNAME)nat $^
67
68 $(LIBNAME).cma: $(THREADS_BCOBJS)
69 $(V_OCAMLMKLIB)$(MKLIB) -o $(LIBNAME) -ocamlc '$(CAMLC)' -linkall $^
70
71 # See remark above: force static linking of libthreadsnat.a
72 $(LIBNAME).cmxa: $(THREADS_NCOBJS)
73 $(V_LINKOPT)$(CAMLOPT) -linkall -a -cclib -lthreadsnat -o $@ $^
74
75 # The following lines produce two object files st_stubs.b.$(O) and
76 # st_stubs.n.$(O) from the same source file st_stubs.c (it is compiled
77 # twice, each time with different options).
78
79 ifeq "$(COMPUTE_DEPS)" "true"
80 st_stubs.%.$(O): st_stubs.c
81 else
82 st_stubs.%.$(O): st_stubs.c $(RUNTIME_HEADERS) $(wildcard *.h)
83 endif
84 $(V_CC)$(CC) $(OC_CFLAGS) $(CFLAGS) $(OC_CPPFLAGS) $(CPPFLAGS) \
85 $(OUTPUTOBJ)$@ -c $<
86
87 .PHONY: partialclean
88 partialclean:
89 rm -f *.cm*
90
91 .PHONY: clean
92 clean: partialclean
93 rm -f dllthreads*.so dllthreads*.dll *.a *.lib *.o *.obj
94 rm -rf $(DEPDIR)
95
96 .PHONY: distclean
97 distclean: clean
98 rm -f META
99
100 INSTALL_THREADSLIBDIR=$(INSTALL_LIBDIR)/$(LIBNAME)
101
102 install:
103 if test -f dllthreads$(EXT_DLL); then \
104 $(INSTALL_PROG) dllthreads$(EXT_DLL) "$(INSTALL_STUBLIBDIR)"; \
105 fi
106 $(INSTALL_DATA) libthreads.$(A) "$(INSTALL_LIBDIR)"
107 $(MKDIR) "$(INSTALL_THREADSLIBDIR)"
108 $(INSTALL_DATA) \
109 $(CMIFILES) threads.cma META \
110 "$(INSTALL_THREADSLIBDIR)"
111 ifeq "$(INSTALL_SOURCE_ARTIFACTS)" "true"
112 $(INSTALL_DATA) \
113 $(CMIFILES:.cmi=.cmti) \
114 "$(INSTALL_THREADSLIBDIR)"
115 $(INSTALL_DATA) $(MLIFILES) "$(INSTALL_THREADSLIBDIR)"
116 endif
117 $(INSTALL_DATA) caml/threads.h "$(INSTALL_INCDIR)"
118
119 installopt:
120 $(INSTALL_DATA) libthreadsnat.$(A) "$(INSTALL_LIBDIR)"
121 $(INSTALL_DATA) \
122 $(THREADS_NCOBJS) threads.cmxa threads.$(A) \
123 "$(INSTALL_THREADSLIBDIR)"
124
125 %.cmi: %.mli
126 $(V_OCAMLC)$(CAMLC) -c $(COMPFLAGS) $<
127
128 %.cmo: %.ml
129 $(V_OCAMLC)$(CAMLC) -c $(COMPFLAGS) $<
130
131 %.cmx: %.ml
132 $(V_OCAMLOPT)$(CAMLOPT) -c $(COMPFLAGS) $(OPTCOMPFLAGS) $<
133
134 DEP_FILES := st_stubs.b.$(D)
135 ifeq "$(NATIVE_COMPILER)" "true"
136 DEP_FILES += st_stubs.n.$(D)
137 endif
138
139 ifeq "$(COMPUTE_DEPS)" "true"
140 include $(addprefix $(DEPDIR)/, $(DEP_FILES))
141 endif
142
143 %.b.$(D): OC_CPPFLAGS = $(OC_BYTECODE_CPPFLAGS)
144 %.n.$(O): OC_CPPFLAGS = $(OC_NATIVE_CPPFLAGS)
145 %.n.$(D): OC_CPPFLAGS = $(OC_NATIVE_CPPFLAGS)
146
147 define GEN_RULE
148 $(DEPDIR)/%.$(1).$(D): %.c | $(DEPDIR)
149 $$(V_CCDEPS)$$(DEP_CC) $$(OC_CPPFLAGS) $$(CPPFLAGS) $$< -MT '$$*.$(1).$(O)' -MF $$@
150 endef
151
152 $(foreach object_type, b n, $(eval $(call GEN_RULE,$(object_type))))
153
154 .PHONY: depend
155 depend:
156 $(V_GEN)$(OCAMLRUN) $(ROOTDIR)/boot/ocamlc -depend -slash *.mli *.ml > .depend
157
158 include .depend