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