clamav/docs/CMakeLists.txt

121 lines
3.7 KiB
Text
Raw Normal View History

GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
# Generate documentation (man pages, doxygen, etc.)
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
if(ENABLE_MAN_PAGES)
#
# man pages
#
# .1 files
configure_file(man/clamscan.1.in man/clamscan.1)
configure_file(man/freshclam.1.in man/freshclam.1)
configure_file(man/sigtool.1.in man/sigtool.1)
configure_file(man/clamdscan.1.in man/clamdscan.1)
configure_file(man/clamconf.1.in man/clamconf.1)
configure_file(man/clamdtop.1.in man/clamdtop.1)
configure_file(man/clamsubmit.1.in man/clamsubmit.1)
configure_file(man/clambc.1.in man/clambc.1)
# .5 files
configure_file(man/clamd.conf.5.in man/clamd.conf.5)
configure_file(man/clamav-milter.conf.5.in man/clamav-milter.conf.5)
configure_file(man/freshclam.conf.5.in man/freshclam.conf.5)
# .8 files
configure_file(man/clamd.8.in man/clamd.8)
configure_file(man/clamav-milter.8.in man/clamav-milter.8)
if(C_LINUX)
configure_file(man/clamonacc.8.in man/clamonacc.8)
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
endif()
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
set(MAN1_FILES
man/clamscan.1
man/freshclam.1
man/sigtool.1
man/clamdscan.1
man/clamconf.1
man/clamdtop.1
man/clamsubmit.1
man/clambc.1)
foreach(m IN LISTS MAN1_FILES)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${m}
DESTINATION
CMake: Support to build deb, rpm, & macOS pkg packages CMake/CPack is already used to build: - TGZ source tarball - WiX-based installer (Windows) - ZIP install packages (Windows) This commit adds support for building: - macOS PKG installer - DEB package - RPM package This should also enable building FreeBSD packages, but while I was able to build all of the static dependencies using Mussels, CMake/CPack 3.20 doesn't appear to have the the FreeBSD generator despite being in the documentation. The package names are will be in this format: clamav-<version><suffix>.<os>.<arch>.<extension> This includes changing the Windows .zip and .msi installer names. E.g.: - clamav-0.104.0-rc.macos.x86_64.pkg - clamav-0.104.0-rc.win.win32.msi - clamav-0.104.0-rc.win.win32.zip - clamav-0.104.0-rc.win.x64.msi - clamav-0.104.0-rc.linux.x86_64.deb - clamav-0.104.0-rc.linux.x86_64.rpm Notes about building the packages: I've only tested this with building ClamAV using static dependencies that I build using the clamav_deps "host-static" recipes from the "clamav" Mussels cookbook. Eg: msl build clamav_deps -t host-static Here's an example configuration to build clam in this way, installing to /usr/local/clamav: ```sh cmake .. \ -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \ -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \ -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D ENABLE_EXAMPLES=OFF \ -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \ -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \ -D ENABLE_JSON_SHARED=OFF \ -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \ -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \ -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \ -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \ -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \ -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \ -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \ -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \ -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \ -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a" ``` Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's install location. This can be different than the install prefix. E.g.: ```sh -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \ ``` Then `make` and then one of these, depending on the platform: ```sh cpack # macOS: productbuild is default cpack -G DEB # Debian-based cpack -G RPM # RPM-based ``` On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can be converted to html so it will render in the installer. On RPM-based systems, you'll need rpmbuild (install rpm-build) This commit also fixes an issue where the html manual (if present) was not correctly added to the Windows (or now other) install packages. Fix num to hex function for Windows installer guid Fix win32 cpack build Fix macOS cpack build
2021-07-27 14:28:13 -07:00
${CMAKE_INSTALL_MANDIR}/man1
COMPONENT documentation)
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
endforeach()
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
set(MAN5_FILES
man/clamd.conf.5
man/clamav-milter.conf.5
man/freshclam.conf.5)
foreach(m IN LISTS MAN5_FILES)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${m}
DESTINATION
CMake: Support to build deb, rpm, & macOS pkg packages CMake/CPack is already used to build: - TGZ source tarball - WiX-based installer (Windows) - ZIP install packages (Windows) This commit adds support for building: - macOS PKG installer - DEB package - RPM package This should also enable building FreeBSD packages, but while I was able to build all of the static dependencies using Mussels, CMake/CPack 3.20 doesn't appear to have the the FreeBSD generator despite being in the documentation. The package names are will be in this format: clamav-<version><suffix>.<os>.<arch>.<extension> This includes changing the Windows .zip and .msi installer names. E.g.: - clamav-0.104.0-rc.macos.x86_64.pkg - clamav-0.104.0-rc.win.win32.msi - clamav-0.104.0-rc.win.win32.zip - clamav-0.104.0-rc.win.x64.msi - clamav-0.104.0-rc.linux.x86_64.deb - clamav-0.104.0-rc.linux.x86_64.rpm Notes about building the packages: I've only tested this with building ClamAV using static dependencies that I build using the clamav_deps "host-static" recipes from the "clamav" Mussels cookbook. Eg: msl build clamav_deps -t host-static Here's an example configuration to build clam in this way, installing to /usr/local/clamav: ```sh cmake .. \ -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \ -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \ -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D ENABLE_EXAMPLES=OFF \ -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \ -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \ -D ENABLE_JSON_SHARED=OFF \ -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \ -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \ -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \ -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \ -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \ -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \ -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \ -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \ -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \ -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a" ``` Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's install location. This can be different than the install prefix. E.g.: ```sh -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \ ``` Then `make` and then one of these, depending on the platform: ```sh cpack # macOS: productbuild is default cpack -G DEB # Debian-based cpack -G RPM # RPM-based ``` On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can be converted to html so it will render in the installer. On RPM-based systems, you'll need rpmbuild (install rpm-build) This commit also fixes an issue where the html manual (if present) was not correctly added to the Windows (or now other) install packages. Fix num to hex function for Windows installer guid Fix win32 cpack build Fix macOS cpack build
2021-07-27 14:28:13 -07:00
${CMAKE_INSTALL_MANDIR}/man5
COMPONENT documentation)
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
endforeach()
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
set(MAN8_FILES
man/clamd.8
man/clamav-milter.8)
foreach(m IN LISTS MAN8_FILES)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${m}
DESTINATION
CMake: Support to build deb, rpm, & macOS pkg packages CMake/CPack is already used to build: - TGZ source tarball - WiX-based installer (Windows) - ZIP install packages (Windows) This commit adds support for building: - macOS PKG installer - DEB package - RPM package This should also enable building FreeBSD packages, but while I was able to build all of the static dependencies using Mussels, CMake/CPack 3.20 doesn't appear to have the the FreeBSD generator despite being in the documentation. The package names are will be in this format: clamav-<version><suffix>.<os>.<arch>.<extension> This includes changing the Windows .zip and .msi installer names. E.g.: - clamav-0.104.0-rc.macos.x86_64.pkg - clamav-0.104.0-rc.win.win32.msi - clamav-0.104.0-rc.win.win32.zip - clamav-0.104.0-rc.win.x64.msi - clamav-0.104.0-rc.linux.x86_64.deb - clamav-0.104.0-rc.linux.x86_64.rpm Notes about building the packages: I've only tested this with building ClamAV using static dependencies that I build using the clamav_deps "host-static" recipes from the "clamav" Mussels cookbook. Eg: msl build clamav_deps -t host-static Here's an example configuration to build clam in this way, installing to /usr/local/clamav: ```sh cmake .. \ -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \ -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \ -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D ENABLE_EXAMPLES=OFF \ -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \ -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \ -D ENABLE_JSON_SHARED=OFF \ -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \ -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \ -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \ -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \ -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \ -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \ -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \ -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \ -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \ -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a" ``` Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's install location. This can be different than the install prefix. E.g.: ```sh -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \ ``` Then `make` and then one of these, depending on the platform: ```sh cpack # macOS: productbuild is default cpack -G DEB # Debian-based cpack -G RPM # RPM-based ``` On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can be converted to html so it will render in the installer. On RPM-based systems, you'll need rpmbuild (install rpm-build) This commit also fixes an issue where the html manual (if present) was not correctly added to the Windows (or now other) install packages. Fix num to hex function for Windows installer guid Fix win32 cpack build Fix macOS cpack build
2021-07-27 14:28:13 -07:00
${CMAKE_INSTALL_MANDIR}/man8
COMPONENT documentation)
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
endforeach()
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
if(C_LINUX)
# Also install Linux-only manpage
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/man/clamonacc.8
DESTINATION
CMake: Support to build deb, rpm, & macOS pkg packages CMake/CPack is already used to build: - TGZ source tarball - WiX-based installer (Windows) - ZIP install packages (Windows) This commit adds support for building: - macOS PKG installer - DEB package - RPM package This should also enable building FreeBSD packages, but while I was able to build all of the static dependencies using Mussels, CMake/CPack 3.20 doesn't appear to have the the FreeBSD generator despite being in the documentation. The package names are will be in this format: clamav-<version><suffix>.<os>.<arch>.<extension> This includes changing the Windows .zip and .msi installer names. E.g.: - clamav-0.104.0-rc.macos.x86_64.pkg - clamav-0.104.0-rc.win.win32.msi - clamav-0.104.0-rc.win.win32.zip - clamav-0.104.0-rc.win.x64.msi - clamav-0.104.0-rc.linux.x86_64.deb - clamav-0.104.0-rc.linux.x86_64.rpm Notes about building the packages: I've only tested this with building ClamAV using static dependencies that I build using the clamav_deps "host-static" recipes from the "clamav" Mussels cookbook. Eg: msl build clamav_deps -t host-static Here's an example configuration to build clam in this way, installing to /usr/local/clamav: ```sh cmake .. \ -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \ -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \ -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D ENABLE_EXAMPLES=OFF \ -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \ -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \ -D ENABLE_JSON_SHARED=OFF \ -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \ -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \ -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \ -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \ -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \ -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \ -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \ -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \ -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \ -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a" ``` Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's install location. This can be different than the install prefix. E.g.: ```sh -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \ ``` Then `make` and then one of these, depending on the platform: ```sh cpack # macOS: productbuild is default cpack -G DEB # Debian-based cpack -G RPM # RPM-based ``` On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can be converted to html so it will render in the installer. On RPM-based systems, you'll need rpmbuild (install rpm-build) This commit also fixes an issue where the html manual (if present) was not correctly added to the Windows (or now other) install packages. Fix num to hex function for Windows installer guid Fix win32 cpack build Fix macOS cpack build
2021-07-27 14:28:13 -07:00
${CMAKE_INSTALL_MANDIR}/man8
COMPONENT documentation)
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
endif()
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
endif()
if(ENABLE_DOXYGEN)
#
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
# clamav.h and libfreshclam.h doxygen docs
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
#
find_package(Doxygen REQUIRED)
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_GENERATE_MAN NO)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(EXTRACT_ALL YES)
set(HIDE_UNDOC_MEMBERS YES)
set(JAVADOC_AUTOBRIEF YES)
set(OPTIMIZE_OUTPUT_FOR_C YES)
set(FULL_PATH_NAMES NO)
set(GENERATE_LATEX NO)
doxygen_add_docs(doxygen
${CMAKE_SOURCE_DIR}/libclamav/clamav.h
${CMAKE_SOURCE_DIR}/libfreshclam/libfreshclam.h
GitHub Actions testing on Ubuntu, Mac, & Windows Updates to fix issues in the CMake install instructions. Updates the README.md to indicate that CMake is now preferred Adds a GitHub Actions badge, Discord badge, and logo to the README.md. CMake: - Renamed ENABLE_DOCS to ENABLE_MAN_PAGES. - Fixed build issue when milter isn't enabled on Linux. Changed the default to build milter on non-macOS, non-Windows operating systems. - Fix LD_LIBRARY_PATH for tests including on macOS where LD_LIBRARY_PATH and DYLD_LIBRARY_PATH must be manually propagated to subprocesses. - Use UNKNOWN IMPORTED library instead of INTERFACE IMPORTED library for pdcurses, but still use INTERFACE IMPORTED for ncurses. UNKNOWN IMPORTED appears to be required so that we can use $<TARGET_FILE_DIR:Curses::curses> to collected the pdcurses library at install time on Windows. - When building with vcpkg on Windows, CMake will automatically install your app local dependencies (aka the DLL runtime dependencies). Meanwhile, file(GET_RUNTIME_DEPENDENCIES ...) doesn't appear to work correctly with vcpkg packages. The solution is to use a custom target that has CMake perform a local install to the unit_tests directory when using vcpkg. This is in fact far easier than using GET_RUNTIME_DEPENDENCIES in the unit_tests for assembling the test environment but we can't use this method for the non-vcpkg install because it won't collect checkDynamic.dll for us because we don't install our tests. We also can't link with the static check.lib because the static check.lib has pthreads symbols linked in and will conflict with our pthread.dll. TL;DR: We'll continue to use file(GET_RUNTIME_DEPENDENCIES ...) for assembling the test enviornment on non-vcpkg builds, and use the local install method for vcpkg builds. testcase.py: Wrapped a Pathlib.unlink() call in exception handling as the missing_ok optional parameter requires a Python version too new for common use. Remove localtime_r from win32 compat lib. localtime_r may be present in libcheck when building with vcpkg and while making it a static function would also solve the issue, using localtime_s instead like we do everywhere else should work just fine. check_clamd: Limited the max # of connections for the stress test on Mac to 850, to address issues found testing on macos-latest on GitHub Actions.
2020-11-18 21:19:27 -08:00
COMMENT "Generate html documentation")
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${CMAKE_INSTALL_DOCDIR}
CMake: Support to build deb, rpm, & macOS pkg packages CMake/CPack is already used to build: - TGZ source tarball - WiX-based installer (Windows) - ZIP install packages (Windows) This commit adds support for building: - macOS PKG installer - DEB package - RPM package This should also enable building FreeBSD packages, but while I was able to build all of the static dependencies using Mussels, CMake/CPack 3.20 doesn't appear to have the the FreeBSD generator despite being in the documentation. The package names are will be in this format: clamav-<version><suffix>.<os>.<arch>.<extension> This includes changing the Windows .zip and .msi installer names. E.g.: - clamav-0.104.0-rc.macos.x86_64.pkg - clamav-0.104.0-rc.win.win32.msi - clamav-0.104.0-rc.win.win32.zip - clamav-0.104.0-rc.win.x64.msi - clamav-0.104.0-rc.linux.x86_64.deb - clamav-0.104.0-rc.linux.x86_64.rpm Notes about building the packages: I've only tested this with building ClamAV using static dependencies that I build using the clamav_deps "host-static" recipes from the "clamav" Mussels cookbook. Eg: msl build clamav_deps -t host-static Here's an example configuration to build clam in this way, installing to /usr/local/clamav: ```sh cmake .. \ -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \ -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \ -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D ENABLE_EXAMPLES=OFF \ -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \ -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \ -D ENABLE_JSON_SHARED=OFF \ -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \ -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \ -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \ -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \ -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \ -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \ -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \ -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \ -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \ -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a" ``` Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's install location. This can be different than the install prefix. E.g.: ```sh -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \ ``` Then `make` and then one of these, depending on the platform: ```sh cpack # macOS: productbuild is default cpack -G DEB # Debian-based cpack -G RPM # RPM-based ``` On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can be converted to html so it will render in the installer. On RPM-based systems, you'll need rpmbuild (install rpm-build) This commit also fixes an issue where the html manual (if present) was not correctly added to the Windows (or now other) install packages. Fix num to hex function for Windows installer guid Fix win32 cpack build Fix macOS cpack build
2021-07-27 14:28:13 -07:00
COMPONENT documentation OPTIONAL)
Add CMake build tooling This patch adds experimental-quality CMake build tooling. The libmspack build required a modification to use "" instead of <> for header #includes. This will hopefully be included in the libmspack upstream project when adding CMake build tooling to libmspack. Removed use of libltdl when using CMake. Flex & Bison are now required to build. If -DMAINTAINER_MODE, then GPERF is also required, though it currently doesn't actually do anything. TODO! I found that the autotools build system was generating the lexer output but not actually compiling it, instead using previously generated (and manually renamed) lexer c source. As a consequence, changes to the .l and .y files weren't making it into the build. To resolve this, I removed generated flex/bison files and fixed the tooling to use the freshly generated files. Flex and bison are now required build tools. On Windows, this adds a dependency on the winflexbison package, which can be obtained using Chocolatey or may be manually installed. CMake tooling only has partial support for building with external LLVM library, and no support for the internal LLVM (to be removed in the future). I.e. The CMake build currently only supports the bytecode interpreter. Many files used include paths relative to the top source directory or relative to the current project, rather than relative to each build target. Modern CMake support requires including internal dependency headers the same way you would external dependency headers (albeit with "" instead of <>). This meant correcting all header includes to be relative to the build targets and not relative to the workspace. For example, ... ```c include "../libclamav/clamav.h" include "clamd/clamd_others.h" ``` ... becomes: ```c // libclamav include "clamav.h" // clamd include "clamd_others.h" ``` Fixes header name conflicts by renaming a few of the files. Converted the "shared" code into a static library, which depends on libclamav. The ironically named "shared" static library provides features common to the ClamAV apps which are not required in libclamav itself and are not intended for use by downstream projects. This change was required for correct modern CMake practices but was also required to use the automake "subdir-objects" option. This eliminates warnings when running autoreconf which, in the next version of autoconf & automake are likely to break the build. libclamav used to build in multiple stages where an earlier stage is a static library containing utils required by the "shared" code. Linking clamdscan and clamdtop with this libclamav utils static lib allowed these two apps to function without libclamav. While this is nice in theory, the practical gains are minimal and it complicates the build system. As such, the autotools and CMake tooling was simplified for improved maintainability and this feature was thrown out. clamdtop and clamdscan now require libclamav to function. Removed the nopthreads version of the autotools libclamav_internal_utils static library and added pthread linking to a couple apps that may have issues building on some platforms without it, with the intention of removing needless complexity from the source. Kept the regular version of libclamav_internal_utils.la though it is no longer used anywhere but in libclamav. Added an experimental doxygen build option which attempts to build clamav.h and libfreshclam doxygen html docs. The CMake build tooling also may build the example program(s), which isn't a feature in the Autotools build system. Changed C standard to C90+ due to inline linking issues with socket.h when linking libfreshclam.so on Linux. Generate common.rc for win32. Fix tabs/spaces in shared Makefile.am, and remove vestigial ifndef from misc.c. Add CMake files to the automake dist, so users can try the new CMake tooling w/out having to build from a git clone. clamonacc changes: - Renamed FANOTIFY macro to HAVE_SYS_FANOTIFY_H to better match other similar macros. - Added a new clamav-clamonacc.service systemd unit file, based on the work of ChadDevOps & Aaron Brighton. - Added missing clamonacc man page. Updates to clamdscan man page, add missing options. Remove vestigial CL_NOLIBCLAMAV definitions (all apps now use libclamav). Rename Windows mspack.dll to libmspack.dll so all ClamAV-built libraries have the lib-prefix with Visual Studio as with CMake.
2020-08-13 00:25:34 -07:00
endif()
CMake: Support to build deb, rpm, & macOS pkg packages CMake/CPack is already used to build: - TGZ source tarball - WiX-based installer (Windows) - ZIP install packages (Windows) This commit adds support for building: - macOS PKG installer - DEB package - RPM package This should also enable building FreeBSD packages, but while I was able to build all of the static dependencies using Mussels, CMake/CPack 3.20 doesn't appear to have the the FreeBSD generator despite being in the documentation. The package names are will be in this format: clamav-<version><suffix>.<os>.<arch>.<extension> This includes changing the Windows .zip and .msi installer names. E.g.: - clamav-0.104.0-rc.macos.x86_64.pkg - clamav-0.104.0-rc.win.win32.msi - clamav-0.104.0-rc.win.win32.zip - clamav-0.104.0-rc.win.x64.msi - clamav-0.104.0-rc.linux.x86_64.deb - clamav-0.104.0-rc.linux.x86_64.rpm Notes about building the packages: I've only tested this with building ClamAV using static dependencies that I build using the clamav_deps "host-static" recipes from the "clamav" Mussels cookbook. Eg: msl build clamav_deps -t host-static Here's an example configuration to build clam in this way, installing to /usr/local/clamav: ```sh cmake .. \ -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \ -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \ -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D ENABLE_EXAMPLES=OFF \ -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \ -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \ -D ENABLE_JSON_SHARED=OFF \ -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \ -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \ -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \ -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \ -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \ -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \ -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \ -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \ -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \ -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a" ``` Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's install location. This can be different than the install prefix. E.g.: ```sh -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \ ``` Then `make` and then one of these, depending on the platform: ```sh cpack # macOS: productbuild is default cpack -G DEB # Debian-based cpack -G RPM # RPM-based ``` On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can be converted to html so it will render in the installer. On RPM-based systems, you'll need rpmbuild (install rpm-build) This commit also fixes an issue where the html manual (if present) was not correctly added to the Windows (or now other) install packages. Fix num to hex function for Windows installer guid Fix win32 cpack build Fix macOS cpack build
2021-07-27 14:28:13 -07:00
# When built from the release tarball, this includes the user manual
# which is exported from the clamav-faq repo.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/html/index.html)
if(WIN32)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/html/
DESTINATION ./UserManual
CMake: Support to build deb, rpm, & macOS pkg packages CMake/CPack is already used to build: - TGZ source tarball - WiX-based installer (Windows) - ZIP install packages (Windows) This commit adds support for building: - macOS PKG installer - DEB package - RPM package This should also enable building FreeBSD packages, but while I was able to build all of the static dependencies using Mussels, CMake/CPack 3.20 doesn't appear to have the the FreeBSD generator despite being in the documentation. The package names are will be in this format: clamav-<version><suffix>.<os>.<arch>.<extension> This includes changing the Windows .zip and .msi installer names. E.g.: - clamav-0.104.0-rc.macos.x86_64.pkg - clamav-0.104.0-rc.win.win32.msi - clamav-0.104.0-rc.win.win32.zip - clamav-0.104.0-rc.win.x64.msi - clamav-0.104.0-rc.linux.x86_64.deb - clamav-0.104.0-rc.linux.x86_64.rpm Notes about building the packages: I've only tested this with building ClamAV using static dependencies that I build using the clamav_deps "host-static" recipes from the "clamav" Mussels cookbook. Eg: msl build clamav_deps -t host-static Here's an example configuration to build clam in this way, installing to /usr/local/clamav: ```sh cmake .. \ -D CMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE \ -D CMAKE_PREFIX_PATH=$HOME/.mussels/install/host-static \ -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CMAKE_MODULE_PATH=$HOME/.mussels/install/host-static/lib/cmake \ -D CMAKE_BUILD_TYPE=RelWithDebInfo \ -D ENABLE_EXAMPLES=OFF \ -D JSONC_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/json-c" \ -D JSONC_LIBRARY="$HOME/.mussels/install/host-static/lib/libjson-c.a" \ -D ENABLE_JSON_SHARED=OFF \ -D BZIP2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D BZIP2_LIBRARY_RELEASE="$HOME/.mussels/install/host-static/lib/libbz2_static.a" \ -D OPENSSL_ROOT_DIR="$HOME/.mussels/install/host-static" \ -D OPENSSL_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D OPENSSL_CRYPTO_LIBRARY="$HOME/.mussels/install/host-static/lib/libcrypto.a" \ -D OPENSSL_SSL_LIBRARY="$HOME/.mussels/install/host-static/lib/libssl.a" \ -D LIBXML2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include/libxml2" \ -D LIBXML2_LIBRARY="$HOME/.mussels/install/host-static/lib/libxml2.a" \ -D PCRE2_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D PCRE2_LIBRARY="$HOME/.mussels/install/host-static/lib/libpcre2-8.a" \ -D CURSES_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D CURSES_LIBRARY="$HOME/.mussels/install/host-static/lib/libncurses.a" \ -D ZLIB_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D ZLIB_LIBRARY="$HOME/.mussels/install/host-static/lib/libz.a" \ -D LIBCHECK_INCLUDE_DIR="$HOME/.mussels/install/host-static/include" \ -D LIBCHECK_LIBRARY="$HOME/.mussels/install/host-static/lib/libcheck.a" ``` Set CPACK_PACKAGING_INSTALL_PREFIX to customize the resulting package's install location. This can be different than the install prefix. E.g.: ```sh -D CMAKE_INSTALL_PREFIX="/usr/local/clamav" \ -D CPACK_PACKAGING_INSTALL_PREFIX="/usr/local/clamav" \ ``` Then `make` and then one of these, depending on the platform: ```sh cpack # macOS: productbuild is default cpack -G DEB # Debian-based cpack -G RPM # RPM-based ``` On macOS you'll need to `pip3 install markdown` so that the NEWS.md file can be converted to html so it will render in the installer. On RPM-based systems, you'll need rpmbuild (install rpm-build) This commit also fixes an issue where the html manual (if present) was not correctly added to the Windows (or now other) install packages. Fix num to hex function for Windows installer guid Fix win32 cpack build Fix macOS cpack build
2021-07-27 14:28:13 -07:00
COMPONENT documentation)
else()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/html
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT documentation)
endif()
endif()