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