Example for enabled_if system in dune files

Sadly, currently the best course of action IMO is to read OCaml’s configure.ac and look the possible values for the system you are trying to match.

e.g. for linux that would be:

(enabled_if
 (or
  (= %{system} "linux")
  (= %{system} "linux_elf")
  (= %{system} "elf")
  (= %{system} "linux_eabihf")
  (= %{system} "linux_eabi")))

See Get the `system` variable to be consistent · Issue #10613 · ocaml/ocaml · GitHub for upstream issue. Given all this is legacy code (surprising to the main devs themselves I might add), I don’t think more possible values will get added in the future.

When this issue gets fixed – in dune (see The documentation/value of %{system} is not consistent · Issue #4895 · ocaml/dune · GitHub) and/or the compiler – at least one of these values will stil be around so this is safe to use in the long run I think.

2 Likes