Memorandum: How to install ClamAV® from the Git sources on macOS

How to install ClamAV from the Git sources on macOS

Autotools (Automake, Autoconf, M4, pkg-config, Libtool) are now required in order to build ClamAV from the Git sources, because the files generated by these tools have been removed from the Git repository.
By yourself you have to generate a pakage of files (configure, configure.ac, Makefile.in, Makefile.am, …) for running ./configure.
Install Autotools and run ./autogen.sh, thus you can get necessary files to run ./configure.
Besides that, PCRE Libraries and OpenSSL Libraries are required to compile ClamAV.

Autotools build system has been dropped in the dev/0.104 branch - "Autotools build system dropped".
Instead of Autotools (eg: ./configure && make && sudo make install), CMake is required to build ClamAV.

For further information, see the following section:
"How to build ClamAV® with CMake Build System on macOS".


This memorandum contains as below:
1) Install Automake
2) Install Autoconf
3) Install M4
4) Install pkgconfig
5) Install Libtool
6) Install PCRE Libraries
7) Install OpenSSL Libraries
8) Now you can build ClamAV from the Git sources
9) Links…



1) Install Automake

1. Download the latest Automake
cd ~
curl -O http://ftp.gnu.org/gnu/automake/automake-1.16.tar.gz
tar zxf automake-1.16.tar.gz

2. Configure Automake
cd automake-1.16
./configure --prefix=/usr/local/automake

3. Compile and install Automake
make && make check
sudo make install

4. Create a symbolic link
sudo ln -s /usr/local/automake/bin/aclocal /usr/local/bin/
sudo ln -s /usr/local/automake/bin/aclocal-1.16 /usr/local/bin/
sudo ln -s /usr/local/automake/bin/automake /usr/local/bin/
sudo ln -s /usr/local/automake/bin/automake-1.16 /usr/local/bin/




2) Install Autoconf

1. Download the latest Autoconf
cd ~
curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar zxf autoconf-2.69.tar.gz

2. Configure autoconf
cd autoconf-2.69
./configure --prefix=/usr/local/autoconf

3. Compile and install autoconf
make && make check
sudo make install

4. Create a symbolic link
sudo ln -s /usr/local/autoconf/bin/autoconf /usr/local/bin/
sudo ln -s /usr/local/autoconf/bin/autoheader /usr/local/bin/
sudo ln -s /usr/local/autoconf/bin/autom4te /usr/local/bin/
sudo ln -s /usr/local/autoconf/bin/autoreconf /usr/local/bin/
sudo ln -s /usr/local/autoconf/bin/autoscan /usr/local/bin/
sudo ln -s /usr/local/autoconf/bin/autoupdate /usr/local/bin/
sudo ln -s /usr/local/autoconf/bin/ifnames /usr/local/bin/




3) Install M4

1. M4 is already installed with Command Line Tools.

2. You can confirm the installation of M4:
which m4
/usr/bin/m4

m4 --version
GNU M4 1.4.6
Copyright (C) 2006 Free Software Foundation, Inc.




4) 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  --prefix=/usr/local/pkgconfig --with-internal-glib

3. Compile and install pkg-config
make && make check
sudo make install

4. Set search path
export PATH="/usr/local/keyconfig/bin:$PATH"




5) Install Libtool

1. Download the latest Libtool
cd ~
curl -O ftp://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz
tar zxf libtool-2.4.6.tar.gz

2. Configure Libtool
cd libtool-2.4.6
./configure --prefix=/usr/local/libtool

3. Compile and install Libtool
make && make check
sudo make install

4. Create a symbolic link
sudo ln -s /usr/local/libtool/bin/glibtool /usr/local/bin/
sudo ln -s /usr/local/libtool/bin/glibtoolize /usr/local/bin/
sudo ln -s /usr/local/libtool/bin/libtool /usr/local/bin/
sudo ln -s /usr/local/libtool/bin/libtoolize /usr/local/bin/

sudo ln -s /usr/local/libtool/include/libltdl /usr/local/include/
sudo ln -s /usr/local/libtool/include/ltdl.h /usr/local/include/

sudo ln -s /usr/local/libtool/lib/libltdl.7.dylib /usr/local/lib/
sudo ln -s /usr/local/libtool/lib/libltdl.a /usr/local/lib/
sudo ln -s /usr/local/libtool/lib/libltdl.dylib /usr/local/lib/
sudo ln -s /usr/local/libtool/lib/libltdl.la /usr/local/lib/

sudo ln -s /usr/local/libtool/share/aclocal/libtool.m4 /usr/local/share/aclocal/
sudo ln -s /usr/local/libtool/share/aclocal/lt~obsolete.m4 /usr/local/share/aclocal/
sudo ln -s /usr/local/libtool/share/aclocal/ltargz.m4 /usr/local/share/aclocal/
sudo ln -s /usr/local/libtool/share/aclocal/ltdl.m4 /usr/local/share/aclocal/
sudo ln -s /usr/local/libtool/share/aclocal/ltoptions.m4 /usr/local/share/aclocal/
sudo ln -s /usr/local/libtool/share/aclocal/ltsugar.m4 /usr/local/share/aclocal/
sudo ln -s /usr/local/libtool/share/aclocal/ltversion.m4 /usr/local/share/aclocal/




6) Install PCRE Libraries

1. Download the latest PCRE2
cd ~
curl -O https://ftp.pcre.org/pub/pcre/pcre2-10.37.tar.gz
tar zxf pcre2-10.37.tar.gz

2. Configure PCRE2
cd pcre2-10.37
./configure --prefix=/usr/local/pcre2

3. Compile and install PCRE2
make && sudo make install




7) Install OpenSSL Libraries

1. Download the latest Libressl
cd ~
curl -O https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.4.3.tar.gz
tar zxf libressl-3.4.3.tar.gz

2. Configure Libressl
cd libressl-3.4.3
./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.4.3




8) Now you can build ClamAV from the Git sources

1. Set environment variables before building ClamAV.
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export ACLOCAL_PATH="/usr/local/share/aclocal:$ACLOCAL_PATH"

2. Download the latest sources from the GIT repository
cd ~
curl -LO https://github.com/Cisco-Talos/clamav/archive/refs/heads/dev/0.103.3.zip
unzip 0.103.3.zip

3. Run ./autogen.sh
cd clamav-dev-0.103.3
./autogen.sh

4. Verify that running ./autogen.sh ends up with the results as follows:
You can now run ./configure

5. Run ./configure
export CFLAGS="-O3"
export CXXFLAGS="-O3"
export CPPFLAGS="-I/usr/local/pcre2/include -I/usr/local/libressl/include"
./configure --prefix=/usr/local/clamXav --build=x86_64-apple-darwin`uname -r`\
--with-pcre=/usr/local/pcre2 --with-openssl=/usr/local/libressl --enable-llvm=no

6. Compile and install ClamAV®
make && make check
sudo make install

7. That's all…
    Building ClamAV® from the release tarball should be unaffected.
    For further information to build ClamAV on macOS, refer to:
    "Building ClamAV® on Mac OS X 10.4 through macOS 11.0 Big Sur".


Links…

mail