qa: additional Linux memory test data, esp. latest /proc/vmstat
[pcp.git] / configure.ac
blob0cd945f716b9f4dd5573a08d0fae3272e3b45839
1 dnl
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.
5 dnl 
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.
10 dnl 
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
14 dnl for more details.
15 dnl 
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
21 AC_PREREQ([2.63])dnl
23 dnl Irix build issue ... use the tools from the local filesystems
24 unset ROOT TOOLROOT
26 AC_ARG_WITH(
27     [64bit],
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"])
32 AC_ARG_WITH(
33     [optimization],
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])
39 AC_ARG_WITH(
40     [threads],
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"],
44     [do_threads=check])
46 AC_ARG_WITH(
47     [secure-sockets],
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"],
51     [do_secure=check])
53 AC_ARG_WITH(
54     [static-probes],
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"],
58     [do_probes=check])
60 AC_ARG_WITH(
61     [infiniband],
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])
67 AC_ARG_WITH(
68     [user],
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"],
72     [pcp_user=pcp])
73 AC_SUBST(pcp_user)
75 AC_ARG_WITH(
76     [group],
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"],
80     [pcp_group=pcp])
81 AC_SUBST(pcp_group)
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"],
87     [do_discovery=check])
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"],
93     [do_systemd=check])
95 AC_ARG_WITH([qt],
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"],
99     [do_qt=check])
101 AC_ARG_WITH([qt3d],
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"],
105     [do_qt3d=check])
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"],
111     [do_python=check])
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"],
117     [do_python3=check])
119 AC_ARG_WITH([books],
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"],
123     [do_books=no])
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])
131 AC_ARG_WITH([papi],
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"],
137     [do_papi=check])
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"],
149     [do_pmdajson=check])
151 AC_ARG_WITH([pmdasnmp],
152     [AC_HELP_STRING([--with-pmdasnmp],
153                    [enable SNMP pmda (default is on)])],
154     [do_pmdasnmp=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-pmdasnmp=$withval"],
155     [do_pmdasnmp=check])
157 AC_ARG_WITH([manager],
158     [AC_HELP_STRING([--with-manager],
159                    [enable daemon manager (default is on)])],
160     [do_manager=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-manager=$withval"],
161     [do_manager=check])
163 AC_ARG_WITH([webapi],
164     [AC_HELP_STRING([--with-webapi],
165                    [enable REST API daemon (default is on)])],
166     [do_webapi=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-webapi=$withval"],
167     [do_webapi=check])
169 AC_ARG_WITH([webjs],
170     [AC_HELP_STRING([--with-webjs],
171                     [enable building of webjs packages (default is off)])],
172     [do_webjs=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-webjs=$withval"],
173     [do_webjs=no])
175 AC_ARG_WITH([vector],
176     [AC_HELP_STRING([--with-vector],
177                     [enable building of vector package (default is off)])],
178     [do_vector=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-vector=$withval"],
179     [do_vector=no])
181 AC_ARG_WITH([parfait],
182     [AC_HELP_STRING([--with-parfait],
183                     [enable building of parfait package (default is off)])],
184     [do_parfait=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-parfait=$withval"],
185     [do_parfait=no])
187 AC_ARG_WITH([selinux],
188     [AC_HELP_STRING([--with-selinux],
189                     [enable building of selinux package (default is on)])],
190     [do_selinux=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-selinux=$withval"],
191     [do_selinux=check])
192 dnl things set in the environment by Makepkgs never make it into an RPM
193 dnl build where the environment is stripped ... use a --with-foo=path
194 dnl construct to workaround this
196 AC_ARG_WITH([make],
197     [AC_HELP_STRING([--with-make],
198                     [path to GNU compatible make(1) (default is empty for auto discovery)])],
199     [MAKE=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-make=$withval"],
200     [MAKE=''])
202 AC_ARG_WITH([tar],
203     [AC_HELP_STRING([--with-tar],
204                     [path to GNU compatible tar(1) (default is empty for auto discovery)])],
205     [TAR=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-tar=$withval"],
206     [TAR=''])
208 AC_ARG_WITH([zip],
209     [AC_HELP_STRING([--with-zip],
210                     [path to GNU compatible zip(1) (default is empty for auto discovery)])],
211     [ZIP=$withval; PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --with-zip=$withval"],
212     [ZIP=''])
215 dnl Note: the following environment variables may be set to override defaults:
216 dnl MAKE CC CPP LD LEX YACC INSTALL AWK SED ECHO
219 dnl Guess target platfrom
220 AC_CANONICAL_SYSTEM
221 if test -z "$target"
222 then
223     echo '
224 FATAL ERROR: Cannot guess your target, try explicit specification
225              using --target or mailto: pcp@groups.io to ask.'
226     rm -rf conftest conftest.*
227     exit 1
228 else
229     dnl Remove 4th name component, if present, from target, target_os,
230     dnl  build and build_os. Squash all x86 cpus into one LCD form - i386
231     target=`echo $target | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`
232     target_os=`echo $target_os | sed '[s/solaris2\..*/solaris/]'`
233     target_os=`echo $target_os | sed '[s/^\([^-][^-]*\)-.*$/\1/]' | sed '[s/[\.0-9]*//g]'`
235     build=`echo $build | sed '[s/^\([^-][^-]*-[^-][^-]*-[^-][^-]*\)-.*$/\1/]'`
236     build_os=`echo $build_os | sed '[s/solaris2\..*/solaris/]'`
237     build_os=`echo $build_os | sed '[s/^\([^-][^-]*\)-.*$/\1/]'`
240 echo Building on $build for $target 
241 echo "Build: os=$build_os cpu=$build_cpu"
242 echo "Target: os=$target_os cpu=$target_cpu"
244 if test "$cross_compiling" = "yes"; then
245     if test -f ./config.$target_os; then
246         . ./config.$target_os
247     else
248         echo
249         echo "
250 FATAL ERROR: Cannot perform cross-compilation without a file to source
251              configuration information from (config.$target_os is missing)"
252         rm -rf conftest conftest.*
253         exit 1
254     fi
256 AC_SUBST(cross_compiling)
258 dnl CFLAGS setting is a co-dependency between here and PCFLAGS in
259 dnl src/include/builddefs.in ... need to be the same in both places
261 target_distro=$target_os
262 if test $target_os = linux
263 then
264     AC_DEFINE(IS_LINUX, [1], [Platform is Linux])
265     test -f /etc/SuSE-release && target_distro=suse
266     test -f /etc/fedora-release && target_distro=fedora
267     test -f /etc/redhat-release && target_distro=redhat
268     test -f /etc/debian_version && target_distro=debian
269     test -f /etc/slackware-version && target_distro=slackware
270     test -f /etc/gentoo-release && target_distro=gentoo
271     test -f /etc/mandriva-release && target_distro=mandriva
272     test -f /etc/arch-release && target_distro=arch
273     export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
274     pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
275     pcp_ps_all_flags=-efw
276 elif test $target_os = darwin
277 then
278     AC_DEFINE(IS_DARWIN, [1], [Platform is Darwin (Mac OS X)])
279     target_distro=macosx
280     version=`sw_vers -productVersion | sed -e 's/\.//' -e 's/\..*//g'`
281     CFLAGS="-fPIC -no-cpp-precomp -fno-strict-aliasing -arch i386"
282     if test $version -ge 106
283     then
284         target_distro=cocoa
285         CFLAGS="$CFLAGS -arch x86_64"
286     fi
287     export CFLAGS
288     pcp_platform_paths='/usr/local/bin'
289     pcp_ps_all_flags="-axw -o user,pid,ppid,cpu,stime,tty,time,command"
290 elif test $target_os = mingw
291 then
292     AC_DEFINE(IS_MINGW, [1], [Platform is MinGW (Windows)])
293     CFLAGS="-fno-strict-aliasing"
294     pcp_platform_paths=''
295     pcp_ps_all_flags=-efW
296 elif test $target_os = solaris
297 then
298     AC_DEFINE(IS_SOLARIS, [1], [Platform is Solaris])
299     export CFLAGS_IF_GCC="-fPIC -fno-strict-aliasing"
300     export CFLAGS_IF_SUNCC="-fPIC -xalias_level=any -D_XPG4_2 -D__EXTENSIONS__"
301     pcp_platform_paths='/usr/bin/X11:/usr/local/bin:/opt/sfw/bin:/opt/csw/bin'
302     pcp_ps_all_flags=-ef
303 elif test $target_os = aix
304 then
305     AC_DEFINE(IS_AIX, [1], [Platform is AIX])
306     export CFLAGS="-qcpluscmt"
307     pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
308     pcp_ps_all_flags=-ef
309 elif test $target_os = freebsd || test $target_os = kfreebsd
310 then
311     AC_DEFINE(IS_FREEBSD, [1], [Platform is FreeBSD])
312     test -f /etc/debian_version && target_distro=debian
313     export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
314     if test $target_os = kfreebsd
315     then
316         pcp_ps_all_flags=-efw
317     else
318         pcp_ps_all_flags=auxww
319     fi
320     pcp_platform_paths='/usr/bin/X11'
321     test -d /usr/local/bin && pcp_platform_paths="$pcp_platform_paths:/usr/local/bin"
322     test -d /usr/bsd && pcp_platform_paths="$pcp_platform_paths:/usr/bsd"
323 elif test $target_os = gnu
324 then
325     AC_DEFINE(IS_GNU, [1], [Platform is GNU Hurd])
326     test -f /etc/debian_version && target_distro=debian
327     export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
328     pcp_platform_paths='/usr/bin/X11:/usr/local/bin'
329     pcp_ps_all_flags=-efw
330 elif test $target_os = netbsdelf
331 then
332     target_os=netbsd
333     AC_DEFINE(IS_NETBSD, [1], [Platform is NetBSD])
334     export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE -D_NETBSD_SOURCE"
335     pcp_platform_paths='/usr/pkg/bin'
336     pcp_ps_all_flags=auxww
337 elif test $target_os = openbsd
338 then
339     target_os=openbsd
340     AC_DEFINE(IS_OPENBSD, [1], [Platform is OpenBSD])
341     export CFLAGS="-fPIC -fno-strict-aliasing -D_GNU_SOURCE"
342     pcp_platform_paths='/usr/local/bin'
343     pcp_ps_all_flags=auxww
344 else
345     echo
346     echo "FATAL ERROR: need platform-specific customization for \"$target_os\""
347     rm -rf conftest conftest.*
348     exit 1
350 AC_SUBST(pcp_platform_paths)
351 AC_SUBST(pcp_ps_all_flags)
353 dnl default C and C++ compiler optimization to -O2 -g
354 if test "$use_optimization" = no
355 then
356     optimization="-O0 -g"
357 else
358     optimization="-O2 -g"
360 AC_SUBST(optimization)
362 PKG_PROG_PKG_CONFIG
363 if test -z "$PKG_CONFIG"; then
364     AC_MSG_ERROR([cannot find a 'pkg-config' command])
367 dnl check if user wants their own C compiler
368 cflags_abi=
369 AC_PROG_CC(suncc egcc gcc cc)
370 if test $target_os = solaris
371 then
372     AC_PATH_PROG(CCPATH,$CC,$CC)
373     cc=$CCPATH
374     if test "$GCC" = "yes"
375     then
376         CFLAGS="$CFLAGS $CFLAGS_IF_GCC"
377     else
378         CFLAGS="$CFLAGS $CFLAGS_IF_SUNCC"
379     fi
380     if test "$use_64bit" = "no"
381     then
382         :
383     else
384         AC_MSG_CHECKING([for 64 bit Solaris host])
385         case `isainfo -k`
386         in
387             amd64|sparcv9)
388                 cflags_abi=-m64
389                 CFLAGS="$CFLAGS -m64"
390                 LDFLAGS="$LDFLAGS -m64"
391                 AC_MSG_RESULT(yes)
392                 ;;
393             *)
394                 AC_MSG_RESULT(no)
395                 ;;
396         esac
397     fi
398 else
399     cc=$CC
401 AC_SUBST(cc)
402 cc_is_gcc=$GCC
403 AC_SUBST(cc_is_gcc)
404 AC_SUBST(cflags_abi)
405 dnl these become CFLAGS and LDFLAGS for the build
406 PCFLAGS="$CFLAGS"
407 PLDFLAGS=$LDFLAGS
409 if echo "$CFLAGS" | grep 'D_FORTIFY_SOURCE' >/dev/null
410 then
411     dnl for cc use locally in configure (not exported via $PCFLAGS),
412     dnl add -O in case -D_FORTIFY_SOURCE has been added to CFLAGS above,
413     dnl as -D_FORTIFY_SOURCE requires -O but we've separated optimization
414     dnl flags out into $CFLAGS_OPT for our build infrastructure
415     CFLAGS="-O $PCFLAGS"
418 dnl some versions of gcc (e.g. version 4.8.4 on Gentoo Hardened) have added
419 dnl a predefined for _FORTIFY_SOURCE but only when -O is specified ... so
420 dnl to be safe we have -U_FORTIFY_SOURCE before -D_FORTIFY_SOURCE=2 below
422 dnl Add some security-related gcc flags
423 if echo "$CFLAGS" | grep stack-protector >/dev/null
424 then
425     dnl already set, probably from the environment
426     :
427 else
428     AC_ARG_ENABLE([ssp],
429     [AS_HELP_STRING([--disable-ssp], [disable gcc stack-protector])])
430     AS_IF([test "x$cc_is_gcc" = xyes -a "x$enable_ssp" != xno ],[
431        save_CFLAGS="$CFLAGS"
432        CFLAGS="$CFLAGS -O -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
433        AC_COMPILE_IFELSE([AC_LANG_SOURCE([int something ();])], [
434            AC_MSG_NOTICE([Compiling with gcc -fstack-protector-all et al.])
435            PCFLAGS="$PCFLAGS -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"],[
436            AC_MSG_NOTICE([Compiler does not support -fstack-protector-all et al.])
437            CFLAGS="$save_CFLAGS"
438        ])
439     ])
441 AC_SUBST(PCFLAGS)
442 AC_SUBST(PLDFLAGS)
444 dnl Check for even more security-related gcc/linker flags, useful for daemons
445 AC_ARG_ENABLE([pie],
446   [AS_HELP_STRING([--disable-pie], [disable position-independent-executable])])
447 AS_IF([test "x$cc_is_gcc" = xyes -a "x$enable_pie" != xno],[
448    PIECFLAGS='-fPIE'
449    PIELDFLAGS='-pie -Wl,-z,relro -Wl,-z,now'
450    save_CFLAGS="$CFLAGS"
451    save_LDFLAGS="$LDFLAGS"
452    CFLAGS="$CFLAGS $PIECFLAGS"
453    LDFLAGS="$LDFLAGS $PIELDFLAGS"
454    AC_LINK_IFELSE([AC_LANG_SOURCE([void main () {}])], [
455        AC_MSG_NOTICE([Compiling with gcc pie et al.])
456    ], [
457        AC_MSG_NOTICE([Compiler does not support -pie et al.])
458        PIECFLAGS=""
459        PIELDFLAGS=""
460    ])
461    CFLAGS="$save_CFLAGS"
462    LDFLAGS="$save_LDFLAGS"
464 AC_SUBST(PIELDFLAGS)
465 AC_SUBST(PIECFLAGS)
467 dnl Check for support for symbol hiding via gcc flags
468 AC_ARG_ENABLE([visibility],
469   [AS_HELP_STRING([--disable-visibility], [disable gcc symbol visibility])])
470 AS_IF([test "x$cc_is_gcc" = xyes -a "$enable_visibility" != no],[
471    INVISIBILITY="-fvisibility=hidden"
472    save_CFLAGS="$CFLAGS"
473    CFLAGS="$CFLAGS -c $INVISIBILITY"
474    AC_COMPILE_IFELSE([AC_LANG_SOURCE([int visible () { return 0; }])], [
475        AC_MSG_NOTICE([Compiling DSO PMDAs with gcc -fvisibility=hidden])
476    ], [
477        AC_MSG_NOTICE([Compiler does not support -fvisibility.])
478        INVISIBILITY=""
479    ])
480    CFLAGS="$save_CFLAGS"
482 AC_SUBST(INVISIBILITY)
484 AC_PROG_CXX(eg++ g++ c++)
485 cxx=$CXX
486 AC_SUBST(cxx)
487 AC_MSG_CHECKING([for working C++ compiler])
488 AC_LANG_PUSH([C++])
489 AC_COMPILE_IFELSE(
490    [AC_LANG_PROGRAM([[#include <cstdio>]],
491                     [[const char gday[] = "G'day, world\n";]])],
492    [AC_MSG_RESULT([yes])],
493    [AC_MSG_RESULT([no])
494     cxx=""])
495 AC_LANG_POP([C++])
497 dnl Prevent shared libraries from being built for libpcp and other core libraries
498 AC_ARG_ENABLE([shared],
499   [AS_HELP_STRING([--disable-shared], [disable core shared libary generation])],
500   [PACKAGE_CONFIGURE="$PACKAGE_CONFIGURE --disable-shared=$withval"])
501 AC_SUBST(enable_shared)
503 dnl check if user wants to use any of their own commands;
504 dnl ordering is important: some tests use earlier results
506 test -z "$AWK" && AC_PATH_PROGS(AWK, gawk awk, /usr/bin/awk)
507 case "$AWK"
509     gawk|*/gawk)
510         awk="$AWK --posix"
511         ;;
512     *)
513         awk=$AWK
514         ;;
515 esac
516 AC_SUBST(awk)
518 if test -z "$SED"; then
519     AC_PATH_PROG(SED, sed, /bin/sed)
521 if test ! -x "$SED"; then
522     AC_MSG_ERROR([cannot find a valid 'sed' command.])
524 sed=$SED
525 AC_SUBST(sed)
527 if test -z "$ECHO"; then
528     AC_PATH_PROG(ECHO, echo, /bin/echo)
530 if test ! -x "$ECHO"; then
531     AC_MSG_ERROR([cannot find a valid 'echo' command.])
533 echo=$ECHO
534 AC_SUBST(echo)
536 if test -z "$FIND"; then
537     AC_PATH_PROG(FIND, find, /usr/bin/find)
539 if test ! -x "$FIND"; then
540     AC_MSG_ERROR([cannot find a valid 'find' command.])
542 find=$FIND
543 AC_SUBST(find)
545 if test -z "$WHICH"; then
546     AC_PATH_PROG(WHICH, which, /usr/bin/which)
548 if test ! -x "$WHICH"; then
549     AC_MSG_ERROR([cannot find a valid 'which' command.])
551 which=$WHICH
552 AC_SUBST(which)
554 AC_PROG_LEX
555 lex=`$echo $LEX | awk '{print $1}'`
556 lex=`$which "$lex"`
557 if test ! -x "$lex"; then
558     AC_MSG_ERROR([cannot find a valid 'lex'/'flex' command.])
560 lex=$LEX
561 AC_SUBST(lex)
563 AC_PROG_YACC
564 yacc=`$echo $YACC | awk '{print $1}'`
565 yacc=`$which "$yacc"`
566 if test ! -x "$yacc"; then
567     AC_MSG_ERROR([cannot find a valid 'yacc'/'bison' command.])
569 yacc=$YACC
570 AC_SUBST(yacc)
572 dnl check we don't get the Windows sort ...
573 AC_MSG_CHECKING([where unix-like sort(1) lives])
574 if test $target_os = mingw; then
575     for d in /bin /usr/bin /mingw/bin /mingw/usr/bin
576     do
577         if test -x $d/sort; then
578             sort=$d/sort
579             break
580         fi
581     done
582 else
583     sort=`$which sort`
585 AC_MSG_RESULT($sort)
586 $sort -n </dev/null
587 if test $? != 0
588 then
589     echo
590     echo "FATAL ERROR: $sort -n failed!"
591     rm -rf conftest conftest.*
592     exit 1
594 AC_SUBST(sort)
596 dnl echo_n set to -n if echo understands -n to suppress newline
597 dnl echo_c set to \c if echo understands \c to suppress newline
598 AC_MSG_CHECKING([if echo uses -n or backslash-c to suppress newlines])
599 if ( $echo "testing\c"; $echo 1,2,3 ) | grep c >/dev/null
600 then
601   if ( $echo -n testing; $echo 1,2,3 ) | sed s/-n/xn/ | grep xn >/dev/null
602   then
603     echo_n= echo_c=
604     AC_MSG_RESULT([neither?])
605   else
606     echo_n=-n echo_c=
607     AC_MSG_RESULT([ -n])
608   fi
609 else
610   echo_n= echo_c='\c'
611   AC_MSG_RESULT([backslash-c])
613 AC_SUBST(echo_n)
614 AC_SUBST(echo_c)
616 dnl subsequent configure checks rely on $EGREP being set
617 AC_PROG_EGREP
619 dnl Check for static probes (dtrace, systemtap)
620 if test "$do_probes" = "check" -o "$do_probes" = "yes"
621 then
622     enable_probes=true
623     AC_CHECK_PROGS(DTRACE, dtrace, [])
624     if test -z "$DTRACE"
625     then
626         if test "$do_probes" = "yes"
627         then
628             AC_MSG_ERROR([cannot enable static probes - no dtrace executable])
629         fi
630         enable_probes=false
631     fi
632     AC_CHECK_HEADERS([sys/sdt.h], [
633         if $enable_probes = true
634         then
635             if test $target_os = kfreebsd
636             then
637                 enable_probes=false
638             elif test $target_os = freebsd
639             then
640                 dnl dtrace support in FreeBSD depends on configuration of kernel
641                 rm -f conftest.d conftest.h
642                 cat <<End-of-File >conftest.d
643 provider eek {
644 probe urk(int);
646 End-of-File
647                 if dtrace -s conftest.d -h >/dev/null 2>&1
648                 then
649                     if test ! -f conftest.h
650                     then
651                         enable_probes=false
652                         if test "$do_probes" = "yes"
653                         then
654                             AC_MSG_ERROR([cannot enable static probes - no .h from dtrace -h])
655                         fi
656                     fi
657                 else
658                     enable_probes=false
659                     if test "$do_probes" = "yes"
660                     then
661                         AC_MSG_ERROR([cannot enable static probes - dtrace failed])
662                     fi
663                 fi
664             fi
665         fi
666     ], [
667         enable_probes=false
668         if test "$do_probes" = "yes"
669         then
670             AC_MSG_ERROR([cannot enable static probes - no SDT header])
671         fi
672     ])
674     if test "$enable_probes" = "true"
675     then
676         AC_DEFINE(HAVE_STATIC_PROBES, [1], [Static probes (dtrace, systemtap)])
677     fi
678     AC_SUBST(enable_probes)
679     AC_SUBST(DTRACE)
682 dnl Check for service discovery mechanisms (DNS-SD, Avahi)
683 AS_IF([test "x$do_discovery" != "xno"], [
684     # on Mac OS X, dns_sd.h
686     # on Linux, aloha Avahi
687     enable_avahi=true
688     PKG_CHECK_MODULES([avahi], [avahi-client],
689         [AC_CHECK_LIB(avahi-client, avahi_client_new,
690                       [lib_for_avahi="-lavahi-common -lavahi-client"],
691                       [enable_avahi=false])
692         ],[enable_avahi=false])
693     AC_CHECK_HEADERS([avahi-client/publish.h],, [enable_avahi=false])
694     AC_CHECK_HEADERS([avahi-common/alternative.h],, [enable_avahi=false])
696     if test "$enable_avahi" = "true"
697     then
698         AC_SUBST(lib_for_avahi)
699         AC_SUBST(avahi_CFLAGS)
700         AC_DEFINE(HAVE_AVAHI, [1], [Service discovery via Avahi])
701         enable_discovery=true
702     fi
704     if test "$do_discovery" != "check" -a "$enable_discovery" != "true"
705     then
706         AC_MSG_ERROR([cannot enable service discovery - no supported mechanisms])
707     fi
708     if test "$enable_discovery" = "true"
709     then
710         AC_DEFINE(HAVE_SERVICE_DISCOVERY, [1], [Service discovery mechanisms])
711     fi
713 AC_SUBST(enable_discovery)
714 AC_SUBST(enable_avahi)
716 dnl Check for systemd services
717 enable_systemd=false
718 AS_IF([test "x$do_systemd" != "xno"], [
719     enable_systemd=true
721     PKG_CHECK_VAR([SYSTEMD_SYSTEMUNITDIR], [systemd], [systemdsystemunitdir],
722         [pcp_systemdunit_dir=$SYSTEMD_SYSTEMUNITDIR], [enable_systemd=false])
723     AC_SUBST(pcp_systemdunit_dir)
724     if test -z "$pcp_systemdunit_dir"
725     then
726         if test "$do_systemd" = "yes"
727         then
728             AC_MSG_ERROR([cannot enable systemd support - no systemunitdir path])
729         fi
730         enable_systemd=false
731     fi
733 AC_SUBST(enable_systemd)
735 dnl NB: No AC_PREFIX_DEFAULT is needed, as the default configure invocation
736 dnl targets a build for non-system directories such as /usr/local.
737 dnl AC_PREFIX_DEFAULT([])
739 . ./VERSION.pcp
740 PACKAGE_VERSION=${PACKAGE_MAJOR}.${PACKAGE_MINOR}.${PACKAGE_REVISION}
741 AC_SUBST(PACKAGE_VERSION)
742 AC_SUBST(PACKAGE_MAJOR)
743 AC_SUBST(PACKAGE_MINOR)
744 AC_SUBST(PACKAGE_REVISION)
745 AC_SUBST(PACKAGE_BUILD)
747 if test -z "$PACKAGE_BUILD_DATE" ; then
748     PACKAGE_BUILD_DATE=`date +%Y-%m-%d`
750 AC_SUBST(PACKAGE_BUILD_DATE)
752 if test -z "$PACKAGE_DISTRIBUTION" ; then
753     PACKAGE_DISTRIBUTION=$target_distro
755 AC_SUBST(PACKAGE_DISTRIBUTION)
757 dnl generate PM_VERSION_CURRENT for header
758 pm_version_current=`awk </dev/null "BEGIN { print (${PACKAGE_MAJOR}*256+${PACKAGE_MINOR})*256+${PACKAGE_REVISION} }"`
759 AC_SUBST(pm_version_current)
761 dnl output header files with cpp defs HAVE_*, etc
762 AC_CONFIG_HEADERS(src/include/pcp/config.h src/include/pcp/configsz.h)
763 AC_OUTPUT(src/include/pcp/platform_defs.h src/include/pcp/platformsz.h)
765 AC_CHECK_PROGS(GIT, git)
766 AC_SUBST(GIT)
768 dnl check if python available for the build and runtime
769 AC_CHECK_PROGS(PYTHON, python, python2.7)
770 AC_SUBST(PYTHON)
772 dnl check if python3 available for the build and runtime
773 AC_CHECK_PROGS(PYTHON3, python3, python3.4)
774 AC_SUBST(PYTHON3)
776 dnl check if python tools/packages wanted (need python >= 2.6)
777 enable_python2=false
778 AS_IF([test "x$do_python" != "xno"], [
779     enable_python2=true
780     if test -z "$PYTHON"
781     then
782         enable_python2=false
783     else
784         AC_MSG_CHECKING([Python version])
785         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 }'`
786         AC_MSG_RESULT([$PY_MAJOR.$PY_MINOR.$PY_POINT])
787         if test "$PY_MAJOR" -lt 2; then
788             echo WARNING: Python version 2.6 or later does not seem to be installed.
789             enable_python2=false
790         else
791             if test "$PY_MAJOR" -eq 2 -a "$PY_MINOR" -lt 6 ; then
792                 echo WARNING: Python version 2.$PY_MINOR is too old.
793                 echo Python version 2.6 or later is required for Python builds.
794                 enable_python2=false
795             else
796                 AC_CHECK_HEADERS([python${PY_MAJOR}.${PY_MINOR}/Python.h], [], [
797                     echo WARNING: Python version $PY_MAJOR.$PY_MINOR header file missing.
798                     echo Cannot proceed with the Python $PY_MAJOR installation found.
799                     enable_python2=false
800                 ])
801             fi
802         fi
803     fi
805     if test "$do_python" != "check" -a "$enable_python2" != "true"
806     then
807         AC_MSG_ERROR([cannot enable Python - no supported version found])
808     fi
810 AC_SUBST(enable_python2)
812 dnl check if python3 tools/packages wanted (need python >= 3.3)
813 enable_python3=false
814 AS_IF([test "x$do_python3" != "xno"], [
815     enable_python3=true
816     if test -z "$PYTHON3"
817     then
818         enable_python3=false
819     else
820         AC_MSG_CHECKING([Python3 version])
821         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 }'`
822         AC_MSG_RESULT([$PY_MAJOR.$PY_MINOR.$PY_POINT])
823         if test "$PY_MAJOR" -lt 3; then
824             echo WARNING: Python version 3.3 or later does not seem to be installed.
825             enable_python3=false
826         else
827             if test "$PY_MAJOR" -eq 3 -a "$PY_MINOR" -lt 3 ; then
828                 echo WARNING: Python version 3.$PY_MINOR is too old.
829                 echo Python version 3.3 or later is required for Python builds.
830                 enable_python3=false
831             else
832                 AC_CHECK_HEADERS([python${PY_MAJOR}.${PY_MINOR}m/Python.h], [], [
833                     echo WARNING: Python version $PY_MAJOR.$PY_MINOR header file missing.
834                     echo Cannot proceed with the Python $PY_MAJOR installation found.
835                     enable_python3=false
836                 ])
837             fi
838         fi
839     fi
841     if test "$do_python3" != "check" -a "$enable_python3" != "true"
842     then
843         AC_MSG_ERROR([cannot enable Python3 - no supported version found])
844     fi
846 AC_SUBST(enable_python3)
848 dnl convenience macro to determine if either python is available
849 AC_MSG_CHECKING([for any python version])
850 if test "$cross_compiling" = "yes"; then
851     ans=$have_python
852     echo "cross-compile -> \"$ans\"" >&5
853 elif test "$enable_python2" = "true" -o "$enable_python3" = "true"
854 then
855     have_python=true
856 else
857     have_python=false
859 AC_SUBST(have_python)
860 if $have_python; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
862 dnl choose the prefered python executable (py2 -> py3 transtion)
863 if test "$enable_python3" = "true"
864 then
865     pcp_python_prog=$PYTHON3
866 elif test "$enable_python2" = "true"
867 then
868     pcp_python_prog=$PYTHON
869 else
870     pcp_python_prog=""
872 AC_SUBST(pcp_python_prog)
874 dnl check availability of some Python modules
875 dnl usage PCP_CHECK_PYTHON_MODULE(module_name) or
876 dnl PCP_CHECK_PYTHON_MODULE(module_name, <import string>)
877 dnl default <import string> is "import module_name"
879 dnl sets $have_python_<module_name> as true or false
881 AC_DEFUN(PCP_CHECK_PYTHON_MODULE,
882   [ AC_MSG_CHECKING(for Python module $1)
883     if test -n "$2"
884     then
885         txt="$2"
886     else
887         txt="import $1"
888     fi
889     $pcp_python_prog -c 'import sys;
890 '"$txt" >>config.log 2>&1
891     if test "$?" = 0
892     then
893         AC_MSG_RESULT(yes)
894         eval have_python_$1=true
895     else
896         AC_MSG_RESULT(no)
897         eval have_python_$1=false
898     fi
899   ])
900 PCP_CHECK_PYTHON_MODULE(jsonpointer)
901 AC_SUBST(have_python_jsonpointer)
902 PCP_CHECK_PYTHON_MODULE(setuptools)
903 AC_SUBST(have_python_setuptools)
904 PCP_CHECK_PYTHON_MODULE(requests)
905 AC_SUBST(have_python_requests)
906 PCP_CHECK_PYTHON_MODULE(six)
907 AC_SUBST(have_python_six)
909 AC_MSG_CHECKING([if the json PMDA should be included])
910 pmda_json=false
911 AS_IF([test "x$do_pmdajson" = "xyes"], [pmda_json=true])
912 AS_IF([test "x$do_pmdajson" = "xcheck"], [
913     dnl JSON PMDA needs both the six and jsonpointer Python modules
914     $have_python_jsonpointer && $have_python_six && pmda_json=true
916 AC_SUBST(PMDA_JSON, $pmda_json)
917 if $pmda_json; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
919 PCP_CHECK_PYTHON_MODULE(libvirt)
920 AC_SUBST(have_python_libvirt)
922 dnl check if perl available for the build and runtime
923 AC_CHECK_PROGS(PERL, perl)
924 AC_SUBST(PERL)
926 AC_MSG_CHECKING([for any perl version])
927 if test "$cross_compiling" = "yes"; then
928     ans=$have_perl
929     echo "cross-compile -> \"$ans\"" >&5
930 elif test -n "$PERL"
931 then
932     pcp_perl_prog=$PERL
933     have_perl=true
934 else
935     pcp_perl_prog=""
936     have_perl=false
938 AC_SUBST(pcp_perl_prog)
939 AC_SUBST(have_perl)
940 AC_MSG_RESULT($pcp_perl_prog)
942 AC_MSG_CHECKING([if the SNMP PMDA should be included])
943 pmda_snmp=false
944 AS_IF([test "x$do_pmdasnmp" = "xyes"], [pmda_snmp=true])
945 AS_IF([test "x$do_pmdasnmp" = "xcheck"], [
946     dnl SNMP PMDA needs perl and the Net::SNMP module
947     if test "$have_perl" = true
948     then
949         if $pcp_perl_prog -e "use Net::SNMP" >/dev/null 2>&1
950         then
951             pmda_snmp=true
952         fi
953     fi
955 AC_SUBST(PMDA_SNMP, $pmda_snmp)
956 if $pmda_snmp; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
958 AC_MSG_CHECKING([if the mysql PMDA should be included])
959 pmda_mysql=false
960 if test "$have_perl" = true
961 then
962     dnl rpm build for mysql PMDA needs Perl DBI and DBD::mysql
963     if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
964     then
965         if $pcp_perl_prog -e "use DBD::mysql" >/dev/null 2>&1
966         then
967             pmda_mysql=true
968         fi
969     fi
971 AC_SUBST(PMDA_MYSQL, $pmda_mysql)
972 if $pmda_mysql; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
974 AC_MSG_CHECKING([if the postgresql PMDA should be included])
975 pmda_postgresql=false
976 if test "$have_perl" = true
977 then
978     dnl rpm build for postgresql PMDA needs Perl DBI and DBD::Pg
979     if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
980     then
981         if $pcp_perl_prog -e "use DBD::Pg" >/dev/null 2>&1
982         then
983             pmda_postgresql=true
984         fi
985     fi
987 AC_SUBST(PMDA_POSTGRESQL, $pmda_postgresql)
988 if $pmda_postgresql; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
990 AC_MSG_CHECKING([if the oracle PMDA should be included])
991 pmda_oracle=false
992 if test "$have_perl" = true
993 then
994     dnl rpm build for oracle PMDA needs Perl DBI
995     if $pcp_perl_prog -e "use DBI" >/dev/null 2>&1
996     then
997         pmda_oracle=true
998     fi
1000 AC_SUBST(PMDA_ORACLE, $pmda_oracle)
1001 if $pmda_oracle; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1003 AC_MSG_CHECKING([if the elasticsearch PMDA should be included])
1004 pmda_elasticsearch=false
1005 if test "$have_perl" = true
1006 then
1007     dnl rpm build for elasticsearch PMDA needs Perl LWP::UserAgent
1008     if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1009     then
1010         pmda_elasticsearch=true
1011     fi
1013 AC_SUBST(PMDA_ELASTICSEARCH, $pmda_elasticsearch)
1014 if $pmda_elasticsearch; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1016 AC_MSG_CHECKING([if the nginx PMDA should be included])
1017 pmda_nginx=false
1018 if test "$have_perl" = true
1019 then
1020     dnl rpm build for nginx PMDA needs Perl LWP::UserAgent
1021     if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1022     then
1023         pmda_nginx=true
1024     fi
1026 AC_SUBST(PMDA_NGINX, $pmda_nginx)
1027 if $pmda_nginx; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1029 AC_MSG_CHECKING([if the activemq PMDA should be included])
1030 pmda_activemq=false
1031 if test "$have_perl" = true
1032 then
1033     dnl rpm build for activemq PMDA needs Perl LWP::UserAgent
1034     if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1035     then
1036         pmda_activemq=true
1037     fi
1039 AC_SUBST(PMDA_ACTIVEMQ, $pmda_activemq)
1040 if $pmda_activemq; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1042 AC_MSG_CHECKING([if the bind2 PMDA should be included])
1043 pmda_bind2=false
1044 if test "$have_perl" = true
1045 then
1046     dnl rpm build for bind2 PMDA needs Perl LWP::UserAgent, XML::LibXML
1047     if $pcp_perl_prog -e "use LWP::UserAgent" >/dev/null 2>&1
1048     then
1049         if $pcp_perl_prog -e "use XML::LibXML" >/dev/null 2>&1
1050         then
1051             if $pcp_perl_prog -e "use File::Slurp" >/dev/null 2>&1
1052             then
1053                 pmda_bind2=true
1054             fi
1055         fi
1056     fi
1058 AC_SUBST(PMDA_BIND2, $pmda_bind2)
1059 if $pmda_bind2; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1061 AC_MSG_CHECKING([if the nutcracker PMDA should be included])
1062 pmda_nutcracker=false
1063 if test "$have_perl" = true
1064 then
1065     dnl rpm build for nutcracker PMDA needs Perl JSON YAML::XS
1066     if $pcp_perl_prog -e "use YAML::XS" >/dev/null 2>&1
1067     then
1068         if $pcp_perl_prog -e "use JSON" >/dev/null 2>&1
1069         then
1070             pmda_nutcracker=true
1071         fi
1072     fi
1074 AC_SUBST(PMDA_NUTCRACKER, $pmda_nutcracker)
1075 if $pmda_nutcracker; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1077 AC_MSG_CHECKING([if the libvirt PMDA should be included])
1078 pmda_libvirt=false
1079 if test "$have_python" = true
1080 then
1081     dnl rpm build for libvirt PMDA needs Python libvirt and lxml modules
1082     if $pcp_python_prog -c "import libvirt" >/dev/null 2>&1
1083     then
1084         if $pcp_python_prog -c "import lxml" >/dev/null 2>&1
1085         then
1086             pmda_libvirt=true
1087         fi
1088     fi
1090 AC_SUBST(PMDA_LIBVIRT, $pmda_libvirt)
1091 if $pmda_libvirt; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1093 qmake=$QMAKE
1094 enable_qt=false
1095 qt_release=release
1096 AS_IF([test "x$do_qt" != "xno"], [
1097     enable_qt=true
1098     
1099     if test -z "$QMAKE"
1100     then
1101         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])
1102         test "x$cc_is_gcc" = xyes -a $target_os = solaris && QMAKE="$QMAKE -spec solaris-g++"
1103     fi
1104     qmake=$QMAKE
1105     if test -z "$QMAKE"
1106     then
1107         enable_qt=false
1108     else
1109         AC_MSG_CHECKING([Qt version])
1110         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 }'`
1111         AC_MSG_RESULT([$QT_MAJOR.$QT_MINOR.$QT_POINT])
1112         if test "$QT_MAJOR" -lt 4; then
1113             echo WARNING: Qt version 4.4 or later does not seem to be installed.
1114             echo Cannot proceed with the Qt $QT_MAJOR installation found.
1115             enable_qt=false
1116         fi
1117         if test "$QT_MAJOR" -eq 4 -a "$QT_MINOR" -lt 4 ; then
1118             echo WARNING: Qt version 4.$QT_MINOR is too old.
1119             echo Qt version 4.4 or later is required for Qt builds.
1120             enable_qt=false
1121         fi
1122     fi
1124     if test "$do_qt" != "check" -a "$enable_qt" != "true"
1125     then
1126         AC_MSG_ERROR([cannot enable Qt - no supported Qt installation found])
1127     elif test "$enable_qt" = "true" -a "x$cxx" = "x"
1128     then
1129         enable_qt=false
1130         test "$do_qt" != "check" && \
1131         AC_MSG_ERROR([C++ compiler unavailable, cannot build Qt components])
1132     elif test "$do_qt" = "debug"
1133     then
1134         dnl Debug/release style build? (non-debug by default)
1135         qt_release=debug
1136         enable_qt=true
1137     fi
1139 AC_SUBST(qt_release)
1140 AC_SUBST(enable_qt)
1141 AC_SUBST(qmake)
1143 enable_qt3d=false
1144 AS_IF([test "x$do_qt3d" != "xno"], [
1145     if test -f /usr/include/Coin3/Inventor/Qt/SoQt.h
1146     then
1147         enable_qt3d=$enable_qt
1148     elif test -a "$do_qt3d" = "yes"
1149     then
1150         AC_MSG_ERROR([cannot enable support for 3D scene graph API])
1151     fi
1153 AC_SUBST(enable_qt3d)
1155 dnl check if user wants their own make program
1156 dnl note: all makefiles in this package use the gmake syntax
1157 if test -z "$MAKE"
1158 then
1159     AC_PATH_PROG(MAKE, gmake)
1160     if test -z "$MAKE" 
1161     then
1162         # look elsewhere ...
1163         AC_MSG_CHECKING([for GNU make elsewhere])
1164         for f in /usr/local/bin/gmake /usr/freeware/bin/gmake /usr/local/bin/make /opt/sfw/bin/gmake nowhere
1165         do
1166             if test -x $f
1167             then
1168                 MAKE=$f
1169                 break
1170             fi
1171         done
1172         if test $f = nowhere
1173         then
1174             # Check if /usr/bin/make is any good
1175             mver=`/usr/bin/make --version 2>/dev/null | sed -n -e1p | cut -c1-8`
1176             if test "$mver" != "GNU Make"
1177             then
1178                 echo
1179                 echo "FATAL ERROR: could not find GNU make anywhere"
1180                 echo "You need to set \$MAKE as the full path to GNU make "
1181                 echo "in the environment."
1182                 rm -rf conftest conftest.*
1183                 exit 1
1184             else
1185                 MAKE=/usr/bin/make
1186             fi
1187         fi
1188         AC_MSG_RESULT($MAKE)
1189     fi 
1191 make=$MAKE
1192 AC_SUBST(make)
1194 dnl check if users wants their own CPP
1195 if test -z "$CPP"; then
1196     AC_PROG_CPP
1198 cpp=$CPP
1199 AC_SUBST(cpp)
1201 dnl check if users wants their own linker
1202 if test -z "$LD"; then
1203     AC_PATH_PROG(LD, ld, /usr/bin/ld)
1205 ld=$LD
1206 AC_SUBST(ld)
1208 dnl Provide ways to override owner and group for installed files
1209 if test -z "$PCP_USER_INSTALL" ; then
1210     pcp_user_install=root
1211 else
1212     pcp_user_install="$PCP_USER_INSTALL"
1214 AC_SUBST(pcp_user_install)
1215 if test -z "$PCP_GROUP_INSTALL" ; then
1216     case "$target_os"
1217     in
1218         darwin|freebsd|netbsd|openbsd)
1219             pcp_group_install=wheel
1220             ;;
1221         *)
1222             pcp_group_install=root
1223             ;;
1224     esac
1225 else
1226     pcp_group_install="$PCP_GROUP_INSTALL"
1228 AC_SUBST(pcp_group_install)
1230 dnl check if the tar program is available
1231 if test -z "$TAR"; then
1232     AC_PATH_PROGS(TAR, gtar tar, tar)
1234 if test $target_os = darwin -a -x /usr/bin/gnutar
1235 then
1236     TAR=/usr/bin/gnutar
1238 tar=$TAR
1239 AC_SUBST(tar)
1241 dnl check if the gzip program is available
1242 dnl (needed to gzip man pages on some platforms)
1243 if test -z "$ZIP"; then
1244     AC_PATH_PROG(ZIP, gzip, /bin/gzip)
1246 test ! -x "$ZIP" && ZIP=/usr/local/bin/gzip
1247 test ! -x "$ZIP" && ZIP=/usr/freeware/bin/gzip
1248 test ! -x "$ZIP" && ZIP=/usr/bin/gzip
1249 gzip=$ZIP
1250 test -z "$gzip" && gzip=no-gzip
1251 AC_SUBST(gzip)
1253 dnl check if the bzip2 program is available
1254 dnl (needed to bzip2 man pages on some platforms)
1255 if test -z "$BZIP2"; then
1256     AC_PATH_PROG(BZIP2, bzip2, /bin/bzip2)
1258 test ! -x "$BZIP2" && BZIP2=/usr/bin/bzip2
1259 test ! -x "$BZIP2" && BZIP2=/usr/local/bin/bzip2
1260 test ! -x "$BZIP2" && BZIP2=/usr/freeware/bin/bzip2
1261 bzip2=$BZIP2
1262 test -z "$bzip2" && bzip2=no-bzip2
1263 AC_SUBST(bzip2)
1265 dnl check if the lzma program is available
1266 dnl (needed to lzma man pages on some platforms)
1267 if test -z "$LZMA"; then
1268     AC_PATH_PROG(LZMA, lzma, /bin/lzma)
1270 test ! -x "$LZMA" && LZMA=/usr/bin/lzma
1271 test ! -x "$LZMA" && LZMA=/usr/local/bin/lzma
1272 test ! -x "$LZMA" && LZMA=/usr/freeware/bin/lzma
1273 lzma=$LZMA
1274 test -z "$lzma" && lzma=no-lzma
1275 AC_SUBST(lzma)
1277 dnl check if the xz program is available
1278 dnl (needed to xz man pages on some platforms)
1279 if test -z "$XZ"; then
1280     AC_PATH_PROG(XZ, xz, /bin/xz)
1282 test ! -x "$XZ" && XZ=/usr/bin/xz
1283 test ! -x "$XZ" && XZ=/usr/local/bin/xz
1284 test ! -x "$XZ" && XZ=/usr/freeware/bin/xz
1285 xz=$XZ
1286 test -z "$xz" && xz=no-xz
1287 AC_SUBST(xz)
1289 dnl Check for mac PackageMaker
1290 AC_MSG_CHECKING([for PackageMaker])
1291 if test -z "$PACKAGE_MAKER"
1292 then
1293     if test $target_os = darwin
1294     then
1295         if test -x /Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1296         then # local XCode extras install
1297             package_maker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1298             AC_MSG_RESULT([ yes (local install)])
1299         elif test -x /Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1300         then # Darwin 6.x
1301             package_maker=/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1302             AC_MSG_RESULT([ yes (darwin 6.x)])
1303         elif test -x /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
1304         then # Darwin 7.x
1305             AC_MSG_RESULT([ yes (darwin 7.x)])
1306             package_maker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
1307         else
1308             AC_MSG_RESULT([ not found!])
1309             AC_MSG_WARN([PackageMaker not found, mac packages will not be made])
1310         fi
1311     else
1312         AC_MSG_RESULT([ no])    
1313     fi
1314 else
1315     package_maker="$PACKAGE_MAKER"
1317 AC_SUBST(package_maker)
1319 dnl check if the hdiutil program is available
1320 if test -z "$HDIUTIL"; then
1321     AC_PATH_PROG(HDIUTIL, hdiutil)
1323 hdiutil=$HDIUTIL
1324 AC_SUBST(hdiutil)
1326 dnl check if the mkinstallp program is available (AIX)
1327 if test -z "$MKINSTALLP"; then
1328     AC_PATH_PROG(MKINSTALLP, mkinstallp)
1330 mkinstallp=$MKINSTALLP
1331 AC_SUBST(mkinstallp)
1333 dnl check for the Solaris pmgmk package maker
1334 if test -z "$PKGMK"; then
1335     AC_PATH_PROG(PKGMK, pkgmk)
1337 pkgmk=$PKGMK
1338 AC_SUBST(pkgmk)
1340 dnl check if the dlltool program is available
1341 if test -z "$DLLTOOL"; then
1342     AC_PATH_PROG(DLLTOOL, dlltool)
1344 dlltool=$DLLTOOL
1345 AC_SUBST(dlltool)
1347 dnl check if the rpmbuild program is available
1348 if test -z "$RPMBUILD"; then
1349     AC_PATH_PROG(RPMBUILD, rpmbuild)
1351 test $target_distro = slackware && RPMBUILD=''
1352 rpmbuild=$RPMBUILD
1353 AC_SUBST(rpmbuild)
1355 dnl check if the rpm program is available
1356 if test -z "$RPM"; then
1357     AC_PATH_PROG(RPM, rpm)
1359 test $target_distro = slackware && RPM=''
1360 rpm=$RPM
1361 AC_SUBST(rpm)
1363 dnl if rpmbuild exists, use it, otherwise use rpm
1364 if test -n "$RPMBUILD" -a -x "$RPMBUILD"
1365 then
1366     rpmprog=$RPMBUILD
1367 else
1368     rpmprog=$RPM
1370 AC_SUBST(rpmprog)
1372 dnl check if the pod2man program is available (perl man page builder)
1373 if test -z "$POD2MAN"; then
1374     AC_PATH_PROG(POD2MAN, pod2man)
1376 pod2man=$POD2MAN
1377 AC_SUBST(pod2man)
1379 dnl extra check for the Perl MakeMaker package
1380 AC_MSG_CHECKING([if ExtUtils::MakeMaker is installed])
1381 perl -e "use ExtUtils::MakeMaker" 2>/dev/null
1382 if test $? -eq 0
1383 then
1384     AC_MSG_RESULT([ yes])
1385 else
1386     AC_MSG_RESULT([ no])
1387     echo
1388     echo "FATAL ERROR: Perl ExtUtils::MakeMaker module missing."
1389     echo "You can either install this from your distribution, or"
1390     echo "download from CPAN (Comprehensive Perl Archive Network)."
1391     rm -rf conftest conftest.*
1392     exit 1
1395 AC_PATH_PROG(TRUEPROG, true)
1397 dnl check if the makedepend program is available
1398 if test -z "$MAKEDEPEND"; then
1399     AC_PATH_PROG(MAKEDEPEND, makedepend, $TRUEPROG)
1401 makedepend=$MAKEDEPEND
1402 AC_SUBST(makedepend)
1404 dnl check if the md5sum program is available
1405 if test -z "$MD5SUM"; then
1406    AC_PATH_PROG(MD5SUM, md5sum, $TRUEPROG)
1408 md5sum=$MD5SUM
1409 AC_SUBST(md5sum)
1411 dnl check if the Debian dpkg program is available
1412 if test -z "$DPKG"; then
1413    AC_PATH_PROG(DPKG, dpkg)
1415 dpkg=$DKPG
1416 AC_SUBST(dpkg)
1418 dnl check for the Slackware makepkg packaging tool
1419 if test -z "$MAKEPKG"; then
1420    AC_PATH_PROG(MAKEPKG, makepkg)
1422 makepkg=$MAKEPKG
1423 AC_SUBST(makepkg)
1425 dnl check if a toolchain is available for the books
1426 test -z "$PUBLICAN" && AC_PATH_PROG(PUBLICAN, publican)
1427 publican=$PUBLICAN
1428 AC_SUBST(publican)
1429 test -z "$DBLATEX" && AC_PATH_PROG(DBLATEX, dblatex)
1430 dblatex=$DBLATEX
1431 AC_SUBST(dblatex)
1432 test -z "$XMLTO" && AC_PATH_PROG(XMLTO, xmlto)
1433 xmlto=$XMLTO
1434 AC_SUBST(xmlto)
1436 book_toolchain=""
1437 if test "$do_books" = "check" -o "$do_books" = "yes"
1438 then
1439     if test "$BOOK_TOOLCHAIN" != ""
1440     then
1441         book_toolchain=$BOOK_TOOLCHAIN
1442     elif test "$DBLATEX" != ""
1443     then
1444         book_toolchain=dblatex
1445     elif test "$PUBLICAN" != ""
1446     then
1447         book_toolchain=publican
1448     elif test "$XMLTO" != ""
1449     then
1450         book_toolchain=xmlto
1451     elif test "$do_books" = "yes"
1452     then
1453         AC_MSG_ERROR([cannot enable books build - no toolchain found])
1454     fi
1456 AC_SUBST(book_toolchain)
1458 book_brand="common"
1459 if test "$do_books_brand" != ""
1460 then
1461     book_brand=$do_books_brand
1463 AC_SUBST(book_brand)
1465 dnl check if symbolic links are supported
1466 AC_PROG_LN_S
1467 if test $target_os = mingw; then
1468     as_ln_s=/bin/true
1471 dnl if /proc is not mounted, try and mount it
1472 dnl before trying to run the ps style test below
1473 if test -d /proc
1474 then
1475     test -f /proc/stat || mount /proc >/dev/null 2>&1
1478 dnl set platform specific ps
1479 if test -n "$PROCPS"
1480 then
1481     pcp_ps_prog="$PROCPS"
1482 else
1483     pcp_ps_prog=ps
1485 AC_SUBST(pcp_ps_prog)
1487 dnl set platform specific event logger
1488 if test $target_os = mingw
1489 then
1490     pcp_syslog_prog=pcp-eventlog
1491 else
1492     pcp_syslog_prog=logger
1494 AC_SUBST(pcp_syslog_prog)
1496 grep=grep
1497 if test $target_os = solaris
1498 then
1499     test -f /usr/xpg4/bin/grep && grep=/usr/xpg4/bin/grep
1501 AC_SUBST(grep)
1503 dnl checks for /proc pseudo file system
1504 AC_MSG_CHECKING([for /proc ])
1505 if test "$cross_compiling" = "yes"; then
1506     ans=$have_procfs
1507     echo "cross-compile -> \"$ans\"" >&5
1508 elif test -d /proc
1509 then
1510     have_procfs=true
1511 else
1512     have_procfs=false
1514 if $have_procfs
1515 then
1516     AC_MSG_RESULT(yes)
1517     AC_DEFINE(HAVE_PROCFS, [1], [Support for /proc pseudo-filesystem])
1518 else
1519     AC_MSG_RESULT(no)
1522 dnl Checks for C header files.
1523 AC_HEADER_DIRENT
1524 AC_HEADER_STDC
1525 AC_HEADER_SYS_WAIT
1526 AC_CHECK_HEADERS(fcntl.h limits.h malloc.h strings.h syslog.h)
1527 AC_CHECK_HEADERS(stddef.h sched.h dlfcn.h dl.h)
1528 AC_CHECK_HEADERS(sys/times.h sys/resource.h sys/prctl.h)
1529 AC_CHECK_HEADERS(sys/sysinfo.h sys/systeminfo.h)
1530 AC_CHECK_HEADERS(endian.h standards.h sys/byteorder.h)
1531 AC_CHECK_HEADERS(libgen.h sys/mman.h sys/un.h)
1532 AC_CHECK_HEADERS(values.h stdint.h ieeefp.h math.h)
1533 AC_CHECK_HEADERS(pwd.h grp.h regex.h sys/wait.h)
1534 AC_CHECK_HEADERS(termio.h termios.h sys/termios.h)
1535 AC_CHECK_HEADERS(sys/ioctl.h sys/select.h sys/socket.h)
1536 AC_CHECK_HEADERS(netdb.h)
1537 if test $target_os = darwin -o $target_os = openbsd
1538 then
1539     AC_CHECK_HEADERS(net/if.h, [], [], [#include <sys/types.h>
1540 #include <sys/socket.h>])
1541 else
1542     AC_CHECK_HEADERS(net/if.h)
1544 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h arpa/inet.h)
1545 AC_CHECK_HEADERS(windows.h winsock2.h ws2tcpip.h)
1546 AC_CHECK_HEADERS(execinfo.h bits/wordsize.h)
1547 AC_CHECK_HEADERS(iptypes.h, [], [], [#include <windows.h>])
1548 AC_CHECK_HEADERS(iphlpapi.h, [], [], [#include <winsock2.h>])
1549 AC_CHECK_HEADERS(fts.h libzfs.h)
1550 AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/mount.h)
1552 dnl Check if we have <sys/endian.h> ... standard way
1553 AC_MSG_CHECKING([for sys/endian.h ])
1554 AC_TRY_COMPILE(
1555 [  
1556     #include <sys/endian.h> 
1559 ], AC_DEFINE(HAVE_SYS_ENDIAN_H, [1], [sys/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1561 dnl Check if we have <machine/endian.h> ... MacOSX way
1562 AC_MSG_CHECKING([for machine/endian.h ])
1563 AC_TRY_COMPILE(
1564 [  
1565     #include <machine/endian.h> 
1568 ], AC_DEFINE(HAVE_MACHINE_ENDIAN_H, [1], [machine/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1570 dnl Check if we have <sys/endian.h> ... IRIX strangeness
1571 AC_MSG_CHECKING([for sys/endian.h (IRIX variant) ])
1572 AC_TRY_COMPILE(
1573 [  
1574     #include <standards.h>
1575     #include <sys/endian.h> 
1578 ], AC_DEFINE(HAVE_SYS_ENDIAN_H, [1], [IRIX sys/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1580 dnl Checks for typedefs, structures, and compiler characteristics.
1581 AC_C_CONST
1582 AC_TYPE_OFF_T
1583 AC_TYPE_PID_T
1584 AC_TYPE_SIZE_T
1585 AC_HEADER_TIME
1586 AC_STRUCT_TM
1587 AC_C_INLINE
1589 dnl check if regex functions come from libregex (mingw)
1590 AC_CHECK_LIB(regex, regcomp)
1591 lib_for_regex=""
1592 if test $ac_cv_lib_regex_regcomp = yes
1593 then
1594     lib_for_regex="-lregex"
1596 AC_SUBST(lib_for_regex)
1598 PKG_CHECK_MODULES([ncurses], [ncurses], [have_ncurses=true], [have_ncurses=false])
1599 AC_SUBST(HAVE_NCURSES, [$have_ncurses])
1601 PKG_CHECK_MODULES([SYSTEMD], [libsystemd],
1602                   [pmda_systemd=true], [pmda_systemd=false])
1603 if $pmda_systemd
1604 then
1605     :
1606 else
1607     dnl libsystemd-journal is an alternative for older distros
1608     PKG_CHECK_MODULES([SYSTEMD], [libsystemd-journal],
1609                       [pmda_systemd=true], [pmda_systemd=false])
1611 AC_MSG_CHECKING([if the systemd PMDA should be included])
1612 AC_SUBST(PMDA_SYSTEMD, $pmda_systemd)
1613 if $pmda_systemd; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1615 pmda_infiniband=false
1616 AS_IF([test "x$do_infiniband" != "xno"], [
1617     AC_CHECK_HEADERS([infiniband/umad.h], [
1618         AC_CHECK_HEADERS([infiniband/mad.h], [pmda_infiniband=true], [])
1619     ], [])
1620     savedLIBS=$LIBS
1621     IB_LIBS=""
1622     AC_CHECK_LIB(ibmad, madrpc_init)
1623     AC_CHECK_LIB(ibumad, umad_init)
1624     if test $ac_cv_lib_ibmad_madrpc_init = yes -a $ac_cv_lib_ibumad_umad_init = yes
1625     then
1626         IB_LIBS="-libmad -libumad"
1627         LIBS="$IB_LIBS"
1628         AC_MSG_CHECKING([for port_performance_query_via])
1629         AC_TRY_LINK_FUNC(port_performance_query_via,
1630                 AC_DEFINE(HAVE_PORT_PERFORMANCE_QUERY_VIA, [1], [port_performance_query_via API])
1631                 have_port_performance_query_via=true
1632                 AC_MSG_RESULT(yes),
1633                 have_port_performance_query_via=false
1634                 AC_MSG_RESULT(no))
1635         AC_MSG_CHECKING([for pma_query_via])
1636         AC_TRY_LINK_FUNC(pma_query_via,
1637                 AC_DEFINE(HAVE_PMA_QUERY_VIA, [1], [pma_query_via API])
1638                 have_pma_query_via=true
1639                 AC_MSG_RESULT(yes),
1640                 have_pma_query_via=false
1641                 AC_MSG_RESULT(no))
1642         LIBS=$savedLIBS
1643         if test $have_pma_query_via -o $have_port_performance_query_via
1644         then
1645             :
1646         else
1647             pmda_infiniband=false
1648         fi
1649     else
1650         pmda_infiniband=false
1651     fi
1652     LIBS=$savedLIBS
1653     AC_SUBST(IB_LIBS)
1655 AC_MSG_CHECKING([if the infiniband PMDA should be included])
1656 AC_SUBST(PMDA_INFINIBAND, $pmda_infiniband)
1657 if $pmda_infiniband; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1659 pmda_papi=false
1660 AS_IF([test "x$do_papi" != "xno"], [
1661     enable_papi=true
1663     saved_LDFLAGS="$LDFLAGS"
1664     saved_CFLAGS="$CFLAGS"
1665     savedLIBS=$LIBS
1667     dnl potentially from the environment, else empty
1668     CFLAGS="$papi_CFLAGS"
1669     LDFLAGS="$papi_LIBS"
1671     case "$do_papi" in
1672         yes|no|check)
1673             ;;
1674         */*)
1675             PAPI_ROOTDIR=$do_papi;
1676             CFLAGS="-I$PAPI_ROOTDIR/include"
1677             LDFLAGS="-L$PAPI_ROOTDIR/lib"
1678             ;;
1679          *)
1680             PKG_CHECK_MODULES(papi,[$do_papi],[
1681                   CFLAGS="$papi_CFLAGS"
1682                   LDFLAGS="$papi_LIBS"])
1683             ;;
1684     esac
1686     # $papi_LIBS may include -lpapi harmlessly redudantly with AC_CHECK_LIB
1687     AC_CHECK_LIB([papi], [PAPI_library_init],
1688                  [papi_libs="$LDFLAGS -lpapi"],
1689                  [enable_papi=false])
1690     AC_CHECK_HEADERS([papi.h], [papi_cflags="$CFLAGS"], [enable_papi=false])
1691     if test "$do_papi" != "check" -a "$enable_papi" != "true"
1692     then
1693         AC_MSG_ERROR([PAPI is not installed, cannot enable the PAPI PMDA])
1694     else
1695         pmda_papi=$enable_papi
1696     fi
1697     LIBS=$savedLIBS
1698     CFLAGS="$saved_CFLAGS"
1699     LDFLAGS="$saved_LDFLAGS"
1700     AC_SUBST(PAPI_CFLAGS, $papi_cflags)
1701     AC_SUBST(PAPI_LIBS, $papi_libs)
1703 AC_MSG_CHECKING([if the papi PMDA should be included])
1704 AC_SUBST(PMDA_PAPI, $pmda_papi)
1705 if $pmda_papi; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1707 AS_IF([test "x$pmda_papi" = "xtrue"], [
1708         dnl check if struct PAPI_component_info_t has a disabled field
1709         AC_MSG_CHECKING([whether struct PAPI_component_info_t has a disabled field])
1710 cat <<End-of-File >conftest.c
1711 #include <papi.h>
1712 int main() { PAPI_component_info_t *c; c->disabled = 0; }
1713 End-of-File
1714         (eval $ac_compile) 2>conftest.out
1715         cat conftest.out >&5
1716         if test -s conftest.out
1717         then
1718            AC_MSG_RESULT(no)
1719         else
1720            AC_DEFINE(HAVE_PAPI_DISABLED_COMP, [1], [PAPI_component_info_t field])
1721            AC_MSG_RESULT(yes)
1723         fi
1724         rm -f conftest.*
1727 pmda_perfevent=false
1728 AS_IF([test "x$do_perfevent" != "xno" ], [
1729     enable_perfevent=true
1731     savedLIBS=$LIBS
1732     AC_CHECK_LIB([pfm], [pfm_get_os_event_encoding],
1733                  [pfm_libs="-lpfm"],
1734                  [enable_perfevent=false])
1735     AC_CHECK_HEADERS([perfmon/pfmlib_perf_event.h], [], [enable_perfevent=false])
1736     if test "$do_perfevent" != "check" -a "$enable_perfevent" != "true"
1737     then
1738         AC_MSG_ERROR([libpfm is not installed, cannot enable the perfevent PMDA])
1739     else
1740         pmda_perfevent=$enable_perfevent
1741     fi
1742     LIBS=$savedLIBS
1743     AC_SUBST(PFM_LIBS, $pfm_libs)
1745 AC_MSG_CHECKING([if the perfevent PMDA should be included])
1746 AC_SUBST(PMDA_PERFEVENT, $pmda_perfevent)
1747 if $pmda_perfevent; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1749 dnl Do you have RPM Package Manager libraries for pmdarpm?
1750 pmda_rpm=false
1751 savedLIBS=$LIBS
1752 AC_MSG_CHECKING([for rpmlib > 4.4.2])
1753 AC_COMPILE_IFELSE(
1754    [AC_LANG_PROGRAM([[#include <rpm/header.h>]],
1755                     [[(void)HEADERGET_EXT;]])],
1756    [AC_MSG_RESULT([yes])
1757     pmda_rpm=true],
1758    [AC_MSG_RESULT([no])])
1759 AC_MSG_CHECKING([if the rpm PMDA should be included])
1760 AC_SUBST(PMDA_RPM,$pmda_rpm)
1761 if $pmda_rpm; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1762 LIBS=$savedLIBS
1764 dnl Do you have the required qshape script for the postfix PMDA
1765 dnl The logic here is copied from the PMDA's Install script
1766 pmda_postfix=false
1767 AC_CHECK_PROGS(QSHAPE, qshape, [], path=[$PATH:/usr/sbin])
1768 AC_MSG_CHECKING([if the postfix PMDA should be included])
1769 if test -n "$QSHAPE"
1770 then
1771     pmda_postfix=true
1772 else
1773     for script in /usr/share/doc/packages/postfix-doc/auxiliary/qshape/qshape.pl
1774     do
1775         if test -f "$script"
1776         then
1777             pmda_postfix=true
1778             break
1779         fi
1780     done
1782 AC_SUBST(PMDA_POSTFIX,$pmda_postfix)
1783 if $pmda_postfix; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1785 dnl Do you have system microhttpd libraries for pmwebapi?
1786 PKG_CHECK_MODULES([libmicrohttpd], [libmicrohttpd > 0.9.9], [have_libmicrohttpd=true], [have_libmicrohttpd=false])
1787 AC_SUBST(HAVE_LIBMICROHTTPD, [$have_libmicrohttpd])
1789 dnl Do you have graphics libraries for pmwebapi?
1790 PKG_CHECK_MODULES([cairo], [cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2], [have_cairo=true], [have_cairo=false])
1791 AC_SUBST(HAVE_CAIRO, [$have_cairo])
1793 enable_webapi=false
1794 AS_IF([test "x$do_webapi" != "xno"], [
1795     enable_webapi=true
1797     if test "$have_libmicrohttpd" != "true"
1798     then
1799         enable_webapi=false
1800         test "$do_webapi" != "check" && \
1801         AC_MSG_ERROR([libmicrohttpd is not installed, cannot enable the web API])
1802     elif test "$do_webapi" != "check" -a "x$cxx" = "x"
1803     then
1804         enable_webapi=false
1805         test "$do_webapi" != "check" && \
1806         AC_MSG_ERROR([C++ compiler unavailable, cannot enable the web API])
1807     fi
1809 AC_SUBST(enable_webapi)
1811 enable_manager=false
1812 AS_IF([test "x$do_manager" != "xno"], [
1813     enable_manager=true
1815     if test "$target_os" = "mingw"
1816     then
1817         enable_manager=false
1818         test "$do_manager" != "check" && \
1819         AC_MSG_ERROR([MinGW build, cannot enable daemon manager])
1820     elif test "x$cxx" = "x"
1821     then
1822         enable_manager=false
1823         test "$do_manager" != "check" && \
1824         AC_MSG_ERROR([C++ compiler unavailable, cannot enable daemon manager])
1825     fi
1826     AC_MSG_CHECKING([compilation features for daemon manager])
1827     AC_TRY_COMPILE(
1828         [ #ifndef _XOPEN_SOURCE
1829           #define _XOPEN_SOURCE 600
1830           #endif
1831           #include <stdio.h>
1832         ], [],
1833         AC_MSG_RESULT(yes),
1834         enable_manager=false
1835         AC_MSG_RESULT(no))
1837 AC_SUBST(enable_manager)
1839 enable_selinux=false
1840 AS_IF([test "x$do_selinux" != "xno"], [
1841     if test -f /usr/share/selinux/devel/Makefile
1842     then
1843         enable_selinux=true
1844     else
1845         AC_MSG_RESULT(no)
1846     fi
1848 AC_SUBST(enable_selinux)
1849 AC_SUBST(pcp_selinux_dir)
1852 dnl Checks for library functions.
1853 AC_TYPE_SIGNAL
1854 AC_FUNC_WAIT3
1855 AC_FUNC_VPRINTF
1856 AC_CHECK_FUNCS(mktime nanosleep usleep unsetenv)
1857 AC_CHECK_FUNCS(select socket gethostname getpeerucred getpeereid)
1858 AC_CHECK_FUNCS(uname syslog __clone pipe2 fcntl ioctl)
1859 AC_CHECK_FUNCS(prctl setlinebuf waitpid atexit kill)
1860 AC_CHECK_FUNCS(chown fchmod getcwd scandir mkstemp)
1861 AC_CHECK_FUNCS(brk sbrk posix_memalign memalign valloc)
1862 AC_CHECK_FUNCS(signal sighold sigrelse tcgetattr)
1863 AC_CHECK_FUNCS(regex regcmp regexec regcomp)
1864 AC_CHECK_FUNCS(strtod strtol strtoll strtoull strndup strchrnul)
1865 AC_CHECK_FUNCS(getuid getgid)
1866 AC_CHECK_FUNCS(getgrent getgrent_r getgrnam getgrnam_r getgrgid getgrgid_r)
1867 AC_CHECK_FUNCS(getpwent getpwent_r getpwnam getpwnam_r getpwuid getpwuid_r)
1868 AC_CHECK_FUNCS(sysinfo trace_back_stack backtrace)
1869 AC_CHECK_FUNCS(sendmsg recvmsg setns)
1871 dnl only define readdir64 on non-linux platforms that support it
1872 if test $target_os != linux -a $target_os != freebsd -a $target_os != kfreebsd -a $target_os != netbsd; then
1873     AC_CHECK_FUNCS(readdir64)
1876 dnl typedefs missing from sys/types.h, stdlib.h or stddef.h
1877 if test $target_os = solaris
1878 then
1879    AC_CHECK_TYPE(__int32_t, int32_t)
1880    AC_CHECK_TYPE(__uint32_t, uint32_t)
1881    AC_CHECK_TYPE(__int64_t, int64_t)
1882    AC_CHECK_TYPE(__uint64_t, uint64_t)
1883    AC_CHECK_TYPE(uint_t, u_int32_t)
1884 else
1885     AC_CHECK_TYPE(__int32_t, int)
1886     AC_CHECK_TYPE(__uint32_t, unsigned int)
1887     AC_CHECK_TYPE(__int64_t, long long)
1888     AC_CHECK_TYPE(__uint64_t, unsigned long long)
1889     AC_CHECK_TYPE(uint_t, unsigned int)
1892 dnl check if we have a type for the pointer's size integer (__psint_t)
1893 AC_MSG_CHECKING([for __psint_t ])
1894 AC_TRY_COMPILE(
1895 [  
1896     #include <sys/types.h>
1897     #include <stdlib.h> 
1898     #include <stddef.h>
1899 ], [ __psint_t psint; ],
1900 AC_DEFINE(HAVE___PSINT_T, [1], [__psint_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1902 dnl check if we have a type for pointer difference (ptrdiff_t)
1903 AC_MSG_CHECKING([for ptrdiff_t ])
1904 AC_TRY_COMPILE([
1905     #include <stddef.h>
1906     #ifdef HAVE_MALLOC_H
1907     #include <malloc.h>
1908     #endif
1909 ], [ ptrdiff_t ptrdiff; ],
1910 AC_DEFINE(HAVE_PTRDIFF_T, [1], [ptrdiff_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1912 dnl check if we have types for uid_t, gid_t (POSIX) or SID (Win32)
1913 AC_MSG_CHECKING([for uid_t ])
1914 AC_TRY_COMPILE([
1915     #include <sys/types.h>
1916     #ifdef HAVE_PWD_H
1917     #include <pwd.h>
1918     #endif
1919 ], [ uid_t uid; ],
1920 AC_DEFINE(HAVE_UID_T, [1], [uid_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1921 AC_MSG_CHECKING([for gid_t ])
1922 AC_TRY_COMPILE([
1923     #include <sys/types.h>
1924     #ifdef HAVE_GRP_H
1925     #include <grp.h>
1926     #endif
1927 ], [ gid_t gid; ],
1928 AC_DEFINE(HAVE_GID_T, [1], [gid_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1929 AC_MSG_CHECKING([for SID ])
1930 AC_TRY_COMPILE([
1931     #ifdef HAVE_WINDOWS_H
1932     #include <windows.h>
1933     #endif
1934 ], [ SID sid; ],
1935 AC_DEFINE(HAVE_SID, [1], [sid type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1937 dnl check if we have a type for socklen_t
1938 AC_MSG_CHECKING([for socklen_t ])
1939 AC_TRY_COMPILE([
1940     #include <sys/types.h>
1941     #ifdef HAVE_SYS_SOCKET_H
1942     #include <sys/socket.h>
1943     #endif
1944 ], [ socklen_t len; ],
1945 AC_DEFINE(HAVE_SOCKLEN_T, [1], [socklen_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1947 dnl check if LL suffix on constants is supported
1948 AC_TRY_COMPILE([
1949     #include <stdio.h>
1950 ], [ long long x = 0LL; ],
1951 AC_DEFINE(HAVE_CONST_LONGLONG, [1], [LL suffix on constants]))
1953 dnl check if _environ is declared globally
1954 AC_TRY_LINK([
1955     #include <stdlib.h>
1956     #include <unistd.h>
1957 ], [ char **x = _environ; ],
1958 AC_DEFINE(HAVE_UNDERBAR_ENVIRON, [1], [_environ declared globally]))
1960 dnl check for PR_TERMCHILD and PR_SET_PDEATHSIG in <sys/prctl.h>
1961 AC_MSG_CHECKING([for PR_TERMCHILD constant in sys/prctl.h])
1962 AC_TRY_COMPILE([
1963     #ifdef HAVE_SYS_PRCTL_H
1964     #include <sys/prctl.h>
1965     #endif
1966 ], [ int i = PR_TERMCHILD; ],
1967 AC_DEFINE(HAVE_PR_TERMCHILD, [1], [PR_TERMCHILD constant]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1969 AC_MSG_CHECKING([for PR_SET_PDEATHSIG constant in sys/prctl.h])
1970 AC_TRY_COMPILE([
1971     #ifdef HAVE_SYS_PRCTL_H
1972     #include <sys/prctl.h>
1973     #endif
1974 ], [ int i = PR_SET_PDEATHSIG; ],
1975 AC_DEFINE(HAVE_PR_SET_PDEATHSIG, [1], [PR_SET_PDEATHSIG constant]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1977 AC_HEADER_TIOCGWINSZ
1979 dnl check if linker needs -rdynamic for dynamically loaded shared
1980 dnl libraries to see the symbols in the process loading them.
1981 dnl This is e.g., needed on linux for pmcd loading pmda_pmcd.so.
1982 AC_MSG_CHECKING([if linker supports -rdynamic])
1983 save_CFLAGS="$CFLAGS"
1984 CFLAGS="-rdynamic"
1985 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1986     [AC_MSG_RESULT([yes])
1987      rdynamic_flag=-rdynamic],
1988     [AC_MSG_RESULT([no])
1989      rdynamic_flag=]
1991 CFLAGS="$save_CFLAGS"
1992 AC_SUBST([rdynamic_flag])
1995 dnl check if argument to user's select() method in scandir call is const
1996 AC_MSG_CHECKING([whether const arg for scandir() select method])
1997 cat <<End-of-File >conftest.c
1998 #include <stdlib.h>
1999 #include <unistd.h>
2000 #include <dirent.h>
2001 static int
2002 my_select(const struct dirent *foo) { return 0; }
2003 int main() { struct dirent **list; return scandir(".", &list, my_select, NULL); }
2004 End-of-File
2005 (eval $ac_compile) 2>conftest.out
2006 cat conftest.out >&5
2007 if test -s conftest.out
2008 then
2009     AC_MSG_RESULT(no)
2010 else
2011     AC_DEFINE(HAVE_CONST_DIRENT, [1], [const arg for scandir() select method])
2012     AC_MSG_RESULT(yes)
2014 rm -f conftest.*
2016 dnl check if struct dirent has a d_off (directory offset) field
2017 AC_MSG_CHECKING([whether struct dirent has a d_off field])
2018 cat <<End-of-File >conftest.c
2019 #include <stdlib.h>
2020 #include <unistd.h>
2021 #include <dirent.h>
2022 int main() { struct dirent d; d.d_off = 0; }
2023 End-of-File
2024 (eval $ac_compile) 2>conftest.out
2025 cat conftest.out >&5
2026 if test -s conftest.out
2027 then
2028     AC_MSG_RESULT(no)
2029 else
2030     AC_DEFINE(HAVE_DIRENT_D_OFF, [1], [struct dirent d_off field])
2031     AC_MSG_RESULT(yes)
2033 rm -f conftest.*
2035 dnl check if printf %p has 0x prefix
2036 AC_MSG_CHECKING([if printf %p produces 0x prefix])
2037 if test "$cross_compiling" = "yes"; then
2038     ans=$printf_p_prefix
2039     echo "cross-compile -> \"$ans\"" >&5
2040 else
2041     cat <<End-of-File >conftest.c
2042 #include <stdio.h>
2043 int main(int argc,  char **argv) { printf("%p", argv); return(0); }
2044 End-of-File
2045     (eval $ac_compile) 2>&5
2046     (eval $ac_link) 2>&5
2047     ans=`./conftest`
2048     echo "./conftest -> \"$ans\"" >&5
2050 case "$ans"
2052     0x*)
2053         AC_DEFINE(HAVE_PRINTF_P_PFX, [1], [printf %p produces 0x])
2054         AC_MSG_RESULT(yes)
2055         ;;
2056     *)
2057         AC_MSG_RESULT(no)
2058         ;;
2059 esac
2060 rm -rf conftest conftest.*
2062 _do_type()
2064     # need to deal with this sort of cpp output ...
2065     #   typedef long pid_t;
2066     #   typedef unsigned int pid_t;
2067     #   typedef unsigned int pid_t __attribute__ ((__mode__ (__SI__)));
2068     #   __extension__ typedef int pid_t;
2069     #   typedef foo_t
2070     #                  pid_t;
2071     #   typedef struct {
2072     #         ....
2073     #   } pid_t;
2074     #   typedef ... *pid;
2075     # and chaining of the form
2076     #   typedef long __pid_t;
2077     #   typedef __pid_t pid_t;
2078     #
2079     _raw=`$CPP conftest.c \
2080     | $SED \
2081         -e 's/[[        ]]__attribute__ ((.*));/;/' \
2082         -e 's/__extension__[[   ]][[    ]]*//' \
2083     | $AWK '
2084 /bozo/          { print; next }
2085 $1 == "typedef" { printf "%s",$0
2086                   if ($NF ~ /;$/) {
2087                       print ""
2088                       next
2089                   }
2090                   wantsemi = 1
2091                   if ($0 ~ /{/) depth = 1
2092                   next
2093                 }
2094 wantsemi == 1   { printf " %s",$0
2095                   if ($0 ~ /{/) depth++
2096                   if (depth) {
2097                       if ($0 ~ /}/) depth--
2098                       if (depth > 0) next
2099                   }
2100                   if ($NF ~ /;$/) {
2101                       print ""
2102                       wantsemi = 0
2103                       next
2104                   }
2105                 }' \
2106     | $SED \
2107         -e 's/\*/* /g' \
2108         -e 's/^[[       ]]*//' \
2109         -e 's/;[[       ]]*$//' \
2110     | $AWK '
2111 $1 == "typedef" { map[[$NF]] = ""
2112                   for (i = 2; i < NF; i++) {
2113                     if (i == 2)
2114                         map[[$NF]] = $i
2115                     else
2116                         map[[$NF]] = map[[$NF]] " " $i
2117                   }
2118                   print $NF " -> " map[[$NF]] >"conftest.debug"
2119                   next
2120                 }
2121 $2 == "bozo"    { t = $1
2122                   printf "best guess: %s",t >"conftest.debug"
2123                   while (map[[t]] != "") {
2124                     t = map[[t]]
2125                     printf " -> %s",t >"conftest.debug"
2126                   }
2127                   print "" >"conftest.debug"
2128                   print t
2129                   exit
2130                 }'`
2131     case "$_raw"
2132     in
2133     int)
2134         _fmt='"d"'
2135         ;;
2136     unsigned|'unsigned int')
2137         _fmt='"u"'
2138         ;;
2139     long|'long int')
2140         _fmt='"ld"'
2141         ;;
2142     'long long'|'long long int')
2143         if test $target_os = mingw; then
2144             _fmt='"I64d"'
2145         else
2146             _fmt='"lld"'
2147         fi
2148         ;;
2149     'unsigned long'|'unsigned long int'|'long unsigned int')
2150         _fmt='"lu"'
2151         ;;
2152     'unsigned long long'|'unsigned long long int')
2153         if test $target_os = mingw; then
2154             _fmt='"I64u"'
2155         else
2156             _fmt='"llu"'
2157         fi
2158         ;;
2159     *\*)        # pointer to a something
2160         _fmt='"p"'
2161         ;;
2162     struct\ *)  # not much can be done here ...
2163         _fmt='"p"'
2164         ;;
2165     *)
2166         echo
2167         echo "FATAL ERROR: don't know what to do with type \"$_raw\""
2168         echo "... typedef mapping ..."
2169         cat conftest.debug
2170         rm -rf conftest conftest.*
2171         exit 1
2172         ;;
2173     esac
2176 dnl printf type for pid_t
2177 AC_MSG_CHECKING([printf type for pid_t])
2178 if test "$cross_compiling" = "yes"; then
2179     ans=$printf_fmt_pid
2180     echo "cross-compile -> \"$ans\"" >&5
2181     fmt_pid="$ans"
2182 else
2183     cat <<End-of-File >conftest.c
2184 #include <sys/types.h>
2185 #include <unistd.h>
2186 pid_t bozo;
2187 End-of-File
2188     _do_type
2189     fmt_pid="$_fmt"
2191 AC_MSG_RESULT($fmt_pid)
2192 AC_SUBST(fmt_pid)
2193 rm -rf conftest.c conftest.debug
2195 dnl printf type for int64_t
2196 AC_MSG_CHECKING([printf type for int64_t ])
2197 if test "$cross_compiling" = "yes"; then
2198     ans=$printf_fmt_int64
2199     echo "cross-compile -> \"$ans\"" >&5
2200 else
2201     cat <<End-of-File >conftest.c
2202 #include <stdio.h>
2203 #include <stdint.h>
2204 #include <inttypes.h>
2205 int main()
2207     printf("\"%s\"\n", __PRI64_PREFIX "d");
2208     return(0);
2210 End-of-File
2211     ans=''
2212     (eval $ac_link) 2>&5
2213     if test -x ./conftest
2214     then
2215         ans=`./conftest`
2216         echo "./conftest -> \"$ans\"" >&5
2217     fi
2218     if test -z "$ans"
2219     then
2220         dnl have to try the hardway ...
2221         cat <<End-of-File >conftest.c
2222 #include <stdio.h>
2223 #include <stdint.h>
2224 #include <string.h>
2225 int main()
2227     char buf[[17]];
2228     int64_t bozo = 0x12345678abcdLL;
2229     sprintf(buf, "%lx", bozo);
2230     if (strcmp(buf, "12345678abcd") == 0)
2231         printf("\"ld\"\n");
2232     else {
2233         sprintf(buf, "%llx", bozo);
2234         if (strcmp(buf, "12345678abcd") == 0)
2235             printf("\"lld\"\n");
2236     }
2237     return(0);
2239 End-of-File
2240         (eval $ac_link) 2>&5
2241         if test -x ./conftest
2242         then
2243             ans=`./conftest`
2244             echo "./conftest -> \"$ans\"" >&5
2245         fi
2246     fi
2248 if test -z "$ans"
2249 then
2250     echo 'FATAL ERROR: Cannot determine printf format for int64_t type'
2251     rm -rf conftest conftest.*
2252     exit 1
2254 fmt_int64="$ans"
2255 AC_MSG_RESULT("$fmt_int64")
2256 AC_SUBST(fmt_int64)
2257 dnl and the unsigned version of this ...
2258 fmt_uint64=`echo $fmt_int64 | sed -e 's/d"/u"/'`
2259 AC_SUBST(fmt_uint64)
2260 rm -rf conftest.* conftest
2262 AC_MSG_CHECKING([strtol or strtoll for int64_t])
2263 if test "$cross_compiling" = "yes"; then
2264     ans=$strtoint64
2265     echo "cross-compile -> \"$ans\"" >&5
2266 else
2267     cat <<End-of-File >conftest.c
2268 #include <stdio.h>
2269 #include <stdlib.h>
2270 main()
2272     long long int       value = -1;
2273     value = strtol("1234567812345678", NULL, 16);
2274     if (value == 0x1234567812345678LL) {
2275         printf("strotol\n");
2276         exit(0);
2277     }
2278     value = strtoll("1234567812345678", NULL, 16);
2279     if (value == 0x1234567812345678LL) {
2280         printf("strtoll\n");
2281         exit(0);
2282     }
2283     exit(1);
2285 End-of-File
2286     (eval $ac_compile) 2>&5
2287     (eval $ac_link) 2>&5
2288     ans=`./conftest`
2289     echo "./conftest -> \"$ans\"" >&5
2291 case "$ans"
2293     strtol)
2294         AC_DEFINE(strtoint64, strtol)
2295         AC_DEFINE(strtouint64, strtoul)
2296         AC_MSG_RESULT([strtol])
2297         ;;
2298     strtoll)
2299         AC_DEFINE(strtoint64, strtoll)
2300         AC_DEFINE(strtouint64, strtoull)
2301         AC_MSG_RESULT([strtoll])
2302         ;;
2303     *)
2304         AC_DEFINE(strtoint64, strtoll)
2305         AC_DEFINE(strtouint64, strtoull)
2306         AC_MSG_RESULT([assuming strtoll])
2307         ;;
2308 esac
2309 rm -rf conftest conftest.*
2311 if test "$do_threads" = "check" -o "$do_threads" = "yes"
2312 then
2313     AC_CHECK_HEADERS(
2314         pthread.h,
2315         [],
2316         [
2317             if test "$do_threads" = "yes"
2318             then
2319                 AC_MSG_ERROR([cannot enable multi-threaded mode - no pthread.h])
2320             fi
2321         ])
2323     dnl Check if pthread_mutex_t is defined in pthread.h
2324     dnl Ignore the fact that pthread.h could be missing - we don't
2325     dnl really care if this test fails because of missing pthread_mutex_t
2326     dnl or because of missing headers.
2327     AC_MSG_CHECKING([for pthread_mutex_t in pthread.h])
2328     AC_TRY_COMPILE(
2329         [#include <pthread.h>], [pthread_mutex_t mymutex;],
2330         AC_DEFINE(HAVE_PTHREAD_MUTEX_T, [1], [pthread_mutex_t type]) AC_MSG_RESULT(yes),
2331         [
2332             if test "$do_threads" = "yes"
2333             then
2334                 AC_MSG_ERROR([cannot enable multi-threaded mode - no mutexes])
2335             else
2336                 AC_MSG_RESULT(no)
2337             fi
2338         ])
2340     dnl Check which library provide pthread stuff
2341     AC_MSG_CHECKING([where pthread_create() is defined])
2342     for cand in "" pthreads pthread ; do
2343         savedLIBS=$LIBS
2344         if test -n "$cand" 
2345         then
2346             LIBS=`echo $LIBS -l$cand`
2347         fi
2348         AC_TRY_LINK(
2349         [
2350             #include <pthread.h>
2351         ],
2352         [
2353             pthread_create(NULL, NULL, NULL, NULL);
2354         ],  AC_MSG_RESULT(lib${cand:-c})
2355             if test -z "$cand"
2356             then
2357                 lib_for_pthreads="$cand"
2358             else
2359                 lib_for_pthreads="-l$cand"
2360             fi
2361             LIBS=$savedLIBS
2362             break )
2363         LIBS=$savedLIBS
2364     done
2365     AC_SUBST(lib_for_pthreads)
2367     if test "$ac_cv_header_pthread_h" = "yes"
2368     then
2369         dnl printf type for pthread_t
2370         AC_MSG_CHECKING([printf type for pthread_t])
2371         cat <<End-of-File >conftest.c
2372 #include <pthread.h>
2373 pthread_t bozo;
2374 End-of-File
2375         _do_type
2376         fmt_pthread="$_fmt"
2377         AC_MSG_RESULT($fmt_pthread)
2378         AC_SUBST(fmt_pthread)
2379         rm -rf conftest.c conftest.debug
2381         dnl check if gcc supports __thread for thread private data
2382         AC_MSG_CHECKING([if compiler supports __thread])
2383         dnl __thread support is broken in some places
2384         if test $target_os = netbsd
2385         then
2386             AC_TRY_COMPILE([#include <pthread.h>
2387 #if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 5 )
2388 broken!
2389 #else
2390 __thread int x;
2391 #endif], [],
2392                 AC_DEFINE(HAVE___THREAD, [1], [__thread private data]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2393         else
2394             AC_TRY_COMPILE([#include <pthread.h>
2395 __thread int x;], [],
2396                 AC_DEFINE(HAVE___THREAD, [1], [__thread private data]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2397         fi
2399         dnl Check if pthread_barrier_t is defined in pthread.h
2400         AC_MSG_CHECKING([for pthread_barrier_t in pthread.h])
2401         AC_TRY_COMPILE([#include <pthread.h>], [pthread_barrier_t mybarrier;],
2402             AC_DEFINE(HAVE_PTHREAD_BARRIER_T, [1], [pthread_barrier_t type]) AC_MSG_RESULT(yes),
2403             AC_MSG_RESULT(no))
2404     fi
2407 AC_MSG_CHECKING([sizeof suseconds_t])
2408 if test "$cross_compiling" = "yes"; then
2409     ans=$sizeof_suseconds_t
2410     echo "cross-compile -> \"$ans\"" >&5
2411 else
2412     cat <<End-of-File >conftest.c
2413 #include <sys/time.h>
2414 main() { printf("%d", (int)sizeof(suseconds_t)); }
2415 End-of-File
2416     (eval $ac_compile) 2>&5
2417     (eval $ac_link) 2>&5
2418     ans=`./conftest`
2419     echo "./conftest -> \"$ans\"" >&5
2420     rm -rf conftest conftest.*
2422 AC_MSG_RESULT($ans)
2423 AC_DEFINE_UNQUOTED(SIZEOF_SUSECONDS_T, $ans, [sizeof suseconds_t])
2425 AC_MSG_CHECKING([sizeof time_t])
2426 if test "$cross_compiling" = "yes"; then
2427     ans=$sizeof_time_t
2428     echo "cross-compile -> \"$ans\"" >&5
2429 else
2430     cat <<End-of-File >conftest.c
2431 #include <sys/time.h>
2432 main() { printf("%d", (int)sizeof(time_t)); }
2433 End-of-File
2434     (eval $ac_compile) 2>&5
2435     (eval $ac_link) 2>&5
2436     ans=`./conftest`
2437     echo "./conftest -> \"$ans\"" >&5
2438     rm -rf conftest conftest.*
2440 AC_MSG_RESULT($ans)
2441 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ans, [sizeof time_t])
2443 dnl check sizeof long
2444 AC_MSG_CHECKING([sizeof long])
2445 if test "$cross_compiling" = "yes"; then
2446     ans=$sizeof_long
2447     echo "cross-compile -> \"$ans\"" >&5
2448 else
2449     cat <<End-of-File >conftest.c
2450 #include <stdio.h>
2451 main() { printf("%d", (int)sizeof(long)); }
2452 End-of-File
2453     (eval $ac_compile) 2>&5
2454     (eval $ac_link) 2>&5
2455     ans=`./conftest`
2456     echo "./conftest -> \"$ans\"" >&5
2458 AC_MSG_RESULT($ans)
2459 if test "$ans" = 4; then
2460     AC_DEFINE(HAVE_32BIT_LONG, [1], [sizeof long])
2461 elif test "$ans" = 8; then
2462     AC_DEFINE(HAVE_64BIT_LONG, [1], [sizeof long])
2463 else
2464     echo
2465     echo "FATAL ERROR: size of long is not 32 or 64 bits, cannot proceed."
2466     echo "sizeof(char *) -> $ans"
2467     rm -rf conftest conftest.*
2468     exit 1
2470 rm -rf conftest conftest.*
2472 dnl check sizeof pointer
2473 AC_MSG_CHECKING([sizeof pointer])
2474 if test "$cross_compiling" = "yes"; then
2475     ans=$sizeof_pointer
2476     echo "cross-compile -> \"$ans\"" >&5
2477 else
2478     cat <<End-of-File >conftest.c
2479 #include <stdio.h>
2480 main() { printf("%d", (int)sizeof(char *)); }
2481 End-of-File
2482     (eval $ac_compile) 2>&5
2483     (eval $ac_link) 2>&5
2484     ans=`./conftest`
2485     echo "./conftest -> \"$ans\"" >&5
2487 AC_MSG_RESULT($ans)
2488 if test "$ans" = 4; then
2489     AC_DEFINE(HAVE_32BIT_PTR, [1], [pointer size])
2490     PCP_PTR_SIZE=32
2491 elif test "$ans" = 8; then
2492     AC_DEFINE(HAVE_64BIT_PTR, [1], [pointer size])
2493     PCP_PTR_SIZE=64
2494 else
2495     echo
2496     echo "FATAL ERROR: size of pointer is not 32 or 64 bits, cannot proceed."
2497     echo "sizeof(char *) -> $ans"
2498     rm -rf conftest conftest.*
2499     exit 1
2501 rm -rf conftest conftest.*
2503 dnl check sizeof int. If not 32, we die
2504 AC_MSG_CHECKING([sizeof int])
2505 if test "$cross_compiling" = "yes"; then
2506     ans=$sizeof_int
2507     echo "cross-compile -> \"$ans\"" >&5
2508 else
2509     cat <<End-of-File >conftest.c
2510 #include <stdio.h>
2511 main() { printf("%d", (int)sizeof(int)); }
2512 End-of-File
2513     (eval $ac_compile) 2>&5
2514     (eval $ac_link) 2>&5
2515     ans=`./conftest`
2516     echo "./conftest -> \"$ans\"" >&5
2518 AC_MSG_RESULT($ans)
2519 if test "$ans" != 4
2520 then
2521     echo
2522     echo "FATAL ERROR: sizeof(int) is not 32 bits, cannot proceed."
2523     echo "Note: 32-bit ints are assumed in the PCP external file formats and"
2524     echo "      the over-the-wire PDU formats"
2525     rm -rf conftest conftest.*
2526     exit 1
2528 rm -rf conftest conftest.*
2530 dnl check bit field allocation order within a word
2531 AC_MSG_CHECKING([if bit fields allocated left-to-right])
2532 if test "$cross_compiling" = "yes"; then
2533     ans=$bit_field_scheme
2534     echo "cross-compile -> \"$ans\"" >&5
2535 else
2536     cat <<End-of-File >conftest.c
2537 union { struct { unsigned int b:4; unsigned int c:4; } a; int p; } u;
2538 main() { u.a.b = 1; u.a.c = 2; printf("%0*x", 2*sizeof(int), u.p); }
2539 End-of-File
2540     (eval $ac_compile) 2>&5
2541     (eval $ac_link) 2>&5
2542     ans=`./conftest`
2543     echo "./conftest -> \"$ans\"" >&5
2545 case "$ans"
2547     1200*|*0012)
2548         # left-to-right starting from MSB (SGI cc on MIPS), or
2549         # left-to-right ending at LSB
2550         AC_DEFINE(HAVE_BITFIELDS_LTOR, [1], [left-to-right bitfield ordering])
2551         AC_MSG_RESULT(yes)
2552         ;;
2553     2100*|*0021)
2554         # right-to-left ending at MSB, or
2555         # right-to-left starting from LSB (gcc in Intel)
2556         AC_MSG_RESULT(no)
2557         ;;
2558     *)
2559         AC_MSG_RESULT(unknown)
2560         echo "FATAL ERROR: could not fathom your compiler's bit field allocation scheme"
2561         rm -f conftest conftest.*
2562         exit 1
2563         ;;
2564 esac
2565 rm -rf conftest conftest.*
2567 dnl check if compiler can cast __uint64_t to double
2568 AC_TRY_LINK(
2570     #include <stdlib.h>
2571     #include <unistd.h>
2574     __uint64_t x = 0;
2575     double y = (double)x;
2576 ], AC_DEFINE(HAVE_CAST_U64_DOUBLE, [1], [compiler casts u64 to double]))
2578 dnl check if basename and dirname need -lgen, -lpcp or nothing to work
2579 dnl (assume both go together)
2580 AC_CHECK_FUNCS(basename)
2581 if test $ac_cv_func_basename = yes
2582 then
2583     AC_DEFINE(HAVE_BASENAME, [1], [basename API])
2584     AC_DEFINE(HAVE_DIRNAME, [1], [dirname API])
2585     lib_for_basename=""
2586 else
2587     AC_CHECK_LIB(gen, basename)
2588     if test $ac_cv_lib_gen_basename = yes
2589     then
2590         AC_DEFINE(HAVE_BASENAME, [1], [basename API])
2591         AC_DEFINE(HAVE_DIRNAME, [1], [dirname API])
2592         lib_for_basename="-lgen"
2593     else
2594         lib_for_basename="-lpcp"
2595     fi
2597 AC_SUBST(lib_for_basename)
2599 dnl check if clock_gettime needs -lrt to work
2600 lib_for_clock_gettime=
2601 AC_CHECK_FUNCS(clock_gettime)
2602 if test $ac_cv_func_clock_gettime = no
2603 then
2604     AC_CHECK_LIB(rt, clock_gettime)
2605     if test $ac_cv_lib_rt_clock_gettime = yes
2606     then
2607         AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [clock_gettime API])
2608         lib_for_rt=-lrt
2609     fi
2611 AC_SUBST(lib_for_rt)
2613 dnl check if dlopen et al need -ldl to work
2614 lib_for_dlopen=
2615 AC_CHECK_FUNCS(dlopen)
2616 if test $ac_cv_func_dlopen = no
2617 then
2618     AC_CHECK_LIB(dl, dlopen)
2619     if test $ac_cv_lib_dl_dlopen = yes
2620     then
2621         AC_DEFINE(HAVE_DLOPEN, [1], [dlopen API])
2622         lib_for_dlopen=-ldl
2623     fi
2625 AC_SUBST(lib_for_dlopen)
2627 dnl check if flog10, pow, fpclassify and isnanf are available
2628 dnl in the maths library
2629 lib_for_math=
2630 AC_CHECK_FUNCS(flog10)
2631 if test $ac_cv_func_flog10 = no
2632 then
2633     AC_CHECK_LIB(m, flog10)
2634     if test $ac_cv_lib_m_flog10 = yes
2635     then
2636         AC_DEFINE(HAVE_FLOG10, [1], [flog10 math API])
2637         lib_for_math=-lm
2638     fi
2639 else
2640     AC_DEFINE(HAVE_FLOG10, [1], [flog10 math API])
2642 AC_CHECK_FUNCS(pow)
2643 if test $ac_cv_func_pow = no
2644 then
2645     AC_CHECK_LIB(m, pow)
2646     if test $ac_cv_lib_m_pow = yes
2647     then
2648         AC_DEFINE(HAVE_POW, [1], [pow math API])
2649         lib_for_math=-lm
2650     fi
2651 else
2652     AC_DEFINE(HAVE_POW, [1], [pow math API])
2654 AC_MSG_CHECKING([for fpclassify()])
2655 ac_cv_func_fpclassify=no
2656 AC_TRY_LINK(
2658     #include <math.h>
2661     double x = 123.456;
2662     if (fpclassify(x) == FP_NAN) exit(1);
2663 ], ac_cv_func_fpclassify=yes)
2664 AC_MSG_RESULT($ac_cv_func_fpclassify)
2665 if test $ac_cv_func_fpclassify = no
2666 then
2667     dnl try with -lm
2668     AC_MSG_CHECKING([for fpclassify() with -lm])
2669     savedLIBS=$LIBS
2670     LIBS=-lm
2671     AC_TRY_LINK(
2673     #include <math.h>
2676     double x = 123.456;
2677     if (fpclassify(x) == FP_NAN) exit(1);
2678 ], ac_cv_func_fpclassify=yes)
2679     AC_MSG_RESULT($ac_cv_func_fpclassify)
2680     if test $ac_cv_func_fpclassify = yes
2681     then
2682         lib_for_math=-lm
2683     fi
2684     LIBS=$savedLIBS
2686 if test $ac_cv_func_fpclassify = yes
2687 then
2688     AC_DEFINE(HAVE_FPCLASSIFY, [1], [fpclassify math API])
2689 else
2690     dnl prefer fpclassify() but will take isnan() and isnanf() as
2691     dnl possible alternates
2692     AC_CHECK_FUNCS(isnan)
2693     if test $ac_cv_func_isnan = no
2694     then
2695         AC_CHECK_LIB(m, isnan)
2696         if test $ac_cv_lib_m_isnan = yes
2697         then
2698             AC_DEFINE(HAVE_ISNAN, [1], [isnan math API])
2699             lib_for_math=-lm
2700         fi
2701     fi
2702     AC_CHECK_FUNCS(isnanf)
2703     if test $ac_cv_func_isnanf = no
2704     then
2705         AC_CHECK_LIB(m, isnanf)
2706         if test $ac_cv_lib_m_isnanf = yes
2707         then
2708             AC_DEFINE(HAVE_ISNANF, [1], [isnanf math API])
2709             lib_for_math=-lm
2710         fi
2711     fi
2713 AC_SUBST(lib_for_math)
2715 dnl check if we have the SIG_PF typedef
2716 AC_TRY_LINK([#include <signal.h>], [SIG_PF x;],
2717     AC_DEFINE(HAVE_SIGPF, [1], [SIG_PF typedef]))
2719 dnl check if we have the SA_SIGINFO #define
2720 AC_TRY_LINK([#include <signal.h>], [int x = SA_SIGINFO;],
2721     AC_DEFINE(HAVE_SA_SIGINFO, [1], [SA_SIGINFO macro]))
2723 dnl check if we support the SIGPIPE signal
2724 AC_TRY_LINK([#include <signal.h>], [int x = SIGPIPE;],
2725     AC_DEFINE(HAVE_SIGPIPE, [1], [SIGPIPE signal]))
2727 dnl check if we support the SIGHUP signal
2728 AC_TRY_LINK([#include <signal.h>], [int x = SIGHUP;],
2729     AC_DEFINE(HAVE_SIGHUP, [1], [SIGHUP signal]))
2731 dnl check if we support the SIGBUS signal
2732 AC_TRY_LINK([#include <signal.h>], [int x = SIGBUS;],
2733     AC_DEFINE(HAVE_SIGBUS, [1], [SIGBUS signal]))
2735 dnl check if we need to explicitly include signal.h
2736 AC_TRY_LINK([#include <sys/wait.h>],
2737 [   typedef void (*SIGRET)(int);
2738     SIGRET x = SIG_IGN;
2739 ], AC_DEFINE(HAVE_WAIT_INCLUDES_SIGNAL, [1], [indirect signal.h]))
2741 dnl check for name and type of time fields in struct stat
2742 dnl IRIX example        timespec_t st_mtim;     
2743 dnl Linux example       struct timespec st_mtim;
2744 dnl Darwin example      struct timespec st_mtimespec;
2745 dnl Solaris example     timestruc_t st_mtim;
2746 dnl FreeBSD (6.1)       struct timespec st_mtimespec;
2747 dnl                     struct timespec {
2748 dnl                             time_t tv_sec;
2749 dnl                             long tv_nsec;
2750 dnl                     };
2752 have_stat_type=false
2753 have_stat_name=false
2754 if test $have_stat_name = false
2755 then
2756     AC_EGREP_HEADER(
2757     changequote(<<, >>)<<[      ]st_mtimespec>>changequote([, ]),
2758     sys/stat.h, [ have_stat_name=true;
2759     AC_DEFINE(HAVE_ST_MTIME_WITH_SPEC, [1], [st_mtimespec stat field]) ])
2761 if test $have_stat_name = false -a $target_os != darwin -a $target_os != linux -a $target_os != kfreebsd -a $target_os != netbsd
2762 then
2763     AC_EGREP_HEADER(
2764     changequote(<<, >>)<<[      ]st_mtime>>changequote([, ]),
2765     sys/stat.h, [ have_stat_name=true;
2766     AC_DEFINE(HAVE_ST_MTIME_WITH_E, [1], [st_mtime stat field]) ])
2768 if test $have_stat_type = false
2769 then
2770     AC_EGREP_HEADER(
2771     changequote(<<, >>)<<timestruc_t[   ][      ]*st_mtim>>changequote([, ]),
2772     sys/stat.h, [ have_stat_type=true;
2773     AC_DEFINE(HAVE_STAT_TIMESTRUC, [1], [timestruc_t type]) ])
2775 if test $have_stat_type = false
2776 then
2777     AC_EGREP_HEADER(
2778     changequote(<<, >>)<<timespec_t[    ][      ]*st_mtim>>changequote([, ]),
2779     sys/stat.h, [ have_stat_type=true;
2780     AC_DEFINE(HAVE_STAT_TIMESPEC_T, [1], [timespec_t type]) ])
2782 if test $have_stat_type = false
2783 then
2784     AC_EGREP_HEADER(
2785     changequote(<<, >>)<<timespec[      ][      ]*st_mtim>>changequote([, ]),
2786     sys/stat.h, [ have_stat_type=true;
2787     AC_DEFINE(HAVE_STAT_TIMESPEC, [1], [timespec type]) ])
2789 if test $have_stat_type = false
2790 then
2791     AC_EGREP_HEADER(
2792     changequote(<<, >>)<<time_t[        ][      ]*st_mtim>>changequote([, ]),
2793     sys/stat.h, [ have_stat_type=true;
2794     AC_DEFINE(HAVE_STAT_TIME_T, [1], [time_t type]) ])
2796 if test $have_stat_type = false
2797 then
2798     echo 'FATAL ERROR: Cannot determine struct stat time types.'
2799     rm -rf conftest conftest.*
2800     exit 1
2804 dnl Work out where to install stuff for this package
2805 dnl (and where to find stuff at run-time for add-on packages).
2809 dnl Predictable directory containing pcp.conf, or overridden
2810 dnl by the $PCP_CONF environment variable. If this is not set
2811 dnl (default /etc/pcp.conf), then $PCP_CONF must be set in
2812 dnl the environment.
2814 dnl The eval echo stuff is used to get around unfavourable
2815 dnl elements of the GNU standards, which cause embedding of
2816 dnl ${prefix} within many of these various $dirs.
2817 dnl http://www.gnu.org/software/autoconf/manual/autoconf.html#Installation-Directory-Variables
2819 pcp_etc_dir=`eval echo $sysconfdir`
2820 pcp_etc_dir=`eval echo $pcp_etc_dir`
2821 AC_SUBST(pcp_etc_dir)
2822 pcp_saslconf_dir=`eval echo $sysconfdir/sasl2`
2823 pcp_saslconf_dir=`eval echo $pcp_saslconf_dir`
2824 AC_SUBST(pcp_saslconf_dir)
2825 pcp_sysconf_dir=`eval echo $sysconfdir/pcp`
2826 pcp_sysconf_dir=`eval echo $pcp_sysconf_dir`
2827 AC_SUBST(pcp_sysconf_dir)
2828 pcp_pmcdconf_path=$pcp_sysconf_dir/pmcd/pmcd.conf
2829 pcp_pmcdrclocal_path=$pcp_sysconf_dir/pmcd/rc.local
2830 pcp_pmcdoptions_path=$pcp_sysconf_dir/pmcd/pmcd.options
2831 pcp_pmwebdoptions_path=$pcp_sysconf_dir/pmwebd/pmwebd.options
2832 pcp_pmmgroptions_path=$pcp_sysconf_dir/pmmgr/pmmgr.options
2833 pcp_pmproxyoptions_path=$pcp_sysconf_dir/pmproxy/pmproxy.options
2834 pcp_pmiecontrol_path=$pcp_sysconf_dir/pmie/control
2835 pcp_pmsnapcontrol_path=$pcp_sysconf_dir/pmsnap/control
2836 pcp_pmloggercontrol_path=$pcp_sysconf_dir/pmlogger/control
2837 AC_SUBST(pcp_pmcdconf_path)
2838 AC_SUBST(pcp_pmcdoptions_path)
2839 AC_SUBST(pcp_pmcdrclocal_path)
2840 AC_SUBST(pcp_pmwebdoptions_path)
2841 AC_SUBST(pcp_pmmgroptions_path)
2842 AC_SUBST(pcp_pmproxyoptions_path)
2843 AC_SUBST(pcp_pmiecontrol_path)
2844 AC_SUBST(pcp_pmsnapcontrol_path)
2845 AC_SUBST(pcp_pmloggercontrol_path)
2847 dnl shared PCP files (shareable for diskless)
2848 pcp_share_dir=`eval echo $datarootdir/pcp`
2849 pcp_share_dir=`eval echo $pcp_share_dir`
2850 AC_SUBST(pcp_share_dir)
2852 dnl private PCP executables
2853 pcp_binadm_dir=`eval echo $libexecdir/pcp/bin`
2854 pcp_binadm_dir=`eval echo $pcp_binadm_dir`
2855 AC_SUBST(pcp_binadm_dir)
2857 dnl non-shared (i.e. system local) PCP files
2858 pcp_var_dir=`eval echo $localstatedir/lib/pcp`
2859 pcp_var_dir=`eval echo $pcp_var_dir`
2860 AC_SUBST(pcp_var_dir)
2862 dnl pmcd control and options files
2863 AC_ARG_WITH(configdir,[AC_HELP_STRING([--with-configdir],[configuration directory [LOCALSTATEDIR/pcp/config]])],
2864                       [pcp_config_dir=$withval],
2865                       [pcp_config_dir=$pcp_var_dir/config])
2867 pcp_pmdas_dir=$pcp_var_dir/pmdas
2868 AC_SUBST(pcp_pmdas_dir)
2870 pcp_selinux_dir=$pcp_var_dir/selinux
2871 AC_SUBST(pcp_selinux_dir)
2873 dnl runtime shared libraries
2874 pcp_lib_dir=`eval echo $libdir`
2875 pcp_lib_dir=`eval echo $pcp_lib_dir`
2876 pcp_lib32_dir=`echo $pcp_lib_dir | sed -e s,64,, -e s,//,/,`
2877 AC_SUBST(pcp_lib_dir)
2878 AC_SUBST(pcp_lib32_dir)
2880 dnl perl modules
2881 AC_ARG_WITH(perl_installdirs,[AC_HELP_STRING([--with-perl_installdirs],[perl installdirs [vendor]])],
2882                       [perl_installdirs=$withval],
2883                       [perl_installdirs=vendor])
2884 perl_installdirs=`eval echo $perl_installdirs`
2885 perl_installdirs=`eval echo $perl_installdirs`
2886 AC_SUBST(perl_installdirs)
2887 AC_ARG_WITH(perl_install_base,[AC_HELP_STRING([--with-perl_install_base],[perl install_base [PREFIX]])],
2888                       [perl_install_base=$withval],
2889                       [perl_install_base=$prefix])
2890 perl_install_base=`eval echo $perl_install_base`
2891 perl_install_base=`eval echo $perl_install_base`
2892 AC_SUBST(perl_install_base)
2894 AC_ARG_WITH(python_prefix,[AC_HELP_STRING([--with-python_prefix],[python setup.py prefix [PREFIX]])],
2895                       [python_prefix=$withval],
2896                       [python_prefix=$prefix])
2897 python_prefix=`eval echo $python_prefix`
2898 python_prefix=`eval echo $python_prefix`
2899 AC_SUBST(python_prefix)
2901 AC_PATH_XTRA
2902 pcp_x11_incflags=$X_CFLAGS
2903 AC_SUBST(pcp_x11_incflags)
2904 pcp_x11_libflags=$X_LIBS
2905 AC_SUBST(pcp_x11_libflags)
2906 pcp_x11_extra=$X_EXTRA_LIBS
2907 AC_SUBST(pcp_x11_extra)
2908 pcp_x11_pre=$X_PRE_LIBS
2909 AC_SUBST(pcp_x11_pre)
2911 dnl man pages (source)
2912 have_manpages=false
2913 have_gzipped_manpages=false
2914 have_bzip2ed_manpages=false
2915 have_lzmaed_manpages=false
2916 have_xzed_manpages=false
2917 need_old_tbl_header=false
2918 man_header=
2919 pcp_man_dir=`eval echo $mandir`
2920 pcp_man_dir=`eval echo $pcp_man_dir`
2922 dnl guess compression in use
2923 for d in /usr/man /usr/share/man $pcp_man_dir
2925     for sd in man1 sman1
2926     do
2927         if test -f $d/$sd/man.1.gz
2928         then
2929             have_gzipped_manpages=true
2930             have_manpages=true
2931             man_header=`$ZIP -d < $d/$sd/man.1.gz | head -1`
2932             break
2933         elif test -f $d/$sd/man.1.bz2
2934         then
2935             have_bzip2ed_manpages=true
2936             have_manpages=true
2937             man_header=`$BZIP2 -d < $d/$sd/man.1.bz2 | head -1`
2938             break
2939         elif test -f $d/$sd/man.1.lzma
2940         then
2941             have_lzmaed_manpages=true
2942             have_manpages=true
2943             man_header=`$LZMA -d < $d/$sd/man.1.lzma | head -1`
2944             break
2945         elif test -f $d/$sd/man.1.xz
2946         then
2947             have_xzed_manpages=true
2948             have_manpages=true
2949             man_header=`$XZ -d < $d/$sd/man.1.xz | head -1`
2950             break
2951         elif test -f $d/$sd/man.1
2952         then
2953             man_header=`head -1 $d/$sd/man.1`
2954             have_manpages=true
2955             break
2956         fi
2957     done
2958 done
2959 if test x"$man_header" = "x'\\\" t" -o x"$man_header" = "x'\\\" te" ; then
2960     need_old_tbl_header=true
2962 AC_SUBST(pcp_man_dir)
2963 AC_SUBST(have_manpages)
2964 AC_SUBST(have_gzipped_manpages)
2965 AC_SUBST(have_bzip2ed_manpages)
2966 AC_SUBST(have_lzmaed_manpages)
2967 AC_SUBST(have_xzed_manpages)
2968 AC_SUBST(need_old_tbl_header)
2970 dnl public binaries
2971 pcp_bin_dir=`eval echo $bindir`
2972 pcp_bin_dir=`eval echo $pcp_bin_dir`
2973 AC_SUBST(pcp_bin_dir)
2975 pcp_sbin_dir=`eval echo $sbindir`
2976 pcp_sbin_dir=`eval echo $pcp_sbin_dir`
2977 AC_SUBST(pcp_sbin_dir)
2979 dnl include files
2980 pcp_inc_dir=`eval echo $includedir/pcp`
2981 pcp_inc_dir=`eval echo $pcp_inc_dir`
2982 AC_SUBST(pcp_inc_dir)
2984 dnl books - pdfs, html
2985 if test $target_os = linux; then
2986     pcp_books_dir=`eval echo $datarootdir/doc/pcp-doc`
2987 else
2988     pcp_books_dir=`eval echo $datarootdir/doc/pcp`
2990 pcp_books_dir=`eval echo $pcp_books_dir`
2991 pcp_html_dir=`eval echo $pcp_books_dir/html`
2992 AC_SUBST(pcp_books_dir)
2993 AC_SUBST(pcp_html_dir)
2995 dnl icon pixmap files
2996 if test $target_os = linux; then
2997     pcp_icons_dir=`eval echo $datarootdir/pcp-gui/pixmaps`
2998 else
2999     pcp_icons_dir=`eval echo $datarootdir/pcp/pixmaps`
3001 pcp_icons_dir=`eval echo $pcp_icons_dir`
3002 AC_SUBST(pcp_icons_dir)
3004 dnl desktop application entries
3005 pcp_desktop_dir=`eval echo $datarootdir/applications`
3006 pcp_desktop_dir=`eval echo $pcp_desktop_dir`
3007 AC_SUBST(pcp_desktop_dir)
3009 dnl rc/startup files
3010 AC_ARG_WITH(rcdir,[AC_HELP_STRING([--with-rcdir],[rc directory [SYSCONFDIR/rc.d]])],
3011                   [pcp_rc_dir=$withval], [
3012 if $enable_systemd
3013 then
3014     pcp_rc_dir="$pcp_share_dir/lib"
3015 else
3016     pcp_rc_dir="$pcp_etc_dir/init.d"
3017 fi])
3018 AC_SUBST(pcp_rc_dir)
3020 dnl rc sysconfig dir
3021 AC_ARG_WITH(sysconfigdir,[AC_HELP_STRING([--with-sysconfigdir],[sysconfig directory [SYSCONFDIR/sysconfig]])],
3022                   [pcp_sysconfig_dir=$withval],
3023                   [pcp_sysconfig_dir=$pcp_etc_dir/sysconfig])
3024 AC_SUBST(pcp_sysconfig_dir)
3026 dnl logs
3027 AC_ARG_WITH(logdir,[AC_HELP_STRING([--with-logdir],[log directory [LOCALSTATEDIR/log/pcp]])],
3028                    [pcp_log_dir=$withval],
3029                    [pcp_log_dir=$localstatedir/log/pcp])
3030 pcp_log_dir=`eval echo $pcp_log_dir`
3031 pcp_log_dir=`eval echo $pcp_log_dir`
3032 AC_SUBST(pcp_log_dir)
3034 AC_ARG_WITH(rundir,[AC_HELP_STRING([--with-rundir],[run directory [LOCALSTATEDIR/run/pcp]])],
3035                    [pcp_run_dir=$withval],
3036                    [pcp_run_dir=$localstatedir/run/pcp])
3037 pcp_run_dir=`eval echo $pcp_run_dir`
3038 pcp_run_dir=`eval echo $pcp_run_dir`
3039 AC_SUBST(pcp_run_dir)
3041 dnl world-writeable temporary files directory
3042 AC_ARG_WITH(tmpdir,[AC_HELP_STRING([--with-tmpdir],[tmp directory [LOCALSTATEDIR/tmp]])],
3043                    [pcp_tmpfile_dir=$withval],
3044                    [pcp_tmpfile_dir=$localstatedir/tmp])
3045 pcp_tmpfile_dir=`eval echo $pcp_tmpfile_dir`
3046 pcp_tmpfile_dir=`eval echo $pcp_tmpfile_dir`
3047 AC_SUBST(pcp_tmpfile_dir)
3049 dnl non-world-writeable status files directory
3050 pcp_tmp_dir=`eval echo $pcp_var_dir/tmp`
3051 AC_SUBST(pcp_tmp_dir)
3053 dnl doc directory
3054 AC_ARG_WITH(docdir,[AC_HELP_STRING([--with-docdir],[docs directory [DOCDIR/pcp-VERSION]])],
3055                    [pcp_doc_dir=$withval],
3056                    [PACKAGE=pcp-${PACKAGE_VERSION}; pcp_doc_dir=$docdir])
3057 pcp_doc_dir=`eval echo $pcp_doc_dir`
3058 pcp_doc_dir=`eval echo $pcp_doc_dir`
3059 AC_SUBST(pcp_doc_dir)
3061 dnl demos directory
3062 AC_ARG_WITH(demosdir,[AC_HELP_STRING([--with-demosdir],[run directory [DATADIR/pcp/demos]])],
3063                    [pcp_demos_dir=$withval],
3064                    [pcp_demos_dir=$pcp_share_dir/demos])
3065 AC_SUBST(pcp_demos_dir)
3067 if test -z "$XCONFIRM" 
3068 then
3069     AC_PATH_PROG(ac_xconfirm_prog, xconfirm, $pcp_bin_dir/pmconfirm)
3070 else
3071     ac_xconfirm_prog=$XCONFIRM
3073 AC_SUBST(ac_xconfirm_prog)
3075 dnl Check for FNDELAY defined in <fcntl.h>
3076 if test "$ac_cv_header_fcntl_h" = "yes"
3077 then
3078     AC_MSG_CHECKING([for FNDELAY in fcntl.h])
3079     AC_TRY_COMPILE([#include <fcntl.h>],
3080         [ int i = FNDELAY; ],
3081         AC_DEFINE(HAVE_FNDELAY, [1], [FNDELAY macro])
3082         AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3085 dnl check for zpool_vdev_name API style from <libzfs.h>
3086 if test "$ac_cv_header_libzfs_h" = "yes"
3087 then
3088     AC_MSG_CHECKING([for 5-argument style zpool_vdev_name])
3089     AC_TRY_COMPILE([#include <libzfs.h>],
3090         [ libzfs_handle_t *zh;
3091           zpool_handle_t *zp;
3092           nvlist_t *np;
3093           (void) zpool_vdev_name(zh, zp, np, B_FALSE, B_FALSE);
3094         ],
3095         AC_DEFINE(HAVE_ZPOOL_VDEV_NAME_5ARG, [1], [5-arg zpool_vdev_name])
3096         AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3098     AC_MSG_CHECKING([for 4-argument style zpool_vdev_name])
3099     AC_TRY_COMPILE([#include <libzfs.h>],
3100         [ libzfs_handle_t *zh;
3101           zpool_handle_t *zp;
3102           nvlist_t *np;
3103           (void) zpool_vdev_name(zh, zp, np, B_FALSE);
3104         ],
3105         AC_DEFINE(HAVE_ZPOOL_VDEV_NAME_4ARG, [1], [4-arg zpool_vdev_name])
3106         AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3109 dnl Check for Network Security Services (NSS) and
3110 dnl Simple Authentication and Security Layer (SASL)
3111 if test "$do_secure" = "check" -o "$do_secure" = "yes"
3112 then
3113     enable_secure=true
3115     saved_CFLAGS="$CFLAGS"
3116     saved_CPPFLAGS="$CPPFLAGS"
3117     NSS_INC_DIRS="-I/usr/include/nss -I/usr/include/nss3"
3118     NSPR_INC_DIRS="-I/usr/include/nspr -I/usr/include/nspr4"
3119     CFLAGS="$CFLAGS $NSS_INC_DIRS $NSPR_INC_DIRS"
3120     CPPFLAGS="$CPPFLAGS $NSS_INC_DIRS $NSPR_INC_DIRS"
3122     AC_CHECK_HEADERS([nss/nss.h], [NSSCFLAGS=-I/usr/include/nss], [
3123         AC_CHECK_HEADERS([nss3/nss.h], [NSSCFLAGS=-I/usr/include/nss3], [
3124             enable_secure=false
3125             if test "$do_secure" = "yes"
3126             then
3127                 AC_MSG_ERROR([cannot enable secure sockets mode - no NSS header])
3128             fi
3129         ])
3130     ])
3131     AC_SUBST(NSSCFLAGS)
3133     AC_CHECK_HEADERS([nspr/nspr.h], [NSPRCFLAGS=-I/usr/include/nspr], [
3134         AC_CHECK_HEADERS([nspr4/nspr.h], [NSPRCFLAGS=-I/usr/include/nspr4], [
3135             enable_secure=false
3136             if test "$do_secure" = "yes"
3137             then
3138                 AC_MSG_ERROR([cannot enable secure sockets mode - no NSPR header])
3139             fi
3140         ])
3141     ])
3142     AC_SUBST(NSPRCFLAGS)
3144     AC_CHECK_HEADERS([sasl/sasl.h], [SASLCFLAGS=-I/usr/include/sasl], [
3145         enable_secure=false
3146         if test "$do_secure" = "yes"
3147         then
3148             AC_MSG_ERROR([cannot enable secure sockets mode - no SASL header])
3149         fi
3150     ])
3151     AC_SUBST(SASLCFLAGS)
3153     AC_CHECK_LIB(sasl2, sasl_server_init, [lib_for_sasl="-lsasl2"], [
3154         enable_secure=false
3155         if test "$do_secure" = "yes"
3156         then
3157             AC_MSG_ERROR([cannot enable secure sockets mode - no SASL library])
3158         fi
3159     ])
3160     AC_SUBST(lib_for_sasl)
3162     AC_CHECK_LIB(ssl, SSL_ImportFD, [lib_for_ssl="-lssl"], [
3163         AC_CHECK_LIB(ssl3, SSL_ImportFD, [lib_for_ssl="-lssl3"], [
3164             enable_secure=false
3165             if test "$do_secure" = "yes"
3166             then
3167                 AC_MSG_ERROR([cannot enable secure sockets mode - no SSL library])
3168             fi
3169         ])
3170     ])
3171     AC_SUBST(lib_for_ssl)
3173     AC_CHECK_LIB(nss, NSS_Init, [lib_for_nss="-lnss"], [
3174         AC_CHECK_LIB(nss3, NSS_Init, [lib_for_nss="-lnss3"], [
3175             enable_secure=false
3176             if test "$do_secure" = "yes"
3177             then
3178                 AC_MSG_ERROR([cannot enable secure sockets mode - no NSS library])
3179             fi
3180         ])
3181     ])
3182     AC_SUBST(lib_for_nss)
3184     AC_CHECK_LIB(nspr, PR_Init, [lib_for_nspr="-lnspr"], [
3185         AC_CHECK_LIB(nspr4, PR_Init, [lib_for_nspr="-lnspr4"], [
3186             enable_secure=false
3187             if test "$do_secure" = "yes"
3188             then
3189                 AC_MSG_ERROR([cannot enable secure sockets mode - no NSPR library])
3190             fi
3191         ])
3192     ])
3193     AC_SUBST(lib_for_nspr)
3195     if test "$enable_secure" = "true"
3196     then
3197         AC_DEFINE(HAVE_SECURE_SOCKETS, [1], [Encrypted sockets])
3198     fi
3199     AC_SUBST(enable_secure)
3201     CPPFLAGS="$saved_CPPFLAGS"
3202     CFLAGS="$saved_CFLAGS"
3205 dnl check for -latomic, needed for some -march=i386 builds with i686 c++ distro headers
3206 AC_CHECK_LIB(atomic, __atomic_fetch_add_4, [lib_for_atomic="-latomic"])
3207 AC_SUBST(lib_for_atomic)
3209 dnl check for array sessions
3210 if test -f /usr/include/sn/arsess.h
3211 then
3212     pcp_mpi_dirs=libpcp_mpi\ libpcp_mpiread
3213 else
3214     pcp_mpi_dirs=
3216 AC_SUBST(pcp_mpi_dirs)
3218 dnl check for Unix Domain socket family structure
3219 AC_MSG_CHECKING([for struct sockaddr_un in sys/un.h])
3220 AC_TRY_COMPILE([
3221     #include <sys/types.h>
3222     #ifdef HAVE_SYS_SOCKET_H
3223     #include <sys/socket.h>
3224     #endif
3225     #ifdef HAVE_SYS_UN_H
3226     #include <sys/un.h>
3227     #endif
3228 ], [ struct sockaddr_un sa; sa.sun_family = AF_UNIX; ],
3229 AC_DEFINE(HAVE_STRUCT_SOCKADDR_UN, [1], [sockaddr_un type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3231 dnl check for Linux Unix Domain socket credential structure
3232 AC_MSG_CHECKING([for struct ucred in sys/socket.h])
3233 AC_TRY_COMPILE([
3234     #include <sys/types.h>
3235     #ifdef HAVE_SYS_SOCKET_H
3236     #include <sys/socket.h>
3237     #endif
3238     #ifdef HAVE_SYS_UN_H
3239     #include <sys/un.h>
3240     #endif
3241 ], [ struct ucred ucred; ucred.uid = 0; ],
3242 AC_DEFINE(HAVE_STRUCT_UCRED, [1], [ucred type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3244 dnl check for struct timespec in <time.h>
3245 AC_MSG_CHECKING([for struct timespec in time.h])
3246 AC_TRY_COMPILE([
3247     #include <time.h>
3248 ], [ struct timespec foo; ],
3249 AC_DEFINE(HAVE_STRUCT_TIMESPEC, [1], [timespec type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3251 dnl check if we have IRIX style altzone 
3252 AC_MSG_CHECKING([for altzone in time.h])
3253 AC_TRY_COMPILE([
3254     #include <time.h>
3255 ], [ time_t az = altzone; ],
3256 AC_DEFINE(HAVE_ALTZONE, [1], [altzone global]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3258 dnl If there is no altzone, check if strftime can handle %z
3259 AC_MSG_CHECKING([if strftime knows about %z])
3260 AC_TRY_RUN(
3262 #include <time.h>
3263 int main () {
3264     char b[32]="";
3265     time_t t = time(NULL);
3266     struct tm * t1 = localtime (&t);
3267     if (strftime (b, 32, "%z", t1) < 3)
3268        return (1);
3269     if (strcmp(b, "%z") == 0)
3270        return(1);
3271     return (0);
3273 ], AC_DEFINE(HAVE_STRFTIME_z, [1], [strftime with %z]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no), AC_MSG_RESULT(no))
3275 dnl does strerror_r return char * a la GNU
3276 dnl (as opposed to the int return for XSI-compliant variants)
3277 AC_MSG_CHECKING([if strerror_r returns char *])
3278 AC_TRY_COMPILE(
3279     [#include <string.h>], [strerror_r(0, NULL, 0)[0];],
3280     AC_DEFINE(HAVE_STRERROR_R_PTR, [1], [strerror_r return]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3282 dnl first check for readline on its own then with curses
3283 savedLIBS=$LIBS
3284 LIBS=
3285 lib_for_curses=
3286 lib_for_readline=
3287 AC_CHECK_FUNC(readline,,
3288     [
3289         AC_CHECK_LIB(readline, readline,,
3290             [
3291                 dnl AC seems to cache lib/func results
3292                 dnl so use another readline func here
3293                 AC_CHECK_LIB(readline, add_history,,,[-lcurses])
3294             ])
3295     ])
3296 if test $ac_cv_func_readline = yes
3297 then
3298     AC_DEFINE(HAVE_READLINE, [1], [readline API])
3299 elif test $ac_cv_lib_readline_readline = yes
3300 then
3301     AC_DEFINE(HAVE_READLINE, [1], [readline API])
3302     lib_for_readline=-lreadline
3303 elif test $ac_cv_lib_readline_add_history = yes
3304 then
3305     AC_DEFINE(HAVE_READLINE, [1], [readline API])
3306     lib_for_curses=-lcurses
3307     lib_for_readline=-lreadline
3309 AC_SUBST(lib_for_readline)
3310 AC_SUBST(lib_for_curses)
3311 LIBS=$savedLIBS
3313 dnl Look for zlib
3314 PKG_CHECK_MODULES([zlib], [zlib >= 1.0.0], [have_zlib=true], [have_zlib=false])
3315 AC_SUBST(HAVE_ZLIB, [$have_zlib])
3317 dnl Check if we have AI_ADDRCONFIG
3318 AC_MSG_CHECKING([for AI_ADDRCONFIG])
3319 AC_TRY_COMPILE(
3320 [  
3321     #include <netdb.h>
3322     int test = AI_ADDRCONFIG;
3325 ], AC_DEFINE(HAVE_AI_ADDRCONFIG, [1], [AI_ADDRCONFIG macro]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3327 dnl Find external source tarballs for packaging
3329 have_parfait=false
3330 if test -f ./build/tar/parfait.tar.gz
3331 then
3332     AC_MSG_NOTICE([adding Parfait package to the build])
3333     have_parfait=true
3335 AC_SUBST(have_parfait)
3337 have_vector=false
3338 if test -f ./build/tar/vector.tar.gz
3339 then
3340     AC_MSG_NOTICE([adding Vector webapp to the build])
3341     have_vector=true
3343 AC_SUBST(have_vector)
3345 have_webjs=false
3346 if test -f ./build/tar/webjs.tar.gz
3347 then
3348     AC_MSG_NOTICE([adding webjs webapps to the build])
3349     have_webjs=true
3351 AC_SUBST(have_webjs)
3353 dnl Capture special options passed to configure
3354 AC_SUBST(PACKAGE_CONFIGURE)
3357 dnl output files
3360 AC_OUTPUT(
3361 dnl   Build definitions for use in Makefiles
3362     src/include/builddefs
3363 dnl   PCP paths and other defs
3364     src/include/pcp.conf
3365 dnl   Linux Software Map entry
3366     pcp.lsm
3367 dnl   Preamble for deb install scripts
3368     debian/pcp.preinst.head
3369     debian/pcp.postinst.head
3370 dnl   Preamble for tar install scripts
3371     build/tar/preinstall.head
3372     build/tar/postinstall.head
3373 dnl   Build definitions for use in packaging
3374     build/GNUlocaldefs
3375     build/mac/uninstall-pcp
3378 dnl verbose diagnostics
3380 dnl echo config.status: settings dump begin
3381 dnl grep '^S.".*=' config.status
3382 dnl echo config.status: settings dump end