package / ocaml-base-compiler.4.10.0 / Makefile.best_binaries
1 #**************************************************************************
2 #* *
3 #* OCaml *
4 #* *
5 #* Gabriel Scherer, projet Parsifal, INRIA Saclay *
6 #* *
7 #* Copyright 2019 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 # This Makefile should be included.
17
18 # It expects:
19 # - Makefile.common to be included as well
20 # - a ROOTDIR variable pointing to the repository root
21 # relative to the including Makefile
22
23 # It exports definitions of BEST_OCAML{C,OPT,LEX,DEP} commands that
24 # run to either the bytecode binary built in the repository or the
25 # native binary, if available. Note that they never use the boot/
26 # versions: we assume that ocamlc, ocamlopt, etc. have been run first.
27
28 check_not_stale = \
29 $(if $(shell test $(ROOTDIR)/$1 -nt $(ROOTDIR)/$2 && echo stale), \
30 $(info Warning: we are not using the native binary $2 \
31 because it is older than the bytecode binary $1; \
32 you should silence this warning by either removing $2 \
33 or rebuilding it (or `touch`-ing it) if you want it used.), \
34 ok)
35
36 choose_best = $(strip $(if \
37 $(and $(wildcard $(ROOTDIR)/$1.opt),$(strip \
38 $(call check_not_stale,$1,$1.opt))), \
39 $(ROOTDIR)/$1.opt, \
40 $(CAMLRUN) $(ROOTDIR)/$1))
41
42 BEST_OCAMLC := $(call choose_best,ocamlc)
43 BEST_OCAMLOPT := $(call choose_best,ocamlopt)
44 BEST_OCAMLLEX := $(call choose_best,lex/ocamllex)
45
46 BEST_OCAMLDEP := $(BEST_OCAMLC) -depend
47