Compiling Suricata from source on macOS

I just went through Suricata compilation on MacOS (26.6.2), and I thought I could capture the process, in here for now.

Install build dependencies

Install the required build tools and libraries using Homebrew:

brew install \
    autoconf automake libtool pkgconf \
    rust cbindgen \
    jansson libpcap pcre2 libyaml zlib

You may/may not want to install Rust/cbindgen through Homebrew. The alternative is to use rustup.

Cloning the repositories

Assuming the repositories for both Suricata and Suricata-verify are checked out next to each other:

.
β”œβ”€β”€ suricata
└── suricata-verify

Enter suricata folder.

Install build dependencies

Install the required build tools and libraries using Homebrew:

./autogen.sh
./configure \
    --with-libjansson-includes="$(brew --prefix jansson)/include" \
    --with-libjansson-libraries="$(brew --prefix jansson)/lib" \
    --with-libyaml-includes="$(brew --prefix libyaml)/include" \
    --with-libyaml-libraries="$(brew --prefix libyaml)/lib" \
    --with-libpcre2-includes="$(brew --prefix pcre2)/include" \
    --with-libpcre2-libraries="$(brew --prefix pcre2)/lib"

After a successful configure, Suricata can be compiled using all available logical CPU cores:

make -j$(sysctl -n hw.logicalcpu)

The compiled Suricata binary will be in ./src/suricata

Running suricata-verify

If you also want to run the `suricata-verify` test suite, install the Python YAML dependency:

python3 -m pip install PyYAML

you can run the tests from inside the Suricata source directory with:

python3 ../suricata-verify/run.py -q -j$(sysctl -n hw.logicalcpu)

One-step full build and test command

For a fresh Git checkout of both Suricata and Suricata-verify, the complete sequence is:

./autogen.sh && \
./configure \
--with-libjansson-includes="$(brew --prefix jansson)/include" \
--with-libjansson-libraries="$(brew --prefix jansson)/lib" \
--with-libyaml-includes="$(brew --prefix libyaml)/include" \
--with-libyaml-libraries="$(brew --prefix libyaml)/lib" \
--with-libpcre2-includes="$(brew --prefix pcre2)/include" \
--with-libpcre2-libraries="$(brew --prefix pcre2)/lib" && \
make -j$(sysctl -n hw.logicalcpu) && \
python3 ../suricata-verify/run.py -q -j$(sysctl -n hw.logicalcpu)

This will:

1. Generate the build system with `autogen.sh`.

2. Configure Suricata using the Homebrew library locations.

3. Compile Suricata.

4. Run the complete `suricata-verify` test suite.

1 Like