Search code examples
buildocamlopam

Detecting target architecture in OPAM build


When writing an OPAM package configuration file, I can specify the target platform in the build field, like so:

build: [
  ["./configure" "build-linux" {os = "linux"}
                 "build-macosx" {os = "darwin"}
                 "build-cygwin" {os = "cygwin"}]
]

Is there a way to do the same for target architecture, e.g. ["./configure" "build-linux-x64" {os = "linux" && arch = "x86_64"}]? TIA.


Solution

  • You can find the list of variables using ocaml config list. It shows that the variable you are after is indeed arch:

    % opam config var arch
    x86_64
    

    So, yes, you can do that. But note that the syntax will be os = "linux" & arch = "x86_64".