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