Cross compile mosquitto using zig build (tested with ziglang 0.15.1).
- produce static executables
- support for TLS (with an option to disable it if it is not needed)
- bridge enabled
- no websocket support
- no systemd support (e.g. SDNotify isn't enabled)
Note
The mosquitto source code is downloaded automatically using the ziglang build system. You can manually download the source code yourself by downloading the url defined in the corresponding the build.zig.zon.
-
Clone the project
git clone https://github.com/thin-edge/zig-mosquitto cd zig-mosquitto -
Build all targets
just build-all
Or specify the
VERSIONenvironment variable.VERSION=2.0.22 just build-all
If you don't want to include TLS, then you can run:
just build-notls-all
-
Use the build linux packages under the
dist/folderls -l build/{VERSION}/dist/ # Using DNF (Fedora, RHEL, AmazonLinux) dnf install tedge-mosquitto*.rpm # Using Debian/Ubuntu apt-get install tedge-mosquitto*.deb
If you don't want to build for all of the targets, then you can build using
The compiled mosquitto binary will be created under ./zig-out/mosquitto, however it will only be the binary from the last build.
With TLS
just build x86_64-linux-musl amd64
just build aarch64-linux-musl arm64
just build arm-linux-musleabihf arm7
just build arm-linux-musleabi arm5
just build riscv64-linux-musl riscv64Without TLS
just build-notls x86_64-linux-musl amd64
just build-notls aarch64-linux-musl arm64
just build-notls arm-linux-musleabihf arm7
just build-notls arm-linux-musleabi arm5
just build-notls riscv64-linux-musl riscv64The following items are still yet to be addressed/fixed:
- Support for other init systems like OpenRC, SysVInit, s6-overlay