As documented in comments in rebar_port_compiler.erl, the list elements for port_specs
have an alternative form {ArchRegex, TargetFile, Sources}
. So write your Rebar configuration like this:
{port_specs, [{"linux", "priv/my_port", ["c_src/foo.c", "c_src/bar.c"]}]}.
"What is that regex matched against?", you might ask. It is matched against the return value of rebar_utils:get_arch, which consists of the following parts, separated by hyphens:
- The OTP release as returned by
erlang:system_info(otp_release)
, e.g. "R15B02"
- The system architecture as returned by
erlang:system_info(system_architecture)
. For Unix-like systems, this is the CPU-vendor-OS triplet determined by the configure script, e.g. "i386-apple-darwin10.8.0"
or "x86_64-unknown-linux-gnu"
.
- The emulator word size, 32 or 64, based on the return value of
erlang:system_info({wordsize, external})
.
- The OS family,
unix
or win32
. (The first element of the tuple returned by os:type/0
)
So the end result will be something like "R15B01-i386-apple-darwin10.8.0-32-unix"
or "R15B02-x86_64-unknown-linux-gnu-64-unix"
.