~ubuntu-branches/ubuntu/vivid/menhir/vivid

« back to all changes in this revision

Viewing changes to demos/OMakefile.shared

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2006-07-11 12:26:18 UTC
  • Revision ID: james.westby@ubuntu.com-20060711122618-dea56bmjs3qlmsd8
Tags: upstream-20060615.dfsg
Import upstream version 20060615.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##########################################################################
 
2
#                                                                        #
 
3
#  Menhir                                                                #
 
4
#                                                                        #
 
5
#  Fran�ois Pottier and Yann R�gis-Gianas, INRIA Rocquencourt            #
 
6
#                                                                        #
 
7
#  Copyright 2005 Institut National de Recherche en Informatique et      #
 
8
#  en Automatique. All rights reserved. This file is distributed         #
 
9
#  under the terms of the Q Public License version 1.0, with the         #
 
10
#  change described in file LICENSE.                                     #
 
11
#                                                                        #
 
12
##########################################################################
 
13
 
 
14
# This OMakefile is designed for projects that use Objective Caml,
 
15
# ocamllex, menhir, and alphaCaml.
 
16
 
 
17
# This OMakefile is meant to be included within a host OMakefile
 
18
# that defines the following variables:
 
19
#
 
20
# GENERATED    :  a list of the source (.ml and .mli) files
 
21
#                 that are generated (by invoking ocamllex
 
22
#                 or menhir)
 
23
#
 
24
# MODULES      :  a list of the modules (without extension)
 
25
#                 that should be linked into the executable
 
26
#                 program. Order is significant.
 
27
#
 
28
# EXECUTABLE   :  the base name of the executables that should
 
29
#                 be produced. Suffixes $(BSUFFIX) and $(OSUFFIX)
 
30
#                 will be added to distinguish the bytecode and
 
31
#                 native code versions.
 
32
 
 
33
# -------------------------------------------------------------------------
 
34
 
 
35
# The host OMakefile can override the following default settings.
 
36
 
 
37
# Include directives for compilation and for linking.
 
38
 
 
39
if $(not $(defined INCLUDE))
 
40
    INCLUDE          =
 
41
    export
 
42
 
 
43
# Bytecode compilation flags.
 
44
 
 
45
if $(not $(defined BFLAGS))
 
46
    BFLAGS           = -dtypes -g
 
47
    export
 
48
 
 
49
# Native code compilation flags.
 
50
 
 
51
if $(not $(defined OFLAGS))
 
52
    OFLAGS           = -dtypes
 
53
    export
 
54
 
 
55
# Bytecode link-time flags.
 
56
 
 
57
if $(not $(defined BLNKFLAGS))
 
58
    BLNKFLAGS        = -g
 
59
    export
 
60
 
 
61
# Native code link-time flags.
 
62
 
 
63
if $(not $(defined OLNKFLAGS))
 
64
    OLNKFLAGS        =
 
65
    export
 
66
 
 
67
# Lexer generation flags.
 
68
 
 
69
if $(not $(defined LGFLAGS))
 
70
    LGFLAGS          = 
 
71
    export
 
72
 
 
73
# Parser generation flags.
 
74
 
 
75
if $(not $(defined PGFLAGS))
 
76
    PGFLAGS          = --infer -v
 
77
    export
 
78
 
 
79
# Suffix appended to the name of the bytecode executable.
 
80
 
 
81
if $(not $(defined BSUFFIX))
 
82
    BSUFFIX          = .byte
 
83
    export
 
84
 
 
85
# Suffix appended to the name of the native code executable.
 
86
 
 
87
if $(not $(defined OSUFFIX))
 
88
    OSUFFIX          =
 
89
    export
 
90
 
 
91
# Access paths for the tools.
 
92
 
 
93
if $(not $(defined OCAML))
 
94
    OCAML            = ocaml
 
95
    export
 
96
 
 
97
if $(not $(defined OCAMLC))
 
98
    if $(which ocamlfind)
 
99
        OCAMLC       = ocamlfind ocamlc
 
100
        export
 
101
    elseif $(which ocamlc.opt)
 
102
        OCAMLC       = ocamlc.opt
 
103
        export
 
104
    else
 
105
        OCAMLC       = ocamlc
 
106
        export
 
107
    export
 
108
 
 
109
if $(not $(defined OCAMLOPT))
 
110
    if $(which ocamlfind)
 
111
        OCAMLOPT     = ocamlfind ocamlopt
 
112
        export
 
113
    elseif $(which ocamlopt.opt)
 
114
        OCAMLOPT     = ocamlopt.opt
 
115
        export
 
116
    else
 
117
        OCAMLOPT     = ocamlopt
 
118
        export
 
119
    export
 
120
 
 
121
if $(not $(defined OCAMLDEP))
 
122
    if $(which ocamlfind)
 
123
        OCAMLDEP     = ocamlfind ocamldep
 
124
        export
 
125
    elseif $(which ocamldep.opt)
 
126
        OCAMLDEP     = ocamldep.opt
 
127
        export
 
128
    else
 
129
        OCAMLDEP     = ocamldep
 
130
        export
 
131
    export
 
132
 
 
133
if $(not $(defined OCAMLDEPWRAPPER))
 
134
    OCAMLDEPWRAPPER  = ./ocamldep.wrapper
 
135
    export
 
136
 
 
137
if $(not $(defined OCAMLLEX))
 
138
    OCAMLLEX         = ocamllex
 
139
    export
 
140
 
 
141
if $(not $(defined MENHIR))
 
142
    MENHIR           = menhir
 
143
    export
 
144
 
 
145
if $(not $(defined ALPHACAML))
 
146
    ALPHACAML        = alphaCaml
 
147
    export
 
148
 
 
149
# ----------------------------------------------------------------
 
150
 
 
151
# Define an ocamldep wrapper that creates fake generated files so that
 
152
# ocamldep can see that these files exist (or are supposed to exist).
 
153
# This is required to work around ocamldep's brokenness.
 
154
 
 
155
WrapScanner(command) =
 
156
    $(OCAML) $(OCAMLDEPWRAPPER) $(GENERATED) - $(command)
 
157
 
 
158
# ----------------------------------------------------------------
 
159
 
 
160
# Dependencies.
 
161
 
 
162
.SCANNER: %.cmi: %.mli
 
163
        WrapScanner($(OCAMLDEP) $<)
 
164
 
 
165
.SCANNER: %.cmx %.cmo %.o: %.ml
 
166
        WrapScanner($(OCAMLDEP) $<)
 
167
 
 
168
# ----------------------------------------------------------------
 
169
 
 
170
# Compilation.
 
171
 
 
172
%.cmi: %.mli
 
173
        $(OCAMLC) $(INCLUDE) $(BFLAGS) -c $<
 
174
 
 
175
%.cmo: %.ml
 
176
        $(OCAMLC) $(INCLUDE) $(BFLAGS) -c $<
 
177
 
 
178
%.cmx %.o: %.ml
 
179
        $(OCAMLOPT) $(INCLUDE) $(OFLAGS) -c $<
 
180
 
 
181
%.ml: %.mll
 
182
        $(OCAMLLEX) $(LGFLAGS) $<
 
183
 
 
184
%.ml %.mli: %.mla
 
185
        $(ALPHACAML) $<
 
186
 
 
187
# ----------------------------------------------------------------
 
188
 
 
189
# Linking.
 
190
 
 
191
$(EXECUTABLE)$(OSUFFIX): $(addsuffix .cmx, $(MODULES))
 
192
        $(OCAMLOPT) -o $@ $(INCLUDE) $(OLNKFLAGS) $+
 
193
 
 
194
$(EXECUTABLE)$(BSUFFIX): $(addsuffix .cmo, $(MODULES))
 
195
        $(OCAMLC) -o $@ $(INCLUDE) $(BLNKFLAGS) $+
 
196
 
 
197
# ----------------------------------------------------------------
 
198
 
 
199
# Menhir: multiple file projects.
 
200
 
 
201
MenhirMulti(target, sources, options) =
 
202
    TARGETS   = $(file $(target).ml $(target).mli)
 
203
    SOURCES   = $(file $(sources))
 
204
    $(TARGETS): $(SOURCES)
 
205
        $(MENHIR) --ocamlc "$(OCAMLC)" $(PGFLAGS) --base $(target) $(options) $(SOURCES)
 
206
    .SCANNER: $(TARGETS): $(SOURCES)
 
207
        WrapScanner($(MENHIR) --ocamldep "$(OCAMLDEP)" --depend --base $(target) $(options) $(SOURCES))
 
208
 
 
209
# Menhir: single file projects.
 
210
 
 
211
MenhirMono(target, options) =
 
212
    MenhirMulti($(target), $(target).mly, $(options))
 
213
 
 
214
# Menhir: automatic single file projects.
 
215
# This causes every .mly file to be viewed as a single file project.
 
216
 
 
217
MenhirAuto() =
 
218
    foreach (target, $(glob *.mly))
 
219
        MenhirMono($(removesuffix $(target)), $(EMPTY))
 
220
 
 
221
# ----------------------------------------------------------------
 
222
 
 
223
.PHONY: clean
 
224
 
 
225
clean:
 
226
    /bin/rm -f $(EXECUTABLE)$(BSUFFIX) $(EXECUTABLE)$(OSUFFIX) $(GENERATED)
 
227
    /bin/rm -f *.cmi *.cmx *.cmo *.o *~ .*~ *.automaton *.conflicts *.annot