2 dnl Copyright (c) 2012-2017 Red Hat.
3 dnl Copyright (c) 2008 Aconex. All Rights Reserved.
4 dnl Copyright (c) 2000-2004,2008 Silicon Graphics, Inc. All Rights Reserved.
6 dnl This program is free software; you can redistribute it and/or modify it
7 dnl under the terms of the GNU General Public License as published by the
8 dnl Free Software Foundation; either version 2 of the License, or (at your
9 dnl option) any later version.
11 dnl This program is distributed in the hope that it will be useful, but
12 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 dnl unpacking check - this file must exist
18 AC_INIT(src/include/pcp/pmapi.h)
20 dnl need 2.63 for AS_VAR_IF and AS_VAR_COPY
23 dnl Irix build issue ... use the tools from the local filesystems
28 [AS_HELP_STRING([--with-64bit],
29 [turn on 64 bit compilation mode (default is platform dependent)])],
30 [use_64bit=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-64bit=$withval"])
34 [AS_HELP_STRING([--with-optimization],
35 [enable optimization for C/C++ code (default is yes)])],
36 [use_optimization=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-optimization=$withval"],
37 [use_optimizaton=yes])
41 [AC_HELP_STRING([--with-threads],
42 [enable support for multiple threads (default is on)])],
43 [do_threads=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-threads=$withval"],
48 [AC_HELP_STRING([--with-secure-sockets],
49 [enable support for secure sockets (default is on)])],
50 [do_secure=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-secure-sockets=$withval"],
55 [AC_HELP_STRING([--with-static-probes],
56 [enable support for static probes (default is on)])],
57 [do_probes=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-static-probes=$withval"],
62 [AC_HELP_STRING([--with-infiniband],
63 [enable support for Infiniband metrics (default is on)])],
64 [do_infiniband=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-infiniband=$withval"],
65 [do_infiniband=check])
69 [AS_HELP_STRING([--with-user],
70 [user account under which daemons run (default is pcp)])],
71 [pcp_user=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-user-account=$withval"],
77 [AS_HELP_STRING([--with-group],
78 [user group under which daemons run (default is pcp)])],
79 [pcp_group=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-group-account=$withval"],
83 AC_ARG_WITH([discovery],
84 [AC_HELP_STRING([--with-discovery],
85 [enable support for service discovery (default is on)])],
86 [do_discovery=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-discovery=$withval"],
89 AC_ARG_WITH([systemd],
90 [AC_HELP_STRING([--with-systemd],
91 [enable support for systemd services (default is on)])],
92 [do_systemd=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-systemd=$withval"],
96 [AC_HELP_STRING([--with-qt],
97 [enable support for tools requiring Qt (default is on)])],
98 [do_qt=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-qt=$withval"],
102 [AC_HELP_STRING([--with-qt3d],
103 [enable support for 3D scene graph API (default is on)])],
104 [do_qt3d=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-qt3d=$withval"],
107 AC_ARG_WITH([python],
108 [AC_HELP_STRING([--with-python],
109 [enable support for tools requiring Python (default is on)])],
110 [do_python=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-python=$withval"],
113 AC_ARG_WITH([python3],
114 [AC_HELP_STRING([--with-python3],
115 [enable support for tools requiring Python3 (default is on)])],
116 [do_python3=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-python3=$withval"],
120 [AC_HELP_STRING([--with-books],
121 [enable building of the PCP books (default is off)])],
122 [do_books=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-books=$withval"],
125 AC_ARG_WITH([books-brand],
126 [AC_HELP_STRING([--with-books-brand=BRAND],
127 [choose the docbook brand when building the PCP books (default is common)])],
128 [do_books_brand=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-books-brand=$withval"],
129 [do_books_brand=common])
132 [AC_HELP_STRING([--with-papi@<:@=DIR|=MODULE@:>@],
133 [enable performance api counter pmda (default is on)
134 The optional argument may be a full path of a PAPI installation prefix,
135 or a pkgconfig module name.])],
136 [do_papi=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-papi=$withval"],
139 AC_ARG_WITH([perfevent],
140 [AC_HELP_STRING([--with-perfevent],
141 [enable perfevent pmda (default is on)])],
142 [do_perfevent=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-perfevent=$withval"],
143 [do_perfevent=check])
145 AC_ARG_WITH([pmdajson],
146 [AC_HELP_STRING([--with-pmdajson],
147 [enable JSON pmda (default is on)])],
148 [do_pmdajson=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdajson=$withval"],
151 AC_ARG_WITH([pmdanutcracker],
152 [AC_HELP_STRING([--with-pmdanutcracker],
153 [enable nutcracker pmda (default is on)])],
154 [do_pmdanutcracker=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdanutcracker=$withval"],
155 [do_pmdanutcracker=check])
157 AC_ARG_WITH([pmdasnmp],
158 [AC_HELP_STRING([--with-pmdasnmp],
159 [enable SNMP pmda (default is on)])],
160 [do_pmdasnmp=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdasnmp=$withval"],
163 AC_ARG_WITH([manager],
164 [AC_HELP_STRING([--with-manager],
165 [enable daemon manager (default is on)])],
166 [do_manager=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-manager=$withval"],
169 AC_ARG_WITH([webapi],
170 [AC_HELP_STRING([--with-webapi],
171 [enable REST API daemon (default is on)])],
172 [do_webapi=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-webapi=$withval"],
175 AC_ARG_WITH([webapps],
176 [AC_HELP_STRING([--with-webapps],
177 [enable building of webapp packages (default is off)])],
178 [do_webapps=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-webapps=$withval"],
181 AC_ARG_WITH([selinux],
182 [AC_HELP_STRING([--with-selinux],
183 [enable building of selinux package (default is on)])],
184 [do_selinux=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-selinux=$withval"],
186 dnl things set in the environment by Makepkgs never make it into an RPM
187 dnl build where the environment is stripped ... use a --with-foo=path
188 dnl construct to workaround this
191 [AC_HELP_STRING([--with-make],
192 [path to GNU compatible make(1) (default is empty for auto discovery)])],
193 [MAKE=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-make=$withval"],
197 [AC_HELP_STRING([--with-tar],
198 [path to GNU compatible tar(1) (default is empty for auto discovery)])],
199 [TAR=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-tar=$withval"],
203 [AC_HELP_STRING([--with-zip],
204 [path to GNU compatible zip(1) (default is empty for auto discovery)])],
205 [ZIP=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-zip=$withval"],
209 dnl Note: the following environment variables may be set to override defaults:
210 dnl MAKE CC CPP LD LEX YACC INSTALL AWK SED ECHO
213 dnl Guess target platfrom
218 FATAL ERROR: Cannot guess your target, try explicit specification
219 using --target or mailto: pcp@groups.io to ask.'
220 rm -rf conftest conftest.*
223 dnl Remove 4th name component, if present, from target, target_os,
224 dnl build and build_os. Squash all x86 cpus into one LCD form - i386
225 target=`echo $target | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`
226 target_os=`echo $target_os | sed '[s/solaris2\..*/solaris/]'`
227 target_os=`echo $target_os | sed '[s/^\([^-][^-]*\)-.*$/\1/]' | sed '[s/[\.0-9]*//g]'`
229 build=`echo $build | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`
230 build_os=`echo $build_os | sed '[s/solaris2\..*/solaris/]'`
231 build_os=`echo $build_os | sed '[s/^\([^-][^-]*\)-.*$/\1/]'`
234 echo Building on $build for $target
235 echo "Build: os=$build_os cpu=$build_cpu"
236 echo "Target: os=$target_os cpu=$target_cpu"
238 if test "$cross_compiling" = "yes"; then
239 if test -f ./config.$target_os; then
240 . ./config.$target_os
244 FATAL ERROR: Cannot perform cross-compilation without a file to source
245 configuration information from (config.$target_os is missing)"
246 rm -rf conftest conftest.*
250 AC_SUBST(cross_compiling)
252 dnl CFLAGS setting is a co-dependency between here and PCFLAGS in
253 dnl src/include/builddefs.in ... need to be the same in both places
255 target_distro=$target_os
256 if test $target_os = linux
258 AC_DEFINE(IS_LINUX, [1], [Platform is Linux])
259 test -f /etc/SuSE-release && target_distro=suse
260 test -f /etc/fedora-release && target_distro=fedora
261 test -f /etc/redhat-release && target_distro=redhat
262 test -f /etc/debian_version && target_distro=debian
263 test -f /etc/slackware-version && target_distro=slackware
264 test -f /etc/gentoo-release && target_distro=gentoo
265 test -f /etc/mandriva-release && target_distro=mandriva
266 test -f /etc/arch-release && target_distro=arch
267 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
268 pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
269 pcp_ps_all_flags=-efw
270 elif test $target_os = darwin
272 AC_DEFINE(IS_DARWIN, [1], [Platform is Darwin (Mac OS X)])
274 version=`sw_vers -productVersion | sed -e 's/\.//' -e 's/\..*//g'`
275 CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing -arch i386"
276 if test $version -ge 106
279 CFLAGS="$CFLAGS -arch x86_64"
282 pcp_platform_paths='/usr/local/bin'
283 pcp_ps_all_flags="-axw -o user,pid,ppid,cpu,stime,tty,time,command"
284 elif test $target_os = mingw
286 AC_DEFINE(IS_MINGW, [1], [Platform is MinGW (Windows)])
287 CFLAGS="-fno-strict-aliasing"
288 pcp_platform_paths=''
289 pcp_ps_all_flags=-efW
290 elif test $target_os = solaris
292 AC_DEFINE(IS_SOLARIS, [1], [Platform is Solaris])
293 export CFLAGS_IF_GCC="-fPIC -fno-strict-aliasing"
294 export CFLAGS_IF_SUNCC="-fPIC -xalias_level=any -D_XPG4_2 -D__EXTENSIONS__"
295 pcp_platform_paths='/usr/bin/X11:/usr/local/bin:/opt/sfw/bin:/opt/csw/bin'
297 elif test $target_os = aix
299 AC_DEFINE(IS_AIX, [1], [Platform is AIX])
300 export CFLAGS="-qcpluscmt"
301 pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
303 elif test $target_os = freebsd || test $target_os = kfreebsd
305 AC_DEFINE(IS_FREEBSD, [1], [Platform is FreeBSD])
306 test -f /etc/debian_version && target_distro=debian
307 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
308 if test $target_os = kfreebsd
310 pcp_ps_all_flags=-efw
312 pcp_ps_all_flags=auxww
314 pcp_platform_paths='/usr/bin/X11'
315 test -d /usr/local/bin && pcp_platform_paths="$pcp_platform_paths:/usr/local/bin"
316 test -d /usr/bsd && pcp_platform_paths="$pcp_platform_paths:/usr/bsd"
317 elif test $target_os = gnu
319 AC_DEFINE(IS_GNU, [1], [Platform is GNU Hurd])
320 test -f /etc/debian_version && target_distro=debian
321 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
322 pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
323 pcp_ps_all_flags=-efw
324 elif test $target_os = netbsdelf
327 AC_DEFINE(IS_NETBSD, [1], [Platform is NetBSD])
328 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE -D_NETBSD_SOURCE"
329 pcp_platform_paths='/usr/pkg/bin'
330 pcp_ps_all_flags=auxww
331 elif test $target_os = openbsd
334 AC_DEFINE(IS_OPENBSD, [1], [Platform is OpenBSD])
335 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
336 pcp_platform_paths='/usr/local/bin'
337 pcp_ps_all_flags=auxww
340 echo "FATAL ERROR: need platform-specific customization for \"$target_os\""
341 rm -rf conftest conftest.*
344 AC_SUBST(pcp_platform_paths)
345 AC_SUBST(pcp_ps_all_flags)
347 dnl default C and C++ compiler optimization to -O2 -g
348 if test "$use_optimization" = no
350 optimization="-O0 -g"
352 optimization="-O2 -g"
354 AC_SUBST(optimization)
357 if test -z "$PKG_CONFIG"; then
358 AC_MSG_ERROR([cannot find a 'pkg-config' command])
361 dnl check if user wants their own C compiler
363 AC_PROG_CC(suncc egcc gcc cc)
364 if test $target_os = solaris
366 AC_PATH_PROG(CCPATH,$CC,$CC)
368 if test "$GCC" = "yes"
370 CFLAGS="$CFLAGS $CFLAGS_IF_GCC"
372 CFLAGS="$CFLAGS $CFLAGS_IF_SUNCC"
374 if test "$use_64bit" = "no"
378 AC_MSG_CHECKING([for 64 bit Solaris host])
383 CFLAGS="$CFLAGS -m64"
384 LDFLAGS="$LDFLAGS -m64"
399 dnl these become CFLAGS and LDFLAGS for the build
403 if echo "$CFLAGS" | grep 'D_FORTIFY_SOURCE' >/dev/null
405 dnl for cc use locally in configure (not exported via $PCFLAGS),
406 dnl add -O in case -D_FORTIFY_SOURCE has been added to CFLAGS above,
407 dnl as -D_FORTIFY_SOURCE requires -O but we've separated optimization
408 dnl flags out into $CFLAGS_OPT for our build infrastructure
412 dnl some versions of gcc (e.g. version 4.8.4 on Gentoo Hardened) have added
413 dnl a predefined for _FORTIFY_SOURCE but only when -O is specified ... so
414 dnl to be safe we have -U_FORTIFY_SOURCE before -D_FORTIFY_SOURCE=2 below
416 dnl Add some security-related gcc flags
417 if echo "$CFLAGS" | grep stack-protector >/dev/null
419 dnl already set, probably from the environment
423 [AS_HELP_STRING([--disable-ssp], [disable gcc stack-protector])])
424 AS_IF([test "x$cc_is_gcc" = xyes -a "x$enable_ssp" != xno -a "x$use_optimization" = xyes ],[
425 save_CFLAGS="$CFLAGS"
426 CFLAGS="$CFLAGS -O -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
427 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int something ();])], [
428 AC_MSG_NOTICE([Compiling with gcc -fstack-protector-all et al.])
429 PCFLAGS="$PCFLAGS -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"],[
430 AC_MSG_NOTICE([Compiler does not support -fstack-protector-all et al.])
431 CFLAGS="$save_CFLAGS"
438 dnl Check for even more security-related gcc/linker flags, useful for daemons
440 [AS_HELP_STRING([--disable-pie], [disable position-independent-executable])])
441 AS_IF([test "x$cc_is_gcc" = xyes -a "x$enable_pie" != xno],[
443 PIELDFLAGS='-pie -Wl,-z,relro -Wl,-z,now'
444 save_CFLAGS="$CFLAGS"
445 save_LDFLAGS="$LDFLAGS"
446 CFLAGS="$CFLAGS $PIECFLAGS"
447 LDFLAGS="$LDFLAGS $PIELDFLAGS"
448 AC_LINK_IFELSE([AC_LANG_SOURCE([void main () {}])], [
449 AC_MSG_NOTICE([Compiling with gcc pie et al.])
451 AC_MSG_NOTICE([Compiler does not support -pie et al.])
455 CFLAGS="$save_CFLAGS"
456 LDFLAGS="$save_LDFLAGS"
461 dnl Check for support for symbol hiding via gcc flags
462 AC_ARG_ENABLE([visibility],
463 [AS_HELP_STRING([--disable-visibility], [disable gcc symbol visibility])])
464 AS_IF([test "x$cc_is_gcc" = xyes -a "$enable_visibility" != no],[
465 INVISIBILITY="-fvisibility=hidden"
466 save_CFLAGS="$CFLAGS"
467 CFLAGS="$CFLAGS -c $INVISIBILITY"
468 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int visible () { return 0; }])], [
469 AC_MSG_NOTICE([Compiling DSO PMDAs with gcc -fvisibility=hidden])
471 AC_MSG_NOTICE([Compiler does not support -fvisibility.])
474 CFLAGS="$save_CFLAGS"
476 AC_SUBST(INVISIBILITY)
478 AC_PROG_CXX(eg++ g++ c++)
481 AC_MSG_CHECKING([for working C++ compiler])
484 [AC_LANG_PROGRAM([[#include <cstdio>]],
485 [[const char gday[] = "G'day, world\n";]])],
486 [AC_MSG_RESULT([yes])],
491 dnl Prevent shared libraries from being built for libpcp and other core libraries
492 AC_ARG_ENABLE([shared],
493 [AS_HELP_STRING([--disable-shared], [disable core shared libary generation])],
494 [PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --disable-shared=$withval"])
495 AC_SUBST(enable_shared)
497 dnl check if user wants to use any of their own commands;
498 dnl ordering is important: some tests use earlier results
500 test -z "$AWK" && AC_PATH_PROGS(AWK, gawk awk, /usr/bin/awk)
512 if test -z "$SED"; then
513 AC_PATH_PROG(SED, sed, /bin/sed)
515 if test ! -x "$SED"; then
516 AC_MSG_ERROR([cannot find a valid 'sed' command.])
521 if test -z "$ECHO"; then
522 AC_PATH_PROG(ECHO, echo, /bin/echo)
524 if test ! -x "$ECHO"; then
525 AC_MSG_ERROR([cannot find a valid 'echo' command.])
530 if test -z "$FIND"; then
531 AC_PATH_PROG(FIND, find, /usr/bin/find)
533 if test ! -x "$FIND"; then
534 AC_MSG_ERROR([cannot find a valid 'find' command.])
539 if test -z "$WHICH"; then
540 AC_PATH_PROG(WHICH, which, /usr/bin/which)
542 if test ! -x "$WHICH"; then
543 AC_MSG_ERROR([cannot find a valid 'which' command.])
549 lex=`$echo $LEX | awk '{print $1}'`
551 if test ! -x "$lex"; then
552 AC_MSG_ERROR([cannot find a valid 'lex'/'flex' command.])
558 yacc=`$echo $YACC | awk '{print $1}'`
559 yacc=`$which "$yacc"`
560 if test ! -x "$yacc"; then
561 AC_MSG_ERROR([cannot find a valid 'yacc'/'bison' command.])
566 dnl check we don't get the Windows sort ...
567 AC_MSG_CHECKING([where unix-like sort(1) lives])
568 if test $target_os = mingw; then
569 for d in /bin /usr/bin /mingw/bin /mingw/usr/bin
571 if test -x $d/sort; then
584 echo "FATAL ERROR: $sort -n failed!"
585 rm -rf conftest conftest.*
590 dnl echo_n set to -n if echo understands -n to suppress newline
591 dnl echo_c set to \c if echo understands \c to suppress newline
592 AC_MSG_CHECKING([if echo uses -n or backslash-c to suppress newlines])
593 if ( $echo "testing\c"; $echo 1,2,3 ) | grep c >/dev/null
595 if ( $echo -n testing; $echo 1,2,3 ) | sed s/-n/xn/ | grep xn >/dev/null
598 AC_MSG_RESULT([neither?])
605 AC_MSG_RESULT([backslash-c])
610 dnl subsequent configure checks rely on $EGREP being set
613 dnl Check for static probes (dtrace, systemtap)
614 if test "$do_probes" = "check" -o "$do_probes" = "yes"
617 AC_CHECK_PROGS(DTRACE, dtrace, [])
620 if test "$do_probes" = "yes"
622 AC_MSG_ERROR([cannot enable static probes - no dtrace executable])
626 AC_CHECK_HEADERS([sys/sdt.h], [
627 if $enable_probes = true
629 if test $target_os = kfreebsd
632 elif test $target_os = freebsd
634 dnl dtrace support in FreeBSD depends on configuration of kernel
635 rm -f conftest.d conftest.h
636 cat <<End-of-File >conftest.d
641 if dtrace -s conftest.d -h >/dev/null 2>&1
643 if test ! -f conftest.h
646 if test "$do_probes" = "yes"
648 AC_MSG_ERROR([cannot enable static probes - no .h from dtrace -h])
653 if test "$do_probes" = "yes"
655 AC_MSG_ERROR([cannot enable static probes - dtrace failed])
662 if test "$do_probes" = "yes"
664 AC_MSG_ERROR([cannot enable static probes - no SDT header])
668 if test "$enable_probes" = "true"
670 AC_DEFINE(HAVE_STATIC_PROBES, [1], [Static probes (dtrace, systemtap)])
672 AC_SUBST(enable_probes)
676 dnl Check for service discovery mechanisms (DNS-SD, Avahi)
677 AS_IF([test "x$do_discovery" != "xno"], [
678 # on Mac OS X, dns_sd.h
680 # on Linux, aloha Avahi
682 PKG_CHECK_MODULES([avahi], [avahi-client],
683 [AC_CHECK_LIB(avahi-client, avahi_client_new,
684 [lib_for_avahi="-lavahi-common -lavahi-client"],
685 [enable_avahi=false])
686 ],[enable_avahi=false])
687 AC_CHECK_HEADERS([avahi-client/publish.h],, [enable_avahi=false])
688 AC_CHECK_HEADERS([avahi-common/alternative.h],, [enable_avahi=false])
690 if test "$enable_avahi" = "true"
692 AC_SUBST(lib_for_avahi)
693 AC_SUBST(avahi_CFLAGS)
694 AC_DEFINE(HAVE_AVAHI, [1], [Service discovery via Avahi])
695 enable_discovery=true
698 if test "$do_discovery" != "check" -a "$enable_discovery" != "true"
700 AC_MSG_ERROR([cannot enable service discovery - no supported mechanisms])
702 if test "$enable_discovery" = "true"
704 AC_DEFINE(HAVE_SERVICE_DISCOVERY, [1], [Service discovery mechanisms])
707 AC_SUBST(enable_discovery)
708 AC_SUBST(enable_avahi)
710 dnl Check for systemd services
712 AS_IF([test "x$do_systemd" != "xno"], [
715 PKG_CHECK_VAR([SYSTEMD_SYSTEMUNITDIR], [systemd], [systemdsystemunitdir],
716 [pcp_systemdunit_dir=$SYSTEMD_SYSTEMUNITDIR], [enable_systemd=false])
717 AC_SUBST(pcp_systemdunit_dir)
718 if test -z "$pcp_systemdunit_dir"
720 if test "$do_systemd" = "yes"
722 AC_MSG_ERROR([cannot enable systemd support - no systemunitdir path])
727 AC_SUBST(enable_systemd)
729 dnl NB: No AC_PREFIX_DEFAULT is needed, as the default configure invocation
730 dnl targets a build for non-system directories such as /usr/local.
731 dnl AC_PREFIX_DEFAULT([])
734 PACKAGE_VERSION=${PACKAGE_MAJOR}.${PACKAGE_MINOR}.${PACKAGE_REVISION}
735 AC_SUBST(PACKAGE_VERSION)
736 AC_SUBST(PACKAGE_MAJOR)
737 AC_SUBST(PACKAGE_MINOR)
738 AC_SUBST(PACKAGE_REVISION)
739 AC_SUBST(PACKAGE_BUILD)
741 if test -z "$PACKAGE_BUILD_DATE" ; then
742 PACKAGE_BUILD_DATE=`date +%Y-%m-%d`
744 AC_SUBST(PACKAGE_BUILD_DATE)
746 if test -z "$PACKAGE_DISTRIBUTION" ; then
747 PACKAGE_DISTRIBUTION=$target_distro
749 AC_SUBST(PACKAGE_DISTRIBUTION)
751 dnl generate PM_VERSION_CURRENT for header
752 pm_version_current=`awk </dev/null "BEGIN { print (${PACKAGE_MAJOR}*256+${PACKAGE_MINOR})*256+${PACKAGE_REVISION} }"`
753 AC_SUBST(pm_version_current)
755 dnl output header files with cpp defs HAVE_*, etc
756 AC_CONFIG_HEADERS(src/include/pcp/config.h src/include/pcp/configsz.h)
757 AC_OUTPUT(src/include/pcp/platform_defs.h src/include/pcp/platformsz.h)
759 AC_CHECK_PROGS(GIT, git)
762 dnl check if python available for the build and runtime
763 AC_CHECK_PROGS(PYTHON, python, python2.7)
766 dnl check if python3 available for the build and runtime
767 AC_CHECK_PROGS(PYTHON3, python3, python3.4)
770 dnl check if python tools/packages wanted (need python >= 2.6)
772 AS_IF([test "x$do_python" != "xno"], [
778 AC_MSG_CHECKING([Python version])
779 eval `$PYTHON -V 2>&1 | awk '/^Python/ { ver=2; print $ver }' | awk -F. '{ major=1; minor=2; point=3; printf "export PY_MAJOR=%d PY_MINOR=%d PY_POINT=%d\n",$major,$minor,$point }'`
780 AC_MSG_RESULT([$PY_MAJOR.$PY_MINOR.$PY_POINT])
781 if test "$PY_MAJOR" -lt 2; then
782 echo WARNING: Python version 2.6 or later does not seem to be installed.
785 if test "$PY_MAJOR" -eq 2 -a "$PY_MINOR" -lt 6 ; then
786 echo WARNING: Python version 2.$PY_MINOR is too old.
787 echo Python version 2.6 or later is required for Python builds.
790 AC_CHECK_HEADERS([python${PY_MAJOR}.${PY_MINOR}/Python.h], [], [
791 echo WARNING: Python version $PY_MAJOR.$PY_MINOR header file missing.
792 echo Cannot proceed with the Python $PY_MAJOR installation found.
799 if test "$do_python" != "check" -a "$enable_python2" != "true"
801 AC_MSG_ERROR([cannot enable Python - no supported version found])
804 AC_SUBST(enable_python2)
806 dnl check if python3 tools/packages wanted (need python >= 3.3)
808 AS_IF([test "x$do_python3" != "xno"], [
810 if test -z "$PYTHON3"
814 AC_MSG_CHECKING([Python3 version])
815 eval `$PYTHON3 -V 2>&1 | awk '/^Python/ { ver=2; print $ver }' | awk -F. '{ major=1; minor=2; point=3; printf "export PY_MAJOR=%d PY_MINOR=%d PY_POINT=%d\n",$major,$minor,$point }'`
816 AC_MSG_RESULT([$PY_MAJOR.$PY_MINOR.$PY_POINT])
817 if test "$PY_MAJOR" -lt 3; then
818 echo WARNING: Python version 3.3 or later does not seem to be installed.
821 if test "$PY_MAJOR" -eq 3 -a "$PY_MINOR" -lt 3 ; then
822 echo WARNING: Python version 3.$PY_MINOR is too old.
823 echo Python version 3.3 or later is required for Python builds.
826 AC_CHECK_HEADERS([python${PY_MAJOR}.${PY_MINOR}m/Python.h], [], [
827 echo WARNING: Python version $PY_MAJOR.$PY_MINOR header file missing.
828 echo Cannot proceed with the Python $PY_MAJOR installation found.
835 if test "$do_python3" != "check" -a "$enable_python3" != "true"
837 AC_MSG_ERROR([cannot enable Python3 - no supported version found])
840 AC_SUBST(enable_python3)
842 dnl convenience macro to determine if either python is available
843 AC_MSG_CHECKING([for any python version])
844 if test "$cross_compiling" = "yes"; then
846 echo "cross-compile -> \"$ans\"" >&5
847 elif test "$enable_python2" = "true" -o "$enable_python3" = "true"
853 AC_SUBST(have_python)
854 if $have_python; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
856 dnl choose the prefered python executable (py2 -> py3 transtion)
857 if test "$enable_python3" = "true"
859 pcp_python_prog=$PYTHON3
860 elif test "$enable_python2" = "true"
862 pcp_python_prog=$PYTHON
866 AC_SUBST(pcp_python_prog)
868 dnl check availability of some Python modules
869 dnl usage PCP_CHECK_PYTHON_MODULE(module_name) or
870 dnl PCP_CHECK_PYTHON_MODULE(module_name, <import string>)
871 dnl default <import string> is "import module_name"
873 dnl sets $have_python_<module_name> as true or false
875 AC_DEFUN([PCP_CHECK_PYTHON_MODULE],
876 [ AC_MSG_CHECKING(for Python module $1)
883 $pcp_python_prog -c 'import sys;
884 '"$txt" >>config.log 2>&1
888 eval have_python_$1=true
891 eval have_python_$1=false
894 PCP_CHECK_PYTHON_MODULE(jsonpointer)
895 AC_SUBST(have_python_jsonpointer)
896 PCP_CHECK_PYTHON_MODULE(setuptools)
897 AC_SUBST(have_python_setuptools)
898 PCP_CHECK_PYTHON_MODULE(requests)
899 AC_SUBST(have_python_requests)
900 PCP_CHECK_PYTHON_MODULE(libvirt)
901 AC_SUBST(have_python_libvirt)
902 PCP_CHECK_PYTHON_MODULE(six)
903 AC_SUBST(have_python_six)
905 AC_MSG_CHECKING([if the json PMDA should be included])
907 AS_IF([test "x$do_pmdajson" = "xyes"], [pmda_json=true])
908 AS_IF([test "x$do_pmdajson" = "xcheck"], [
909 dnl JSON PMDA needs both the six and jsonpointer Python modules
910 $have_python_jsonpointer && $have_python_six && pmda_json=true
912 AC_SUBST(PMDA_JSON, $pmda_json)
913 if $pmda_json; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
915 dnl check if perl available for the build and runtime
916 AC_CHECK_PROGS(PERL, perl)
919 AC_MSG_CHECKING([for any perl version])
920 if test "$cross_compiling" = "yes"; then
922 echo "cross-compile -> \"$ans\"" >&5
931 AC_SUBST(pcp_perl_prog)
933 AC_MSG_RESULT($pcp_perl_prog)
935 AC_MSG_CHECKING([if the SNMP PMDA should be included])
937 AS_IF([test "x$do_pmdasnmp" = "xyes"], [pmda_snmp=true])
938 AS_IF([test "x$do_pmdasnmp" = "xcheck"], [
939 dnl SNMP PMDA needs perl and the Net::SNMP module
940 if test "$have_perl" = true
942 if $pcp_perl_prog -e "use Net::SNMP" >/dev/null 2>&1
948 AC_SUBST(PMDA_SNMP, $pmda_snmp)
949 if $pmda_snmp; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
951 AC_MSG_CHECKING([if the mysql PMDA should be included])
953 if test "$have_perl" = true
955 dnl rpm build for mysql PMDA needs Perl DBI and DBD::mysql
956 if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
958 if $pcp_perl_prog -e "use DBD::mysql" >/dev/null 2>&1
964 AC_SUBST(PMDA_MYSQL, $pmda_mysql)
965 if $pmda_mysql; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
967 AC_MSG_CHECKING([if the postgresql PMDA should be included])
968 pmda_postgresql=false
969 if test "$have_perl" = true
971 dnl rpm build for postgresql PMDA needs Perl DBI and DBD::Pg
972 if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
974 if $pcp_perl_prog -e "use DBD::Pg" >/dev/null 2>&1
980 AC_SUBST(PMDA_POSTGRESQL, $pmda_postgresql)
981 if $pmda_postgresql; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
983 AC_MSG_CHECKING([if the oracle PMDA should be included])
985 if test "$have_perl" = true
987 dnl rpm build for oracle PMDA needs Perl DBI
988 if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
993 AC_SUBST(PMDA_ORACLE, $pmda_oracle)
994 if $pmda_oracle; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
996 AC_MSG_CHECKING([if the elasticsearch PMDA should be included])
997 pmda_elasticsearch=false
998 if test "$have_perl" = true
1000 dnl rpm build for elasticsearch PMDA needs Perl LWP::UserAgent
1001 if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1003 pmda_elasticsearch=true
1006 AC_SUBST(PMDA_ELASTICSEARCH, $pmda_elasticsearch)
1007 if $pmda_elasticsearch; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1009 AC_MSG_CHECKING([if the nginx PMDA should be included])
1011 if test "$have_perl" = true
1013 dnl rpm build for nginx PMDA needs Perl LWP::UserAgent
1014 if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1019 AC_SUBST(PMDA_NGINX, $pmda_nginx)
1020 if $pmda_nginx; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1022 AC_MSG_CHECKING([if the activemq PMDA should be included])
1024 if test "$have_perl" = true
1026 dnl rpm build for activemq PMDA needs Perl LWP::UserAgent
1027 if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1032 AC_SUBST(PMDA_ACTIVEMQ, $pmda_activemq)
1033 if $pmda_activemq; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1035 AC_MSG_CHECKING([if the bind2 PMDA should be included])
1037 if test "$have_perl" = true
1039 dnl rpm build for bind2 PMDA needs Perl LWP::UserAgent, XML::LibXML
1040 if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1042 if $pcp_perl_prog -e "use XML::LibXML" >/dev/null 2>&1
1044 if $pcp_perl_prog -e "use File::Slurp" >/dev/null 2>&1
1051 AC_SUBST(PMDA_BIND2, $pmda_bind2)
1052 if $pmda_bind2; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1054 AC_MSG_CHECKING([if the nutcracker PMDA should be included])
1055 pmda_nutcracker=false
1056 AS_IF([test "x$do_pmdanutcracker" = "xyes"], [pmda_nutcracker=true])
1057 AS_IF([test "x$do_pmdanutcracker" = "xcheck"], [
1058 dnl build for nutcracker PMDA needs perl JSON & YAML::XS modules
1059 if test "$have_perl" = true
1061 if $pcp_perl_prog -e "use YAML::XS" >/dev/null 2>&1
1063 if $pcp_perl_prog -e "use JSON" >/dev/null 2>&1
1065 pmda_nutcracker=true
1070 AC_SUBST(PMDA_NUTCRACKER, $pmda_nutcracker)
1071 if $pmda_nutcracker; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1073 AC_MSG_CHECKING([if the LIO PMDA should be included])
1075 if test "$have_python" = true
1077 dnl rpm build for LIO PMDA needs Python rtslib module
1078 if $pcp_python_prog -c "import rtslib" >/dev/null 2>&1
1083 AC_SUBST(PMDA_LIO, $pmda_lio)
1084 if $pmda_lio; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1086 AC_MSG_CHECKING([if the Prometheus PMDA should be included])
1087 pmda_prometheus=false
1088 if test "$have_python" = true
1090 if test "$have_python_requests" = true
1092 pmda_prometheus=true
1095 AC_SUBST(PMDA_PROMETHEUS, $pmda_prometheus)
1096 if $pmda_prometheus; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1098 AC_MSG_CHECKING([if the libvirt PMDA should be included])
1100 if test "$have_python" = true
1102 dnl rpm build for libvirt PMDA needs Python libvirt and lxml modules
1103 if test "$have_python_libvirt" = true
1105 if $pcp_python_prog -c "import lxml" >/dev/null 2>&1
1111 AC_SUBST(PMDA_LIBVIRT, $pmda_libvirt)
1112 if $pmda_libvirt; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1118 AS_IF([test "x$do_qt" != "xno"], [
1123 AC_PATH_PROGS(QMAKE, [qmake-qt5 qmake-qt4 qmake],, [$QTDIR/bin:/usr/bin:/usr/lib64/qt5/bin:/usr/lib/qt5/bin:/usr/lib64/qt4/bin:/usr/lib/qt4/bin:/usr/local/bin])
1124 test "x$cc_is_gcc" = xyes -a $target_os = solaris && QMAKE="$QMAKE -spec solaris-g++"
1131 AC_MSG_CHECKING([Qt version])
1132 eval `$qmake --version | awk '/Using Qt version/ { ver=4; print $ver }' | awk -F. '{ major=1; minor=2; point=3; printf "export QT_MAJOR=%d QT_MINOR=%d QT_POINT=%d\n",$major,$minor,$point }'`
1133 AC_MSG_RESULT([$QT_MAJOR.$QT_MINOR.$QT_POINT])
1134 if test "$QT_MAJOR" -lt 4; then
1135 echo WARNING: Qt version 4.4 or later does not seem to be installed.
1136 echo Cannot proceed with the Qt $QT_MAJOR installation found.
1139 if test "$QT_MAJOR" -eq 4 -a "$QT_MINOR" -lt 4 ; then
1140 echo WARNING: Qt version 4.$QT_MINOR is too old.
1141 echo Qt version 4.4 or later is required for Qt builds.
1144 qt_version=$QT_MAJOR
1147 if test "$do_qt" != "check" -a "$enable_qt" != "true"
1149 AC_MSG_ERROR([cannot enable Qt - no supported Qt installation found])
1150 elif test "$enable_qt" = "true" -a "x$cxx" = "x"
1153 test "$do_qt" != "check" && \
1154 AC_MSG_ERROR([C++ compiler unavailable, cannot build Qt components])
1155 elif test "$do_qt" = "debug"
1157 dnl Debug/release style build? (non-debug by default)
1162 AC_SUBST(qt_release)
1163 AC_SUBST(qt_version)
1168 AS_IF([test "x$do_qt3d" != "xno"], [
1169 if test -f /usr/include/Coin3/Inventor/Qt/SoQt.h -o -f /usr/include/Inventor/Qt/SoQt.h
1171 enable_qt3d=$enable_qt
1172 elif test x"$do_qt3d" = x"yes"
1174 AC_MSG_ERROR([cannot enable support for 3D scene graph API])
1177 AC_SUBST(enable_qt3d)
1179 dnl check if user wants their own make program
1180 dnl note: all makefiles in this package use the gmake syntax
1183 AC_PATH_PROG(MAKE, gmake)
1186 # look elsewhere ...
1187 AC_MSG_CHECKING([for GNU make elsewhere])
1188 for f in /usr/local/bin/gmake /usr/freeware/bin/gmake /usr/local/bin/make /opt/sfw/bin/gmake nowhere
1196 if test $f = nowhere
1198 # Check if /usr/bin/make is any good
1199 mver=`/usr/bin/make --version 2>/dev/null | sed -n -e1p | cut -c1-8`
1200 if test "$mver" != "GNU Make"
1203 echo "FATAL ERROR: could not find GNU make anywhere"
1204 echo "You need to set \$MAKE as the full path to GNU make "
1205 echo "in the environment."
1206 rm -rf conftest conftest.*
1212 AC_MSG_RESULT($MAKE)
1218 dnl check if users wants their own CPP
1219 if test -z "$CPP"; then
1225 dnl check if users wants their own linker
1226 if test -z "$LD"; then
1227 AC_PATH_PROG(LD, ld, /usr/bin/ld)
1232 dnl Provide ways to override owner and group for installed files
1233 if test -z "$PCP_USER_INSTALL" ; then
1234 pcp_user_install=root
1236 pcp_user_install="$PCP_USER_INSTALL"
1238 AC_SUBST(pcp_user_install)
1239 if test -z "$PCP_GROUP_INSTALL" ; then
1242 darwin|freebsd|netbsd|openbsd)
1243 pcp_group_install=wheel
1246 pcp_group_install=root
1250 pcp_group_install="$PCP_GROUP_INSTALL"
1252 AC_SUBST(pcp_group_install)
1254 dnl check if the tar program is available
1255 if test -z "$TAR"; then
1256 AC_PATH_PROGS(TAR, gtar tar, tar)
1258 if test $target_os = darwin -a -x /usr/bin/gnutar
1265 dnl check if the gzip program is available
1266 dnl (needed to gzip man pages on some platforms)
1267 if test -z "$ZIP"; then
1268 AC_PATH_PROG(ZIP, gzip, /bin/gzip)
1270 test ! -x "$ZIP" && ZIP=/usr/local/bin/gzip
1271 test ! -x "$ZIP" && ZIP=/usr/freeware/bin/gzip
1272 test ! -x "$ZIP" && ZIP=/usr/bin/gzip
1274 test -z "$gzip" && gzip=no-gzip
1277 dnl check if the bzip2 program is available
1278 dnl (needed to bzip2 man pages on some platforms)
1279 if test -z "$BZIP2"; then
1280 AC_PATH_PROG(BZIP2, bzip2, /bin/bzip2)
1282 test ! -x "$BZIP2" && BZIP2=/usr/bin/bzip2
1283 test ! -x "$BZIP2" && BZIP2=/usr/local/bin/bzip2
1284 test ! -x "$BZIP2" && BZIP2=/usr/freeware/bin/bzip2
1286 test -z "$bzip2" && bzip2=no-bzip2
1289 dnl check if the lzma program is available
1290 dnl (needed to lzma man pages on some platforms)
1291 if test -z "$LZMA"; then
1292 AC_PATH_PROG(LZMA, lzma, /bin/lzma)
1294 test ! -x "$LZMA" && LZMA=/usr/bin/lzma
1295 test ! -x "$LZMA" && LZMA=/usr/local/bin/lzma
1296 test ! -x "$LZMA" && LZMA=/usr/freeware/bin/lzma
1298 test -z "$lzma" && lzma=no-lzma
1301 dnl check if the xz program is available
1302 dnl (needed to xz man pages on some platforms)
1303 if test -z "$XZ"; then
1304 AC_PATH_PROG(XZ, xz, /bin/xz)
1306 test ! -x "$XZ" && XZ=/usr/bin/xz
1307 test ! -x "$XZ" && XZ=/usr/local/bin/xz
1308 test ! -x "$XZ" && XZ=/usr/freeware/bin/xz
1310 test -z "$xz" && xz=no-xz
1313 dnl Check for mac PackageMaker
1314 AC_MSG_CHECKING([for PackageMaker])
1315 if test -z "$PACKAGE_MAKER"
1317 if test $target_os = darwin
1319 if test -x /Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1320 then # local XCode extras install
1321 package_maker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1322 AC_MSG_RESULT([ yes (local install)])
1323 elif test -x /Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1325 package_maker=/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1326 AC_MSG_RESULT([ yes (darwin 6.x)])
1327 elif test -x /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
1329 AC_MSG_RESULT([ yes (darwin 7.x)])
1330 package_maker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
1332 AC_MSG_RESULT([ not found!])
1333 AC_MSG_WARN([PackageMaker not found, mac packages will not be made])
1336 AC_MSG_RESULT([ no])
1339 package_maker="$PACKAGE_MAKER"
1341 AC_SUBST(package_maker)
1343 dnl check if the hdiutil program is available
1344 if test -z "$HDIUTIL"; then
1345 AC_PATH_PROG(HDIUTIL, hdiutil)
1350 dnl check if the mkinstallp program is available (AIX)
1351 if test -z "$MKINSTALLP"; then
1352 AC_PATH_PROG(MKINSTALLP, mkinstallp)
1354 mkinstallp=$MKINSTALLP
1355 AC_SUBST(mkinstallp)
1357 dnl check for the Solaris pmgmk package maker
1358 if test -z "$PKGMK"; then
1359 AC_PATH_PROG(PKGMK, pkgmk)
1364 dnl check if the dlltool program is available
1365 if test -z "$DLLTOOL"; then
1366 AC_PATH_PROG(DLLTOOL, dlltool)
1371 dnl check if the rpmbuild program is available
1372 if test -z "$RPMBUILD"; then
1373 AC_PATH_PROG(RPMBUILD, rpmbuild)
1375 test $target_distro = slackware && RPMBUILD=''
1379 dnl check if the rpm program is available
1380 if test -z "$RPM"; then
1381 AC_PATH_PROG(RPM, rpm)
1383 test $target_distro = slackware && RPM=''
1387 dnl if rpmbuild exists, use it, otherwise use rpm
1388 if test -n "$RPMBUILD" -a -x "$RPMBUILD"
1396 dnl check if the pod2man program is available (perl man page builder)
1397 if test -z "$POD2MAN"; then
1398 AC_PATH_PROG(POD2MAN, pod2man)
1403 dnl extra check for the Perl MakeMaker package
1404 AC_MSG_CHECKING([if ExtUtils::MakeMaker is installed])
1405 perl -e "use ExtUtils::MakeMaker" 2>/dev/null
1408 AC_MSG_RESULT([ yes])
1410 AC_MSG_RESULT([ no])
1412 echo "FATAL ERROR: Perl ExtUtils::MakeMaker module missing."
1413 echo "You can either install this from your distribution, or"
1414 echo "download from CPAN (Comprehensive Perl Archive Network)."
1415 rm -rf conftest conftest.*
1419 AC_PATH_PROG(TRUEPROG, true)
1421 dnl check if the makedepend program is available
1422 if test -z "$MAKEDEPEND"; then
1423 AC_PATH_PROG(MAKEDEPEND, makedepend, $TRUEPROG)
1425 makedepend=$MAKEDEPEND
1426 AC_SUBST(makedepend)
1428 dnl check if the md5sum program is available
1429 if test -z "$MD5SUM"; then
1430 AC_PATH_PROG(MD5SUM, md5sum, $TRUEPROG)
1435 dnl check if the Debian dpkg program is available
1436 if test -z "$DPKG"; then
1437 AC_PATH_PROG(DPKG, dpkg)
1442 dnl check for the Slackware makepkg packaging tool
1443 if test -z "$MAKEPKG"; then
1444 AC_PATH_PROG(MAKEPKG, makepkg)
1449 dnl check if a toolchain is available for the books
1450 test -z "$PUBLICAN" && AC_PATH_PROG(PUBLICAN, publican)
1453 test -z "$DBLATEX" && AC_PATH_PROG(DBLATEX, dblatex)
1456 test -z "$XMLTO" && AC_PATH_PROG(XMLTO, xmlto)
1461 if test "$do_books" = "check" -o "$do_books" = "yes"
1463 if test "$BOOK_TOOLCHAIN" != ""
1465 book_toolchain=$BOOK_TOOLCHAIN
1466 elif test "$DBLATEX" != ""
1468 book_toolchain=dblatex
1469 elif test "$PUBLICAN" != ""
1471 book_toolchain=publican
1472 elif test "$XMLTO" != ""
1474 book_toolchain=xmlto
1475 elif test "$do_books" = "yes"
1477 AC_MSG_ERROR([cannot enable books build - no toolchain found])
1480 AC_SUBST(book_toolchain)
1483 if test "$do_books_brand" != ""
1485 book_brand=$do_books_brand
1487 AC_SUBST(book_brand)
1489 dnl check if symbolic links are supported
1491 if test $target_os = mingw; then
1495 dnl if /proc is not mounted, try and mount it
1496 dnl before trying to run the ps style test below
1499 test -f /proc/stat || mount /proc >/dev/null 2>&1
1502 dnl set platform specific ps
1503 if test -n "$PROCPS"
1505 pcp_ps_prog="$PROCPS"
1509 AC_SUBST(pcp_ps_prog)
1511 dnl set platform specific event logger
1512 if test $target_os = mingw
1514 pcp_syslog_prog=pcp-eventlog
1516 pcp_syslog_prog=logger
1518 AC_SUBST(pcp_syslog_prog)
1521 if test $target_os = solaris
1523 test -f /usr/xpg4/bin/grep && grep=/usr/xpg4/bin/grep
1527 dnl checks for /proc pseudo file system
1528 AC_MSG_CHECKING([for /proc ])
1529 if test "$cross_compiling" = "yes"; then
1531 echo "cross-compile -> \"$ans\"" >&5
1541 AC_DEFINE(HAVE_PROCFS, [1], [Support for /proc pseudo-filesystem])
1546 dnl Checks for C header files.
1550 AC_CHECK_HEADERS(fcntl.h limits.h malloc.h strings.h syslog.h)
1551 AC_CHECK_HEADERS(stddef.h sched.h dlfcn.h dl.h)
1552 AC_CHECK_HEADERS(sys/times.h sys/resource.h sys/prctl.h)
1553 AC_CHECK_HEADERS(sys/sysinfo.h sys/systeminfo.h)
1554 AC_CHECK_HEADERS(endian.h standards.h sys/byteorder.h)
1555 AC_CHECK_HEADERS(libgen.h sys/mman.h sys/un.h)
1556 AC_CHECK_HEADERS(values.h stdint.h ieeefp.h math.h)
1557 AC_CHECK_HEADERS(pwd.h grp.h regex.h sys/wait.h)
1558 AC_CHECK_HEADERS(termio.h termios.h sys/termios.h)
1559 AC_CHECK_HEADERS(sys/ioctl.h sys/select.h sys/socket.h)
1560 AC_CHECK_HEADERS(netdb.h)
1561 if test $target_os = darwin -o $target_os = openbsd
1563 AC_CHECK_HEADERS(net/if.h, [], [], [#include <sys/types.h>
1564 #include <sys/socket.h>])
1566 AC_CHECK_HEADERS(net/if.h)
1568 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h arpa/inet.h)
1569 AC_CHECK_HEADERS(windows.h winsock2.h ws2tcpip.h)
1570 AC_CHECK_HEADERS(execinfo.h bits/wordsize.h)
1571 AC_CHECK_HEADERS(iptypes.h, [], [], [#include <windows.h>])
1572 AC_CHECK_HEADERS(iphlpapi.h, [], [], [#include <winsock2.h>])
1573 AC_CHECK_HEADERS(fts.h libzfs.h)
1574 AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/mount.h)
1576 dnl Check if we have <sys/endian.h> ... standard way
1577 AC_MSG_CHECKING([for sys/endian.h ])
1580 #include <sys/endian.h>
1583 ], AC_DEFINE(HAVE_SYS_ENDIAN_H, [1], [sys/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1585 dnl Check if we have <machine/endian.h> ... MacOSX way
1586 AC_MSG_CHECKING([for machine/endian.h ])
1589 #include <machine/endian.h>
1592 ], AC_DEFINE(HAVE_MACHINE_ENDIAN_H, [1], [machine/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1594 dnl Check if we have <sys/endian.h> ... IRIX strangeness
1595 AC_MSG_CHECKING([for sys/endian.h (IRIX variant) ])
1598 #include <standards.h>
1599 #include <sys/endian.h>
1602 ], AC_DEFINE(HAVE_SYS_ENDIAN_H, [1], [IRIX sys/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1604 dnl Checks for typedefs, structures, and compiler characteristics.
1613 dnl check if regex functions come from libregex (mingw)
1614 AC_CHECK_LIB(regex, regcomp)
1616 if test $ac_cv_lib_regex_regcomp = yes
1618 lib_for_regex="-lregex"
1620 AC_SUBST(lib_for_regex)
1622 PKG_CHECK_MODULES([ncurses], [ncurses], [have_ncurses=true], [have_ncurses=false])
1623 AC_SUBST(HAVE_NCURSES, [$have_ncurses])
1625 PKG_CHECK_MODULES([SYSTEMD], [libsystemd],
1626 [pmda_systemd=true], [pmda_systemd=false])
1631 dnl libsystemd-journal is an alternative for older distros
1632 PKG_CHECK_MODULES([SYSTEMD], [libsystemd-journal],
1633 [pmda_systemd=true], [pmda_systemd=false])
1635 AC_MSG_CHECKING([if the systemd PMDA should be included])
1636 AC_SUBST(PMDA_SYSTEMD, $pmda_systemd)
1637 if $pmda_systemd; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1639 pmda_infiniband=false
1640 AS_IF([test "x$do_infiniband" != "xno"], [
1641 AC_CHECK_HEADERS([infiniband/umad.h], [
1642 AC_CHECK_HEADERS([infiniband/mad.h], [pmda_infiniband=true], [])
1646 AC_CHECK_LIB(ibmad, madrpc_init)
1647 AC_CHECK_LIB(ibumad, umad_init)
1648 if test $ac_cv_lib_ibmad_madrpc_init = yes -a $ac_cv_lib_ibumad_umad_init = yes
1650 IB_LIBS="-libmad -libumad"
1652 AC_MSG_CHECKING([for port_performance_query_via])
1653 AC_TRY_LINK_FUNC(port_performance_query_via,
1654 AC_DEFINE(HAVE_PORT_PERFORMANCE_QUERY_VIA, [1], [port_performance_query_via API])
1655 have_port_performance_query_via=true
1657 have_port_performance_query_via=false
1659 AC_MSG_CHECKING([for pma_query_via])
1660 AC_TRY_LINK_FUNC(pma_query_via,
1661 AC_DEFINE(HAVE_PMA_QUERY_VIA, [1], [pma_query_via API])
1662 have_pma_query_via=true
1664 have_pma_query_via=false
1667 if test $have_pma_query_via -o $have_port_performance_query_via
1671 pmda_infiniband=false
1674 pmda_infiniband=false
1679 AC_MSG_CHECKING([if the infiniband PMDA should be included])
1680 AC_SUBST(PMDA_INFINIBAND, $pmda_infiniband)
1681 if $pmda_infiniband; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1684 AS_IF([test "x$do_papi" != "xno"], [
1687 saved_LDFLAGS="$LDFLAGS"
1688 saved_CFLAGS="$CFLAGS"
1691 dnl potentially from the environment, else empty
1692 CFLAGS="$papi_CFLAGS"
1693 LDFLAGS="$papi_LIBS"
1699 PAPI_ROOTDIR=$do_papi;
1700 CFLAGS="-I$PAPI_ROOTDIR/include"
1701 LDFLAGS="-L$PAPI_ROOTDIR/lib"
1704 PKG_CHECK_MODULES(papi,[$do_papi],[
1705 CFLAGS="$papi_CFLAGS"
1706 LDFLAGS="$papi_LIBS"])
1710 # $papi_LIBS may include -lpapi harmlessly redudantly with AC_CHECK_LIB
1711 AC_CHECK_LIB([papi], [PAPI_library_init],
1712 [papi_libs="$LDFLAGS -lpapi"],
1713 [enable_papi=false])
1714 AC_CHECK_HEADERS([papi.h], [papi_cflags="$CFLAGS"], [enable_papi=false])
1715 if test "$do_papi" != "check" -a "$enable_papi" != "true"
1717 AC_MSG_ERROR([PAPI is not installed, cannot enable the PAPI PMDA])
1719 pmda_papi=$enable_papi
1722 CFLAGS="$saved_CFLAGS"
1723 LDFLAGS="$saved_LDFLAGS"
1724 AC_SUBST(PAPI_CFLAGS, $papi_cflags)
1725 AC_SUBST(PAPI_LIBS, $papi_libs)
1727 AC_MSG_CHECKING([if the papi PMDA should be included])
1728 AC_SUBST(PMDA_PAPI, $pmda_papi)
1729 if $pmda_papi; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1731 AS_IF([test "x$pmda_papi" = "xtrue"], [
1732 dnl check if struct PAPI_component_info_t has a disabled field
1733 AC_MSG_CHECKING([whether struct PAPI_component_info_t has a disabled field])
1734 cat <<End-of-File >conftest.c
1736 int main() { PAPI_component_info_t *c; c->disabled = 0; }
1738 (eval $ac_compile) 2>conftest.out
1739 cat conftest.out >&5
1740 if test -s conftest.out
1744 AC_DEFINE(HAVE_PAPI_DISABLED_COMP, [1], [PAPI_component_info_t field])
1751 pmda_perfevent=false
1752 AS_IF([test "x$do_perfevent" = "xyes"], [
1755 AC_SUBST(PFM_LIBS, $pfm_libs)
1756 ], [test "x$do_perfevent" != "xno" ], [
1757 enable_perfevent=true
1760 AC_CHECK_LIB([pfm], [pfm_get_os_event_encoding],
1762 [enable_perfevent=false])
1763 AC_CHECK_HEADERS([perfmon/pfmlib_perf_event.h], [], [enable_perfevent=false])
1764 if test "$do_perfevent" != "check" -a "$enable_perfevent" != "true"
1766 AC_MSG_ERROR([libpfm is not installed, cannot enable the perfevent PMDA])
1768 pmda_perfevent=$enable_perfevent
1771 AC_SUBST(PFM_LIBS, $pfm_libs)
1773 AC_MSG_CHECKING([if the perfevent PMDA should be included])
1774 AC_SUBST(PMDA_PERFEVENT, $pmda_perfevent)
1775 if $pmda_perfevent; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1777 dnl Do you have RPM Package Manager libraries for pmdarpm?
1780 AC_MSG_CHECKING([for rpmlib > 4.4.2])
1782 [AC_LANG_PROGRAM([[#include <rpm/header.h>]],
1783 [[(void)HEADERGET_EXT;]])],
1784 [AC_MSG_RESULT([yes])
1786 [AC_MSG_RESULT([no])])
1787 AC_MSG_CHECKING([if the rpm PMDA should be included])
1788 AC_SUBST(PMDA_RPM,$pmda_rpm)
1789 if $pmda_rpm; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1792 dnl Do you have the required qshape script for the postfix PMDA
1793 dnl The logic here is copied from the PMDA's Install script
1795 AC_CHECK_PROGS(QSHAPE, qshape, [], path=[$PATH:/usr/sbin])
1796 AC_MSG_CHECKING([if the postfix PMDA should be included])
1797 if test -n "$QSHAPE"
1801 for script in /usr/share/doc/packages/postfix-doc/auxiliary/qshape/qshape.pl
1803 if test -f "$script"
1810 AC_SUBST(PMDA_POSTFIX,$pmda_postfix)
1811 if $pmda_postfix; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1813 dnl Do you have system microhttpd libraries for pmwebapi?
1814 PKG_CHECK_MODULES([libmicrohttpd], [libmicrohttpd > 0.9.9], [have_libmicrohttpd=true], [have_libmicrohttpd=false])
1815 AC_SUBST(HAVE_LIBMICROHTTPD, [$have_libmicrohttpd])
1817 dnl Do you have graphics libraries for pmwebapi?
1818 PKG_CHECK_MODULES([cairo], [cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2], [have_cairo=true], [have_cairo=false])
1819 AC_SUBST(HAVE_CAIRO, [$have_cairo])
1822 AS_IF([test "x$do_webapi" != "xno"], [
1825 if test "$have_libmicrohttpd" != "true"
1828 test "$do_webapi" != "check" && \
1829 AC_MSG_ERROR([libmicrohttpd is not installed, cannot enable the web API])
1830 elif test "$do_webapi" != "check" -a "x$cxx" = "x"
1833 test "$do_webapi" != "check" && \
1834 AC_MSG_ERROR([C++ compiler unavailable, cannot enable the web API])
1837 AC_SUBST(enable_webapi)
1839 enable_manager=false
1840 AS_IF([test "x$do_manager" != "xno"], [
1843 if test "$target_os" = "mingw"
1845 enable_manager=false
1846 test "$do_manager" != "check" && \
1847 AC_MSG_ERROR([MinGW build, cannot enable daemon manager])
1848 elif test "x$cxx" = "x"
1850 enable_manager=false
1851 test "$do_manager" != "check" && \
1852 AC_MSG_ERROR([C++ compiler unavailable, cannot enable daemon manager])
1854 AC_MSG_CHECKING([compilation features for daemon manager])
1856 [ #ifndef _XOPEN_SOURCE
1857 #define _XOPEN_SOURCE 600
1862 enable_manager=false
1865 AC_SUBST(enable_manager)
1867 AC_CHECK_PROGS(SEINFO, seinfo)
1869 enable_selinux=false
1870 AS_IF([test "x$do_selinux" != "xno"], [
1871 for makefile in /usr/share/selinux/devel/Makefile
1873 if test -f "$makefile" -a "x$SEINFO" != "x"
1879 AC_SUBST(enable_selinux)
1880 AC_SUBST(pcp_selinux_dir)
1882 pcp_selinux_class_status=false
1883 pcp_selinux_cap_userns_ptrace=false
1884 pcp_selinux_container_runtime=false
1885 pcp_selinux_nsfs=false
1886 pcp_selinux_docker_var_lib=false
1887 pcp_selinux_svirt_lxc_net=false
1888 pcp_selinux_systemd_unit_file=false
1889 pcp_selinux_systemd_exec=false
1890 pcp_selinux_tracefs=false
1891 pcp_selinux_unreserved_port=false
1892 AS_IF([test "x$enable_selinux" != "xfalse"], [
1893 for policy_file in /etc/selinux/targeted/policy/policy.*
1895 if test -f "$policy_file"
1897 class_status=`eval seinfo -x --class=system $policy_file | grep status | awk '{ print $1 }'`
1898 if test "x$class_status" != "x"
1900 pcp_selinux_class_status=true
1902 container_runtime=`eval seinfo -t $policy_file | grep container_runtime_t | awk '{ print $1 }'`
1903 if test "x$container_runtime" != "x"
1905 pcp_selinux_container_runtime=true
1907 nsfs=`eval seinfo -t $policy_file | grep nsfs_t | awk '{ print $1 }'`
1908 if test "x$nsfs" != "x"
1910 pcp_selinux_nsfs=true
1912 docker_var_lib=`eval seinfo -t $policy_file | grep docker_var_lib_t | awk '{ print $1 }'`
1913 if test "x$docker_var_lib" != "x"
1915 pcp_selinux_docker_var_lib=true
1917 svirt_lxc_net=`eval seinfo -t $policy_file | grep svirt_lxc_net_t | awk '{ print $1 }'`
1918 if test "x$svirt_lxc_net" != "x"
1920 pcp_selinux_svirt_lxc_net=true
1922 systemd_unit_file=`eval seinfo -t $policy_file | grep systemd_unit_file_t | awk '{ print $1 }'`
1923 if test "x$systemd_unit_file" != "x"
1925 pcp_selinux_systemd_unit_file=true
1927 systemd_exec=`eval seinfo -t $policy_file | grep systemd_systemctl_exec_t | awk '{ print $1 }'`
1928 if test "x$systemd_exec" != "x"
1930 pcp_selinux_systemd_exec=true
1932 cap_userns_ptrace=`eval seinfo -x --class=cap_userns $policy_file 2>&1 | grep sys_ptrace | awk '{ print $1 }'`
1933 if test "x$cap_userns_ptrace" != "x"
1935 pcp_selinux_cap_userns_ptrace=true
1937 unreserved_port=`eval seinfo -t $policy_file | grep unreserved_port_t | awk '{ print $1 }'`
1938 if test "x$unreserved_port" != "x"
1940 pcp_selinux_unreserved_port=true
1942 tracefs=`eval seinfo -t $policy_file | grep tracefs_t | awk '{ print $1 }'`
1943 if test "x$tracefs" != "x"
1945 pcp_selinux_tracefs=true
1951 AC_SUBST(pcp_selinux_class_status)
1952 AC_SUBST(pcp_selinux_cap_userns_ptrace)
1953 AC_SUBST(pcp_selinux_container_runtime)
1954 AC_SUBST(pcp_selinux_nsfs)
1955 AC_SUBST(pcp_selinux_docker_var_lib)
1956 AC_SUBST(pcp_selinux_svirt_lxc_net)
1957 AC_SUBST(pcp_selinux_systemd_unit_file)
1958 AC_SUBST(pcp_selinux_systemd_exec)
1959 AC_SUBST(pcp_selinux_unreserved_port)
1960 AC_SUBST(pcp_selinux_tracefs)
1962 dnl Checks for library functions.
1966 AC_CHECK_FUNCS(mktime nanosleep usleep unsetenv)
1967 AC_CHECK_FUNCS(select socket gethostname getpeerucred getpeereid)
1968 AC_CHECK_FUNCS(uname syslog __clone pipe2 fcntl ioctl)
1969 AC_CHECK_FUNCS(prctl setlinebuf waitpid atexit kill)
1970 AC_CHECK_FUNCS(chown fchmod getcwd scandir mkstemp)
1971 AC_CHECK_FUNCS(brk sbrk posix_memalign memalign valloc)
1972 AC_CHECK_FUNCS(signal sighold sigrelse tcgetattr)
1973 AC_CHECK_FUNCS(regex regcmp regexec regcomp)
1974 AC_CHECK_FUNCS(strtod strtol strtoll strtoull strndup strchrnul)
1975 AC_CHECK_FUNCS(getuid getgid)
1976 AC_CHECK_FUNCS(getgrent getgrent_r getgrnam getgrnam_r getgrgid getgrgid_r)
1977 AC_CHECK_FUNCS(getpwent getpwent_r getpwnam getpwnam_r getpwuid getpwuid_r)
1978 AC_CHECK_FUNCS(sysinfo trace_back_stack backtrace)
1979 AC_CHECK_FUNCS(sendmsg recvmsg setns)
1981 dnl only define readdir64 on non-linux platforms that support it
1982 if test $target_os != linux -a $target_os != freebsd -a $target_os != kfreebsd -a $target_os != netbsd; then
1983 AC_CHECK_FUNCS(readdir64)
1986 dnl typedefs missing from sys/types.h, stdlib.h or stddef.h
1987 if test $target_os = solaris
1989 AC_CHECK_TYPE(__int32_t, int32_t)
1990 AC_CHECK_TYPE(__uint32_t, uint32_t)
1991 AC_CHECK_TYPE(__int64_t, int64_t)
1992 AC_CHECK_TYPE(__uint64_t, uint64_t)
1993 AC_CHECK_TYPE(uint_t, u_int32_t)
1995 AC_CHECK_TYPE(__int32_t, int)
1996 AC_CHECK_TYPE(__uint32_t, unsigned int)
1997 AC_CHECK_TYPE(__int64_t, long long)
1998 AC_CHECK_TYPE(__uint64_t, unsigned long long)
1999 AC_CHECK_TYPE(uint_t, unsigned int)
2002 dnl check if we have a type for the pointer's size integer (__psint_t)
2003 AC_MSG_CHECKING([for __psint_t ])
2006 #include <sys/types.h>
2009 ], [ __psint_t psint; ],
2010 AC_DEFINE(HAVE___PSINT_T, [1], [__psint_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2012 dnl check if we have a type for pointer difference (ptrdiff_t)
2013 AC_MSG_CHECKING([for ptrdiff_t ])
2016 #ifdef HAVE_MALLOC_H
2019 ], [ ptrdiff_t ptrdiff; ],
2020 AC_DEFINE(HAVE_PTRDIFF_T, [1], [ptrdiff_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2022 dnl check if we have types for uid_t, gid_t (POSIX) or SID (Win32)
2023 AC_MSG_CHECKING([for uid_t ])
2025 #include <sys/types.h>
2030 AC_DEFINE(HAVE_UID_T, [1], [uid_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2031 AC_MSG_CHECKING([for gid_t ])
2033 #include <sys/types.h>
2038 AC_DEFINE(HAVE_GID_T, [1], [gid_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2039 AC_MSG_CHECKING([for SID ])
2041 #ifdef HAVE_WINDOWS_H
2042 #include <windows.h>
2045 AC_DEFINE(HAVE_SID, [1], [sid type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2047 dnl check if we have a type for socklen_t
2048 AC_MSG_CHECKING([for socklen_t ])
2050 #include <sys/types.h>
2051 #ifdef HAVE_SYS_SOCKET_H
2052 #include <sys/socket.h>
2054 ], [ socklen_t len; ],
2055 AC_DEFINE(HAVE_SOCKLEN_T, [1], [socklen_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2057 dnl check if LL suffix on constants is supported
2060 ], [ long long x = 0LL; ],
2061 AC_DEFINE(HAVE_CONST_LONGLONG, [1], [LL suffix on constants]))
2063 dnl check if _environ is declared globally
2067 ], [ char **x = _environ; ],
2068 AC_DEFINE(HAVE_UNDERBAR_ENVIRON, [1], [_environ declared globally]))
2070 dnl check for PR_TERMCHILD and PR_SET_PDEATHSIG in <sys/prctl.h>
2071 AC_MSG_CHECKING([for PR_TERMCHILD constant in sys/prctl.h])
2073 #ifdef HAVE_SYS_PRCTL_H
2074 #include <sys/prctl.h>
2076 ], [ int i = PR_TERMCHILD; ],
2077 AC_DEFINE(HAVE_PR_TERMCHILD, [1], [PR_TERMCHILD constant]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2079 AC_MSG_CHECKING([for PR_SET_PDEATHSIG constant in sys/prctl.h])
2081 #ifdef HAVE_SYS_PRCTL_H
2082 #include <sys/prctl.h>
2084 ], [ int i = PR_SET_PDEATHSIG; ],
2085 AC_DEFINE(HAVE_PR_SET_PDEATHSIG, [1], [PR_SET_PDEATHSIG constant]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2087 AC_HEADER_TIOCGWINSZ
2089 dnl check if linker needs -rdynamic for dynamically loaded shared
2090 dnl libraries to see the symbols in the process loading them.
2091 dnl This is e.g., needed on linux for pmcd loading pmda_pmcd.so.
2092 AC_MSG_CHECKING([if linker supports -rdynamic])
2093 save_CFLAGS="$CFLAGS"
2095 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2096 [AC_MSG_RESULT([yes])
2097 rdynamic_flag=-rdynamic],
2098 [AC_MSG_RESULT([no])
2101 CFLAGS="$save_CFLAGS"
2102 AC_SUBST([rdynamic_flag])
2105 dnl check if argument to user's select() method in scandir call is const
2106 AC_MSG_CHECKING([whether const arg for scandir() select method])
2107 cat <<End-of-File >conftest.c
2112 my_select(const struct dirent *foo) { return 0; }
2113 int main() { struct dirent **list; return scandir(".", &list, my_select, NULL); }
2115 (eval $ac_compile) 2>conftest.out
2116 cat conftest.out >&5
2117 if test -s conftest.out
2121 AC_DEFINE(HAVE_CONST_DIRENT, [1], [const arg for scandir() select method])
2126 dnl check if struct dirent has a d_off (directory offset) field
2127 AC_MSG_CHECKING([whether struct dirent has a d_off field])
2128 cat <<End-of-File >conftest.c
2132 int main() { struct dirent d; d.d_off = 0; }
2134 (eval $ac_compile) 2>conftest.out
2135 cat conftest.out >&5
2136 if test -s conftest.out
2140 AC_DEFINE(HAVE_DIRENT_D_OFF, [1], [struct dirent d_off field])
2145 dnl check if printf %p has 0x prefix
2146 AC_MSG_CHECKING([if printf %p produces 0x prefix])
2147 if test "$cross_compiling" = "yes"; then
2148 ans=$printf_p_prefix
2149 echo "cross-compile -> \"$ans\"" >&5
2151 cat <<End-of-File >conftest.c
2153 int main(int argc, char **argv) { printf("%p", argv); return(0); }
2155 (eval $ac_compile) 2>&5
2156 (eval $ac_link) 2>&5
2158 echo "./conftest -> \"$ans\"" >&5
2163 AC_DEFINE(HAVE_PRINTF_P_PFX, [1], [printf %p produces 0x])
2170 rm -rf conftest conftest.*
2174 # need to deal with this sort of cpp output ...
2175 # typedef long pid_t;
2176 # typedef unsigned int pid_t;
2177 # typedef unsigned int pid_t __attribute__ ((__mode__ (__SI__)));
2178 # __extension__ typedef int pid_t;
2185 # and chaining of the form
2186 # typedef long __pid_t;
2187 # typedef __pid_t pid_t;
2189 _raw=`$CPP conftest.c \
2191 -e 's/[[ ]]__attribute__ ((.*));/;/' \
2192 -e 's/__extension__[[ ]][[ ]]*//' \
2194 /bozo/ { print; next }
2195 $1 == "typedef" { printf "%s",$0
2201 if ($0 ~ /{/) depth = 1
2204 wantsemi == 1 { printf " %s",$0
2205 if ($0 ~ /{/) depth++
2207 if ($0 ~ /}/) depth--
2221 $1 == "typedef" { map[[$NF]] = ""
2222 for (i = 2; i < NF; i++) {
2226 map[[$NF]] = map[[$NF]] " " $i
2228 print $NF " -> " map[[$NF]] >"conftest.debug"
2231 $2 == "bozo" { t = $1
2232 printf "best guess: %s",t >"conftest.debug"
2233 while (map[[t]] != "") {
2235 printf " -> %s",t >"conftest.debug"
2237 print "" >"conftest.debug"
2246 unsigned|'unsigned int')
2252 'long long'|'long long int')
2253 if test $target_os = mingw; then
2259 'unsigned long'|'unsigned long int'|'long unsigned int')
2262 'unsigned long long'|'unsigned long long int')
2263 if test $target_os = mingw; then
2269 *\*) # pointer to a something
2272 struct\ *) # not much can be done here ...
2277 echo "FATAL ERROR: don't know what to do with type \"$_raw\""
2278 echo "... typedef mapping ..."
2280 rm -rf conftest conftest.*
2286 dnl printf type for pid_t
2287 AC_MSG_CHECKING([printf type for pid_t])
2288 if test "$cross_compiling" = "yes"; then
2290 echo "cross-compile -> \"$ans\"" >&5
2293 cat <<End-of-File >conftest.c
2294 #include <sys/types.h>
2301 AC_MSG_RESULT($fmt_pid)
2303 rm -rf conftest.c conftest.debug
2305 dnl printf type for int64_t
2306 AC_MSG_CHECKING([printf type for int64_t ])
2307 if test "$cross_compiling" = "yes"; then
2308 ans=$printf_fmt_int64
2309 echo "cross-compile -> \"$ans\"" >&5
2311 cat <<End-of-File >conftest.c
2314 #include <inttypes.h>
2317 printf("\"%s\"\n", __PRI64_PREFIX "d");
2322 (eval $ac_link) 2>&5
2323 if test -x ./conftest
2326 echo "./conftest -> \"$ans\"" >&5
2330 dnl have to try the hardway ...
2331 cat <<End-of-File >conftest.c
2338 int64_t bozo = 0x12345678abcdLL;
2339 sprintf(buf, "%lx", bozo);
2340 if (strcmp(buf, "12345678abcd") == 0)
2343 sprintf(buf, "%llx", bozo);
2344 if (strcmp(buf, "12345678abcd") == 0)
2345 printf("\"lld\"\n");
2350 (eval $ac_link) 2>&5
2351 if test -x ./conftest
2354 echo "./conftest -> \"$ans\"" >&5
2360 echo 'FATAL ERROR: Cannot determine printf format for int64_t type'
2361 rm -rf conftest conftest.*
2365 AC_MSG_RESULT("$fmt_int64")
2367 dnl and the unsigned version of this ...
2368 fmt_uint64=`echo $fmt_int64 | sed -e 's/d"/u"/'`
2369 AC_SUBST(fmt_uint64)
2370 rm -rf conftest.* conftest
2372 AC_MSG_CHECKING([strtol or strtoll for int64_t])
2373 if test "$cross_compiling" = "yes"; then
2375 echo "cross-compile -> \"$ans\"" >&5
2377 cat <<End-of-File >conftest.c
2382 long long int value = -1;
2383 value = strtol("1234567812345678", NULL, 16);
2384 if (value == 0x1234567812345678LL) {
2385 printf("strotol\n");
2388 value = strtoll("1234567812345678", NULL, 16);
2389 if (value == 0x1234567812345678LL) {
2390 printf("strtoll\n");
2396 (eval $ac_compile) 2>&5
2397 (eval $ac_link) 2>&5
2399 echo "./conftest -> \"$ans\"" >&5
2404 AC_DEFINE(strtoint64, [strtol], [Define strtoint64 as strtol])
2405 AC_DEFINE(strtouint64, [strtoul], [Define strtoint64 as strtoul])
2406 AC_MSG_RESULT([strtol])
2409 AC_DEFINE(strtoint64, [strtoll], [Define strtoint64 as strtoll])
2410 AC_DEFINE(strtouint64, [strtoull], [Define strtoint64 as strtoull])
2411 AC_MSG_RESULT([strtoll])
2414 AC_DEFINE(strtoint64, [strtoll], [Default strtoint64 to strtoll])
2415 AC_DEFINE(strtouint64, [strtoull], [Default strtouint64 to strtoull])
2416 AC_MSG_RESULT([assuming strtoll])
2419 rm -rf conftest conftest.*
2421 if test "$do_threads" = "check" -o "$do_threads" = "yes"
2427 if test "$do_threads" = "yes"
2429 AC_MSG_ERROR([cannot enable multi-threaded mode - no pthread.h])
2433 dnl Check if pthread_mutex_t is defined in pthread.h
2434 dnl Ignore the fact that pthread.h could be missing - we don't
2435 dnl really care if this test fails because of missing pthread_mutex_t
2436 dnl or because of missing headers.
2437 AC_MSG_CHECKING([for pthread_mutex_t in pthread.h])
2439 [#include <pthread.h>], [pthread_mutex_t mymutex;],
2440 AC_DEFINE(HAVE_PTHREAD_MUTEX_T, [1], [pthread_mutex_t type]) AC_MSG_RESULT(yes),
2442 if test "$do_threads" = "yes"
2444 AC_MSG_ERROR([cannot enable multi-threaded mode - no mutexes])
2450 dnl Check which library provide pthread stuff
2451 AC_MSG_CHECKING([where pthread_create() is defined])
2452 for cand in "" pthreads pthread ; do
2456 LIBS=`echo $LIBS -l$cand`
2460 #include <pthread.h>
2463 pthread_create(NULL, NULL, NULL, NULL);
2464 ], AC_MSG_RESULT(lib${cand:-c})
2467 lib_for_pthreads="$cand"
2469 lib_for_pthreads="-l$cand"
2475 AC_SUBST(lib_for_pthreads)
2477 if test "$ac_cv_header_pthread_h" = "yes"
2479 dnl printf type for pthread_t
2480 AC_MSG_CHECKING([printf type for pthread_t])
2481 cat <<End-of-File >conftest.c
2482 #include <pthread.h>
2487 AC_MSG_RESULT($fmt_pthread)
2488 AC_SUBST(fmt_pthread)
2489 rm -rf conftest.c conftest.debug
2491 dnl check if gcc supports __thread for thread private data
2492 AC_MSG_CHECKING([if compiler supports __thread])
2493 dnl __thread support is broken in some places
2494 if test $target_os = netbsd
2496 AC_TRY_COMPILE([#include <pthread.h>
2497 #if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 5 )
2502 AC_DEFINE(HAVE___THREAD, [1], [__thread private data]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2504 AC_TRY_COMPILE([#include <pthread.h>
2505 __thread int x;], [],
2506 AC_DEFINE(HAVE___THREAD, [1], [__thread private data]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2509 dnl Check if pthread_barrier_t is defined in pthread.h
2510 AC_MSG_CHECKING([for pthread_barrier_t in pthread.h])
2511 AC_TRY_COMPILE([#include <pthread.h>], [pthread_barrier_t mybarrier;],
2512 AC_DEFINE(HAVE_PTHREAD_BARRIER_T, [1], [pthread_barrier_t type]) AC_MSG_RESULT(yes),
2517 AC_MSG_CHECKING([sizeof suseconds_t])
2518 if test "$cross_compiling" = "yes"; then
2519 ans=$sizeof_suseconds_t
2520 echo "cross-compile -> \"$ans\"" >&5
2522 cat <<End-of-File >conftest.c
2523 #include <sys/time.h>
2524 main() { printf("%d", (int)sizeof(suseconds_t)); }
2526 (eval $ac_compile) 2>&5
2527 (eval $ac_link) 2>&5
2529 echo "./conftest -> \"$ans\"" >&5
2530 rm -rf conftest conftest.*
2533 AC_DEFINE_UNQUOTED(PM_SIZEOF_SUSECONDS_T, $ans, [sizeof suseconds_t])
2535 AC_MSG_CHECKING([sizeof time_t])
2536 if test "$cross_compiling" = "yes"; then
2538 echo "cross-compile -> \"$ans\"" >&5
2540 cat <<End-of-File >conftest.c
2541 #include <sys/time.h>
2542 main() { printf("%d", (int)sizeof(time_t)); }
2544 (eval $ac_compile) 2>&5
2545 (eval $ac_link) 2>&5
2547 echo "./conftest -> \"$ans\"" >&5
2548 rm -rf conftest conftest.*
2551 AC_DEFINE_UNQUOTED(PM_SIZEOF_TIME_T, $ans, [sizeof time_t])
2553 dnl check sizeof long
2554 AC_MSG_CHECKING([sizeof long])
2555 if test "$cross_compiling" = "yes"; then
2557 echo "cross-compile -> \"$ans\"" >&5
2559 cat <<End-of-File >conftest.c
2561 main() { printf("%d", (int)sizeof(long)); }
2563 (eval $ac_compile) 2>&5
2564 (eval $ac_link) 2>&5
2566 echo "./conftest -> \"$ans\"" >&5
2569 if test "$ans" = 4; then
2570 AC_DEFINE(HAVE_32BIT_LONG, [1], [sizeof long])
2571 elif test "$ans" = 8; then
2572 AC_DEFINE(HAVE_64BIT_LONG, [1], [sizeof long])
2575 echo "FATAL ERROR: size of long is not 32 or 64 bits, cannot proceed."
2576 echo "sizeof(char *) -> $ans"
2577 rm -rf conftest conftest.*
2580 rm -rf conftest conftest.*
2582 dnl check sizeof pointer
2583 AC_MSG_CHECKING([sizeof pointer])
2584 if test "$cross_compiling" = "yes"; then
2586 echo "cross-compile -> \"$ans\"" >&5
2588 cat <<End-of-File >conftest.c
2590 main() { printf("%d", (int)sizeof(char *)); }
2592 (eval $ac_compile) 2>&5
2593 (eval $ac_link) 2>&5
2595 echo "./conftest -> \"$ans\"" >&5
2598 if test "$ans" = 4; then
2599 AC_DEFINE(HAVE_32BIT_PTR, [1], [pointer size])
2601 elif test "$ans" = 8; then
2602 AC_DEFINE(HAVE_64BIT_PTR, [1], [pointer size])
2606 echo "FATAL ERROR: size of pointer is not 32 or 64 bits, cannot proceed."
2607 echo "sizeof(char *) -> $ans"
2608 rm -rf conftest conftest.*
2611 rm -rf conftest conftest.*
2613 dnl check sizeof int. If not 32, we die
2614 AC_MSG_CHECKING([sizeof int])
2615 if test "$cross_compiling" = "yes"; then
2617 echo "cross-compile -> \"$ans\"" >&5
2619 cat <<End-of-File >conftest.c
2621 main() { printf("%d", (int)sizeof(int)); }
2623 (eval $ac_compile) 2>&5
2624 (eval $ac_link) 2>&5
2626 echo "./conftest -> \"$ans\"" >&5
2632 echo "FATAL ERROR: sizeof(int) is not 32 bits, cannot proceed."
2633 echo "Note: 32-bit ints are assumed in the PCP external file formats and"
2634 echo " the over-the-wire PDU formats"
2635 rm -rf conftest conftest.*
2638 rm -rf conftest conftest.*
2640 dnl check bit field allocation order within a word
2641 AC_MSG_CHECKING([if bit fields allocated left-to-right])
2642 if test "$cross_compiling" = "yes"; then
2643 ans=$bit_field_scheme
2644 echo "cross-compile -> \"$ans\"" >&5
2646 cat <<End-of-File >conftest.c
2647 union { struct { unsigned int b:4; unsigned int c:4; } a; int p; } u;
2648 main() { u.a.b = 1; u.a.c = 2; printf("%0*x", 2*sizeof(int), u.p); }
2650 (eval $ac_compile) 2>&5
2651 (eval $ac_link) 2>&5
2653 echo "./conftest -> \"$ans\"" >&5
2658 # left-to-right starting from MSB (SGI cc on MIPS), or
2659 # left-to-right ending at LSB
2660 AC_DEFINE(HAVE_BITFIELDS_LTOR, [1], [left-to-right bitfield ordering])
2664 # right-to-left ending at MSB, or
2665 # right-to-left starting from LSB (gcc in Intel)
2669 AC_MSG_RESULT(unknown)
2670 echo "FATAL ERROR: could not fathom your compiler's bit field allocation scheme"
2671 rm -f conftest conftest.*
2675 rm -rf conftest conftest.*
2677 dnl check if compiler can cast __uint64_t to double
2685 double y = (double)x;
2686 ], AC_DEFINE(HAVE_CAST_U64_DOUBLE, [1], [compiler casts u64 to double]))
2688 dnl check if basename and dirname need -lgen, -lpcp or nothing to work
2689 dnl (assume both go together)
2690 AC_CHECK_FUNCS(basename)
2691 if test $ac_cv_func_basename = yes
2693 AC_DEFINE(HAVE_BASENAME, [1], [basename API])
2694 AC_DEFINE(HAVE_DIRNAME, [1], [dirname API])
2697 AC_CHECK_LIB(gen, basename)
2698 if test $ac_cv_lib_gen_basename = yes
2700 AC_DEFINE(HAVE_BASENAME, [1], [basename API])
2701 AC_DEFINE(HAVE_DIRNAME, [1], [dirname API])
2702 lib_for_basename="-lgen"
2704 lib_for_basename="-lpcp"
2707 AC_SUBST(lib_for_basename)
2709 dnl check if clock_gettime needs -lrt to work
2710 lib_for_clock_gettime=
2711 AC_CHECK_FUNCS(clock_gettime)
2712 if test $ac_cv_func_clock_gettime = no
2714 AC_CHECK_LIB(rt, clock_gettime)
2715 if test $ac_cv_lib_rt_clock_gettime = yes
2717 AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [clock_gettime API])
2721 AC_SUBST(lib_for_rt)
2723 dnl check if dlopen et al need -ldl to work
2725 AC_CHECK_FUNCS(dlopen)
2726 if test $ac_cv_func_dlopen = no
2728 AC_CHECK_LIB(dl, dlopen)
2729 if test $ac_cv_lib_dl_dlopen = yes
2731 AC_DEFINE(HAVE_DLOPEN, [1], [dlopen API])
2735 AC_SUBST(lib_for_dlopen)
2737 dnl check if flog10, pow, fpclassify and isnanf are available
2738 dnl in the maths library
2740 AC_CHECK_FUNCS(flog10)
2741 if test $ac_cv_func_flog10 = no
2743 AC_CHECK_LIB(m, flog10)
2744 if test $ac_cv_lib_m_flog10 = yes
2746 AC_DEFINE(HAVE_FLOG10, [1], [flog10 math API])
2750 AC_DEFINE(HAVE_FLOG10, [1], [flog10 math API])
2753 if test $ac_cv_func_pow = no
2755 AC_CHECK_LIB(m, pow)
2756 if test $ac_cv_lib_m_pow = yes
2758 AC_DEFINE(HAVE_POW, [1], [pow math API])
2762 AC_DEFINE(HAVE_POW, [1], [pow math API])
2764 AC_MSG_CHECKING([for fpclassify()])
2765 ac_cv_func_fpclassify=no
2772 if (fpclassify(x) == FP_NAN) exit(1);
2773 ], ac_cv_func_fpclassify=yes)
2774 AC_MSG_RESULT($ac_cv_func_fpclassify)
2775 if test $ac_cv_func_fpclassify = no
2778 AC_MSG_CHECKING([for fpclassify() with -lm])
2787 if (fpclassify(x) == FP_NAN) exit(1);
2788 ], ac_cv_func_fpclassify=yes)
2789 AC_MSG_RESULT($ac_cv_func_fpclassify)
2790 if test $ac_cv_func_fpclassify = yes
2796 if test $ac_cv_func_fpclassify = yes
2798 AC_DEFINE(HAVE_FPCLASSIFY, [1], [fpclassify math API])
2800 dnl prefer fpclassify() but will take isnan() and isnanf() as
2801 dnl possible alternates
2802 AC_CHECK_FUNCS(isnan)
2803 if test $ac_cv_func_isnan = no
2805 AC_CHECK_LIB(m, isnan)
2806 if test $ac_cv_lib_m_isnan = yes
2808 AC_DEFINE(HAVE_ISNAN, [1], [isnan math API])
2812 AC_CHECK_FUNCS(isnanf)
2813 if test $ac_cv_func_isnanf = no
2815 AC_CHECK_LIB(m, isnanf)
2816 if test $ac_cv_lib_m_isnanf = yes
2818 AC_DEFINE(HAVE_ISNANF, [1], [isnanf math API])
2823 AC_SUBST(lib_for_math)
2825 dnl check if we have the SIG_PF typedef
2826 AC_TRY_LINK([#include <signal.h>], [SIG_PF x;],
2827 AC_DEFINE(HAVE_SIGPF, [1], [SIG_PF typedef]))
2829 dnl check if we have the SA_SIGINFO #define
2830 AC_TRY_LINK([#include <signal.h>], [int x = SA_SIGINFO;],
2831 AC_DEFINE(HAVE_SA_SIGINFO, [1], [SA_SIGINFO macro]))
2833 dnl check if we support the SIGPIPE signal
2834 AC_TRY_LINK([#include <signal.h>], [int x = SIGPIPE;],
2835 AC_DEFINE(HAVE_SIGPIPE, [1], [SIGPIPE signal]))
2837 dnl check if we support the SIGHUP signal
2838 AC_TRY_LINK([#include <signal.h>], [int x = SIGHUP;],
2839 AC_DEFINE(HAVE_SIGHUP, [1], [SIGHUP signal]))
2841 dnl check if we support the SIGBUS signal
2842 AC_TRY_LINK([#include <signal.h>], [int x = SIGBUS;],
2843 AC_DEFINE(HAVE_SIGBUS, [1], [SIGBUS signal]))
2845 dnl check if we need to explicitly include signal.h
2846 AC_TRY_LINK([#include <sys/wait.h>],
2847 [ typedef void (*SIGRET)(int);
2849 ], AC_DEFINE(HAVE_WAIT_INCLUDES_SIGNAL, [1], [indirect signal.h]))
2851 dnl check for name and type of time fields in struct stat
2852 dnl IRIX example timespec_t st_mtim;
2853 dnl Linux example struct timespec st_mtim;
2854 dnl Darwin example struct timespec st_mtimespec;
2855 dnl Solaris example timestruc_t st_mtim;
2856 dnl FreeBSD (6.1) struct timespec st_mtimespec;
2857 dnl struct timespec {
2862 have_stat_type=false
2863 have_stat_name=false
2864 if test $have_stat_name = false
2867 changequote(<<, >>)<<[ ]st_mtimespec>>changequote([, ]),
2868 sys/stat.h, [ have_stat_name=true;
2869 AC_DEFINE(HAVE_ST_MTIME_WITH_SPEC, [1], [st_mtimespec stat field]) ])
2871 if test $have_stat_name = false -a $target_os != darwin -a $target_os != linux -a $target_os != kfreebsd -a $target_os != netbsd
2874 changequote(<<, >>)<<[ ]st_mtime>>changequote([, ]),
2875 sys/stat.h, [ have_stat_name=true;
2876 AC_DEFINE(HAVE_ST_MTIME_WITH_E, [1], [st_mtime stat field]) ])
2878 if test $have_stat_type = false
2881 changequote(<<, >>)<<timestruc_t[ ][ ]*st_mtim>>changequote([, ]),
2882 sys/stat.h, [ have_stat_type=true;
2883 AC_DEFINE(HAVE_STAT_TIMESTRUC, [1], [timestruc_t type]) ])
2885 if test $have_stat_type = false
2888 changequote(<<, >>)<<timespec_t[ ][ ]*st_mtim>>changequote([, ]),
2889 sys/stat.h, [ have_stat_type=true;
2890 AC_DEFINE(HAVE_STAT_TIMESPEC_T, [1], [timespec_t type]) ])
2892 if test $have_stat_type = false
2895 changequote(<<, >>)<<timespec[ ][ ]*st_mtim>>changequote([, ]),
2896 sys/stat.h, [ have_stat_type=true;
2897 AC_DEFINE(HAVE_STAT_TIMESPEC, [1], [timespec type]) ])
2899 if test $have_stat_type = false
2902 changequote(<<, >>)<<time_t[ ][ ]*st_mtim>>changequote([, ]),
2903 sys/stat.h, [ have_stat_type=true;
2904 AC_DEFINE(HAVE_STAT_TIME_T, [1], [time_t type]) ])
2906 if test $have_stat_type = false
2908 echo 'FATAL ERROR: Cannot determine struct stat time types.'
2909 rm -rf conftest conftest.*
2914 dnl Work out where to install stuff for this package
2915 dnl (and where to find stuff at run-time for add-on packages).
2919 dnl Predictable directory containing pcp.conf, or overridden
2920 dnl by the $PCP_CONF environment variable. If this is not set
2921 dnl (default /etc/pcp.conf), then $PCP_CONF must be set in
2922 dnl the environment.
2924 dnl The eval echo stuff is used to get around unfavourable
2925 dnl elements of the GNU standards, which cause embedding of
2926 dnl ${prefix} within many of these various $dirs.
2927 dnl http://www.gnu.org/software/autoconf/manual/autoconf.html#Installation-Directory-Variables
2929 pcp_etc_dir=`eval echo $sysconfdir`
2930 pcp_etc_dir=`eval echo $pcp_etc_dir`
2931 AC_SUBST(pcp_etc_dir)
2932 pcp_saslconf_dir=`eval echo $sysconfdir/sasl2`
2933 pcp_saslconf_dir=`eval echo $pcp_saslconf_dir`
2934 AC_SUBST(pcp_saslconf_dir)
2935 pcp_sysconf_dir=`eval echo $sysconfdir/pcp`
2936 pcp_sysconf_dir=`eval echo $pcp_sysconf_dir`
2937 AC_SUBST(pcp_sysconf_dir)
2938 pcp_pmcdconf_path=$pcp_sysconf_dir/pmcd/pmcd.conf
2939 pcp_pmcdrclocal_path=$pcp_sysconf_dir/pmcd/rc.local
2940 pcp_pmcdoptions_path=$pcp_sysconf_dir/pmcd/pmcd.options
2941 pcp_pmwebdoptions_path=$pcp_sysconf_dir/pmwebd/pmwebd.options
2942 pcp_pmmgroptions_path=$pcp_sysconf_dir/pmmgr/pmmgr.options
2943 pcp_pmproxyoptions_path=$pcp_sysconf_dir/pmproxy/pmproxy.options
2944 pcp_pmiecontrol_path=$pcp_sysconf_dir/pmie/control
2945 pcp_pmsnapcontrol_path=$pcp_sysconf_dir/pmsnap/control
2946 pcp_pmloggercontrol_path=$pcp_sysconf_dir/pmlogger/control
2947 AC_SUBST(pcp_pmcdconf_path)
2948 AC_SUBST(pcp_pmcdoptions_path)
2949 AC_SUBST(pcp_pmcdrclocal_path)
2950 AC_SUBST(pcp_pmwebdoptions_path)
2951 AC_SUBST(pcp_pmmgroptions_path)
2952 AC_SUBST(pcp_pmproxyoptions_path)
2953 AC_SUBST(pcp_pmiecontrol_path)
2954 AC_SUBST(pcp_pmsnapcontrol_path)
2955 AC_SUBST(pcp_pmloggercontrol_path)
2957 dnl shared PCP files (shareable for diskless)
2958 pcp_share_dir=`eval echo $datarootdir/pcp`
2959 pcp_share_dir=`eval echo $pcp_share_dir`
2960 AC_SUBST(pcp_share_dir)
2962 dnl private PCP executables
2963 pcp_binadm_dir=`eval echo $libexecdir/pcp/bin`
2964 pcp_binadm_dir=`eval echo $pcp_binadm_dir`
2965 AC_SUBST(pcp_binadm_dir)
2967 dnl non-shared (i.e. system local) PCP files
2968 pcp_var_dir=`eval echo $localstatedir/lib/pcp`
2969 pcp_var_dir=`eval echo $pcp_var_dir`
2970 AC_SUBST(pcp_var_dir)
2972 dnl pmcd control and options files
2973 AC_ARG_WITH(configdir,[AC_HELP_STRING([--with-configdir],[configuration directory [LOCALSTATEDIR/pcp/config]])],
2974 [pcp_config_dir=$withval],
2975 [pcp_config_dir=$pcp_var_dir/config])
2977 pcp_pmdas_dir=$pcp_var_dir/pmdas
2978 AC_SUBST(pcp_pmdas_dir)
2980 pcp_selinux_dir=$pcp_var_dir/selinux
2981 AC_SUBST(pcp_selinux_dir)
2983 dnl runtime shared libraries
2984 pcp_lib_dir=`eval echo $libdir`
2985 pcp_lib_dir=`eval echo $pcp_lib_dir`
2986 pcp_lib32_dir=`echo $pcp_lib_dir | sed -e s,64,, -e s,//,/,`
2987 AC_SUBST(pcp_lib_dir)
2988 AC_SUBST(pcp_lib32_dir)
2991 AC_ARG_WITH(perl_installdirs,[AC_HELP_STRING([--with-perl_installdirs],[perl installdirs [vendor]])],
2992 [perl_installdirs=$withval],
2993 [perl_installdirs=vendor])
2994 perl_installdirs=`eval echo $perl_installdirs`
2995 perl_installdirs=`eval echo $perl_installdirs`
2996 AC_SUBST(perl_installdirs)
2997 AC_ARG_WITH(perl_install_base,[AC_HELP_STRING([--with-perl_install_base],[perl install_base [PREFIX]])],
2998 [perl_install_base=$withval],
2999 [perl_install_base=$prefix])
3000 perl_install_base=`eval echo $perl_install_base`
3001 perl_install_base=`eval echo $perl_install_base`
3002 AC_SUBST(perl_install_base)
3004 AC_ARG_WITH(python_prefix,[AC_HELP_STRING([--with-python_prefix],[python setup.py prefix [PREFIX]])],
3005 [python_prefix=$withval],
3006 [python_prefix=$prefix])
3007 python_prefix=`eval echo $python_prefix`
3008 python_prefix=`eval echo $python_prefix`
3009 AC_SUBST(python_prefix)
3012 pcp_x11_incflags=$X_CFLAGS
3013 AC_SUBST(pcp_x11_incflags)
3014 pcp_x11_libflags=$X_LIBS
3015 AC_SUBST(pcp_x11_libflags)
3016 pcp_x11_extra=$X_EXTRA_LIBS
3017 AC_SUBST(pcp_x11_extra)
3018 pcp_x11_pre=$X_PRE_LIBS
3019 AC_SUBST(pcp_x11_pre)
3021 dnl man pages (source)
3023 have_gzipped_manpages=false
3024 have_bzip2ed_manpages=false
3025 have_lzmaed_manpages=false
3026 have_xzed_manpages=false
3027 need_old_tbl_header=false
3029 pcp_man_dir=`eval echo $mandir`
3030 pcp_man_dir=`eval echo $pcp_man_dir`
3032 dnl guess compression in use
3033 for d in /usr/man /usr/share/man $pcp_man_dir
3035 for sd in man1 sman1
3037 if test -f $d/$sd/man.1.gz
3039 have_gzipped_manpages=true
3041 man_header=`$ZIP -d < $d/$sd/man.1.gz | head -1`
3043 elif test -f $d/$sd/man.1.bz2
3045 have_bzip2ed_manpages=true
3047 man_header=`$BZIP2 -d < $d/$sd/man.1.bz2 | head -1`
3049 elif test -f $d/$sd/man.1.lzma
3051 have_lzmaed_manpages=true
3053 man_header=`$LZMA -d < $d/$sd/man.1.lzma | head -1`
3055 elif test -f $d/$sd/man.1.xz
3057 have_xzed_manpages=true
3059 man_header=`$XZ -d < $d/$sd/man.1.xz | head -1`
3061 elif test -f $d/$sd/man.1
3063 man_header=`head -1 $d/$sd/man.1`
3069 if test x"$man_header" = "x'\\\" t" -o x"$man_header" = "x'\\\" te" ; then
3070 need_old_tbl_header=true
3072 AC_SUBST(pcp_man_dir)
3073 AC_SUBST(have_manpages)
3074 AC_SUBST(have_gzipped_manpages)
3075 AC_SUBST(have_bzip2ed_manpages)
3076 AC_SUBST(have_lzmaed_manpages)
3077 AC_SUBST(have_xzed_manpages)
3078 AC_SUBST(need_old_tbl_header)
3081 pcp_bin_dir=`eval echo $bindir`
3082 pcp_bin_dir=`eval echo $pcp_bin_dir`
3083 AC_SUBST(pcp_bin_dir)
3085 pcp_sbin_dir=`eval echo $sbindir`
3086 pcp_sbin_dir=`eval echo $pcp_sbin_dir`
3087 AC_SUBST(pcp_sbin_dir)
3090 pcp_inc_dir=`eval echo $includedir/pcp`
3091 pcp_inc_dir=`eval echo $pcp_inc_dir`
3092 AC_SUBST(pcp_inc_dir)
3094 dnl books - pdfs, html
3095 if test $target_os = linux; then
3096 pcp_books_dir=`eval echo $datarootdir/doc/pcp-doc`
3098 pcp_books_dir=`eval echo $datarootdir/doc/pcp`
3100 pcp_books_dir=`eval echo $pcp_books_dir`
3101 pcp_html_dir=`eval echo $pcp_books_dir/html`
3102 AC_SUBST(pcp_books_dir)
3103 AC_SUBST(pcp_html_dir)
3105 dnl icon pixmap files
3106 if test $target_os = linux; then
3107 pcp_icons_dir=`eval echo $datarootdir/pcp-gui/pixmaps`
3109 pcp_icons_dir=`eval echo $datarootdir/pcp/pixmaps`
3111 pcp_icons_dir=`eval echo $pcp_icons_dir`
3112 AC_SUBST(pcp_icons_dir)
3114 dnl desktop application entries
3115 pcp_desktop_dir=`eval echo $datarootdir/applications`
3116 pcp_desktop_dir=`eval echo $pcp_desktop_dir`
3117 AC_SUBST(pcp_desktop_dir)
3119 dnl rc/startup files
3120 AC_ARG_WITH(rcdir,[AC_HELP_STRING([--with-rcdir],[rc directory [SYSCONFDIR/rc.d]])],
3121 [pcp_rc_dir=$withval], [
3124 pcp_rc_dir="$pcp_share_dir/lib"
3126 pcp_rc_dir="$pcp_etc_dir/init.d"
3128 AC_SUBST(pcp_rc_dir)
3130 dnl rc sysconfig dir
3131 AC_ARG_WITH(sysconfigdir,[AC_HELP_STRING([--with-sysconfigdir],[sysconfig directory [SYSCONFDIR/sysconfig]])],
3132 [pcp_sysconfig_dir=$withval],
3133 [pcp_sysconfig_dir=$pcp_etc_dir/sysconfig])
3134 AC_SUBST(pcp_sysconfig_dir)
3137 AC_ARG_WITH(logdir,[AC_HELP_STRING([--with-logdir],[log directory [LOCALSTATEDIR/log/pcp]])],
3138 [pcp_log_dir=$withval],
3139 [pcp_log_dir=$localstatedir/log/pcp])
3140 pcp_log_dir=`eval echo $pcp_log_dir`
3141 pcp_log_dir=`eval echo $pcp_log_dir`
3142 AC_SUBST(pcp_log_dir)
3144 AC_ARG_WITH(rundir,[AC_HELP_STRING([--with-rundir],[run directory [LOCALSTATEDIR/run/pcp]])],
3145 [pcp_run_dir=$withval],
3146 [pcp_run_dir=$localstatedir/run/pcp])
3147 pcp_run_dir=`eval echo $pcp_run_dir`
3148 pcp_run_dir=`eval echo $pcp_run_dir`
3149 AC_SUBST(pcp_run_dir)
3151 dnl world-writeable temporary files directory
3152 AC_ARG_WITH(tmpdir,[AC_HELP_STRING([--with-tmpdir],[tmp directory [LOCALSTATEDIR/tmp]])],
3153 [pcp_tmpfile_dir=$withval],
3154 [pcp_tmpfile_dir=$localstatedir/tmp])
3155 pcp_tmpfile_dir=`eval echo $pcp_tmpfile_dir`
3156 pcp_tmpfile_dir=`eval echo $pcp_tmpfile_dir`
3157 AC_SUBST(pcp_tmpfile_dir)
3159 dnl non-world-writeable status files directory
3160 pcp_tmp_dir=`eval echo $pcp_var_dir/tmp`
3161 AC_SUBST(pcp_tmp_dir)
3164 AC_ARG_WITH(docdir,[AC_HELP_STRING([--with-docdir],[docs directory [DOCDIR/pcp-VERSION]])],
3165 [pcp_doc_dir=$withval],
3166 [PACKAGE=pcp-${PACKAGE_VERSION}; pcp_doc_dir=$docdir])
3167 pcp_doc_dir=`eval echo $pcp_doc_dir`
3168 pcp_doc_dir=`eval echo $pcp_doc_dir`
3169 AC_SUBST(pcp_doc_dir)
3172 AC_ARG_WITH(demosdir,[AC_HELP_STRING([--with-demosdir],[run directory [DATADIR/pcp/demos]])],
3173 [pcp_demos_dir=$withval],
3174 [pcp_demos_dir=$pcp_share_dir/demos])
3175 AC_SUBST(pcp_demos_dir)
3177 if test -z "$XCONFIRM"
3179 AC_PATH_PROG(ac_xconfirm_prog, xconfirm, $pcp_bin_dir/pmconfirm)
3181 ac_xconfirm_prog=$XCONFIRM
3183 AC_SUBST(ac_xconfirm_prog)
3185 dnl Check for FNDELAY defined in <fcntl.h>
3186 if test "$ac_cv_header_fcntl_h" = "yes"
3188 AC_MSG_CHECKING([for FNDELAY in fcntl.h])
3189 AC_TRY_COMPILE([#include <fcntl.h>],
3190 [ int i = FNDELAY; ],
3191 AC_DEFINE(HAVE_FNDELAY, [1], [FNDELAY macro])
3192 AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3195 dnl check for zpool_vdev_name API style from <libzfs.h>
3196 if test "$ac_cv_header_libzfs_h" = "yes"
3198 AC_MSG_CHECKING([for 5-argument style zpool_vdev_name])
3199 AC_TRY_COMPILE([#include <libzfs.h>],
3200 [ libzfs_handle_t *zh;
3203 (void) zpool_vdev_name(zh, zp, np, B_FALSE, B_FALSE);
3205 AC_DEFINE(HAVE_ZPOOL_VDEV_NAME_5ARG, [1], [5-arg zpool_vdev_name])
3206 AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3208 AC_MSG_CHECKING([for 4-argument style zpool_vdev_name])
3209 AC_TRY_COMPILE([#include <libzfs.h>],
3210 [ libzfs_handle_t *zh;
3213 (void) zpool_vdev_name(zh, zp, np, B_FALSE);
3215 AC_DEFINE(HAVE_ZPOOL_VDEV_NAME_4ARG, [1], [4-arg zpool_vdev_name])
3216 AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3219 dnl Check for Network Security Services (NSS) and
3220 dnl Simple Authentication and Security Layer (SASL)
3221 if test "$do_secure" = "check" -o "$do_secure" = "yes"
3225 saved_CFLAGS="$CFLAGS"
3226 saved_CPPFLAGS="$CPPFLAGS"
3227 NSS_INC_DIRS="-I/usr/include/nss -I/usr/include/nss3"
3228 NSPR_INC_DIRS="-I/usr/include/nspr -I/usr/include/nspr4"
3229 CFLAGS="$CFLAGS $NSS_INC_DIRS $NSPR_INC_DIRS"
3230 CPPFLAGS="$CPPFLAGS $NSS_INC_DIRS $NSPR_INC_DIRS"
3232 AC_CHECK_HEADERS([nss/nss.h], [NSSCFLAGS=-I/usr/include/nss], [
3233 AC_CHECK_HEADERS([nss3/nss.h], [NSSCFLAGS=-I/usr/include/nss3], [
3235 if test "$do_secure" = "yes"
3237 AC_MSG_ERROR([cannot enable secure sockets mode - no NSS header])
3243 AC_CHECK_HEADERS([nspr/nspr.h], [NSPRCFLAGS=-I/usr/include/nspr], [
3244 AC_CHECK_HEADERS([nspr4/nspr.h], [NSPRCFLAGS=-I/usr/include/nspr4], [
3246 if test "$do_secure" = "yes"
3248 AC_MSG_ERROR([cannot enable secure sockets mode - no NSPR header])
3252 AC_SUBST(NSPRCFLAGS)
3254 AC_CHECK_HEADERS([sasl/sasl.h], [SASLCFLAGS=-I/usr/include/sasl], [
3256 if test "$do_secure" = "yes"
3258 AC_MSG_ERROR([cannot enable secure sockets mode - no SASL header])
3261 AC_SUBST(SASLCFLAGS)
3263 AC_CHECK_LIB(sasl2, sasl_server_init, [lib_for_sasl="-lsasl2"], [
3265 if test "$do_secure" = "yes"
3267 AC_MSG_ERROR([cannot enable secure sockets mode - no SASL library])
3270 AC_SUBST(lib_for_sasl)
3272 AC_CHECK_LIB(ssl, SSL_ImportFD, [lib_for_ssl="-lssl"], [
3273 AC_CHECK_LIB(ssl3, SSL_ImportFD, [lib_for_ssl="-lssl3"], [
3275 if test "$do_secure" = "yes"
3277 AC_MSG_ERROR([cannot enable secure sockets mode - no SSL library])
3281 AC_SUBST(lib_for_ssl)
3283 AC_CHECK_LIB(nss, NSS_Init, [lib_for_nss="-lnss"], [
3284 AC_CHECK_LIB(nss3, NSS_Init, [lib_for_nss="-lnss3"], [
3286 if test "$do_secure" = "yes"
3288 AC_MSG_ERROR([cannot enable secure sockets mode - no NSS library])
3292 AC_SUBST(lib_for_nss)
3294 AC_CHECK_LIB(nspr, PR_Init, [lib_for_nspr="-lnspr"], [
3295 AC_CHECK_LIB(nspr4, PR_Init, [lib_for_nspr="-lnspr4"], [
3297 if test "$do_secure" = "yes"
3299 AC_MSG_ERROR([cannot enable secure sockets mode - no NSPR library])
3303 AC_SUBST(lib_for_nspr)
3305 if test "$enable_secure" = "true"
3307 AC_DEFINE(HAVE_SECURE_SOCKETS, [1], [Encrypted sockets])
3309 AC_SUBST(enable_secure)
3311 CPPFLAGS="$saved_CPPFLAGS"
3312 CFLAGS="$saved_CFLAGS"
3315 dnl check for -latomic, needed for some -march=i386 builds with i686 c++ distro headers
3316 AC_CHECK_LIB(atomic, __atomic_fetch_add_4, [lib_for_atomic="-latomic"])
3317 AC_SUBST(lib_for_atomic)
3319 dnl check for array sessions
3320 if test -f /usr/include/sn/arsess.h
3322 pcp_mpi_dirs=libpcp_mpi\ libpcp_mpiread
3326 AC_SUBST(pcp_mpi_dirs)
3328 dnl check for Unix Domain socket family structure
3329 AC_MSG_CHECKING([for struct sockaddr_un in sys/un.h])
3331 #include <sys/types.h>
3332 #ifdef HAVE_SYS_SOCKET_H
3333 #include <sys/socket.h>
3335 #ifdef HAVE_SYS_UN_H
3338 ], [ struct sockaddr_un sa; sa.sun_family = AF_UNIX; ],
3339 AC_DEFINE(HAVE_STRUCT_SOCKADDR_UN, [1], [sockaddr_un type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3341 dnl check for Linux Unix Domain socket credential structure
3342 AC_MSG_CHECKING([for struct ucred in sys/socket.h])
3344 #include <sys/types.h>
3345 #ifdef HAVE_SYS_SOCKET_H
3346 #include <sys/socket.h>
3348 #ifdef HAVE_SYS_UN_H
3351 ], [ struct ucred ucred; ucred.uid = 0; ],
3352 AC_DEFINE(HAVE_STRUCT_UCRED, [1], [ucred type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3354 dnl check for struct timespec in <time.h>
3355 AC_MSG_CHECKING([for struct timespec in time.h])
3358 ], [ struct timespec foo; ],
3359 AC_DEFINE(HAVE_STRUCT_TIMESPEC, [1], [timespec type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3361 dnl check if we have IRIX style altzone
3362 AC_MSG_CHECKING([for altzone in time.h])
3365 ], [ time_t az = altzone; ],
3366 AC_DEFINE(HAVE_ALTZONE, [1], [altzone global]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3368 dnl If there is no altzone, check if strftime can handle %z
3369 AC_MSG_CHECKING([if strftime knows about %z])
3375 time_t t = time(NULL);
3376 struct tm * t1 = localtime (&t);
3377 if (strftime (b, 32, "%z", t1) < 3)
3379 if (strcmp(b, "%z") == 0)
3383 ], AC_DEFINE(HAVE_STRFTIME_z, [1], [strftime with %z]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no), AC_MSG_RESULT(no))
3385 dnl does strerror_r return char * a la GNU
3386 dnl (as opposed to the int return for XSI-compliant variants)
3387 AC_MSG_CHECKING([if strerror_r returns char *])
3389 [#include <string.h>], [strerror_r(0, NULL, 0)[0];],
3390 AC_DEFINE(HAVE_STRERROR_R_PTR, [1], [strerror_r return]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3392 dnl first check for readline on its own then with curses
3397 AC_CHECK_FUNC(readline,,
3399 AC_CHECK_LIB(readline, readline,,
3401 dnl AC seems to cache lib/func results
3402 dnl so use another readline func here
3403 AC_CHECK_LIB(readline, add_history,,,[-lcurses])
3406 if test $ac_cv_func_readline = yes
3408 AC_DEFINE(HAVE_READLINE, [1], [readline API])
3409 elif test $ac_cv_lib_readline_readline = yes
3411 AC_DEFINE(HAVE_READLINE, [1], [readline API])
3412 lib_for_readline=-lreadline
3413 elif test $ac_cv_lib_readline_add_history = yes
3415 AC_DEFINE(HAVE_READLINE, [1], [readline API])
3416 lib_for_curses=-lcurses
3417 lib_for_readline=-lreadline
3419 AC_SUBST(lib_for_readline)
3420 AC_SUBST(lib_for_curses)
3424 PKG_CHECK_MODULES([zlib], [zlib >= 1.0.0], [have_zlib=true], [have_zlib=false])
3425 AC_SUBST(HAVE_ZLIB, [$have_zlib])
3427 dnl Check if we have AI_ADDRCONFIG
3428 AC_MSG_CHECKING([for AI_ADDRCONFIG])
3432 int test = AI_ADDRCONFIG;
3435 ], AC_DEFINE(HAVE_AI_ADDRCONFIG, [1], [AI_ADDRCONFIG macro]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3437 dnl Find external source tarballs for packaging
3440 if test $do_webapps != "no"
3442 AC_MSG_NOTICE([adding web applications to the build])
3445 AC_SUBST(have_webapps)
3447 dnl Capture special options passed to configure
3448 pcp_prefix=`eval echo $prefix`
3449 AC_SUBST(pcp_prefix)
3450 AC_SUBST(PACKAGE_CONFIGURE)
3457 dnl Build definitions for use in Makefiles
3458 src/include/builddefs
3459 dnl PCP paths and other defs
3460 src/include/pcp.conf
3461 dnl Linux Software Map entry
3463 dnl Preamble for deb install scripts
3464 debian/pcp.preinst.head
3465 debian/pcp.postinst.head
3466 dnl Preamble for tar install scripts
3467 build/tar/preinstall.head
3468 build/tar/postinstall.head
3469 dnl Build definitions for use in packaging
3471 build/mac/uninstall-pcp
3474 dnl verbose diagnostics
3476 dnl echo config.status: settings dump begin
3477 dnl grep '^S.".*=' config.status
3478 dnl echo config.status: settings dump end