2 dnl Copyright (c) 2012-2016 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"],
101 AC_ARG_WITH([python],
102 [AC_HELP_STRING([--with-python],
103 [enable support for tools requiring Python (default is on)])],
104 [do_python=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-python=$withval"],
107 AC_ARG_WITH([python3],
108 [AC_HELP_STRING([--with-python3],
109 [enable support for tools requiring Python3 (default is on)])],
110 [do_python3=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-python3=$withval"],
114 [AC_HELP_STRING([--with-books],
115 [enable building of the PCP books (default is off)])],
116 [do_books=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-books=$withval"],
119 AC_ARG_WITH([books-brand],
120 [AC_HELP_STRING([--with-books-brand=BRAND],
121 [choose the docbook brand when building the PCP books (default is common)])],
122 [do_books_brand=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-books-brand=$withval"],
123 [do_books_brand=common])
126 [AC_HELP_STRING([--with-papi@<:@=DIR|=MODULE@:>@],
127 [enable performance api counter pmda (default is on)
128 The optional argument may be a full path of a PAPI installation prefix,
129 or a pkgconfig module name.])],
130 [do_papi=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-papi=$withval"],
133 AC_ARG_WITH([perfevent],
134 [AC_HELP_STRING([--with-perfevent],
135 [enable perfevent pmda (default is on)])],
136 [do_perfevent=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-perfevent=$withval"],
137 [do_perfevent=check])
139 AC_ARG_WITH([pmdajson],
140 [AC_HELP_STRING([--with-pmdajson],
141 [enable JSON pmda (default is on)])],
142 [do_pmdajson=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdajson=$withval"],
145 AC_ARG_WITH([pmdasnmp],
146 [AC_HELP_STRING([--with-pmdasnmp],
147 [enable SNMP pmda (default is on)])],
148 [do_pmdasnmp=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdasnmp=$withval"],
151 AC_ARG_WITH([manager],
152 [AC_HELP_STRING([--with-manager],
153 [enable daemon manager (default is on)])],
154 [do_manager=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-manager=$withval"],
157 AC_ARG_WITH([webapi],
158 [AC_HELP_STRING([--with-webapi],
159 [enable REST API daemon (default is on)])],
160 [do_webapi=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-webapi=$withval"],
164 [AC_HELP_STRING([--with-webjs],
165 [enable building of webjs packages (default is off)])],
166 [do_webjs=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-webjs=$withval"],
169 AC_ARG_WITH([vector],
170 [AC_HELP_STRING([--with-vector],
171 [enable building of vector package (default is off)])],
172 [do_vector=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-vector=$withval"],
175 AC_ARG_WITH([parfait],
176 [AC_HELP_STRING([--with-parfait],
177 [enable building of parfait package (default is off)])],
178 [do_parfait=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-parfait=$withval"],
181 dnl things set in the environment by Makepkgs never make it into an RPM
182 dnl build where the environment is stripped ... use a --with-foo=path
183 dnl construct to workaround this
186 [AC_HELP_STRING([--with-make],
187 [path to GNU compatible make(1) (default is empty for auto discovery)])],
188 [MAKE=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-make=$withval"],
192 [AC_HELP_STRING([--with-tar],
193 [path to GNU compatible tar(1) (default is empty for auto discovery)])],
194 [TAR=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-tar=$withval"],
198 [AC_HELP_STRING([--with-zip],
199 [path to GNU compatible zip(1) (default is empty for auto discovery)])],
200 [ZIP=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-zip=$withval"],
204 # Note: the following environment variables may be
205 # set to override the defaults.
207 # MAKE CC CPP LD LEX YACC INSTALL AWK SED ECHO
210 dnl Guess target platfrom
215 FATAL ERROR: Cannot guess your target, try explicit specification
216 using --target or mailto: pcp@oss.sgi.com to ask.'
217 rm -rf conftest conftest.*
220 dnl Remove 4th name component, if present, from target, target_os,
221 dnl build and build_os. Squash all x86 cpus into one LCD form - i386
222 target=`echo $target | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`
223 target_os=`echo $target_os | sed '[s/solaris2\..*/solaris/]'`
224 target_os=`echo $target_os | sed '[s/^\([^-][^-]*\)-.*$/\1/]' | sed '[s/[\.0-9]*//g]'`
226 build=`echo $build | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`
227 build_os=`echo $build_os | sed '[s/solaris2\..*/solaris/]'`
228 build_os=`echo $build_os | sed '[s/^\([^-][^-]*\)-.*$/\1/]'`
231 echo Building on $build for $target
232 echo "Build: os=$build_os cpu=$build_cpu"
233 echo "Target: os=$target_os cpu=$target_cpu"
235 if test "$cross_compiling" = "yes"; then
236 if test -f ./config.$target_os; then
237 . ./config.$target_os
241 FATAL ERROR: Cannot perform cross-compilation without a file to source
242 configuration information from (config.$target_os is missing)"
243 rm -rf conftest conftest.*
247 AC_SUBST(cross_compiling)
249 dnl CFLAGS setting is a co-dependency between here and PCFLAGS in
250 dnl src/include/builddefs.in ... need to be the same in both places
252 target_distro=$target_os
253 if test $target_os = linux
255 AC_DEFINE(IS_LINUX, [1], [Platform is Linux])
256 test -f /etc/SuSE-release && target_distro=suse
257 test -f /etc/fedora-release && target_distro=fedora
258 test -f /etc/redhat-release && target_distro=redhat
259 test -f /etc/debian_version && target_distro=debian
260 test -f /etc/slackware-version && target_distro=slackware
261 test -f /etc/gentoo-release && target_distro=gentoo
262 test -f /etc/mandriva-release && target_distro=mandriva
263 test -f /etc/arch-release && target_distro=arch
264 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
265 pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
266 pcp_ps_all_flags=-efw
267 elif test $target_os = darwin
269 AC_DEFINE(IS_DARWIN, [1], [Platform is Darwin (Mac OS X)])
271 version=`sw_vers -productVersion | sed -e 's/\.//' -e 's/\..*//g'`
272 CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing -arch i386"
273 if test $version -ge 106
276 CFLAGS="$CFLAGS -arch x86_64"
279 pcp_platform_paths='/usr/local/bin'
280 pcp_ps_all_flags="-axw -o user,pid,ppid,cpu,stime,tty,time,command"
281 elif test $target_os = mingw
283 AC_DEFINE(IS_MINGW, [1], [Platform is MinGW (Windows)])
284 CFLAGS="-fno-strict-aliasing"
285 pcp_platform_paths=''
286 pcp_ps_all_flags=-efW
287 elif test $target_os = solaris
289 AC_DEFINE(IS_SOLARIS, [1], [Platform is Solaris])
290 export CFLAGS_IF_GCC="-fPIC -fno-strict-aliasing"
291 export CFLAGS_IF_SUNCC="-fPIC -xalias_level=any -D_XPG4_2 -D__EXTENSIONS__"
292 pcp_platform_paths='/usr/bin/X11:/usr/local/bin:/opt/sfw/bin:/opt/csw/bin'
294 elif test $target_os = aix
296 AC_DEFINE(IS_AIX, [1], [Platform is AIX])
297 export CFLAGS="-qcpluscmt"
298 pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
300 elif test $target_os = freebsd || test $target_os = kfreebsd
302 AC_DEFINE(IS_FREEBSD, [1], [Platform is FreeBSD])
303 test -f /etc/debian_version && target_distro=debian
304 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
305 if test $target_os = kfreebsd
307 pcp_ps_all_flags=-efw
309 pcp_ps_all_flags=auxww
311 pcp_platform_paths='/usr/bin/X11'
312 test -d /usr/local/bin && pcp_platform_paths="$pcp_platform_paths:/usr/local/bin"
313 test -d /usr/bsd && pcp_platform_paths="$pcp_platform_paths:/usr/bsd"
314 elif test $target_os = gnu
316 AC_DEFINE(IS_GNU, [1], [Platform is GNU Hurd])
317 test -f /etc/debian_version && target_distro=debian
318 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
319 pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
320 pcp_ps_all_flags=-efw
321 elif test $target_os = netbsdelf
324 AC_DEFINE(IS_NETBSD, [1], [Platform is NetBSD])
325 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE -D_NETBSD_SOURCE"
326 pcp_platform_paths='/usr/pkg/bin'
327 pcp_ps_all_flags=auxww
328 elif test $target_os = openbsd
331 AC_DEFINE(IS_OPENBSD, [1], [Platform is OpenBSD])
332 export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
333 pcp_platform_paths='/usr/local/bin'
334 pcp_ps_all_flags=auxww
337 echo "FATAL ERROR: need platform-specific customization for \"$target_os\""
338 rm -rf conftest conftest.*
341 AC_SUBST(pcp_platform_paths)
342 AC_SUBST(pcp_ps_all_flags)
344 dnl default C and C++ compiler optimization to -O2 -g
345 if test "$use_optimization" = no
347 optimization="-O0 -g"
349 optimization="-O2 -g"
351 AC_SUBST(optimization)
354 if test -z "$PKG_CONFIG"; then
355 AC_MSG_ERROR([cannot find a 'pkg-config' command])
358 dnl check if user wants their own C compiler
360 AC_PROG_CC(suncc egcc gcc cc)
361 if test $target_os = solaris
363 AC_PATH_PROG(CCPATH,$CC,$CC)
365 if test "$GCC" = "yes"
367 CFLAGS="$CFLAGS $CFLAGS_IF_GCC"
369 CFLAGS="$CFLAGS $CFLAGS_IF_SUNCC"
371 if test "$use_64bit" = "no"
375 AC_MSG_CHECKING([for 64 bit Solaris host])
380 CFLAGS="$CFLAGS -m64"
381 LDFLAGS="$LDFLAGS -m64"
396 dnl these become CFLAGS and LDFLAGS for the build
400 if echo "$CFLAGS" | grep 'D_FORTIFY_SOURCE' >/dev/null
402 dnl for cc use locally in configure (not exported via $PCFLAGS),
403 dnl add -O in case -D_FORTIFY_SOURCE has been added to CFLAGS above,
404 dnl as -D_FORTIFY_SOURCE requires -O but we've separated optimization
405 dnl flags out into $CFLAGS_OPT for our build infrastructure
409 dnl some versions of gcc (e.g. version 4.8.4 on Gentoo Hardened) have added
410 dnl a predefined for _FORTIFY_SOURCE but only when -O is specified ... so
411 dnl to be safe we have -U_FORTIFY_SOURCE before -D_FORTIFY_SOURCE=2 below
413 # Add some security-related gcc flags
414 if echo "$CFLAGS" | grep stack-protector >/dev/null
416 dnl already set, probably from the environment
420 [AS_HELP_STRING([--disable-ssp], [disable gcc stack-protector])])
421 AS_IF([test "x$cc_is_gcc" = xyes -a "x$enable_ssp" != xno ],[
422 save_CFLAGS="$CFLAGS"
423 CFLAGS="$CFLAGS -O -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
424 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int something ();])], [
425 AC_MSG_NOTICE([Compiling with gcc -fstack-protector-all et al.])
426 PCFLAGS="$PCFLAGS -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"],[
427 AC_MSG_NOTICE([Compiler does not support -fstack-protector-all et al.])
428 CFLAGS="$save_CFLAGS"
435 # Check for even more security-related gcc/linker flags, useful for daemons
437 [AS_HELP_STRING([--disable-pie], [disable position-independent-executable])])
438 AS_IF([test "x$cc_is_gcc" = xyes -a "x$enable_pie" != xno],[
440 PIELDFLAGS='-pie -Wl,-z,relro -Wl,-z,now'
441 save_CFLAGS="$CFLAGS"
442 save_LDFLAGS="$LDFLAGS"
443 CFLAGS="$CFLAGS $PIECFLAGS"
444 LDFLAGS="$LDFLAGS $PIELDFLAGS"
445 AC_LINK_IFELSE([AC_LANG_SOURCE([void main () {}])], [
446 AC_MSG_NOTICE([Compiling with gcc pie et al.])
448 AC_MSG_NOTICE([Compiler does not support -pie et al.])
452 CFLAGS="$save_CFLAGS"
453 LDFLAGS="$save_LDFLAGS"
458 # Check for support for symbol hiding via gcc flags
459 AC_ARG_ENABLE([visibility],
460 [AS_HELP_STRING([--disable-visibility], [disable gcc symbol visibility])])
461 AS_IF([test "x$cc_is_gcc" = xyes -a "$enable_visibility" != no],[
462 INVISIBILITY="-fvisibility=hidden"
463 save_CFLAGS="$CFLAGS"
464 CFLAGS="$CFLAGS -c $INVISIBILITY"
465 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int visible () { return 0; }])], [
466 AC_MSG_NOTICE([Compiling DSO PMDAs with gcc -fvisibility=hidden])
468 AC_MSG_NOTICE([Compiler does not support -fvisibility.])
471 CFLAGS="$save_CFLAGS"
473 AC_SUBST(INVISIBILITY)
475 AC_PROG_CXX(eg++ g++ c++)
478 AC_MSG_CHECKING([for working C++ compiler])
481 [AC_LANG_PROGRAM([[#include <cstdio>]],
482 [[const char gday[] = "G'day, world\n";]])],
483 [AC_MSG_RESULT([yes])],
488 # Prevent shared libraries from being built for libpcp and other core libraries
489 AC_ARG_ENABLE([shared],
490 [AS_HELP_STRING([--disable-shared], [disable core shared libary generation])],
491 [PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --disable-shared=$withval"])
492 AC_SUBST(enable_shared)
494 dnl check if user wants to use any of their own commands;
495 dnl ordering is important: some tests use earlier results
497 test -z "$AWK" && AC_PATH_PROGS(AWK, gawk awk, /usr/bin/awk)
509 if test -z "$SED"; then
510 AC_PATH_PROG(SED, sed, /bin/sed)
512 if test ! -x "$SED"; then
513 AC_MSG_ERROR([cannot find a valid 'sed' command.])
518 if test -z "$ECHO"; then
519 AC_PATH_PROG(ECHO, echo, /bin/echo)
521 if test ! -x "$ECHO"; then
522 AC_MSG_ERROR([cannot find a valid 'echo' command.])
527 if test -z "$FIND"; then
528 AC_PATH_PROG(FIND, find, /usr/bin/find)
530 if test ! -x "$FIND"; then
531 AC_MSG_ERROR([cannot find a valid 'find' command.])
536 if test -z "$WHICH"; then
537 AC_PATH_PROG(WHICH, which, /usr/bin/which)
539 if test ! -x "$WHICH"; then
540 AC_MSG_ERROR([cannot find a valid 'which' command.])
546 lex=`$echo $LEX | awk '{print $1}'`
548 if test ! -x "$lex"; then
549 AC_MSG_ERROR([cannot find a valid 'lex'/'flex' command.])
555 yacc=`$echo $YACC | awk '{print $1}'`
556 yacc=`$which "$yacc"`
557 if test ! -x "$yacc"; then
558 AC_MSG_ERROR([cannot find a valid 'yacc'/'bison' command.])
563 dnl check we don't get the Windows sort ...
564 AC_MSG_CHECKING([where unix-like sort(1) lives])
565 if test $target_os = mingw; then
566 for d in /bin /usr/bin /mingw/bin /mingw/usr/bin
568 if test -x $d/sort; then
581 echo "FATAL ERROR: $sort -n failed!"
582 rm -rf conftest conftest.*
587 dnl echo_n set to -n if echo understands -n to suppress newline
588 dnl echo_c set to \c if echo understands \c to suppress newline
589 AC_MSG_CHECKING([if echo uses -n or backslash-c to suppress newlines])
590 if ( $echo "testing\c"; $echo 1,2,3 ) | grep c >/dev/null
592 if ( $echo -n testing; $echo 1,2,3 ) | sed s/-n/xn/ | grep xn >/dev/null
595 AC_MSG_RESULT([neither?])
602 AC_MSG_RESULT([backslash-c])
607 dnl subsequent configure checks rely on $EGREP being set
610 dnl Check for static probes (dtrace, systemtap)
611 if test "$do_probes" = "check" -o "$do_probes" = "yes"
614 AC_CHECK_PROGS(DTRACE, dtrace, [])
617 if test "$do_probes" = "yes"
619 AC_MSG_ERROR([cannot enable static probes - no dtrace executable])
623 AC_CHECK_HEADERS([sys/sdt.h], [
624 if $enable_probes = true
626 if test $target_os = kfreebsd
629 elif test $target_os = freebsd
631 dnl dtrace support in FreeBSD depends on configuration of kernel
632 rm -f conftest.d conftest.h
633 cat <<End-of-File >conftest.d
638 if dtrace -s conftest.d -h >/dev/null 2>&1
640 if test ! -f conftest.h
643 if test "$do_probes" = "yes"
645 AC_MSG_ERROR([cannot enable static probes - no .h from dtrace -h])
650 if test "$do_probes" = "yes"
652 AC_MSG_ERROR([cannot enable static probes - dtrace failed])
659 if test "$do_probes" = "yes"
661 AC_MSG_ERROR([cannot enable static probes - no SDT header])
665 if test "$enable_probes" = "true"
667 AC_DEFINE(HAVE_STATIC_PROBES, [1], [Static probes (dtrace, systemtap)])
669 AC_SUBST(enable_probes)
673 dnl Check for service discovery mechanisms (DNS-SD, Avahi)
674 AS_IF([test "x$do_discovery" != "xno"], [
675 # on Mac OS X, dns_sd.h
677 # on Linux, aloha Avahi
679 PKG_CHECK_MODULES([avahi], [avahi-client],
680 [AC_CHECK_LIB(avahi-client, avahi_client_new,
681 [lib_for_avahi="-lavahi-common -lavahi-client"],
682 [enable_avahi=false])
683 ],[enable_avahi=false])
684 AC_CHECK_HEADERS([avahi-client/publish.h],, [enable_avahi=false])
685 AC_CHECK_HEADERS([avahi-common/alternative.h],, [enable_avahi=false])
687 if test "$enable_avahi" = "true"
689 AC_SUBST(lib_for_avahi)
690 AC_SUBST(avahi_CFLAGS)
691 AC_DEFINE(HAVE_AVAHI, [1], [Service discovery via Avahi])
692 enable_discovery=true
695 if test "$do_discovery" != "check" -a "$enable_discovery" != "true"
697 AC_MSG_ERROR([cannot enable service discovery - no supported mechanisms])
699 if test "$enable_discovery" = "true"
701 AC_DEFINE(HAVE_SERVICE_DISCOVERY, [1], [Service discovery mechanisms])
704 AC_SUBST(enable_discovery)
705 AC_SUBST(enable_avahi)
707 dnl Check for systemd services
709 AS_IF([test "x$do_systemd" != "xno"], [
712 PKG_CHECK_VAR([SYSTEMD_SYSTEMUNITDIR], [systemd], [systemdsystemunitdir],
713 [pcp_systemdunit_dir=$SYSTEMD_SYSTEMUNITDIR], [enable_systemd=false])
714 AC_SUBST(pcp_systemdunit_dir)
715 if test -z "$pcp_systemdunit_dir"
717 if test "$do_systemd" = "yes"
719 AC_MSG_ERROR([cannot enable systemd support - no systemunitdir path])
724 AC_SUBST(enable_systemd)
726 # NB: No AC_PREFIX_DEFAULT is needed, as the default configure invocation
727 # targets a build for non-system directories such as /usr/local.
728 # AC_PREFIX_DEFAULT([])
731 PACKAGE_VERSION=${PACKAGE_MAJOR}.${PACKAGE_MINOR}.${PACKAGE_REVISION}
732 AC_SUBST(PACKAGE_VERSION)
733 AC_SUBST(PACKAGE_MAJOR)
734 AC_SUBST(PACKAGE_MINOR)
735 AC_SUBST(PACKAGE_REVISION)
736 AC_SUBST(PACKAGE_BUILD)
738 if test -z "$PACKAGE_BUILD_DATE" ; then
739 PACKAGE_BUILD_DATE=`date +%Y-%m-%d`
741 AC_SUBST(PACKAGE_BUILD_DATE)
743 if test -z "$PACKAGE_DISTRIBUTION" ; then
744 PACKAGE_DISTRIBUTION=$target_distro
746 AC_SUBST(PACKAGE_DISTRIBUTION)
748 dnl generate PM_VERSION_CURRENT for header
749 pm_version_current=`awk </dev/null "BEGIN { print (${PACKAGE_MAJOR}*256+${PACKAGE_MINOR})*256+${PACKAGE_REVISION} }"`
750 AC_SUBST(pm_version_current)
752 dnl output header files with cpp defs HAVE_*, etc
753 AC_CONFIG_HEADERS(src/include/pcp/config.h src/include/pcp/configsz.h)
754 AC_OUTPUT(src/include/pcp/platform_defs.h src/include/pcp/platformsz.h)
756 AC_CHECK_PROGS(GIT, git)
759 dnl check if python available for the build and runtime
760 AC_CHECK_PROGS(PYTHON, python, python2.7)
763 dnl check if python3 available for the build and runtime
764 AC_CHECK_PROGS(PYTHON3, python3, python3.4)
767 dnl check if python tools/packages wanted (need python >= 2.6)
769 AS_IF([test "x$do_python" != "xno"], [
775 AC_MSG_CHECKING([Python version])
776 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 }'`
777 AC_MSG_RESULT([$PY_MAJOR.$PY_MINOR.$PY_POINT])
778 if test "$PY_MAJOR" -lt 2; then
779 echo WARNING: Python version 2.6 or later does not seem to be installed.
782 if test "$PY_MAJOR" -eq 2 -a "$PY_MINOR" -lt 6 ; then
783 echo WARNING: Python version 2.$PY_MINOR is too old.
784 echo Python version 2.6 or later is required for Python builds.
787 AC_CHECK_HEADERS([python${PY_MAJOR}.${PY_MINOR}/Python.h], [], [
788 echo WARNING: Python version $PY_MAJOR.$PY_MINOR header file missing.
789 echo Cannot proceed with the Python $PY_MAJOR installation found.
796 if test "$do_python" != "check" -a "$enable_python2" != "true"
798 AC_MSG_ERROR([cannot enable Python - no supported version found])
801 AC_SUBST(enable_python2)
803 dnl check if python3 tools/packages wanted (need python >= 3.3)
805 AS_IF([test "x$do_python3" != "xno"], [
807 if test -z "$PYTHON3"
811 AC_MSG_CHECKING([Python3 version])
812 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 }'`
813 AC_MSG_RESULT([$PY_MAJOR.$PY_MINOR.$PY_POINT])
814 if test "$PY_MAJOR" -lt 3; then
815 echo WARNING: Python version 3.3 or later does not seem to be installed.
818 if test "$PY_MAJOR" -eq 3 -a "$PY_MINOR" -lt 3 ; then
819 echo WARNING: Python version 3.$PY_MINOR is too old.
820 echo Python version 3.3 or later is required for Python builds.
823 AC_CHECK_HEADERS([python${PY_MAJOR}.${PY_MINOR}m/Python.h], [], [
824 echo WARNING: Python version $PY_MAJOR.$PY_MINOR header file missing.
825 echo Cannot proceed with the Python $PY_MAJOR installation found.
832 if test "$do_python3" != "check" -a "$enable_python3" != "true"
834 AC_MSG_ERROR([cannot enable Python3 - no supported version found])
837 AC_SUBST(enable_python3)
839 dnl convenience macro to determine if either python is available
840 AC_MSG_CHECKING([for any python version])
841 if test "$cross_compiling" = "yes"; then
843 echo "cross-compile -> \"$ans\"" >&5
844 elif test "$enable_python2" = "true" -o "$enable_python3" = "true"
850 AC_SUBST(have_python)
851 if $have_python; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
853 dnl choose the prefered python executable (py2 -> py3 transtion)
854 if test "$enable_python3" = "true"
856 pcp_python_prog=$PYTHON3
857 elif test "$enable_python2" = "true"
859 pcp_python_prog=$PYTHON
863 AC_SUBST(pcp_python_prog)
865 dnl check availability of some Python modules
866 dnl usage PCP_CHECK_PYTHON_MODULE(module_name) or
867 dnl PCP_CHECK_PYTHON_MODULE(module_name, <import string>)
868 dnl default <import string> is "import module_name"
870 dnl sets $have_python_<module_name> as true or false
872 AC_DEFUN(PCP_CHECK_PYTHON_MODULE,
873 [ AC_MSG_CHECKING(for Python module $1)
880 $pcp_python_prog -c 'import sys;
881 '"$txt" >>config.log 2>&1
885 eval have_python_$1=true
888 eval have_python_$1=false
891 PCP_CHECK_PYTHON_MODULE(jsonpointer)
892 AC_SUBST(have_python_jsonpointer)
893 PCP_CHECK_PYTHON_MODULE(requests)
894 AC_SUBST(have_python_requests)
895 PCP_CHECK_PYTHON_MODULE(six)
896 AC_SUBST(have_python_six)
898 AC_MSG_CHECKING([if the json PMDA should be included])
900 AS_IF([test "x$do_pmdajson" = "xyes"], [pmda_json=true])
901 AS_IF([test "x$do_pmdajson" = "xcheck"], [
902 dnl JSON PMDA needs both the six and jsonpointer Python modules
903 $have_python_jsonpointer && $have_python_six && pmda_json=true
905 AC_SUBST(PMDA_JSON, $pmda_json)
906 if $pmda_json; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
908 PCP_CHECK_PYTHON_MODULE(libvirt)
909 AC_SUBST(have_python_libvirt)
911 dnl check if perl available for the build and runtime
912 AC_CHECK_PROGS(PERL, perl)
915 AC_MSG_CHECKING([for any perl version])
916 if test "$cross_compiling" = "yes"; then
918 echo "cross-compile -> \"$ans\"" >&5
927 AC_SUBST(pcp_perl_prog)
929 AC_MSG_RESULT($pcp_perl_prog)
931 AC_MSG_CHECKING([if the SNMP PMDA should be included])
933 AS_IF([test "x$do_pmdasnmp" = "xyes"], [pmda_snmp=true])
934 AS_IF([test "x$do_pmdasnmp" = "xcheck"], [
935 dnl SNMP PMDA needs perl and the Net::SNMP module
936 if test "$have_perl" = true
938 if $pcp_perl_prog -e "use Net::SNMP" >/dev/null 2>&1
944 AC_SUBST(PMDA_SNMP, $pmda_snmp)
945 if $pmda_snmp; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
947 AC_MSG_CHECKING([if the mysql PMDA should be included])
949 if test "$have_perl" = true
951 dnl rpm build for mysql PMDA needs Perl DBI and DBD::mysql
952 if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
954 if $pcp_perl_prog -e "use DBD::mysql" >/dev/null 2>&1
960 AC_SUBST(PMDA_MYSQL, $pmda_mysql)
961 if $pmda_mysql; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
963 AC_MSG_CHECKING([if the postgresql PMDA should be included])
964 pmda_postgresql=false
965 if test "$have_perl" = true
967 dnl rpm build for postgresql PMDA needs Perl DBI and DBD::Pg
968 if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
970 if $pcp_perl_prog -e "use DBD::Pg" >/dev/null 2>&1
976 AC_SUBST(PMDA_POSTGRESQL, $pmda_postgresql)
977 if $pmda_postgresql; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
979 AC_MSG_CHECKING([if the oracle PMDA should be included])
981 if test "$have_perl" = true
983 dnl rpm build for oracle PMDA needs Perl DBI
984 if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
989 AC_SUBST(PMDA_ORACLE, $pmda_oracle)
990 if $pmda_oracle; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
992 AC_MSG_CHECKING([if the elasticsearch PMDA should be included])
993 pmda_elasticsearch=false
994 if test "$have_perl" = true
996 dnl rpm build for elasticsearch PMDA needs Perl LWP::UserAgent
997 if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
999 pmda_elasticsearch=true
1002 AC_SUBST(PMDA_ELASTICSEARCH, $pmda_elasticsearch)
1003 if $pmda_elasticsearch; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1005 AC_MSG_CHECKING([if the nginx PMDA should be included])
1007 if test "$have_perl" = true
1009 dnl rpm build for nginx PMDA needs Perl LWP::UserAgent
1010 if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1015 AC_SUBST(PMDA_NGINX, $pmda_nginx)
1016 if $pmda_nginx; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1018 AC_MSG_CHECKING([if the activemq PMDA should be included])
1020 if test "$have_perl" = true
1022 dnl rpm build for activemq PMDA needs Perl LWP::UserAgent
1023 if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1028 AC_SUBST(PMDA_ACTIVEMQ, $pmda_activemq)
1029 if $pmda_activemq; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1031 AC_MSG_CHECKING([if the libvirt PMDA should be included])
1033 if test "$have_python" = true
1035 dnl rpm build for libvirt PMDA needs Python libvirt and lxml modules
1036 if $pcp_python_prog -c "import libvirt" >/dev/null 2>&1
1038 if $pcp_python_prog -c "import lxml" >/dev/null 2>&1
1040 dnl temporarily disabled until dynamic instance/metric IDs resolved
1041 dnl pmda_libvirt=true
1046 AC_SUBST(PMDA_LIBVIRT, $pmda_libvirt)
1047 if $pmda_libvirt; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1052 AS_IF([test "x$do_qt" != "xno"], [
1057 dnl qmake-qt5 [/usr/lib64/qt5/bin:/usr/lib/qt5/bin]
1058 AC_PATH_PROGS(QMAKE, [qmake-qt4 qmake],, [$QTDIR/bin:/usr/bin:/usr/lib64/qt4/bin:/usr/lib/qt4/bin:/usr/local/bin])
1059 test "x$cc_is_gcc" = xyes -a $target_os = solaris && QMAKE="$QMAKE -spec solaris-g++"
1066 AC_MSG_CHECKING([Qt version])
1067 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 }'`
1068 AC_MSG_RESULT([$QT_MAJOR.$QT_MINOR.$QT_POINT])
1069 if test "$QT_MAJOR" -lt 4; then
1070 echo WARNING: Qt version 4.4 or later does not seem to be installed.
1071 echo Cannot proceed with the Qt $QT_MAJOR installation found.
1074 if test "$QT_MAJOR" -eq 4 -a "$QT_MINOR" -lt 4 ; then
1075 echo WARNING: Qt version 4.$QT_MINOR is too old.
1076 echo Qt version 4.4 or later is required for Qt builds.
1081 if test "$do_qt" != "check" -a "$enable_qt" != "true"
1083 AC_MSG_ERROR([cannot enable Qt - no supported Qt installation found])
1084 elif test "$enable_qt" = "true" -a "x$cxx" = "x"
1087 test "$do_qt" != "check" && \
1088 AC_MSG_ERROR([C++ compiler unavailable, cannot build Qt components])
1089 elif test "$do_qt" = "debug"
1091 dnl Debug/release style build? (non-debug by default)
1096 AC_SUBST(qt_release)
1100 dnl check if user wants their own make program
1101 dnl note: all makefiles in this package use the gmake syntax
1104 AC_PATH_PROG(MAKE, gmake)
1107 # look elsewhere ...
1108 AC_MSG_CHECKING([for GNU make elsewhere])
1109 for f in /usr/local/bin/gmake /usr/freeware/bin/gmake /usr/local/bin/make /opt/sfw/bin/gmake nowhere
1117 if test $f = nowhere
1119 # Check if /usr/bin/make is any good
1120 mver=`/usr/bin/make --version 2>/dev/null | sed -n -e1p | cut -c1-8`
1121 if test "$mver" != "GNU Make"
1124 echo "FATAL ERROR: could not find GNU make anywhere"
1125 echo "You need to set \$MAKE as the full path to GNU make "
1126 echo "in the environment."
1127 rm -rf conftest conftest.*
1133 AC_MSG_RESULT($MAKE)
1139 dnl check if users wants their own CPP
1140 if test -z "$CPP"; then
1146 dnl check if users wants their own linker
1147 if test -z "$LD"; then
1148 AC_PATH_PROG(LD, ld, /usr/bin/ld)
1153 dnl Provide ways to override owner and group for installed files
1154 if test -z "$PCP_USER_INSTALL" ; then
1155 pcp_user_install=root
1157 pcp_user_install="$PCP_USER_INSTALL"
1159 AC_SUBST(pcp_user_install)
1160 if test -z "$PCP_GROUP_INSTALL" ; then
1163 darwin|freebsd|netbsd|openbsd)
1164 pcp_group_install=wheel
1167 pcp_group_install=root
1171 pcp_group_install="$PCP_GROUP_INSTALL"
1173 AC_SUBST(pcp_group_install)
1175 dnl check if the tar program is available
1176 if test -z "$TAR"; then
1177 AC_PATH_PROGS(TAR, gtar tar, tar)
1179 if test $target_os = darwin -a -x /usr/bin/gnutar
1186 dnl check if the gzip program is available
1187 dnl (needed to gzip man pages on some platforms)
1188 if test -z "$ZIP"; then
1189 AC_PATH_PROG(ZIP, gzip, /bin/gzip)
1191 test ! -x "$ZIP" && ZIP=/usr/local/bin/gzip
1192 test ! -x "$ZIP" && ZIP=/usr/freeware/bin/gzip
1193 test ! -x "$ZIP" && ZIP=/usr/bin/gzip
1195 test -z "$gzip" && gzip=no-gzip
1198 dnl check if the bzip2 program is available
1199 dnl (needed to bzip2 man pages on some platforms)
1200 if test -z "$BZIP2"; then
1201 AC_PATH_PROG(BZIP2, bzip2, /bin/bzip2)
1203 test ! -x "$BZIP2" && BZIP2=/usr/bin/bzip2
1204 test ! -x "$BZIP2" && BZIP2=/usr/local/bin/bzip2
1205 test ! -x "$BZIP2" && BZIP2=/usr/freeware/bin/bzip2
1207 test -z "$bzip2" && bzip2=no-bzip2
1210 dnl check if the lzma program is available
1211 dnl (needed to lzma man pages on some platforms)
1212 if test -z "$LZMA"; then
1213 AC_PATH_PROG(LZMA, lzma, /bin/lzma)
1215 test ! -x "$LZMA" && LZMA=/usr/bin/lzma
1216 test ! -x "$LZMA" && LZMA=/usr/local/bin/lzma
1217 test ! -x "$LZMA" && LZMA=/usr/freeware/bin/lzma
1219 test -z "$lzma" && lzma=no-lzma
1222 dnl check if the xz program is available
1223 dnl (needed to xz man pages on some platforms)
1224 if test -z "$XZ"; then
1225 AC_PATH_PROG(XZ, xz, /bin/xz)
1227 test ! -x "$XZ" && XZ=/usr/bin/xz
1228 test ! -x "$XZ" && XZ=/usr/local/bin/xz
1229 test ! -x "$XZ" && XZ=/usr/freeware/bin/xz
1231 test -z "$xz" && xz=no-xz
1234 dnl Check for mac PackageMaker
1235 AC_MSG_CHECKING([for PackageMaker])
1236 if test -z "$PACKAGE_MAKER"
1238 if test $target_os = darwin
1240 if test -x /Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1241 then # local XCode extras install
1242 package_maker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1243 AC_MSG_RESULT([ yes (local install)])
1244 elif test -x /Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1246 package_maker=/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1247 AC_MSG_RESULT([ yes (darwin 6.x)])
1248 elif test -x /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
1250 AC_MSG_RESULT([ yes (darwin 7.x)])
1251 package_maker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
1253 AC_MSG_RESULT([ not found!])
1254 AC_MSG_WARN([PackageMaker not found, mac packages will not be made])
1257 AC_MSG_RESULT([ no])
1260 package_maker="$PACKAGE_MAKER"
1262 AC_SUBST(package_maker)
1264 dnl check if the hdiutil program is available
1265 if test -z "$HDIUTIL"; then
1266 AC_PATH_PROG(HDIUTIL, hdiutil)
1271 dnl check if the mkinstallp program is available (AIX)
1272 if test -z "$MKINSTALLP"; then
1273 AC_PATH_PROG(MKINSTALLP, mkinstallp)
1275 mkinstallp=$MKINSTALLP
1276 AC_SUBST(mkinstallp)
1278 dnl check for the Solaris pmgmk package maker
1279 if test -z "$PKGMK"; then
1280 AC_PATH_PROG(PKGMK, pkgmk)
1285 dnl check if the dlltool program is available
1286 if test -z "$DLLTOOL"; then
1287 AC_PATH_PROG(DLLTOOL, dlltool)
1292 dnl check if the rpmbuild program is available
1293 if test -z "$RPMBUILD"; then
1294 AC_PATH_PROG(RPMBUILD, rpmbuild)
1296 test $target_distro = slackware && RPMBUILD=''
1300 dnl check if the rpm program is available
1301 if test -z "$RPM"; then
1302 AC_PATH_PROG(RPM, rpm)
1304 test $target_distro = slackware && RPM=''
1308 dnl if rpmbuild exists, use it, otherwise use rpm
1309 if test -n "$RPMBUILD" -a -x "$RPMBUILD"
1317 dnl check if the pod2man program is available (perl man page builder)
1318 if test -z "$POD2MAN"; then
1319 AC_PATH_PROG(POD2MAN, pod2man)
1324 dnl extra check for the Perl MakeMaker package
1325 AC_MSG_CHECKING([if ExtUtils::MakeMaker is installed])
1326 perl -e "use ExtUtils::MakeMaker" 2>/dev/null
1329 AC_MSG_RESULT([ yes])
1331 AC_MSG_RESULT([ no])
1333 echo "FATAL ERROR: Perl ExtUtils::MakeMaker module missing."
1334 echo "You can either install this from your distribution, or"
1335 echo "download from CPAN (Comprehensive Perl Archive Network)."
1336 rm -rf conftest conftest.*
1340 AC_PATH_PROG(TRUEPROG, true)
1342 dnl check if the makedepend program is available
1343 if test -z "$MAKEDEPEND"; then
1344 AC_PATH_PROG(MAKEDEPEND, makedepend, $TRUEPROG)
1346 makedepend=$MAKEDEPEND
1347 AC_SUBST(makedepend)
1349 dnl check if the md5sum program is available
1350 if test -z "$MD5SUM"; then
1351 AC_PATH_PROG(MD5SUM, md5sum, $TRUEPROG)
1356 dnl check if the Debian dpkg program is available
1357 if test -z "$DPKG"; then
1358 AC_PATH_PROG(DPKG, dpkg)
1363 dnl check for the Slackware makepkg packaging tool
1364 if test -z "$MAKEPKG"; then
1365 AC_PATH_PROG(MAKEPKG, makepkg)
1370 dnl check if a toolchain is available for the books
1371 test -z "$PUBLICAN" && AC_PATH_PROG(PUBLICAN, publican)
1374 test -z "$DBLATEX" && AC_PATH_PROG(DBLATEX, dblatex)
1377 test -z "$XMLTO" && AC_PATH_PROG(XMLTO, xmlto)
1382 if test "$do_books" = "check" -o "$do_books" = "yes"
1384 if test "$BOOK_TOOLCHAIN" != ""
1386 book_toolchain=$BOOK_TOOLCHAIN
1387 elif test "$DBLATEX" != ""
1389 book_toolchain=dblatex
1390 elif test "$PUBLICAN" != ""
1392 book_toolchain=publican
1393 elif test "$XMLTO" != ""
1395 book_toolchain=xmlto
1396 elif test "$do_books" = "yes"
1398 AC_MSG_ERROR([cannot enable books build - no toolchain found])
1401 AC_SUBST(book_toolchain)
1404 if test "$do_books_brand" != ""
1406 book_brand=$do_books_brand
1408 AC_SUBST(book_brand)
1410 dnl check if symbolic links are supported
1412 if test $target_os = mingw; then
1416 dnl if /proc is not mounted, try and mount it
1417 dnl before trying to run the ps style test below
1420 test -f /proc/stat || mount /proc >/dev/null 2>&1
1423 dnl set platform specific ps
1424 if test -n "$PROCPS"
1426 pcp_ps_prog="$PROCPS"
1430 AC_SUBST(pcp_ps_prog)
1432 dnl set platform specific event logger
1433 if test $target_os = mingw
1435 pcp_syslog_prog=pcp-eventlog
1437 pcp_syslog_prog=logger
1439 AC_SUBST(pcp_syslog_prog)
1442 if test $target_os = solaris
1444 test -f /usr/xpg4/bin/grep && grep=/usr/xpg4/bin/grep
1448 dnl checks for /proc pseudo file system
1449 AC_MSG_CHECKING([for /proc ])
1450 if test "$cross_compiling" = "yes"; then
1452 echo "cross-compile -> \"$ans\"" >&5
1462 AC_DEFINE(HAVE_PROCFS, [1], [Support for /proc pseudo-filesystem])
1467 dnl Checks for C header files.
1471 AC_CHECK_HEADERS(fcntl.h limits.h malloc.h strings.h syslog.h)
1472 AC_CHECK_HEADERS(stddef.h sched.h dlfcn.h dl.h)
1473 AC_CHECK_HEADERS(sys/times.h sys/resource.h sys/prctl.h)
1474 AC_CHECK_HEADERS(sys/sysinfo.h sys/systeminfo.h)
1475 AC_CHECK_HEADERS(endian.h standards.h sys/byteorder.h)
1476 AC_CHECK_HEADERS(libgen.h sys/mman.h sys/un.h)
1477 AC_CHECK_HEADERS(values.h stdint.h ieeefp.h math.h)
1478 AC_CHECK_HEADERS(pwd.h grp.h regex.h sys/wait.h)
1479 AC_CHECK_HEADERS(termio.h termios.h sys/termios.h)
1480 AC_CHECK_HEADERS(sys/ioctl.h sys/select.h sys/socket.h)
1481 AC_CHECK_HEADERS(netdb.h)
1482 if test $target_os = darwin -o $target_os = openbsd
1484 AC_CHECK_HEADERS(net/if.h, [], [], [#include <sys/types.h>
1485 #include <sys/socket.h>])
1487 AC_CHECK_HEADERS(net/if.h)
1489 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h arpa/inet.h)
1490 AC_CHECK_HEADERS(windows.h winsock2.h ws2tcpip.h)
1491 AC_CHECK_HEADERS(execinfo.h bits/wordsize.h)
1492 AC_CHECK_HEADERS(iptypes.h, [], [], [#include <windows.h>])
1493 AC_CHECK_HEADERS(iphlpapi.h, [], [], [#include <winsock2.h>])
1494 AC_CHECK_HEADERS(fts.h libzfs.h)
1495 AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/mount.h)
1497 dnl Check if we have <sys/endian.h> ... standard way
1498 AC_MSG_CHECKING([for sys/endian.h ])
1501 #include <sys/endian.h>
1504 ], AC_DEFINE(HAVE_SYS_ENDIAN_H, [1], [sys/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1506 dnl Check if we have <machine/endian.h> ... MacOSX way
1507 AC_MSG_CHECKING([for machine/endian.h ])
1510 #include <machine/endian.h>
1513 ], AC_DEFINE(HAVE_MACHINE_ENDIAN_H, [1], [machine/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1515 dnl Check if we have <sys/endian.h> ... IRIX strangeness
1516 AC_MSG_CHECKING([for sys/endian.h (IRIX variant) ])
1519 #include <standards.h>
1520 #include <sys/endian.h>
1523 ], AC_DEFINE(HAVE_SYS_ENDIAN_H, [1], [IRIX sys/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1525 dnl Checks for typedefs, structures, and compiler characteristics.
1534 dnl check if regex functions come from libregex (mingw)
1535 AC_CHECK_LIB(regex, regcomp)
1537 if test $ac_cv_lib_regex_regcomp = yes
1539 lib_for_regex="-lregex"
1541 AC_SUBST(lib_for_regex)
1543 PKG_CHECK_MODULES([ncurses], [ncurses], [have_ncurses=true], [have_ncurses=false])
1544 AC_SUBST(HAVE_NCURSES, [$have_ncurses])
1546 PKG_CHECK_MODULES([SYSTEMD], [libsystemd],
1547 [pmda_systemd=true], [pmda_systemd=false])
1548 AC_MSG_CHECKING([if the systemd PMDA should be included])
1549 AC_SUBST(PMDA_SYSTEMD, $pmda_systemd)
1550 if $pmda_systemd; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1552 pmda_infiniband=false
1553 AS_IF([test "x$do_infiniband" != "xno"], [
1554 AC_CHECK_HEADERS([infiniband/umad.h], [
1555 AC_CHECK_HEADERS([infiniband/mad.h], [pmda_infiniband=true], [])
1559 AC_CHECK_LIB(ibmad, madrpc_init)
1560 AC_CHECK_LIB(ibumad, umad_init)
1561 if test $ac_cv_lib_ibmad_madrpc_init = yes -a $ac_cv_lib_ibumad_umad_init = yes
1563 IB_LIBS="-libmad -libumad"
1565 AC_MSG_CHECKING([for port_performance_query_via])
1566 AC_TRY_LINK_FUNC(port_performance_query_via,
1567 AC_DEFINE(HAVE_PORT_PERFORMANCE_QUERY_VIA, [1], [port_performance_query_via API])
1568 have_port_performance_query_via=true
1570 have_port_performance_query_via=false
1572 AC_MSG_CHECKING([for pma_query_via])
1573 AC_TRY_LINK_FUNC(pma_query_via,
1574 AC_DEFINE(HAVE_PMA_QUERY_VIA, [1], [pma_query_via API])
1575 have_pma_query_via=true
1577 have_pma_query_via=false
1580 if test $have_pma_query_via -o $have_port_performance_query_via
1584 pmda_infiniband=false
1587 pmda_infiniband=false
1592 AC_MSG_CHECKING([if the infiniband PMDA should be included])
1593 AC_SUBST(PMDA_INFINIBAND, $pmda_infiniband)
1594 if $pmda_infiniband; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1597 AS_IF([test "x$do_papi" != "xno"], [
1600 saved_LDFLAGS="$LDFLAGS"
1601 saved_CFLAGS="$CFLAGS"
1604 dnl potentially from the environment, else empty
1605 CFLAGS="$papi_CFLAGS"
1606 LDFLAGS="$papi_LIBS"
1612 PAPI_ROOTDIR=$do_papi;
1613 CFLAGS="-I$PAPI_ROOTDIR/include"
1614 LDFLAGS="-L$PAPI_ROOTDIR/lib"
1617 PKG_CHECK_MODULES(papi,[$do_papi],[
1618 CFLAGS="$papi_CFLAGS"
1619 LDFLAGS="$papi_LIBS"])
1623 # $papi_LIBS may include -lpapi harmlessly redudantly with AC_CHECK_LIB
1624 AC_CHECK_LIB([papi], [PAPI_library_init],
1625 [papi_libs="$LDFLAGS -lpapi"],
1626 [enable_papi=false])
1627 AC_CHECK_HEADERS([papi.h], [papi_cflags="$CFLAGS"], [enable_papi=false])
1628 if test "$do_papi" != "check" -a "$enable_papi" != "true"
1630 AC_MSG_ERROR([PAPI is not installed, cannot enable the PAPI PMDA])
1632 pmda_papi=$enable_papi
1635 CFLAGS="$saved_CFLAGS"
1636 LDFLAGS="$saved_LDFLAGS"
1637 AC_SUBST(PAPI_CFLAGS, $papi_cflags)
1638 AC_SUBST(PAPI_LIBS, $papi_libs)
1640 AC_MSG_CHECKING([if the papi PMDA should be included])
1641 AC_SUBST(PMDA_PAPI, $pmda_papi)
1642 if $pmda_papi; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1644 AS_IF([test "x$pmda_papi" = "xtrue"], [
1645 dnl check if struct PAPI_component_info_t has a disabled field
1646 AC_MSG_CHECKING([whether struct PAPI_component_info_t has a disabled field])
1647 cat <<End-of-File >conftest.c
1649 int main() { PAPI_component_info_t *c; c->disabled = 0; }
1651 (eval $ac_compile) 2>conftest.out
1652 cat conftest.out >&5
1653 if test -s conftest.out
1657 AC_DEFINE(HAVE_PAPI_DISABLED_COMP, [1], [PAPI_component_info_t field])
1664 pmda_perfevent=false
1665 AS_IF([test "x$do_perfevent" != "xno" ], [
1666 enable_perfevent=true
1669 AC_CHECK_LIB([pfm], [pfm_get_os_event_encoding],
1671 [enable_perfevent=false])
1672 AC_CHECK_HEADERS([perfmon/pfmlib_perf_event.h], [], [enable_perfevent=false])
1673 if test "$do_perfevent" != "check" -a "$enable_papi" != "true"
1675 AC_MSG_ERROR([libpfm is not installed, cannot enable the perfevent PMDA])
1677 pmda_perfevent=$enable_perfevent
1680 AC_SUBST(PFM_LIBS, $pfm_libs)
1682 AC_MSG_CHECKING([if the perfevent PMDA should be included])
1683 AC_SUBST(PMDA_PERFEVENT, $pmda_perfevent)
1684 if $pmda_perfevent; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1686 dnl Do you have RPM Package Manager libraries for pmdarpm?
1689 AC_MSG_CHECKING([for rpmlib > 4.4.2])
1691 [AC_LANG_PROGRAM([[#include <rpm/header.h>]],
1692 [[(void)HEADERGET_EXT;]])],
1693 [AC_MSG_RESULT([yes])
1695 [AC_MSG_RESULT([no])])
1696 AC_MSG_CHECKING([if the rpm PMDA should be included])
1697 AC_SUBST(PMDA_RPM,$pmda_rpm)
1698 if $pmda_rpm; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1701 dnl Do you have the required qshape script for the postfix PMDA
1702 dnl The logic here is copied from the PMDA's Install script
1704 AC_CHECK_PROGS(QSHAPE, qshape, [], path=[$PATH:/usr/sbin])
1705 AC_MSG_CHECKING([if the postfix PMDA should be included])
1706 if test -n "$QSHAPE"
1710 for script in /usr/share/doc/packages/postfix-doc/auxiliary/qshape/qshape.pl
1712 if test -f "$script"
1719 AC_SUBST(PMDA_POSTFIX,$pmda_postfix)
1720 if $pmda_postfix; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1722 dnl Do you have system microhttpd libraries for pmwebapi?
1723 PKG_CHECK_MODULES([libmicrohttpd], [libmicrohttpd > 0.9.9], [have_libmicrohttpd=true], [have_libmicrohttpd=false])
1724 AC_SUBST(HAVE_LIBMICROHTTPD, [$have_libmicrohttpd])
1726 dnl Do you have graphics libraries for pmwebapi?
1727 PKG_CHECK_MODULES([cairo], [cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2], [have_cairo=true], [have_cairo=false])
1728 AC_SUBST(HAVE_CAIRO, [$have_cairo])
1731 AS_IF([test "x$do_webapi" != "xno"], [
1734 if test "$have_libmicrohttpd" != "true"
1737 test "$do_webapi" != "check" && \
1738 AC_MSG_ERROR([libmicrohttpd is not installed, cannot enable the web API])
1739 elif test "$do_webapi" != "check" -a "x$cxx" = "x"
1742 test "$do_webapi" != "check" && \
1743 AC_MSG_ERROR([C++ compiler unavailable, cannot enable the web API])
1746 AC_SUBST(enable_webapi)
1748 enable_manager=false
1749 AS_IF([test "x$do_manager" != "xno"], [
1752 if test "$target_os" = "mingw"
1754 enable_manager=false
1755 test "$do_manager" != "check" && \
1756 AC_MSG_ERROR([MinGW build, cannot enable daemon manager])
1757 elif test "x$cxx" = "x"
1759 enable_manager=false
1760 test "$do_manager" != "check" && \
1761 AC_MSG_ERROR([C++ compiler unavailable, cannot enable daemon manager])
1763 AC_MSG_CHECKING([compilation features for daemon manager])
1765 [ #ifndef _XOPEN_SOURCE
1766 #define _XOPEN_SOURCE 600
1771 enable_manager=false
1774 AC_SUBST(enable_manager)
1776 dnl Checks for library functions.
1780 AC_CHECK_FUNCS(mktime nanosleep usleep unsetenv)
1781 AC_CHECK_FUNCS(select socket gethostname getpeerucred getpeereid)
1782 AC_CHECK_FUNCS(uname syslog __clone pipe2 fcntl ioctl)
1783 AC_CHECK_FUNCS(prctl setlinebuf waitpid atexit kill)
1784 AC_CHECK_FUNCS(chown fchmod getcwd scandir mkstemp)
1785 AC_CHECK_FUNCS(brk sbrk posix_memalign memalign valloc)
1786 AC_CHECK_FUNCS(signal sighold sigrelse tcgetattr)
1787 AC_CHECK_FUNCS(regex regcmp regexec regcomp)
1788 AC_CHECK_FUNCS(strtod strtol strtoll strtoull strndup strchrnul)
1789 AC_CHECK_FUNCS(getuid getgid)
1790 AC_CHECK_FUNCS(getgrent getgrent_r getgrnam getgrnam_r getgrgid getgrgid_r)
1791 AC_CHECK_FUNCS(getpwent getpwent_r getpwnam getpwnam_r getpwuid getpwuid_r)
1792 AC_CHECK_FUNCS(sysinfo trace_back_stack backtrace)
1793 AC_CHECK_FUNCS(sendmsg recvmsg setns)
1795 dnl only define readdir64 on non-linux platforms that support it
1796 if test $target_os != linux -a $target_os != freebsd -a $target_os != kfreebsd -a $target_os != netbsd; then
1797 AC_CHECK_FUNCS(readdir64)
1800 dnl typedefs missing from sys/types.h, stdlib.h or stddef.h
1801 if test $target_os = solaris
1803 AC_CHECK_TYPE(__int32_t, int32_t)
1804 AC_CHECK_TYPE(__uint32_t, uint32_t)
1805 AC_CHECK_TYPE(__int64_t, int64_t)
1806 AC_CHECK_TYPE(__uint64_t, uint64_t)
1807 AC_CHECK_TYPE(uint_t, u_int32_t)
1809 AC_CHECK_TYPE(__int32_t, int)
1810 AC_CHECK_TYPE(__uint32_t, unsigned int)
1811 AC_CHECK_TYPE(__int64_t, long long)
1812 AC_CHECK_TYPE(__uint64_t, unsigned long long)
1813 AC_CHECK_TYPE(uint_t, unsigned int)
1816 dnl check if we have a type for the pointer's size integer (__psint_t)
1817 AC_MSG_CHECKING([for __psint_t ])
1820 #include <sys/types.h>
1823 ], [ __psint_t psint; ],
1824 AC_DEFINE(HAVE___PSINT_T, [1], [__psint_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1826 dnl check if we have a type for pointer difference (ptrdiff_t)
1827 AC_MSG_CHECKING([for ptrdiff_t ])
1830 #ifdef HAVE_MALLOC_H
1833 ], [ ptrdiff_t ptrdiff; ],
1834 AC_DEFINE(HAVE_PTRDIFF_T, [1], [ptrdiff_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1836 dnl check if we have types for uid_t, gid_t (POSIX) or SID (Win32)
1837 AC_MSG_CHECKING([for uid_t ])
1839 #include <sys/types.h>
1844 AC_DEFINE(HAVE_UID_T, [1], [uid_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1845 AC_MSG_CHECKING([for gid_t ])
1847 #include <sys/types.h>
1852 AC_DEFINE(HAVE_GID_T, [1], [gid_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1853 AC_MSG_CHECKING([for SID ])
1855 #ifdef HAVE_WINDOWS_H
1856 #include <windows.h>
1859 AC_DEFINE(HAVE_SID, [1], [sid type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1861 dnl check if we have a type for socklen_t
1862 AC_MSG_CHECKING([for socklen_t ])
1864 #include <sys/types.h>
1865 #ifdef HAVE_SYS_SOCKET_H
1866 #include <sys/socket.h>
1868 ], [ socklen_t len; ],
1869 AC_DEFINE(HAVE_SOCKLEN_T, [1], [socklen_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1871 dnl check if LL suffix on constants is supported
1874 ], [ long long x = 0LL; ],
1875 AC_DEFINE(HAVE_CONST_LONGLONG, [1], [LL suffix on constants]))
1877 dnl check if _environ is declared globally
1881 ], [ char **x = _environ; ],
1882 AC_DEFINE(HAVE_UNDERBAR_ENVIRON, [1], [_environ declared globally]))
1884 dnl check for PR_TERMCHILD and PR_SET_PDEATHSIG in <sys/prctl.h>
1885 AC_MSG_CHECKING([for PR_TERMCHILD constant in sys/prctl.h])
1887 #ifdef HAVE_SYS_PRCTL_H
1888 #include <sys/prctl.h>
1890 ], [ int i = PR_TERMCHILD; ],
1891 AC_DEFINE(HAVE_PR_TERMCHILD, [1], [PR_TERMCHILD constant]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1893 AC_MSG_CHECKING([for PR_SET_PDEATHSIG constant in sys/prctl.h])
1895 #ifdef HAVE_SYS_PRCTL_H
1896 #include <sys/prctl.h>
1898 ], [ int i = PR_SET_PDEATHSIG; ],
1899 AC_DEFINE(HAVE_PR_SET_PDEATHSIG, [1], [PR_SET_PDEATHSIG constant]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1901 AC_HEADER_TIOCGWINSZ
1903 dnl check if linker needs -rdynamic for dynamically loaded shared
1904 dnl libraries to see the symbols in the process loading them.
1905 dnl This is e.g., needed on linux for pmcd loading pmda_pmcd.so.
1906 AC_MSG_CHECKING([if linker supports -rdynamic])
1907 save_CFLAGS="$CFLAGS"
1909 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1910 [AC_MSG_RESULT([yes])
1911 rdynamic_flag=-rdynamic],
1912 [AC_MSG_RESULT([no])
1915 CFLAGS="$save_CFLAGS"
1916 AC_SUBST([rdynamic_flag])
1919 dnl check if argument to user's select() method in scandir call is const
1920 AC_MSG_CHECKING([whether const arg for scandir() select method])
1921 cat <<End-of-File >conftest.c
1926 my_select(const struct dirent *foo) { return 0; }
1927 int main() { struct dirent **list; return scandir(".", &list, my_select, NULL); }
1929 (eval $ac_compile) 2>conftest.out
1930 cat conftest.out >&5
1931 if test -s conftest.out
1935 AC_DEFINE(HAVE_CONST_DIRENT, [1], [const arg for scandir() select method])
1940 dnl check if struct dirent has a d_off (directory offset) field
1941 AC_MSG_CHECKING([whether struct dirent has a d_off field])
1942 cat <<End-of-File >conftest.c
1946 int main() { struct dirent d; d.d_off = 0; }
1948 (eval $ac_compile) 2>conftest.out
1949 cat conftest.out >&5
1950 if test -s conftest.out
1954 AC_DEFINE(HAVE_DIRENT_D_OFF, [1], [struct dirent d_off field])
1959 dnl check if printf %p has 0x prefix
1960 AC_MSG_CHECKING([if printf %p produces 0x prefix])
1961 if test "$cross_compiling" = "yes"; then
1962 ans=$printf_p_prefix
1963 echo "cross-compile -> \"$ans\"" >&5
1965 cat <<End-of-File >conftest.c
1967 int main(int argc, char **argv) { printf("%p", argv); return(0); }
1969 (eval $ac_compile) 2>&5
1970 (eval $ac_link) 2>&5
1972 echo "./conftest -> \"$ans\"" >&5
1977 AC_DEFINE(HAVE_PRINTF_P_PFX, [1], [printf %p produces 0x])
1984 rm -rf conftest conftest.*
1988 # need to deal with this sort of cpp output ...
1989 # typedef long pid_t;
1990 # typedef unsigned int pid_t;
1991 # typedef unsigned int pid_t __attribute__ ((__mode__ (__SI__)));
1992 # __extension__ typedef int pid_t;
1999 # and chaining of the form
2000 # typedef long __pid_t;
2001 # typedef __pid_t pid_t;
2003 _raw=`$CPP conftest.c \
2005 -e 's/[[ ]]__attribute__ ((.*));/;/' \
2006 -e 's/__extension__[[ ]][[ ]]*//' \
2008 /bozo/ { print; next }
2009 $1 == "typedef" { printf "%s",$0
2015 if ($0 ~ /{/) depth = 1
2018 wantsemi == 1 { printf " %s",$0
2019 if ($0 ~ /{/) depth++
2021 if ($0 ~ /}/) depth--
2035 $1 == "typedef" { map[[$NF]] = ""
2036 for (i = 2; i < NF; i++) {
2040 map[[$NF]] = map[[$NF]] " " $i
2042 print $NF " -> " map[[$NF]] >"conftest.debug"
2045 $2 == "bozo" { t = $1
2046 printf "best guess: %s",t >"conftest.debug"
2047 while (map[[t]] != "") {
2049 printf " -> %s",t >"conftest.debug"
2051 print "" >"conftest.debug"
2060 unsigned|'unsigned int')
2066 'long long'|'long long int')
2067 if test $target_os = mingw; then
2073 'unsigned long'|'unsigned long int'|'long unsigned int')
2076 'unsigned long long'|'unsigned long long int')
2077 if test $target_os = mingw; then
2083 *\*) # pointer to a something
2086 struct\ *) # not much can be done here ...
2091 echo "FATAL ERROR: don't know what to do with type \"$_raw\""
2092 echo "... typedef mapping ..."
2094 rm -rf conftest conftest.*
2100 dnl printf type for pid_t
2101 AC_MSG_CHECKING([printf type for pid_t])
2102 if test "$cross_compiling" = "yes"; then
2104 echo "cross-compile -> \"$ans\"" >&5
2107 cat <<End-of-File >conftest.c
2108 #include <sys/types.h>
2115 AC_MSG_RESULT($fmt_pid)
2117 rm -rf conftest.c conftest.debug
2119 dnl printf type for int64_t
2120 AC_MSG_CHECKING([printf type for int64_t ])
2121 if test "$cross_compiling" = "yes"; then
2122 ans=$printf_fmt_int64
2123 echo "cross-compile -> \"$ans\"" >&5
2125 cat <<End-of-File >conftest.c
2128 #include <inttypes.h>
2131 printf("\"%s\"\n", __PRI64_PREFIX "d");
2136 (eval $ac_link) 2>&5
2137 if test -x ./conftest
2140 echo "./conftest -> \"$ans\"" >&5
2144 dnl have to try the hardway ...
2145 cat <<End-of-File >conftest.c
2152 int64_t bozo = 0x12345678abcdLL;
2153 sprintf(buf, "%lx", bozo);
2154 if (strcmp(buf, "12345678abcd") == 0)
2157 sprintf(buf, "%llx", bozo);
2158 if (strcmp(buf, "12345678abcd") == 0)
2159 printf("\"lld\"\n");
2164 (eval $ac_link) 2>&5
2165 if test -x ./conftest
2168 echo "./conftest -> \"$ans\"" >&5
2174 echo 'FATAL ERROR: Cannot determine printf format for int64_t type'
2175 rm -rf conftest conftest.*
2179 AC_MSG_RESULT("$fmt_int64")
2181 rm -rf conftest.* conftest
2183 AC_MSG_CHECKING([strtol or strtoll for int64_t])
2184 if test "$cross_compiling" = "yes"; then
2186 echo "cross-compile -> \"$ans\"" >&5
2188 cat <<End-of-File >conftest.c
2193 long long int value = -1;
2194 value = strtol("1234567812345678", NULL, 16);
2195 if (value == 0x1234567812345678LL) {
2196 printf("strotol\n");
2199 value = strtoll("1234567812345678", NULL, 16);
2200 if (value == 0x1234567812345678LL) {
2201 printf("strtoll\n");
2207 (eval $ac_compile) 2>&5
2208 (eval $ac_link) 2>&5
2210 echo "./conftest -> \"$ans\"" >&5
2215 AC_DEFINE(strtoint64, strtol)
2216 AC_DEFINE(strtouint64, strtoul)
2217 AC_MSG_RESULT([strtol])
2220 AC_DEFINE(strtoint64, strtoll)
2221 AC_DEFINE(strtouint64, strtoull)
2222 AC_MSG_RESULT([strtoll])
2225 AC_DEFINE(strtoint64, strtoll)
2226 AC_DEFINE(strtouint64, strtoull)
2227 AC_MSG_RESULT([assuming strtoll])
2230 rm -rf conftest conftest.*
2232 if test "$do_threads" = "check" -o "$do_threads" = "yes"
2238 if test "$do_threads" = "yes"
2240 AC_MSG_ERROR([cannot enable multi-threaded mode - no pthread.h])
2244 dnl Check if pthread_mutex_t is defined in pthread.h
2245 dnl Ignore the fact that pthread.h could be missing - we don't
2246 dnl really care if this test fails because of missing pthread_mutex_t
2247 dnl or because of missing headers.
2248 AC_MSG_CHECKING([for pthread_mutex_t in pthread.h])
2250 [#include <pthread.h>], [pthread_mutex_t mymutex;],
2251 AC_DEFINE(HAVE_PTHREAD_MUTEX_T, [1], [pthread_mutex_t type]) AC_MSG_RESULT(yes),
2253 if test "$do_threads" = "yes"
2255 AC_MSG_ERROR([cannot enable multi-threaded mode - no mutexes])
2261 dnl Check which library provide pthread stuff
2262 AC_MSG_CHECKING([where pthread_create() is defined])
2263 for cand in "" pthreads pthread ; do
2267 LIBS=`echo $LIBS -l$cand`
2271 #include <pthread.h>
2274 pthread_create(NULL, NULL, NULL, NULL);
2275 ], AC_MSG_RESULT(lib${cand:-c})
2278 lib_for_pthreads="$cand"
2280 lib_for_pthreads="-l$cand"
2286 AC_SUBST(lib_for_pthreads)
2288 if test "$ac_cv_header_pthread_h" = "yes"
2290 dnl printf type for pthread_t
2291 AC_MSG_CHECKING([printf type for pthread_t])
2292 cat <<End-of-File >conftest.c
2293 #include <pthread.h>
2298 AC_MSG_RESULT($fmt_pthread)
2299 AC_SUBST(fmt_pthread)
2300 rm -rf conftest.c conftest.debug
2302 dnl check if gcc supports __thread for thread private data
2303 AC_MSG_CHECKING([if compiler supports __thread])
2304 dnl __thread support is broken in some places
2305 if test $target_os = netbsd
2307 AC_TRY_COMPILE([#include <pthread.h>
2308 #if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 5 )
2313 AC_DEFINE(HAVE___THREAD, [1], [__thread private data]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2315 AC_TRY_COMPILE([#include <pthread.h>
2316 __thread int x;], [],
2317 AC_DEFINE(HAVE___THREAD, [1], [__thread private data]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2320 dnl Check if pthread_barrier_t is defined in pthread.h
2321 AC_MSG_CHECKING([for pthread_barrier_t in pthread.h])
2322 AC_TRY_COMPILE([#include <pthread.h>], [pthread_barrier_t mybarrier;],
2323 AC_DEFINE(HAVE_PTHREAD_BARRIER_T, [1], [pthread_barrier_t type]) AC_MSG_RESULT(yes),
2328 AC_MSG_CHECKING([sizeof suseconds_t])
2329 if test "$cross_compiling" = "yes"; then
2330 ans=$sizeof_suseconds_t
2331 echo "cross-compile -> \"$ans\"" >&5
2333 cat <<End-of-File >conftest.c
2334 #include <sys/time.h>
2335 main() { printf("%d", (int)sizeof(suseconds_t)); }
2337 (eval $ac_compile) 2>&5
2338 (eval $ac_link) 2>&5
2340 echo "./conftest -> \"$ans\"" >&5
2341 rm -rf conftest conftest.*
2344 AC_DEFINE_UNQUOTED(SIZEOF_SUSECONDS_T, $ans, [sizeof suseconds_t])
2346 AC_MSG_CHECKING([sizeof time_t])
2347 if test "$cross_compiling" = "yes"; then
2349 echo "cross-compile -> \"$ans\"" >&5
2351 cat <<End-of-File >conftest.c
2352 #include <sys/time.h>
2353 main() { printf("%d", (int)sizeof(time_t)); }
2355 (eval $ac_compile) 2>&5
2356 (eval $ac_link) 2>&5
2358 echo "./conftest -> \"$ans\"" >&5
2359 rm -rf conftest conftest.*
2362 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ans, [sizeof time_t])
2364 dnl check sizeof long
2365 AC_MSG_CHECKING([sizeof long])
2366 if test "$cross_compiling" = "yes"; then
2368 echo "cross-compile -> \"$ans\"" >&5
2370 cat <<End-of-File >conftest.c
2372 main() { printf("%d", (int)sizeof(long)); }
2374 (eval $ac_compile) 2>&5
2375 (eval $ac_link) 2>&5
2377 echo "./conftest -> \"$ans\"" >&5
2380 if test "$ans" = 4; then
2381 AC_DEFINE(HAVE_32BIT_LONG, [1], [sizeof long])
2382 elif test "$ans" = 8; then
2383 AC_DEFINE(HAVE_64BIT_LONG, [1], [sizeof long])
2386 echo "FATAL ERROR: size of long is not 32 or 64 bits, cannot proceed."
2387 echo "sizeof(char *) -> $ans"
2388 rm -rf conftest conftest.*
2391 rm -rf conftest conftest.*
2393 dnl check sizeof pointer
2394 AC_MSG_CHECKING([sizeof pointer])
2395 if test "$cross_compiling" = "yes"; then
2397 echo "cross-compile -> \"$ans\"" >&5
2399 cat <<End-of-File >conftest.c
2401 main() { printf("%d", (int)sizeof(char *)); }
2403 (eval $ac_compile) 2>&5
2404 (eval $ac_link) 2>&5
2406 echo "./conftest -> \"$ans\"" >&5
2409 if test "$ans" = 4; then
2410 AC_DEFINE(HAVE_32BIT_PTR, [1], [pointer size])
2412 elif test "$ans" = 8; then
2413 AC_DEFINE(HAVE_64BIT_PTR, [1], [pointer size])
2417 echo "FATAL ERROR: size of pointer is not 32 or 64 bits, cannot proceed."
2418 echo "sizeof(char *) -> $ans"
2419 rm -rf conftest conftest.*
2422 rm -rf conftest conftest.*
2424 dnl check sizeof int. If not 32, we die
2425 AC_MSG_CHECKING([sizeof int])
2426 if test "$cross_compiling" = "yes"; then
2428 echo "cross-compile -> \"$ans\"" >&5
2430 cat <<End-of-File >conftest.c
2432 main() { printf("%d", (int)sizeof(int)); }
2434 (eval $ac_compile) 2>&5
2435 (eval $ac_link) 2>&5
2437 echo "./conftest -> \"$ans\"" >&5
2443 echo "FATAL ERROR: sizeof(int) is not 32 bits, cannot proceed."
2444 echo "Note: 32-bit ints are assumed in the PCP external file formats and"
2445 echo " the over-the-wire PDU formats"
2446 rm -rf conftest conftest.*
2449 rm -rf conftest conftest.*
2451 dnl check bit field allocation order within a word
2452 AC_MSG_CHECKING([if bit fields allocated left-to-right])
2453 if test "$cross_compiling" = "yes"; then
2454 ans=$bit_field_scheme
2455 echo "cross-compile -> \"$ans\"" >&5
2457 cat <<End-of-File >conftest.c
2458 union { struct { unsigned int b:4; unsigned int c:4; } a; int p; } u;
2459 main() { u.a.b = 1; u.a.c = 2; printf("%0*x", 2*sizeof(int), u.p); }
2461 (eval $ac_compile) 2>&5
2462 (eval $ac_link) 2>&5
2464 echo "./conftest -> \"$ans\"" >&5
2469 # left-to-right starting from MSB (SGI cc on MIPS), or
2470 # left-to-right ending at LSB
2471 AC_DEFINE(HAVE_BITFIELDS_LTOR, [1], [left-to-right bitfield ordering])
2475 # right-to-left ending at MSB, or
2476 # right-to-left starting from LSB (gcc in Intel)
2480 AC_MSG_RESULT(unknown)
2481 echo "FATAL ERROR: could not fathom your compiler's bit field allocation scheme"
2482 rm -f conftest conftest.*
2486 rm -rf conftest conftest.*
2488 dnl check if compiler can cast __uint64_t to double
2496 double y = (double)x;
2497 ], AC_DEFINE(HAVE_CAST_U64_DOUBLE, [1], [compiler casts u64 to double]))
2499 dnl check if basename and dirname need -lgen, -lpcp or nothing to work
2500 dnl (assume both go together)
2501 AC_CHECK_FUNCS(basename)
2502 if test $ac_cv_func_basename = yes
2504 AC_DEFINE(HAVE_BASENAME, [1], [basename API])
2505 AC_DEFINE(HAVE_DIRNAME, [1], [dirname API])
2508 AC_CHECK_LIB(gen, basename)
2509 if test $ac_cv_lib_gen_basename = yes
2511 AC_DEFINE(HAVE_BASENAME, [1], [basename API])
2512 AC_DEFINE(HAVE_DIRNAME, [1], [dirname API])
2513 lib_for_basename="-lgen"
2515 lib_for_basename="-lpcp"
2518 AC_SUBST(lib_for_basename)
2520 dnl check if clock_gettime needs -lrt to work
2521 lib_for_clock_gettime=
2522 AC_CHECK_FUNCS(clock_gettime)
2523 if test $ac_cv_func_clock_gettime = no
2525 AC_CHECK_LIB(rt, clock_gettime)
2526 if test $ac_cv_lib_rt_clock_gettime = yes
2528 AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [clock_gettime API])
2532 AC_SUBST(lib_for_rt)
2534 dnl check if dlopen et al need -ldl to work
2536 AC_CHECK_FUNCS(dlopen)
2537 if test $ac_cv_func_dlopen = no
2539 AC_CHECK_LIB(dl, dlopen)
2540 if test $ac_cv_lib_dl_dlopen = yes
2542 AC_DEFINE(HAVE_DLOPEN, [1], [dlopen API])
2546 AC_SUBST(lib_for_dlopen)
2548 dnl check if flog10, pow, fpclassify and isnanf are available
2549 dnl in the maths library
2551 AC_CHECK_FUNCS(flog10)
2552 if test $ac_cv_func_flog10 = no
2554 AC_CHECK_LIB(m, flog10)
2555 if test $ac_cv_lib_m_flog10 = yes
2557 AC_DEFINE(HAVE_FLOG10, [1], [flog10 math API])
2561 AC_DEFINE(HAVE_FLOG10, [1], [flog10 math API])
2564 if test $ac_cv_func_pow = no
2566 AC_CHECK_LIB(m, pow)
2567 if test $ac_cv_lib_m_pow = yes
2569 AC_DEFINE(HAVE_POW, [1], [pow math API])
2573 AC_DEFINE(HAVE_POW, [1], [pow math API])
2575 AC_MSG_CHECKING([for fpclassify()])
2576 ac_cv_func_fpclassify=no
2583 if (fpclassify(x) == FP_NAN) exit(1);
2584 ], ac_cv_func_fpclassify=yes)
2585 AC_MSG_RESULT($ac_cv_func_fpclassify)
2586 if test $ac_cv_func_fpclassify = no
2589 AC_MSG_CHECKING([for fpclassify() with -lm])
2598 if (fpclassify(x) == FP_NAN) exit(1);
2599 ], ac_cv_func_fpclassify=yes)
2600 AC_MSG_RESULT($ac_cv_func_fpclassify)
2601 if test $ac_cv_func_fpclassify = yes
2607 if test $ac_cv_func_fpclassify = yes
2609 AC_DEFINE(HAVE_FPCLASSIFY, [1], [fpclassify math API])
2611 dnl prefer fpclassify() but will take isnan() and isnanf() as
2612 dnl possible alternates
2613 AC_CHECK_FUNCS(isnan)
2614 if test $ac_cv_func_isnan = no
2616 AC_CHECK_LIB(m, isnan)
2617 if test $ac_cv_lib_m_isnan = yes
2619 AC_DEFINE(HAVE_ISNAN, [1], [isnan math API])
2623 AC_CHECK_FUNCS(isnanf)
2624 if test $ac_cv_func_isnanf = no
2626 AC_CHECK_LIB(m, isnanf)
2627 if test $ac_cv_lib_m_isnanf = yes
2629 AC_DEFINE(HAVE_ISNANF, [1], [isnanf math API])
2634 AC_SUBST(lib_for_math)
2636 dnl check if we have the SIG_PF typedef
2637 AC_TRY_LINK([#include <signal.h>], [SIG_PF x;],
2638 AC_DEFINE(HAVE_SIGPF, [1], [SIG_PF typedef]))
2640 dnl check if we have the SA_SIGINFO #define
2641 AC_TRY_LINK([#include <signal.h>], [int x = SA_SIGINFO;],
2642 AC_DEFINE(HAVE_SA_SIGINFO, [1], [SA_SIGINFO macro]))
2644 dnl check if we support the SIGPIPE signal
2645 AC_TRY_LINK([#include <signal.h>], [int x = SIGPIPE;],
2646 AC_DEFINE(HAVE_SIGPIPE, [1], [SIGPIPE signal]))
2648 dnl check if we support the SIGHUP signal
2649 AC_TRY_LINK([#include <signal.h>], [int x = SIGHUP;],
2650 AC_DEFINE(HAVE_SIGHUP, [1], [SIGHUP signal]))
2652 dnl check if we support the SIGBUS signal
2653 AC_TRY_LINK([#include <signal.h>], [int x = SIGBUS;],
2654 AC_DEFINE(HAVE_SIGBUS, [1], [SIGBUS signal]))
2656 dnl check if we need to explicitly include signal.h
2657 AC_TRY_LINK([#include <sys/wait.h>],
2658 [ typedef void (*SIGRET)(int);
2660 ], AC_DEFINE(HAVE_WAIT_INCLUDES_SIGNAL, [1], [indirect signal.h]))
2662 dnl check for name and type of time fields in struct stat
2663 dnl IRIX example timespec_t st_mtim;
2664 dnl Linux example struct timespec st_mtim;
2665 dnl Darwin example struct timespec st_mtimespec;
2666 dnl Solaris example timestruc_t st_mtim;
2667 dnl FreeBSD (6.1) struct timespec st_mtimespec;
2668 dnl struct timespec {
2673 have_stat_type=false
2674 have_stat_name=false
2675 if test $have_stat_name = false
2678 changequote(<<, >>)<<[ ]st_mtimespec>>changequote([, ]),
2679 sys/stat.h, [ have_stat_name=true;
2680 AC_DEFINE(HAVE_ST_MTIME_WITH_SPEC, [1], [st_mtimespec stat field]) ])
2682 if test $have_stat_name = false -a $target_os != darwin -a $target_os != linux -a $target_os != kfreebsd -a $target_os != netbsd
2685 changequote(<<, >>)<<[ ]st_mtime>>changequote([, ]),
2686 sys/stat.h, [ have_stat_name=true;
2687 AC_DEFINE(HAVE_ST_MTIME_WITH_E, [1], [st_mtime stat field]) ])
2689 if test $have_stat_type = false
2692 changequote(<<, >>)<<timestruc_t[ ][ ]*st_mtim>>changequote([, ]),
2693 sys/stat.h, [ have_stat_type=true;
2694 AC_DEFINE(HAVE_STAT_TIMESTRUC, [1], [timestruc_t type]) ])
2696 if test $have_stat_type = false
2699 changequote(<<, >>)<<timespec_t[ ][ ]*st_mtim>>changequote([, ]),
2700 sys/stat.h, [ have_stat_type=true;
2701 AC_DEFINE(HAVE_STAT_TIMESPEC_T, [1], [timespec_t type]) ])
2703 if test $have_stat_type = false
2706 changequote(<<, >>)<<timespec[ ][ ]*st_mtim>>changequote([, ]),
2707 sys/stat.h, [ have_stat_type=true;
2708 AC_DEFINE(HAVE_STAT_TIMESPEC, [1], [timespec type]) ])
2710 if test $have_stat_type = false
2713 changequote(<<, >>)<<time_t[ ][ ]*st_mtim>>changequote([, ]),
2714 sys/stat.h, [ have_stat_type=true;
2715 AC_DEFINE(HAVE_STAT_TIME_T, [1], [time_t type]) ])
2717 if test $have_stat_type = false
2719 echo 'FATAL ERROR: Cannot determine struct stat time types.'
2720 rm -rf conftest conftest.*
2725 dnl Work out where to install stuff for this package
2726 dnl (and where to find stuff at run-time for add-on packages).
2730 dnl Predictable directory containing pcp.conf, or overridden
2731 dnl by the $PCP_CONF environment variable. If this is not set
2732 dnl (default /etc/pcp.conf), then $PCP_CONF must be set in
2733 dnl the environment.
2735 dnl The eval echo stuff is used to get around unfavourable
2736 dnl elements of the GNU standards, which cause embedding of
2737 dnl ${prefix} within many of these various $dirs.
2738 dnl http://www.gnu.org/software/autoconf/manual/autoconf.html#Installation-Directory-Variables
2740 pcp_etc_dir=`eval echo $sysconfdir`
2741 pcp_etc_dir=`eval echo $pcp_etc_dir`
2742 AC_SUBST(pcp_etc_dir)
2743 pcp_saslconf_dir=`eval echo $sysconfdir/sasl2`
2744 pcp_saslconf_dir=`eval echo $pcp_saslconf_dir`
2745 AC_SUBST(pcp_saslconf_dir)
2746 pcp_sysconf_dir=`eval echo $sysconfdir/pcp`
2747 pcp_sysconf_dir=`eval echo $pcp_sysconf_dir`
2748 AC_SUBST(pcp_sysconf_dir)
2749 pcp_pmcdconf_path=$pcp_sysconf_dir/pmcd/pmcd.conf
2750 pcp_pmcdrclocal_path=$pcp_sysconf_dir/pmcd/rc.local
2751 pcp_pmcdoptions_path=$pcp_sysconf_dir/pmcd/pmcd.options
2752 pcp_pmwebdoptions_path=$pcp_sysconf_dir/pmwebd/pmwebd.options
2753 pcp_pmmgroptions_path=$pcp_sysconf_dir/pmmgr/pmmgr.options
2754 pcp_pmproxyoptions_path=$pcp_sysconf_dir/pmproxy/pmproxy.options
2755 pcp_pmiecontrol_path=$pcp_sysconf_dir/pmie/control
2756 pcp_pmsnapcontrol_path=$pcp_sysconf_dir/pmsnap/control
2757 pcp_pmloggercontrol_path=$pcp_sysconf_dir/pmlogger/control
2758 AC_SUBST(pcp_pmcdconf_path)
2759 AC_SUBST(pcp_pmcdoptions_path)
2760 AC_SUBST(pcp_pmcdrclocal_path)
2761 AC_SUBST(pcp_pmwebdoptions_path)
2762 AC_SUBST(pcp_pmmgroptions_path)
2763 AC_SUBST(pcp_pmproxyoptions_path)
2764 AC_SUBST(pcp_pmiecontrol_path)
2765 AC_SUBST(pcp_pmsnapcontrol_path)
2766 AC_SUBST(pcp_pmloggercontrol_path)
2768 dnl shared PCP files (shareable for diskless)
2769 pcp_share_dir=`eval echo $datarootdir/pcp`
2770 pcp_share_dir=`eval echo $pcp_share_dir`
2771 AC_SUBST(pcp_share_dir)
2773 dnl private PCP executables
2774 pcp_binadm_dir=`eval echo $libexecdir/pcp/bin`
2775 pcp_binadm_dir=`eval echo $pcp_binadm_dir`
2776 AC_SUBST(pcp_binadm_dir)
2778 dnl non-shared (i.e. system local) PCP files
2779 pcp_var_dir=`eval echo $localstatedir/lib/pcp`
2780 pcp_var_dir=`eval echo $pcp_var_dir`
2781 AC_SUBST(pcp_var_dir)
2783 dnl pmcd control and options files
2784 AC_ARG_WITH(configdir,[AC_HELP_STRING([--with-configdir],[configuration directory [LOCALSTATEDIR/pcp/config]])],
2785 [pcp_config_dir=$withval],
2786 [pcp_config_dir=$pcp_var_dir/config])
2788 pcp_pmdas_dir=$pcp_var_dir/pmdas
2789 AC_SUBST(pcp_pmdas_dir)
2791 dnl runtime shared libraries
2792 pcp_lib_dir=`eval echo $libdir`
2793 pcp_lib_dir=`eval echo $pcp_lib_dir`
2794 pcp_lib32_dir=`echo $pcp_lib_dir | sed -e s,64,, -e s,//,/,`
2795 AC_SUBST(pcp_lib_dir)
2796 AC_SUBST(pcp_lib32_dir)
2799 AC_ARG_WITH(perl_installdirs,[AC_HELP_STRING([--with-perl_installdirs],[perl installdirs [vendor]])],
2800 [perl_installdirs=$withval],
2801 [perl_installdirs=vendor])
2802 perl_installdirs=`eval echo $perl_installdirs`
2803 perl_installdirs=`eval echo $perl_installdirs`
2804 AC_SUBST(perl_installdirs)
2805 AC_ARG_WITH(perl_install_base,[AC_HELP_STRING([--with-perl_install_base],[perl install_base [PREFIX]])],
2806 [perl_install_base=$withval],
2807 [perl_install_base=$prefix])
2808 perl_install_base=`eval echo $perl_install_base`
2809 perl_install_base=`eval echo $perl_install_base`
2810 AC_SUBST(perl_install_base)
2812 AC_ARG_WITH(python_prefix,[AC_HELP_STRING([--with-python_prefix],[python setup.py prefix [PREFIX]])],
2813 [python_prefix=$withval],
2814 [python_prefix=$prefix])
2815 python_prefix=`eval echo $python_prefix`
2816 python_prefix=`eval echo $python_prefix`
2817 AC_SUBST(python_prefix)
2820 pcp_x11_incflags=$X_CFLAGS
2821 AC_SUBST(pcp_x11_incflags)
2822 pcp_x11_libflags=$X_LIBS
2823 AC_SUBST(pcp_x11_libflags)
2824 pcp_x11_extra=$X_EXTRA_LIBS
2825 AC_SUBST(pcp_x11_extra)
2826 pcp_x11_pre=$X_PRE_LIBS
2827 AC_SUBST(pcp_x11_pre)
2829 dnl man pages (source)
2831 have_gzipped_manpages=false
2832 have_bzip2ed_manpages=false
2833 have_lzmaed_manpages=false
2834 have_xzed_manpages=false
2835 need_old_tbl_header=false
2837 pcp_man_dir=`eval echo $mandir`
2838 pcp_man_dir=`eval echo $pcp_man_dir`
2840 dnl guess compression in use
2841 for d in /usr/man /usr/share/man $pcp_man_dir
2843 for sd in man1 sman1
2845 if test -f $d/$sd/man.1.gz
2847 have_gzipped_manpages=true
2849 man_header=`$ZIP -d < $d/$sd/man.1.gz | head -1`
2851 elif test -f $d/$sd/man.1.bz2
2853 have_bzip2ed_manpages=true
2855 man_header=`$BZIP2 -d < $d/$sd/man.1.bz2 | head -1`
2857 elif test -f $d/$sd/man.1.lzma
2859 have_lzmaed_manpages=true
2861 man_header=`$LZMA -d < $d/$sd/man.1.lzma | head -1`
2863 elif test -f $d/$sd/man.1.xz
2865 have_xzed_manpages=true
2867 man_header=`$XZ -d < $d/$sd/man.1.xz | head -1`
2869 elif test -f $d/$sd/man.1
2871 man_header=`head -1 $d/$sd/man.1`
2877 if test x"$man_header" = "x'\\\" t" -o x"$man_header" = "x'\\\" te" ; then
2878 need_old_tbl_header=true
2880 AC_SUBST(pcp_man_dir)
2881 AC_SUBST(have_manpages)
2882 AC_SUBST(have_gzipped_manpages)
2883 AC_SUBST(have_bzip2ed_manpages)
2884 AC_SUBST(have_lzmaed_manpages)
2885 AC_SUBST(have_xzed_manpages)
2886 AC_SUBST(need_old_tbl_header)
2889 pcp_bin_dir=`eval echo $bindir`
2890 pcp_bin_dir=`eval echo $pcp_bin_dir`
2891 AC_SUBST(pcp_bin_dir)
2893 pcp_sbin_dir=`eval echo $sbindir`
2894 pcp_sbin_dir=`eval echo $pcp_sbin_dir`
2895 AC_SUBST(pcp_sbin_dir)
2898 pcp_inc_dir=`eval echo $includedir/pcp`
2899 pcp_inc_dir=`eval echo $pcp_inc_dir`
2900 AC_SUBST(pcp_inc_dir)
2902 dnl books - pdfs, html
2903 if test $target_os = linux; then
2904 pcp_books_dir=`eval echo $datarootdir/doc/pcp-doc`
2906 pcp_books_dir=`eval echo $datarootdir/doc/pcp`
2908 pcp_books_dir=`eval echo $pcp_books_dir`
2909 pcp_html_dir=`eval echo $pcp_books_dir/html`
2910 AC_SUBST(pcp_books_dir)
2911 AC_SUBST(pcp_html_dir)
2913 dnl icon pixmap files
2914 if test $target_os = linux; then
2915 pcp_icons_dir=`eval echo $datarootdir/pcp-gui/pixmaps`
2917 pcp_icons_dir=`eval echo $datarootdir/pcp/pixmaps`
2919 pcp_icons_dir=`eval echo $pcp_icons_dir`
2920 AC_SUBST(pcp_icons_dir)
2922 dnl desktop application entries
2923 pcp_desktop_dir=`eval echo $datarootdir/applications`
2924 pcp_desktop_dir=`eval echo $pcp_desktop_dir`
2925 AC_SUBST(pcp_desktop_dir)
2927 dnl rc/startup files
2928 AC_ARG_WITH(rcdir,[AC_HELP_STRING([--with-rcdir],[rc directory [SYSCONFDIR/rc.d]])],
2929 [pcp_rc_dir=$withval], [
2932 pcp_rc_dir="$pcp_share_dir/lib"
2934 pcp_rc_dir="$pcp_etc_dir/init.d"
2936 AC_SUBST(pcp_rc_dir)
2938 dnl rc sysconfig dir
2939 AC_ARG_WITH(sysconfigdir,[AC_HELP_STRING([--with-sysconfigdir],[sysconfig directory [SYSCONFDIR/sysconfig]])],
2940 [pcp_sysconfig_dir=$withval],
2941 [pcp_sysconfig_dir=$pcp_etc_dir/sysconfig])
2942 AC_SUBST(pcp_sysconfig_dir)
2945 AC_ARG_WITH(logdir,[AC_HELP_STRING([--with-logdir],[log directory [LOCALSTATEDIR/log/pcp]])],
2946 [pcp_log_dir=$withval],
2947 [pcp_log_dir=$localstatedir/log/pcp])
2948 pcp_log_dir=`eval echo $pcp_log_dir`
2949 pcp_log_dir=`eval echo $pcp_log_dir`
2950 AC_SUBST(pcp_log_dir)
2952 AC_ARG_WITH(rundir,[AC_HELP_STRING([--with-rundir],[run directory [LOCALSTATEDIR/run/pcp]])],
2953 [pcp_run_dir=$withval],
2954 [pcp_run_dir=$localstatedir/run/pcp])
2955 pcp_run_dir=`eval echo $pcp_run_dir`
2956 pcp_run_dir=`eval echo $pcp_run_dir`
2957 AC_SUBST(pcp_run_dir)
2959 dnl world-writeable temporary files directory
2960 AC_ARG_WITH(tmpdir,[AC_HELP_STRING([--with-tmpdir],[tmp directory [LOCALSTATEDIR/tmp]])],
2961 [pcp_tmpfile_dir=$withval],
2962 [pcp_tmpfile_dir=$localstatedir/tmp])
2963 pcp_tmpfile_dir=`eval echo $pcp_tmpfile_dir`
2964 pcp_tmpfile_dir=`eval echo $pcp_tmpfile_dir`
2965 AC_SUBST(pcp_tmpfile_dir)
2967 dnl non-world-writeable status files directory
2968 pcp_tmp_dir=`eval echo $pcp_var_dir/tmp`
2969 AC_SUBST(pcp_tmp_dir)
2972 AC_ARG_WITH(docdir,[AC_HELP_STRING([--with-docdir],[docs directory [DOCDIR/pcp-VERSION]])],
2973 [pcp_doc_dir=$withval],
2974 [PACKAGE=pcp-${PACKAGE_VERSION}; pcp_doc_dir=$docdir])
2975 pcp_doc_dir=`eval echo $pcp_doc_dir`
2976 pcp_doc_dir=`eval echo $pcp_doc_dir`
2977 AC_SUBST(pcp_doc_dir)
2980 AC_ARG_WITH(demosdir,[AC_HELP_STRING([--with-demosdir],[run directory [DATADIR/pcp/demos]])],
2981 [pcp_demos_dir=$withval],
2982 [pcp_demos_dir=$pcp_share_dir/demos])
2983 AC_SUBST(pcp_demos_dir)
2985 if test -z "$XCONFIRM"
2987 AC_PATH_PROG(ac_xconfirm_prog, xconfirm, $pcp_bin_dir/pmconfirm)
2989 ac_xconfirm_prog=$XCONFIRM
2991 AC_SUBST(ac_xconfirm_prog)
2993 dnl Check for FNDELAY defined in <fcntl.h>
2994 if test "$ac_cv_header_fcntl_h" = "yes"
2996 AC_MSG_CHECKING([for FNDELAY in fcntl.h])
2997 AC_TRY_COMPILE([#include <fcntl.h>],
2998 [ int i = FNDELAY; ],
2999 AC_DEFINE(HAVE_FNDELAY, [1], [FNDELAY macro])
3000 AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3003 dnl check for zpool_vdev_name API style from <libzfs.h>
3004 if test "$ac_cv_header_libzfs_h" = "yes"
3006 AC_MSG_CHECKING([for 5-argument style zpool_vdev_name])
3007 AC_TRY_COMPILE([#include <libzfs.h>],
3008 [ libzfs_handle_t *zh;
3011 (void) zpool_vdev_name(zh, zp, np, B_FALSE, B_FALSE);
3013 AC_DEFINE(HAVE_ZPOOL_VDEV_NAME_5ARG, [1], [5-arg zpool_vdev_name])
3014 AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3016 AC_MSG_CHECKING([for 4-argument style zpool_vdev_name])
3017 AC_TRY_COMPILE([#include <libzfs.h>],
3018 [ libzfs_handle_t *zh;
3021 (void) zpool_vdev_name(zh, zp, np, B_FALSE);
3023 AC_DEFINE(HAVE_ZPOOL_VDEV_NAME_4ARG, [1], [4-arg zpool_vdev_name])
3024 AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3027 dnl Check for Network Security Services (NSS) and
3028 dnl Simple Authentication and Security Layer (SASL)
3029 if test "$do_secure" = "check" -o "$do_secure" = "yes"
3033 saved_CFLAGS="$CFLAGS"
3034 saved_CPPFLAGS="$CPPFLAGS"
3035 NSS_INC_DIRS="-I/usr/include/nss -I/usr/include/nss3"
3036 NSPR_INC_DIRS="-I/usr/include/nspr -I/usr/include/nspr4"
3037 CFLAGS="$CFLAGS $NSS_INC_DIRS $NSPR_INC_DIRS"
3038 CPPFLAGS="$CPPFLAGS $NSS_INC_DIRS $NSPR_INC_DIRS"
3040 AC_CHECK_HEADERS([nss/nss.h], [NSSCFLAGS=-I/usr/include/nss], [
3041 AC_CHECK_HEADERS([nss3/nss.h], [NSSCFLAGS=-I/usr/include/nss3], [
3043 if test "$do_secure" = "yes"
3045 AC_MSG_ERROR([cannot enable secure sockets mode - no NSS header])
3051 AC_CHECK_HEADERS([nspr/nspr.h], [NSPRCFLAGS=-I/usr/include/nspr], [
3052 AC_CHECK_HEADERS([nspr4/nspr.h], [NSPRCFLAGS=-I/usr/include/nspr4], [
3054 if test "$do_secure" = "yes"
3056 AC_MSG_ERROR([cannot enable secure sockets mode - no NSPR header])
3060 AC_SUBST(NSPRCFLAGS)
3062 AC_CHECK_HEADERS([sasl/sasl.h], [SASLCFLAGS=-I/usr/include/sasl], [
3064 if test "$do_secure" = "yes"
3066 AC_MSG_ERROR([cannot enable secure sockets mode - no SASL header])
3069 AC_SUBST(SASLCFLAGS)
3071 AC_CHECK_LIB(sasl2, sasl_server_init, [lib_for_sasl="-lsasl2"], [
3073 if test "$do_secure" = "yes"
3075 AC_MSG_ERROR([cannot enable secure sockets mode - no SASL library])
3078 AC_SUBST(lib_for_sasl)
3080 AC_CHECK_LIB(ssl, SSL_ImportFD, [lib_for_ssl="-lssl"], [
3081 AC_CHECK_LIB(ssl3, SSL_ImportFD, [lib_for_ssl="-lssl3"], [
3083 if test "$do_secure" = "yes"
3085 AC_MSG_ERROR([cannot enable secure sockets mode - no SSL library])
3089 AC_SUBST(lib_for_ssl)
3091 AC_CHECK_LIB(nss, NSS_Init, [lib_for_nss="-lnss"], [
3092 AC_CHECK_LIB(nss3, NSS_Init, [lib_for_nss="-lnss3"], [
3094 if test "$do_secure" = "yes"
3096 AC_MSG_ERROR([cannot enable secure sockets mode - no NSS library])
3100 AC_SUBST(lib_for_nss)
3102 AC_CHECK_LIB(nspr, PR_Init, [lib_for_nspr="-lnspr"], [
3103 AC_CHECK_LIB(nspr4, PR_Init, [lib_for_nspr="-lnspr4"], [
3105 if test "$do_secure" = "yes"
3107 AC_MSG_ERROR([cannot enable secure sockets mode - no NSPR library])
3111 AC_SUBST(lib_for_nspr)
3113 if test "$enable_secure" = "true"
3115 AC_DEFINE(HAVE_SECURE_SOCKETS, [1], [Encrypted sockets])
3117 AC_SUBST(enable_secure)
3119 CPPFLAGS="$saved_CPPFLAGS"
3120 CFLAGS="$saved_CFLAGS"
3123 dnl check for -latomic, needed for some -march=i386 builds with i686 c++ distro headers
3124 AC_CHECK_LIB(atomic, __atomic_fetch_add_4, [lib_for_atomic="-latomic"])
3125 AC_SUBST(lib_for_atomic)
3127 dnl check for array sessions
3128 if test -f /usr/include/sn/arsess.h
3130 pcp_mpi_dirs=libpcp_mpi\ libpcp_mpiread
3134 AC_SUBST(pcp_mpi_dirs)
3136 dnl check for Unix Domain socket family structure
3137 AC_MSG_CHECKING([for struct sockaddr_un in sys/un.h])
3139 #include <sys/types.h>
3140 #ifdef HAVE_SYS_SOCKET_H
3141 #include <sys/socket.h>
3143 #ifdef HAVE_SYS_UN_H
3146 ], [ struct sockaddr_un sa; sa.sun_family = AF_UNIX; ],
3147 AC_DEFINE(HAVE_STRUCT_SOCKADDR_UN, [1], [sockaddr_un type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3149 dnl check for Linux Unix Domain socket credential structure
3150 AC_MSG_CHECKING([for struct ucred in sys/socket.h])
3152 #include <sys/types.h>
3153 #ifdef HAVE_SYS_SOCKET_H
3154 #include <sys/socket.h>
3156 #ifdef HAVE_SYS_UN_H
3159 ], [ struct ucred ucred; ucred.uid = 0; ],
3160 AC_DEFINE(HAVE_STRUCT_UCRED, [1], [ucred type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3162 dnl check for struct timespec in <time.h>
3163 AC_MSG_CHECKING([for struct timespec in time.h])
3166 ], [ struct timespec foo; ],
3167 AC_DEFINE(HAVE_STRUCT_TIMESPEC, [1], [timespec type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3169 dnl check if we have IRIX style altzone
3170 AC_MSG_CHECKING([for altzone in time.h])
3173 ], [ time_t az = altzone; ],
3174 AC_DEFINE(HAVE_ALTZONE, [1], [altzone global]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3176 dnl If there is no altzone, check if strftime can handle %z
3177 AC_MSG_CHECKING([if strftime knows about %z])
3183 time_t t = time(NULL);
3184 struct tm * t1 = localtime (&t);
3185 if (strftime (b, 32, "%z", t1) < 3)
3187 if (strcmp(b, "%z") == 0)
3191 ], AC_DEFINE(HAVE_STRFTIME_z, [1], [strftime with %z]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no), AC_MSG_RESULT(no))
3193 dnl does strerror_r return char * a la GNU
3194 dnl (as opposed to the int return for XSI-compliant variants)
3195 AC_MSG_CHECKING([if strerror_r returns char *])
3197 [#include <string.h>], [strerror_r(0, NULL, 0)[0];],
3198 AC_DEFINE(HAVE_STRERROR_R_PTR, [1], [strerror_r return]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3200 dnl first check for readline on its own then with curses
3205 AC_CHECK_FUNC(readline,,
3207 AC_CHECK_LIB(readline, readline,,
3209 dnl AC seems to cache lib/func results
3210 dnl so use another readline func here
3211 AC_CHECK_LIB(readline, add_history,,,[-lcurses])
3214 if test $ac_cv_func_readline = yes
3216 AC_DEFINE(HAVE_READLINE, [1], [readline API])
3217 elif test $ac_cv_lib_readline_readline = yes
3219 AC_DEFINE(HAVE_READLINE, [1], [readline API])
3220 lib_for_readline=-lreadline
3221 elif test $ac_cv_lib_readline_add_history = yes
3223 AC_DEFINE(HAVE_READLINE, [1], [readline API])
3224 lib_for_curses=-lcurses
3225 lib_for_readline=-lreadline
3227 AC_SUBST(lib_for_readline)
3228 AC_SUBST(lib_for_curses)
3232 PKG_CHECK_MODULES([zlib], [zlib >= 1.0.0], [have_zlib=true], [have_zlib=false])
3233 AC_SUBST(HAVE_ZLIB, [$have_zlib])
3235 dnl Check if we have AI_ADDRCONFIG
3236 AC_MSG_CHECKING([for AI_ADDRCONFIG])
3240 int test = AI_ADDRCONFIG;
3243 ], AC_DEFINE(HAVE_AI_ADDRCONFIG, [1], [AI_ADDRCONFIG macro]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3245 dnl Find external source tarballs for packaging
3248 if test -f ./build/tar/parfait.tar.gz
3250 AC_MSG_NOTICE([adding Parfait package to the build])
3253 AC_SUBST(have_parfait)
3256 if test -f ./build/tar/vector.tar.gz
3258 AC_MSG_NOTICE([adding Vector webapp to the build])
3261 AC_SUBST(have_vector)
3264 if test -f ./build/tar/webjs.tar.gz
3266 AC_MSG_NOTICE([adding webjs webapps to the build])
3269 AC_SUBST(have_webjs)
3271 dnl Capture special options passed to configure
3272 AC_SUBST(PACKAGE_CONFIGURE)
3279 dnl Build definitions for use in Makefiles
3280 src/include/builddefs
3281 dnl PCP paths and other defs
3282 src/include/pcp.conf
3283 dnl Linux Software Map entry
3285 dnl Preamble for deb install scripts
3286 debian/pcp.preinst.head
3287 debian/pcp.postinst.head
3288 dnl Preamble for tar install scripts
3289 build/tar/preinstall.head
3290 build/tar/postinstall.head
3291 dnl Build definitions for use in packaging
3293 build/mac/uninstall-pcp
3296 dnl verbose diagnostics
3298 dnl echo config.status: settings dump begin
3299 dnl grep '^S.".*=' config.status
3300 dnl echo config.status: settings dump end