2 # Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
4 # Authors: Fabio M. Di Nitto <fabbione@kronosnet.org>
5 # Federico Simoncelli <fsimon@kronosnet.org>
7 # This software licensed under GPL-2.0+, LGPL-2.0+
11 # Process this file with autoconf to produce a configure script.
16 m4_esyscmd([build-aux/git-version-gen .tarball-version .gitarchivever]),
17 [devel@lists.kronosnet.org])
18 # Don't let AC_PROC_CC (invoked by AC_USE_SYSTEM_EXTENSIONS) replace
19 # undefined CFLAGS with -g -O2, overriding our special OPT_CFLAGS.
21 AC_USE_SYSTEM_EXTENSIONS
22 AM_INIT_AUTOMAKE([1.13 dist-bzip2 dist-xz color-tests -Wno-portability subdir-objects])
25 # --enable-new-dtags: Use RUNPATH instead of RPATH.
26 # It is necessary to have this done before libtool does linker detection.
27 # See also: https://github.com/kronosnet/kronosnet/issues/107
28 # --as-needed: Modern systems have builtin ceil() making -lm superfluous but
29 # AC_SEARCH_LIBS can't detect this because it tests with a false prototype
30 AX_CHECK_LINK_FLAG([-Wl,--enable-new-dtags],
31 [AM_LDFLAGS=-Wl,--enable-new-dtags],
32 [AC_MSG_ERROR(["Linker support for --enable-new-dtags is required"])])
33 AX_CHECK_LINK_FLAG([-Wl,--as-needed], [AM_LDFLAGS="$AM_LDFLAGS -Wl,--as-needed"])
35 AC_SUBST([AM_LDFLAGS])
36 saved_LDFLAGS="$LDFLAGS"
37 LDFLAGS="$AM_LDFLAGS $LDFLAGS"
39 LDFLAGS="$saved_LDFLAGS"
41 AC_CONFIG_MACRO_DIR([m4])
42 AC_CONFIG_SRCDIR([kronosnetd/main.c])
43 AC_CONFIG_HEADERS([config.h])
49 systemddir=${prefix}/lib/systemd/system
51 if test "$prefix" = "NONE"; then
53 if test "$localstatedir" = "\${prefix}/var"; then
56 if test "$sysconfdir" = "\${prefix}/etc"; then
59 if test "$systemddir" = "NONE/lib/systemd/system"; then
60 systemddir=/lib/systemd/system
62 if test "$libdir" = "\${exec_prefix}/lib"; then
63 if test -e /usr/lib64; then
77 if test "x$ac_cv_prog_cc_c99" = "xno"; then
78 AC_MSG_ERROR(["C99 support is required"])
85 AC_CHECK_PROGS([VALGRIND_EXEC], [valgrind])
86 AM_CONDITIONAL([HAS_VALGRIND], [test x$VALGRIND_EXEC != "x"])
88 # KNET_OPTION_DEFINES(stem,type,detection code)
89 # stem: enters name of option, Automake conditional and preprocessor define
90 # type: compress or crypto, determines where the default comes from
91 AC_DEFUN([KNET_OPTION_DEFINES],[
92 AC_ARG_ENABLE([$2-$1],[AS_HELP_STRING([--disable-$2-$1],[disable libknet $1 support])],,
93 [enable_$2_$1="$enable_$2_all"])
94 AM_CONDITIONAL([BUILD_]m4_toupper([$2_$1]),[test "x$enable_$2_$1" = xyes])
95 if test "x$enable_$2_$1" = xyes; then
98 AC_DEFINE_UNQUOTED([WITH_]m4_toupper([$2_$1]), [`test "x$enable_$2_$1" != xyes; echo $?`], $1 $2 [built in])
102 [AS_HELP_STRING([--disable-man],[disable man page creation])],,
103 [ enable_man="yes" ])
104 AM_CONDITIONAL([BUILD_MAN], [test x$enable_man = xyes])
106 AC_ARG_ENABLE([libknet-sctp],
107 [AS_HELP_STRING([--disable-libknet-sctp],[disable libknet SCTP support])],,
108 [ enable_libknet_sctp="yes" ])
109 AM_CONDITIONAL([BUILD_SCTP], [test x$enable_libknet_sctp = xyes])
111 AC_ARG_ENABLE([crypto-all],
112 [AS_HELP_STRING([--disable-crypto-all],[disable libknet all crypto modules support])],,
113 [ enable_crypto_all="yes" ])
115 KNET_OPTION_DEFINES([nss],[crypto],[PKG_CHECK_MODULES([nss], [nss])])
116 KNET_OPTION_DEFINES([openssl],[crypto],[
117 PKG_CHECK_MODULES([openssl],[libcrypto < 1.1],
118 [AC_DEFINE_UNQUOTED([BUILDCRYPTOOPENSSL10], [1], [openssl 1.0 crypto])],
119 [PKG_CHECK_MODULES([openssl],[libcrypto >= 1.1],
120 [AC_DEFINE_UNQUOTED([BUILDCRYPTOOPENSSL11], [1], [openssl 1.1 crypto])])])
123 AC_ARG_ENABLE([compress-all],
124 [AS_HELP_STRING([--disable-compress-all],[disable libknet all compress modules support])],,
125 [ enable_compress_all="yes" ])
127 KNET_OPTION_DEFINES([zlib],[compress],[PKG_CHECK_MODULES([zlib], [zlib])])
128 KNET_OPTION_DEFINES([lz4],[compress],[PKG_CHECK_MODULES([liblz4], [liblz4])])
129 KNET_OPTION_DEFINES([lzo2],[compress],[
130 PKG_CHECK_MODULES([lzo2], [lzo2],
131 [# work around broken pkg-config file in v2.10
132 AC_SUBST([lzo2_CFLAGS],[`echo $lzo2_CFLAGS | sed 's,/lzo *, ,'`])],
133 [AC_CHECK_HEADERS([lzo/lzo1x.h],
134 [AC_CHECK_LIB([lzo2], [lzo1x_decompress_safe],
135 [AC_SUBST([lzo2_LIBS], [-llzo2])])],
136 [AC_MSG_ERROR(["missing required lzo/lzo1x.h header"])])])
138 KNET_OPTION_DEFINES([lzma],[compress],[PKG_CHECK_MODULES([liblzma], [liblzma])])
139 KNET_OPTION_DEFINES([bzip2],[compress],[
140 PKG_CHECK_MODULES([bzip2], [bzip2],,
141 [AC_CHECK_HEADERS([bzlib.h],
142 [AC_CHECK_LIB([bz2], [BZ2_bzBuffToBuffCompress],
143 [AC_SUBST([bzip2_LIBS], [-lbz2])])],
144 [AC_MSG_ERROR(["missing required bzlib.h"])])])
148 [AS_HELP_STRING([--enable-poc],[enable building poc code])],,
150 AM_CONDITIONAL([BUILD_POC], [test x$enable_poc = xyes])
152 AC_ARG_ENABLE([kronosnetd],
153 [AS_HELP_STRING([--enable-kronosnetd],[Kronosnetd support])],,
154 [ enable_kronosnetd="no" ])
155 AM_CONDITIONAL([BUILD_KRONOSNETD], [test x$enable_kronosnetd = xyes])
157 AC_ARG_ENABLE([runautogen],
158 [AS_HELP_STRING([--enable-runautogen],[run autogen.sh])],,
159 [ enable_runautogen="no" ])
160 AM_CONDITIONAL([BUILD_RUNAUTOGEN], [test x$enable_runautogen = xyes])
162 override_rpm_debuginfo_option="yes"
163 AC_ARG_ENABLE([rpm-debuginfo],
164 [AS_HELP_STRING([--enable-rpm-debuginfo],[build debuginfo packages])],,
165 [ enable_rpm_debuginfo="no", override_rpm_debuginfo_option="no" ])
166 AM_CONDITIONAL([BUILD_RPM_DEBUGINFO], [test x$enable_rpm_debuginfo = xyes])
167 AM_CONDITIONAL([OVERRIDE_RPM_DEBUGINFO], [test x$override_rpm_debuginfo_option = xyes])
169 AC_ARG_ENABLE([libnozzle],
170 [AS_HELP_STRING([--enable-libnozzle],[libnozzle support])],,
171 [ enable_libnozzle="yes" ])
173 if test "x$enable_kronosnetd" = xyes; then
176 AM_CONDITIONAL([BUILD_LIBNOZZLE], [test x$enable_libnozzle = xyes])
178 ## local helper functions
179 # this function checks if CC support options passed as
180 # args. Global CPPFLAGS are ignored during this test.
182 saveCPPFLAGS="$CPPFLAGS"
184 if echo $CC | grep -q clang; then
185 CPPFLAGS="-Werror $CPPFLAGS"
187 AC_MSG_CHECKING([whether $CC supports "$@"])
188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
189 [RC=0; AC_MSG_RESULT([yes])],
190 [RC=1; AC_MSG_RESULT([no])])
191 CPPFLAGS="$saveCPPFLAGS"
195 # Checks for libraries.
196 AX_PTHREAD(,[AC_MSG_ERROR([POSIX threads support is required])])
199 AC_SEARCH_LIBS([ceil], [m], , [AC_MSG_ERROR([ceil not found])])
200 AC_SUBST([m_LIBS], [$LIBS])
202 AC_SEARCH_LIBS([clock_gettime], [rt], , [AC_MSG_ERROR([clock_gettime not found])])
203 AC_SUBST([rt_LIBS], [$LIBS])
205 AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
206 AC_SUBST([dl_LIBS], [$LIBS])
211 AC_MSG_CHECKING([for os in ${host_os}])
214 AC_DEFINE_UNQUOTED([KNET_LINUX], [1], [Compiling for Linux platform])
215 AC_MSG_RESULT([Linux])
218 AC_DEFINE_UNQUOTED([KNET_BSD], [1], [Compiling for BSD platform])
222 AC_MSG_ERROR([Unsupported OS? hmmmm])
226 # Checks for header files.
227 AC_CHECK_HEADERS([sys/epoll.h])
228 AC_CHECK_FUNCS([kevent])
229 # if neither sys/epoll.h nor kevent are present, we should fail.
231 if test "x$ac_cv_header_sys_epoll_h" = xno && test "x$ac_cv_func_kevent" = xno; then
232 AC_MSG_ERROR([Both epoll and kevent unavailable on this OS])
235 if test "x$ac_cv_header_sys_epoll_h" = xyes && test "x$ac_cv_func_kevent" = xyes; then
236 AC_MSG_ERROR([Both epoll and kevent available on this OS, please contact the maintainers to fix the code])
239 if test "x$enable_libknet_sctp" = xyes; then
240 AC_CHECK_HEADERS([netinet/sctp.h],, [AC_MSG_ERROR(["missing required SCTP headers"])])
243 # Checks for typedefs, structures, and compiler characteristics.
257 if test "x$enable_man" = "xyes"; then
258 AC_ARG_VAR([DOXYGEN], [override doxygen executable])
259 AC_CHECK_PROGS([DOXYGEN], [doxygen], [no])
260 if test "x$DOXYGEN" = xno; then
261 AC_MSG_ERROR(["Doxygen command not found"])
263 # required by doxyxml to build man pages dynamically
264 # Don't let AC_PROC_CC (invoked by AX_PROG_CC_FOR_BUILD) replace
265 # undefined CFLAGS_FOR_BUILD with -g -O2, overriding our special OPT_CFLAGS.
266 : ${CFLAGS_FOR_BUILD=""}
268 saved_PKG_CONFIG="$PKG_CONFIG"
269 saved_ac_cv_path_PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
270 unset PKG_CONFIG ac_cv_path_PKG_CONFIG
271 AC_PATH_PROG([PKG_CONFIG], [pkg-config])
272 PKG_CHECK_MODULES([libqb_BUILD], [libqb])
273 PKG_CHECK_MODULES([libxml_BUILD], [libxml-2.0])
274 PKG_CONFIG="$saved_PKG_CONFIG"
275 ac_cv_path_PKG_CONFIG="$saved_ac_cv_path_PKG_CONFIG"
278 # checks for libnozzle
279 if test "x$enable_libnozzle" = xyes; then
280 if `echo $host_os | grep -q linux`; then
281 PKG_CHECK_MODULES([libnl], [libnl-3.0])
282 PKG_CHECK_MODULES([libnlroute], [libnl-route-3.0 >= 3.3], [],
283 [PKG_CHECK_MODULES([libnlroute], [libnl-route-3.0 < 3.3],
284 [AC_DEFINE_UNQUOTED([LIBNL3_WORKAROUND], [1], [Enable libnl < 3.3 build workaround])], [])])
288 # checks for kronosnetd
289 if test "x$enable_kronosnetd" = xyes; then
290 AC_CHECK_HEADERS([security/pam_appl.h],
291 [AC_CHECK_LIB([pam], [pam_start],
292 [AC_SUBST([pam_LIBS], [-lpam])],
293 [AC_MSG_ERROR([Unable to find LinuxPAM devel files])])])
295 AC_CHECK_HEADERS([security/pam_misc.h],
296 [AC_CHECK_LIB([pam_misc], [misc_conv],
297 [AC_SUBST([pam_misc_LIBS], [-lpam_misc])],
298 [AC_MSG_ERROR([Unable to find LinuxPAM MISC devel files])])])
300 PKG_CHECK_MODULES([libqb], [libqb])
302 AC_CHECK_LIB([qb], [qb_log_thread_priority_set],
303 [have_qb_log_thread_priority_set="yes"],
304 [have_qb_log_thread_priority_set="no"])
305 if test "x${have_qb_log_thread_priority_set}" = xyes; then
306 AC_DEFINE_UNQUOTED([HAVE_QB_LOG_THREAD_PRIORITY_SET], [1], [have qb_log_thread_priority_set])
311 AC_ARG_ENABLE([debug],
312 [AS_HELP_STRING([--enable-debug],[enable debug build])])
314 AC_ARG_WITH([initdefaultdir],
315 [AS_HELP_STRING([--with-initdefaultdir=DIR],[path to /etc/sysconfig or /etc/default dir])],
316 [ INITDEFAULTDIR="$withval" ],
317 [ INITDEFAULTDIR="$sysconfdir/default" ])
319 AC_ARG_WITH([initddir],
320 [AS_HELP_STRING([--with-initddir=DIR],[path to init script directory])],
321 [ INITDDIR="$withval" ],
322 [ INITDDIR="$sysconfdir/init.d" ])
324 AC_ARG_WITH([systemddir],
325 [AS_HELP_STRING([--with-systemddir=DIR],[path to systemd unit files directory])],
326 [ SYSTEMDDIR="$withval" ],
327 [ SYSTEMDDIR="$systemddir" ])
329 AC_ARG_WITH([syslogfacility],
330 [AS_HELP_STRING([--with-syslogfacility=FACILITY],[default syslog facility])],
331 [ SYSLOGFACILITY="$withval" ],
332 [ SYSLOGFACILITY="LOG_DAEMON" ])
334 AC_ARG_WITH([sysloglevel],
335 [AS_HELP_STRING([--with-sysloglevel=LEVEL],[default syslog level])],
336 [ SYSLOGLEVEL="$withval" ],
337 [ SYSLOGLEVEL="LOG_INFO" ])
339 AC_ARG_WITH([defaultadmgroup],
340 [AS_HELP_STRING([--with-defaultadmgroup=GROUP],
341 [define PAM group. Users part of this group will be allowed to configure
342 kronosnet. Others will only receive read-only rights.])],
343 [ DEFAULTADMGROUP="$withval" ],
344 [ DEFAULTADMGROUP="kronosnetadm" ])
347 LOGDIR=${localstatedir}/log/
348 RUNDIR=${localstatedir}/run/
349 DEFAULT_CONFIG_DIR=${sysconfdir}/kronosnet
353 AC_SUBST([DEFAULT_CONFIG_DIR])
354 AC_SUBST([INITDEFAULTDIR])
356 AC_SUBST([SYSTEMDDIR])
358 AC_SUBST([DEFAULTADMGROUP])
360 AC_DEFINE_UNQUOTED([DEFAULT_CONFIG_DIR],
361 ["$(eval echo ${DEFAULT_CONFIG_DIR})"],
362 [Default config directory])
364 AC_DEFINE_UNQUOTED([DEFAULT_CONFIG_FILE],
365 ["$(eval echo ${DEFAULT_CONFIG_DIR}/kronosnetd.conf)"],
366 [Default config file])
368 AC_DEFINE_UNQUOTED([LOGDIR],
369 ["$(eval echo ${LOGDIR})"],
370 [Default logging directory])
372 AC_DEFINE_UNQUOTED([DEFAULT_LOG_FILE],
373 ["$(eval echo ${LOGDIR}/kronosnetd.log)"],
376 AC_DEFINE_UNQUOTED([RUNDIR],
377 ["$(eval echo ${RUNDIR})"],
378 [Default run directory])
380 AC_DEFINE_UNQUOTED([SYSLOGFACILITY],
381 [$(eval echo ${SYSLOGFACILITY})],
382 [Default syslog facility])
384 AC_DEFINE_UNQUOTED([SYSLOGLEVEL],
385 [$(eval echo ${SYSLOGLEVEL})],
386 [Default syslog level])
388 AC_DEFINE_UNQUOTED([DEFAULTADMGROUP],
389 ["$(eval echo ${DEFAULTADMGROUP})"],
390 [Default admin group])
393 if test "x${enable_debug}" = xyes; then
394 AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code])
401 if test "x${GCC}" = xyes; then
417 suggest-attribute=noreturn
418 suggest-attribute=format
419 property-attribute-mismatch
421 declaration-after-statement
426 missing-format-attribute
449 unused-but-set-variable
450 unused-const-variable
459 for j in $WARNLIST; do
460 if cc_supports_flag -W$j; then
461 EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j";
465 AC_SUBST([AM_CFLAGS],["$OPT_CFLAGS $GDB_FLAGS $EXTRA_WARNINGS"])
468 AS_IF([test "$ax_cv_prog_date_gnu_date:$ax_cv_prog_date_gnu_utc" = yes:yes],
469 [UTC_DATE_AT="date -u -d@"],
470 [AS_IF([test "x$ax_cv_prog_date_bsd_date" = xyes],
471 [UTC_DATE_AT="date -u -r"],
472 [AC_MSG_ERROR([date utility unable to convert epoch to UTC])])])
473 AC_SUBST([UTC_DATE_AT])
475 AC_ARG_VAR([SOURCE_EPOCH],[last modification date of the source])
476 AC_MSG_NOTICE([trying to determine source epoch])
477 AC_MSG_CHECKING([for source epoch in \$SOURCE_EPOCH])
478 AS_IF([test -n "$SOURCE_EPOCH"],
479 [AC_MSG_RESULT([yes])],
481 AC_MSG_CHECKING([for source epoch in source_epoch file])
482 AS_IF([test -e "$srcdir/source_epoch"],
483 [read SOURCE_EPOCH <"$srcdir/source_epoch"
484 AC_MSG_RESULT([yes])],
486 AC_MSG_CHECKING([for source epoch baked in by gitattributes export-subst])
487 SOURCE_EPOCH='$Format:%at$' # template for rewriting by git-archive
488 AS_CASE([$SOURCE_EPOCH],
489 [?Format:*], # was not rewritten
491 AC_MSG_CHECKING([for source epoch in \$SOURCE_DATE_EPOCH])
492 AS_IF([test "x$SOURCE_DATE_EPOCH" != x],
493 [SOURCE_EPOCH="$SOURCE_DATE_EPOCH"
494 AC_MSG_RESULT([yes])],
496 AC_MSG_CHECKING([whether git log can provide a source epoch])
497 SOURCE_EPOCH=f${SOURCE_EPOCH#\$F} # convert into git log --pretty format
498 SOURCE_EPOCH=$(cd "$srcdir" && git log -1 --pretty=${SOURCE_EPOCH%$} 2>/dev/null)
499 AS_IF([test -n "$SOURCE_EPOCH"],
500 [AC_MSG_RESULT([yes])],
501 [AC_MSG_RESULT([no, using current time and breaking reproducibility])
502 SOURCE_EPOCH=$(date +%s)])])],
503 [AC_MSG_RESULT([yes])]
506 AC_MSG_NOTICE([using source epoch $($UTC_DATE_AT$SOURCE_EPOCH +'%F %T %Z')])
512 libnozzle/libnozzle.pc
513 libnozzle/tests/Makefile
515 kronosnetd/kronosnetd.logrotate
518 libknet/tests/Makefile
523 poc-code/iov-hash/Makefile
524 poc-code/access-list/Makefile
527 if test "x$VERSION" = "xUNKNOWN"; then
528 AC_MSG_ERROR([m4_text_wrap([
529 configure was unable to determine the source tree's current version. This
530 generally happens when using git archive (or the github download button)
531 generated tarball/zip file. In order to workaround this issue, either use git
532 clone https://github.com/kronosnet/kronosnet.git or use an official release
533 tarball, available at https://kronosnet.org/releases/. Alternatively you
534 can add a compatible version in a .tarball-version file at the top of the
535 source tree, wipe your autom4te.cache dir and generated configure, and rerun