build: Start using library versioning for various libraries
[obnox/glusterfs.git] / configure.ac
1 dnl  Copyright (c) 2006-2012 Red Hat, Inc. <http://www.redhat.com>
2 dnl  This file is part of GlusterFS.
3 dnl
4 dnl  This file is licensed to you under your choice of the GNU Lesser
5 dnl  General Public License, version 3 or any later version (LGPLv3 or
6 dnl  later), or the GNU General Public License, version 2 (GPLv2), in all
7 dnl  cases as published by the Free Software Foundation.
8
9 AC_INIT([glusterfs],[3git],[gluster-users@gluster.org],,[https://github.com/gluster/glusterfs.git])
10
11 AM_INIT_AUTOMAKE
12
13 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
14
15 if make --help 2>&1 | grep -q no-print-directory; then
16    AM_MAKEFLAGS="$AM_MAKEFLAGS --no-print-directory";
17 fi
18
19 if make --help 2>&1 | grep -q quiet; then
20    AM_MAKEFLAGS="$AM_MAKEFLAGS --quiet"
21 fi
22
23 if libtool --help 2>&1 | grep -q quiet; then
24    AM_LIBTOOLFLAGS="--quiet";
25 fi
26
27 AC_CONFIG_HEADERS([config.h])
28
29 AC_CONFIG_FILES([Makefile
30                 libglusterfs/Makefile
31                 libglusterfs/src/Makefile
32                 geo-replication/src/peer_gsec_create
33                 geo-replication/src/peer_add_secret_pub
34                 glusterfsd/Makefile
35                 glusterfsd/src/Makefile
36                 rpc/Makefile
37                 rpc/rpc-lib/Makefile
38                 rpc/rpc-lib/src/Makefile
39                 rpc/rpc-transport/Makefile
40                 rpc/rpc-transport/socket/Makefile
41                 rpc/rpc-transport/socket/src/Makefile
42                 rpc/rpc-transport/rdma/Makefile
43                 rpc/rpc-transport/rdma/src/Makefile
44                 rpc/xdr/Makefile
45                 rpc/xdr/src/Makefile
46                 xlators/Makefile
47                 xlators/mount/Makefile
48                 xlators/mount/fuse/Makefile
49                 xlators/mount/fuse/src/Makefile
50                 xlators/mount/fuse/utils/mount.glusterfs
51                 xlators/mount/fuse/utils/mount_glusterfs
52                 xlators/mount/fuse/utils/Makefile
53                 xlators/storage/Makefile
54                 xlators/storage/posix/Makefile
55                 xlators/storage/posix/src/Makefile
56                 xlators/storage/bd/Makefile
57                 xlators/storage/bd/src/Makefile
58                 xlators/cluster/Makefile
59                 xlators/cluster/afr/Makefile
60                 xlators/cluster/afr/src/Makefile
61                 xlators/cluster/stripe/Makefile
62                 xlators/cluster/stripe/src/Makefile
63                 xlators/cluster/dht/Makefile
64                 xlators/cluster/dht/src/Makefile
65                 xlators/performance/Makefile
66                 xlators/performance/write-behind/Makefile
67                 xlators/performance/write-behind/src/Makefile
68                 xlators/performance/read-ahead/Makefile
69                 xlators/performance/read-ahead/src/Makefile
70                 xlators/performance/readdir-ahead/Makefile
71                 xlators/performance/readdir-ahead/src/Makefile
72                 xlators/performance/io-threads/Makefile
73                 xlators/performance/io-threads/src/Makefile
74                 xlators/performance/io-cache/Makefile
75                 xlators/performance/io-cache/src/Makefile
76                 xlators/performance/symlink-cache/Makefile
77                 xlators/performance/symlink-cache/src/Makefile
78                 xlators/performance/quick-read/Makefile
79                 xlators/performance/quick-read/src/Makefile
80                 xlators/performance/open-behind/Makefile
81                 xlators/performance/open-behind/src/Makefile
82                 xlators/performance/md-cache/Makefile
83                 xlators/performance/md-cache/src/Makefile
84                 xlators/debug/Makefile
85                 xlators/debug/trace/Makefile
86                 xlators/debug/trace/src/Makefile
87                 xlators/debug/error-gen/Makefile
88                 xlators/debug/error-gen/src/Makefile
89                 xlators/debug/io-stats/Makefile
90                 xlators/debug/io-stats/src/Makefile
91                 xlators/protocol/Makefile
92                 xlators/protocol/auth/Makefile
93                 xlators/protocol/auth/addr/Makefile
94                 xlators/protocol/auth/addr/src/Makefile
95                 xlators/protocol/auth/login/Makefile
96                 xlators/protocol/auth/login/src/Makefile
97                 xlators/protocol/client/Makefile
98                 xlators/protocol/client/src/Makefile
99                 xlators/protocol/server/Makefile
100                 xlators/protocol/server/src/Makefile
101                 xlators/features/Makefile
102                 xlators/features/changelog/Makefile
103                 xlators/features/changelog/src/Makefile
104                 xlators/features/changelog/lib/Makefile
105                 xlators/features/changelog/lib/src/Makefile
106                 xlators/features/glupy/Makefile
107                 xlators/features/glupy/src/Makefile
108                 xlators/features/locks/Makefile
109                 xlators/features/locks/src/Makefile
110                 xlators/features/quota/Makefile
111                 xlators/features/quota/src/Makefile
112                 xlators/features/marker/Makefile
113                 xlators/features/marker/src/Makefile
114                 xlators/features/read-only/Makefile
115                 xlators/features/read-only/src/Makefile
116                 xlators/features/compress/Makefile
117                 xlators/features/compress/src/Makefile
118                 xlators/features/mac-compat/Makefile
119                 xlators/features/mac-compat/src/Makefile
120                 xlators/features/quiesce/Makefile
121                 xlators/features/quiesce/src/Makefile
122                 xlators/features/index/Makefile
123                 xlators/features/index/src/Makefile
124                 xlators/features/protect/Makefile
125                 xlators/features/protect/src/Makefile
126                 xlators/features/gfid-access/Makefile
127                 xlators/features/gfid-access/src/Makefile
128                 xlators/playground/Makefile
129                 xlators/playground/template/Makefile
130                 xlators/playground/template/src/Makefile
131                 xlators/encryption/Makefile
132                 xlators/encryption/rot-13/Makefile
133                 xlators/encryption/rot-13/src/Makefile
134                 xlators/encryption/crypt/Makefile
135                 xlators/encryption/crypt/src/Makefile
136                 xlators/features/qemu-block/Makefile
137                 xlators/features/qemu-block/src/Makefile
138                 xlators/system/Makefile
139                 xlators/system/posix-acl/Makefile
140                 xlators/system/posix-acl/src/Makefile
141                 xlators/nfs/Makefile
142                 xlators/nfs/server/Makefile
143                 xlators/nfs/server/src/Makefile
144                 xlators/mgmt/Makefile
145                 xlators/mgmt/glusterd/Makefile
146                 xlators/mgmt/glusterd/src/Makefile
147                 cli/Makefile
148                 cli/src/Makefile
149                 doc/Makefile
150                 extras/Makefile
151                 extras/init.d/Makefile
152                 extras/init.d/glusterd.plist
153                 extras/init.d/glusterd-Debian
154                 extras/init.d/glusterd-Redhat
155                 extras/init.d/glusterd-SuSE
156                 extras/systemd/Makefile
157                 extras/systemd/glusterd.service
158                 extras/benchmarking/Makefile
159                 extras/hook-scripts/Makefile
160                 extras/ocf/Makefile
161                 extras/ocf/glusterd
162                 extras/ocf/volume
163                 extras/LinuxRPM/Makefile
164                 extras/geo-rep/Makefile
165                 extras/hook-scripts/add-brick/Makefile
166                 extras/hook-scripts/add-brick/pre/Makefile
167                 extras/hook-scripts/add-brick/post/Makefile
168                 contrib/fuse-util/Makefile
169                 contrib/uuid/uuid_types.h
170                 glusterfs-api.pc
171                 libgfchangelog.pc
172                 api/Makefile
173                 api/src/Makefile
174                 api/examples/Makefile
175                 api/examples/setup.py
176                 geo-replication/Makefile
177                 geo-replication/src/Makefile
178                 geo-replication/syncdaemon/Makefile
179                 glusterfs.spec])
180
181 AC_CANONICAL_HOST
182
183 AC_PROG_CC
184 AC_DISABLE_STATIC
185 AC_PROG_LIBTOOL
186
187 AC_ARG_WITH(pkgconfigdir,
188             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
189             [pkgconfigdir=$withval],
190             [pkgconfigdir='${libdir}/pkgconfig'])
191 AC_SUBST(pkgconfigdir)
192
193 AC_ARG_WITH(mountutildir,
194             [  --with-mountutildir=DIR mount helper utility in DIR @<:@/sbin@:>@],
195             [mountutildir=$withval],
196             [mountutildir='/sbin'])
197 AC_SUBST(mountutildir)
198
199 AC_ARG_WITH(systemddir,
200             [  --with-systemddir=DIR systemd service files in DIR @<:@/usr/lib/systemd/system@:>@],
201             [systemddir=$withval],
202             [systemddir='/usr/lib/systemd/system'])
203 AC_SUBST(systemddir)
204
205 AC_ARG_WITH(initdir,
206             [  --with-initdir=DIR init.d scripts in DIR @<:@/etc/init.d@:>@],
207             [initdir=$withval],
208             [initdir='/etc/init.d'])
209 AC_SUBST(initdir)
210
211 AC_ARG_WITH(launchddir,
212             [  --with-launchddir=DIR launchd services in DIR @<:@/Library/LaunchDaemons@:>@],
213             [launchddir=$withval],
214             [launchddir='/Library/LaunchDaemons'])
215 AC_SUBST(launchddir)
216
217 AC_ARG_WITH([ocf],
218             [AS_HELP_STRING([--without-ocf], [build OCF-compliant cluster resource agents])],
219             ,
220             [OCF_SUBDIR='ocf'],
221             )
222 AC_SUBST(OCF_SUBDIR)
223
224 # LEX needs a check
225 AC_PROG_LEX
226 if test  "x${LEX}" != "xflex" -a "x${FLEX}" != "xlex"; then
227    AC_MSG_ERROR([Flex or lex required to build glusterfs.])
228 fi
229
230 dnl
231 dnl Word sizes...
232 dnl
233 AC_CHECK_SIZEOF(short)
234 AC_CHECK_SIZEOF(int)
235 AC_CHECK_SIZEOF(long)
236 AC_CHECK_SIZEOF(long long)
237 SIZEOF_SHORT=$ac_cv_sizeof_short
238 SIZEOF_INT=$ac_cv_sizeof_int
239 SIZEOF_LONG=$ac_cv_sizeof_long
240 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
241 AC_SUBST(SIZEOF_SHORT)
242 AC_SUBST(SIZEOF_INT)
243 AC_SUBST(SIZEOF_LONG)
244 AC_SUBST(SIZEOF_LONG_LONG)
245
246 # YACC needs a check
247 AC_PROG_YACC
248 if test "x${YACC}" = "xbyacc" -o "x${YACC}" = "xyacc" -o "x${YACC}" = "x"; then
249    AC_MSG_ERROR([GNU Bison required to build glusterfs.])
250 fi
251
252 AC_CHECK_TOOL([LD],[ld])
253
254 AC_CHECK_LIB([crypto], [MD5], , AC_MSG_ERROR([OpenSSL crypto library is required to build glusterfs]))
255
256 AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs]))
257
258 AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs])))
259
260 AC_CHECK_FUNC([gettext], [has_gettext=yes], AC_CHECK_LIB([intl], [gettext], , AC_MSG_ERROR([gettext support is required to build glusterfs])))
261
262 AC_CHECK_HEADERS([sys/xattr.h])
263
264 AC_CHECK_HEADERS([sys/extattr.h])
265
266 AC_CHECK_HEADERS([openssl/md5.h])
267
268 AC_CHECK_HEADERS([linux/falloc.h])
269
270 case $host_os in
271   darwin*)
272     if ! test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -ge 5; then
273       AC_MSG_ERROR([You need at least OS X 10.5 (Leopard) to build Glusterfs])
274     fi
275     ;;
276 esac
277
278 dnl Mac OS X does not have spinlocks
279 AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
280 if test "x${have_spinlock}" = "xyes"; then
281    AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
282 fi
283 AC_SUBST(HAVE_SPINLOCK)
284
285 dnl some os may not have GNU defined strnlen function
286 AC_CHECK_FUNC([strnlen], [have_strnlen=yes])
287 if test "x${have_strnlen}" = "xyes"; then
288    AC_DEFINE(HAVE_STRNLEN, 1, [define if found strnlen])
289 fi
290 AC_SUBST(HAVE_STRNLEN)
291
292
293 AC_CHECK_FUNC([setfsuid], [have_setfsuid=yes])
294 AC_CHECK_FUNC([setfsgid], [have_setfsgid=yes])
295
296 if test "x${have_setfsuid}" = "xyes" -a "x${have_setfsgid}" = "xyes"; then
297   AC_DEFINE(HAVE_SET_FSID, 1, [define if found setfsuid setfsgid])
298 fi
299
300
301 # FUSE section
302 AC_ARG_ENABLE([fuse-client],
303               AC_HELP_STRING([--disable-fuse-client],
304                              [Do not build the fuse client. NOTE: you cannot mount glusterfs without the client]))
305
306 BUILD_FUSE_CLIENT=no
307 if test "x$enable_fuse_client" != "xno"; then
308    FUSE_CLIENT_SUBDIR=fuse
309    BUILD_FUSE_CLIENT="yes"
310 fi
311
312 AC_ARG_ENABLE([bd-xlator],
313               AC_HELP_STRING([--enable-bd-xlator], [Build BD xlator]))
314
315 if test "x$enable_bd_xlator" != "xno"; then
316   AC_CHECK_LIB([lvm2app],
317                [lvm_init,lvm_lv_from_name],
318                [HAVE_BD_LIB="yes"],
319                [HAVE_BD_LIB="no"])
320
321 if test "x$HAVE_BD_LIB" = "xyes"; then
322     # lvm_lv_from_name() has been made public with lvm2-2.02.79
323     AC_CHECK_DECLS(
324                   [lvm_lv_from_name],
325                   [NEED_LVM_LV_FROM_NAME_DECL="no"],
326                   [NEED_LVM_LV_FROM_NAME_DECL="yes"],
327                   [[#include <lvm2app.h>]])
328   fi
329 fi
330
331 if test "x$enable_bd_xlator" = "xyes" -a "x$HAVE_BD_LIB" = "xno"; then
332    echo "BD xlator requested but required lvm2 development library not found."
333    exit 1
334 fi
335
336 BUILD_BD_XLATOR=no
337 if test "x${enable-bd-xlator}" != "xno" -a "x${HAVE_BD_LIB}" = "xyes"; then
338   BUILD_BD_XLATOR=yes
339   AC_DEFINE(HAVE_BD_XLATOR, 1, [define if lvm2app library found and bd xlator
340                             enabled])
341   if test "x$NEED_LVM_LV_FROM_NAME_DECL" = "xyes"; then
342     AC_DEFINE(NEED_LVM_LV_FROM_NAME_DECL, 1, [defined if lvm_lv_from_name()
343                   was not found in the lvm2app.h header, but can be linked])
344   fi
345 fi
346
347 AM_CONDITIONAL([ENABLE_BD_XLATOR], [test x$BUILD_BD_XLATOR = xyes])
348
349 # start encryption/crypt section
350
351 AC_CHECK_HEADERS([openssl/cmac.h], [have_cmac_h=yes], [have_cmac_h=no])
352
353 AC_ARG_ENABLE([crypt-xlator],
354         AC_HELP_STRING([--enable-crypt-xlator], [Build crypt encryption xlator]))
355
356 if test "x$enable_crypt_xlator" = "xyes" -a "x$have_cmac_h" = "xno"; then
357    echo "Encryption xlator requires OpenSSL with cmac.h"
358    exit 1
359 fi
360
361 BUILD_CRYPT_XLATOR=no
362 if test "x$enable_crypt_xlator" != "xno" -a "x$have_cmac_h" = "xyes"; then
363    BUILD_CRYPT_XLATOR=yes
364    AC_DEFINE(HAVE_CRYPT_XLATOR, 1, [enable building crypt encryption xlator])
365 fi
366
367 AM_CONDITIONAL([ENABLE_CRYPT_XLATOR], [test x$BUILD_CRYPT_XLATOR = xyes])
368
369 AC_SUBST(FUSE_CLIENT_SUBDIR)
370 # end FUSE section
371
372
373 # FUSERMOUNT section
374 AC_ARG_ENABLE([fusermount],
375               AC_HELP_STRING([--disable-fusermount],
376                              [Use system's fusermount]))
377
378 BUILD_FUSERMOUNT="yes"
379 if test "x$enable_fusermount" = "xno"; then
380   BUILD_FUSERMOUNT="no"
381 else
382   AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount])
383   FUSERMOUNT_SUBDIR="contrib/fuse-util"
384 fi
385
386 AC_SUBST(FUSERMOUNT_SUBDIR)
387 #end FUSERMOUNT section
388
389 # QEMU_BLOCK section
390
391 AC_ARG_ENABLE([qemu-block],
392                 AC_HELP_STRING([--enable-qemu-block],
393                         [Build QEMU Block formats translator]))
394
395 if test "x$enable_qemu_block" != "xno"; then
396   PKG_CHECK_MODULES([GLIB], [glib-2.0],
397                     [HAVE_GLIB_2="yes"],
398                     [HAVE_GLIB_2="no"])
399 fi
400
401 if test "x$enable_qemu_block" = "xyes" -a "x$HAVE_GLIB_2" = "xno"; then
402    echo "QEMU Block formats translator requires libglib-2.0, but missing."
403    exit 1
404 fi
405
406 BUILD_QEMU_BLOCK=no
407 if test "x${enable_qemu_block}" != "xno" -a "x${HAVE_GLIB_2}" = "xyes"; then
408   BUILD_QEMU_BLOCK=yes
409   AC_DEFINE(HAVE_QEMU_BLOCK, 1, [define if libglib-2.0 library found and QEMU
410                              Block translator enabled])
411 fi
412
413 AM_CONDITIONAL([ENABLE_QEMU_BLOCK], [test x$BUILD_QEMU_BLOCK = xyes])
414
415 # end QEMU_BLOCK section
416
417 # EPOLL section
418 AC_ARG_ENABLE([epoll],
419               AC_HELP_STRING([--disable-epoll],
420                              [Use poll instead of epoll.]))
421
422 BUILD_EPOLL=no
423 if test "x$enable_epoll" != "xno"; then
424    AC_CHECK_HEADERS([sys/epoll.h],
425                     [BUILD_EPOLL=yes],
426                     [BUILD_EPOLL=no])
427 fi
428 # end EPOLL section
429
430
431 # IBVERBS section
432 AC_ARG_ENABLE([ibverbs],
433               AC_HELP_STRING([--disable-ibverbs],
434                              [Do not build the ibverbs transport]))
435
436 if test "x$enable_ibverbs" != "xno"; then
437   AC_CHECK_LIB([ibverbs],
438                [ibv_get_device_list],
439                [HAVE_LIBIBVERBS="yes"],
440                [HAVE_LIBIBVERBS="no"])
441   AC_CHECK_LIB([rdmacm], [rdma_create_id], [HAVE_RDMACM="yes"], [HAVE_RDMACM="no"])
442 fi
443
444 if test "x$enable_ibverbs" = "xyes"; then
445    if test "x$HAVE_LIBIBVERBS" = "xno"; then
446       echo "ibverbs-transport requested, but libibverbs is not present."
447       exit 1
448    fi
449
450    if test "x$HAVE_RDMACM" = "xno"; then
451       echo "ibverbs-transport requested, but librdmacm is not present."
452       exit 1
453    fi
454 fi
455
456 BUILD_RDMA=no
457 BUILD_IBVERBS=no
458 if test "x$enable_ibverbs" != "xno" -a "x$HAVE_LIBIBVERBS" = "xyes" -a "x$HAVE_RDMACM" = "xyes"; then
459   IBVERBS_SUBDIR=ib-verbs
460   BUILD_IBVERBS=yes
461   RDMA_SUBDIR=rdma
462   BUILD_RDMA=yes
463 fi
464
465 AC_SUBST(IBVERBS_SUBDIR)
466 AC_SUBST(RDMA_SUBDIR)
467 # end IBVERBS section
468
469
470 # SYNCDAEMON section
471 AC_ARG_ENABLE([georeplication],
472               AC_HELP_STRING([--disable-georeplication],
473                              [Do not install georeplication components]))
474
475 BUILD_SYNCDAEMON=no
476 case $host_os in
477      linux*)
478 #do nothing
479        ;;
480      netbsd*)
481 #do nothing
482        ;;
483      *)
484 #disabling geo replication for non-linux platforms
485         enable_georeplication=no
486         ;;
487 esac
488 SYNCDAEMON_COMPILE=0
489 if test "x$enable_georeplication" != "xno"; then
490   SYNCDAEMON_SUBDIR=geo-replication
491   SYNCDAEMON_COMPILE=1
492
493   BUILD_SYNCDAEMON="yes"
494   AM_PATH_PYTHON([2.4])
495   echo -n "checking if python is python 2.x... "
496   if echo $PYTHON_VERSION | grep ^2; then
497     :
498   else
499     echo no
500     AC_MSG_ERROR([only python 2.x is supported])
501   fi
502   echo -n "checking if python has ctypes support... "
503   if "$PYTHON" -c 'import ctypes' 2>/dev/null; then
504     echo yes
505   else
506     echo no
507     AC_MSG_ERROR([python does not have ctypes support])
508   fi
509 fi
510 AC_SUBST(SYNCDAEMON_COMPILE)
511 AC_SUBST(SYNCDAEMON_SUBDIR)
512 # end SYNCDAEMON section
513
514 # CDC xlator - check if libz is present if so enable HAVE_LIB_Z
515 echo -n "checking if libz is present... "
516
517 PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0],
518                   [echo "yes (features requiring zlib enabled)"  AC_DEFINE(HAVE_LIB_Z, 1, [define if zlib is present])],
519                   [echo "no"] )
520
521 AC_SUBST(LIBZ_CFLAGS)
522 AC_SUBST(LIBZ_LIBS)
523 # end CDC xlator secion
524
525 # check for systemtap/dtrace
526 BUILD_SYSTEMTAP=no
527 AC_MSG_CHECKING([whether to include systemtap tracing support])
528 AC_ARG_ENABLE([systemtap],
529               [AS_HELP_STRING([--enable-systemtap],
530               [Enable inclusion of systemtap trace support])],
531               [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP="def"])
532
533 AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test "x${ENABLE_SYSTEMTAP}" = "xyes"])
534 AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
535
536 if test "x${ENABLE_SYSTEMTAP}" != "xno"; then
537     AC_CHECK_PROG(DTRACE, dtrace, "yes", "no")
538     AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND="yes"],
539                     [SDT_H_FOUND="no"])
540 fi
541
542 if test "x${ENABLE_SYSTEMTAP}" = "xyes"; then
543     if test "x${DTRACE}" = "xno"; then
544         AC_MSG_ERROR([dtrace not found])
545     elif test "$x{SDT_H_FOUND}" = "xno"; then
546         AC_MSG_ERROR([systemtap support needs sys/sdt.h header])
547     fi
548 fi
549
550 if test "x${DTRACE}" = "xyes" -a "x${SDT_H_FOUND}" = "xyes"; then
551     AC_MSG_CHECKING([x"${DTRACE}"xy"${SDT_H_FOUND}"y])
552     AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using  probes.])
553     BUILD_SYSTEMTAP=yes
554 fi
555 # end of systemtap/dtrace
556
557 # xml-output
558 AC_ARG_ENABLE([xml-output],
559               AC_HELP_STRING([--disable-xml-output],
560                              [Disable the xml output]))
561 BUILD_XML_OUTPUT="yes"
562 if test "x$enable_xml_output" != "xno"; then
563     #check if libxml is present if so enable HAVE_LIB_XML
564     m4_ifdef([AM_PATH_XML2],[AM_PATH_XML2([2.6.19])], [no_xml=yes])
565     if test "x${no_xml}" = "x"; then
566         AC_DEFINE([HAVE_LIB_XML], [1], [Define to 1 if using libxml2.])
567     else
568         AC_MSG_WARN([libxml2 devel libraries not found disabling XML support])
569         BUILD_XML_OUTPUT="no"
570     fi
571 else
572     BUILD_XML_OUTPUT="no"
573 fi
574 # end of xml-output
575
576 dnl FreeBSD > 5 has execinfo as a Ported library for giving a workaround
577 dnl solution to GCC backtrace functionality
578
579 AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes],
580                AC_CHECK_LIB([execinfo], [backtrace], [have_backtrace=yes]))
581 dnl               AC_MSG_ERROR([libexecinfo not found libexecinfo required.])))
582
583 if test "x${have_backtrace}" = "xyes"; then
584    AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
585 fi
586 AC_SUBST(HAVE_BACKTRACE)
587
588 dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
589 AC_CHECK_FUNC([malloc_stats], [have_malloc_stats=yes])
590 if test "x${have_malloc_stats}" = "xyes"; then
591    AC_DEFINE(HAVE_MALLOC_STATS, 1, [define if found malloc_stats])
592 fi
593 AC_SUBST(HAVE_MALLOC_STATS)
594
595 dnl Linux, Solaris, Cygwin
596 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
597 dnl FreeBSD, NetBSD
598 AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec])
599 case $host_os in
600         *netbsd*)
601         CFLAGS="${CFLAGS} -D_INCOMPLETE_XOPEN_C063"
602         ;;
603 esac
604 AC_CHECK_FUNC([linkat], [have_linkat=yes])
605 if test "x${have_linkat}" = "xyes"; then
606    AC_DEFINE(HAVE_LINKAT, 1, [define if found linkat])
607 fi
608 AC_SUBST(HAVE_LINKAT)
609
610 dnl check for Monotonic clock
611 AC_CHECK_FUNC([clock_gettime], [has_monotonic_clock=yes], AC_CHECK_LIB([rt], [clock_gettime], , AC_MSG_WARN([System doesn't have monotonic clock using contrib])))
612
613 dnl Check for argp
614 AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))
615 AC_CONFIG_SUBDIRS(argp-standalone)
616
617 BUILD_ARGP_STANDALONE=no
618 if test "x${ac_cv_header_argp_h}" = "xno"; then
619    BUILD_ARGP_STANDALONE=yes
620    ARGP_STANDALONE_CPPFLAGS='-I${top_srcdir}/argp-standalone'
621    ARGP_STANDALONE_LDADD='${top_builddir}/argp-standalone/libargp.a'
622 fi
623
624 AC_SUBST(ARGP_STANDALONE_CPPFLAGS)
625 AC_SUBST(ARGP_STANDALONE_LDADD)
626
627 AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))
628
629 AC_CHECK_FUNC([llistxattr], [have_llistxattr=yes])
630 if test "x${have_llistxattr}" = "xyes"; then
631    AC_DEFINE(HAVE_LLISTXATTR, 1, [define if llistxattr exists])
632 fi
633
634 AC_CHECK_FUNC([fdatasync], [have_fdatasync=yes])
635 if test "x${have_fdatasync}" = "xyes"; then
636    AC_DEFINE(HAVE_FDATASYNC, 1, [define if fdatasync exists])
637 fi
638
639 AC_CHECK_FUNC([fallocate], [have_fallocate=yes])
640 if test "x${have_fallocate}" = "xyes"; then
641    AC_DEFINE(HAVE_FALLOCATE, 1, [define if fallocate exists])
642 fi
643
644 AC_CHECK_FUNC([posix_fallocate], [have_posix_fallocate=yes])
645 if test "x${have_posix_fallocate}" = "xyes"; then
646    AC_DEFINE(HAVE_POSIX_FALLOCATE, 1, [define if posix_fallocate exists])
647 fi
648
649
650 # Check the distribution where you are compiling glusterfs on
651
652 GF_DISTRIBUTION=
653 AC_CHECK_FILE([/etc/debian_version])
654 AC_CHECK_FILE([/etc/SuSE-release])
655 AC_CHECK_FILE([/etc/redhat-release])
656
657 if test "x$ac_cv_file__etc_debian_version" = "xyes"; then
658    GF_DISTRIBUTION=Debian
659 fi
660 if test "x$ac_cv_file__etc_SuSE_release" = "xyes"; then
661    GF_DISTRIBUTION=SuSE
662 fi
663 if test "x$ac_cv_file__etc_redhat_release" = "xyes"; then
664    GF_DISTRIBUTION=Redhat
665 fi
666
667 AC_SUBST(GF_DISTRIBUTION)
668
669 GF_HOST_OS=""
670 GF_LDFLAGS="-rdynamic"
671
672 # check for gcc -Werror=format-security
673 saved_CFLAGS=$CFLAGS
674 CFLAGS="-Wformat -Werror=format-security"
675 AC_MSG_CHECKING([whether $CC accepts -Werror=format-security])
676 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no])
677 echo $cc_werror_format_security
678 if test "x$cc_werror_format_security" = "xno"; then
679     CFLAGS="$saved_CFLAGS"
680 else
681     CFLAGS="$saved_CFLAGS $CFLAGS"
682 fi
683
684 # check for gcc -Werror=implicit-function-declaration
685 saved_CFLAGS=$CFLAGS
686 CFLAGS="-Werror=implicit-function-declaration"
687 AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration])
688 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no])
689 echo $cc_werror_implicit
690 if test "x$cc_werror_implicit" = "xno"; then
691     CFLAGS="$saved_CFLAGS"
692 else
693     CFLAGS="$saved_CFLAGS $CFLAGS"
694 fi
695
696 case $host_os in
697      linux*)
698         GF_HOST_OS="GF_LINUX_HOST_OS"
699         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -O0"
700         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
701         GF_LDADD="${ARGP_STANDALONE_LDADD}"
702         GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\""
703         ;;
704      solaris*)
705         GF_HOST_OS="GF_SOLARIS_HOST_OS"
706         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -O0 -m64"
707         GF_LDFLAGS=""
708         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
709         GF_LDADD="${ARGP_STANDALONE_LDADD}"
710         GF_GLUSTERFS_LIBS="-lnsl -lresolv -lsocket"
711         BUILD_FUSE_CLIENT=no
712         FUSE_CLIENT_SUBDIR=""
713         ;;
714      *netbsd*)
715         GF_HOST_OS="GF_BSD_HOST_OS"
716         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_INCOMPLETE_XOPEN_C063"
717         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
718         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
719         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
720         GF_LDADD="${ARGP_STANDALONE_LDADD}"
721         if test "x$ac_cv_header_execinfo_h" = "xyes"; then
722            GF_GLUSTERFS_LIBS="-lexecinfo"
723         fi
724         GF_FUSE_LDADD="-lperfuse"
725         BUILD_FUSE_CLIENT=yes
726         LEXLIB=""
727         ;;
728      *bsd*)
729         GF_HOST_OS="GF_BSD_HOST_OS"
730         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -O0"
731         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
732         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
733         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
734         GF_LDADD="${ARGP_STANDALONE_LDADD}"
735         if test "x$ac_cv_header_execinfo_h" = "xyes"; then
736            GF_GLUSTERFS_LIBS="-lexecinfo"
737         fi
738         BUILD_FUSE_CLIENT=no
739         ;;
740      darwin*)
741         GF_HOST_OS="GF_DARWIN_HOST_OS"
742         LIBTOOL=glibtool
743         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE -O0"
744         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
745         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
746         GF_GLUSTERFS_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D__DARWIN_64_BIT_INO_T -undefined suppress -flat_namespace -O0"
747         GF_LDADD="${ARGP_STANDALONE_LDADD}"
748         GF_FUSE_CFLAGS="-I\$(CONTRIBDIR)/macfuse"
749         ;;
750 esac
751
752 # enable debug section
753 AC_ARG_ENABLE([debug],
754               AC_HELP_STRING([--enable-debug],
755                              [Enable debug build options.]))
756
757 # syslog section
758 AC_ARG_ENABLE([syslog],
759               AC_HELP_STRING([--disable-syslog],
760                              [Disable syslog for logging]))
761
762 USE_SYSLOG="yes"
763 if test "x$enable_syslog" != "xno"; then
764   AC_DEFINE(GF_USE_SYSLOG, 1, [Use syslog for logging])
765 else
766   USE_SYSLOG="no"
767 fi
768 AM_CONDITIONAL([ENABLE_SYSLOG], [test x$USE_SYSLOG = xyes])
769 #end syslog section
770
771 BUILD_READLINE=no
772 AC_CHECK_LIB([readline -lcurses],[readline],[RLLIBS="-lreadline -lcurses"])
773 AC_CHECK_LIB([readline -ltermcap],[readline],[RLLIBS="-lreadline -ltermcap"])
774 AC_CHECK_LIB([readline -lncurses],[readline],[RLLIBS="-lreadline -lncurses"])
775
776 if test "x$RLLIBS" != "x"; then
777    AC_DEFINE(HAVE_READLINE, 1, [readline enabled CLI])
778    BUILD_READLINE=yes
779 fi
780
781 BUILD_LIBAIO=no
782 AC_CHECK_LIB([aio],[io_setup],[LIBAIO="-laio"])
783
784 if test "x$LIBAIO" != "x"; then
785    AC_DEFINE(HAVE_LIBAIO, 1, [libaio based POSIX enabled])
786    BUILD_LIBAIO=yes
787 fi
788
789 # glupy section
790 BUILD_GLUPY=no
791 have_python2=no
792 have_Python_h=no
793
794 AM_PATH_PYTHON()
795 if echo $PYTHON_VERSION | grep ^2; then
796   have_python2=yes
797 fi
798 saved_CFLAGS=$CFLAGS
799 saved_CPPFLAGS=$CPPFLAGS
800 saved_LDFLAGS=$LDFLAGS
801 CFLAGS=`${PYTHON}-config --cflags`
802 CPPFLAGS=$CFLAGS
803 LDFLAGS="-L`${PYTHON}-config --prefix`/lib `${PYTHON}-config --ldflags`"
804 AC_CHECK_HEADERS([python$PYTHON_VERSION/Python.h],[have_Python_h=yes],[])
805 AC_ARG_ENABLE([glupy],
806               AS_HELP_STRING([--enable-glupy],
807                              [build glupy]))
808 case x$enable_glupy in
809    xyes)
810       if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
811          BUILD_GLUPY=yes
812          saved_CFLAGS="$saved_CFLAGS $CFLAGS"
813          saved_CPPFLAGS="$saved_CPPFLAGS $CPPFLAGS"
814          saved_LDFLAGS="$saved_LDFLAGS $LDFLAGS"
815       else
816          AC_MSG_ERROR([glupy requires python-devel/python-dev package and python2.x])
817       fi
818       ;;
819    xno)
820       ;;
821    *)
822       if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
823          BUILD_GLUPY=yes
824          saved_CFLAGS="$saved_CFLAGS $CFLAGS"
825          saved_CPPFLAGS="$saved_CPPFLAGS $CPPFLAGS"
826          saved_LDFLAGS="$saved_LDFLAGS $LDFLAGS"
827       else
828          AC_MSG_WARN([
829         ---------------------------------------------------------------------------------
830          cannot build glupy. python 2.x and python-devel/python-dev package are required.
831         ---------------------------------------------------------------------------------])
832       fi
833       ;;
834 esac
835 CFLAGS=$saved_CFLAGS
836 CPPFLAGS=$saved_CPPFLAGS
837 LDFLAGS=$saved_LDFLAGS
838
839 if test "x$BUILD_GLUPY" = "xyes"; then
840    BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"`
841    BUILD_PYTHON_LIB=python$PYTHON_VERSION
842    GLUPY_SUBDIR=glupy
843    GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile
844    GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile
845    echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB"
846    AC_SUBST(BUILD_PYTHON_INC)
847    AC_SUBST(BUILD_PYTHON_LIB)
848    AC_SUBST(GLUPY_SUBDIR)
849    AC_SUBST(GLUPY_SUBDIR_MAKEFILE)
850    AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE)
851 fi
852 # end glupy section
853
854 # Other stuff (most notably the glupy section) might have injected another -O2
855 # into CFLAGS, so *do this last*.
856 BUILD_DEBUG=no
857 if test "x$enable_debug" = "xyes"; then
858    BUILD_DEBUG=yes
859    CFLAGS=`echo $CFLAGS | sed -e s/O2/O0/g`
860 else
861    BUILD_DEBUG=no
862 fi
863 AC_SUBST(CFLAGS)
864 # end enable debug section
865
866 AC_SUBST(GF_HOST_OS)
867 AC_SUBST([GF_GLUSTERFS_LIBS])
868 AC_SUBST(GF_GLUSTERFS_CFLAGS)
869 AC_SUBST(GF_CFLAGS)
870 AC_SUBST(GF_LDFLAGS)
871 AC_SUBST(GF_LDADD)
872 AC_SUBST(GF_FUSE_LDADD)
873 AC_SUBST(GF_FUSE_CFLAGS)
874 AC_SUBST(RLLIBS)
875 AC_SUBST(LIBAIO)
876 AC_SUBST(AM_MAKEFLAGS)
877 AC_SUBST(AM_LIBTOOLFLAGS)
878
879 CONTRIBDIR='$(top_srcdir)/contrib'
880 AC_SUBST(CONTRIBDIR)
881
882 GF_CPPDEFINES='-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)'
883 GF_CPPINCLUDES='-I$(top_srcdir)/libglusterfs/src -I$(CONTRIBDIR)/uuid'
884 GF_CPPFLAGS="$GF_CPPDEFINES $GF_CPPINCLUDES"
885 AC_SUBST([GF_CPPFLAGS])
886
887 AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS")
888
889 AM_CONDITIONAL([GF_INSTALL_VAR_LIB_GLUSTERD], test ! -d ${localstatedir}/lib/glusterd && test -d ${sysconfdir}/glusterd )
890
891 dnl pkg-config versioning
892 GFAPI_VERSION="0.0.6"
893 LIBGFCHANGELOG_VERSION="0.0.1"
894 AC_SUBST(GFAPI_VERSION)
895 AC_SUBST(LIBGFCHANGELOG_VERSION)
896
897 dnl libtool versioning
898 LIBGFXDR_LT_VERSION="0:1:0"
899 LIBGFRPC_LT_VERSION="0:1:0"
900 LIBGLUSTERFS_LT_VERSION="0:1:0"
901 LIBGFCHANGELOG_LT_VERSION="0:1:0"
902 GFAPI_LT_VERSION="0:6:0"
903 AC_SUBST(LIBGFXDR_LT_VERSION)
904 AC_SUBST(LIBGFRPC_LT_VERSION)
905 AC_SUBST(LIBGLUSTERFS_LT_VERSION)
906 AC_SUBST(LIBGFCHANGELOG_LT_VERSION)
907 AC_SUBST(GFAPI_LT_VERSION)
908
909 AC_OUTPUT
910
911 echo
912 echo "GlusterFS configure summary"
913 echo "==========================="
914 echo "FUSE client          : $BUILD_FUSE_CLIENT"
915 echo "Infiniband verbs     : $BUILD_IBVERBS"
916 echo "epoll IO multiplex   : $BUILD_EPOLL"
917 echo "argp-standalone      : $BUILD_ARGP_STANDALONE"
918 echo "fusermount           : $BUILD_FUSERMOUNT"
919 echo "readline             : $BUILD_READLINE"
920 echo "georeplication       : $BUILD_SYNCDAEMON"
921 echo "Linux-AIO            : $BUILD_LIBAIO"
922 echo "Enable Debug         : $BUILD_DEBUG"
923 echo "systemtap            : $BUILD_SYSTEMTAP"
924 echo "Block Device xlator  : $BUILD_BD_XLATOR"
925 echo "glupy                : $BUILD_GLUPY"
926 echo "Use syslog           : $USE_SYSLOG"
927 echo "XML output           : $BUILD_XML_OUTPUT"
928 echo "QEMU Block formats   : $BUILD_QEMU_BLOCK"
929 echo "Encryption xlator    : $BUILD_CRYPT_XLATOR"
930 echo