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