Fix potential buffer overflows detected by Coverity.
[pcp.git] / configure.ac
blob23abea234dc2db13bf265a2c00bfadf7c7c16cbd
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 LIO PMDA should be included])
1078 pmda_lio=false
1079 if test "$have_python" = true
1080 then
1081     dnl rpm build for LIO PMDA needs Python rtslib module
1082     if $pcp_python_prog -c "import rtslib" >/dev/null 2>&1
1083     then
1084         pmda_lio=true
1085     fi
1087 AC_SUBST(PMDA_LIO, $pmda_lio)
1088 if $pmda_lio; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1090 AC_MSG_CHECKING([if the libvirt PMDA should be included])
1091 pmda_libvirt=false
1092 if test "$have_python" = true
1093 then
1094     dnl rpm build for libvirt PMDA needs Python libvirt and lxml modules
1095     if $pcp_python_prog -c "import libvirt" >/dev/null 2>&1
1096     then
1097         if $pcp_python_prog -c "import lxml" >/dev/null 2>&1
1098         then
1099             pmda_libvirt=true
1100         fi
1101     fi
1103 AC_SUBST(PMDA_LIBVIRT, $pmda_libvirt)
1104 if $pmda_libvirt; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1106 qmake=$QMAKE
1107 enable_qt=false
1108 qt_release=release
1109 AS_IF([test "x$do_qt" != "xno"], [
1110     enable_qt=true
1111     
1112     if test -z "$QMAKE"
1113     then
1114         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])
1115         test "x$cc_is_gcc" = xyes -a $target_os = solaris && QMAKE="$QMAKE -spec solaris-g++"
1116     fi
1117     qmake=$QMAKE
1118     if test -z "$QMAKE"
1119     then
1120         enable_qt=false
1121     else
1122         AC_MSG_CHECKING([Qt version])
1123         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 }'`
1124         AC_MSG_RESULT([$QT_MAJOR.$QT_MINOR.$QT_POINT])
1125         if test "$QT_MAJOR" -lt 4; then
1126             echo WARNING: Qt version 4.4 or later does not seem to be installed.
1127             echo Cannot proceed with the Qt $QT_MAJOR installation found.
1128             enable_qt=false
1129         fi
1130         if test "$QT_MAJOR" -eq 4 -a "$QT_MINOR" -lt 4 ; then
1131             echo WARNING: Qt version 4.$QT_MINOR is too old.
1132             echo Qt version 4.4 or later is required for Qt builds.
1133             enable_qt=false
1134         fi
1135     fi
1137     if test "$do_qt" != "check" -a "$enable_qt" != "true"
1138     then
1139         AC_MSG_ERROR([cannot enable Qt - no supported Qt installation found])
1140     elif test "$enable_qt" = "true" -a "x$cxx" = "x"
1141     then
1142         enable_qt=false
1143         test "$do_qt" != "check" && \
1144         AC_MSG_ERROR([C++ compiler unavailable, cannot build Qt components])
1145     elif test "$do_qt" = "debug"
1146     then
1147         dnl Debug/release style build? (non-debug by default)
1148         qt_release=debug
1149         enable_qt=true
1150     fi
1152 AC_SUBST(qt_release)
1153 AC_SUBST(enable_qt)
1154 AC_SUBST(qmake)
1156 enable_qt3d=false
1157 AS_IF([test "x$do_qt3d" != "xno"], [
1158     if test -f /usr/include/Coin3/Inventor/Qt/SoQt.h
1159     then
1160         enable_qt3d=$enable_qt
1161     elif test -a "$do_qt3d" = "yes"
1162     then
1163         AC_MSG_ERROR([cannot enable support for 3D scene graph API])
1164     fi
1166 AC_SUBST(enable_qt3d)
1168 dnl check if user wants their own make program
1169 dnl note: all makefiles in this package use the gmake syntax
1170 if test -z "$MAKE"
1171 then
1172     AC_PATH_PROG(MAKE, gmake)
1173     if test -z "$MAKE" 
1174     then
1175         # look elsewhere ...
1176         AC_MSG_CHECKING([for GNU make elsewhere])
1177         for f in /usr/local/bin/gmake /usr/freeware/bin/gmake /usr/local/bin/make /opt/sfw/bin/gmake nowhere
1178         do
1179             if test -x $f
1180             then
1181                 MAKE=$f
1182                 break
1183             fi
1184         done
1185         if test $f = nowhere
1186         then
1187             # Check if /usr/bin/make is any good
1188             mver=`/usr/bin/make --version 2>/dev/null | sed -n -e1p | cut -c1-8`
1189             if test "$mver" != "GNU Make"
1190             then
1191                 echo
1192                 echo "FATAL ERROR: could not find GNU make anywhere"
1193                 echo "You need to set \$MAKE as the full path to GNU make "
1194                 echo "in the environment."
1195                 rm -rf conftest conftest.*
1196                 exit 1
1197             else
1198                 MAKE=/usr/bin/make
1199             fi
1200         fi
1201         AC_MSG_RESULT($MAKE)
1202     fi 
1204 make=$MAKE
1205 AC_SUBST(make)
1207 dnl check if users wants their own CPP
1208 if test -z "$CPP"; then
1209     AC_PROG_CPP
1211 cpp=$CPP
1212 AC_SUBST(cpp)
1214 dnl check if users wants their own linker
1215 if test -z "$LD"; then
1216     AC_PATH_PROG(LD, ld, /usr/bin/ld)
1218 ld=$LD
1219 AC_SUBST(ld)
1221 dnl Provide ways to override owner and group for installed files
1222 if test -z "$PCP_USER_INSTALL" ; then
1223     pcp_user_install=root
1224 else
1225     pcp_user_install="$PCP_USER_INSTALL"
1227 AC_SUBST(pcp_user_install)
1228 if test -z "$PCP_GROUP_INSTALL" ; then
1229     case "$target_os"
1230     in
1231         darwin|freebsd|netbsd|openbsd)
1232             pcp_group_install=wheel
1233             ;;
1234         *)
1235             pcp_group_install=root
1236             ;;
1237     esac
1238 else
1239     pcp_group_install="$PCP_GROUP_INSTALL"
1241 AC_SUBST(pcp_group_install)
1243 dnl check if the tar program is available
1244 if test -z "$TAR"; then
1245     AC_PATH_PROGS(TAR, gtar tar, tar)
1247 if test $target_os = darwin -a -x /usr/bin/gnutar
1248 then
1249     TAR=/usr/bin/gnutar
1251 tar=$TAR
1252 AC_SUBST(tar)
1254 dnl check if the gzip program is available
1255 dnl (needed to gzip man pages on some platforms)
1256 if test -z "$ZIP"; then
1257     AC_PATH_PROG(ZIP, gzip, /bin/gzip)
1259 test ! -x "$ZIP" && ZIP=/usr/local/bin/gzip
1260 test ! -x "$ZIP" && ZIP=/usr/freeware/bin/gzip
1261 test ! -x "$ZIP" && ZIP=/usr/bin/gzip
1262 gzip=$ZIP
1263 test -z "$gzip" && gzip=no-gzip
1264 AC_SUBST(gzip)
1266 dnl check if the bzip2 program is available
1267 dnl (needed to bzip2 man pages on some platforms)
1268 if test -z "$BZIP2"; then
1269     AC_PATH_PROG(BZIP2, bzip2, /bin/bzip2)
1271 test ! -x "$BZIP2" && BZIP2=/usr/bin/bzip2
1272 test ! -x "$BZIP2" && BZIP2=/usr/local/bin/bzip2
1273 test ! -x "$BZIP2" && BZIP2=/usr/freeware/bin/bzip2
1274 bzip2=$BZIP2
1275 test -z "$bzip2" && bzip2=no-bzip2
1276 AC_SUBST(bzip2)
1278 dnl check if the lzma program is available
1279 dnl (needed to lzma man pages on some platforms)
1280 if test -z "$LZMA"; then
1281     AC_PATH_PROG(LZMA, lzma, /bin/lzma)
1283 test ! -x "$LZMA" && LZMA=/usr/bin/lzma
1284 test ! -x "$LZMA" && LZMA=/usr/local/bin/lzma
1285 test ! -x "$LZMA" && LZMA=/usr/freeware/bin/lzma
1286 lzma=$LZMA
1287 test -z "$lzma" && lzma=no-lzma
1288 AC_SUBST(lzma)
1290 dnl check if the xz program is available
1291 dnl (needed to xz man pages on some platforms)
1292 if test -z "$XZ"; then
1293     AC_PATH_PROG(XZ, xz, /bin/xz)
1295 test ! -x "$XZ" && XZ=/usr/bin/xz
1296 test ! -x "$XZ" && XZ=/usr/local/bin/xz
1297 test ! -x "$XZ" && XZ=/usr/freeware/bin/xz
1298 xz=$XZ
1299 test -z "$xz" && xz=no-xz
1300 AC_SUBST(xz)
1302 dnl Check for mac PackageMaker
1303 AC_MSG_CHECKING([for PackageMaker])
1304 if test -z "$PACKAGE_MAKER"
1305 then
1306     if test $target_os = darwin
1307     then
1308         if test -x /Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1309         then # local XCode extras install
1310             package_maker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1311             AC_MSG_RESULT([ yes (local install)])
1312         elif test -x /Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1313         then # Darwin 6.x
1314             package_maker=/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1315             AC_MSG_RESULT([ yes (darwin 6.x)])
1316         elif test -x /Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
1317         then # Darwin 7.x
1318             AC_MSG_RESULT([ yes (darwin 7.x)])
1319             package_maker=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
1320         else
1321             AC_MSG_RESULT([ not found!])
1322             AC_MSG_WARN([PackageMaker not found, mac packages will not be made])
1323         fi
1324     else
1325         AC_MSG_RESULT([ no])    
1326     fi
1327 else
1328     package_maker="$PACKAGE_MAKER"
1330 AC_SUBST(package_maker)
1332 dnl check if the hdiutil program is available
1333 if test -z "$HDIUTIL"; then
1334     AC_PATH_PROG(HDIUTIL, hdiutil)
1336 hdiutil=$HDIUTIL
1337 AC_SUBST(hdiutil)
1339 dnl check if the mkinstallp program is available (AIX)
1340 if test -z "$MKINSTALLP"; then
1341     AC_PATH_PROG(MKINSTALLP, mkinstallp)
1343 mkinstallp=$MKINSTALLP
1344 AC_SUBST(mkinstallp)
1346 dnl check for the Solaris pmgmk package maker
1347 if test -z "$PKGMK"; then
1348     AC_PATH_PROG(PKGMK, pkgmk)
1350 pkgmk=$PKGMK
1351 AC_SUBST(pkgmk)
1353 dnl check if the dlltool program is available
1354 if test -z "$DLLTOOL"; then
1355     AC_PATH_PROG(DLLTOOL, dlltool)
1357 dlltool=$DLLTOOL
1358 AC_SUBST(dlltool)
1360 dnl check if the rpmbuild program is available
1361 if test -z "$RPMBUILD"; then
1362     AC_PATH_PROG(RPMBUILD, rpmbuild)
1364 test $target_distro = slackware && RPMBUILD=''
1365 rpmbuild=$RPMBUILD
1366 AC_SUBST(rpmbuild)
1368 dnl check if the rpm program is available
1369 if test -z "$RPM"; then
1370     AC_PATH_PROG(RPM, rpm)
1372 test $target_distro = slackware && RPM=''
1373 rpm=$RPM
1374 AC_SUBST(rpm)
1376 dnl if rpmbuild exists, use it, otherwise use rpm
1377 if test -n "$RPMBUILD" -a -x "$RPMBUILD"
1378 then
1379     rpmprog=$RPMBUILD
1380 else
1381     rpmprog=$RPM
1383 AC_SUBST(rpmprog)
1385 dnl check if the pod2man program is available (perl man page builder)
1386 if test -z "$POD2MAN"; then
1387     AC_PATH_PROG(POD2MAN, pod2man)
1389 pod2man=$POD2MAN
1390 AC_SUBST(pod2man)
1392 dnl extra check for the Perl MakeMaker package
1393 AC_MSG_CHECKING([if ExtUtils::MakeMaker is installed])
1394 perl -e "use ExtUtils::MakeMaker" 2>/dev/null
1395 if test $? -eq 0
1396 then
1397     AC_MSG_RESULT([ yes])
1398 else
1399     AC_MSG_RESULT([ no])
1400     echo
1401     echo "FATAL ERROR: Perl ExtUtils::MakeMaker module missing."
1402     echo "You can either install this from your distribution, or"
1403     echo "download from CPAN (Comprehensive Perl Archive Network)."
1404     rm -rf conftest conftest.*
1405     exit 1
1408 AC_PATH_PROG(TRUEPROG, true)
1410 dnl check if the makedepend program is available
1411 if test -z "$MAKEDEPEND"; then
1412     AC_PATH_PROG(MAKEDEPEND, makedepend, $TRUEPROG)
1414 makedepend=$MAKEDEPEND
1415 AC_SUBST(makedepend)
1417 dnl check if the md5sum program is available
1418 if test -z "$MD5SUM"; then
1419    AC_PATH_PROG(MD5SUM, md5sum, $TRUEPROG)
1421 md5sum=$MD5SUM
1422 AC_SUBST(md5sum)
1424 dnl check if the Debian dpkg program is available
1425 if test -z "$DPKG"; then
1426    AC_PATH_PROG(DPKG, dpkg)
1428 dpkg=$DKPG
1429 AC_SUBST(dpkg)
1431 dnl check for the Slackware makepkg packaging tool
1432 if test -z "$MAKEPKG"; then
1433    AC_PATH_PROG(MAKEPKG, makepkg)
1435 makepkg=$MAKEPKG
1436 AC_SUBST(makepkg)
1438 dnl check if a toolchain is available for the books
1439 test -z "$PUBLICAN" && AC_PATH_PROG(PUBLICAN, publican)
1440 publican=$PUBLICAN
1441 AC_SUBST(publican)
1442 test -z "$DBLATEX" && AC_PATH_PROG(DBLATEX, dblatex)
1443 dblatex=$DBLATEX
1444 AC_SUBST(dblatex)
1445 test -z "$XMLTO" && AC_PATH_PROG(XMLTO, xmlto)
1446 xmlto=$XMLTO
1447 AC_SUBST(xmlto)
1449 book_toolchain=""
1450 if test "$do_books" = "check" -o "$do_books" = "yes"
1451 then
1452     if test "$BOOK_TOOLCHAIN" != ""
1453     then
1454         book_toolchain=$BOOK_TOOLCHAIN
1455     elif test "$DBLATEX" != ""
1456     then
1457         book_toolchain=dblatex
1458     elif test "$PUBLICAN" != ""
1459     then
1460         book_toolchain=publican
1461     elif test "$XMLTO" != ""
1462     then
1463         book_toolchain=xmlto
1464     elif test "$do_books" = "yes"
1465     then
1466         AC_MSG_ERROR([cannot enable books build - no toolchain found])
1467     fi
1469 AC_SUBST(book_toolchain)
1471 book_brand="common"
1472 if test "$do_books_brand" != ""
1473 then
1474     book_brand=$do_books_brand
1476 AC_SUBST(book_brand)
1478 dnl check if symbolic links are supported
1479 AC_PROG_LN_S
1480 if test $target_os = mingw; then
1481     as_ln_s=/bin/true
1484 dnl if /proc is not mounted, try and mount it
1485 dnl before trying to run the ps style test below
1486 if test -d /proc
1487 then
1488     test -f /proc/stat || mount /proc >/dev/null 2>&1
1491 dnl set platform specific ps
1492 if test -n "$PROCPS"
1493 then
1494     pcp_ps_prog="$PROCPS"
1495 else
1496     pcp_ps_prog=ps
1498 AC_SUBST(pcp_ps_prog)
1500 dnl set platform specific event logger
1501 if test $target_os = mingw
1502 then
1503     pcp_syslog_prog=pcp-eventlog
1504 else
1505     pcp_syslog_prog=logger
1507 AC_SUBST(pcp_syslog_prog)
1509 grep=grep
1510 if test $target_os = solaris
1511 then
1512     test -f /usr/xpg4/bin/grep && grep=/usr/xpg4/bin/grep
1514 AC_SUBST(grep)
1516 dnl checks for /proc pseudo file system
1517 AC_MSG_CHECKING([for /proc ])
1518 if test "$cross_compiling" = "yes"; then
1519     ans=$have_procfs
1520     echo "cross-compile -> \"$ans\"" >&5
1521 elif test -d /proc
1522 then
1523     have_procfs=true
1524 else
1525     have_procfs=false
1527 if $have_procfs
1528 then
1529     AC_MSG_RESULT(yes)
1530     AC_DEFINE(HAVE_PROCFS, [1], [Support for /proc pseudo-filesystem])
1531 else
1532     AC_MSG_RESULT(no)
1535 dnl Checks for C header files.
1536 AC_HEADER_DIRENT
1537 AC_HEADER_STDC
1538 AC_HEADER_SYS_WAIT
1539 AC_CHECK_HEADERS(fcntl.h limits.h malloc.h strings.h syslog.h)
1540 AC_CHECK_HEADERS(stddef.h sched.h dlfcn.h dl.h)
1541 AC_CHECK_HEADERS(sys/times.h sys/resource.h sys/prctl.h)
1542 AC_CHECK_HEADERS(sys/sysinfo.h sys/systeminfo.h)
1543 AC_CHECK_HEADERS(endian.h standards.h sys/byteorder.h)
1544 AC_CHECK_HEADERS(libgen.h sys/mman.h sys/un.h)
1545 AC_CHECK_HEADERS(values.h stdint.h ieeefp.h math.h)
1546 AC_CHECK_HEADERS(pwd.h grp.h regex.h sys/wait.h)
1547 AC_CHECK_HEADERS(termio.h termios.h sys/termios.h)
1548 AC_CHECK_HEADERS(sys/ioctl.h sys/select.h sys/socket.h)
1549 AC_CHECK_HEADERS(netdb.h)
1550 if test $target_os = darwin -o $target_os = openbsd
1551 then
1552     AC_CHECK_HEADERS(net/if.h, [], [], [#include <sys/types.h>
1553 #include <sys/socket.h>])
1554 else
1555     AC_CHECK_HEADERS(net/if.h)
1557 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h arpa/inet.h)
1558 AC_CHECK_HEADERS(windows.h winsock2.h ws2tcpip.h)
1559 AC_CHECK_HEADERS(execinfo.h bits/wordsize.h)
1560 AC_CHECK_HEADERS(iptypes.h, [], [], [#include <windows.h>])
1561 AC_CHECK_HEADERS(iphlpapi.h, [], [], [#include <winsock2.h>])
1562 AC_CHECK_HEADERS(fts.h libzfs.h)
1563 AC_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/mount.h)
1565 dnl Check if we have <sys/endian.h> ... standard way
1566 AC_MSG_CHECKING([for sys/endian.h ])
1567 AC_TRY_COMPILE(
1568 [  
1569     #include <sys/endian.h> 
1572 ], AC_DEFINE(HAVE_SYS_ENDIAN_H, [1], [sys/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1574 dnl Check if we have <machine/endian.h> ... MacOSX way
1575 AC_MSG_CHECKING([for machine/endian.h ])
1576 AC_TRY_COMPILE(
1577 [  
1578     #include <machine/endian.h> 
1581 ], AC_DEFINE(HAVE_MACHINE_ENDIAN_H, [1], [machine/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1583 dnl Check if we have <sys/endian.h> ... IRIX strangeness
1584 AC_MSG_CHECKING([for sys/endian.h (IRIX variant) ])
1585 AC_TRY_COMPILE(
1586 [  
1587     #include <standards.h>
1588     #include <sys/endian.h> 
1591 ], AC_DEFINE(HAVE_SYS_ENDIAN_H, [1], [IRIX sys/endian.h]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1593 dnl Checks for typedefs, structures, and compiler characteristics.
1594 AC_C_CONST
1595 AC_TYPE_OFF_T
1596 AC_TYPE_PID_T
1597 AC_TYPE_SIZE_T
1598 AC_HEADER_TIME
1599 AC_STRUCT_TM
1600 AC_C_INLINE
1602 dnl check if regex functions come from libregex (mingw)
1603 AC_CHECK_LIB(regex, regcomp)
1604 lib_for_regex=""
1605 if test $ac_cv_lib_regex_regcomp = yes
1606 then
1607     lib_for_regex="-lregex"
1609 AC_SUBST(lib_for_regex)
1611 PKG_CHECK_MODULES([ncurses], [ncurses], [have_ncurses=true], [have_ncurses=false])
1612 AC_SUBST(HAVE_NCURSES, [$have_ncurses])
1614 PKG_CHECK_MODULES([SYSTEMD], [libsystemd],
1615                   [pmda_systemd=true], [pmda_systemd=false])
1616 if $pmda_systemd
1617 then
1618     :
1619 else
1620     dnl libsystemd-journal is an alternative for older distros
1621     PKG_CHECK_MODULES([SYSTEMD], [libsystemd-journal],
1622                       [pmda_systemd=true], [pmda_systemd=false])
1624 AC_MSG_CHECKING([if the systemd PMDA should be included])
1625 AC_SUBST(PMDA_SYSTEMD, $pmda_systemd)
1626 if $pmda_systemd; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1628 pmda_infiniband=false
1629 AS_IF([test "x$do_infiniband" != "xno"], [
1630     AC_CHECK_HEADERS([infiniband/umad.h], [
1631         AC_CHECK_HEADERS([infiniband/mad.h], [pmda_infiniband=true], [])
1632     ], [])
1633     savedLIBS=$LIBS
1634     IB_LIBS=""
1635     AC_CHECK_LIB(ibmad, madrpc_init)
1636     AC_CHECK_LIB(ibumad, umad_init)
1637     if test $ac_cv_lib_ibmad_madrpc_init = yes -a $ac_cv_lib_ibumad_umad_init = yes
1638     then
1639         IB_LIBS="-libmad -libumad"
1640         LIBS="$IB_LIBS"
1641         AC_MSG_CHECKING([for port_performance_query_via])
1642         AC_TRY_LINK_FUNC(port_performance_query_via,
1643                 AC_DEFINE(HAVE_PORT_PERFORMANCE_QUERY_VIA, [1], [port_performance_query_via API])
1644                 have_port_performance_query_via=true
1645                 AC_MSG_RESULT(yes),
1646                 have_port_performance_query_via=false
1647                 AC_MSG_RESULT(no))
1648         AC_MSG_CHECKING([for pma_query_via])
1649         AC_TRY_LINK_FUNC(pma_query_via,
1650                 AC_DEFINE(HAVE_PMA_QUERY_VIA, [1], [pma_query_via API])
1651                 have_pma_query_via=true
1652                 AC_MSG_RESULT(yes),
1653                 have_pma_query_via=false
1654                 AC_MSG_RESULT(no))
1655         LIBS=$savedLIBS
1656         if test $have_pma_query_via -o $have_port_performance_query_via
1657         then
1658             :
1659         else
1660             pmda_infiniband=false
1661         fi
1662     else
1663         pmda_infiniband=false
1664     fi
1665     LIBS=$savedLIBS
1666     AC_SUBST(IB_LIBS)
1668 AC_MSG_CHECKING([if the infiniband PMDA should be included])
1669 AC_SUBST(PMDA_INFINIBAND, $pmda_infiniband)
1670 if $pmda_infiniband; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1672 pmda_papi=false
1673 AS_IF([test "x$do_papi" != "xno"], [
1674     enable_papi=true
1676     saved_LDFLAGS="$LDFLAGS"
1677     saved_CFLAGS="$CFLAGS"
1678     savedLIBS=$LIBS
1680     dnl potentially from the environment, else empty
1681     CFLAGS="$papi_CFLAGS"
1682     LDFLAGS="$papi_LIBS"
1684     case "$do_papi" in
1685         yes|no|check)
1686             ;;
1687         */*)
1688             PAPI_ROOTDIR=$do_papi;
1689             CFLAGS="-I$PAPI_ROOTDIR/include"
1690             LDFLAGS="-L$PAPI_ROOTDIR/lib"
1691             ;;
1692          *)
1693             PKG_CHECK_MODULES(papi,[$do_papi],[
1694                   CFLAGS="$papi_CFLAGS"
1695                   LDFLAGS="$papi_LIBS"])
1696             ;;
1697     esac
1699     # $papi_LIBS may include -lpapi harmlessly redudantly with AC_CHECK_LIB
1700     AC_CHECK_LIB([papi], [PAPI_library_init],
1701                  [papi_libs="$LDFLAGS -lpapi"],
1702                  [enable_papi=false])
1703     AC_CHECK_HEADERS([papi.h], [papi_cflags="$CFLAGS"], [enable_papi=false])
1704     if test "$do_papi" != "check" -a "$enable_papi" != "true"
1705     then
1706         AC_MSG_ERROR([PAPI is not installed, cannot enable the PAPI PMDA])
1707     else
1708         pmda_papi=$enable_papi
1709     fi
1710     LIBS=$savedLIBS
1711     CFLAGS="$saved_CFLAGS"
1712     LDFLAGS="$saved_LDFLAGS"
1713     AC_SUBST(PAPI_CFLAGS, $papi_cflags)
1714     AC_SUBST(PAPI_LIBS, $papi_libs)
1716 AC_MSG_CHECKING([if the papi PMDA should be included])
1717 AC_SUBST(PMDA_PAPI, $pmda_papi)
1718 if $pmda_papi; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1720 AS_IF([test "x$pmda_papi" = "xtrue"], [
1721         dnl check if struct PAPI_component_info_t has a disabled field
1722         AC_MSG_CHECKING([whether struct PAPI_component_info_t has a disabled field])
1723 cat <<End-of-File >conftest.c
1724 #include <papi.h>
1725 int main() { PAPI_component_info_t *c; c->disabled = 0; }
1726 End-of-File
1727         (eval $ac_compile) 2>conftest.out
1728         cat conftest.out >&5
1729         if test -s conftest.out
1730         then
1731            AC_MSG_RESULT(no)
1732         else
1733            AC_DEFINE(HAVE_PAPI_DISABLED_COMP, [1], [PAPI_component_info_t field])
1734            AC_MSG_RESULT(yes)
1736         fi
1737         rm -f conftest.*
1740 pmda_perfevent=false
1741 AS_IF([test "x$do_perfevent" != "xno" ], [
1742     enable_perfevent=true
1744     savedLIBS=$LIBS
1745     AC_CHECK_LIB([pfm], [pfm_get_os_event_encoding],
1746                  [pfm_libs="-lpfm"],
1747                  [enable_perfevent=false])
1748     AC_CHECK_HEADERS([perfmon/pfmlib_perf_event.h], [], [enable_perfevent=false])
1749     if test "$do_perfevent" != "check" -a "$enable_perfevent" != "true"
1750     then
1751         AC_MSG_ERROR([libpfm is not installed, cannot enable the perfevent PMDA])
1752     else
1753         pmda_perfevent=$enable_perfevent
1754     fi
1755     LIBS=$savedLIBS
1756     AC_SUBST(PFM_LIBS, $pfm_libs)
1758 AC_MSG_CHECKING([if the perfevent PMDA should be included])
1759 AC_SUBST(PMDA_PERFEVENT, $pmda_perfevent)
1760 if $pmda_perfevent; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1762 dnl Do you have RPM Package Manager libraries for pmdarpm?
1763 pmda_rpm=false
1764 savedLIBS=$LIBS
1765 AC_MSG_CHECKING([for rpmlib > 4.4.2])
1766 AC_COMPILE_IFELSE(
1767    [AC_LANG_PROGRAM([[#include <rpm/header.h>]],
1768                     [[(void)HEADERGET_EXT;]])],
1769    [AC_MSG_RESULT([yes])
1770     pmda_rpm=true],
1771    [AC_MSG_RESULT([no])])
1772 AC_MSG_CHECKING([if the rpm PMDA should be included])
1773 AC_SUBST(PMDA_RPM,$pmda_rpm)
1774 if $pmda_rpm; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1775 LIBS=$savedLIBS
1777 dnl Do you have the required qshape script for the postfix PMDA
1778 dnl The logic here is copied from the PMDA's Install script
1779 pmda_postfix=false
1780 AC_CHECK_PROGS(QSHAPE, qshape, [], path=[$PATH:/usr/sbin])
1781 AC_MSG_CHECKING([if the postfix PMDA should be included])
1782 if test -n "$QSHAPE"
1783 then
1784     pmda_postfix=true
1785 else
1786     for script in /usr/share/doc/packages/postfix-doc/auxiliary/qshape/qshape.pl
1787     do
1788         if test -f "$script"
1789         then
1790             pmda_postfix=true
1791             break
1792         fi
1793     done
1795 AC_SUBST(PMDA_POSTFIX,$pmda_postfix)
1796 if $pmda_postfix; then AC_MSG_RESULT(yes); else AC_MSG_RESULT(no); fi
1798 dnl Do you have system microhttpd libraries for pmwebapi?
1799 PKG_CHECK_MODULES([libmicrohttpd], [libmicrohttpd > 0.9.9], [have_libmicrohttpd=true], [have_libmicrohttpd=false])
1800 AC_SUBST(HAVE_LIBMICROHTTPD, [$have_libmicrohttpd])
1802 dnl Do you have graphics libraries for pmwebapi?
1803 PKG_CHECK_MODULES([cairo], [cairo >= 1.2, cairo-ft >= 1.2, cairo-png >= 1.2], [have_cairo=true], [have_cairo=false])
1804 AC_SUBST(HAVE_CAIRO, [$have_cairo])
1806 enable_webapi=false
1807 AS_IF([test "x$do_webapi" != "xno"], [
1808     enable_webapi=true
1810     if test "$have_libmicrohttpd" != "true"
1811     then
1812         enable_webapi=false
1813         test "$do_webapi" != "check" && \
1814         AC_MSG_ERROR([libmicrohttpd is not installed, cannot enable the web API])
1815     elif test "$do_webapi" != "check" -a "x$cxx" = "x"
1816     then
1817         enable_webapi=false
1818         test "$do_webapi" != "check" && \
1819         AC_MSG_ERROR([C++ compiler unavailable, cannot enable the web API])
1820     fi
1822 AC_SUBST(enable_webapi)
1824 enable_manager=false
1825 AS_IF([test "x$do_manager" != "xno"], [
1826     enable_manager=true
1828     if test "$target_os" = "mingw"
1829     then
1830         enable_manager=false
1831         test "$do_manager" != "check" && \
1832         AC_MSG_ERROR([MinGW build, cannot enable daemon manager])
1833     elif test "x$cxx" = "x"
1834     then
1835         enable_manager=false
1836         test "$do_manager" != "check" && \
1837         AC_MSG_ERROR([C++ compiler unavailable, cannot enable daemon manager])
1838     fi
1839     AC_MSG_CHECKING([compilation features for daemon manager])
1840     AC_TRY_COMPILE(
1841         [ #ifndef _XOPEN_SOURCE
1842           #define _XOPEN_SOURCE 600
1843           #endif
1844           #include <stdio.h>
1845         ], [],
1846         AC_MSG_RESULT(yes),
1847         enable_manager=false
1848         AC_MSG_RESULT(no))
1850 AC_SUBST(enable_manager)
1852 AC_CHECK_PROGS(SEINFO, seinfo)
1853 AC_SUBST(SEINFO)
1854 enable_selinux=false
1855 AS_IF([test "x$do_selinux" != "xno"], [
1856 for makefile in /usr/share/selinux/devel/Makefile
1858     if test -f "$makefile" -a "x$SEINFO" != "x"
1859     then
1860         enable_selinux=true
1861     fi
1862 done
1864 AC_SUBST(enable_selinux)
1865 AC_SUBST(pcp_selinux_dir)
1868 dnl Checks for library functions.
1869 AC_TYPE_SIGNAL
1870 AC_FUNC_WAIT3
1871 AC_FUNC_VPRINTF
1872 AC_CHECK_FUNCS(mktime nanosleep usleep unsetenv)
1873 AC_CHECK_FUNCS(select socket gethostname getpeerucred getpeereid)
1874 AC_CHECK_FUNCS(uname syslog __clone pipe2 fcntl ioctl)
1875 AC_CHECK_FUNCS(prctl setlinebuf waitpid atexit kill)
1876 AC_CHECK_FUNCS(chown fchmod getcwd scandir mkstemp)
1877 AC_CHECK_FUNCS(brk sbrk posix_memalign memalign valloc)
1878 AC_CHECK_FUNCS(signal sighold sigrelse tcgetattr)
1879 AC_CHECK_FUNCS(regex regcmp regexec regcomp)
1880 AC_CHECK_FUNCS(strtod strtol strtoll strtoull strndup strchrnul)
1881 AC_CHECK_FUNCS(getuid getgid)
1882 AC_CHECK_FUNCS(getgrent getgrent_r getgrnam getgrnam_r getgrgid getgrgid_r)
1883 AC_CHECK_FUNCS(getpwent getpwent_r getpwnam getpwnam_r getpwuid getpwuid_r)
1884 AC_CHECK_FUNCS(sysinfo trace_back_stack backtrace)
1885 AC_CHECK_FUNCS(sendmsg recvmsg setns)
1887 dnl only define readdir64 on non-linux platforms that support it
1888 if test $target_os != linux -a $target_os != freebsd -a $target_os != kfreebsd -a $target_os != netbsd; then
1889     AC_CHECK_FUNCS(readdir64)
1892 dnl typedefs missing from sys/types.h, stdlib.h or stddef.h
1893 if test $target_os = solaris
1894 then
1895    AC_CHECK_TYPE(__int32_t, int32_t)
1896    AC_CHECK_TYPE(__uint32_t, uint32_t)
1897    AC_CHECK_TYPE(__int64_t, int64_t)
1898    AC_CHECK_TYPE(__uint64_t, uint64_t)
1899    AC_CHECK_TYPE(uint_t, u_int32_t)
1900 else
1901     AC_CHECK_TYPE(__int32_t, int)
1902     AC_CHECK_TYPE(__uint32_t, unsigned int)
1903     AC_CHECK_TYPE(__int64_t, long long)
1904     AC_CHECK_TYPE(__uint64_t, unsigned long long)
1905     AC_CHECK_TYPE(uint_t, unsigned int)
1908 dnl check if we have a type for the pointer's size integer (__psint_t)
1909 AC_MSG_CHECKING([for __psint_t ])
1910 AC_TRY_COMPILE(
1911 [  
1912     #include <sys/types.h>
1913     #include <stdlib.h> 
1914     #include <stddef.h>
1915 ], [ __psint_t psint; ],
1916 AC_DEFINE(HAVE___PSINT_T, [1], [__psint_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1918 dnl check if we have a type for pointer difference (ptrdiff_t)
1919 AC_MSG_CHECKING([for ptrdiff_t ])
1920 AC_TRY_COMPILE([
1921     #include <stddef.h>
1922     #ifdef HAVE_MALLOC_H
1923     #include <malloc.h>
1924     #endif
1925 ], [ ptrdiff_t ptrdiff; ],
1926 AC_DEFINE(HAVE_PTRDIFF_T, [1], [ptrdiff_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1928 dnl check if we have types for uid_t, gid_t (POSIX) or SID (Win32)
1929 AC_MSG_CHECKING([for uid_t ])
1930 AC_TRY_COMPILE([
1931     #include <sys/types.h>
1932     #ifdef HAVE_PWD_H
1933     #include <pwd.h>
1934     #endif
1935 ], [ uid_t uid; ],
1936 AC_DEFINE(HAVE_UID_T, [1], [uid_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1937 AC_MSG_CHECKING([for gid_t ])
1938 AC_TRY_COMPILE([
1939     #include <sys/types.h>
1940     #ifdef HAVE_GRP_H
1941     #include <grp.h>
1942     #endif
1943 ], [ gid_t gid; ],
1944 AC_DEFINE(HAVE_GID_T, [1], [gid_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1945 AC_MSG_CHECKING([for SID ])
1946 AC_TRY_COMPILE([
1947     #ifdef HAVE_WINDOWS_H
1948     #include <windows.h>
1949     #endif
1950 ], [ SID sid; ],
1951 AC_DEFINE(HAVE_SID, [1], [sid type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1953 dnl check if we have a type for socklen_t
1954 AC_MSG_CHECKING([for socklen_t ])
1955 AC_TRY_COMPILE([
1956     #include <sys/types.h>
1957     #ifdef HAVE_SYS_SOCKET_H
1958     #include <sys/socket.h>
1959     #endif
1960 ], [ socklen_t len; ],
1961 AC_DEFINE(HAVE_SOCKLEN_T, [1], [socklen_t type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1963 dnl check if LL suffix on constants is supported
1964 AC_TRY_COMPILE([
1965     #include <stdio.h>
1966 ], [ long long x = 0LL; ],
1967 AC_DEFINE(HAVE_CONST_LONGLONG, [1], [LL suffix on constants]))
1969 dnl check if _environ is declared globally
1970 AC_TRY_LINK([
1971     #include <stdlib.h>
1972     #include <unistd.h>
1973 ], [ char **x = _environ; ],
1974 AC_DEFINE(HAVE_UNDERBAR_ENVIRON, [1], [_environ declared globally]))
1976 dnl check for PR_TERMCHILD and PR_SET_PDEATHSIG in <sys/prctl.h>
1977 AC_MSG_CHECKING([for PR_TERMCHILD constant in sys/prctl.h])
1978 AC_TRY_COMPILE([
1979     #ifdef HAVE_SYS_PRCTL_H
1980     #include <sys/prctl.h>
1981     #endif
1982 ], [ int i = PR_TERMCHILD; ],
1983 AC_DEFINE(HAVE_PR_TERMCHILD, [1], [PR_TERMCHILD constant]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1985 AC_MSG_CHECKING([for PR_SET_PDEATHSIG constant in sys/prctl.h])
1986 AC_TRY_COMPILE([
1987     #ifdef HAVE_SYS_PRCTL_H
1988     #include <sys/prctl.h>
1989     #endif
1990 ], [ int i = PR_SET_PDEATHSIG; ],
1991 AC_DEFINE(HAVE_PR_SET_PDEATHSIG, [1], [PR_SET_PDEATHSIG constant]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
1993 AC_HEADER_TIOCGWINSZ
1995 dnl check if linker needs -rdynamic for dynamically loaded shared
1996 dnl libraries to see the symbols in the process loading them.
1997 dnl This is e.g., needed on linux for pmcd loading pmda_pmcd.so.
1998 AC_MSG_CHECKING([if linker supports -rdynamic])
1999 save_CFLAGS="$CFLAGS"
2000 CFLAGS="-rdynamic"
2001 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
2002     [AC_MSG_RESULT([yes])
2003      rdynamic_flag=-rdynamic],
2004     [AC_MSG_RESULT([no])
2005      rdynamic_flag=]
2007 CFLAGS="$save_CFLAGS"
2008 AC_SUBST([rdynamic_flag])
2011 dnl check if argument to user's select() method in scandir call is const
2012 AC_MSG_CHECKING([whether const arg for scandir() select method])
2013 cat <<End-of-File >conftest.c
2014 #include <stdlib.h>
2015 #include <unistd.h>
2016 #include <dirent.h>
2017 static int
2018 my_select(const struct dirent *foo) { return 0; }
2019 int main() { struct dirent **list; return scandir(".", &list, my_select, NULL); }
2020 End-of-File
2021 (eval $ac_compile) 2>conftest.out
2022 cat conftest.out >&5
2023 if test -s conftest.out
2024 then
2025     AC_MSG_RESULT(no)
2026 else
2027     AC_DEFINE(HAVE_CONST_DIRENT, [1], [const arg for scandir() select method])
2028     AC_MSG_RESULT(yes)
2030 rm -f conftest.*
2032 dnl check if struct dirent has a d_off (directory offset) field
2033 AC_MSG_CHECKING([whether struct dirent has a d_off field])
2034 cat <<End-of-File >conftest.c
2035 #include <stdlib.h>
2036 #include <unistd.h>
2037 #include <dirent.h>
2038 int main() { struct dirent d; d.d_off = 0; }
2039 End-of-File
2040 (eval $ac_compile) 2>conftest.out
2041 cat conftest.out >&5
2042 if test -s conftest.out
2043 then
2044     AC_MSG_RESULT(no)
2045 else
2046     AC_DEFINE(HAVE_DIRENT_D_OFF, [1], [struct dirent d_off field])
2047     AC_MSG_RESULT(yes)
2049 rm -f conftest.*
2051 dnl check if printf %p has 0x prefix
2052 AC_MSG_CHECKING([if printf %p produces 0x prefix])
2053 if test "$cross_compiling" = "yes"; then
2054     ans=$printf_p_prefix
2055     echo "cross-compile -> \"$ans\"" >&5
2056 else
2057     cat <<End-of-File >conftest.c
2058 #include <stdio.h>
2059 int main(int argc,  char **argv) { printf("%p", argv); return(0); }
2060 End-of-File
2061     (eval $ac_compile) 2>&5
2062     (eval $ac_link) 2>&5
2063     ans=`./conftest`
2064     echo "./conftest -> \"$ans\"" >&5
2066 case "$ans"
2068     0x*)
2069         AC_DEFINE(HAVE_PRINTF_P_PFX, [1], [printf %p produces 0x])
2070         AC_MSG_RESULT(yes)
2071         ;;
2072     *)
2073         AC_MSG_RESULT(no)
2074         ;;
2075 esac
2076 rm -rf conftest conftest.*
2078 _do_type()
2080     # need to deal with this sort of cpp output ...
2081     #   typedef long pid_t;
2082     #   typedef unsigned int pid_t;
2083     #   typedef unsigned int pid_t __attribute__ ((__mode__ (__SI__)));
2084     #   __extension__ typedef int pid_t;
2085     #   typedef foo_t
2086     #                  pid_t;
2087     #   typedef struct {
2088     #         ....
2089     #   } pid_t;
2090     #   typedef ... *pid;
2091     # and chaining of the form
2092     #   typedef long __pid_t;
2093     #   typedef __pid_t pid_t;
2094     #
2095     _raw=`$CPP conftest.c \
2096     | $SED \
2097         -e 's/[[        ]]__attribute__ ((.*));/;/' \
2098         -e 's/__extension__[[   ]][[    ]]*//' \
2099     | $AWK '
2100 /bozo/          { print; next }
2101 $1 == "typedef" { printf "%s",$0
2102                   if ($NF ~ /;$/) {
2103                       print ""
2104                       next
2105                   }
2106                   wantsemi = 1
2107                   if ($0 ~ /{/) depth = 1
2108                   next
2109                 }
2110 wantsemi == 1   { printf " %s",$0
2111                   if ($0 ~ /{/) depth++
2112                   if (depth) {
2113                       if ($0 ~ /}/) depth--
2114                       if (depth > 0) next
2115                   }
2116                   if ($NF ~ /;$/) {
2117                       print ""
2118                       wantsemi = 0
2119                       next
2120                   }
2121                 }' \
2122     | $SED \
2123         -e 's/\*/* /g' \
2124         -e 's/^[[       ]]*//' \
2125         -e 's/;[[       ]]*$//' \
2126     | $AWK '
2127 $1 == "typedef" { map[[$NF]] = ""
2128                   for (i = 2; i < NF; i++) {
2129                     if (i == 2)
2130                         map[[$NF]] = $i
2131                     else
2132                         map[[$NF]] = map[[$NF]] " " $i
2133                   }
2134                   print $NF " -> " map[[$NF]] >"conftest.debug"
2135                   next
2136                 }
2137 $2 == "bozo"    { t = $1
2138                   printf "best guess: %s",t >"conftest.debug"
2139                   while (map[[t]] != "") {
2140                     t = map[[t]]
2141                     printf " -> %s",t >"conftest.debug"
2142                   }
2143                   print "" >"conftest.debug"
2144                   print t
2145                   exit
2146                 }'`
2147     case "$_raw"
2148     in
2149     int)
2150         _fmt='"d"'
2151         ;;
2152     unsigned|'unsigned int')
2153         _fmt='"u"'
2154         ;;
2155     long|'long int')
2156         _fmt='"ld"'
2157         ;;
2158     'long long'|'long long int')
2159         if test $target_os = mingw; then
2160             _fmt='"I64d"'
2161         else
2162             _fmt='"lld"'
2163         fi
2164         ;;
2165     'unsigned long'|'unsigned long int'|'long unsigned int')
2166         _fmt='"lu"'
2167         ;;
2168     'unsigned long long'|'unsigned long long int')
2169         if test $target_os = mingw; then
2170             _fmt='"I64u"'
2171         else
2172             _fmt='"llu"'
2173         fi
2174         ;;
2175     *\*)        # pointer to a something
2176         _fmt='"p"'
2177         ;;
2178     struct\ *)  # not much can be done here ...
2179         _fmt='"p"'
2180         ;;
2181     *)
2182         echo
2183         echo "FATAL ERROR: don't know what to do with type \"$_raw\""
2184         echo "... typedef mapping ..."
2185         cat conftest.debug
2186         rm -rf conftest conftest.*
2187         exit 1
2188         ;;
2189     esac
2192 dnl printf type for pid_t
2193 AC_MSG_CHECKING([printf type for pid_t])
2194 if test "$cross_compiling" = "yes"; then
2195     ans=$printf_fmt_pid
2196     echo "cross-compile -> \"$ans\"" >&5
2197     fmt_pid="$ans"
2198 else
2199     cat <<End-of-File >conftest.c
2200 #include <sys/types.h>
2201 #include <unistd.h>
2202 pid_t bozo;
2203 End-of-File
2204     _do_type
2205     fmt_pid="$_fmt"
2207 AC_MSG_RESULT($fmt_pid)
2208 AC_SUBST(fmt_pid)
2209 rm -rf conftest.c conftest.debug
2211 dnl printf type for int64_t
2212 AC_MSG_CHECKING([printf type for int64_t ])
2213 if test "$cross_compiling" = "yes"; then
2214     ans=$printf_fmt_int64
2215     echo "cross-compile -> \"$ans\"" >&5
2216 else
2217     cat <<End-of-File >conftest.c
2218 #include <stdio.h>
2219 #include <stdint.h>
2220 #include <inttypes.h>
2221 int main()
2223     printf("\"%s\"\n", __PRI64_PREFIX "d");
2224     return(0);
2226 End-of-File
2227     ans=''
2228     (eval $ac_link) 2>&5
2229     if test -x ./conftest
2230     then
2231         ans=`./conftest`
2232         echo "./conftest -> \"$ans\"" >&5
2233     fi
2234     if test -z "$ans"
2235     then
2236         dnl have to try the hardway ...
2237         cat <<End-of-File >conftest.c
2238 #include <stdio.h>
2239 #include <stdint.h>
2240 #include <string.h>
2241 int main()
2243     char buf[[17]];
2244     int64_t bozo = 0x12345678abcdLL;
2245     sprintf(buf, "%lx", bozo);
2246     if (strcmp(buf, "12345678abcd") == 0)
2247         printf("\"ld\"\n");
2248     else {
2249         sprintf(buf, "%llx", bozo);
2250         if (strcmp(buf, "12345678abcd") == 0)
2251             printf("\"lld\"\n");
2252     }
2253     return(0);
2255 End-of-File
2256         (eval $ac_link) 2>&5
2257         if test -x ./conftest
2258         then
2259             ans=`./conftest`
2260             echo "./conftest -> \"$ans\"" >&5
2261         fi
2262     fi
2264 if test -z "$ans"
2265 then
2266     echo 'FATAL ERROR: Cannot determine printf format for int64_t type'
2267     rm -rf conftest conftest.*
2268     exit 1
2270 fmt_int64="$ans"
2271 AC_MSG_RESULT("$fmt_int64")
2272 AC_SUBST(fmt_int64)
2273 dnl and the unsigned version of this ...
2274 fmt_uint64=`echo $fmt_int64 | sed -e 's/d"/u"/'`
2275 AC_SUBST(fmt_uint64)
2276 rm -rf conftest.* conftest
2278 AC_MSG_CHECKING([strtol or strtoll for int64_t])
2279 if test "$cross_compiling" = "yes"; then
2280     ans=$strtoint64
2281     echo "cross-compile -> \"$ans\"" >&5
2282 else
2283     cat <<End-of-File >conftest.c
2284 #include <stdio.h>
2285 #include <stdlib.h>
2286 main()
2288     long long int       value = -1;
2289     value = strtol("1234567812345678", NULL, 16);
2290     if (value == 0x1234567812345678LL) {
2291         printf("strotol\n");
2292         exit(0);
2293     }
2294     value = strtoll("1234567812345678", NULL, 16);
2295     if (value == 0x1234567812345678LL) {
2296         printf("strtoll\n");
2297         exit(0);
2298     }
2299     exit(1);
2301 End-of-File
2302     (eval $ac_compile) 2>&5
2303     (eval $ac_link) 2>&5
2304     ans=`./conftest`
2305     echo "./conftest -> \"$ans\"" >&5
2307 case "$ans"
2309     strtol)
2310         AC_DEFINE(strtoint64, strtol)
2311         AC_DEFINE(strtouint64, strtoul)
2312         AC_MSG_RESULT([strtol])
2313         ;;
2314     strtoll)
2315         AC_DEFINE(strtoint64, strtoll)
2316         AC_DEFINE(strtouint64, strtoull)
2317         AC_MSG_RESULT([strtoll])
2318         ;;
2319     *)
2320         AC_DEFINE(strtoint64, strtoll)
2321         AC_DEFINE(strtouint64, strtoull)
2322         AC_MSG_RESULT([assuming strtoll])
2323         ;;
2324 esac
2325 rm -rf conftest conftest.*
2327 if test "$do_threads" = "check" -o "$do_threads" = "yes"
2328 then
2329     AC_CHECK_HEADERS(
2330         pthread.h,
2331         [],
2332         [
2333             if test "$do_threads" = "yes"
2334             then
2335                 AC_MSG_ERROR([cannot enable multi-threaded mode - no pthread.h])
2336             fi
2337         ])
2339     dnl Check if pthread_mutex_t is defined in pthread.h
2340     dnl Ignore the fact that pthread.h could be missing - we don't
2341     dnl really care if this test fails because of missing pthread_mutex_t
2342     dnl or because of missing headers.
2343     AC_MSG_CHECKING([for pthread_mutex_t in pthread.h])
2344     AC_TRY_COMPILE(
2345         [#include <pthread.h>], [pthread_mutex_t mymutex;],
2346         AC_DEFINE(HAVE_PTHREAD_MUTEX_T, [1], [pthread_mutex_t type]) AC_MSG_RESULT(yes),
2347         [
2348             if test "$do_threads" = "yes"
2349             then
2350                 AC_MSG_ERROR([cannot enable multi-threaded mode - no mutexes])
2351             else
2352                 AC_MSG_RESULT(no)
2353             fi
2354         ])
2356     dnl Check which library provide pthread stuff
2357     AC_MSG_CHECKING([where pthread_create() is defined])
2358     for cand in "" pthreads pthread ; do
2359         savedLIBS=$LIBS
2360         if test -n "$cand" 
2361         then
2362             LIBS=`echo $LIBS -l$cand`
2363         fi
2364         AC_TRY_LINK(
2365         [
2366             #include <pthread.h>
2367         ],
2368         [
2369             pthread_create(NULL, NULL, NULL, NULL);
2370         ],  AC_MSG_RESULT(lib${cand:-c})
2371             if test -z "$cand"
2372             then
2373                 lib_for_pthreads="$cand"
2374             else
2375                 lib_for_pthreads="-l$cand"
2376             fi
2377             LIBS=$savedLIBS
2378             break )
2379         LIBS=$savedLIBS
2380     done
2381     AC_SUBST(lib_for_pthreads)
2383     if test "$ac_cv_header_pthread_h" = "yes"
2384     then
2385         dnl printf type for pthread_t
2386         AC_MSG_CHECKING([printf type for pthread_t])
2387         cat <<End-of-File >conftest.c
2388 #include <pthread.h>
2389 pthread_t bozo;
2390 End-of-File
2391         _do_type
2392         fmt_pthread="$_fmt"
2393         AC_MSG_RESULT($fmt_pthread)
2394         AC_SUBST(fmt_pthread)
2395         rm -rf conftest.c conftest.debug
2397         dnl check if gcc supports __thread for thread private data
2398         AC_MSG_CHECKING([if compiler supports __thread])
2399         dnl __thread support is broken in some places
2400         if test $target_os = netbsd
2401         then
2402             AC_TRY_COMPILE([#include <pthread.h>
2403 #if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 5 )
2404 broken!
2405 #else
2406 __thread int x;
2407 #endif], [],
2408                 AC_DEFINE(HAVE___THREAD, [1], [__thread private data]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2409         else
2410             AC_TRY_COMPILE([#include <pthread.h>
2411 __thread int x;], [],
2412                 AC_DEFINE(HAVE___THREAD, [1], [__thread private data]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
2413         fi
2415         dnl Check if pthread_barrier_t is defined in pthread.h
2416         AC_MSG_CHECKING([for pthread_barrier_t in pthread.h])
2417         AC_TRY_COMPILE([#include <pthread.h>], [pthread_barrier_t mybarrier;],
2418             AC_DEFINE(HAVE_PTHREAD_BARRIER_T, [1], [pthread_barrier_t type]) AC_MSG_RESULT(yes),
2419             AC_MSG_RESULT(no))
2420     fi
2423 AC_MSG_CHECKING([sizeof suseconds_t])
2424 if test "$cross_compiling" = "yes"; then
2425     ans=$sizeof_suseconds_t
2426     echo "cross-compile -> \"$ans\"" >&5
2427 else
2428     cat <<End-of-File >conftest.c
2429 #include <sys/time.h>
2430 main() { printf("%d", (int)sizeof(suseconds_t)); }
2431 End-of-File
2432     (eval $ac_compile) 2>&5
2433     (eval $ac_link) 2>&5
2434     ans=`./conftest`
2435     echo "./conftest -> \"$ans\"" >&5
2436     rm -rf conftest conftest.*
2438 AC_MSG_RESULT($ans)
2439 AC_DEFINE_UNQUOTED(SIZEOF_SUSECONDS_T, $ans, [sizeof suseconds_t])
2441 AC_MSG_CHECKING([sizeof time_t])
2442 if test "$cross_compiling" = "yes"; then
2443     ans=$sizeof_time_t
2444     echo "cross-compile -> \"$ans\"" >&5
2445 else
2446     cat <<End-of-File >conftest.c
2447 #include <sys/time.h>
2448 main() { printf("%d", (int)sizeof(time_t)); }
2449 End-of-File
2450     (eval $ac_compile) 2>&5
2451     (eval $ac_link) 2>&5
2452     ans=`./conftest`
2453     echo "./conftest -> \"$ans\"" >&5
2454     rm -rf conftest conftest.*
2456 AC_MSG_RESULT($ans)
2457 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ans, [sizeof time_t])
2459 dnl check sizeof long
2460 AC_MSG_CHECKING([sizeof long])
2461 if test "$cross_compiling" = "yes"; then
2462     ans=$sizeof_long
2463     echo "cross-compile -> \"$ans\"" >&5
2464 else
2465     cat <<End-of-File >conftest.c
2466 #include <stdio.h>
2467 main() { printf("%d", (int)sizeof(long)); }
2468 End-of-File
2469     (eval $ac_compile) 2>&5
2470     (eval $ac_link) 2>&5
2471     ans=`./conftest`
2472     echo "./conftest -> \"$ans\"" >&5
2474 AC_MSG_RESULT($ans)
2475 if test "$ans" = 4; then
2476     AC_DEFINE(HAVE_32BIT_LONG, [1], [sizeof long])
2477 elif test "$ans" = 8; then
2478     AC_DEFINE(HAVE_64BIT_LONG, [1], [sizeof long])
2479 else
2480     echo
2481     echo "FATAL ERROR: size of long is not 32 or 64 bits, cannot proceed."
2482     echo "sizeof(char *) -> $ans"
2483     rm -rf conftest conftest.*
2484     exit 1
2486 rm -rf conftest conftest.*
2488 dnl check sizeof pointer
2489 AC_MSG_CHECKING([sizeof pointer])
2490 if test "$cross_compiling" = "yes"; then
2491     ans=$sizeof_pointer
2492     echo "cross-compile -> \"$ans\"" >&5
2493 else
2494     cat <<End-of-File >conftest.c
2495 #include <stdio.h>
2496 main() { printf("%d", (int)sizeof(char *)); }
2497 End-of-File
2498     (eval $ac_compile) 2>&5
2499     (eval $ac_link) 2>&5
2500     ans=`./conftest`
2501     echo "./conftest -> \"$ans\"" >&5
2503 AC_MSG_RESULT($ans)
2504 if test "$ans" = 4; then
2505     AC_DEFINE(HAVE_32BIT_PTR, [1], [pointer size])
2506     PCP_PTR_SIZE=32
2507 elif test "$ans" = 8; then
2508     AC_DEFINE(HAVE_64BIT_PTR, [1], [pointer size])
2509     PCP_PTR_SIZE=64
2510 else
2511     echo
2512     echo "FATAL ERROR: size of pointer is not 32 or 64 bits, cannot proceed."
2513     echo "sizeof(char *) -> $ans"
2514     rm -rf conftest conftest.*
2515     exit 1
2517 rm -rf conftest conftest.*
2519 dnl check sizeof int. If not 32, we die
2520 AC_MSG_CHECKING([sizeof int])
2521 if test "$cross_compiling" = "yes"; then
2522     ans=$sizeof_int
2523     echo "cross-compile -> \"$ans\"" >&5
2524 else
2525     cat <<End-of-File >conftest.c
2526 #include <stdio.h>
2527 main() { printf("%d", (int)sizeof(int)); }
2528 End-of-File
2529     (eval $ac_compile) 2>&5
2530     (eval $ac_link) 2>&5
2531     ans=`./conftest`
2532     echo "./conftest -> \"$ans\"" >&5
2534 AC_MSG_RESULT($ans)
2535 if test "$ans" != 4
2536 then
2537     echo
2538     echo "FATAL ERROR: sizeof(int) is not 32 bits, cannot proceed."
2539     echo "Note: 32-bit ints are assumed in the PCP external file formats and"
2540     echo "      the over-the-wire PDU formats"
2541     rm -rf conftest conftest.*
2542     exit 1
2544 rm -rf conftest conftest.*
2546 dnl check bit field allocation order within a word
2547 AC_MSG_CHECKING([if bit fields allocated left-to-right])
2548 if test "$cross_compiling" = "yes"; then
2549     ans=$bit_field_scheme
2550     echo "cross-compile -> \"$ans\"" >&5
2551 else
2552     cat <<End-of-File >conftest.c
2553 union { struct { unsigned int b:4; unsigned int c:4; } a; int p; } u;
2554 main() { u.a.b = 1; u.a.c = 2; printf("%0*x", 2*sizeof(int), u.p); }
2555 End-of-File
2556     (eval $ac_compile) 2>&5
2557     (eval $ac_link) 2>&5
2558     ans=`./conftest`
2559     echo "./conftest -> \"$ans\"" >&5
2561 case "$ans"
2563     1200*|*0012)
2564         # left-to-right starting from MSB (SGI cc on MIPS), or
2565         # left-to-right ending at LSB
2566         AC_DEFINE(HAVE_BITFIELDS_LTOR, [1], [left-to-right bitfield ordering])
2567         AC_MSG_RESULT(yes)
2568         ;;
2569     2100*|*0021)
2570         # right-to-left ending at MSB, or
2571         # right-to-left starting from LSB (gcc in Intel)
2572         AC_MSG_RESULT(no)
2573         ;;
2574     *)
2575         AC_MSG_RESULT(unknown)
2576         echo "FATAL ERROR: could not fathom your compiler's bit field allocation scheme"
2577         rm -f conftest conftest.*
2578         exit 1
2579         ;;
2580 esac
2581 rm -rf conftest conftest.*
2583 dnl check if compiler can cast __uint64_t to double
2584 AC_TRY_LINK(
2586     #include <stdlib.h>
2587     #include <unistd.h>
2590     __uint64_t x = 0;
2591     double y = (double)x;
2592 ], AC_DEFINE(HAVE_CAST_U64_DOUBLE, [1], [compiler casts u64 to double]))
2594 dnl check if basename and dirname need -lgen, -lpcp or nothing to work
2595 dnl (assume both go together)
2596 AC_CHECK_FUNCS(basename)
2597 if test $ac_cv_func_basename = yes
2598 then
2599     AC_DEFINE(HAVE_BASENAME, [1], [basename API])
2600     AC_DEFINE(HAVE_DIRNAME, [1], [dirname API])
2601     lib_for_basename=""
2602 else
2603     AC_CHECK_LIB(gen, basename)
2604     if test $ac_cv_lib_gen_basename = yes
2605     then
2606         AC_DEFINE(HAVE_BASENAME, [1], [basename API])
2607         AC_DEFINE(HAVE_DIRNAME, [1], [dirname API])
2608         lib_for_basename="-lgen"
2609     else
2610         lib_for_basename="-lpcp"
2611     fi
2613 AC_SUBST(lib_for_basename)
2615 dnl check if clock_gettime needs -lrt to work
2616 lib_for_clock_gettime=
2617 AC_CHECK_FUNCS(clock_gettime)
2618 if test $ac_cv_func_clock_gettime = no
2619 then
2620     AC_CHECK_LIB(rt, clock_gettime)
2621     if test $ac_cv_lib_rt_clock_gettime = yes
2622     then
2623         AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [clock_gettime API])
2624         lib_for_rt=-lrt
2625     fi
2627 AC_SUBST(lib_for_rt)
2629 dnl check if dlopen et al need -ldl to work
2630 lib_for_dlopen=
2631 AC_CHECK_FUNCS(dlopen)
2632 if test $ac_cv_func_dlopen = no
2633 then
2634     AC_CHECK_LIB(dl, dlopen)
2635     if test $ac_cv_lib_dl_dlopen = yes
2636     then
2637         AC_DEFINE(HAVE_DLOPEN, [1], [dlopen API])
2638         lib_for_dlopen=-ldl
2639     fi
2641 AC_SUBST(lib_for_dlopen)
2643 dnl check if flog10, pow, fpclassify and isnanf are available
2644 dnl in the maths library
2645 lib_for_math=
2646 AC_CHECK_FUNCS(flog10)
2647 if test $ac_cv_func_flog10 = no
2648 then
2649     AC_CHECK_LIB(m, flog10)
2650     if test $ac_cv_lib_m_flog10 = yes
2651     then
2652         AC_DEFINE(HAVE_FLOG10, [1], [flog10 math API])
2653         lib_for_math=-lm
2654     fi
2655 else
2656     AC_DEFINE(HAVE_FLOG10, [1], [flog10 math API])
2658 AC_CHECK_FUNCS(pow)
2659 if test $ac_cv_func_pow = no
2660 then
2661     AC_CHECK_LIB(m, pow)
2662     if test $ac_cv_lib_m_pow = yes
2663     then
2664         AC_DEFINE(HAVE_POW, [1], [pow math API])
2665         lib_for_math=-lm
2666     fi
2667 else
2668     AC_DEFINE(HAVE_POW, [1], [pow math API])
2670 AC_MSG_CHECKING([for fpclassify()])
2671 ac_cv_func_fpclassify=no
2672 AC_TRY_LINK(
2674     #include <math.h>
2677     double x = 123.456;
2678     if (fpclassify(x) == FP_NAN) exit(1);
2679 ], ac_cv_func_fpclassify=yes)
2680 AC_MSG_RESULT($ac_cv_func_fpclassify)
2681 if test $ac_cv_func_fpclassify = no
2682 then
2683     dnl try with -lm
2684     AC_MSG_CHECKING([for fpclassify() with -lm])
2685     savedLIBS=$LIBS
2686     LIBS=-lm
2687     AC_TRY_LINK(
2689     #include <math.h>
2692     double x = 123.456;
2693     if (fpclassify(x) == FP_NAN) exit(1);
2694 ], ac_cv_func_fpclassify=yes)
2695     AC_MSG_RESULT($ac_cv_func_fpclassify)
2696     if test $ac_cv_func_fpclassify = yes
2697     then
2698         lib_for_math=-lm
2699     fi
2700     LIBS=$savedLIBS
2702 if test $ac_cv_func_fpclassify = yes
2703 then
2704     AC_DEFINE(HAVE_FPCLASSIFY, [1], [fpclassify math API])
2705 else
2706     dnl prefer fpclassify() but will take isnan() and isnanf() as
2707     dnl possible alternates
2708     AC_CHECK_FUNCS(isnan)
2709     if test $ac_cv_func_isnan = no
2710     then
2711         AC_CHECK_LIB(m, isnan)
2712         if test $ac_cv_lib_m_isnan = yes
2713         then
2714             AC_DEFINE(HAVE_ISNAN, [1], [isnan math API])
2715             lib_for_math=-lm
2716         fi
2717     fi
2718     AC_CHECK_FUNCS(isnanf)
2719     if test $ac_cv_func_isnanf = no
2720     then
2721         AC_CHECK_LIB(m, isnanf)
2722         if test $ac_cv_lib_m_isnanf = yes
2723         then
2724             AC_DEFINE(HAVE_ISNANF, [1], [isnanf math API])
2725             lib_for_math=-lm
2726         fi
2727     fi
2729 AC_SUBST(lib_for_math)
2731 dnl check if we have the SIG_PF typedef
2732 AC_TRY_LINK([#include <signal.h>], [SIG_PF x;],
2733     AC_DEFINE(HAVE_SIGPF, [1], [SIG_PF typedef]))
2735 dnl check if we have the SA_SIGINFO #define
2736 AC_TRY_LINK([#include <signal.h>], [int x = SA_SIGINFO;],
2737     AC_DEFINE(HAVE_SA_SIGINFO, [1], [SA_SIGINFO macro]))
2739 dnl check if we support the SIGPIPE signal
2740 AC_TRY_LINK([#include <signal.h>], [int x = SIGPIPE;],
2741     AC_DEFINE(HAVE_SIGPIPE, [1], [SIGPIPE signal]))
2743 dnl check if we support the SIGHUP signal
2744 AC_TRY_LINK([#include <signal.h>], [int x = SIGHUP;],
2745     AC_DEFINE(HAVE_SIGHUP, [1], [SIGHUP signal]))
2747 dnl check if we support the SIGBUS signal
2748 AC_TRY_LINK([#include <signal.h>], [int x = SIGBUS;],
2749     AC_DEFINE(HAVE_SIGBUS, [1], [SIGBUS signal]))
2751 dnl check if we need to explicitly include signal.h
2752 AC_TRY_LINK([#include <sys/wait.h>],
2753 [   typedef void (*SIGRET)(int);
2754     SIGRET x = SIG_IGN;
2755 ], AC_DEFINE(HAVE_WAIT_INCLUDES_SIGNAL, [1], [indirect signal.h]))
2757 dnl check for name and type of time fields in struct stat
2758 dnl IRIX example        timespec_t st_mtim;     
2759 dnl Linux example       struct timespec st_mtim;
2760 dnl Darwin example      struct timespec st_mtimespec;
2761 dnl Solaris example     timestruc_t st_mtim;
2762 dnl FreeBSD (6.1)       struct timespec st_mtimespec;
2763 dnl                     struct timespec {
2764 dnl                             time_t tv_sec;
2765 dnl                             long tv_nsec;
2766 dnl                     };
2768 have_stat_type=false
2769 have_stat_name=false
2770 if test $have_stat_name = false
2771 then
2772     AC_EGREP_HEADER(
2773     changequote(<<, >>)<<[      ]st_mtimespec>>changequote([, ]),
2774     sys/stat.h, [ have_stat_name=true;
2775     AC_DEFINE(HAVE_ST_MTIME_WITH_SPEC, [1], [st_mtimespec stat field]) ])
2777 if test $have_stat_name = false -a $target_os != darwin -a $target_os != linux -a $target_os != kfreebsd -a $target_os != netbsd
2778 then
2779     AC_EGREP_HEADER(
2780     changequote(<<, >>)<<[      ]st_mtime>>changequote([, ]),
2781     sys/stat.h, [ have_stat_name=true;
2782     AC_DEFINE(HAVE_ST_MTIME_WITH_E, [1], [st_mtime stat field]) ])
2784 if test $have_stat_type = false
2785 then
2786     AC_EGREP_HEADER(
2787     changequote(<<, >>)<<timestruc_t[   ][      ]*st_mtim>>changequote([, ]),
2788     sys/stat.h, [ have_stat_type=true;
2789     AC_DEFINE(HAVE_STAT_TIMESTRUC, [1], [timestruc_t type]) ])
2791 if test $have_stat_type = false
2792 then
2793     AC_EGREP_HEADER(
2794     changequote(<<, >>)<<timespec_t[    ][      ]*st_mtim>>changequote([, ]),
2795     sys/stat.h, [ have_stat_type=true;
2796     AC_DEFINE(HAVE_STAT_TIMESPEC_T, [1], [timespec_t type]) ])
2798 if test $have_stat_type = false
2799 then
2800     AC_EGREP_HEADER(
2801     changequote(<<, >>)<<timespec[      ][      ]*st_mtim>>changequote([, ]),
2802     sys/stat.h, [ have_stat_type=true;
2803     AC_DEFINE(HAVE_STAT_TIMESPEC, [1], [timespec type]) ])
2805 if test $have_stat_type = false
2806 then
2807     AC_EGREP_HEADER(
2808     changequote(<<, >>)<<time_t[        ][      ]*st_mtim>>changequote([, ]),
2809     sys/stat.h, [ have_stat_type=true;
2810     AC_DEFINE(HAVE_STAT_TIME_T, [1], [time_t type]) ])
2812 if test $have_stat_type = false
2813 then
2814     echo 'FATAL ERROR: Cannot determine struct stat time types.'
2815     rm -rf conftest conftest.*
2816     exit 1
2820 dnl Work out where to install stuff for this package
2821 dnl (and where to find stuff at run-time for add-on packages).
2825 dnl Predictable directory containing pcp.conf, or overridden
2826 dnl by the $PCP_CONF environment variable. If this is not set
2827 dnl (default /etc/pcp.conf), then $PCP_CONF must be set in
2828 dnl the environment.
2830 dnl The eval echo stuff is used to get around unfavourable
2831 dnl elements of the GNU standards, which cause embedding of
2832 dnl ${prefix} within many of these various $dirs.
2833 dnl http://www.gnu.org/software/autoconf/manual/autoconf.html#Installation-Directory-Variables
2835 pcp_etc_dir=`eval echo $sysconfdir`
2836 pcp_etc_dir=`eval echo $pcp_etc_dir`
2837 AC_SUBST(pcp_etc_dir)
2838 pcp_saslconf_dir=`eval echo $sysconfdir/sasl2`
2839 pcp_saslconf_dir=`eval echo $pcp_saslconf_dir`
2840 AC_SUBST(pcp_saslconf_dir)
2841 pcp_sysconf_dir=`eval echo $sysconfdir/pcp`
2842 pcp_sysconf_dir=`eval echo $pcp_sysconf_dir`
2843 AC_SUBST(pcp_sysconf_dir)
2844 pcp_pmcdconf_path=$pcp_sysconf_dir/pmcd/pmcd.conf
2845 pcp_pmcdrclocal_path=$pcp_sysconf_dir/pmcd/rc.local
2846 pcp_pmcdoptions_path=$pcp_sysconf_dir/pmcd/pmcd.options
2847 pcp_pmwebdoptions_path=$pcp_sysconf_dir/pmwebd/pmwebd.options
2848 pcp_pmmgroptions_path=$pcp_sysconf_dir/pmmgr/pmmgr.options
2849 pcp_pmproxyoptions_path=$pcp_sysconf_dir/pmproxy/pmproxy.options
2850 pcp_pmiecontrol_path=$pcp_sysconf_dir/pmie/control
2851 pcp_pmsnapcontrol_path=$pcp_sysconf_dir/pmsnap/control
2852 pcp_pmloggercontrol_path=$pcp_sysconf_dir/pmlogger/control
2853 AC_SUBST(pcp_pmcdconf_path)
2854 AC_SUBST(pcp_pmcdoptions_path)
2855 AC_SUBST(pcp_pmcdrclocal_path)
2856 AC_SUBST(pcp_pmwebdoptions_path)
2857 AC_SUBST(pcp_pmmgroptions_path)
2858 AC_SUBST(pcp_pmproxyoptions_path)
2859 AC_SUBST(pcp_pmiecontrol_path)
2860 AC_SUBST(pcp_pmsnapcontrol_path)
2861 AC_SUBST(pcp_pmloggercontrol_path)
2863 dnl shared PCP files (shareable for diskless)
2864 pcp_share_dir=`eval echo $datarootdir/pcp`
2865 pcp_share_dir=`eval echo $pcp_share_dir`
2866 AC_SUBST(pcp_share_dir)
2868 dnl private PCP executables
2869 pcp_binadm_dir=`eval echo $libexecdir/pcp/bin`
2870 pcp_binadm_dir=`eval echo $pcp_binadm_dir`
2871 AC_SUBST(pcp_binadm_dir)
2873 dnl non-shared (i.e. system local) PCP files
2874 pcp_var_dir=`eval echo $localstatedir/lib/pcp`
2875 pcp_var_dir=`eval echo $pcp_var_dir`
2876 AC_SUBST(pcp_var_dir)
2878 dnl pmcd control and options files
2879 AC_ARG_WITH(configdir,[AC_HELP_STRING([--with-configdir],[configuration directory [LOCALSTATEDIR/pcp/config]])],
2880                       [pcp_config_dir=$withval],
2881                       [pcp_config_dir=$pcp_var_dir/config])
2883 pcp_pmdas_dir=$pcp_var_dir/pmdas
2884 AC_SUBST(pcp_pmdas_dir)
2886 pcp_selinux_dir=$pcp_var_dir/selinux
2887 AC_SUBST(pcp_selinux_dir)
2889 dnl runtime shared libraries
2890 pcp_lib_dir=`eval echo $libdir`
2891 pcp_lib_dir=`eval echo $pcp_lib_dir`
2892 pcp_lib32_dir=`echo $pcp_lib_dir | sed -e s,64,, -e s,//,/,`
2893 AC_SUBST(pcp_lib_dir)
2894 AC_SUBST(pcp_lib32_dir)
2896 dnl perl modules
2897 AC_ARG_WITH(perl_installdirs,[AC_HELP_STRING([--with-perl_installdirs],[perl installdirs [vendor]])],
2898                       [perl_installdirs=$withval],
2899                       [perl_installdirs=vendor])
2900 perl_installdirs=`eval echo $perl_installdirs`
2901 perl_installdirs=`eval echo $perl_installdirs`
2902 AC_SUBST(perl_installdirs)
2903 AC_ARG_WITH(perl_install_base,[AC_HELP_STRING([--with-perl_install_base],[perl install_base [PREFIX]])],
2904                       [perl_install_base=$withval],
2905                       [perl_install_base=$prefix])
2906 perl_install_base=`eval echo $perl_install_base`
2907 perl_install_base=`eval echo $perl_install_base`
2908 AC_SUBST(perl_install_base)
2910 AC_ARG_WITH(python_prefix,[AC_HELP_STRING([--with-python_prefix],[python setup.py prefix [PREFIX]])],
2911                       [python_prefix=$withval],
2912                       [python_prefix=$prefix])
2913 python_prefix=`eval echo $python_prefix`
2914 python_prefix=`eval echo $python_prefix`
2915 AC_SUBST(python_prefix)
2917 AC_PATH_XTRA
2918 pcp_x11_incflags=$X_CFLAGS
2919 AC_SUBST(pcp_x11_incflags)
2920 pcp_x11_libflags=$X_LIBS
2921 AC_SUBST(pcp_x11_libflags)
2922 pcp_x11_extra=$X_EXTRA_LIBS
2923 AC_SUBST(pcp_x11_extra)
2924 pcp_x11_pre=$X_PRE_LIBS
2925 AC_SUBST(pcp_x11_pre)
2927 dnl man pages (source)
2928 have_manpages=false
2929 have_gzipped_manpages=false
2930 have_bzip2ed_manpages=false
2931 have_lzmaed_manpages=false
2932 have_xzed_manpages=false
2933 need_old_tbl_header=false
2934 man_header=
2935 pcp_man_dir=`eval echo $mandir`
2936 pcp_man_dir=`eval echo $pcp_man_dir`
2938 dnl guess compression in use
2939 for d in /usr/man /usr/share/man $pcp_man_dir
2941     for sd in man1 sman1
2942     do
2943         if test -f $d/$sd/man.1.gz
2944         then
2945             have_gzipped_manpages=true
2946             have_manpages=true
2947             man_header=`$ZIP -d < $d/$sd/man.1.gz | head -1`
2948             break
2949         elif test -f $d/$sd/man.1.bz2
2950         then
2951             have_bzip2ed_manpages=true
2952             have_manpages=true
2953             man_header=`$BZIP2 -d < $d/$sd/man.1.bz2 | head -1`
2954             break
2955         elif test -f $d/$sd/man.1.lzma
2956         then
2957             have_lzmaed_manpages=true
2958             have_manpages=true
2959             man_header=`$LZMA -d < $d/$sd/man.1.lzma | head -1`
2960             break
2961         elif test -f $d/$sd/man.1.xz
2962         then
2963             have_xzed_manpages=true
2964             have_manpages=true
2965             man_header=`$XZ -d < $d/$sd/man.1.xz | head -1`
2966             break
2967         elif test -f $d/$sd/man.1
2968         then
2969             man_header=`head -1 $d/$sd/man.1`
2970             have_manpages=true
2971             break
2972         fi
2973     done
2974 done
2975 if test x"$man_header" = "x'\\\" t" -o x"$man_header" = "x'\\\" te" ; then
2976     need_old_tbl_header=true
2978 AC_SUBST(pcp_man_dir)
2979 AC_SUBST(have_manpages)
2980 AC_SUBST(have_gzipped_manpages)
2981 AC_SUBST(have_bzip2ed_manpages)
2982 AC_SUBST(have_lzmaed_manpages)
2983 AC_SUBST(have_xzed_manpages)
2984 AC_SUBST(need_old_tbl_header)
2986 dnl public binaries
2987 pcp_bin_dir=`eval echo $bindir`
2988 pcp_bin_dir=`eval echo $pcp_bin_dir`
2989 AC_SUBST(pcp_bin_dir)
2991 pcp_sbin_dir=`eval echo $sbindir`
2992 pcp_sbin_dir=`eval echo $pcp_sbin_dir`
2993 AC_SUBST(pcp_sbin_dir)
2995 dnl include files
2996 pcp_inc_dir=`eval echo $includedir/pcp`
2997 pcp_inc_dir=`eval echo $pcp_inc_dir`
2998 AC_SUBST(pcp_inc_dir)
3000 dnl books - pdfs, html
3001 if test $target_os = linux; then
3002     pcp_books_dir=`eval echo $datarootdir/doc/pcp-doc`
3003 else
3004     pcp_books_dir=`eval echo $datarootdir/doc/pcp`
3006 pcp_books_dir=`eval echo $pcp_books_dir`
3007 pcp_html_dir=`eval echo $pcp_books_dir/html`
3008 AC_SUBST(pcp_books_dir)
3009 AC_SUBST(pcp_html_dir)
3011 dnl icon pixmap files
3012 if test $target_os = linux; then
3013     pcp_icons_dir=`eval echo $datarootdir/pcp-gui/pixmaps`
3014 else
3015     pcp_icons_dir=`eval echo $datarootdir/pcp/pixmaps`
3017 pcp_icons_dir=`eval echo $pcp_icons_dir`
3018 AC_SUBST(pcp_icons_dir)
3020 dnl desktop application entries
3021 pcp_desktop_dir=`eval echo $datarootdir/applications`
3022 pcp_desktop_dir=`eval echo $pcp_desktop_dir`
3023 AC_SUBST(pcp_desktop_dir)
3025 dnl rc/startup files
3026 AC_ARG_WITH(rcdir,[AC_HELP_STRING([--with-rcdir],[rc directory [SYSCONFDIR/rc.d]])],
3027                   [pcp_rc_dir=$withval], [
3028 if $enable_systemd
3029 then
3030     pcp_rc_dir="$pcp_share_dir/lib"
3031 else
3032     pcp_rc_dir="$pcp_etc_dir/init.d"
3033 fi])
3034 AC_SUBST(pcp_rc_dir)
3036 dnl rc sysconfig dir
3037 AC_ARG_WITH(sysconfigdir,[AC_HELP_STRING([--with-sysconfigdir],[sysconfig directory [SYSCONFDIR/sysconfig]])],
3038                   [pcp_sysconfig_dir=$withval],
3039                   [pcp_sysconfig_dir=$pcp_etc_dir/sysconfig])
3040 AC_SUBST(pcp_sysconfig_dir)
3042 dnl logs
3043 AC_ARG_WITH(logdir,[AC_HELP_STRING([--with-logdir],[log directory [LOCALSTATEDIR/log/pcp]])],
3044                    [pcp_log_dir=$withval],
3045                    [pcp_log_dir=$localstatedir/log/pcp])
3046 pcp_log_dir=`eval echo $pcp_log_dir`
3047 pcp_log_dir=`eval echo $pcp_log_dir`
3048 AC_SUBST(pcp_log_dir)
3050 AC_ARG_WITH(rundir,[AC_HELP_STRING([--with-rundir],[run directory [LOCALSTATEDIR/run/pcp]])],
3051                    [pcp_run_dir=$withval],
3052                    [pcp_run_dir=$localstatedir/run/pcp])
3053 pcp_run_dir=`eval echo $pcp_run_dir`
3054 pcp_run_dir=`eval echo $pcp_run_dir`
3055 AC_SUBST(pcp_run_dir)
3057 dnl world-writeable temporary files directory
3058 AC_ARG_WITH(tmpdir,[AC_HELP_STRING([--with-tmpdir],[tmp directory [LOCALSTATEDIR/tmp]])],
3059                    [pcp_tmpfile_dir=$withval],
3060                    [pcp_tmpfile_dir=$localstatedir/tmp])
3061 pcp_tmpfile_dir=`eval echo $pcp_tmpfile_dir`
3062 pcp_tmpfile_dir=`eval echo $pcp_tmpfile_dir`
3063 AC_SUBST(pcp_tmpfile_dir)
3065 dnl non-world-writeable status files directory
3066 pcp_tmp_dir=`eval echo $pcp_var_dir/tmp`
3067 AC_SUBST(pcp_tmp_dir)
3069 dnl doc directory
3070 AC_ARG_WITH(docdir,[AC_HELP_STRING([--with-docdir],[docs directory [DOCDIR/pcp-VERSION]])],
3071                    [pcp_doc_dir=$withval],
3072                    [PACKAGE=pcp-${PACKAGE_VERSION}; pcp_doc_dir=$docdir])
3073 pcp_doc_dir=`eval echo $pcp_doc_dir`
3074 pcp_doc_dir=`eval echo $pcp_doc_dir`
3075 AC_SUBST(pcp_doc_dir)
3077 dnl demos directory
3078 AC_ARG_WITH(demosdir,[AC_HELP_STRING([--with-demosdir],[run directory [DATADIR/pcp/demos]])],
3079                    [pcp_demos_dir=$withval],
3080                    [pcp_demos_dir=$pcp_share_dir/demos])
3081 AC_SUBST(pcp_demos_dir)
3083 if test -z "$XCONFIRM" 
3084 then
3085     AC_PATH_PROG(ac_xconfirm_prog, xconfirm, $pcp_bin_dir/pmconfirm)
3086 else
3087     ac_xconfirm_prog=$XCONFIRM
3089 AC_SUBST(ac_xconfirm_prog)
3091 dnl Check for FNDELAY defined in <fcntl.h>
3092 if test "$ac_cv_header_fcntl_h" = "yes"
3093 then
3094     AC_MSG_CHECKING([for FNDELAY in fcntl.h])
3095     AC_TRY_COMPILE([#include <fcntl.h>],
3096         [ int i = FNDELAY; ],
3097         AC_DEFINE(HAVE_FNDELAY, [1], [FNDELAY macro])
3098         AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3101 dnl check for zpool_vdev_name API style from <libzfs.h>
3102 if test "$ac_cv_header_libzfs_h" = "yes"
3103 then
3104     AC_MSG_CHECKING([for 5-argument style zpool_vdev_name])
3105     AC_TRY_COMPILE([#include <libzfs.h>],
3106         [ libzfs_handle_t *zh;
3107           zpool_handle_t *zp;
3108           nvlist_t *np;
3109           (void) zpool_vdev_name(zh, zp, np, B_FALSE, B_FALSE);
3110         ],
3111         AC_DEFINE(HAVE_ZPOOL_VDEV_NAME_5ARG, [1], [5-arg zpool_vdev_name])
3112         AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3114     AC_MSG_CHECKING([for 4-argument style zpool_vdev_name])
3115     AC_TRY_COMPILE([#include <libzfs.h>],
3116         [ libzfs_handle_t *zh;
3117           zpool_handle_t *zp;
3118           nvlist_t *np;
3119           (void) zpool_vdev_name(zh, zp, np, B_FALSE);
3120         ],
3121         AC_DEFINE(HAVE_ZPOOL_VDEV_NAME_4ARG, [1], [4-arg zpool_vdev_name])
3122         AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3125 dnl Check for Network Security Services (NSS) and
3126 dnl Simple Authentication and Security Layer (SASL)
3127 if test "$do_secure" = "check" -o "$do_secure" = "yes"
3128 then
3129     enable_secure=true
3131     saved_CFLAGS="$CFLAGS"
3132     saved_CPPFLAGS="$CPPFLAGS"
3133     NSS_INC_DIRS="-I/usr/include/nss -I/usr/include/nss3"
3134     NSPR_INC_DIRS="-I/usr/include/nspr -I/usr/include/nspr4"
3135     CFLAGS="$CFLAGS $NSS_INC_DIRS $NSPR_INC_DIRS"
3136     CPPFLAGS="$CPPFLAGS $NSS_INC_DIRS $NSPR_INC_DIRS"
3138     AC_CHECK_HEADERS([nss/nss.h], [NSSCFLAGS=-I/usr/include/nss], [
3139         AC_CHECK_HEADERS([nss3/nss.h], [NSSCFLAGS=-I/usr/include/nss3], [
3140             enable_secure=false
3141             if test "$do_secure" = "yes"
3142             then
3143                 AC_MSG_ERROR([cannot enable secure sockets mode - no NSS header])
3144             fi
3145         ])
3146     ])
3147     AC_SUBST(NSSCFLAGS)
3149     AC_CHECK_HEADERS([nspr/nspr.h], [NSPRCFLAGS=-I/usr/include/nspr], [
3150         AC_CHECK_HEADERS([nspr4/nspr.h], [NSPRCFLAGS=-I/usr/include/nspr4], [
3151             enable_secure=false
3152             if test "$do_secure" = "yes"
3153             then
3154                 AC_MSG_ERROR([cannot enable secure sockets mode - no NSPR header])
3155             fi
3156         ])
3157     ])
3158     AC_SUBST(NSPRCFLAGS)
3160     AC_CHECK_HEADERS([sasl/sasl.h], [SASLCFLAGS=-I/usr/include/sasl], [
3161         enable_secure=false
3162         if test "$do_secure" = "yes"
3163         then
3164             AC_MSG_ERROR([cannot enable secure sockets mode - no SASL header])
3165         fi
3166     ])
3167     AC_SUBST(SASLCFLAGS)
3169     AC_CHECK_LIB(sasl2, sasl_server_init, [lib_for_sasl="-lsasl2"], [
3170         enable_secure=false
3171         if test "$do_secure" = "yes"
3172         then
3173             AC_MSG_ERROR([cannot enable secure sockets mode - no SASL library])
3174         fi
3175     ])
3176     AC_SUBST(lib_for_sasl)
3178     AC_CHECK_LIB(ssl, SSL_ImportFD, [lib_for_ssl="-lssl"], [
3179         AC_CHECK_LIB(ssl3, SSL_ImportFD, [lib_for_ssl="-lssl3"], [
3180             enable_secure=false
3181             if test "$do_secure" = "yes"
3182             then
3183                 AC_MSG_ERROR([cannot enable secure sockets mode - no SSL library])
3184             fi
3185         ])
3186     ])
3187     AC_SUBST(lib_for_ssl)
3189     AC_CHECK_LIB(nss, NSS_Init, [lib_for_nss="-lnss"], [
3190         AC_CHECK_LIB(nss3, NSS_Init, [lib_for_nss="-lnss3"], [
3191             enable_secure=false
3192             if test "$do_secure" = "yes"
3193             then
3194                 AC_MSG_ERROR([cannot enable secure sockets mode - no NSS library])
3195             fi
3196         ])
3197     ])
3198     AC_SUBST(lib_for_nss)
3200     AC_CHECK_LIB(nspr, PR_Init, [lib_for_nspr="-lnspr"], [
3201         AC_CHECK_LIB(nspr4, PR_Init, [lib_for_nspr="-lnspr4"], [
3202             enable_secure=false
3203             if test "$do_secure" = "yes"
3204             then
3205                 AC_MSG_ERROR([cannot enable secure sockets mode - no NSPR library])
3206             fi
3207         ])
3208     ])
3209     AC_SUBST(lib_for_nspr)
3211     if test "$enable_secure" = "true"
3212     then
3213         AC_DEFINE(HAVE_SECURE_SOCKETS, [1], [Encrypted sockets])
3214     fi
3215     AC_SUBST(enable_secure)
3217     CPPFLAGS="$saved_CPPFLAGS"
3218     CFLAGS="$saved_CFLAGS"
3221 dnl check for -latomic, needed for some -march=i386 builds with i686 c++ distro headers
3222 AC_CHECK_LIB(atomic, __atomic_fetch_add_4, [lib_for_atomic="-latomic"])
3223 AC_SUBST(lib_for_atomic)
3225 dnl check for array sessions
3226 if test -f /usr/include/sn/arsess.h
3227 then
3228     pcp_mpi_dirs=libpcp_mpi\ libpcp_mpiread
3229 else
3230     pcp_mpi_dirs=
3232 AC_SUBST(pcp_mpi_dirs)
3234 dnl check for Unix Domain socket family structure
3235 AC_MSG_CHECKING([for struct sockaddr_un in sys/un.h])
3236 AC_TRY_COMPILE([
3237     #include <sys/types.h>
3238     #ifdef HAVE_SYS_SOCKET_H
3239     #include <sys/socket.h>
3240     #endif
3241     #ifdef HAVE_SYS_UN_H
3242     #include <sys/un.h>
3243     #endif
3244 ], [ struct sockaddr_un sa; sa.sun_family = AF_UNIX; ],
3245 AC_DEFINE(HAVE_STRUCT_SOCKADDR_UN, [1], [sockaddr_un type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3247 dnl check for Linux Unix Domain socket credential structure
3248 AC_MSG_CHECKING([for struct ucred in sys/socket.h])
3249 AC_TRY_COMPILE([
3250     #include <sys/types.h>
3251     #ifdef HAVE_SYS_SOCKET_H
3252     #include <sys/socket.h>
3253     #endif
3254     #ifdef HAVE_SYS_UN_H
3255     #include <sys/un.h>
3256     #endif
3257 ], [ struct ucred ucred; ucred.uid = 0; ],
3258 AC_DEFINE(HAVE_STRUCT_UCRED, [1], [ucred type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3260 dnl check for struct timespec in <time.h>
3261 AC_MSG_CHECKING([for struct timespec in time.h])
3262 AC_TRY_COMPILE([
3263     #include <time.h>
3264 ], [ struct timespec foo; ],
3265 AC_DEFINE(HAVE_STRUCT_TIMESPEC, [1], [timespec type]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3267 dnl check if we have IRIX style altzone 
3268 AC_MSG_CHECKING([for altzone in time.h])
3269 AC_TRY_COMPILE([
3270     #include <time.h>
3271 ], [ time_t az = altzone; ],
3272 AC_DEFINE(HAVE_ALTZONE, [1], [altzone global]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3274 dnl If there is no altzone, check if strftime can handle %z
3275 AC_MSG_CHECKING([if strftime knows about %z])
3276 AC_TRY_RUN(
3278 #include <time.h>
3279 int main () {
3280     char b[32]="";
3281     time_t t = time(NULL);
3282     struct tm * t1 = localtime (&t);
3283     if (strftime (b, 32, "%z", t1) < 3)
3284        return (1);
3285     if (strcmp(b, "%z") == 0)
3286        return(1);
3287     return (0);
3289 ], AC_DEFINE(HAVE_STRFTIME_z, [1], [strftime with %z]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no), AC_MSG_RESULT(no))
3291 dnl does strerror_r return char * a la GNU
3292 dnl (as opposed to the int return for XSI-compliant variants)
3293 AC_MSG_CHECKING([if strerror_r returns char *])
3294 AC_TRY_COMPILE(
3295     [#include <string.h>], [strerror_r(0, NULL, 0)[0];],
3296     AC_DEFINE(HAVE_STRERROR_R_PTR, [1], [strerror_r return]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3298 dnl first check for readline on its own then with curses
3299 savedLIBS=$LIBS
3300 LIBS=
3301 lib_for_curses=
3302 lib_for_readline=
3303 AC_CHECK_FUNC(readline,,
3304     [
3305         AC_CHECK_LIB(readline, readline,,
3306             [
3307                 dnl AC seems to cache lib/func results
3308                 dnl so use another readline func here
3309                 AC_CHECK_LIB(readline, add_history,,,[-lcurses])
3310             ])
3311     ])
3312 if test $ac_cv_func_readline = yes
3313 then
3314     AC_DEFINE(HAVE_READLINE, [1], [readline API])
3315 elif test $ac_cv_lib_readline_readline = yes
3316 then
3317     AC_DEFINE(HAVE_READLINE, [1], [readline API])
3318     lib_for_readline=-lreadline
3319 elif test $ac_cv_lib_readline_add_history = yes
3320 then
3321     AC_DEFINE(HAVE_READLINE, [1], [readline API])
3322     lib_for_curses=-lcurses
3323     lib_for_readline=-lreadline
3325 AC_SUBST(lib_for_readline)
3326 AC_SUBST(lib_for_curses)
3327 LIBS=$savedLIBS
3329 dnl Look for zlib
3330 PKG_CHECK_MODULES([zlib], [zlib >= 1.0.0], [have_zlib=true], [have_zlib=false])
3331 AC_SUBST(HAVE_ZLIB, [$have_zlib])
3333 dnl Check if we have AI_ADDRCONFIG
3334 AC_MSG_CHECKING([for AI_ADDRCONFIG])
3335 AC_TRY_COMPILE(
3336 [  
3337     #include <netdb.h>
3338     int test = AI_ADDRCONFIG;
3341 ], AC_DEFINE(HAVE_AI_ADDRCONFIG, [1], [AI_ADDRCONFIG macro]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
3343 dnl Find external source tarballs for packaging
3345 have_parfait=false
3346 if test -f ./build/tar/parfait.tar.gz
3347 then
3348     AC_MSG_NOTICE([adding Parfait package to the build])
3349     have_parfait=true
3351 AC_SUBST(have_parfait)
3353 have_vector=false
3354 if test -f ./build/tar/vector.tar.gz
3355 then
3356     AC_MSG_NOTICE([adding Vector webapp to the build])
3357     have_vector=true
3359 AC_SUBST(have_vector)
3361 have_webjs=false
3362 if test -f ./build/tar/webjs.tar.gz
3363 then
3364     AC_MSG_NOTICE([adding webjs webapps to the build])
3365     have_webjs=true
3367 AC_SUBST(have_webjs)
3369 dnl Capture special options passed to configure
3370 AC_SUBST(PACKAGE_CONFIGURE)
3373 dnl output files
3376 AC_OUTPUT(
3377 dnl   Build definitions for use in Makefiles
3378     src/include/builddefs
3379 dnl   PCP paths and other defs
3380     src/include/pcp.conf
3381 dnl   Linux Software Map entry
3382     pcp.lsm
3383 dnl   Preamble for deb install scripts
3384     debian/pcp.preinst.head
3385     debian/pcp.postinst.head
3386 dnl   Preamble for tar install scripts
3387     build/tar/preinstall.head
3388     build/tar/postinstall.head
3389 dnl   Build definitions for use in packaging
3390     build/GNUlocaldefs
3391     build/mac/uninstall-pcp
3394 dnl verbose diagnostics
3396 dnl echo config.status: settings dump begin
3397 dnl grep '^S.".*=' config.status
3398 dnl echo config.status: settings dump end