1 #**************************************************************************
2 #* *
3 #* OCaml *
4 #* *
5 #* Xavier Clerc, SED, INRIA Rocquencourt *
6 #* *
7 #* Copyright 2010 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 provides variables for using the in-tree compiler,
17 # interpreter, lexer and other associated tools. It is intended to be
18 # included within other makefiles.
19 # See manual/tools/Makefile and manual/manual/tutorials/Makefile as examples.
20 # Note that these makefile should define the $(TOPDIR) variable on their
21 # own.
22
23 WINTOPDIR=`cygpath -m "$(TOPDIR)"`
24
25 # TOPDIR is the root directory of the OCaml sources, in Unix syntax.
26 # WINTOPDIR is the same directory, in Windows syntax.
27
28 OTOPDIR=$(TOPDIR)
29 CTOPDIR=$(TOPDIR)
30 CYGPATH=echo
31 DIFF=diff -q
32 SORT=sort
33 SET_LD_PATH=CAML_LD_LIBRARY_PATH="$(LD_PATH)"
34
35 # The variables above may be overridden by .../Makefile.config
36 # OTOPDIR is either TOPDIR or WINTOPDIR, whichever is appropriate for
37 # arguments given to the OCaml compiler.
38 # CTOPDIR is either TOPDIR or WINTOPDIR, whichever is appropriate for
39 # arguments given to the C and Fortran compilers.
40 # CYGPATH is the command that translates unix-style file names into
41 # whichever syntax is appropriate for arguments of OCaml programs.
42 # DIFF is a "diff -q" command that ignores trailing CRs under Windows.
43 # SORT is the Unix "sort" command. Usually a simple command, but may be an
44 # absolute name if the Windows "sort" command is in the PATH.
45 # SET_LD_PATH is a command prefix that sets the path for dynamic libraries
46 # (CAML_LD_LIBRARY_PATH for Unix, PATH for Windows) using the LD_PATH shell
47 # variable. Note that for Windows we add Unix-syntax directory names in
48 # PATH, and Cygwin will translate it to Windows syntax.
49
50 include $(TOPDIR)/Makefile.config
51
52 # Make sure USE_RUNTIME is defined
53 USE_RUNTIME ?=
54
55 ifneq ($(USE_RUNTIME),)
56 #Check USE_RUNTIME value
57 ifeq ($(findstring $(USE_RUNTIME),d i),)
58 $(error If set, USE_RUNTIME must be equal to "d" (debug runtime) \
59 or "i" (instrumented runtime))
60 endif
61
62 RUNTIME_VARIANT=-I $(OTOPDIR)/runtime \
63 -runtime-variant $(USE_RUNTIME)
64 export OCAMLRUNPARAM?=v=0
65 endif
66
67 OCAMLRUN=$(TOPDIR)/runtime/ocamlrun$(USE_RUNTIME)$(EXE)
68
69 OCFLAGS=-nostdlib -I $(OTOPDIR)/stdlib $(COMPFLAGS)
70 OCOPTFLAGS=
71
72 ifeq ($(SUPPORTS_SHARED_LIBRARIES),false)
73 CUSTOM = -custom
74 else
75 CUSTOM =
76 endif
77
78 OCAML=$(OCAMLRUN) $(OTOPDIR)/ocaml $(OCFLAGS) -noinit
79 ifeq "$(FLEXLINK)" ""
80 FLEXLINK_PREFIX=
81 else
82 ifeq "$(wildcard $(TOPDIR)/flexdll/Makefile)" ""
83 FLEXLINK_PREFIX=
84 else
85 EMPTY=
86 FLEXLINK_PREFIX=OCAML_FLEXLINK="$(WINTOPDIR)/boot/ocamlrun \
87 $(WINTOPDIR)/flexdll/flexlink.exe" $(EMPTY)
88 endif
89 endif
90 OCAMLC=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/ocamlc $(CUSTOM) $(OCFLAGS) \
91 $(RUNTIME_VARIANT)
92 OCAMLOPT=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/ocamlopt $(OCFLAGS) \
93 $(RUNTIME_VARIANT)
94 OCAMLDOC=$(OCAMLRUN) $(OTOPDIR)/ocamldoc/ocamldoc
95 OCAMLLEX=$(OCAMLRUN) $(OTOPDIR)/lex/ocamllex
96 OCAMLMKLIB=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/tools/ocamlmklib \
97 -ocamlc "$(OTOPDIR)/runtime/ocamlrun$(USE_RUNTIME)$(EXE) \
98 $(OTOPDIR)/ocamlc $(OCFLAGS) $(RUNTIME_VARIANT)" \
99 -ocamlopt "$(OTOPDIR)/runtime/ocamlrun$(USE_RUNTIME)$(EXE) \
100 $(OTOPDIR)/ocamlopt $(OCFLAGS) $(RUNTIME_VARIANT)"
101 OCAMLYACC=$(TOPDIR)/yacc/ocamlyacc$(EXE)
102 DUMPOBJ=$(OCAMLRUN) $(OTOPDIR)/tools/dumpobj
103 OBJINFO=$(OCAMLRUN) $(OTOPDIR)/tools/ocamlobjinfo
104
105 #FORTRAN_COMPILER=
106 #FORTRAN_LIBRARY=
107
108 UNIXLIBVAR=`case "$(OTHERLIBRARIES)" in *win32unix*) echo win32;; esac`
109