[erlang-questions] Building a C port

Tim Watson watson.timothy@REDACTED
Sat Oct 15 04:29:22 CEST 2011


>
>
> > Could I use rebar instead?
>
> Yes, you might be able to use rebar for doing this, but rebar integration
> with C/C++ port/port_driver/nif is both minimal and ad-hoc.  So, you won't
> have something flexible like autotools where you can use macros to add extra
> checking, if you need it.  Rebar integration should work for a simple case
> where you don't case as much about where the various executables are coming
> from and where the output files are going.
>
>
In my experience, rebar support for building ports is neither minimal nor
ad-hoc. Rebar fully supports overriding where the inputs, dependencies and
outputs should be, as well as allowing you to override CC and LDFLAGS plus
half a dozen other variables. I'll be the first to admit that it's got a way
to go in terms of Windows support, but on most other platforms, you can
configure it not only with custom build parameters but also with OS, arch
and type specific flags. I have cross platform rebar builds that do very
nicely on several Linux distros, FreeBSD and OS-X with very minimal config.
Take a look at the rebar.example.config to get a feel for it. Obviously
rebar isn't going to provide everything autotools does, but for a simple
port/driver you should be ok.

If you need to do minor custom stuff in your builds, you can always write a
rebar plugin. It'll load these from source so you don't have to package them
up or included them in your production code, and they're pure Erlang so you
can do whatever you like. It isn't going to replace autotools, but for
simple ports/drivers rebar will often suffice.

I hadn't considered compiling rebar as part of my build process before, but
it's something I might start thinking about for future projects, so thanks
for pointing that out Michael.

Cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111015/379ba7a5/attachment.htm>


More information about the erlang-questions mailing list