Fix parallel 'make check-ocaml-examples'

Some versions of ocamlc create a file of the same name in the tmp directory when invoking
using ocalmc on swigp4.ml. The name is the same even from different example directories.
TMPDIR is a workaround to make ocamlc use a different directory for this temp file.
Parallel make (-j) broke because different instances of ocamlc tried to
create the same temp file.
Issue #1503
This commit is contained in:
William S Fulton 2019-03-26 07:48:33 +00:00
commit b092055ca8

View file

@ -865,12 +865,15 @@ NOLINK ?= false
OCAMLPP= -pp "camlp4o ./swigp4.cmo"
OCAMLP4WHERE=`$(COMPILETOOL) @CAMLP4@ -where`
OCAMLCORE=\
(test -f swig.mli || $(SWIG) -ocaml -co swig.mli 2>/dev/null) && \
(test -f swig.ml || $(SWIG) -ocaml -co swig.ml 2>/dev/null) && \
(test -f swigp4.ml || $(SWIG) -ocaml -co swigp4.ml 2>/dev/null) && \
(test -f swig.cmi || $(OCC) -c swig.mli) && \
(test -f swig.cmo || $(OCC) -c swig.ml) && \
(test -f swigp4.cmi || $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml)
$(SWIG) -ocaml -co swig.mli 2>/dev/null && \
$(SWIG) -ocaml -co swig.ml 2>/dev/null && \
$(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \
$(OCC) -c swig.mli && \
$(OCC) -c swig.ml && \
mkdir -p ./localtmp && \
env TMPDIR=./localtmp $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml && \
rm -rf ./localtmp
# TMPDIR above is a workaround for some ocamlc versions, such as 4.05.0, which always create a temp file of the same name breaking parallel make
ocaml_static: $(SRCDIR_SRCS)
$(OCAMLCORE)
@ -957,6 +960,7 @@ ocaml_clean:
rm -f *_wrap* *~ .~* *.cmo *.cmi *.mli $(TARGET).ml $(RUNME) $(RUNME)_top swig.ml swigp4.ml
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
rm -rf ./localtmp
##################################################################
##### RUBY ######