1dnl
2dnl  Copyright 2020 Northern.tech AS
3dnl
4dnl  This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
5dnl
6dnl  This program is free software; you can redistribute it and/or modify it
7dnl  under the terms of the GNU General Public License as published by the
8dnl  Free Software Foundation; version 3.
9dnl
10dnl  This program is distributed in the hope that it will be useful,
11dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13dnl  GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this program; if not, write to the Free Software
17dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
18dnl
19dnl To the extent this program is licensed as part of the Enterprise
20dnl versions of CFEngine, the applicable Commercial Open Source License
21dnl (COSL) may apply to this file if you as a licensee so wish it. See
22dnl included file COSL.txt.
23dnl
24dnl ##########################################################################
25dnl #
26dnl # Build CFEngine
27dnl #
28dnl # Run ./autogen.sh to build configure script
29dnl #
30dnl ##########################################################################
31
32AC_PREREQ(2.63)
33
34m4_define([cfversion_from_env],  m4_normalize(m4_esyscmd([echo $EXPLICIT_VERSION])))
35m4_define([cfversion_from_file], m4_normalize(m4_esyscmd([cat CFVERSION])))
36m4_ifval(cfversion_from_env, [
37    m4_define([cfversion], cfversion_from_env)
38], [
39    m4_ifval(cfversion_from_file, [
40        m4_define([cfversion], cfversion_from_file)
41    ], [
42        m4_fatal([Could not determine CFEngine version;
43                  please set EXPLICIT_VERSION in the environment,
44                  or make sure all git tags are up to date and rerun autogen.sh])
45    ])
46])
47
48
49AC_INIT(cfengine, cfversion)
50AC_CONFIG_SRCDIR([libpromises/generic_agent.c])
51AC_CANONICAL_TARGET
52
53dnl
54dnl This program needs to be checked early, as MAKEINFO variable is expanded in
55dnl AM_INIT_AUTOMAKE.
56dnl
57AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo)
58
59
60dnl Parallel unit tests are causing spurious failures across several systems,
61dnl particularly those doing process testing.
62dnl Unfortunately the option to disable parallel tests (serial-tests) doesn't
63dnl exist in automake 1.11 and earlier, so we need to do this complicated logic
64dnl to determine whether we can disable it or not. If it doesn't exist as an
65dnl option, then serial tests are already the default.
66AC_MSG_CHECKING([automake version])
67m4_define(AUTOMAKE_VERSION, m4_normalize(m4_esyscmd([automake --version 2>&1 | sed -ne '/^automake/{s/^automake.* \([^ ][^ ]*\)$/\1/; p;}'])))
68m4_define(SERIAL_TESTS, m4_bmatch(AUTOMAKE_VERSION, [^1\.\([0-9]\|1[0-1]\)\(\.\|$\)], [], [serial-tests]))
69AC_MSG_RESULT(AUTOMAKE_VERSION)
70
71
72AM_INIT_AUTOMAKE([tar-ustar] SERIAL_TESTS)
73AM_MAINTAINER_MODE([enable])
74
75m4_divert_text([DEFAULTS], [: "${AR_FLAGS=cr}"])
76
77cfengine_version=cfversion
78
79m4_undefine([cfversion])
80m4_undefine([cfversion_from_file])
81m4_undefine([cfversion_from_env])
82
83AS_IF([test -n "$RELEASE"],
84      [AC_DEFINE_UNQUOTED(RELEASE, ["$RELEASE"], [Release number])],
85      [AC_DEFINE(RELEASE, ["1"], [Release number])])
86
87AC_DEFINE(BUILD_YEAR, esyscmd([date +%Y | tr -d '\n']), "Software build year")
88
89AC_DEFINE_UNQUOTED(ABS_TOP_SRCDIR,
90"`cd -- "$srcdir"; pwd`",
91[Absolute path of source tree])
92
93m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
94
95AC_CONFIG_HEADERS([config.h])
96
97dnl Libtool madness
98
99AC_CONFIG_MACRO_DIR([m4])
100
101dnl
102dnl hide [s]include macros, so old aclocal (automake < 1.10) won't find them and
103dnl won't complain about something/something.m4 not found
104dnl
105m4_define(incstart,sinc)
106m4_define(incend,lude)
107
108dnl
109dnl Save environment CFLAGS before autoconf starts messing with it.
110dnl It is restored later.
111dnl
112ENV_CFLAGS="$CFLAGS"
113
114dnl ######################################################################
115dnl Checks for programs.
116dnl ######################################################################
117
118AC_PROG_CC
119AC_PROG_MKDIR_P
120AC_EXEEXT
121
122dnl GCC specific flags
123m4_include([m4/cf3_gcc_flags.m4])
124
125# Use either new LT_INIT or old AC_DISABLE_STATIC/AC_PROG_LIBTOOL macros
126m4_ifdef([LT_INIT],
127  [LT_INIT([disable-static])],
128  [AC_DISABLE_STATIC
129   AC_PROG_LIBTOOL])
130
131AM_PROG_LEX
132AC_PROG_YACC
133AC_PROG_INSTALL
134AC_PATH_PROG([PERL], [perl])
135AC_CONFIG_LIBOBJ_DIR(libntech/libcompat)
136AC_PATH_PROG(GETCONF, getconf, false, $PATH:$prefix/bin:/usr/bin:/usr/local/bin:/sw/bin)
137AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = "xyes")
138
139
140dnl ######################################################################
141dnl Use pthreads if available
142dnl ######################################################################
143
144AC_ARG_WITH([pthreads],
145    [AS_HELP_STRING([--with-pthreads[[=PATH]]],
146                    [Specify path to pthreads, if not the part of operating system])])
147
148if test "x$with_pthreads" != x && test "x$with_pthreads" != "xyes" && test "x$with_pthreads" != "xno"; then
149   LIBS="$LIBS -L$with_pthreads/lib"
150   CPPFLAGS="-I$with_pthreads/include $CPPFLAGS"
151fi
152
153ACX_PTHREAD([],
154            [AC_MSG_ERROR(pthread-compatible library is required to build CFEngine)])
155
156CC="$PTHREAD_CC"
157CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
158LIBS="$PTHREAD_LIBS $LIBS"
159
160dnl ######################################################################
161dnl Whether to build extensions as builtin extensions or a separate
162dnl plugin. The default is plugin.
163dnl --enable-builtin-extensions is the default on Windows, and can be
164dnl used on other platforms for debugging purposes, but isn't otherwise
165dnl supported.
166dnl ######################################################################
167
168AC_ARG_ENABLE([builtin-extensions], [AS_HELP_STRING([Build binaries with builtin extensions])],
169              [],
170              [
171                  AS_CASE([${target_os}], [mingw*], [enable_builtin_extensions=yes], [enable_builtin_extensions=no])
172              ])
173AM_CONDITIONAL([BUILTIN_EXTENSIONS], [test "x$enable_builtin_extensions" = "xyes"])
174AS_IF([test "x$enable_builtin_extensions" = "xyes"], [AC_DEFINE([BUILTIN_EXTENSIONS], [1], [Define if you want builtin Enterprise extensions])])
175AC_SUBST([enable_builtin_extensions])
176
177dnl ######################################################################
178dnl Configure files layout
179dnl ######################################################################
180
181AC_ARG_ENABLE([fhs],
182        [AS_HELP_STRING([--enable-fhs], [Enable FHS compliance. Defaults to custom CFEngine files layout])])
183
184#
185# pkglibdir/pkgdatadir are not overridable, so use our own invention instead.
186#
187
188AS_IF([test x"$enable_fhs" = xyes], [
189  projlibdir='${pkglibdir}'
190  WORKDIR='${localstatedir}/lib/${PACKAGE}'
191  MASTERDIR='default'
192  INPUTDIR='default'
193  LOGDIR='${localstatedir}/log/${PACKAGE}'
194  PIDDIR='${runstatedir:-${localstatedir}/run}/${PACKAGE}'
195  STATEDIR='default'
196], [
197  if test x"$prefix" = xNONE || test x"$prefix" = x/var/cfengine; then
198    prefix=/var/cfengine
199    case "$target_os" in
200      mingw*)
201        WORKDIR=$(cmd /c "echo %PROGRAMFILES%\\Cfengine" | sed 's/\\/\\\\/g')
202        MASTERDIR=default
203        INPUTDIR=default
204        LOGDIR=$(cmd /c "echo %PROGRAMFILES%\\Cfengine" | sed 's/\\/\\\\/g')
205        PIDDIR=$(cmd /c "echo %PROGRAMFILES%\\Cfengine" | sed 's/\\/\\\\/g')
206        STATEDIR=default
207      ;;
208      *)
209        WORKDIR=/var/cfengine
210        MASTERDIR=default
211        INPUTDIR=default
212        LOGDIR=/var/cfengine
213        PIDDIR=/var/cfengine
214        STATEDIR=default
215      ;;
216    esac
217  else
218    WORKDIR="${localstatedir}/${PACKAGE}"
219    MASTERDIR="default"
220    INPUTDIR="default"
221    LOGDIR="${localstatedir}/${PACKAGE}"
222    PIDDIR="${localstatedir}/${PACKAGE}"
223    STATEDIR="default"
224  fi
225  bindir="${bindir:-${exec_prefix}/bin}"
226  projlibdir='${libdir}'
227])
228
229AC_SUBST(projlibdir)
230
231dnl ######################################################################
232dnl Platform specific compiler flags.
233dnl ######################################################################
234
235AS_CASE([${target_os}],
236  [mingw*],
237    # Disable printf format warnings, because our wrapper supports more
238    # flags than vanilla Windows version, so they are false positives.
239    [CFLAGS="$CFLAGS -Wno-format"])
240
241dnl ######################################################################
242dnl Enable debugging
243dnl ######################################################################
244
245AC_ARG_ENABLE(debug,
246              AS_HELP_STRING([--enable-debug], [Enable debugging]),
247              [debug=$enableval],
248              [debug=no])
249AM_CONDITIONAL([NDEBUG], [test x"$debug" = x"no"])
250
251dnl Even though CFLAGS should contain the command-line CFLAGS
252dnl as last, some macro seem to messes the order up and insert
253dnl its own optimisation flags as well. So we append ENV_CFLAGS
254dnl at the end manually, causing a bit of flag duplication.
255
256if test x"$debug" = x"yes"
257then
258    CFLAGS="$CFLAGS -g3 -O0 $ENV_CFLAGS"
259else
260    CFLAGS="$CFLAGS -O2 -DNDEBUG $ENV_CFLAGS"
261fi
262
263dnl ######################################################################
264dnl Checks for libraries.
265dnl ######################################################################
266
267dnl Now check for database connectors
268
269# TODO remove
270AC_ARG_WITH([sql],
271    [AS_HELP_STRING([--with-sql[[=PATH]]],
272        [Enable SQL database connectors (deprecated, use \
273        --with[[out]]-postgresql and --with[[out]]-mysql instead)])
274    ],
275    [with_postgresql=$with_sql; with_mysql=$with_sql],
276    [])
277
278dnl PostgreSQL
279
280AC_ARG_WITH([postgresql],
281    [AS_HELP_STRING([--with-postgresql[[=PATH]]],
282        [Enable PostgreSQL connector])
283    ],
284    [],
285    [with_postgresql=check])
286
287if test "x$with_postgresql" != "xno"
288then
289    if test "x$with_postgresql" != xyes && test "x$with_postgresql" != xcheck
290    then
291        PG_CONFIG=$with_postgresql/bin/pg_config
292    else
293        PG_CONFIG=pg_config
294    fi
295
296    # pg_config is only for native builds
297    if test "x$cross_compiling" = "xno"
298    then
299        if test x`which $PG_CONFIG` != x
300        then
301            pg_include_dir=`$PG_CONFIG --includedir`
302            if test -n "$pg_include_dir"
303            then
304                POSTGRESQL_CPPFLAGS="-I$pg_include_dir"
305            fi
306        fi
307    fi
308
309    CF3_WITH_LIBRARY(postgresql,
310        [AC_CHECK_LIB(pq, PQconnectdb,
311            [],
312            [if test "x$with_postgresql" != xcheck; then
313                AC_MSG_ERROR(Cannot find PostgreSQL client library); fi]
314         )
315         AC_CHECK_HEADERS(libpq-fe.h,
316             [],
317             [if test "x$with_postgresql" != xcheck; then
318                 AC_MSG_ERROR(Cannot find PostgreSQL client library); fi]
319         )]
320    )
321fi
322
323dnl MySQL
324
325AC_ARG_WITH([mysql],
326    [AS_HELP_STRING([--with-mysql[[=PATH]]],
327        [Enable MySQL connector])
328    ],
329    [],
330    [with_mysql=check])
331
332if test "x$with_mysql" != "xno"
333then
334    if test "x$with_mysql" != xyes &&
335       test "x$with_mysql" != xcheck
336    then
337        MYSQL_CONFIG=$with_mysql/bin/mysql_config
338    else
339        MYSQL_CONFIG=mysql_config
340    fi
341
342    # mysql_config is only for native builds
343    if test "x$cross_compiling" = "xno"
344    then
345        if test x`which $MYSQL_CONFIG` != x
346        then
347            mysql_include_dir=`$MYSQL_CONFIG --include`
348            if test -n "$mysql_include_dir"
349            then
350                MYSQL_CPPFLAGS="$mysql_include_dir"
351            fi
352        fi
353    fi
354
355    CF3_WITH_LIBRARY(mysql,
356        [AC_CHECK_LIB(mysqlclient, mysql_real_connect,
357            [],
358            [if test "x$with_mysql" != xcheck; then
359                AC_MSG_ERROR(Cannot find MySQL client library); fi]
360        )
361        AC_CHECK_HEADERS(mysql.h,
362            [],
363            [if test "x$with_mysql" != xcheck; then
364                AC_MSG_ERROR(Cannot find MySQL clientlibrary); fi]
365        )
366        AC_CHECK_LIB(mysqlclient, EVP_CIPHER_CTX_init,
367            [AC_MSG_ERROR([MySQL client library exports symbols clashing \
368                with OpenSSL. Get the update from distribution provider, \
369                recompile MySQL library or disable MySQL connector. See \
370                http://bugs.mysql.com/bug.php?id=65055 for details.])
371            ]
372        )]
373    )
374fi
375
376dnl
377dnl In-process databases
378dnl
379
380dnl QDBM
381
382AC_ARG_WITH([qdbm],
383    [AS_HELP_STRING([--with-qdbm[[=PATH]]], [use QDBM to store runtime data])])
384AS_IF([test -n "$with_qdbm" && test "x$with_qdbm" != "xno"], [WITH_QDBM=1], [WITH_QDBM=0])
385
386if test $WITH_QDBM = 1; then
387  CF3_WITH_LIBRARY(qdbm, [
388    AC_CHECK_LIB(qdbm, dpopen, [], [AC_MSG_ERROR(Cannot find QDBM)])
389    AC_CHECK_HEADERS(depot.h, [], [AC_MSG_ERROR(Cannot find QDBM)])
390    AC_DEFINE(QDB, 1, [Define if QDBM is available])
391  ])
392fi
393
394dnl Tokyo Cabinet
395
396AC_ARG_WITH([tokyocabinet],
397    [AS_HELP_STRING([--with-tokyocabinet[[=PATH]]], [use Tokyo Cabinet to store runtime data])])
398
399AS_IF([test $WITH_QDBM -eq 0 && test -n "$with_tokyocabinet" && test "x$with_tokyocabinet" != "xno"], [WITH_TOKYO=1], [WITH_TOKYO=0])
400
401if test $WITH_TOKYO = 1; then
402  CF3_WITH_LIBRARY(tokyocabinet, [
403    AC_CHECK_LIB(tokyocabinet, tchdbnew, [], [AC_MSG_ERROR(Cannot find Tokyo Cabinet)])
404    AC_CHECK_HEADERS(tcutil.h, [], [AC_MSG_ERROR(Cannot find Tokyo Cabinet)])
405    AC_CHECK_HEADERS(tchdb.h, [], [AC_MSG_ERROR(Cannot find Tokyo Cabinet)])
406    AC_DEFINE(TCDB, 1, [Define if Tokyo Cabinet is available.])
407  ])
408fi
409
410dnl OpenLDAP Lightning MDB
411
412AC_ARG_WITH([lmdb],
413    [AS_HELP_STRING([--with-lmdb[[=PATH]]], [use Lightning MDB to store runtime data])])
414
415AS_IF([test $WITH_TOKYO -eq 0 && test $WITH_QDBM -eq 0 && (! test -n "$with_lmdb" || test "x$with_lmdb" != "xno")], [WITH_LMDB=1], [WITH_LMDB=0])
416
417if test $WITH_LMDB = 1; then
418  CF3_WITH_LIBRARY(lmdb, [
419    AC_CHECK_LIB(lmdb, mdb_dbi_open, [], [AC_MSG_ERROR(Cannot find Lightning MDB)])
420    AC_CHECK_HEADERS(lmdb.h, [], [AC_MSG_ERROR(Cannot find Lightning MDB)])
421    AC_DEFINE(LMDB, 1, [Define if Lightning MDB is available])
422  ])
423fi
424
425if test $WITH_QDBM -eq 0 && test $WITH_TOKYO -eq 0 && test $WITH_LMDB -eq 0; then
426   AC_MSG_ERROR(Either Tokyo Cabinet, LMDB, or QDBM must be selected to compile CFEngine)
427fi
428
429dnl
430dnl OpenSSL
431dnl
432
433AC_ARG_WITH(openssl,
434    [AS_HELP_STRING([--with-openssl[[=PATH]]],
435    [Specify OpenSSL path])], [], [with_openssl=yes])
436
437if test x"$with_openssl" = xno ; then
438    AC_MSG_ERROR([This release of CFEngine requires OpenSSL >= 0.9.7])
439fi
440
441if  test -d /usr/local/Cellar/openssl/ && \
442    test -d /usr/local/opt/openssl/ && \
443    test "x$with_openssl" = "xyes" ; then
444    with_openssl="/usr/local/opt/openssl"
445    echo "OS X Homebrew detected"
446    echo "Defaulting to: --with-openssl=$with_openssl"
447fi
448
449CF3_WITH_LIBRARY(openssl, [
450   AC_CHECK_LIB(crypto, RSA_generate_key_ex, [], [])
451   AC_CHECK_LIB(ssl, SSL_free, [], [])
452   AC_CHECK_DECLS([SSL_CTX_clear_options], [], [], [[#include <openssl/ssl.h>]])
453   AC_CHECK_HEADERS([openssl/opensslv.h], [], [AC_MSG_ERROR(Cannot find OpenSSL)])
454
455   AC_MSG_CHECKING(for OpenSSL version)
456
457   AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
458   #include <openssl/opensslv.h>
459
460   #if OPENSSL_VERSION_NUMBER < 0x0090602fL
461   #This OpenSSL is too old
462   #endif
463   ]])],[AC_MSG_RESULT(OK)],[AC_MSG_ERROR(This release of CFEngine requires OpenSSL >= 0.9.7)])
464
465   if test "x$ac_cv_lib_crypto_RSA_generate_key_ex" = "xyes" ; then
466      AC_DEFINE(OPENSSL_NO_DEPRECATED, 1, [Define if non deprecated API is available.])
467   fi
468
469   if test "x$ac_cv_lib_crypto_RSA_generate_key_ex" = "xno" && \
470      test "x$ac_cv_lib_crypto_RSA_generate_key" = "xno" ; then
471      AC_MSG_ERROR(Cannot find OpenSSL)
472   fi
473
474   AC_CHECK_DECL([SSL_OP_NO_TLSv1_1],
475    [AC_DEFINE([HAVE_TLS_1_1], [1], [Define if TLS 1.1 is supported by OpenSSL])],
476    [], [[#include <openssl/ssl.h>]]
477    )
478   AC_CHECK_DECL([SSL_OP_NO_TLSv1_2],
479    [AC_DEFINE([HAVE_TLS_1_2], [1], [Define if TLS 1.2 is supported by OpenSSL])],
480    [], [[#include <openssl/ssl.h>]]
481    )
482   AC_CHECK_DECL([SSL_OP_NO_TLSv1_3],
483    [AC_DEFINE([HAVE_TLS_1_3], [1], [Define if TLS 1.3 is supported by OpenSSL])],
484    [], [[#include <openssl/ssl.h>]]
485    )
486])
487
488dnl PCRE
489
490AC_ARG_WITH([pcre], [AS_HELP_STRING([--with-pcre[[=PATH]]], [Specify PCRE path])], [], [with_pcre=yes])
491
492if test "x$with_pcre" = "xno"; then
493   AC_MSG_ERROR([PCRE is required])
494fi
495
496CF3_WITH_LIBRARY(pcre, [
497  AC_CHECK_LIB(pcre, pcre_exec, [], [AC_MSG_ERROR(Cannot find PCRE)])
498  AC_CHECK_HEADERS([pcre.h], [],
499    [AC_CHECK_HEADERS([pcre/pcre.h], [PCRE_CPPFLAGS="-Ipcre"],
500                      AC_MSG_ERROR(Cannot find PCRE))])
501])
502
503dnl libvirt
504
505AC_ARG_WITH([libvirt],
506    [AS_HELP_STRING([--with-libvirt[[=PATH]]], [support virtual machine management])],
507    [], [with_libvirt=check])
508
509if test "x$with_libvirt" != xno
510then
511   CF3_WITH_LIBRARY(libvirt, [
512      AC_CHECK_LIB(virt, virConnectOpen, [], [if test "x$with_libvirt" != xcheck; then AC_MSG_ERROR(Cannot find libvirt library); fi])
513      AC_CHECK_HEADERS(libvirt/libvirt.h, [], [if test "x$with_libvirt" != xcheck; then AC_MSG_ERROR(Cannot find libvirt library headers); fi])
514   ])
515fi
516
517dnl  BIG FAT WARNING FOR AC_CHECK_LIB: *always* leave the
518dnl  "action-if-yes" parameter empty else LIBS is not changed and C
519dnl  define is not generated!  Or use AC_SEARCH_LIBS for a better
520dnl  interface.
521
522dnl libacl
523dnl It is enough for any of the header files [acl.h sys/acl.h acl/libacl.h] to be present
524
525AC_ARG_WITH([libacl],
526    [AS_HELP_STRING([--with-libacl[[=PATH]]], [Specify libacl path])], [], [with_libacl=check])
527
528if test "x$with_libacl" != xno
529then
530  CF3_WITH_LIBRARY(libacl, [
531    AC_CHECK_LIB(acl, acl_init,
532      [],
533      [if test "x$with_libacl" != xcheck; then AC_MSG_ERROR(Cannot find libacl library); fi])
534    AC_CHECK_HEADERS([acl.h sys/acl.h acl/libacl.h],
535      [libacl_header_found=yes])
536    if test "x$libacl_header_found" != "xyes" && test "x$with_libacl" != xcheck;
537    then
538      AC_MSG_ERROR(Cannot find libacl library headers);
539    fi
540  ])
541fi
542
543dnl libcurl
544
545AC_ARG_WITH([libcurl],
546    [AS_HELP_STRING([--with-libcurl[[=PATH]]], [Specify libcurl path])], [], [with_libcurl=check])
547
548if test "x$with_libcurl" != xno
549then
550  CF3_WITH_LIBRARY(libcurl, [
551    AC_CHECK_LIB(curl, curl_global_init,
552      [],
553      [  libcurl_lib_found=no;
554         if test "x$with_libcurl" != xcheck;
555         then
556             AC_MSG_ERROR(Cannot find libcurl library);
557         fi
558      ])
559    AC_CHECK_HEADERS([curl/curl.h],
560      [libcurl_header_found=yes],
561      [if test "x$with_libcurl" != xcheck; then AC_MSG_ERROR(Cannot find libcurl header files); fi])
562  ])
563fi
564
565AM_CONDITIONAL(HAVE_LIBCURL,
566        [test "x$libcurl_lib_found" != xno && test "x$libcurl_header_found" = xyes])
567
568dnl libyaml
569
570AC_ARG_WITH([libyaml],
571    [AS_HELP_STRING([--with-libyaml[[=PATH]]], [Specify libyaml path])], [], [with_libyaml=check])
572
573if test "x$with_libyaml" != xno
574then
575  CF3_WITH_LIBRARY(libyaml, [
576    AC_CHECK_LIB(yaml, yaml_parser_initialize,
577      [],
578      [if test "x$with_libyaml" != xcheck; then AC_MSG_ERROR(Cannot find libyaml library); fi])
579    AC_CHECK_HEADERS(yaml.h,
580      [libyaml_header_found=yes],
581      [if test "x$with_libyaml" != xcheck; then AC_MSG_ERROR(Cannot find libyaml header files); fi])
582  ])
583fi
584
585dnl libxml2
586
587AC_ARG_WITH([libxml2],
588    [AS_HELP_STRING([--with-libxml2[[=PATH]]],
589        [Specify libxml2 path])
590    ],
591    [],
592    [with_libxml2=check])
593
594if test "x$with_libxml2" != xno
595then
596    if test "x$with_libxml2" != xyes &&
597       test "x$with_libxml2" != xcheck
598    then
599        XML2_CONFIG=$with_libxml2/bin/xml2-config
600    else
601        XML2_CONFIG=xml2-config
602    fi
603
604    # xml2-config is only for native builds
605    if test "x$cross_compiling" = "xno" && test x`which $XML2_CONFIG` != x
606    then
607        xml2_include_dir=`$XML2_CONFIG --cflags`
608        if test -n "$xml2_include_dir"
609        then
610            LIBXML2_CPPFLAGS="$xml2_include_dir"
611        fi
612    else                # xml2-config not found
613        # if a path, e.g. /var/cfengine was given, then we
614        # must take into account that libxml2 includes are in
615        # /var/cfengine/include/libxml2
616        LIBXML2_CPPFLAGS=-I$with_libxml2/include/libxml2
617    fi
618
619    CF3_WITH_LIBRARY(libxml2,
620        [AC_CHECK_LIB(xml2, xmlFirstElementChild,
621            [],
622            [if test "x$with_libxml2" != xcheck; then
623                AC_MSG_ERROR(Cannotfind libxml2); fi]
624        )
625        AC_CHECK_HEADERS([libxml/xmlwriter.h], [break],
626            [if test "x$with_libxml2" != xcheck; then
627                AC_MSG_ERROR(Cannot find libxml2); fi]
628        )]
629    )
630fi
631
632AM_CONDITIONAL([HAVE_LIBXML2],
633    [test "x$with_libxml2" != xno &&
634     test "x$ac_cv_lib_xml2_xmlFirstElementChild" = xyes])
635
636dnl avahi
637
638AC_CHECK_HEADERS(avahi-client/client.h,
639    AM_CONDITIONAL(HAVE_AVAHI_CLIENT, true),
640    AM_CONDITIONAL(HAVE_AVAHI_CLIENT, false),
641    [])
642AC_CHECK_HEADERS(avahi-common/address.h,
643    AM_CONDITIONAL(HAVE_AVAHI_COMMON, true),
644    AM_CONDITIONAL(HAVE_AVAHI_COMMON, false),
645    [])
646
647dnl
648
649dnl ######################################################################
650dnl Checks for header files.
651dnl ######################################################################
652
653AC_CHECK_HEADERS(unistd.h stdlib.h sys/loadavg.h)
654AC_CHECK_HEADERS(sys/param.h sys/resource.h)
655
656# sys/param.h is required for sys/mount.h on OpenBSD
657AC_CHECK_HEADERS(sys/mount.h, [], [], [AC_INCLUDES_DEFAULT
658#ifdef HAVE_SYS_PARAM_H
659# include <sys/param.h>
660#endif
661])
662
663# Required on BSD to get struct sockaddr_dl (for retrieving MAC addresses from getifaddrs())
664AC_CHECK_HEADERS(net/if_dl.h)
665
666# Required on Solaris to get struct arpreq (for retrieving MAC addresses)
667AC_CHECK_HEADERS(net/if_arp.h, , , [AC_INCLUDES_DEFAULT
668#include <sys/socket.h>
669])
670
671AC_CHECK_HEADERS(utime.h)
672AC_CHECK_HEADERS(time.h)
673AC_CHECK_HEADERS(sys/time.h)
674AC_CHECK_HEADERS(malloc.h sys/malloc.h)
675AC_CHECK_HEADERS(vfs.h)
676AC_CHECK_HEADERS(sys/vfs.h)
677AC_CHECK_HEADERS(sys/sockio.h)
678AC_CHECK_HEADERS(sys/statvfs.h)
679AC_CHECK_HEADERS(sys/statfs.h)
680AC_CHECK_HEADERS(fcntl.h)
681AC_CHECK_HEADERS(sys/filesys.h)
682AC_CHECK_HEADERS(dustat.h)
683AC_CHECK_HEADERS(sys/systeminfo.h)
684AC_CHECK_HEADERS(ieeefp.h)
685AC_CHECK_HEADERS(winsock2.h)
686AC_CHECK_HEADERS(ws2tcpip.h)
687AC_CHECK_HEADERS(zone.h)
688AC_CHECK_HEADERS(sys/uio.h)
689AC_CHECK_HEADERS_ONCE([sys/sysmacros.h]) dnl glibc deprecated inclusion in sys/type.h
690AC_CHECK_HEADERS(sys/types.h)
691AC_CHECK_HEADERS(sys/mpctl.h) dnl For HP-UX $(sys.cpus) - Mantis #1069
692AC_CHECK_HEADERS(shadow.h)
693AC_CHECK_HEADERS(sys/jail.h, [], [], [AC_INCLUDES_DEFAULT
694#ifdef HAVE_SYS_PARAM_H
695# include <sys/param.h>
696#endif
697])
698AC_CHECK_HEADERS(net/route.h netinet/in.h netinet/ip.h)
699
700
701AC_HEADER_STDC
702AC_HEADER_TIME
703AC_HEADER_SYS_WAIT
704AC_HEADER_DIRENT
705AC_HEADER_STDBOOL
706
707dnl ######################################################################
708dnl Checks for data types
709dnl ######################################################################
710
711AC_TYPE_MODE_T
712AC_TYPE_SIZE_T
713AC_TYPE_UID_T
714AC_TYPE_PID_T
715AC_CHECK_TYPES(clockid_t, [], [], [[
716#ifdef HAVE_TIME_H
717# include <time.h>
718#endif
719]])
720
721AC_CHECK_TYPES(socklen_t, [], [], [[
722#ifdef HAVE_SYS_TYPES_H
723# include <sys/types.h>
724#endif
725
726#include <sys/socket.h>
727]])
728
729dnl ######################################################################
730dnl Checks for typedefs, structures, and compiler characteristics.
731dnl ######################################################################
732
733AC_C_CONST
734
735AC_FUNC_FSEEKO
736AC_SYS_LARGEFILE
737AC_TYPE_OFF_T
738
739#
740# AC_SYS_LARGEFILE correctly figures out necessary macros for large files, but
741# on AIX there is a gotcha:
742#
743# Code generated by flex #includes <stdio.h> at the beginning of the file, which
744# picks up 32-bit wide off_t. Then it #includes <config.h> which provides LFS
745# macros, and finally it includes another system header, now with 64-bit wide
746# off_t, which causes a conflict.
747#
748if test "x$ac_cv_sys_large_files" = x1; then
749  CPPFLAGS="-D_LARGE_FILES=1 $CPPFLAGS"
750fi
751
752dnl ######################################################################
753dnl Check for libraries
754dnl ######################################################################
755
756AC_CHECK_LIB(m, sqrt)
757AC_CHECK_LIB(rt, clock_gettime)
758AC_CHECK_LIB(dl, dlopen)
759
760dnl ######################################################################
761dnl Check for special functions
762dnl ######################################################################
763
764AC_CHECK_DECLS(clock_gettime, [], [], [[#include <time.h>]])
765AC_REPLACE_FUNCS(clock_gettime)
766
767AC_CHECK_DECLS(unsetenv)
768AC_REPLACE_FUNCS(unsetenv)
769
770AC_CHECK_DECLS(strnlen)
771AC_REPLACE_FUNCS(strnlen)
772
773cf3_FUNC_STRNDUP
774
775AC_CHECK_DECLS(seteuid)
776AC_REPLACE_FUNCS(seteuid)
777
778AC_CHECK_DECLS(setlinebuf)
779AC_REPLACE_FUNCS(setlinebuf)
780
781AC_CHECK_DECLS(strlcat)
782AC_REPLACE_FUNCS(strlcat)
783
784AC_CHECK_DECLS(strlcpy)
785AC_REPLACE_FUNCS(strlcpy)
786
787AC_CHECK_DECLS(realpath)
788
789AC_CHECK_DECLS(strdup)
790AC_REPLACE_FUNCS(strdup)
791
792AC_CHECK_DECLS(memrchr)
793AC_REPLACE_FUNCS(memrchr)
794
795AC_CHECK_DECLS(round, [], [], [[#include <math.h>]])
796AC_REPLACE_FUNCS(round)
797
798AC_CHECK_DECLS(nanosleep)
799AC_REPLACE_FUNCS(nanosleep)
800
801AC_CHECK_DECLS(memdup)
802AC_REPLACE_FUNCS(memdup)
803
804AC_CHECK_DECLS(memmem)
805AC_REPLACE_FUNCS(memmem)
806
807AC_CHECK_DECLS(srand48)
808AC_REPLACE_FUNCS(srand48)
809
810AC_CHECK_DECLS(drand48)
811AC_REPLACE_FUNCS(drand48)
812
813AC_CHECK_DECLS(strerror)
814AC_REPLACE_FUNCS(strerror)
815
816AC_CHECK_DECLS(strstr)
817AC_REPLACE_FUNCS(strstr)
818
819AC_CHECK_DECLS(strcasestr)
820AC_REPLACE_FUNCS(strcasestr)
821
822AC_CHECK_DECLS(strcasecmp)
823AC_REPLACE_FUNCS(strcasecmp)
824
825AC_CHECK_DECLS(strncasecmp)
826AC_REPLACE_FUNCS(strncasecmp)
827
828AC_CHECK_DECLS(strsep)
829AC_REPLACE_FUNCS(strsep)
830
831AC_CHECK_DECLS(strsignal)
832AC_REPLACE_FUNCS(strsignal)
833
834AC_CHECK_DECLS(gmtime_r, [], [], [[#include <time.h>]])
835AC_REPLACE_FUNCS(gmtime_r)
836
837AC_CHECK_DECLS(getline, [], [], [#define _GNU_SOURCE 1
838AC_INCLUDES_DEFAULT])
839AC_REPLACE_FUNCS(getline)
840
841AC_CHECK_DECLS(strchrnul, [], [], [#define _GNU_SOURCE 1
842AC_INCLUDES_DEFAULT])
843AC_REPLACE_FUNCS(strchrnul)
844
845AC_CHECK_DECLS(localtime_r, [], [], [[#include <time.h>]])
846AC_REPLACE_FUNCS(localtime_r)
847
848AC_CHECK_DECLS(fgetgrent, [], [], [[#include <grp.h>]])
849
850AC_CHECK_DECLS(isfinite, [], [], [[#include <math.h>]])
851
852AC_CHECK_FUNCS(getpwent setpwent endpwent)
853
854AC_CHECK_FUNCS(fgetspent lckpwdf ulckpwdf)
855AC_CHECK_LIB([sec], [fgetspent], [
856    AC_DEFINE([HAVE_LIBSEC], 1, [Define if -lsec is available])
857    AC_DEFINE([HAVE_FGETSPENT], 1, [Define if fgetspent is available])
858    LIBS="-lsec $LIBS"
859])
860
861AC_CHECK_DECLS(getloadavg)
862AC_FUNC_GETLOADAVG
863
864AC_C_BIGENDIAN
865AC_CHECK_HEADERS([endian.h])
866AC_CHECK_DECLS(le32toh, [], [], [[#include <endian.h>]])
867
868AC_CHECK_DECLS(closefrom, [], [], [[#include <unistd.h>
869                                    #include <stdlib.h>]])
870AC_REPLACE_FUNCS(closefrom)
871
872AC_CHECK_HEADERS([sys/pstat.h])
873AC_CHECK_FUNCS(pstat_getfile2)
874
875CF3_PATH_ROOT_PROG([CHPASSWD], [chpasswd], [], [/sbin:/usr/sbin:/bin:/usr/bin:$PATH])
876AS_IF([test "x$CHPASSWD" != "x"],
877      [AC_DEFINE(HAVE_CHPASSWD, 1, [Define if chpasswd tool is present])]
878      [AC_DEFINE_UNQUOTED(CHPASSWD, ["$CHPASSWD"], [Path to chpasswd tool])]
879     )
880
881dnl AIX has this.
882CF3_PATH_ROOT_PROG([PWDADM], [pwdadm], [], [/sbin:/usr/sbin:/bin:/usr/bin:$PATH])
883AS_IF([test "x$PWDADM" != "x"],
884      [AC_DEFINE(HAVE_PWDADM, 1, [Define if pwdadm tool is present])]
885      [AC_DEFINE_UNQUOTED(PWDADM, ["$PWDADM"], [Path to pwdadm tool])]
886     )
887
888CF3_PATH_ROOT_PROG([USERADD], [useradd], [], [/sbin:/usr/sbin:/bin:/usr/bin:$PATH])
889AS_IF([test "x$USERADD" != "x"],
890      [AC_DEFINE(HAVE_USERADD, 1, [Define if useradd tool is present])]
891      [AC_DEFINE_UNQUOTED(USERADD, ["$USERADD"], [Path to useradd tool])]
892     )
893
894CF3_PATH_ROOT_PROG([USERMOD], [usermod], [], [/sbin:/usr/sbin:/bin:/usr/bin:$PATH])
895AS_IF([test "x$USERMOD" != "x"],
896      [AC_DEFINE(HAVE_USERMOD, 1, [Define if usermod tool is present])]
897      [AC_DEFINE_UNQUOTED(USERMOD, ["$USERMOD"], [Path to usermod tool])]
898     )
899
900CF3_PATH_ROOT_PROG([USERDEL], [userdel], [], [/sbin:/usr/sbin:/bin:/usr/bin:$PATH])
901AS_IF([test "x$USERDEL" != "x"],
902      [AC_DEFINE(HAVE_USERDEL, 1, [Define if userdel tool is present])]
903      [AC_DEFINE_UNQUOTED(USERDEL, ["$USERDEL"], [Path to userdel tool])]
904     )
905
906AS_IF([test "x$USERADD" != x && \
907       test "x$USERMOD" != x && test "x$USERDEL" != x],
908      [have_userprogs=yes],
909      [have_userprogs=no]
910)
911
912dnl FreeBSD
913CF3_PATH_ROOT_PROG([CHPASS], [chpass], [], [/usr/bin:$PATH])
914AS_IF([test "x$CHPASS" != "x"],
915      [AC_DEFINE(HAVE_CHPASS, 1, [Define if chpass tool is present])]
916      [AC_DEFINE_UNQUOTED(CHPASS, ["$CHPASS"], [Path to chpass tool])]
917     )
918
919CF3_PATH_ROOT_PROG([PW], [pw], [], [/usr/sbin:$PATH])
920AS_IF([test "x$PW" != "x"],
921      [AC_DEFINE(HAVE_PW, 1, [Define if pw tool is present])]
922      [AC_DEFINE_UNQUOTED(PW, ["$PW"], [Path to pw tool])]
923     )
924
925AS_IF([test "x$CHPASS" != x && \
926       test "x$PW" != x],
927      [have_userprogs=yes],
928      [have_userprogs=no]
929)
930
931AC_ARG_WITH([pam], AS_HELP_STRING([--with-pam], [Compile with PAM support]))
932AS_IF([test x$with_pam != xno],
933[
934  CF3_WITH_LIBRARY(pam, [
935    AC_CHECK_LIB(pam, pam_start)
936    AC_CHECK_HEADERS([security/pam_appl.h])
937  ])
938  dnl These platforms must have pam, others can have it, but not required.
939  AS_CASE([$target_os],
940          [*gnu*|*solaris*|*aix*|*hpux*|*hp-ux*], [
941              AS_IF([test "x$ac_cv_lib_pam_pam_start" != "xyes"],
942                    [AC_MSG_ERROR(Cannot find PAM library)]
943              )
944              AS_IF([test "x$ac_cv_header_security_pam_appl_h" != "xyes"],
945                    [AC_MSG_ERROR(Cannot find PAM headers)]
946          )]
947  )
948  AS_IF([test "x$ac_cv_lib_pam_pam_start" = "xyes" && \
949         test "x$ac_cv_header_security_pam_appl_h" = "xyes"],
950        [have_pam=yes],
951        [have_pam=no]
952  )
953  AC_CHECK_FUNCS(fgetpwent fgetgrent)
954  AS_IF([test "x$ac_cv_func_fgetpwent" = "xyes" && \
955         test "x$ac_cv_func_fgetgrent" = "xyes"],
956         [have_fgetpwent_fgetgrent=yes]
957         [AC_DEFINE(HAVE_FGETPWENT_FGETGRENT, 1, [Define if fgetpwent and fgetgrent functions are present])],
958         [have_fgetpwent_fgetgrent=no]
959     )
960
961  AS_CASE(["$target_os"],
962     [freebsd*],
963     [
964        AS_IF([test "x$have_pam" = "xyes" && \
965               test "x$have_userprogs" = "xyes"],
966              [users_promises_ok=yes],
967              [users_promises_ok=no])
968     ],
969     [
970        AS_IF([test "x$have_pam" = "xyes" && \
971               test "x$have_userprogs" = "xyes"
972               test "x$ac_cv_func_fgetpwent" = "xyes" && \
973               test "x$ac_cv_func_fgetgrent" = "xyes"],
974              [users_promises_ok=yes],
975              [users_promises_ok=no])
976     ])
977], [
978  users_promises_ok=no
979])
980AM_CONDITIONAL(HAVE_USERS_PROMISE_DEPS, [test "x$users_promises_ok" = "xyes"])
981
982AC_CHECK_DECLS(getnetgrent, [], [], [[#include <netdb.h>]])
983AC_CHECK_FUNCS(getnetgrent)
984
985AC_CHECK_DECLS(setnetgrent, [], [], [[#include <netdb.h>]])
986AC_CHECK_FUNCS(setnetgrent)
987AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
988                                   [[extern int setnetgrent(const char *)]])],
989  [AC_DEFINE([SETNETGRENT_RETURNS_INT], 1, [Whether setnetgrent returns int])],
990  [AC_DEFINE([SETNETGRENT_RETURNS_INT], 0, [Whether setnetgrent returns int])])
991
992
993AC_CHECK_DECLS(endnetgrent, [], [], [[#include <netdb.h>]])
994AC_CHECK_FUNCS(endnetgrent)
995AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],
996                                   [[extern int endnetgrent(const char *)]])],
997  [AC_DEFINE([ENDNETGRENT_RETURNS_INT], 1, [Whether endnetgrent returns int])],
998  [AC_DEFINE([ENDNETGRENT_RETURNS_INT], 0, [Whether endnetgrent returns int])])
999
1000
1001AC_CHECK_FUNCS(sendto)
1002AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1003                                     #include <sys/socket.h>]],
1004                                   [[extern ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)]])],
1005    [AC_DEFINE([SENDTO_RETURNS_SSIZE_T], 1, [Whether sendto returns ssize_t])],
1006    [AC_DEFINE([SENDTO_RETURNS_SSIZE_T], 0, [Whether sendto does not returns ssize_t])])
1007
1008CF3_CHECK_PROPER_FUNC([ctime],
1009  [],
1010  [[#error ctime(3) may produce different results on different OSes. Let's have our POSIX-compliant implementation all the time]],
1011  [#define ctime rpl_ctime])
1012CF3_REPLACE_PROPER_FUNC([ctime])
1013
1014dnl Check whether mkdir accepts two parameters
1015CF3_CHECK_PROPER_FUNC([mkdir],
1016  [[#include <sys/stat.h>
1017    #include <sys/types.h>]],
1018  [[int mkdir(const char *pathname, mode_t mode);]],
1019  [#define mkdir rpl_mkdir])
1020
1021dnl Check for Win32 stat. We don't know to detect improper stat during
1022dnl compilation, so we resort to OS type detection.
1023
1024CF3_CHECK_PROPER_FUNC([stat],
1025  [[#include <sys/types.h>
1026    #include <sys/stat.h>]],
1027  [[#if defined(__MINGW32__)
1028    #error stat in Windows CRT ill-behaves
1029    #endif]],
1030  [])
1031
1032dnl Check for Win32 rename. We don't know how to detect improper rename (not
1033dnl removing target file if it exists) during cross-compilation, so we resort to
1034dnl OS type detection.
1035
1036CF3_CHECK_PROPER_FUNC([rename],
1037  [],
1038  [[#if defined(__MINGW32__)
1039    #error rename in Windows CRT ill-behaves
1040    #endif]],
1041  [#define rename rpl_rename])
1042
1043AC_CHECK_DECLS(mkdtemp)
1044AC_REPLACE_FUNCS(mkdtemp)
1045
1046AC_CHECK_DECLS(strrstr)
1047AC_REPLACE_FUNCS(strrstr)
1048
1049AC_CHECK_DECLS(stpncpy)
1050AC_REPLACE_FUNCS(stpncpy)
1051
1052AC_CHECK_FUNCS(seteuid setegid setreuid setregid)
1053AC_CHECK_FUNCS(uname gethostname chflags)
1054AC_CHECK_FUNCS(mkfifo statfs statvfs door)
1055AC_CHECK_FUNCS(sysinfo setsid sysconf)
1056AC_CHECK_FUNCS(getzoneid getzonenamebyid)
1057AC_CHECK_FUNCS(fpathconf)
1058
1059AC_CHECK_MEMBERS([struct stat.st_mtim, struct stat.st_mtimespec])
1060AC_CHECK_MEMBERS([struct stat.st_blocks])
1061
1062AC_MSG_CHECKING([for PRIuMAX/PRIdMAX macros])
1063AC_EGREP_CPP([primacros_found],
1064  AC_INCLUDES_DEFAULT
1065  [#include <inttypes.h>
1066  #if defined(PRIuMAX) && defined(PRIdMAX)
1067    primacros_found
1068  #endif
1069  ],
1070  [AC_MSG_RESULT(yes)],
1071  [AC_MSG_RESULT(no)
1072   AC_MSG_RESULT(Unable to find out how to scan intmax_t/uintmax_t types)])
1073
1074HW_FUNC_VSNPRINTF
1075HW_FUNC_SNPRINTF
1076HW_FUNC_VASPRINTF
1077HW_FUNC_ASPRINTF
1078
1079dnl dirfd might be a function or a macro
1080
1081AC_CHECK_DECLS(dirfd, [], [], [AC_INCLUDES_DEFAULT
1082#ifdef HAVE_DIRENT_H
1083# include <dirent.h>
1084#endif
1085])
1086
1087AC_CHECK_FUNCS(dirfd, [], [
1088  AC_MSG_CHECKING([for dirfd macro])
1089  AC_EGREP_CPP([dirfd_found],
1090    AC_INCLUDES_DEFAULT
1091    [#ifdef HAVE_DIRENT_H
1092    # include <dirent.h>
1093    #endif
1094    #ifdef dirfd
1095      dirfd_found
1096    #endif
1097    ],
1098  [AC_MSG_RESULT(yes)
1099  DIRFD_MACRO_FOUND=1],
1100  [AC_MSG_RESULT(no)])
1101  if test x$DIRFD_MACRO_FOUND = x; then
1102    AC_LIBOBJ([dirfd])
1103  fi])
1104
1105AC_CHECK_FUNCS(jail_get)
1106
1107dnl
1108dnl Various functions
1109dnl
1110
1111AC_SEARCH_LIBS(setsockopt, socket)
1112AC_SEARCH_LIBS(gethostent, nsl)
1113
1114AC_CHECK_FUNCS(socket)
1115AC_CHECK_FUNCS(setsockopt)
1116AC_CHECK_FUNCS(gethostent)
1117
1118AC_CHECK_TYPES(struct sockaddr_storage, [], [], [[
1119#if HAVE_WINSOCK2_H
1120    #include <winsock2.h>
1121#endif
1122#if HAVE_WS2TCPIP_H
1123    #include <ws2tcpip.h>
1124#else
1125    #include <sys/socket.h>
1126    #include <netdb.h>
1127#endif]])
1128
1129AC_CHECK_DECLS(getaddrinfo, [], [AC_LIBOBJ(getaddrinfo)], [[
1130#if HAVE_WINSOCK2_H
1131    #include <winsock2.h>
1132#endif
1133#if HAVE_WS2TCPIP_H
1134    #include <ws2tcpip.h>
1135#else
1136    #include <sys/socket.h>
1137    #include <netdb.h>
1138#endif
1139]])
1140
1141AC_CHECK_DECLS([[inet_ntop], [inet_pton]], [], [], [[#include <arpa/inet.h>]])
1142AC_REPLACE_FUNCS(inet_ntop inet_pton)
1143
1144AC_CHECK_FUNCS(getifaddrs)
1145
1146AC_CHECK_FUNCS(getprocs64)
1147
1148AC_CHECK_FUNC(lchown, AC_DEFINE(HAVE_LCHOWN, 1, [Whether to use lchown(3) to change ownerships]))
1149
1150AC_CHECK_DECLS(pthread_attr_setstacksize, [], [], [[#include <pthread.h>]])
1151AC_REPLACE_FUNCS(pthread_attr_setstacksize)
1152
1153AC_CHECK_DECLS(pthread_sigmask, [], [], [[#include <signal.h>]])
1154AC_REPLACE_FUNCS(pthread_sigmask)
1155
1156AC_CHECK_DECLS(sched_yield, [], [], [[#include <sched.h>]])
1157AC_CHECK_FUNCS(sched_yield)
1158
1159AC_CHECK_DECLS([openat], [], [], [[#define _GNU_SOURCE 1
1160                                   #include <fcntl.h>]])
1161AC_CHECK_DECLS([fstatat], [], [], [[#define _GNU_SOURCE 1
1162                                    #include <sys/stat.h>]])
1163AC_CHECK_DECLS([fchownat], [], [], [[#define _GNU_SOURCE 1
1164                                     #include <unistd.h>]])
1165AC_CHECK_DECLS([fchmodat], [], [], [[#define _GNU_SOURCE 1
1166                                    #include <sys/stat.h>]])
1167AC_CHECK_DECLS([readlinkat], [], [], [[#define _GNU_SOURCE 1
1168                                       #include <unistd.h>]])
1169AC_REPLACE_FUNCS(openat fstatat fchownat fchmodat readlinkat)
1170
1171AC_CHECK_DECLS([log2], [], [], [[#include <math.h>]])
1172AC_REPLACE_FUNCS(log2)
1173
1174dnl ######################################################################
1175dnl Required by cf-upgrade. It cannot be implemented in libcompat because
1176dnl cf-upgrade does not link to any libraries except libutils and only
1177dnl statically.
1178dnl ######################################################################
1179AC_CHECK_FUNC(fexecve, AC_DEFINE(HAVE_FEXECVE, 1, [Whether to use fexecve(3) to execute a new process]))
1180
1181dnl ######################################################################
1182dnl These need declarations here, but will be defined in the
1183dnl Enterprise Windows code.
1184dnl ######################################################################
1185
1186AC_CHECK_DECLS(alarm)
1187AC_CHECK_DECLS(chmod)
1188AC_CHECK_DECLS(chown)
1189AC_CHECK_DECLS(fchmod)
1190AC_CHECK_FUNCS(fchmod)
1191AC_CHECK_DECLS(uname)
1192AC_CHECK_DECLS(getuid)
1193AC_CHECK_DECLS(getgid)
1194AC_CHECK_DECLS(lstat)
1195AC_CHECK_FUNCS(sleep)
1196AC_CHECK_DECLS(socketpair, [], [], [[#include <sys/socket.h>]])
1197AC_CHECK_DECLS(fsync)
1198AC_CHECK_DECLS(glob, [], [], [[#include <glob.h>]])
1199
1200dnl ######################################################################
1201dnl Check for sa_len in struct sockaddr
1202dnl ######################################################################
1203
1204AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [
1205#include <sys/types.h>
1206#include <sys/socket.h>])
1207
1208AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr],,, [
1209#include <sys/ioctl.h>
1210#include <net/if.h>])
1211
1212dnl BSD uses sys/sysctl.h for CPU counting
1213AC_CHECK_HEADERS(sys/sysctl.h, [], [], [AC_INCLUDES_DEFAULT
1214#ifdef HAVE_SYS_PARAM_H
1215# include <sys/param.h>
1216#endif
1217])
1218
1219dnl ######################################################################
1220dnl Requirements for GetUptimeMinutes() to set $(sys.uptime)
1221dnl ######################################################################
1222dnl Linux sysinfo() call
1223AC_CHECK_MEMBERS([struct sysinfo.uptime], , , [#include <sys/sysinfo.h>])
1224
1225dnl BSD uses sys/sysctl.h to get time-of-boot
1226AC_CHECK_HEADERS(sys/sysctl.h, [], [], [AC_INCLUDES_DEFAULT
1227#ifdef HAVE_SYS_PARAM_H
1228# include <sys/param.h>
1229#endif
1230])
1231
1232dnl Solaris uses kstat.h to get time-of-boot
1233AC_CHECK_HEADERS(kstat.h)
1234dnl SystemV way to get uptime, highly portable
1235AC_CHECK_HEADERS(utmp.h)
1236dnl POSIX way to get uptime
1237AC_CHECK_HEADERS(utmpx.h)
1238
1239dnl #######################################################################
1240dnl Newer BSD systems don't have a compatible rtentry - use ortentry
1241dnl #######################################################################
1242
1243rtry=none
1244AC_MSG_CHECKING(for either struct rtentry or struct ortentry)
1245AC_EGREP_HEADER(rtentry, net/route.h, rtry=rtentry)
1246if test "$rtry" = rtentry; then
1247 AC_DEFINE(HAVE_RTENTRY, 1, [Do we have any route entry structure?])
1248fi
1249AC_EGREP_HEADER(ortentry, net/route.h, rtry=ortentry)
1250if test "$rtry" = ortentry; then
1251 AC_DEFINE(HAVE_ORTENTRY, 1, [The old route entry structure in newer BSDs])
1252fi
1253AC_MSG_RESULT([$rtry])
1254
1255dnl #######################################################################
1256dnl Enable extended attributes. Used for SELinux and ACLs
1257dnl #######################################################################
1258
1259AC_CHECK_FUNCS(llistxattr, [AC_DEFINE(WITH_XATTR, 1, [Define if you have a libc that supports extended attributes])])
1260AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h])
1261
1262AC_MSG_CHECKING([whether xattr functions have extra arguments])
1263AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
1264                                    #include <sys/xattr.h>],
1265                                    [(void)llistxattr("", 0, 0, 0);
1266                                    (void)lgetxattr("", "", 0, 0, 0, 0);
1267                                    (void)lsetxattr("", "", "", 0, 0, 0);
1268                                    (void)lremovexattr("", "", 0);])],
1269                  [AC_DEFINE(WITH_XATTR_EXTRA_ARGS, 1, [Define if your xattr implementation has extra arguments])]
1270                  [AC_MSG_RESULT([yes])],
1271                  [AC_MSG_RESULT([no])])
1272
1273dnl ######################################################################
1274dnl Give the chance to enable SELINUX
1275dnl ######################################################################
1276
1277AC_ARG_ENABLE([selinux], [AS_HELP_STRING([--enable-selinux], [Deprecated. SELinux support is always enabled])])
1278
1279dnl ######################################################################
1280dnl Collect all the options
1281dnl ######################################################################
1282
1283CORE_CPPFLAGS="$LMDB_CPPFLAGS $TOKYOCABINET_CPPFLAGS $QDBM_CPPFLAGS $PCRE_CPPFLAGS $OPENSSL_CPPFLAGS $SQLITE3_CPPFLAGS $LIBACL_CPPFLAGS $LIBCURL_CPPFLAGS $LIBYAML_CPPFLAGS $POSTGRESQL_CPPFLAGS $MYSQL_CPPFLAGS $LIBXML2_CPPFLAGS $CPPFLAGS"
1284CORE_CFLAGS="$LMDB_CFLAGS $TOKYOCABINET_CFLAGS $QDBM_CFLAGS $PCRE_CFLAGS $OPENSSL_CFLAGS $SQLITE3_CFLAGS $LIBACL_CFLAGS $LIBCURL_CFLAGS $LIBYAML_CFLAGS $POSTGRESQL_CFLAGS $MYSQL_CFLAGS $LIBXML2_CFLAGS $CFLAGS"
1285CORE_LDFLAGS="$LMDB_LDFLAGS $TOKYOCABINET_LDFLAGS $QDBM_LDFLAGS $PCRE_LDFLAGS $OPENSSL_LDFLAGS $SQLITE3_LDFLAGS $LIBACL_LDFLAGS $LIBCURL_LDFLAGS $LIBYAML_LDFLAGS $POSTGRESQL_LDFLAGS $MYSQL_LDFLAGS $LIBXML2_LDFLAGS $LDFLAGS"
1286CORE_LIBS="$LMDB_LIBS $TOKYOCABINET_LIBS $QDBM_LIBS $PCRE_LIBS $OPENSSL_LIBS $SQLITE3_LIBS $LIBACL_LIBS $LIBCURL_LIBS $LIBYAML_LIBS $POSTGRESQL_LIBS $MYSQL_LIBS $LIBXML2_LIBS $LIBS"
1287
1288dnl ######################################################################
1289dnl Make them available to subprojects.
1290dnl ######################################################################
1291
1292AC_SUBST([CORE_CPPFLAGS])
1293AC_SUBST([CORE_CFLAGS])
1294AC_SUBST([CORE_LDFLAGS])
1295AC_SUBST([CORE_LIBS])
1296AC_CONFIG_FILES([configure_flags.env])
1297
1298dnl ######################################################################
1299dnl OS specific stuff
1300dnl ######################################################################
1301
1302case "$target_os" in
1303
1304   solaris2.8|solaris2.9)
1305        AC_DEFINE(_XOPEN_SOURCE, 500, [UNIX 98])
1306        AC_DEFINE(__EXTENSIONS__, 1, [Extended UNIX 98 interfaces])
1307        ;;
1308   solaris2.10|solaris2.11)
1309        AC_DEFINE(_XOPEN_SOURCE, 600, [SUSv3])
1310        AC_DEFINE(__EXTENSIONS__, 1, [Extended UNIX 98 interfaces])
1311        ;;
1312   hpux*|hp-ux*)
1313        dnl pstat* functions may fail with EOVERFLOW without this.
1314        AC_DEFINE(_PSTAT64, 1, [Enable wide data structures everywhere])
1315        ;;
1316   aix*)
1317        CPPFLAGS="$CPPFLAGS -w"
1318        ;;
1319   linux*|*bsd*|*gnu*)
1320        AC_CHECK_LIB(nss_nis, yp_get_default_domain)
1321        ;;
1322   freebsd*|dragonfly*)
1323     AM_CONDITIONAL([FREEBSD], true)
1324        ;;
1325   netbsd*)
1326        ;;
1327   unicos*)
1328        ;;
1329   cray*)
1330        ;;
1331   qnx*)
1332        ;;
1333   openbsd*|obsd*)
1334        ;;
1335   sysv4.2MP|unix_sv*)
1336        ;;
1337   cygwin*)
1338        ;;
1339   mingw*)
1340        ;;
1341   sco*)
1342        ;;
1343   darwin*)
1344        ;;
1345   *)
1346        AC_MSG_ERROR(Unknown system type $target_os)
1347        ;;
1348esac
1349
1350m4_include([m4/cf3_platforms.m4])
1351
1352dnl #####################################################################
1353dnl Configure directories
1354dnl #####################################################################
1355
1356AC_ARG_WITH(workdir,
1357    [  --with-workdir=WORKDIR  default for internal (trusted) working directory ],
1358    [
1359        if test "x$withval" != x ; then
1360            WORKDIR="$withval"
1361            LOGDIR="$withval"
1362            PIDDIR="$withval"
1363        fi
1364    ],
1365)
1366
1367dnl Expand ${prefix} and whatnot in WORKDIR
1368
1369adl_RECURSIVE_EVAL("${WORKDIR}", WORKDIR)
1370
1371AC_DEFINE_UNQUOTED(WORKDIR, "${WORKDIR}", [Workdir location])
1372AC_SUBST(workdir, "${WORKDIR}")
1373
1374AC_ARG_WITH(masterdir,
1375    [  --with-masterdir=MASTERDIR  default for internal masterfiles directory ],
1376    [
1377        if test "x$withval" != x ; then
1378            MASTERDIR="$withval"
1379        fi
1380    ],
1381)
1382
1383dnl Expand ${prefix} and whatnot in MASTERDIR
1384
1385adl_RECURSIVE_EVAL("${MASTERDIR}", MASTERDIR)
1386
1387AC_DEFINE_UNQUOTED(MASTERDIR, "${MASTERDIR}", [Masterfiles directory location])
1388AC_SUBST(masterdir, "${MASTERDIR}")
1389
1390AC_ARG_WITH(inputdir,
1391    [  --with-inputdir=INPUTDIR  default for internal inputs directory ],
1392    [
1393        if test "x$withval" != x ; then
1394            INPUTDIR="$withval"
1395        fi
1396    ],
1397)
1398
1399dnl Expand ${prefix} and whatnot in INPUTDIR
1400
1401adl_RECURSIVE_EVAL("${INPUTDIR}", INPUTDIR)
1402
1403AC_DEFINE_UNQUOTED(INPUTDIR, "${INPUTDIR}", [Inputs directory location])
1404AC_SUBST(inputdir, "${INPUTDIR}")
1405
1406AC_ARG_WITH(logdir,
1407    [  --with-logdir=LOGDIR  default for internal log directory ],
1408    [
1409        if test "x$withval" != x ; then
1410            LOGDIR="$withval"
1411        fi
1412    ],
1413)
1414
1415dnl Expand ${prefix} and whatnot in LOGDIR
1416
1417adl_RECURSIVE_EVAL("${LOGDIR}", LOGDIR)
1418
1419AC_DEFINE_UNQUOTED(LOGDIR, "${LOGDIR}", [Logdir location])
1420AC_SUBST(logdir, "${LOGDIR}")
1421
1422AC_ARG_WITH(piddir,
1423    [  --with-piddir=LOGDIR  default for internal pid directory ],
1424    [
1425        if test "x$withval" != x ; then
1426            PIDDIR="$withval"
1427        fi
1428    ],
1429)
1430
1431dnl Expand ${prefix} and whatnot in PIDDIR
1432
1433adl_RECURSIVE_EVAL("${PIDDIR}", PIDDIR)
1434
1435AC_DEFINE_UNQUOTED(PIDDIR, "${PIDDIR}", [piddir location])
1436AC_SUBST(piddir, "${PIDDIR}")
1437
1438AC_ARG_WITH(statedir,
1439    [  --with-statedir=STATEDIR  default for internal state directory ],
1440    [
1441        if test "x$withval" != x ; then
1442            STATEDIR="$withval"
1443        fi
1444    ],
1445)
1446
1447dnl Expand ${prefix} and whatnot in STATEDIR
1448
1449adl_RECURSIVE_EVAL("${STATEDIR}", STATEDIR)
1450
1451AC_DEFINE_UNQUOTED(STATEDIR, "${STATEDIR}", [State directory location])
1452AC_SUBST(statedir, "${STATEDIR}")
1453
1454AC_ARG_WITH(shell, [AS_HELP_STRING([--with-shell=PATH],
1455                   [Specify path to POSIX-compatible shell (if not /bin/sh)])],
1456                   [],
1457                   [with_shell=/bin/sh])
1458
1459dnl Expand ${prefix} and whatnot in bindir
1460adl_RECURSIVE_EVAL("${bindir}", bindir)
1461
1462AC_DEFINE_UNQUOTED(BINDIR, "${bindir}", [binaries location])
1463AC_SUBST(bindir, "${bindir}")
1464
1465
1466if test "x$with_shell" = "xno"; then
1467   AC_MSG_ERROR([Please specify full path to POSIX-compatible shell])
1468fi
1469AC_DEFINE_UNQUOTED(SHELL_PATH, "$with_shell", [Path to the POSIX-compatible shell])
1470
1471dnl ######################################################################
1472dnl init.d script installation
1473dnl ######################################################################
1474
1475AC_ARG_WITH(init-script, AS_HELP_STRING([--with-init-script=PATH],
1476    [Install init.d script in given path. The default is no, but if specified, the default path is platform specific.]),
1477[
1478    if test -n "$withval" && test "x$withval" != "xno"; then
1479        if test "x$withval" = "xyes"; then
1480            AS_CASE(["$target_os"],
1481            [aix*],
1482            [
1483                INIT_D_PATH=/etc/rc.d/init.d
1484            ],
1485            [hpux*],
1486            [
1487                INIT_D_PATH=/sbin/init.d
1488            ],
1489            [
1490                INIT_D_PATH=/etc/init.d
1491            ])
1492        else
1493            INIT_D_PATH="$withval"
1494        fi
1495        AC_SUBST([INIT_D_PATH])
1496        AC_CONFIG_FILES([misc/init.d/cfengine3], [chmod +x misc/init.d/cfengine3])
1497    fi
1498])
1499AM_CONDITIONAL([WITH_INIT_D_SCRIPT], [test -n "$INIT_D_PATH"])
1500
1501dnl ######################################################################
1502dnl systemd unit file installation
1503dnl ######################################################################
1504
1505SYSTEMD_SERVICE_PATH=""
1506
1507AC_ARG_WITH(systemd-service, AS_HELP_STRING([--with-systemd-service=PATH],
1508    [Install systemd service file in given path. The default is no, but if specified, the default path is /usr/lib/systemd/system.]),
1509[
1510    if test -n "$withval" && test "x$withval" != "xno"; then
1511        if test "x$withval" = "xyes"; then
1512            SYSTEMD_SERVICE_PATH=/usr/lib/systemd/system
1513        else
1514            SYSTEMD_SERVICE_PATH="$withval"
1515        fi
1516    fi
1517]
1518,
1519[
1520    AC_PATH_PROG([systemctl], [systemctl], [no])
1521    AS_IF([test "x$systemctl" == "xno"],
1522    [AC_MSG_CHECKING([Not a systemd system])],
1523    [
1524        SYSTEMD_SERVICE_PATH=/usr/lib/systemd/system
1525    ])
1526])
1527
1528AS_IF([test "x$SYSTEMD_SERVICE_PATH" = "x"], [], [
1529    AC_SUBST([SYSTEMD_SERVICE_PATH])
1530    AC_CONFIG_FILES([misc/systemd/cfengine3.service])
1531    AC_CONFIG_FILES([misc/systemd/cf-apache.service])
1532    AC_CONFIG_FILES([misc/systemd/cf-execd.service])
1533    AC_CONFIG_FILES([misc/systemd/cf-hub.service])
1534    AC_CONFIG_FILES([misc/systemd/cf-monitord.service])
1535    AC_CONFIG_FILES([misc/systemd/cf-postgres.service])
1536    AC_CONFIG_FILES([misc/systemd/cf-runalerts.service])
1537    AC_CONFIG_FILES([misc/systemd/cf-serverd.service])
1538])
1539
1540AM_CONDITIONAL([WITH_SYSTEMD_SERVICE], [test -n "$SYSTEMD_SERVICE_PATH"])
1541
1542AC_ARG_WITH(environment-path, AS_HELP_STRING([--with-environment-path=PATH],
1543    [Specifies the location of the environment files for the platform. Currently used only by systemd.]))
1544OS_ENVIRONMENT_PATH=
1545if test -z "$with_environment_path" || test "$with_environment_path" = "yes"; then
1546    if test -n "$SYSTEMD_SERVICE_PATH"; then
1547        for i in /etc/sysconfig /etc/default; do
1548            if test -d $i; then
1549                OS_ENVIRONMENT_PATH=$i
1550                break
1551            fi
1552        done
1553        if test -z "$OS_ENVIRONMENT_PATH"; then
1554            AC_MSG_ERROR([Unable to detect location of environment files on the platform (e.g. '/etc/sysconfig'). Please specify it using --with-environment-path, or turn off systemd support.])
1555        fi
1556    fi
1557else
1558    if test "$with_environment_path" = "no"; then
1559        if test -n "$SYSTEMD_SERVICE_PATH"; then
1560            AC_MSG_ERROR([It is not possible to both specify systemd support and not provide an environment path with --without-environment-path.])
1561        fi
1562    else
1563        OS_ENVIRONMENT_PATH="$with_environment_path"
1564    fi
1565fi
1566AC_SUBST([OS_ENVIRONMENT_PATH])
1567
1568dnl #####################################################################
1569dnl SELinux policy build and installation
1570dnl #####################################################################
1571AC_ARG_WITH(selinux-policy,
1572            AS_HELP_STRING([--with-selinux-policy],
1573                           [Whether to build and install SELinux policy (default: no)]),
1574            [], [with_selinux_policy=no])
1575AM_CONDITIONAL([WITH_SELINUX], [test "x$with_selinux_policy" != "xno"])
1576
1577
1578dnl #####################################################################
1579dnl Hostname and Version stuff
1580dnl #####################################################################
1581
1582AC_PATH_PROG(HOSTNAME, hostname, "", $PATH)
1583
1584AC_DEFINE_UNQUOTED(AUTOCONF_HOSTNAME, "`$HOSTNAME`", [Special CFEngine symbol])
1585AC_DEFINE_UNQUOTED(AUTOCONF_SYSNAME, "$target_os", [Speial CFEngine symbol])
1586
1587
1588dnl #####################################################################
1589dnl xen cpuid-based hvm detection
1590dnl #####################################################################
1591
1592AC_MSG_CHECKING(for Xen cpuid-based HVM detection)
1593if test x"$GCC" = "xyes"; then
1594    case $host_cpu in
1595        i[[3456]]86*|x86_64*|amd64)
1596            AC_DEFINE(XEN_CPUID_SUPPORT, 1, [Define if XEN cpuid-based HVM detection is available.])
1597            AC_MSG_RESULT(yes)
1598            ;;
1599        *)
1600            AC_MSG_RESULT(no)
1601            ;;
1602    esac
1603else
1604    AC_MSG_RESULT(no)
1605fi
1606
1607dnl
1608dnl Code coverage
1609dnl
1610
1611AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [Enable code coverage]),
1612              [use_coverage=$enableval], [use_coverage=no])
1613
1614if test "x$use_coverage" = "xyes"; then
1615  if test "$GCC" != "yes"; then
1616    AC_MSG_ERROR([GCC is required for --enable-coverage])
1617  fi
1618
1619  if test "$debug" != "yes"; then
1620    AC_MSG_ERROR([--enable-debug is required for --enable-coverage])
1621  fi
1622
1623  AC_CHECK_PROG(LCOV, lcov, lcov)
1624  AC_CHECK_PROG(LCOV_GENHTML, genhtml, genhtml)
1625
1626  if test -z "$LCOV"; then
1627    AC_MSG_ERROR([Cannot find lcov from the LTP package])
1628  fi
1629
1630  if test -z "$LCOV_GENHTML"; then
1631    AC_MSG_ERROR([Could not find genhtml from the LTP package])
1632  fi
1633
1634  dnl Remove all optimization flags from CFLAGS
1635  changequote({,})
1636  CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
1637  changequote([,])
1638
1639  dnl Add the special gcc flags
1640  CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
1641  LDFLAGS="$LDFLAGS -lgcov"
1642  # Need to set ENABLE_COVERAGE so that tests/unit/Makefile.am can adapt for one
1643  # test which needs gcov stubs if core not built with coverage.
1644  AM_CONDITIONAL([ENABLE_COVERAGE], true)
1645else
1646  AM_CONDITIONAL([ENABLE_COVERAGE], false)
1647fi
1648
1649#
1650# Populate contents of config.post.h
1651#
1652AC_SUBST(post_macros)
1653AM_SUBST_NOTMAKE(post_macros)
1654
1655dnl ######################################################################
1656dnl Check how file descriptor transfers are supported between proceses.
1657dnl ######################################################################
1658AC_CHECK_MEMBER([struct msghdr.msg_control],
1659                [AC_DEFINE([HAVE_MSGHDR_MSG_CONTROL], [1], [Define to 1 if SCM_RIGHTS supported])],
1660                [AC_DEFINE([HAVE_NO_MSGHDR_MSG_CONTROL], [1], [Define to 1 if SCM_RIGHTS support])],
1661                [[#include <sys/types.h>
1662                  #include <sys/socket.h>]])
1663
1664AC_CHECK_MEMBER([struct msghdr.msg_accrights],
1665                [AC_DEFINE([HAVE_MSGHDR_ACCRIGHTS], [1], [Define to 1 if BSD .msg_accrights supported])],
1666                [AC_DEFINE([HAVE_NO_MSGHDR_ACCRIGHTS], [1], [Define to 1 if no BSD .msg_accrights support])],
1667                [[#include <sys/types.h>
1668                  #include <sys/socket.h>]])
1669
1670dnl ######################################################################
1671dnl Summarize
1672dnl ######################################################################
1673
1674AC_MSG_RESULT( )
1675
1676AC_MSG_RESULT(Summary:)
1677AC_MSG_RESULT(> Version: $cfengine_version)
1678
1679AC_MSG_RESULT([> Required libraries])
1680
1681AC_MSG_RESULT([-> OpenSSL: $OPENSSL_PATH])
1682
1683AC_MSG_RESULT([-> PCRE: $PCRE_PATH])
1684
1685if test $WITH_TOKYO = 1; then
1686  AC_MSG_RESULT([-> DB: Tokyo Cabinet: $TOKYOCABINET_PATH])
1687elif test $WITH_QDBM = 1; then
1688  AC_MSG_RESULT([-> DB: QDBM: $QDBM_PATH])
1689fi
1690
1691AC_MSG_RESULT([> Optional libraries])
1692
1693if test "x$ac_cv_lib_mysqlclient_mysql_real_connect" = "xyes"; then
1694  AC_MSG_RESULT([-> MySQL connector: $MYSQL_PATH])
1695else
1696  AC_MSG_RESULT([-> MySQL connector: disabled])
1697fi
1698
1699if test "x$ac_cv_lib_pq_PQconnectdb" = "xyes"; then
1700  AC_MSG_RESULT([-> PostgreSQL connector: $POSTGRESQL_PATH])
1701else
1702  AC_MSG_RESULT([-> PostgreSQL connector: disabled])
1703fi
1704
1705if test $WITH_LMDB = 1; then
1706  AC_MSG_RESULT([-> DB: Lightning MDB: $LMDB_PATH])
1707elif test $WITH_TOKYO = 1; then
1708  AC_MSG_RESULT([-> DB: Tokyo Cabinet: $TOKYOCABINET_PATH])
1709elif test $WITH_QDBM = 1; then
1710  AC_MSG_RESULT([-> DB: QDBM: $QDBM_PATH])
1711fi
1712
1713if test "x$ac_cv_lib_virt_virConnectOpen" = xyes; then
1714  AC_MSG_RESULT([-> libvirt: $LIBVIRT_PATH])
1715else
1716  AC_MSG_RESULT([-> libvirt: disabled])
1717fi
1718
1719if test "x$ac_cv_lib_acl_acl_init" = xyes; then
1720  AC_MSG_RESULT([-> libacl: $LIBACL_PATH])
1721else
1722  AC_MSG_RESULT([-> libacl: disabled])
1723fi
1724
1725if test "x$ac_cv_lib_curl_curl_global_init" = xyes; then
1726  AC_MSG_RESULT([-> libcurl: $LIBCURL_PATH])
1727else
1728  AC_MSG_RESULT([-> libcurl: disabled])
1729fi
1730
1731if test "x$ac_cv_lib_yaml_yaml_parser_initialize" = xyes; then
1732  AC_MSG_RESULT([-> libyaml: $LIBYAML_PATH])
1733else
1734  AC_MSG_RESULT([-> libyaml: disabled])
1735fi
1736
1737if test "x$ac_cv_lib_xml2_xmlFirstElementChild" = xyes; then
1738  AC_MSG_RESULT([-> libxml2: $LIBXML2_PATH])
1739else
1740  AC_MSG_RESULT([-> libxml2: disabled])
1741fi
1742
1743if test "x$users_promises_ok" = "xyes"; then
1744  AC_MSG_RESULT([-> User promises: PAM/user* tools])
1745else
1746  AC_MSG_RESULT([-> User promises: disabled])
1747fi
1748
1749if test "x$enable_builtin_extensions" = "xyes"; then
1750  AC_MSG_RESULT([-> Enterprise extensions: Built in])
1751else
1752  AC_MSG_RESULT([-> Enterprise extensions: Plugin or not included])
1753fi
1754
1755if test -n "$INIT_D_PATH"; then
1756  AC_MSG_RESULT([-> init.d script: $INIT_D_PATH])
1757else
1758  AC_MSG_RESULT([-> init.d script: disabled])
1759fi
1760
1761if test -n "$SYSTEMD_SERVICE_PATH"; then
1762  AC_MSG_RESULT([-> Systemd service: $SYSTEMD_SERVICE_PATH])
1763else
1764  AC_MSG_RESULT([-> Systemd service: disabled])
1765fi
1766
1767if test -n "$OS_ENVIRONMENT_PATH"; then
1768  AC_MSG_RESULT([-> Path of platform environment files: $OS_ENVIRONMENT_PATH])
1769fi
1770
1771if test "x$with_selinux_policy" != "xno"; then
1772  AC_MSG_RESULT([-> SELinux policy: enabled])
1773else
1774  AC_MSG_RESULT([-> SELinux policy: disabled])
1775fi
1776
1777m4_indir(incstart[]incend, [nova/config.m4])
1778
1779AC_MSG_RESULT([-> Workdir: $WORKDIR])
1780AC_MSG_RESULT([-> Masterdir: $MASTERDIR])
1781AC_MSG_RESULT([-> Inputdir: $INPUTDIR])
1782AC_MSG_RESULT([-> Logdir: $LOGDIR])
1783AC_MSG_RESULT([-> Piddir: $PIDDIR])
1784AC_MSG_RESULT([-> Statedir: $STATEDIR])
1785AC_MSG_RESULT([-> bindir: $bindir])
1786
1787AC_MSG_RESULT( )
1788
1789dnl ######################################################################
1790dnl Now make the Makefiles
1791dnl ######################################################################
1792
1793AC_CONFIG_FILES([Makefile
1794    libcfnet/Makefile
1795    libenv/Makefile
1796    libpromises/Makefile
1797    cf-agent/Makefile
1798    cf-check/Makefile
1799    cf-promises/Makefile
1800    cf-execd/Makefile
1801    cf-key/Makefile
1802    cf-monitord/Makefile
1803    cf-upgrade/Makefile
1804    cf-runagent/Makefile
1805    cf-serverd/Makefile
1806    cf-testd/Makefile
1807    cf-net/Makefile
1808    cf-secret/Makefile
1809    config.post.h
1810    contrib/vagrant-ci/centos-6-x64/Makefile
1811    misc/Makefile
1812    misc/selinux/Makefile
1813    ext/Makefile
1814    examples/Makefile
1815    tests/Makefile
1816    tests/acceptance/Makefile
1817    tests/acceptance/25_cf-execd/Makefile
1818    tests/unit/Makefile
1819    tests/load/Makefile
1820    tests/static-check/Makefile
1821    tests/valgrind-check/Makefile])
1822
1823# Run autoconf/configure in libutils, generating necessary makefiles:
1824AC_CONFIG_SUBDIRS([libntech])
1825
1826AC_OUTPUT
1827
1828AC_MSG_RESULT(DONE: Configuration done. Run make/gmake to build CFEngine Community.)
1829