[Omake] Changing OCAMLPACKS in a section fails

Aleksey Nogin nogin at metaprl.org
Wed Feb 14 16:37:03 PST 2007


On 14.02.2007 12:55, Renald Buter wrote:

> NATIVE_ENABLED = true
> USE_OCAMLFIND = true
> 
> section
> 	PROGRAM = main_target
> 	FILES = main_target
> 	OCAMLPACKS = str
> 	.DEFAULT: $(OCamlProgram $(PROGRAM), $(FILES))
> 
> section
> 	PROGRAM = main_target_test
> 	FILES = main_target main_target_test
> 	OCAMLPACKS = oUnit
> 	.DEFAULT: $(OCamlProgram $(PROGRAM), $(FILES))
> ---
> 
> - build lines-grouper main_target_test.cmx
> + ocamlfind ocamlopt -warn-error A -I . -c main_target_test.ml
> File "main_target_test.ml", line 1, characters 0-10:
> Unbound module OUnit

Ah, I see.

Note that OCamlProgram only specifies the _linking_ step, not the 
compilation step (it has to be that way, otherwise we'd end with 
incompatible specifications where in the above example the compilation 
of main_target would be specified to both use and not use oUnit).

By default, the compilation for OCaml files is done via implicit rules 
and, again by default, implicit rules are instantiated using the values 
at the _end_ of the corresponding OMakefile (more precisely - at the end 
of the corresponding .SUBDIRS body).

If you want to force instantiation of implicit rules for a target to be 
"pinned" to a specific variable scope, you need to specify an empty 
dependency for it. E.g:

section
	PROGRAM = main_target_test
	FILES = main_target main_target_test
	OCAMLPACKS = oUnit
         $(addprefix main_target_test, .cmx .cmi $(EXT_OBJ)):
	.DEFAULT: $(OCamlProgram $(PROGRAM), $(FILES))


More information about the Omake mailing list