Skip to content
This repository
Browse code

KaSim first release

  • Loading branch information...
commit 4ff11821e46944e84195f91670720f3b96d376dd 1 parent 50b483e
authored October 24, 2010

Showing 41 changed files with 7,713 additions and 0 deletions. Show diff stats Hide diff stats

  1. 20  Error/ExceptionDefn.ml
  2. 1  Error/debug.ml
  3. 165  LGPL-LICENSE
  4. 38  Makefile
  5. 1,189  OCamlMakefile
  6. 139  dataStructures/heap.ml
  7. 259  dataStructures/largeArray.ml
  8. 15  dataStructures/liftSet.ml
  9. 27  dataStructures/longString.ml
  10. 7  dataStructures/longString.mli
  11. 214  dataStructures/mapExt.ml
  12. 119  dataStructures/memoryManagement.ml
  13. 53  dataStructures/misc.ml
  14. 182  dataStructures/mods.ml
  15. 34  dataStructures/profiling.ml
  16. 191  dataStructures/random_tree.ml
  17. 187  dataStructures/valMap.ml
  18. 91  grammar/ast.ml
  19. 683  grammar/eval.ml
  20. 6  grammar/eval.mli
  21. 155  grammar/kappaLexer.mll
  22. 309  grammar/kappaParser.mly
  23. 4  main/fileName.ml
  24. 94  main/main.ml
  25. 36  main/parameter.ml
  26. 493  pattern/dynamics.ml
  27. 209  pattern/environment.ml
  28. 108  pattern/matching.ml
  29. 324  pattern/mixture.ml
  30. 73  pattern/mixture.mli
  31. 84  pattern/precondition.ml
  32. 9  pattern/precondition.mli
  33. 117  pattern/signature.ml
  34. 8  simulation/b3.ml
  35. 179  simulation/external.ml
  36. 121  simulation/plot.ml
  37. 103  simulation/run.ml
  38. 1,115  simulation/state.ml
  39. 140  siteGraphs/graph.ml
  40. 261  siteGraphs/node.ml
  41. 151  siteGraphs/species.ml
20  Error/ExceptionDefn.ml
... ...
@@ -0,0 +1,20 @@
  1
+exception IntFound of int
  2
+exception StringFound of string
  3
+exception MapFound of (int Mods.IntMap.t)
  4
+exception False
  5
+exception True
  6
+exception Null_event
  7
+exception Deadlock
  8
+exception UserInterrupted of string
  9
+
  10
+exception Syntax_Error of string
  11
+exception Semantics_Error of Misc.position * string
  12
+
  13
+let warning ?with_pos msg = 
  14
+	let _ = 
  15
+		match with_pos with
  16
+			| Some pos -> prerr_string ((Misc.string_of_pos pos)^" ")
  17
+			| None -> ()
  18
+	in
  19
+		prerr_string ("WARNING: "^msg^"\n") ; flush stderr
  20
+
1  Error/debug.ml
... ...
@@ -0,0 +1 @@
  1
+let tag s = print_string (s^"\n") ; flush stdout
165  LGPL-LICENSE
... ...
@@ -0,0 +1,165 @@
  1
+                   GNU LESSER GENERAL PUBLIC LICENSE
  2
+                       Version 3, 29 June 2007
  3
+
  4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
  5
+ Everyone is permitted to copy and distribute verbatim copies
  6
+ of this license document, but changing it is not allowed.
  7
+
  8
+
  9
+  This version of the GNU Lesser General Public License incorporates
  10
+the terms and conditions of version 3 of the GNU General Public
  11
+License, supplemented by the additional permissions listed below.
  12
+
  13
+  0. Additional Definitions.
  14
+
  15
+  As used herein, "this License" refers to version 3 of the GNU Lesser
  16
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
  17
+General Public License.
  18
+
  19
+  "The Library" refers to a covered work governed by this License,
  20
+other than an Application or a Combined Work as defined below.
  21
+
  22
+  An "Application" is any work that makes use of an interface provided
  23
+by the Library, but which is not otherwise based on the Library.
  24
+Defining a subclass of a class defined by the Library is deemed a mode
  25
+of using an interface provided by the Library.
  26
+
  27
+  A "Combined Work" is a work produced by combining or linking an
  28
+Application with the Library.  The particular version of the Library
  29
+with which the Combined Work was made is also called the "Linked
  30
+Version".
  31
+
  32
+  The "Minimal Corresponding Source" for a Combined Work means the
  33
+Corresponding Source for the Combined Work, excluding any source code
  34
+for portions of the Combined Work that, considered in isolation, are
  35
+based on the Application, and not on the Linked Version.
  36
+
  37
+  The "Corresponding Application Code" for a Combined Work means the
  38
+object code and/or source code for the Application, including any data
  39
+and utility programs needed for reproducing the Combined Work from the
  40
+Application, but excluding the System Libraries of the Combined Work.
  41
+
  42
+  1. Exception to Section 3 of the GNU GPL.
  43
+
  44
+  You may convey a covered work under sections 3 and 4 of this License
  45
+without being bound by section 3 of the GNU GPL.
  46
+
  47
+  2. Conveying Modified Versions.
  48
+
  49
+  If you modify a copy of the Library, and, in your modifications, a
  50
+facility refers to a function or data to be supplied by an Application
  51
+that uses the facility (other than as an argument passed when the
  52
+facility is invoked), then you may convey a copy of the modified
  53
+version:
  54
+
  55
+   a) under this License, provided that you make a good faith effort to
  56
+   ensure that, in the event an Application does not supply the
  57
+   function or data, the facility still operates, and performs
  58
+   whatever part of its purpose remains meaningful, or
  59
+
  60
+   b) under the GNU GPL, with none of the additional permissions of
  61
+   this License applicable to that copy.
  62
+
  63
+  3. Object Code Incorporating Material from Library Header Files.
  64
+
  65
+  The object code form of an Application may incorporate material from
  66
+a header file that is part of the Library.  You may convey such object
  67
+code under terms of your choice, provided that, if the incorporated
  68
+material is not limited to numerical parameters, data structure
  69
+layouts and accessors, or small macros, inline functions and templates
  70
+(ten or fewer lines in length), you do both of the following:
  71
+
  72
+   a) Give prominent notice with each copy of the object code that the
  73
+   Library is used in it and that the Library and its use are
  74
+   covered by this License.
  75
+
  76
+   b) Accompany the object code with a copy of the GNU GPL and this license
  77
+   document.
  78
+
  79
+  4. Combined Works.
  80
+
  81
+  You may convey a Combined Work under terms of your choice that,
  82
+taken together, effectively do not restrict modification of the
  83
+portions of the Library contained in the Combined Work and reverse
  84
+engineering for debugging such modifications, if you also do each of
  85
+the following:
  86
+
  87
+   a) Give prominent notice with each copy of the Combined Work that
  88
+   the Library is used in it and that the Library and its use are
  89
+   covered by this License.
  90
+
  91
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
  92
+   document.
  93
+
  94
+   c) For a Combined Work that displays copyright notices during
  95
+   execution, include the copyright notice for the Library among
  96
+   these notices, as well as a reference directing the user to the
  97
+   copies of the GNU GPL and this license document.
  98
+
  99
+   d) Do one of the following:
  100
+
  101
+       0) Convey the Minimal Corresponding Source under the terms of this
  102
+       License, and the Corresponding Application Code in a form
  103
+       suitable for, and under terms that permit, the user to
  104
+       recombine or relink the Application with a modified version of
  105
+       the Linked Version to produce a modified Combined Work, in the
  106
+       manner specified by section 6 of the GNU GPL for conveying
  107
+       Corresponding Source.
  108
+
  109
+       1) Use a suitable shared library mechanism for linking with the
  110
+       Library.  A suitable mechanism is one that (a) uses at run time
  111
+       a copy of the Library already present on the user's computer
  112
+       system, and (b) will operate properly with a modified version
  113
+       of the Library that is interface-compatible with the Linked
  114
+       Version.
  115
+
  116
+   e) Provide Installation Information, but only if you would otherwise
  117
+   be required to provide such information under section 6 of the
  118
+   GNU GPL, and only to the extent that such information is
  119
+   necessary to install and execute a modified version of the
  120
+   Combined Work produced by recombining or relinking the
  121
+   Application with a modified version of the Linked Version. (If
  122
+   you use option 4d0, the Installation Information must accompany
  123
+   the Minimal Corresponding Source and Corresponding Application
  124
+   Code. If you use option 4d1, you must provide the Installation
  125
+   Information in the manner specified by section 6 of the GNU GPL
  126
+   for conveying Corresponding Source.)
  127
+
  128
+  5. Combined Libraries.
  129
+
  130
+  You may place library facilities that are a work based on the
  131
+Library side by side in a single library together with other library
  132
+facilities that are not Applications and are not covered by this
  133
+License, and convey such a combined library under terms of your
  134
+choice, if you do both of the following:
  135
+
  136
+   a) Accompany the combined library with a copy of the same work based
  137
+   on the Library, uncombined with any other library facilities,
  138
+   conveyed under the terms of this License.
  139
+
  140
+   b) Give prominent notice with the combined library that part of it
  141
+   is a work based on the Library, and explaining where to find the
  142
+   accompanying uncombined form of the same work.
  143
+
  144
+  6. Revised Versions of the GNU Lesser General Public License.
  145
+
  146
+  The Free Software Foundation may publish revised and/or new versions
  147
+of the GNU Lesser General Public License from time to time. Such new
  148
+versions will be similar in spirit to the present version, but may
  149
+differ in detail to address new problems or concerns.
  150
+
  151
+  Each version is given a distinguishing version number. If the
  152
+Library as you received it specifies that a certain numbered version
  153
+of the GNU Lesser General Public License "or any later version"
  154
+applies to it, you have the option of following the terms and
  155
+conditions either of that published version or of any later version
  156
+published by the Free Software Foundation. If the Library as you
  157
+received it does not specify a version number of the GNU Lesser
  158
+General Public License, you may choose any version of the GNU Lesser
  159
+General Public License ever published by the Free Software Foundation.
  160
+
  161
+  If the Library as you received it specifies that a proxy can decide
  162
+whether future versions of the GNU Lesser General Public License shall
  163
+apply, that proxy's public statement of acceptance of any version is
  164
+permanent authorization for you to choose that version for the
  165
+Library.
38  Makefile
... ...
@@ -0,0 +1,38 @@
  1
+# see: http://www.ocaml.info/home/ocaml_sources.html#toc16
  2
+
  3
+# put here the names of your source files (in the right order)
  4
+SOURCES = main/parameter.ml \
  5
+		dataStructures/largeArray.ml dataStructures/memoryManagement.ml dataStructures/heap.ml  \
  6
+		dataStructures/misc.ml dataStructures/mapExt.ml dataStructures/valMap.ml dataStructures/random_tree.ml dataStructures/mods.ml dataStructures/liftSet.ml\
  7
+		Error/debug.ml Error/ExceptionDefn.ml \
  8
+		grammar/ast.ml grammar/kappaParser.mly grammar/kappaLexer.mll \
  9
+		pattern/signature.ml pattern/environment.ml \
  10
+		siteGraphs/node.ml pattern/mixture.mli  \
  11
+		pattern/mixture.ml pattern/precondition.ml pattern/precondition.mli \
  12
+		siteGraphs/graph.ml siteGraphs/species.ml pattern/matching.ml pattern/dynamics.ml \
  13
+		grammar/eval.mli simulation/state.ml simulation/external.ml grammar/eval.ml  \
  14
+		simulation/plot.ml simulation/b3.ml simulation/run.ml\
  15
+		main/fileName.ml main/main.ml 
  16
+
  17
+# the name of the resulting executable
  18
+RESULT  = kaSim
  19
+
  20
+# generate type information (.annot files)
  21
+ANNOTATE = yes
  22
+
  23
+
  24
+# make target (see manual) : byte-code, debug-code, native-code, ...
  25
+all: nc
  26
+
  27
+
  28
+OCAMLBINPATH = /sw/bin
  29
+OCAMLLIBPATH = /sw/lib/ocaml
  30
+OCAMLCP = $(OCAMLBINPATH)/ocamlcp
  31
+OCAMLLEX = $(OCAMLBINPATH)/ocamllex
  32
+OCAMLYACC = $(OCAMLBINPATH)/ocamlyacc
  33
+OCAMLC = $(OCAMLBINPATH)/ocamlc.opt
  34
+OCAMLOPT = $(OCAMLBINPATH)/ocamlopt.opt #-g -ccopt -g
  35
+OCAMLDEP = $(OCAMLBINPATH)/ocamldep
  36
+CC = gcc
  37
+
  38
+include OCamlMakefile
1,189  OCamlMakefile
... ...
@@ -0,0 +1,1189 @@
  1
+###########################################################################
  2
+#                              OCamlMakefile
  3
+#                  Copyright (C) 1999-2007  Markus Mottl
  4
+#
  5
+#                             For updates see:
  6
+#                http://www.ocaml.info/home/ocaml_sources.html
  7
+#
  8
+###########################################################################
  9
+
  10
+# Modified by damien for .glade.ml compilation
  11
+
  12
+# Set these variables to the names of the sources to be processed and
  13
+# the result variable. Order matters during linkage!
  14
+
  15
+ifndef SOURCES
  16
+  SOURCES := foo.ml
  17
+endif
  18
+export SOURCES
  19
+
  20
+ifndef RES_CLIB_SUF
  21
+  RES_CLIB_SUF := _stubs
  22
+endif
  23
+export RES_CLIB_SUF
  24
+
  25
+ifndef RESULT
  26
+  RESULT := foo
  27
+endif
  28
+export RESULT := $(strip $(RESULT))
  29
+
  30
+export LIB_PACK_NAME
  31
+
  32
+ifndef DOC_FILES
  33
+  DOC_FILES := $(filter %.mli, $(SOURCES))
  34
+endif
  35
+export DOC_FILES
  36
+FIRST_DOC_FILE := $(firstword $(DOC_FILES))
  37
+
  38
+export BCSUFFIX
  39
+export NCSUFFIX
  40
+
  41
+ifndef TOPSUFFIX
  42
+  TOPSUFFIX := .top
  43
+endif
  44
+export TOPSUFFIX
  45
+
  46
+# Eventually set include- and library-paths, libraries to link,
  47
+# additional compilation-, link- and ocamlyacc-flags
  48
+# Path- and library information needs not be written with "-I" and such...
  49
+# Define THREADS if you need it, otherwise leave it unset (same for
  50
+# USE_CAMLP4)!
  51
+
  52
+export THREADS
  53
+export VMTHREADS
  54
+export ANNOTATE
  55
+export USE_CAMLP4
  56
+
  57
+export INCDIRS
  58
+export LIBDIRS
  59
+export EXTLIBDIRS
  60
+export RESULTDEPS
  61
+export OCAML_DEFAULT_DIRS
  62
+
  63
+export LIBS
  64
+export CLIBS
  65
+export CFRAMEWORKS
  66
+
  67
+export OCAMLFLAGS
  68
+export OCAMLNCFLAGS
  69
+export OCAMLBCFLAGS
  70
+
  71
+export OCAMLLDFLAGS
  72
+export OCAMLNLDFLAGS
  73
+export OCAMLBLDFLAGS
  74
+
  75
+export OCAMLMKLIB_FLAGS
  76
+
  77
+ifndef OCAMLCPFLAGS
  78
+  OCAMLCPFLAGS := a
  79
+endif
  80
+export OCAMLCPFLAGS
  81
+
  82
+ifndef DOC_DIR
  83
+  DOC_DIR := doc
  84
+endif
  85
+export DOC_DIR
  86
+
  87
+export PPFLAGS
  88
+
  89
+export LFLAGS
  90
+export YFLAGS
  91
+export IDLFLAGS
  92
+
  93
+export OCAMLDOCFLAGS
  94
+
  95
+export OCAMLFIND_INSTFLAGS
  96
+
  97
+export DVIPSFLAGS
  98
+
  99
+export STATIC
  100
+
  101
+# Add a list of optional trash files that should be deleted by "make clean"
  102
+export TRASH
  103
+
  104
+ECHO := echo
  105
+
  106
+ifdef REALLY_QUIET
  107
+  export REALLY_QUIET
  108
+  ECHO := true
  109
+  LFLAGS := $(LFLAGS) -q
  110
+  YFLAGS := $(YFLAGS) -q
  111
+endif
  112
+
  113
+####################  variables depending on your OCaml-installation
  114
+
  115
+ifdef MINGW
  116
+  export MINGW
  117
+  WIN32   := 1
  118
+  CFLAGS_WIN32 := -mno-cygwin
  119
+endif
  120
+ifdef MSVC
  121
+  export MSVC
  122
+  WIN32   := 1
  123
+  ifndef STATIC
  124
+    CPPFLAGS_WIN32 := -DCAML_DLL
  125
+  endif
  126
+  CFLAGS_WIN32 += -nologo
  127
+  EXT_OBJ := obj
  128
+  EXT_LIB := lib
  129
+  ifeq ($(CC),gcc)
  130
+    # work around GNU Make default value
  131
+    ifdef THREADS
  132
+      CC := cl -MT
  133
+    else
  134
+      CC := cl
  135
+    endif
  136
+  endif
  137
+  ifeq ($(CXX),g++)
  138
+    # work around GNU Make default value
  139
+    CXX := $(CC)
  140
+  endif
  141
+  CFLAG_O := -Fo
  142
+endif
  143
+ifdef WIN32
  144
+  EXT_CXX := cpp
  145
+  EXE     := .exe
  146
+endif
  147
+
  148
+ifndef EXT_OBJ
  149
+  EXT_OBJ := o
  150
+endif
  151
+ifndef EXT_LIB
  152
+  EXT_LIB := a
  153
+endif
  154
+ifndef EXT_CXX
  155
+  EXT_CXX := cc
  156
+endif
  157
+ifndef EXE
  158
+  EXE := # empty
  159
+endif
  160
+ifndef CFLAG_O
  161
+  CFLAG_O := -o # do not delete this comment (preserves trailing whitespace)!
  162
+endif
  163
+
  164
+export CC
  165
+export CXX
  166
+export CFLAGS
  167
+export CXXFLAGS
  168
+export LDFLAGS
  169
+export CPPFLAGS
  170
+
  171
+ifndef RPATH_FLAG
  172
+  ifdef ELF_RPATH_FLAG
  173
+    RPATH_FLAG := $(ELF_RPATH_FLAG)
  174
+  else
  175
+    RPATH_FLAG := -R
  176
+  endif
  177
+endif
  178
+export RPATH_FLAG
  179
+
  180
+ifndef MSVC
  181
+ifndef PIC_CFLAGS
  182
+  PIC_CFLAGS := -fPIC
  183
+endif
  184
+ifndef PIC_CPPFLAGS
  185
+  PIC_CPPFLAGS := -DPIC
  186
+endif
  187
+endif
  188
+
  189
+export PIC_CFLAGS
  190
+export PIC_CPPFLAGS
  191
+
  192
+BCRESULT  := $(addsuffix $(BCSUFFIX), $(RESULT))
  193
+NCRESULT  := $(addsuffix $(NCSUFFIX), $(RESULT))
  194
+TOPRESULT := $(addsuffix $(TOPSUFFIX), $(RESULT))
  195
+
  196
+ifndef OCAMLFIND
  197
+  OCAMLFIND := ocamlfind
  198
+endif
  199
+export OCAMLFIND
  200
+
  201
+ifndef OCAMLC
  202
+  OCAMLC := ocamlc
  203
+endif
  204
+export OCAMLC
  205
+
  206
+ifndef OCAMLOPT
  207
+  OCAMLOPT := ocamlopt
  208
+endif
  209
+export OCAMLOPT
  210
+
  211
+ifndef OCAMLMKTOP
  212
+  OCAMLMKTOP := ocamlmktop
  213
+endif
  214
+export OCAMLMKTOP
  215
+
  216
+ifndef OCAMLCP
  217
+  OCAMLCP := ocamlcp
  218
+endif
  219
+export OCAMLCP
  220
+
  221
+ifndef OCAMLDEP
  222
+  OCAMLDEP := ocamldep
  223
+endif
  224
+export OCAMLDEP
  225
+
  226
+ifndef OCAMLLEX
  227
+  OCAMLLEX := ocamllex
  228
+endif
  229
+export OCAMLLEX
  230
+
  231
+ifndef OCAMLYACC
  232
+  OCAMLYACC := ocamlyacc
  233
+endif
  234
+export OCAMLYACC
  235
+
  236
+ifndef OCAMLMKLIB
  237
+  OCAMLMKLIB := ocamlmklib
  238
+endif
  239
+export OCAMLMKLIB
  240
+
  241
+ifndef OCAML_GLADECC
  242
+  OCAML_GLADECC := lablgladecc2
  243
+endif
  244
+export OCAML_GLADECC
  245
+
  246
+ifndef OCAML_GLADECC_FLAGS
  247
+  OCAML_GLADECC_FLAGS :=
  248
+endif
  249
+export OCAML_GLADECC_FLAGS
  250
+
  251
+ifndef CAMELEON_REPORT
  252
+  CAMELEON_REPORT := report
  253
+endif
  254
+export CAMELEON_REPORT
  255
+
  256
+ifndef CAMELEON_REPORT_FLAGS
  257
+  CAMELEON_REPORT_FLAGS :=
  258
+endif
  259
+export CAMELEON_REPORT_FLAGS
  260
+
  261
+ifndef CAMELEON_ZOGGY
  262
+  CAMELEON_ZOGGY := camlp4o pa_zog.cma pr_o.cmo
  263
+endif
  264
+export CAMELEON_ZOGGY
  265
+
  266
+ifndef CAMELEON_ZOGGY_FLAGS
  267
+  CAMELEON_ZOGGY_FLAGS :=
  268
+endif
  269
+export CAMELEON_ZOGGY_FLAGS
  270
+
  271
+ifndef OXRIDL
  272
+  OXRIDL := oxridl
  273
+endif
  274
+export OXRIDL
  275
+
  276
+ifndef CAMLIDL
  277
+  CAMLIDL := camlidl
  278
+endif
  279
+export CAMLIDL
  280
+
  281
+ifndef CAMLIDLDLL
  282
+  CAMLIDLDLL := camlidldll
  283
+endif
  284
+export CAMLIDLDLL
  285
+
  286
+ifndef NOIDLHEADER
  287
+  MAYBE_IDL_HEADER := -header
  288
+endif
  289
+export NOIDLHEADER
  290
+
  291
+export NO_CUSTOM
  292
+
  293
+ifndef CAMLP4
  294
+  CAMLP4 := camlp4
  295
+endif
  296
+export CAMLP4
  297
+
  298
+ifndef REAL_OCAMLFIND
  299
+  ifdef PACKS
  300
+    ifndef CREATE_LIB
  301
+      ifdef THREADS
  302
+	PACKS += threads
  303
+      endif
  304
+    endif
  305
+    empty :=
  306
+    space := $(empty) $(empty)
  307
+    comma := ,
  308
+    ifdef PREDS
  309
+      PRE_OCAML_FIND_PREDICATES := $(subst $(space),$(comma),$(PREDS))
  310
+      PRE_OCAML_FIND_PACKAGES := $(subst $(space),$(comma),$(PACKS))
  311
+      OCAML_FIND_PREDICATES := -predicates $(PRE_OCAML_FIND_PREDICATES)
  312
+  #    OCAML_DEP_PREDICATES := -syntax $(PRE_OCAML_FIND_PREDICATES)
  313
+      OCAML_FIND_PACKAGES := $(OCAML_FIND_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
  314
+      OCAML_DEP_PACKAGES := $(OCAML_DEP_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
  315
+    else
  316
+      OCAML_FIND_PACKAGES := -package $(subst $(space),$(comma),$(PACKS))
  317
+      OCAML_DEP_PACKAGES :=
  318
+    endif
  319
+    OCAML_FIND_LINKPKG := -linkpkg
  320
+    REAL_OCAMLFIND := $(OCAMLFIND)
  321
+  endif
  322
+endif
  323
+
  324
+export OCAML_FIND_PACKAGES
  325
+export OCAML_DEP_PACKAGES
  326
+export OCAML_FIND_LINKPKG
  327
+export REAL_OCAMLFIND
  328
+
  329
+ifndef OCAMLDOC
  330
+  OCAMLDOC := ocamldoc
  331
+endif
  332
+export OCAMLDOC
  333
+
  334
+ifndef LATEX
  335
+  LATEX := latex
  336
+endif
  337
+export LATEX
  338
+
  339
+ifndef DVIPS
  340
+  DVIPS := dvips
  341
+endif
  342
+export DVIPS
  343
+
  344
+ifndef PS2PDF
  345
+  PS2PDF := ps2pdf
  346
+endif
  347
+export PS2PDF
  348
+
  349
+ifndef OCAMLMAKEFILE
  350
+  OCAMLMAKEFILE := OCamlMakefile
  351
+endif
  352
+export OCAMLMAKEFILE
  353
+
  354
+ifndef OCAMLLIBPATH
  355
+  OCAMLLIBPATH := \
  356
+    $(shell $(OCAMLC) 2>/dev/null -where || echo /usr/local/lib/ocaml)
  357
+endif
  358
+export OCAMLLIBPATH
  359
+
  360
+ifndef OCAML_LIB_INSTALL
  361
+  OCAML_LIB_INSTALL := $(OCAMLLIBPATH)/contrib
  362
+endif
  363
+export OCAML_LIB_INSTALL
  364
+
  365
+###########################################################################
  366
+
  367
+####################  change following sections only if
  368
+####################    you know what you are doing!
  369
+
  370
+# delete target files when a build command fails
  371
+.PHONY: .DELETE_ON_ERROR
  372
+.DELETE_ON_ERROR:
  373
+
  374
+# for pedants using "--warn-undefined-variables"
  375
+export MAYBE_IDL
  376
+export REAL_RESULT
  377
+export CAMLIDLFLAGS
  378
+export THREAD_FLAG
  379
+export RES_CLIB
  380
+export MAKEDLL
  381
+export ANNOT_FLAG
  382
+export C_OXRIDL
  383
+export SUBPROJS
  384
+export CFLAGS_WIN32
  385
+export CPPFLAGS_WIN32
  386
+
  387
+INCFLAGS :=
  388
+
  389
+SHELL := /bin/sh
  390
+
  391
+MLDEPDIR := ._d
  392
+BCDIDIR  := ._bcdi
  393
+NCDIDIR  := ._ncdi
  394
+
  395
+FILTER_EXTNS := %.mli %.ml %.mll %.mly %.idl %.oxridl %.c %.m %.$(EXT_CXX) %.rep %.zog %.glade
  396
+
  397
+FILTERED     := $(filter $(FILTER_EXTNS), $(SOURCES))
  398
+SOURCE_DIRS  := $(filter-out ./, $(sort $(dir $(FILTERED))))
  399
+
  400
+FILTERED_REP := $(filter %.rep, $(FILTERED))
  401
+DEP_REP      := $(FILTERED_REP:%.rep=$(MLDEPDIR)/%.d)
  402
+AUTO_REP     := $(FILTERED_REP:.rep=.ml)
  403
+
  404
+FILTERED_ZOG := $(filter %.zog, $(FILTERED))
  405
+DEP_ZOG      := $(FILTERED_ZOG:%.zog=$(MLDEPDIR)/%.d)
  406
+AUTO_ZOG     := $(FILTERED_ZOG:.zog=.ml)
  407
+
  408
+FILTERED_GLADE := $(filter %.glade, $(FILTERED))
  409
+DEP_GLADE      := $(FILTERED_GLADE:%.glade=$(MLDEPDIR)/%.d)
  410
+AUTO_GLADE     := $(FILTERED_GLADE:.glade=.ml)
  411
+
  412
+FILTERED_ML  := $(filter %.ml, $(FILTERED))
  413
+DEP_ML       := $(FILTERED_ML:%.ml=$(MLDEPDIR)/%.d)
  414
+
  415
+FILTERED_MLI := $(filter %.mli, $(FILTERED))
  416
+DEP_MLI      := $(FILTERED_MLI:.mli=.di)
  417
+
  418
+FILTERED_MLL := $(filter %.mll, $(FILTERED))
  419
+DEP_MLL      := $(FILTERED_MLL:%.mll=$(MLDEPDIR)/%.d)
  420
+AUTO_MLL     := $(FILTERED_MLL:.mll=.ml)
  421
+
  422
+FILTERED_MLY := $(filter %.mly, $(FILTERED))
  423
+DEP_MLY      := $(FILTERED_MLY:%.mly=$(MLDEPDIR)/%.d) $(FILTERED_MLY:.mly=.di)
  424
+AUTO_MLY     := $(FILTERED_MLY:.mly=.mli) $(FILTERED_MLY:.mly=.ml)
  425
+
  426
+FILTERED_IDL := $(filter %.idl, $(FILTERED))
  427
+DEP_IDL      := $(FILTERED_IDL:%.idl=$(MLDEPDIR)/%.d) $(FILTERED_IDL:.idl=.di)
  428
+C_IDL        := $(FILTERED_IDL:%.idl=%_stubs.c)
  429
+ifndef NOIDLHEADER
  430
+ C_IDL += $(FILTERED_IDL:.idl=.h)
  431
+endif
  432
+OBJ_C_IDL    := $(FILTERED_IDL:%.idl=%_stubs.$(EXT_OBJ))
  433
+AUTO_IDL     := $(FILTERED_IDL:.idl=.mli) $(FILTERED_IDL:.idl=.ml) $(C_IDL)
  434
+
  435
+FILTERED_OXRIDL := $(filter %.oxridl, $(FILTERED))
  436
+DEP_OXRIDL      := $(FILTERED_OXRIDL:%.oxridl=$(MLDEPDIR)/%.d) $(FILTERED_OXRIDL:.oxridl=.di)
  437
+AUTO_OXRIDL     := $(FILTERED_OXRIDL:.oxridl=.mli) $(FILTERED_OXRIDL:.oxridl=.ml) $(C_OXRIDL)
  438
+
  439
+FILTERED_C_CXX := $(filter %.c %.m %.$(EXT_CXX), $(FILTERED))
  440
+OBJ_C_CXX      := $(FILTERED_C_CXX:.c=.$(EXT_OBJ))
  441
+OBJ_C_CXX      := $(OBJ_C_CXX:.m=.$(EXT_OBJ))
  442
+OBJ_C_CXX      := $(OBJ_C_CXX:.$(EXT_CXX)=.$(EXT_OBJ))
  443
+
  444
+PRE_TARGETS  += $(AUTO_MLL) $(AUTO_MLY) $(AUTO_IDL) $(AUTO_OXRIDL) $(AUTO_ZOG) $(AUTO_REP) $(AUTO_GLADE)
  445
+
  446
+ALL_DEPS     := $(DEP_ML) $(DEP_MLI) $(DEP_MLL) $(DEP_MLY) $(DEP_IDL) $(DEP_OXRIDL) $(DEP_ZOG) $(DEP_REP) $(DEP_GLADE)
  447
+
  448
+MLDEPS       := $(filter %.d, $(ALL_DEPS))
  449
+MLIDEPS      := $(filter %.di, $(ALL_DEPS))
  450
+BCDEPIS      := $(MLIDEPS:%.di=$(BCDIDIR)/%.di)
  451
+NCDEPIS      := $(MLIDEPS:%.di=$(NCDIDIR)/%.di)
  452
+
  453
+ALLML        := $(filter %.mli %.ml %.mll %.mly %.idl %.oxridl %.rep %.zog %.glade, $(FILTERED))
  454
+
  455
+IMPLO_INTF   := $(ALLML:%.mli=%.mli.__)
  456
+IMPLO_INTF   := $(foreach file, $(IMPLO_INTF), \
  457
+                  $(basename $(file)).cmi $(basename $(file)).cmo)
  458
+IMPLO_INTF   := $(filter-out %.mli.cmo, $(IMPLO_INTF))
  459
+IMPLO_INTF   := $(IMPLO_INTF:%.mli.cmi=%.cmi)
  460
+
  461
+IMPLX_INTF   := $(IMPLO_INTF:.cmo=.cmx)
  462
+
  463
+INTF         := $(filter %.cmi, $(IMPLO_INTF))
  464
+IMPL_CMO     := $(filter %.cmo, $(IMPLO_INTF))
  465
+IMPL_CMX     := $(IMPL_CMO:.cmo=.cmx)
  466
+IMPL_ASM     := $(IMPL_CMO:.cmo=.asm)
  467
+IMPL_S       := $(IMPL_CMO:.cmo=.s)
  468
+
  469
+OBJ_LINK     := $(OBJ_C_IDL) $(OBJ_C_CXX)
  470
+OBJ_FILES    := $(IMPL_CMO:.cmo=.$(EXT_OBJ)) $(OBJ_LINK)
  471
+
  472
+EXECS        := $(addsuffix $(EXE), \
  473
+                            $(sort $(TOPRESULT) $(BCRESULT) $(NCRESULT)))
  474
+ifdef WIN32
  475
+  EXECS      += $(BCRESULT).dll $(NCRESULT).dll
  476
+endif
  477
+
  478
+CLIB_BASE    := $(RESULT)$(RES_CLIB_SUF)
  479
+ifneq ($(strip $(OBJ_LINK)),)
  480
+  RES_CLIB     := lib$(CLIB_BASE).$(EXT_LIB)
  481
+endif
  482
+
  483
+ifdef WIN32
  484
+DLLSONAME := $(CLIB_BASE).dll
  485
+else
  486
+DLLSONAME := dll$(CLIB_BASE).so
  487
+endif
  488
+
  489
+NONEXECS     := $(INTF) $(IMPL_CMO) $(IMPL_CMX) $(IMPL_ASM) $(IMPL_S) \
  490
+		$(OBJ_FILES) $(PRE_TARGETS) $(BCRESULT).cma $(NCRESULT).cmxa \
  491
+		$(NCRESULT).$(EXT_LIB) $(BCRESULT).cmi $(BCRESULT).cmo \
  492
+		$(NCRESULT).cmi $(NCRESULT).cmx $(NCRESULT).o \
  493
+		$(RES_CLIB) $(IMPL_CMO:.cmo=.annot) \
  494
+		$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(LIB_PACK_NAME).cmx $(LIB_PACK_NAME).o
  495
+
  496
+ifndef STATIC
  497
+  NONEXECS += $(DLLSONAME)
  498
+endif
  499
+
  500
+ifndef LIBINSTALL_FILES
  501
+  LIBINSTALL_FILES := $(RESULT).mli $(RESULT).cmi $(RESULT).cma \
  502
+		      $(RESULT).cmxa $(RESULT).$(EXT_LIB) $(RES_CLIB)
  503
+  ifndef STATIC
  504
+    ifneq ($(strip $(OBJ_LINK)),)
  505
+      LIBINSTALL_FILES += $(DLLSONAME)
  506
+    endif
  507
+  endif
  508
+endif
  509
+
  510
+export LIBINSTALL_FILES
  511
+
  512
+ifdef WIN32
  513
+  # some extra stuff is created while linking DLLs
  514
+  NONEXECS   += $(BCRESULT).$(EXT_LIB) $(BCRESULT).exp $(NCRESULT).exp $(CLIB_BASE).exp $(CLIB_BASE).lib
  515
+endif
  516
+
  517
+TARGETS      := $(EXECS) $(NONEXECS)
  518
+
  519
+# If there are IDL-files
  520
+ifneq ($(strip $(FILTERED_IDL)),)
  521
+  MAYBE_IDL := -cclib -lcamlidl
  522
+endif
  523
+
  524
+ifdef USE_CAMLP4
  525
+  CAMLP4PATH := \
  526
+    $(shell $(CAMLP4) -where 2>/dev/null || echo /usr/local/lib/camlp4)
  527
+  INCFLAGS := -I $(CAMLP4PATH)
  528
+  CINCFLAGS := -I$(CAMLP4PATH)
  529
+endif
  530
+
  531
+DINCFLAGS := $(INCFLAGS) $(SOURCE_DIRS:%=-I %) $(OCAML_DEFAULT_DIRS:%=-I %)
  532
+INCFLAGS := $(DINCFLAGS) $(INCDIRS:%=-I %)
  533
+CINCFLAGS += $(SOURCE_DIRS:%=-I%) $(INCDIRS:%=-I%) $(OCAML_DEFAULT_DIRS:%=-I%)
  534
+
  535
+ifndef MSVC
  536
+  CLIBFLAGS += $(SOURCE_DIRS:%=-L%) $(LIBDIRS:%=-L%) \
  537
+               $(EXTLIBDIRS:%=-L%) $(OCAML_DEFAULT_DIRS:%=-L%)
  538
+
  539
+  ifeq ($(ELF_RPATH), yes)
  540
+    CLIBFLAGS += $(EXTLIBDIRS:%=-Wl,$(RPATH_FLAG)%)
  541
+  endif
  542
+endif
  543
+
  544
+ifndef PROFILING
  545
+  INTF_OCAMLC := $(OCAMLC)
  546
+else
  547
+  ifndef THREADS
  548
+    INTF_OCAMLC := $(OCAMLCP) -p $(OCAMLCPFLAGS)
  549
+  else
  550
+    # OCaml does not support profiling byte code
  551
+    # with threads (yet), therefore we force an error.
  552
+    ifndef REAL_OCAMLC
  553
+      $(error Profiling of multithreaded byte code not yet supported by OCaml)
  554
+    endif
  555
+    INTF_OCAMLC := $(OCAMLC)
  556
+  endif
  557
+endif
  558
+
  559
+ifndef MSVC
  560
+  COMMON_LDFLAGS := $(LDFLAGS:%=-ccopt %) $(SOURCE_DIRS:%=-ccopt -L%) \
  561
+		    $(LIBDIRS:%=-ccopt -L%) $(EXTLIBDIRS:%=-ccopt -L%) \
  562
+		    $(EXTLIBDIRS:%=-ccopt -Wl $(OCAML_DEFAULT_DIRS:%=-ccopt -L%))
  563
+
  564
+  ifeq ($(ELF_RPATH),yes)
  565
+    COMMON_LDFLAGS += $(EXTLIBDIRS:%=-ccopt -Wl,$(RPATH_FLAG)%)
  566
+  endif
  567
+else
  568
+  COMMON_LDFLAGS := -ccopt "/link -NODEFAULTLIB:LIBC $(LDFLAGS:%=%) $(SOURCE_DIRS:%=-LIBPATH:%) \
  569
+		    $(LIBDIRS:%=-LIBPATH:%) $(EXTLIBDIRS:%=-LIBPATH:%) \
  570
+		    $(OCAML_DEFAULT_DIRS:%=-LIBPATH:%) "
  571
+endif
  572
+
  573
+CLIBS_OPTS := $(CLIBS:%=-cclib -l%) $(CFRAMEWORKS:%=-cclib '-framework %')
  574
+ifdef MSVC
  575
+  ifndef STATIC
  576
+  # MSVC libraries do not have 'lib' prefix
  577
+  CLIBS_OPTS := $(CLIBS:%=-cclib %.lib)
  578
+  endif
  579
+endif
  580
+
  581
+ifneq ($(strip $(OBJ_LINK)),)
  582
+  ifdef CREATE_LIB
  583
+    OBJS_LIBS := -cclib -l$(CLIB_BASE) $(CLIBS_OPTS) $(MAYBE_IDL)
  584
+  else
  585
+    OBJS_LIBS := $(OBJ_LINK) $(CLIBS_OPTS) $(MAYBE_IDL)
  586
+  endif
  587
+else
  588
+  OBJS_LIBS := $(CLIBS_OPTS) $(MAYBE_IDL)
  589
+endif
  590
+
  591
+# If we have to make byte-code
  592
+ifndef REAL_OCAMLC
  593
+  BYTE_OCAML := y
  594
+
  595
+  # EXTRADEPS is added dependencies we have to insert for all
  596
+  # executable files we generate.  Ideally it should be all of the
  597
+  # libraries we use, but it's hard to find the ones that get searched on
  598
+  # the path since I don't know the paths built into the compiler, so
  599
+  # just include the ones with slashes in their names.
  600
+  EXTRADEPS := $(addsuffix .cma,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
  601
+  SPECIAL_OCAMLFLAGS := $(OCAMLBCFLAGS)
  602
+
  603
+  REAL_OCAMLC := $(INTF_OCAMLC)
  604
+
  605
+  REAL_IMPL := $(IMPL_CMO)
  606
+  REAL_IMPL_INTF := $(IMPLO_INTF)
  607
+  IMPL_SUF := .cmo
  608
+
  609
+  DEPFLAGS  :=
  610
+  MAKE_DEPS := $(MLDEPS) $(BCDEPIS)
  611
+
  612
+  ifdef CREATE_LIB
  613
+    override CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
  614
+    override CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
  615
+    ifndef STATIC
  616
+      ifneq ($(strip $(OBJ_LINK)),)
  617
+	MAKEDLL := $(DLLSONAME)
  618
+	ALL_LDFLAGS := -dllib $(DLLSONAME)
  619
+      endif
  620
+    endif
  621
+  endif
  622
+
  623
+  ifndef NO_CUSTOM
  624
+    ifneq "$(strip $(OBJ_LINK) $(THREADS) $(MAYBE_IDL) $(CLIBS) $(CFRAMEWORKS))" ""
  625
+      ALL_LDFLAGS += -custom
  626
+    endif
  627
+  endif
  628
+
  629
+  ALL_LDFLAGS += $(INCFLAGS) $(OCAMLLDFLAGS) $(OCAMLBLDFLAGS) \
  630
+                 $(COMMON_LDFLAGS) $(LIBS:%=%.cma)
  631
+  CAMLIDLDLLFLAGS :=
  632
+
  633
+  ifdef THREADS
  634
+    ifdef VMTHREADS
  635
+      THREAD_FLAG := -vmthread
  636
+    else
  637
+      THREAD_FLAG := -thread
  638
+    endif
  639
+    ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
  640
+    ifndef CREATE_LIB
  641
+      ifndef REAL_OCAMLFIND
  642
+        ALL_LDFLAGS := unix.cma threads.cma $(ALL_LDFLAGS)
  643
+      endif
  644
+    endif
  645
+  endif
  646
+
  647
+# we have to make native-code
  648
+else
  649
+  EXTRADEPS := $(addsuffix .cmxa,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
  650
+  ifndef PROFILING
  651
+    SPECIAL_OCAMLFLAGS := $(OCAMLNCFLAGS)
  652
+    PLDFLAGS :=
  653
+  else
  654
+    SPECIAL_OCAMLFLAGS := -p $(OCAMLNCFLAGS)
  655
+    PLDFLAGS := -p
  656
+  endif
  657
+
  658
+  REAL_IMPL := $(IMPL_CMX)
  659
+  REAL_IMPL_INTF := $(IMPLX_INTF)
  660
+  IMPL_SUF := .cmx
  661
+
  662
+  override CPPFLAGS := -DNATIVE_CODE $(CPPFLAGS)
  663
+
  664
+  DEPFLAGS  := -native
  665
+  MAKE_DEPS := $(MLDEPS) $(NCDEPIS)
  666
+
  667
+  ALL_LDFLAGS := $(PLDFLAGS) $(INCFLAGS) $(OCAMLLDFLAGS) \
  668
+                 $(OCAMLNLDFLAGS) $(COMMON_LDFLAGS)
  669
+  CAMLIDLDLLFLAGS := -opt
  670
+
  671
+  ifndef CREATE_LIB
  672
+    ALL_LDFLAGS += $(LIBS:%=%.cmxa)
  673
+  else
  674
+    override CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
  675
+    override CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
  676
+  endif
  677
+
  678
+  ifdef THREADS
  679
+    THREAD_FLAG := -thread
  680
+    ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
  681
+    ifndef CREATE_LIB
  682
+      ifndef REAL_OCAMLFIND
  683
+        ALL_LDFLAGS := unix.cmxa threads.cmxa $(ALL_LDFLAGS)
  684
+      endif
  685
+    endif
  686
+  endif
  687
+endif
  688
+
  689
+export MAKE_DEPS
  690
+
  691
+ifdef ANNOTATE
  692
+  ANNOT_FLAG := -dtypes
  693
+else
  694
+endif
  695
+
  696
+ALL_OCAMLCFLAGS := $(THREAD_FLAG) $(ANNOT_FLAG) $(OCAMLFLAGS) \
  697
+                   $(INCFLAGS) $(SPECIAL_OCAMLFLAGS)
  698
+
  699
+ifdef make_deps
  700
+  -include $(MAKE_DEPS)
  701
+  PRE_TARGETS :=
  702
+endif
  703
+
  704
+###########################################################################
  705
+# USER RULES
  706
+
  707
+# Call "OCamlMakefile QUIET=" to get rid of all of the @'s.
  708
+QUIET=@
  709
+
  710
+# generates byte-code (default)
  711
+byte-code:		$(PRE_TARGETS)
  712
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
  713
+				REAL_RESULT="$(BCRESULT)" make_deps=yes
  714
+bc:	byte-code
  715
+
  716
+byte-code-nolink:	$(PRE_TARGETS)
  717
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
  718
+				REAL_RESULT="$(BCRESULT)" make_deps=yes
  719
+bcnl:	byte-code-nolink
  720
+
  721
+top:			$(PRE_TARGETS)
  722
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(TOPRESULT) \
  723
+				REAL_RESULT="$(BCRESULT)" make_deps=yes
  724
+
  725
+# generates native-code
  726
+
  727
+native-code:		$(PRE_TARGETS)
  728
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
  729
+				REAL_RESULT="$(NCRESULT)" \
  730
+				REAL_OCAMLC="$(OCAMLOPT)" \
  731
+				make_deps=yes
  732
+nc:	native-code
  733
+
  734
+native-code-nolink:	$(PRE_TARGETS)
  735
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
  736
+				REAL_RESULT="$(NCRESULT)" \
  737
+				REAL_OCAMLC="$(OCAMLOPT)" \
  738
+				make_deps=yes
  739
+ncnl:	native-code-nolink
  740
+
  741
+# generates byte-code libraries
  742
+byte-code-library:	$(PRE_TARGETS)
  743
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
  744
+				$(RES_CLIB) $(BCRESULT).cma \
  745
+				REAL_RESULT="$(BCRESULT)" \
  746
+				CREATE_LIB=yes \
  747
+				make_deps=yes
  748
+bcl:	byte-code-library
  749
+
  750
+# generates native-code libraries
  751
+native-code-library:	$(PRE_TARGETS)
  752
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
  753
+				$(RES_CLIB) $(NCRESULT).cmxa \
  754
+				REAL_RESULT="$(NCRESULT)" \
  755
+				REAL_OCAMLC="$(OCAMLOPT)" \
  756
+				CREATE_LIB=yes \
  757
+				make_deps=yes
  758
+ncl:	native-code-library
  759
+
  760
+ifdef WIN32
  761
+# generates byte-code dll
  762
+byte-code-dll:		$(PRE_TARGETS)
  763
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
  764
+				$(RES_CLIB) $(BCRESULT).dll \
  765
+				REAL_RESULT="$(BCRESULT)" \
  766
+				make_deps=yes
  767
+bcd:	byte-code-dll
  768
+
  769
+# generates native-code dll
  770
+native-code-dll:	$(PRE_TARGETS)
  771
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
  772
+				$(RES_CLIB) $(NCRESULT).dll \
  773
+				REAL_RESULT="$(NCRESULT)" \
  774
+				REAL_OCAMLC="$(OCAMLOPT)" \
  775
+				make_deps=yes
  776
+ncd:	native-code-dll
  777
+endif
  778
+
  779
+# generates byte-code with debugging information
  780
+debug-code:		$(PRE_TARGETS)
  781
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
  782
+				REAL_RESULT="$(BCRESULT)" make_deps=yes \
  783
+				OCAMLFLAGS="-g $(OCAMLFLAGS)" \
  784
+				OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
  785
+dc:	debug-code
  786
+
  787
+debug-code-nolink:	$(PRE_TARGETS)
  788
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
  789
+				REAL_RESULT="$(BCRESULT)" make_deps=yes \
  790
+				OCAMLFLAGS="-g $(OCAMLFLAGS)" \
  791
+				OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
  792
+dcnl:	debug-code-nolink
  793
+
  794
+# generates byte-code libraries with debugging information
  795
+debug-code-library:	$(PRE_TARGETS)
  796
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
  797
+				$(RES_CLIB) $(BCRESULT).cma \
  798
+				REAL_RESULT="$(BCRESULT)" make_deps=yes \
  799
+				CREATE_LIB=yes \
  800
+				OCAMLFLAGS="-g $(OCAMLFLAGS)" \
  801
+				OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
  802
+dcl:	debug-code-library
  803
+
  804
+# generates byte-code for profiling
  805
+profiling-byte-code:		$(PRE_TARGETS)
  806
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
  807
+				REAL_RESULT="$(BCRESULT)" PROFILING="y" \
  808
+				make_deps=yes
  809
+pbc:	profiling-byte-code
  810
+
  811
+# generates native-code
  812
+
  813
+profiling-native-code:		$(PRE_TARGETS)
  814
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
  815
+				REAL_RESULT="$(NCRESULT)" \
  816
+				REAL_OCAMLC="$(OCAMLOPT)" \
  817
+				PROFILING="y" \
  818
+				make_deps=yes
  819
+pnc:	profiling-native-code
  820
+
  821
+# generates byte-code libraries
  822
+profiling-byte-code-library:	$(PRE_TARGETS)
  823
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
  824
+				$(RES_CLIB) $(BCRESULT).cma \
  825
+				REAL_RESULT="$(BCRESULT)" PROFILING="y" \
  826
+				CREATE_LIB=yes \
  827
+				make_deps=yes
  828
+pbcl:	profiling-byte-code-library
  829
+
  830
+# generates native-code libraries
  831
+profiling-native-code-library:	$(PRE_TARGETS)
  832
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
  833
+				$(RES_CLIB) $(NCRESULT).cmxa \
  834
+				REAL_RESULT="$(NCRESULT)" PROFILING="y" \
  835
+				REAL_OCAMLC="$(OCAMLOPT)" \
  836
+				CREATE_LIB=yes \
  837
+				make_deps=yes
  838
+pncl:	profiling-native-code-library
  839
+
  840
+# packs byte-code objects
  841
+pack-byte-code:			$(PRE_TARGETS)
  842
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT).cmo \
  843
+				REAL_RESULT="$(BCRESULT)" \
  844
+				PACK_LIB=yes make_deps=yes
  845
+pabc:	pack-byte-code
  846
+
  847
+# packs native-code objects
  848
+pack-native-code:		$(PRE_TARGETS)
  849
+			$(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
  850
+				$(NCRESULT).cmx $(NCRESULT).o \
  851
+				REAL_RESULT="$(NCRESULT)" \
  852
+				REAL_OCAMLC="$(OCAMLOPT)" \
  853
+				PACK_LIB=yes make_deps=yes
  854
+panc:	pack-native-code
  855
+
  856
+# generates HTML-documentation
  857
+htdoc:	$(DOC_DIR)/$(RESULT)/html/index.html
  858
+
  859
+# generates Latex-documentation
  860
+ladoc:	$(DOC_DIR)/$(RESULT)/latex/doc.tex
  861
+
  862
+# generates PostScript-documentation
  863
+psdoc:	$(DOC_DIR)/$(RESULT)/latex/doc.ps
  864
+
  865
+# generates PDF-documentation
  866
+pdfdoc:	$(DOC_DIR)/$(RESULT)/latex/doc.pdf
  867
+
  868
+# generates all supported forms of documentation
  869
+doc: htdoc ladoc psdoc pdfdoc
  870
+
  871
+###########################################################################
  872
+# LOW LEVEL RULES
  873
+
  874
+$(REAL_RESULT):		$(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS) $(RESULTDEPS)
  875
+			$(REAL_OCAMLFIND) $(REAL_OCAMLC) \
  876
+				$(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
  877
+				$(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
  878
+				$(REAL_IMPL)
  879
+
  880
+nolink:			$(REAL_IMPL_INTF) $(OBJ_LINK)
  881
+
  882
+ifdef WIN32
  883
+$(REAL_RESULT).dll:	$(REAL_IMPL_INTF) $(OBJ_LINK)
  884
+			$(CAMLIDLDLL) $(CAMLIDLDLLFLAGS) $(OBJ_LINK) $(CLIBS) \
  885
+				-o $@ $(REAL_IMPL)
  886
+endif
  887
+
  888
+%$(TOPSUFFIX):		$(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
  889
+			$(REAL_OCAMLFIND) $(OCAMLMKTOP) \
  890
+				$(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
  891
+				$(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
  892
+				$(REAL_IMPL)
  893
+
  894
+.SUFFIXES:		.mli .ml .cmi .cmo .cmx .cma .cmxa .$(EXT_OBJ) \
  895
+                        .mly .di .d .$(EXT_LIB) .idl %.oxridl .c .m .$(EXT_CXX) .h .so \
  896
+                        .rep .zog .glade
  897
+
  898
+ifndef STATIC
  899
+ifdef MINGW
  900
+$(DLLSONAME):		$(OBJ_LINK)
  901
+			$(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \
  902
+			-Wl,--whole-archive $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/lib%.a))) \
  903
+			 $(OCAMLLIBPATH)/ocamlrun.a \
  904
+			-Wl,--export-all-symbols \
  905
+			-Wl,--no-whole-archive
  906
+else
  907
+ifdef MSVC
  908
+$(DLLSONAME):		$(OBJ_LINK)
  909
+			link /NOLOGO /DLL /OUT:$@ $(OBJ_LINK) \
  910
+			 $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/%.lib))) \
  911
+			 $(OCAMLLIBPATH)/ocamlrun.lib
  912
+
  913
+else
  914
+$(DLLSONAME):		$(OBJ_LINK)
  915
+			$(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \
  916
+				-o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=-l%) $(CFRAMEWORKS:%=-framework %) \
  917
+				$(OCAMLMKLIB_FLAGS)
  918
+endif
  919
+endif
  920
+endif
  921
+
  922
+ifndef LIB_PACK_NAME
  923
+$(RESULT).cma:		$(REAL_IMPL_INTF) $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
  924
+			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(REAL_IMPL)
  925
+
  926
+$(RESULT).cmxa $(RESULT).$(EXT_LIB):	$(REAL_IMPL_INTF) $(EXTRADEPS) $(RESULTDEPS)
  927
+			$(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(REAL_IMPL)
  928
+else
  929
+ifdef BYTE_OCAML
  930
+$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo: $(REAL_IMPL_INTF)
  931
+			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmo $(OCAMLLDFLAGS) $(REAL_IMPL)
  932
+else
  933
+$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx: $(REAL_IMPL_INTF)
  934
+			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmx  $(OCAMLLDFLAGS) $(REAL_IMPL)
  935
+endif
  936
+
  937
+$(RESULT).cma:		$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
  938
+			$(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(LIB_PACK_NAME).cmo
  939
+
  940
+$(RESULT).cmxa $(RESULT).$(EXT_LIB):	$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx $(EXTRADEPS) $(RESULTDEPS)
  941
+			$(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(LIB_PACK_NAME).cmx
  942
+endif
  943
+
  944
+$(RES_CLIB): 		$(OBJ_LINK)
  945
+ifndef MSVC
  946
+  ifneq ($(strip $(OBJ_LINK)),)
  947
+		      $(AR) rcs $@ $(OBJ_LINK)
  948
+  endif
  949
+else
  950
+  ifneq ($(strip $(OBJ_LINK)),)
  951
+			lib -nologo -debugtype:cv -out:$(RES_CLIB) $(OBJ_LINK)
  952
+  endif
  953
+endif
  954
+
  955
+.mli.cmi: $(EXTRADEPS)
  956
+			$(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
  957
+			if [ -z "$$pp" ]; then \
  958
+			  $(ECHO) $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
  959
+				-c $(THREAD_FLAG) $(ANNOT_FLAG) \
  960
+				$(OCAMLFLAGS) $(INCFLAGS) $<; \
  961
+			  $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
  962
+				-c $(THREAD_FLAG) $(ANNOT_FLAG) \
  963
+				$(OCAMLFLAGS) $(INCFLAGS) $<; \
  964
+			else \
  965
+			    $(ECHO) $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
  966
+				-c -pp \"$$pp $(PPFLAGS)\" $(THREAD_FLAG) $(ANNOT_FLAG) \
  967
+				$(OCAMLFLAGS) $(INCFLAGS) $<; \
  968
+			    $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
  969
+				-c -pp "$$pp $(PPFLAGS)" $(THREAD_FLAG) $(ANNOT_FLAG) \
  970
+				$(OCAMLFLAGS) $(INCFLAGS) $<; \
  971
+			fi
  972
+
  973
+.ml.cmi .ml.$(EXT_OBJ) .ml.cmx .ml.cmo: $(EXTRADEPS)
  974
+			$(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
  975
+			if [ -z "$$pp" ]; then \
  976
+			  $(ECHO) $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
  977
+				-c $(ALL_OCAMLCFLAGS) $<; \
  978
+			  $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
  979
+				-c $(ALL_OCAMLCFLAGS) $<; \
  980
+			else \
  981
+			  $(ECHO) $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
  982
+				-c -pp \"$$pp $(PPFLAGS)\" $(ALL_OCAMLCFLAGS) $<; \
  983
+			  $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
  984
+				-c -pp "$$pp $(PPFLAGS)" $(ALL_OCAMLCFLAGS) $<; \