1dnl   Copyright (C) 2013-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
2dnl   Copyright (C) 2007-2013 Sourcefire, Inc.
3dnl   Copyright (C) 2002-2007 Tomasz Kojm <tkojm@clamav.net>
4dnl   socklen_t check (c) Alexander V. Lukyanov <lav@yars.free.net>
5dnl
6dnl   This program is free software; you can redistribute it and/or modify
7dnl   it under the terms of the GNU General Public License as published by
8dnl   the Free Software Foundation; either version 2 of the License, or
9dnl   (at your option) any later version.
10dnl
11dnl   This program is distributed in the hope that it will be useful,
12dnl   but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14dnl   GNU General Public License for more details.
15dnl
16dnl   You should have received a copy of the GNU General Public License
17dnl   along with this program; if not, write to the Free Software
18dnl   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19dnl   MA 02110-1301, USA.
20
21AC_PREREQ([2.59])
22
23dnl For a release change [devel] to the real version [0.xy]
24dnl also change VERSION below
25AC_INIT([ClamAV], [0.103.5], [https://github.com/Cisco-Talos/clamav/issues], [clamav], [https://www.clamav.net/])
26
27dnl put configure auxiliary into config
28AC_CONFIG_AUX_DIR([config])
29
30dnl enable C++
31AC_PROG_CXX()
32
33AH_BOTTOM([#include "platform.h"])
34AC_CONFIG_HEADERS([clamav-config.h libclammspack/config.h:libclammspack/config.h.in])
35
36dnl safety check, this used to be a parameter to AC_INIT
37AC_CONFIG_SRCDIR([clamscan/clamscan.c])
38AC_CONFIG_MACRO_DIR([m4])
39AC_CREATE_TARGET_H([target.h])
40
41dnl -Wall and -Werror here are NOT CFLAGS, they refer to automake warnings
42dnl enable stealth builds and psychedelic tests
43AM_INIT_AUTOMAKE([1.11.1 -Wall -Wportability -Wno-override subdir-objects std-options foreign dist-bzip2 no-define color-tests parallel-tests tar-ustar])
44AM_SILENT_RULES([yes])
45AC_USE_SYSTEM_EXTENSIONS
46m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
47
48dnl we told automake to not define these, since we want to include
49dnl the date in the version
50AC_DEFINE([PACKAGE], PACKAGE_NAME, [Name of package])
51
52m4_include([m4/reorganization/version.m4])
53
54LT_CONFIG_LTDL_DIR([libltdl])
55LT_INIT([dlopen disable-static])
56LTDL_INIT([recursive])
57PKG_PROG_PKG_CONFIG(0.16)
58
59m4_include([m4/reorganization/libclamav-only.m4])
60
61m4_include([m4/reorganization/build_tools.m4])
62m4_include([m4/reorganization/headers.m4])
63
64AC_CONFIG_FILES([libltdl/Makefile])
65
66AC_DEFINE([SCANBUFF], 131072, [scan buffer size])
67AC_DEFINE([FILEBUFF], 8192,   [file i/o buffer size])
68
69m4_include([m4/reorganization/c_options.m4])
70m4_include([m4/reorganization/compiler_checks.m4])
71m4_include([m4/reorganization/linker_checks.m4])
72
73AC_ARG_ENABLE([experimental],
74[AS_HELP_STRING([--enable-experimental], [enable experimental code])],
75enable_experimental=$enableval, enable_experimental="no")
76
77if test "$enable_experimental" = "yes"; then
78  AC_DEFINE([CL_EXPERIMENTAL],1,[enable experimental code])
79  VERSION_SUFFIX="$VERSION_SUFFIX-exp"
80fi
81
82build_configure_args=`echo "$ac_configure_args" | sed -e 's/[\"]//g'`
83AC_SUBST([BUILD_CONFIGURE_FLAGS], [$build_configure_args])
84
85m4_include([m4/reorganization/code_checks/fuzz.m4])
86m4_include([m4/reorganization/code_checks/functions.m4])
87m4_include([m4/reorganization/code_checks/mpool.m4])
88m4_include([m4/reorganization/code_checks/unit_tests.m4])
89m4_include([m4/reorganization/code_checks/coverage.m4])
90
91dnl libclamav dependencies
92m4_include([m4/reorganization/libs/xml.m4])
93m4_include([m4/reorganization/libs/openssl.m4])
94m4_include([m4/reorganization/libs/json.m4])
95m4_include([m4/reorganization/libs/pcre.m4])
96m4_include([m4/reorganization/libs/libmspack.m4])
97
98if test "x$use_internal_mspack" = "xno"; then
99    mspack_msg="External, $LIBMSPACK_CFLAGS $LIBMSPACK_LIBS"
100fi
101
102AM_MAINTAINER_MODE
103m4_include([m4/reorganization/libs/libz.m4])
104m4_include([m4/reorganization/libs/bzip.m4])
105m4_include([m4/reorganization/libs/unrar.m4])
106m4_include([m4/reorganization/libs/systemd.m4])
107m4_include([m4/reorganization/code_checks/ipv6.m4])
108m4_include([m4/reorganization/code_checks/dns.m4])
109m4_include([m4/reorganization/code_checks/fanotify.m4])
110m4_include([m4/reorganization/code_checks/setpgrp.m4])
111m4_include([m4/reorganization/milter/enable.m4])
112m4_include([m4/reorganization/libs/iconv_check.m4])
113m4_include([m4/reorganization/code_checks/pthreads.m4])
114m4_include([m4/reorganization/code_checks/reentrant.m4])
115m4_include([m4/reorganization/utility_checks/id.m4])
116m4_include([m4/reorganization/utility_checks/yp.m4])
117m4_include([m4/reorganization/usergroup.m4])
118m4_include([m4/reorganization/debug.m4])
119m4_include([m4/reorganization/customversion.m4])
120m4_include([m4/reorganization/nocache.m4])
121m4_include([m4/reorganization/dns.m4])
122m4_include([m4/reorganization/bigstack.m4])
123m4_include([m4/reorganization/dbdir.m4])
124m4_include([m4/reorganization/cfgdir.m4])
125m4_include([m4/reorganization/code_checks/in_port_t.m4])
126m4_include([m4/reorganization/code_checks/in_addr_t.m4])
127m4_include([m4/reorganization/os_checks.m4])
128m4_include([m4/reorganization/milter/check.m4])
129m4_include([m4/reorganization/code_checks/pthread_02.m4])
130m4_include([m4/reorganization/code_checks/ctime.m4])
131m4_include([m4/reorganization/code_checks/socklen_t.m4])
132m4_include([m4/reorganization/clamav_user.m4])
133m4_include([m4/reorganization/code_checks/compiler_attribs.m4])
134m4_include([m4/reorganization/code_checks/select.m4])
135m4_include([m4/reorganization/code_checks/stat64.m4])
136m4_include([m4/reorganization/code_checks/shift.m4])
137m4_include([m4/reorganization/code_checks/features.m4])
138m4_include([m4/reorganization/clamdtop.m4])
139m4_include([m4/reorganization/distcheck.m4])
140m4_include([m4/reorganization/llvm.m4])
141m4_include([m4/reorganization/sha_collect.m4])
142m4_include([m4/reorganization/yara.m4])
143m4_include([m4/reorganization/code_checks/fts.m4])
144m4_include([m4/reorganization/prelude.m4])
145m4_include([m4/reorganization/bsd.m4])
146
147dnl Clamonacc loading
148m4_include([m4/reorganization/clamonacc.m4])
149
150dnl FreshClam dependencies
151m4_include([m4/reorganization/libs/curl.m4])
152m4_include([m4/reorganization/substitutions.m4])
153m4_include([m4/reorganization/strni.m4])
154
155if test "x$use_internal_mspack" = "xyes"; then
156    mspack_msg="Internal"
157    AC_SYS_LARGEFILE
158else
159    mspack_msg="External, $LIBMSPACK_CFLAGS $LIBMSPACK_LIBS"
160fi
161
162dnl Enable Objective-C, needed for macOS, may not be inside conditional.
163AC_PROG_OBJC
164
165dnl Detect the target system
166build_linux=no
167build_windows=no
168build_mac=no
169
170AC_CANONICAL_HOST
171
172case "${host_os}" in
173    cygwin*|mingw*)
174        build_windows=yes
175        ;;
176    darwin*)
177        build_mac=yes
178        ;;
179    *)
180        build_linux=yes
181        ;;
182esac
183
184AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
185AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
186AM_CONDITIONAL([MACOS], [test "$build_mac" = "yes"])
187
188
189AC_CONFIG_FILES([
190                 Makefile
191                 clamav-config
192                 libclamav.pc
193                 platform.h
194                 clamav-types.h
195                 clamav-version.h])
196if test "x$enable_libclamav_only" != "xyes"; then
197    AC_CONFIG_FILES([
198                     clamscan/Makefile
199                     database/Makefile
200                     docs/Makefile
201                     shared/Makefile
202                     clamd/Makefile
203                     clamd/clamav-daemon.service
204                     clamd/clamav-daemon.socket
205                     clamdscan/Makefile
206                     clamsubmit/Makefile
207                     clamav-milter/Makefile
208                     freshclam/clamav-freshclam.service
209                     freshclam/Makefile
210                     sigtool/Makefile
211                     clamconf/Makefile
212                     etc/Makefile
213                     test/Makefile
214                     unit_tests/Makefile
215                     fuzz/Makefile
216                     clamdtop/Makefile
217                     clambc/Makefile
218                     libfreshclam/Makefile
219                     docs/man/clamav-milter.8
220                     docs/man/clamav-milter.conf.5
221                     docs/man/clambc.1
222                     docs/man/clamconf.1
223                     docs/man/clamd.8
224                     docs/man/clamd.conf.5
225                     docs/man/clamdscan.1
226                     docs/man/clamscan.1
227                     docs/man/freshclam.1
228                     docs/man/freshclam.conf.5
229                     docs/man/sigtool.1
230                     docs/man/clamdtop.1
231                     docs/man/clamsubmit.1
232                     ])
233fi
234
235AM_COND_IF([BUILD_CLAMONACC],
236    [AC_CONFIG_FILES([
237        clamonacc/Makefile
238        clamonacc/clamav-clamonacc.service
239        docs/man/clamonacc.8
240    ])
241])
242
243# Define variables needed to generate clamav-types.h.
244m4_include([m4/reorganization/types.m4])
245
246AC_OUTPUT
247
248if test "$enable_llvm" = "yes" && test "$subdirfailed" != "no"; then
249    AC_MSG_ERROR([Failed to configure LLVM, and LLVM was explicitly requested])
250fi
251if test "$enable_llvm" = "auto" && test "$subdirfailed" != "no"; then
252    system_llvm="MIA"
253    llvm_linking=""
254fi
255
256AM_CONDITIONAL([ENABLE_LLVM],
257	       [test "$subdirfailed" != "yes" && test "$enable_llvm" != "no"])
258AM_CONDITIONAL([ENABLE_YARA],
259	       [test "$enable_yara" != "no"])
260AM_CONDITIONAL([ENABLE_CLAMSUBMIT],
261	       [test "X$have_curl" = "Xyes" && test "X$have_json" = "Xyes"])
262no_recursion="yes";
263
264AC_OUTPUT([libclamav/Makefile])
265
266# Print a summary of what features we enabled
267AC_MSG_NOTICE([Summary of detected features follows])
268
269cat <<EOF
270              OS          : $target_os
271              pthreads    : $have_pthreads ($THREAD_LIBS)
272EOF
273
274AC_MSG_NOTICE([Summary of miscellaneous features])
275if test "x$CHECK_LIBS" = "x"; then
276    check_libs="no"
277else
278    check_libs="$CHECK_LIBS"
279fi
280CL_MSG_STATUS([check       ],[$check_libs],[$enable_check_ut])
281CL_MSG_STATUS([fanotify    ],[$have_fanotify],[$have_fanotify])
282if test "x$ac_cv_have_control_in_msghdr" = "xyes"; then
283    CL_MSG_STATUS([fdpassing   ],[$have_fdpass],[$want_fdpassing])
284else
285    CL_MSG_STATUS([fdpassing   ],[n/a],[])
286fi
287CL_MSG_STATUS([IPv6        ],[$have_cv_ipv6],[$want_ipv6])
288CL_MSG_STATUS([openssl     ],[$LIBSSL_HOME],[yes])
289CL_MSG_STATUS([libcurl     ],[$LIBCURL_HOME],[yes])
290
291if test "x$enable_libclamav_only" != "xyes"; then
292    AC_MSG_NOTICE([Summary of optional tools])
293
294    if test "X$HAVE_LIBNCURSES" = "Xyes" || test "X$HAVE_LIBPDCURSES" = "Xyes"; then
295        CL_MSG_STATUS([clamdtop    ],[yes ($CURSES_LIBS)], [yes])
296    else
297        CL_MSG_STATUS([clamdtop    ],[no (missing ncurses / pdcurses)], [no])
298    fi
299
300    if test "X$have_milter" = "Xyes"; then
301        CL_MSG_STATUS([milter      ],[yes ($CLAMAV_MILTER_LIBS)], [yes])
302    else
303        CL_MSG_STATUS([milter      ],[no (missing libmilter)], [no])
304    fi
305
306    if test "X$have_json" = "Xyes"; then
307        CL_MSG_STATUS([clamsubmit  ], [yes (libjson-c-dev found at $LIBJSON_HOME, linking=$json_linking)], [yes])
308    else
309        CL_MSG_STATUS([clamsubmit  ], [no (missing libjson-c-dev. Use the website to submit FPs/FNs.)], [no])
310    fi
311
312    AM_COND_IF([BUILD_CLAMONACC],
313        [CL_MSG_STATUS([clamonacc   ],[yes],[$enable_clamonacc])],
314        [CL_MSG_STATUS([clamonacc   ],[no],[$enable_clamonacc])])
315fi
316
317
318AC_MSG_NOTICE([Summary of engine performance features])
319if test "x$enable_debug" = "xyes"; then
320    CL_MSG_STATUS([release mode],[no],[debug build])
321else
322    CL_MSG_STATUS([release mode],[yes],[yes])
323fi
324have_jit="no"
325if test "$subdirfailed" = "no"; then
326    have_jit="yes"
327fi
328if test "$enable_llvm" = "no"; then
329   CL_MSG_STATUS([llvm        ],[$have_jit],[$enable_llvm])
330elif test "x$llvmconfig" = "x"; then
331   CL_MSG_STATUS([llvm        ],[$have_jit ($llvmver), from internal],[$enable_llvm])
332else
333   CL_MSG_STATUS([llvm        ],[$have_jit ($llvmver), from $llvmconfig ($llvm_linking)],[$enable_llvm])
334fi
335CL_MSG_STATUS([mempool     ],[$have_mempool],[$enable_mempool])
336
337AC_MSG_NOTICE([Summary of engine detection features])
338CL_MSG_STATUS([iconv       ],[$am_func_iconv],[])
339CL_MSG_STATUS([bzip2       ],[$bzip_check],[$want_bzip2])
340if test "x${ZLIB_HOME}" != "x"; then
341    CL_MSG_STATUS([zlib        ], [yes (zlib found at $ZLIB_HOME)], [yes])
342else
343    CL_MSG_STATUS([zlib        ], [yes (from system)], [yes])
344fi
345CL_MSG_STATUS([unrar       ],[$want_unrar],[$want_unrar])
346if test "X$have_json" = "Xyes"; then
347    CL_MSG_STATUS([preclass    ],[yes (libjson-c-dev found at $LIBJSON_HOME, linking=$json_linking)],[yes])
348else
349    CL_MSG_STATUS([preclass    ],[no (missing libjson-c-dev)],[no])
350fi
351if test "x$PCRE_HOME" = "x"; then
352    CL_MSG_STATUS([pcre        ],[no],[$have_pcre])
353else
354    CL_MSG_STATUS([pcre        ],[$PCRE_HOME],[$have_pcre])
355fi
356CL_MSG_STATUS([libmspack   ],[yes],[$mspack_msg])
357if test "x$XML_LIBS" = "x"; then
358    CL_MSG_STATUS([libxml2     ],[no],[])
359else
360    CL_MSG_STATUS([libxml2     ],[yes, from $XML_HOME],[])
361fi
362CL_MSG_STATUS([yara        ],[$enable_yara],[$enable_yara])
363CL_MSG_STATUS([fts         ],[yes],[$lfs_fts_msg])
364
365
366# Yep, downgrading the compiler avoids the bug too:
367# 4.0.x, and 4.1.0 are the known buggy versions
368# 3.4 doesn't have the bug
369if test "x$gcc_check" != "xyes"; then
370    AC_MSG_WARN([
371****** Optimizations disabled to avoid compiler bugs
372****** The resulting binaries will be slow!
373****** It is recommended to either upgrade or downgrade your compiler
374    ])
375fi
376
377if test "x$cross_compiling" != "xno" || test "x$gcc_check" != "xyes" || test "x$bzip_check" != "xok" ; then
378    AC_MSG_WARN([
379****** WARNING:
380****** You are cross compiling to a different host or you are
381****** linking to bugged system libraries or you have manually
382****** disabled important configure checks.
383****** Please be aware that this build may be badly broken.
384****** DO NOT REPORT BUGS BASED ON THIS BUILD !!!
385    ])
386fi
387
388if test "X$have_json" = "Xyes" && test "x$json_linking" = "xdynamic"; then
389    AC_MSG_WARN([
390****** libjson-c is known to share symbol names with other JSON libraries
391****** which may result in crashes for applications that use libclamav.
392****** Consider using --with-libjson-static=[path/to/libjson-c.a],
393****** providing a json-c library that was compiled with CFLAGS="-fPIC".
394    ])
395fi
396
397if test "x$clamonacc-curl" = "xdeprecated"; then
398    AC_MSG_WARN([m4_normalize([
399****** your libcurl (e.g. libcurl-devel) is older than the recommended version. Installing ClamAV with clamonacc requires libcurl 7.40 or higher to use fdpassing.
400****** fdpassing with clamonacc will be disabled on your system.
401****** for more information on ClamAV's on-access scanner, please read our documentation: https://docs.clamav.net/manual/OnAccess.html
402    ])])
403fi
404