summaryrefslogtreecommitdiff
path: root/otherlibs/systhreads/Makefile
blob: 0f544ab008f19ada3fc097f4bfa7ef13a6114774 (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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#########################################################################
#                                                                       #
#                            Objective Caml                             #
#                                                                       #
#            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 Library General Public License, with     #
#   the special exception on linking described in file ../../LICENSE.   #
#                                                                       #
#########################################################################

# $Id$

include ../../config/Makefile
NOJOIN=-nojoin
CAMLC=../../ocamlcomp.sh $(NOJOIN) -I ../unix
CAMLOPT=../../ocamlcompopt.sh $(NOJOIN) -I ../unix
JCC=../../ocamlcomp.sh -I ../unix
JCOPT=../../ocamlcompopt.sh -I ../unix
MKLIB=../../boot/ocamlrun ../../tools/ocamlmklib
COMPFLAGS=-warn-error A -g
OCAMLPP=-pp '../../tools/remove_DEBUG'


BYTECODE_JOIN_C_OBJS=join_b.o
NATIVECODE_JOIN_C_OBJS=join_n.o

JOIN_OBJS=join_debug.cmo join_misc.cmo join_link.cmo join_hash.cmo\
 join_set.cmo join_queue.cmo join_extern.cmo join_scheduler.cmo join_port.cmo\
 join_message.cmo join_space.cmo join_prim.cmo join_test.cmo

BYTECODE_C_OBJS=st_stubs_b.o $(BYTECODE_JOIN_C_OBJS)
NATIVECODE_C_OBJS=st_stubs_n.o $(NATIVECODE_JOIN_C_OBJS)
CAML_THREAD_OBJS=thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo 
THREAD_OBJS= $(CAML_THREAD_OBJS) $(JOIN_OBJS)

GENFILES=join.c join_types.mli\
 join_debug.mli join_debug.ml\
 join_misc.mli join_misc.ml\
 join_link.mli join_link.ml\
 join_port.mli join_port.ml\
 join_hash.mli join_hash.ml\
 join_set.mli join_set.ml\
 join_queue.mli join_queue.ml\
 join_scheduler.mli join_scheduler.ml\
 join_message.mli join_message.ml\
 join_space.mli join_space.ml\
 join_prim.ml join_prim.mli\
 join_test.mli join_test.ml

all: libthreads.a threads.cma 


allopt: libthreadsnat.a threads.cmxa 

libthreads.a: $(BYTECODE_C_OBJS)
	$(MKLIB) -o threads $(BYTECODE_C_OBJS)

st_stubs_b.o: st_stubs.c st_posix.h
	$(BYTECC) -O -I../../byterun $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS) \
	   -c st_stubs.c
	mv st_stubs.o st_stubs_b.o

join_b.o: join.c
	$(BYTECC) -DCAML_NAME_SPACE -O -I../../byterun $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS) \
	   -c join.c
	mv join.o join_b.o

# Dynamic linking with -lpthread is risky on many platforms, so
# do not create a shared object for libthreadsnat.
libthreadsnat.a: $(NATIVECODE_C_OBJS)
	$(AR) rc libthreadsnat.a $(NATIVECODE_C_OBJS)

libjoinnat.a: $(NATIVECODE_JOIN_C_OBJS)
	$(AR) rc libjoinnat.a $(NATIVECODE_JOIN_C_OBJS)

st_stubs_n.o: st_stubs.c st_posix.h
	$(NATIVECC) -O -I../../asmrun -I../../byterun $(NATIVECCCOMPOPTS) $(SHAREDCCCOMPOPTS) -DNATIVE_CODE -DTARGET_$(ARCH) -DSYS_$(SYSTEM) -c st_stubs.c
	mv st_stubs.o st_stubs_n.o

join_n.o: join.c
	$(NATIVECC) -DCAML_NAME_SPACE -O -I../../asmrun -I../../byterun $(NATIVECCCOMPOPTS) $(SHAREDCCCOMPOPTS) -DNATIVE_CODE -DTARGET_$(ARCH) -DSYS_$(SYSTEM) -c join.c
	mv join.o join_n.o

threads.cma: $(THREAD_OBJS)
	$(MKLIB) -ocamlc '$(CAMLC)' -o threads $(THREAD_OBJS) \
	  -cclib -lunix $(PTHREAD_LINK)

# See remark above: force static linking of libthreadsnat.a
threads.cmxa: $(THREAD_OBJS:.cmo=.cmx)
	$(CAMLOPT) -a -o threads.cmxa $(THREAD_OBJS:.cmo=.cmx) \
	  -cclib -lthreadsnat $(PTHREAD_LINK)

# Note: I removed "-cclib -lunix" from the line above.
# Indeed, if we link threads.cmxa, then we must also link unix.cmxa,
# which itself will pass -lunix to the C linker.  It seems more
# modular to me this way. -- Alain


$(THREAD_OBJS:.cmo=.cmx) $(JOIN_OBJS:.cmo=.cmx): ../../ocamlopt

join_debug.ml: ../threads/join_debug.ml
	ln -s ../threads/join_debug.ml .

join_debug.mli: ../threads/join_debug.mli
	ln -s ../threads/join_debug.mli .

join_misc.ml: ../threads/join_misc.ml
	ln -s ../threads/join_misc.ml .

join_misc.mli: ../threads/join_misc.mli
	ln -s ../threads/join_misc.mli .

join_link.ml: ../threads/join_link.ml
	ln -s ../threads/join_link.ml .

join_link.mli: ../threads/join_link.mli
	ln -s ../threads/join_link.mli .

join_port.ml: ../threads/join_port.ml
	ln -s ../threads/join_port.ml .

join_port.mli: ../threads/join_port.mli
	ln -s ../threads/join_port.mli .

join_hash.ml: ../threads/join_hash.ml
	ln -s ../threads/join_hash.ml .

join_hash.mli: ../threads/join_hash.mli
	ln -s ../threads/join_hash.mli .

join_set.ml: ../threads/join_set.ml
	ln -s ../threads/join_set.ml .

join_set.mli: ../threads/join_set.mli
	ln -s ../threads/join_set.mli .

join_queue.ml: ../threads/join_queue.ml
	ln -s ../threads/join_queue.ml .

join_queue.mli: ../threads/join_queue.mli
	ln -s ../threads/join_queue.mli .

join_scheduler.ml: ../threads/join_scheduler.ml
	ln -s ../threads/join_scheduler.ml .

join_scheduler.mli: ../threads/join_scheduler.mli
	ln -s ../threads/join_scheduler.mli .

join_types.mli: ../threads/join_types.mli
	ln -s ../threads/join_types.mli .

join_prim.ml: ../threads/join_prim.ml
	ln -s ../threads/join_prim.ml .

join_prim.mli: ../threads/join_prim.mli
	ln -s ../threads/join_prim.mli .

join_test.ml: ../threads/join_test.ml
	ln -s ../threads/join_test.ml .

join_test.mli: ../threads/join_test.mli
	ln -s ../threads/join_test.mli .

join_message.ml: ../threads/join_message.ml
	ln -s ../threads/join_message.ml .

join_message.mli: ../threads/join_message.mli
	ln -s ../threads/join_message.mli .

join_space.ml: ../threads/join_space.ml
	ln -s ../threads/join_space.ml .

join_space.mli: ../threads/join_space.mli
	ln -s ../threads/join_space.mli .

join.c: ../threads/join.c
	ln -s ../threads/join.c .

partialclean:
	rm -f *.cm*

clean: partialclean
	rm -f *.o *.a *.so

install:
	if test -f dllthreads.so; then cp dllthreads.so $(STUBLIBDIR)/dllthreads.so; fi
	cp libthreads.a $(LIBDIR)/libthreads.a
	cd $(LIBDIR); $(RANLIB) libthreads.a
	if test -d $(LIBDIR)/threads; then :; else mkdir $(LIBDIR)/threads; fi
	cp thread.mli mutex.mli condition.mli\
  event.mli threadUnix.mli $(LIBDIR)/threads
	cp join_prim.cmi join_test.cmi $(LIBDIR)/threads
	cp $(CAML_THREAD_OBJS:.cmo=.cmi) threads.cma $(LIBDIR)/threads
	cp threads.h $(LIBDIR)/caml/threads.h

installopt:
	cp libthreadsnat.a $(LIBDIR)/libthreadsnat.a
	cd $(LIBDIR); $(RANLIB) libthreadsnat.a
	cp $(THREAD_OBJS:.cmo=.cmx) threads.cmxa threads.a $(LIBDIR)/threads
	cd $(LIBDIR)/threads; $(RANLIB) threads.a


.SUFFIXES: .jml .ml .mli .cmo .cmi .cmx

.mli.cmi:
	$(CAMLC) -c $(COMPFLAGS) $<

.ml.cmo:
	$(CAMLC) -g -c $(COMPFLAGS) $(OCAMLPP) $<

.jml.cmo:
	$(JCC) -c $(COMPFLAGS) $(OCAMLPP) -impl $<

.ml.cmx:
	$(CAMLOPT) -c $(COMPFLAGS) $(OCAMLPP) $<

.jml.cmx:
	$(JCOPT) -c $(COMPFLAGS) $(OCAMLPP) -impl $<

depend: $(GENFILES)
	-gcc -MM -I../../byterun *.c > .depend
	../../boot/ocamlrun ../../tools/ocamldep -nojoin *.mli *.ml >> .depend

include .depend