Pass custom CFLAGS while building ocaml

If I understand ocaml’s configure file (I’m looking at >= 4.09.1), I can run ./configure CFLAGS=$MYFLAGS to configure ocaml with custom CFLAGS. However I am not running the configure by hand, but as part of a opam init/opam switch create process.

My understanding is that I could patch ocaml’s opam file with my new flags, but I didn’t find in the doc how to access environment variables from a opam file.
In the past (4.07.1) we were patching the configure file directly, but it seems things have changed since then.

Is it the right path to follow or are there other solutions ?


As far as I know currently CFLAGS and LDFLAGS are not properly taken into account by ./configure. See, where you can also find information about some workarounds.


Thank you for the link. I’m still struggling with it but it is very helpful :slight_smile: