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