2016-02-18 07:11:59 -08:00
|
|
|
#**************************************************************************
|
|
|
|
#* *
|
|
|
|
#* 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. *
|
|
|
|
#* *
|
|
|
|
#**************************************************************************
|
1999-11-17 10:59:06 -08:00
|
|
|
|
1997-05-14 02:43:45 -07:00
|
|
|
include ../../config/Makefile
|
2015-07-17 07:31:05 -07:00
|
|
|
CAMLRUN ?= ../../boot/ocamlrun
|
|
|
|
CAMLYACC ?= ../../boot/ocamlyacc
|
1997-05-14 02:43:45 -07:00
|
|
|
|
2014-04-02 09:20:38 -07:00
|
|
|
ROOTDIR=../..
|
2015-07-17 07:31:05 -07:00
|
|
|
CAMLC=$(CAMLRUN) $(ROOTDIR)/ocamlc -nostdlib \
|
2014-04-12 03:17:02 -07:00
|
|
|
-I $(ROOTDIR)/stdlib -I $(ROOTDIR)/otherlibs/unix
|
2015-07-17 07:31:05 -07:00
|
|
|
CAMLOPT=$(CAMLRUN) $(ROOTDIR)/ocamlopt -nostdlib \
|
2014-04-12 03:17:02 -07:00
|
|
|
-I $(ROOTDIR)/stdlib -I $(ROOTDIR)/otherlibs/unix
|
2015-07-17 07:31:05 -07:00
|
|
|
MKLIB=$(CAMLRUN) ../../tools/ocamlmklib
|
2014-04-29 04:56:17 -07:00
|
|
|
COMPFLAGS=-w +33..39 -warn-error A -g -bin-annot -safe-string
|
2016-02-11 03:16:10 -08:00
|
|
|
ifeq "$(FLAMBDA)" "true"
|
|
|
|
OPTCOMPFLAGS=-O3
|
|
|
|
else
|
|
|
|
OPTCOMPFLAGS=
|
|
|
|
endif
|
1997-05-14 02:43:45 -07:00
|
|
|
|
2010-04-27 00:55:08 -07:00
|
|
|
BYTECODE_C_OBJS=st_stubs_b.o
|
|
|
|
NATIVECODE_C_OBJS=st_stubs_n.o
|
1997-05-14 02:43:45 -07:00
|
|
|
|
1998-08-08 11:42:22 -07:00
|
|
|
THREAD_OBJS= thread.cmo mutex.cmo condition.cmo event.cmo threadUnix.cmo
|
1997-05-14 02:43:45 -07:00
|
|
|
|
1997-08-29 08:37:22 -07:00
|
|
|
all: libthreads.a threads.cma
|
1997-05-14 02:43:45 -07:00
|
|
|
|
2007-11-12 09:19:48 -08:00
|
|
|
allopt: libthreadsnat.a threads.cmxa
|
1997-05-14 02:43:45 -07:00
|
|
|
|
1997-08-29 08:37:22 -07:00
|
|
|
libthreads.a: $(BYTECODE_C_OBJS)
|
2014-10-15 06:34:58 -07:00
|
|
|
$(MKLIB) -o threads $(BYTECODE_C_OBJS) $(PTHREAD_LINK)
|
1997-05-14 02:43:45 -07:00
|
|
|
|
2010-04-27 00:55:08 -07:00
|
|
|
st_stubs_b.o: st_stubs.c st_posix.h
|
2015-07-17 07:31:05 -07:00
|
|
|
$(BYTECC) -I../../byterun $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS) \
|
2010-04-27 00:55:08 -07:00
|
|
|
-c st_stubs.c
|
|
|
|
mv st_stubs.o st_stubs_b.o
|
1997-05-14 02:43:45 -07:00
|
|
|
|
2001-10-24 06:08:53 -07:00
|
|
|
# Dynamic linking with -lpthread is risky on many platforms, so
|
|
|
|
# do not create a shared object for libthreadsnat.
|
1997-08-29 08:37:22 -07:00
|
|
|
libthreadsnat.a: $(NATIVECODE_C_OBJS)
|
2001-10-24 06:08:53 -07:00
|
|
|
$(AR) rc libthreadsnat.a $(NATIVECODE_C_OBJS)
|
1997-05-14 02:43:45 -07:00
|
|
|
|
2010-04-27 00:55:08 -07:00
|
|
|
st_stubs_n.o: st_stubs.c st_posix.h
|
2015-07-17 07:31:05 -07:00
|
|
|
$(NATIVECC) -I../../asmrun -I../../byterun $(NATIVECCCOMPOPTS) \
|
2013-09-04 08:12:37 -07:00
|
|
|
$(SHAREDCCCOMPOPTS) -DNATIVE_CODE -DTARGET_$(ARCH) \
|
2015-07-20 08:41:44 -07:00
|
|
|
-DMODEL_$(MODEL) -DSYS_$(SYSTEM) -c st_stubs.c
|
2010-04-27 00:55:08 -07:00
|
|
|
mv st_stubs.o st_stubs_n.o
|
1997-05-14 02:43:45 -07:00
|
|
|
|
1997-08-29 08:37:22 -07:00
|
|
|
threads.cma: $(THREAD_OBJS)
|
2013-11-29 05:04:38 -08:00
|
|
|
$(MKLIB) -ocamlc '$(CAMLC)' -o threads $(THREAD_OBJS) \
|
2014-10-15 06:34:58 -07:00
|
|
|
-cclib -lunix $(PTHREAD_CAML_LINK)
|
1997-05-14 02:43:45 -07:00
|
|
|
|
2001-10-24 06:08:53 -07:00
|
|
|
# See remark above: force static linking of libthreadsnat.a
|
1997-08-29 08:37:22 -07:00
|
|
|
threads.cmxa: $(THREAD_OBJS:.cmo=.cmx)
|
2001-10-24 06:08:53 -07:00
|
|
|
$(CAMLOPT) -a -o threads.cmxa $(THREAD_OBJS:.cmo=.cmx) \
|
2014-10-15 06:34:58 -07:00
|
|
|
-cclib -lthreadsnat $(PTHREAD_CAML_LINK)
|
2007-11-06 07:16:56 -08:00
|
|
|
|
2010-01-22 04:48:24 -08:00
|
|
|
# Note: I removed "-cclib -lunix" from the line above.
|
|
|
|
# Indeed, if we link threads.cmxa, then we must also link unix.cmxa,
|
2007-11-06 07:16:56 -08:00
|
|
|
# which itself will pass -lunix to the C linker. It seems more
|
|
|
|
# modular to me this way. -- Alain
|
|
|
|
|
|
|
|
|
1997-12-19 08:04:40 -08:00
|
|
|
$(THREAD_OBJS:.cmo=.cmx): ../../ocamlopt
|
|
|
|
|
1997-05-14 02:43:45 -07:00
|
|
|
partialclean:
|
|
|
|
rm -f *.cm*
|
|
|
|
|
|
|
|
clean: partialclean
|
2003-08-21 06:52:07 -07:00
|
|
|
rm -f *.o *.a *.so
|
1997-05-14 02:43:45 -07:00
|
|
|
|
2014-04-07 00:06:17 -07:00
|
|
|
INSTALL_LIBDIR=$(DESTDIR)$(LIBDIR)
|
|
|
|
INSTALL_STUBLIBDIR=$(DESTDIR)$(STUBLIBDIR)
|
|
|
|
|
1997-05-14 02:43:45 -07:00
|
|
|
install:
|
2014-04-12 03:17:02 -07:00
|
|
|
if test -f dllthreads.so; then \
|
|
|
|
cp dllthreads.so $(INSTALL_STUBLIBDIR)/dllthreads.so; fi
|
2014-04-07 00:06:17 -07:00
|
|
|
cp libthreads.a $(INSTALL_LIBDIR)/libthreads.a
|
|
|
|
cd $(INSTALL_LIBDIR); $(RANLIB) libthreads.a
|
2014-04-12 03:17:02 -07:00
|
|
|
if test -d $(INSTALL_LIBDIR)/threads; then :; \
|
|
|
|
else mkdir $(INSTALL_LIBDIR)/threads; fi
|
2014-04-07 00:06:17 -07:00
|
|
|
cp $(THREAD_OBJS:.cmo=.cmi) threads.cma $(INSTALL_LIBDIR)/threads
|
|
|
|
rm -f $(INSTALL_LIBDIR)/threads/stdlib.cma
|
2014-04-12 03:17:02 -07:00
|
|
|
cp thread.mli mutex.mli condition.mli event.mli threadUnix.mli \
|
|
|
|
$(INSTALL_LIBDIR)
|
2014-04-07 00:06:17 -07:00
|
|
|
cp threads.h $(INSTALL_LIBDIR)/caml/threads.h
|
1997-05-14 02:43:45 -07:00
|
|
|
|
|
|
|
installopt:
|
2014-04-07 00:06:17 -07:00
|
|
|
cp libthreadsnat.a $(INSTALL_LIBDIR)/libthreadsnat.a
|
|
|
|
cd $(INSTALL_LIBDIR); $(RANLIB) libthreadsnat.a
|
2016-02-19 03:16:21 -08:00
|
|
|
cp $(THREAD_OBJS:.cmo=.cmx) threads.cmxa threads.a \
|
|
|
|
$(INSTALL_LIBDIR)/threads
|
|
|
|
cd $(INSTALL_LIBDIR)/threads && $(RANLIB) threads.a
|
1997-05-14 02:43:45 -07:00
|
|
|
|
1997-11-17 05:04:18 -08:00
|
|
|
.SUFFIXES: .ml .mli .cmo .cmi .cmx
|
1997-05-14 02:43:45 -07:00
|
|
|
|
|
|
|
.mli.cmi:
|
|
|
|
$(CAMLC) -c $(COMPFLAGS) $<
|
|
|
|
|
|
|
|
.ml.cmo:
|
2007-01-29 04:11:18 -08:00
|
|
|
$(CAMLC) -c $(COMPFLAGS) $<
|
1997-05-14 02:43:45 -07:00
|
|
|
|
|
|
|
.ml.cmx:
|
2016-02-11 03:16:10 -08:00
|
|
|
$(CAMLOPT) -c $(COMPFLAGS) $(OPTCOMPFLAGS) $<
|
1997-05-14 02:43:45 -07:00
|
|
|
|
1997-11-17 05:04:18 -08:00
|
|
|
depend: $(GENFILES)
|
2015-01-20 09:02:26 -08:00
|
|
|
-$(CC) -MM -I../../byterun *.c > .depend
|
2016-04-13 08:04:15 -07:00
|
|
|
$(CAMLRUN) ../../tools/ocamldep -slash *.mli *.ml >> .depend
|
1997-05-14 02:43:45 -07:00
|
|
|
|
|
|
|
include .depend
|