[Omake] How to build camlp4 extension?

Dmitry Bely dmitry.bely at gmail.com
Tue Nov 28 06:07:31 PST 2006


I have an Ocaml project where both native and bytecode executables are build:

BYTE_ENABLED = true
NATIVE_ENABLED = true

To compile .ml files I need some custom camlp4 syntax extension
pa_ba.cmo, so I have:

OCAMLPPFLAGS = -pp "camlp4o -I . pa_ba.cmo"
OCAMLDEPFLAGS += $(OCAMLPPFLAGS)

MLFILES = ...
LIB = ...
OCamlLibrary($(LIB), $(MLFILES))

etc. But how to build the syntax extension itself? I tried the following:

section
    BYTE_ENABLED = true
    NATIVE_ENABLED = false
    OCAMLFLAGS = -I +camlp4
    OCAMLPPFLAGS = -pp "camlp4o pa_extend.cmo q_MLast.cmo"
    OCAMLDEPFLAGS = $(OCAMLPPFLAGS)
    pa_ba.cmo: pa_ba.ml

.DEFAULT: pa_ba.cmo

This does not work:

*** omake:
   These file are targeted separately, but appear as effects of a single rule.
   This is likely to lead to unpredictable behavior.
   targets:
      debug\Core\pa_ba.obj
      debug\Core\pa_ba.cmo
[...]
- build debug\Core pa_ba.obj
+ ocamlc.opt -warn-error A -g -pp "camlp4o -I . pa_ba.cmo" -I . -c pa_ba.ml
<W> Grammar extension: in [expr], some rule has been masked
File "pa_ba.ml", line 6, characters 8-15:
Unbound quotation: "expr"
Uncaught exception: Pcaml.Qerror("expr", 0, _)
Preprocessor error

Do you know how to correctly write a rule to make pa_ba.cmo from pa_ba.ml?

- Dmitry Bely


More information about the Omake mailing list