Congratulations on the ClamAV® version 1.0.0 LTS stable release!
On May 8, 2002, the first version 0.10 of the open source antivirus engine ClamAV was released. Memorandum: How to build ClamAV® using the CMake Build System on macOS
How to build ClamAV® using the CMake Build System on macOS
Autotools build system has been dropped. I'm running the latest stable release ClamAV 1.0.1 LTS on macOS 13.2.1 Ventura now. The ClamAV 1.0.1 Stable Release is available on ClamAVNet Download page! The release notes are here. This memorandum describes how to build ClamAV using the CMake build system and includes the following: 1) Install CMake Build System 2) Install Rust toolchain 3) Install pkg-config 4) Install Libcheck/Check 5) Install PCRE2 Libraries 6) Install OpenSSL Libraries 6-1.When you use LibreSSL… 6-2.When you use OpenSSL… 7) Install JSON-C Libraries 8) Install Ninja Build System 9) Build ClamAV with CMake Build System 9-1.When you use LibreSSL… 9-2.When you use OpenSSL… 10) Build ClamAV with Ninja Build System 10-1.When you use LibreSSL… 10-2.When you use OpenSSL… 11) Links… Regarding the Autotools build system, see "How to install ClamAV® from the Git sources on macOS". 1) Install CMake CMake is an open-source, cross-platform family of tools designed to build, test and package software. 1. Download the latest CMake You can get CMake binary distribution for macOS. Download CMake.app and place it in the Applications directory. cd ~ curl -LO https://github.com/Kitware/CMake/releases/download/v3.26.1/cmake-3.26.1-macos-universal.tar.gz tar xzf cmake-3.26.1-macos-universal.tar.gz cp -r ~/cmake-3.26.1-macos-universal/CMake.app /Applications 2. For Command Line Use (to install symlinks to '/usr/local/bin') sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install 3. You can confirm the installation: which cmake /usr/local/bin/cmake cmake --version cmake version 3.26.1 Without using CMake.app you can build binary by yourself. 1. Download the latest CMake cd ~ curl -LO https://github.com/Kitware/CMake/releases/download/v3.26.1/cmake-3.26.1.tar.gz tar xzf cmake-3.26.1.tar.gz 2. Bootstrap CMake cd cmake-3.26.1 ./bootstrap --prefix=/usr/local/cmake 3. Compile and install CMake make && sudo make install 4. Set search path export PATH="/usr/local/cmake/bin:$PATH" 2) Install Rust toolchain 1. Download rustup and Install Rust toolchain curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 2. Set search path export PATH="$HOME/.cargo/bin:$PATH" 3. You can confirm the installation: rustup --version rustup 1.25.2 (fae52a197 2023-02-01) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: The currently active `rustc` version is `rustc 1.68.0 (2c8cc3432 2023-03-06)` rustc --version rustc 1.68.0 (2c8cc3432 2023-03-06) cargo --version cargo 1.68.0 (115f34552 2023-02-26) 4. You can maintain the toolchain by periodically executing: rustup update stable info: syncing channel updates for 'stable-x86_64-apple-darwin' info: latest update on 2023-03-09, rust version 1.68.0 (2c8cc3432 2023-03-06) info: downloading component 'cargo' info: downloading component 'clippy' info: downloading component 'rust-docs' 19.5 MiB / 19.5 MiB (100 %) 18.3 MiB/s in 1s ETA: 0s info: downloading component 'rust-std' 28.4 MiB / 28.4 MiB (100 %) 27.0 MiB/s in 1s ETA: 0s info: downloading component 'rustc' 57.1 MiB / 57.1 MiB (100 %) 25.5 MiB/s in 2s ETA: 0s info: downloading component 'rustfmt' info: removing previous version of component 'cargo' info: removing previous version of component 'clippy' info: removing previous version of component 'rust-docs' info: removing previous version of component 'rust-std' info: removing previous version of component 'rustc' info: removing previous version of component 'rustfmt' info: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' 19.5 MiB / 19.5 MiB (100 %) 6.2 MiB/s in 2s ETA: 0s info: installing component 'rust-std' 28.4 MiB / 28.4 MiB (100 %) 13.4 MiB/s in 2s ETA: 0s info: installing component 'rustc' 57.1 MiB / 57.1 MiB (100 %) 14.8 MiB/s in 3s ETA: 0s info: installing component 'rustfmt' stable-x86_64-apple-darwin updated - rustc 1.68.0 (2c8cc3432 2023-03-06) (from rustc 1.67.1 (d5a82bbd2 2023-02-07)) info: checking for self-updates 3) Install pkg-config 1. Download the latest pkg-config cd ~ curl -O https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz tar zxf pkg-config-0.29.2.tar.gz 2. Configure pkg-config cd pkg-config-0.29.2 export LDFLAGS="-framework CoreFoundation" ./configure --with-internal-glib --prefix=/usr/local/pkgconfig 3. Compile and install pkg-config make && make check sudo make install 4. Set search path export PATH="/usr/local/keyconfig/bin:$PATH" 4) Install Libcheck/Check 1. Download the latest Check cd ~ curl -LO https://github.com/libcheck/check/releases/download/0.15.2/check-0.15.2.tar.gz tar zxf check-0.15.2.tar.gz 2. Configure Check cd check-0.15.2 ./configure --prefix=/usr/local/check 3. Compile and install Check make && make check sudo make install export PATH="/usr/local/check/bin:$PATH" 5) Install PCRE2 Libraries 1. Download the latest PCRE2 cd ~ curl -LO https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.bz2 tar zxf pcre2-10.42.tar.bz2 2. Configure PCRE2 cd pcre2-10.42 ./configure --prefix=/usr/local/pcre2 3. Compile and install PCRE2 make && make check sudo make install 6) Install OpenSSL Libraries 6-1. When you use LibreSSL… 1. Download the latest LibreSSL cd ~ curl -LO https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.6.2.tar.gz tar zxf libressl-3.6.2.tar.gz 2. Configure LibreSSL cd libressl-3.6.2 ./configure --prefix=/usr/local/libressl 3. Compile and install LibreSSL make && make check sudo make install 4. Set search path export PATH="/usr/local/libressl/bin:$PATH" 5. You can confirm the installation: which openssl /usr/local/libressl/bin/openssl openssl version LibreSSL 3.6.2 6-2. When you use OpenSSL… 1. Download the latest OpenSSL cd ~ curl -LO https://www.openssl.org/source/openssl-3.1.0.tar.gz tar zxf openssl-3.1.0.tar.gz 2. Configure OpenSSL cd openssl-3.1.0 ./configure darwin64-x86_64-cc --prefix=/usr/local/openssl 3. Compile and install OpenSSL make && make test sudo make install 4. Set search path export PATH="/usr/local/openssl/bin:$PATH" 5. You can confirm the installation: which openssl /usr/local/openssl/bin/openssl openssl version OpenSSL 3.1.0 14 Mar 2023 (Library: OpenSSL 3.1.0 14 Mar 2023) 7) Install JSON-C Libraries JSON-C is a JSON implementation in C. 1. Download JSON-C cd ~ curl -LO https://s3.amazonaws.com/json-c_releases/releases/json-c-0.16.tar.gz tar xzf json-c-0.16.tar.gz 2. Configure and Generate JSON-C cd json-c-json-c-0.16 mkdir build cd build cmake -D CMAKE_INSTALL_PREFIX=/usr/local/json-c .. 3. Compile and install JSON-C make && make test sudo make install 4. Create Symbolic Link sudo ln -s /usr/local/json-c/lib/libjson-c.5.dylib /usr/local/lib/ 8) Install Ninja Build System Ninja is a small build system with a focus on speed. So this is an optional install. 1. Download Ninja cd ~ curl -LO https://github.com/ninja-build/ninja/archive/v1.11.1.tar.gz tar xzf v1.11.1.tar.gz 2. Configure and Generate Ninja cd ninja-1.11.1 mkdir build cd build cmake -D CMAKE_INSTALL_PREFIX=/usr/local/ninja/ .. 3. Compile and install Ninja make && make test sudo make install 4. Create Symbolic Link sudo ln -s /usr/local/ninja/bin/ninja /usr/local/bin/ 5. You can confirm the installation: which ninja /usr/local/bin/ninja ninja --version 1.11.1 9) Build ClamAV with CMake Build System 9-1. When you use LibreSSL… 1. Download the latest Release Candidate ClamAV 1.0.1 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.0.1.tar.gz tar zxf clamav-1.0.1.tar.gz 2. Set CMake options and library paths and Configure and Generate. cd clamav-1.0.1 mkdir build cd build cmake \ -D CMAKE_BUILD_TYPE=Release \ -D OPTIMIZE=ON \ -D BYTECODE_RUNTIME="interpreter" \ -D CMAKE_INSTALL_PREFIX=/usr/local/clamXav/ \ -D ENABLE_JSON_SHARED=OFF \ -D ENABLE_TESTS=ON \ -D LIBCHECK_ROOT_DIR=/usr/local/check \ -D LIBCHECK_INCLUDE_DIR=/usr/local/check/include/ \ -D LIBCHECK_LIBRARY=/usr/local/check/lib/libcheck.0.dylib \ -D OPENSSL_ROOT_DIR=/usr/local/libressl/ \ -D OPENSSL_CRYPTO_LIBRARY=/usr/local/libressl/lib/libcrypto.50.dylib \ -D OPENSSL_SSL_LIBRARY=/usr/local/libressl/lib/libssl.53.dylib \ -D PCRE2_LIBRARY=/usr/local/pcre2/lib/libpcre2-8.0.dylib \ -D PCRE2_INCLUDE_DIR=/usr/local/pcre2/include/ \ -D JSONC_LIBRARY=/usr/local/json-c/lib/libjson-c.5.dylib \ -D JSONC_INCLUDE_DIR=/usr/local/json-c/include/json-c/ \ .. 3. You get results as below: -- Configuring done -- Generating done -- Build files have been written to: /Users/xxx/clamav-1.0.1/build 4. Compile and make test; make && make test 5. You get results as below: Running tests... Test project /Users/xxx/Desktop/clamav-1.0.1/build Start 1: libclamav 1/6 Test #1: libclamav ........................ Passed 15.46 sec Start 2: libclamav_rust 2/6 Test #2: libclamav_rust ................... Passed 8.89 sec Start 3: clamscan 3/6 Test #3: clamscan ......................... Passed 0.13 sec Start 4: clamd 4/6 Test #4: clamd ............................ Passed 12.53 sec Start 5: freshclam 5/6 Test #5: freshclam ........................ Passed 27.33 sec Start 6: sigtool 6/6 Test #6: sigtool .......................... Passed 0.46 sec 100% tests passed, 0 tests failed out of 6 Total Test time (real) = 64.81 sec 6. Install ClamAV® sudo make install 9-2. When you use OpenSSL… 1. Download the latest Release Candidate ClamAV 1.0.1 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.0.1.tar.gz tar zxf clamav-1.0.1.tar.gz 2. Set CMake options and library paths and Configure and Generate. cd clamav-1.0.1 mkdir build cd build cmake \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_INSTALL_PREFIX=/usr/local/clamXav/ \ -D BYTECODE_RUNTIME="interpreter" \ -D OPTIMIZE=ON \ -D ENABLE_JSON_SHARED=OFF \ -D ENABLE_TESTS=ON \ -D LIBCHECK_ROOT_DIR=/usr/local/check \ -D LIBCHECK_INCLUDE_DIR=/usr/local/check/include/ \ -D LIBCHECK_LIBRARY=/usr/local/check/lib/libcheck.0.dylib \ -D OPENSSL_ROOT_DIR=/usr/local/openssl/ \ -D OPENSSL_CRYPTO_LIBRARY=/usr/local/openssl/lib/libcrypto.3.dylib \ -D OPENSSL_SSL_LIBRARY=/usr/local/openssl/lib/libssl.3.dylib \ -D PCRE2_LIBRARY=/usr/local/pcre2/lib/libpcre2-8.0.dylib \ -D PCRE2_INCLUDE_DIR=/usr/local/pcre2/include/ \ -D JSONC_LIBRARY=/usr/local/json-c/lib/libjson-c.5.dylib \ -D JSONC_INCLUDE_DIR=/usr/local/json-c/include/json-c/ \ .. 3. You get results as below: -- Configuring done -- Generating done -- Build files have been written to: /Users/xxx/clamav-1.0.1/build 4. Compile and install ClamAV® make && make test sudo make install 10) Build ClamAV with Ninja Build System 10-1. When you use LibreSSL… 1. Download the latest Release Candidate ClamAV 1.0.1 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.0.1.tar.gz 2. Set the build generator to Ninja, set Options and Library Paths, Configure and Generate cd clamav-1.0.1 mkdir build cd build cmake -G Ninja \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_INSTALL_PREFIX=/usr/local/clamXav/ \ -D ENABLE_JSON_SHARED=OFF \ -D BYTECODE_RUNTIME="interpreter" \ -D ENABLE_TESTS=ON \ -D LIBCHECK_ROOT_DIR=/usr/local/check \ -D LIBCHECK_INCLUDE_DIR=/usr/local/check/include/ \ -D LIBCHECK_LIBRARY=/usr/local/check/lib/libcheck.0.dylib \ -D OPENSSL_ROOT_DIR=/usr/local/libressl/ \ -D OPENSSL_CRYPTO_LIBRARY=/usr/local/libressl/lib/libcrypto.50.dylib \ -D OPENSSL_SSL_LIBRARY=/usr/local/libressl/lib/libssl.53.dylib \ -D PCRE2_LIBRARY=/usr/local/pcre2/lib/libpcre2-8.0.dylib \ -D PCRE2_INCLUDE_DIR=/usr/local/pcre2/include/ \ -D JSONC_LIBRARY=/usr/local/json-c/lib/libjson-c.5.dylib \ -D JSONC_INCLUDE_DIR=/usr/local/json-c/include/json-c/ \ .. 3. You get results as below: -- Configuring done -- Generating done -- Build files have been written to: /Users/xxx/clamav-1.0.1/build 4. Compile and make test ninja && ninja test 5. You get results as below: Running tests... Test project /Users/xxx/clamav-1.0.1/build Start 1: libclamav 1/6 Test #1: libclamav ........................ Passed 10.27 sec Start 2: libclamav_rust 2/6 Test #2: libclamav_rust ................... Passed 69.69 sec Start 3: clamscan 3/6 Test #3: clamscan ......................... Passed 3.70 sec Start 4: clamd 4/6 Test #4: clamd ............................ Passed 11.37 sec Start 5: freshclam 5/6 Test #5: freshclam ........................ Passed 32.46 sec Start 6: sigtool 6/6 Test #6: sigtool .......................... Passed 0.24 sec 100% tests passed, 0 tests failed out of 6 6. Install ClamAV® sudo ninja install 10-2. When you use OpenSSL… 1. Download the latest Release Candidate ClamAV 1.0.1 from ClamAVNet. cd ~ curl -LO https://www.clamav.net/downloads/production/clamav-1.0.1.tar.gz 2. Set the build generator to Ninja, set Options and Library Paths, Configure and Generate cd clamav-1.0.1 mkdir build cd build cmake -G Ninja \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_INSTALL_PREFIX=/usr/local/clamXav/ \ -D ENABLE_JSON_SHARED=OFF \ -D BYTECODE_RUNTIME="interpreter" \ -D ENABLE_TESTS=ON \ -D LIBCHECK_ROOT_DIR=/usr/local/check \ -D LIBCHECK_INCLUDE_DIR=/usr/local/check/include/ \ -D LIBCHECK_LIBRARY=/usr/local/check/lib/libcheck.0.dylib \ -D OPENSSL_ROOT_DIR=/usr/local/openssl/ \ -D OPENSSL_CRYPTO_LIBRARY=/usr/local/openssl/lib/libcrypto.3.dylib \ -D OPENSSL_SSL_LIBRARY=/usr/local/openssl/lib/libssl.3.dylib \ -D PCRE2_LIBRARY=/usr/local/pcre2/lib/libpcre2-8.0.dylib \ -D PCRE2_INCLUDE_DIR=/usr/local/pcre2/include/ \ -D JSONC_LIBRARY=/usr/local/json-c/lib/libjson-c.5.dylib \ -D JSONC_INCLUDE_DIR=/usr/local/json-c/include/json-c/ \ .. 3. You get results as below: -- Configuring done -- Generating done -- Build files have been written to: /Users/xxx/clamav-1.0.1/build 4. Compile and install ClamAV® ninja && ninja test sudo ninja install
|