This PR includes many commits related to fixing and improving compilation with newer Rebar3, Erlang and Elixir.
The commit messages should be clear enough. Here I provide a general explanation of the major changes, hopefully ready for inclusion in the release notes:
Summary of compilation methods
When compiling ejabberd from source code, you may have noticed there are a lot of possibilities. Let's take an overview before digging in the new improvements:
Tools to manage the dependencies and compilation:
Rebar: it is nowadays very obsolete, but still does the job of compiling ejabberd
Rebar3: the successor of Rebar, with many improvements and plugins, supports hex.pm and elixir compilation
container images are built using: mix + make prod too, and started with ejabberdctl foreground
Several combinations didn't work correctly until now and have been fixed, for example:
mix + make relive
mix + make prod/dev + ejabberdctl iexlive
mix + make install + ejabberdctl start/foregorund/live
any method + make uninstall
rebar + make prod with Erlang 26
Use Mix or Rebar3 by default instead of Rebar to compile ejabberd
ejabberd uses Rebar to manage dependencies and compilation since ejabberd 13.10 4d8f7706240a1603468968f47fc7b150b788d62f. However, that tool is obsolete and unmaintained since years ago, because there is a complete replacement:
Rebar3 is supported by ejabberd since 20.12 0fc1aea379924b6f83f274f173d0bbd163cae1c2. Among other benefits, this allows to download dependencies from hex.pm and cache them in your system instead of downloading them from git every time, and allows to compile Elixir files and Elixir dependencies.
In fact, ejabberd can be compiled using mix (a tool included with the Elixir programming language) since ejabberd 15.04 ea8db9967fbfe53f581c3ae721657d9e6f919864 (with improvements in ejabberd 21.07 4c5641a6489d0669b4220b5ac759a4e1271af3b5)
For those reasons, the tool selection performed by ./configure will now be:
Use the program specified in option: --with-rebar=/path/to/bin
If none is specified, use the system mix
If Elixir not found, use the system rebar3
If Rebar3 not found, use the rebar3 binary included with ejabberd
Removed Elixir support in Rebar
Support for Elixir 1.1 was added as a dependency in ejabberd 15.02 01e1f677c72b923251f7021bc024319ff129d42d. This allowed to compile Elixir files. But since Elixir 1.4.5 (released Jun 22, 2017) it isn't possible to get Elixir as a dependency... it's nowadays a standalone program. For that reason, support to download old Elixir 1.4.4 as a dependency has been removed.
When Elixir support is required, better simply install Elixir and use mix as build tool:
./configure --with-rebar=mix
Or install Elixir and use the experimental Rebar3 support to compile Elixir files and dependencies:
./configure --with-rebar=rebar3 --enable-elixir
Added Elixir support in Rebar3
It is now possible to compile ejabberd using Rebar3 and support Elixir compilation. This compiles the Elixir files included in ejabberd's lib/ path. There's also support to get dependencies written in Elixir, and it's possible to build OTP releases including Elixir support.
It is necessary to have Elixir installed in the system, and configure the compilation using --enable-elixir. For example:
apt-get install erlang erlang-dev elixir
git clone https://github.com/processone/ejabberd.git ejabberd
cd ejabberd
./autogen.sh
./configure --with-rebar=rebar3 --enable-elixir
make
make dev
_build/dev/rel/ejabberd/bin/ejabberdctl iexlive
Elixir 1.10.3 or higher is required to build an OTP release with make prod or make dev
Elixir 1.11.4 or higher is required to build an OTP release if using Erlang/OTP 24 or higher
Elixir 1.11.0 or higher is required to use make relive
Elixir 1.13.4 with Erlang/OTP 23.0 are the lowest versions tested by Runtime
For all those reasons, if you want to use Elixir, it is highly recommended to use Elixir 1.13.4 or higher with Erlang/OTP 23.0 or higher.
Rebar and Rebar3 binaries updated
The ejabberd source code includes the rebar and rebar3 binaries, and you can use them to compile ejabberd in case they are not installed in your operating system. Those binaries have been updated to support Erlang/OTP from version 23 up to 26.
If you are using Erlang 22.3 or older, you can download the old binaries from ejabberd 21.12, available at:
When ejabberd started to use Rebar2 build tool, that tool could create an OTP release, and the target in Makefile.in was conveniently named make rel.
However, newer tools like Rebar3 and Elixir's Mix support creating different types of releases: production, development, ... In this sense, our make rel target is nowadays more properly named make prod.
For backwards compatibility, make rel redirects to make prod.
New make install-rel and make uninstall-rel
This is an alternative method to install ejabberd in the system, based in the OTP release process. It should produce exactly the same results than the existing make install.
The benefits of make install-rel over the existing method:
this uses OTP release code from rebar/rebar3/mix, and consequently requires less code in our Makefile.in
make uninstall-rel correctly deletes all the library files
This is still experimental, and it would be great if you are able to test it and report any problem; eventually this method could replace the existing one.
Just for curiosity:
ejabberd 13.03-beta1 got support for make uninstallwas added
coverage: 32.567% (-0.003%) from 32.57%
when pulling b4b85e569e14d674531199b8c6497105b18c4772 on badlop:elixir-all-in
into 29ec5bff606da07b03cc3c7a9d5f963008996474 on processone:master.
This PR includes many commits related to fixing and improving compilation with newer Rebar3, Erlang and Elixir.
The commit messages should be clear enough. Here I provide a general explanation of the major changes, hopefully ready for inclusion in the release notes:
Summary of compilation methods
When compiling ejabberd from source code, you may have noticed there are a lot of possibilities. Let's take an overview before digging in the new improvements:
Tools to manage the dependencies and compilation:
Installation methods:
make install
: copies the files to the systemmake prod
: prepares a self-contained OTP production release in_build/prod/
, and generates atar.gz
file. This was previously namedmake rel
make dev
: prepares quickly an OTP development release in_build/dev/
make relive
: prepares the barely minimum in_build/relive/
to run ejabberd and starts itStart scripts and alternatives:
ejabberdctl
with erlang shell:start
/foreground
/live
ejabberdctl
with elixir shell:iexlive
ejabberd
console
/start
(this script is generated by rebar3 or mix, and does not support ejabberdctl configurable options)For example:
CI
dynamic tests userebar3
, andRuntime
tries to test all the possible combinationsmix + make prod
mix + make prod
too, and started withejabberdctl foreground
Several combinations didn't work correctly until now and have been fixed, for example:
mix + make relive
mix + make prod/dev + ejabberdctl iexlive
mix + make install + ejabberdctl start/foregorund/live
any method + make uninstall
rebar + make prod
with Erlang 26Use Mix or Rebar3 by default instead of Rebar to compile ejabberd
ejabberd uses Rebar to manage dependencies and compilation since ejabberd 13.10 4d8f7706240a1603468968f47fc7b150b788d62f. However, that tool is obsolete and unmaintained since years ago, because there is a complete replacement:
Rebar3 is supported by ejabberd since 20.12 0fc1aea379924b6f83f274f173d0bbd163cae1c2. Among other benefits, this allows to download dependencies from hex.pm and cache them in your system instead of downloading them from git every time, and allows to compile Elixir files and Elixir dependencies.
In fact, ejabberd can be compiled using
mix
(a tool included with the Elixir programming language) since ejabberd 15.04 ea8db9967fbfe53f581c3ae721657d9e6f919864 (with improvements in ejabberd 21.07 4c5641a6489d0669b4220b5ac759a4e1271af3b5)For those reasons, the tool selection performed by
./configure
will now be:--with-rebar=/path/to/bin
mix
rebar3
rebar3
binary included with ejabberdRemoved Elixir support in Rebar
Support for Elixir 1.1 was added as a dependency in ejabberd 15.02 01e1f677c72b923251f7021bc024319ff129d42d. This allowed to compile Elixir files. But since Elixir 1.4.5 (released Jun 22, 2017) it isn't possible to get Elixir as a dependency... it's nowadays a standalone program. For that reason, support to download old Elixir 1.4.4 as a dependency has been removed.
When Elixir support is required, better simply install Elixir and use
mix
as build tool:Or install Elixir and use the experimental Rebar3 support to compile Elixir files and dependencies:
Added Elixir support in Rebar3
It is now possible to compile ejabberd using Rebar3 and support Elixir compilation. This compiles the Elixir files included in ejabberd's
lib/
path. There's also support to get dependencies written in Elixir, and it's possible to build OTP releases including Elixir support.It is necessary to have Elixir installed in the system, and configure the compilation using
--enable-elixir
. For example:Elixir versions supported
Elixir 1.10.3 is the minimum supported, but:
make prod
ormake dev
make relive
Runtime
For all those reasons, if you want to use Elixir, it is highly recommended to use Elixir 1.13.4 or higher with Erlang/OTP 23.0 or higher.
Rebar and Rebar3 binaries updated
The ejabberd source code includes the
rebar
andrebar3
binaries, and you can use them to compile ejabberd in case they are not installed in your operating system. Those binaries have been updated to support Erlang/OTP from version 23 up to 26.If you are using Erlang 22.3 or older, you can download the old binaries from ejabberd 21.12, available at:
make rel
is renamed tomake prod
When ejabberd started to use Rebar2 build tool, that tool could create an OTP release, and the target in
Makefile.in
was conveniently namedmake rel
.However, newer tools like Rebar3 and Elixir's Mix support creating different types of releases: production, development, ... In this sense, our
make rel
target is nowadays more properly namedmake prod
.For backwards compatibility,
make rel
redirects tomake prod
.New
make install-rel
andmake uninstall-rel
This is an alternative method to install ejabberd in the system, based in the OTP release process. It should produce exactly the same results than the existing
make install
.The benefits of
make install-rel
over the existing method:Makefile.in
make uninstall-rel
correctly deletes all the library filesThis is still experimental, and it would be great if you are able to test it and report any problem; eventually this method could replace the existing one.
Just for curiosity:
make uninstall
was addedmake uninstall