build: GlusterFS Unit Test Framework
[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 # Initialize CFLAGS before usage
188 AC_ARG_ENABLE([debug],
189               AC_HELP_STRING([--enable-debug],
190                              [Enable debug build options.]))
191 if test "x$enable_debug" = "xyes"; then
192         BUILD_DEBUG=yes
193         CFLAGS="${CFLAGS} -g -O0 -DDEBUG"
194 else
195         BUILD_DEBUG=no
196         CFLAGS="${CFLAGS} -g -O2"
197 fi
198
199 AC_ARG_WITH(pkgconfigdir,
200             [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
201             [pkgconfigdir=$withval],
202             [pkgconfigdir='${libdir}/pkgconfig'])
203 AC_SUBST(pkgconfigdir)
204
205 AC_ARG_WITH(mountutildir,
206             [  --with-mountutildir=DIR mount helper utility in DIR @<:@/sbin@:>@],
207             [mountutildir=$withval],
208             [mountutildir='/sbin'])
209 AC_SUBST(mountutildir)
210
211 AC_ARG_WITH(systemddir,
212             [  --with-systemddir=DIR systemd service files in DIR @<:@/usr/lib/systemd/system@:>@],
213             [systemddir=$withval],
214             [systemddir='/usr/lib/systemd/system'])
215 AC_SUBST(systemddir)
216
217 AC_ARG_WITH(initdir,
218             [  --with-initdir=DIR init.d scripts in DIR @<:@/etc/init.d@:>@],
219             [initdir=$withval],
220             [initdir='/etc/init.d'])
221 AC_SUBST(initdir)
222
223 AC_ARG_WITH(launchddir,
224             [  --with-launchddir=DIR launchd services in DIR @<:@/Library/LaunchDaemons@:>@],
225             [launchddir=$withval],
226             [launchddir='/Library/LaunchDaemons'])
227 AC_SUBST(launchddir)
228
229 AC_ARG_WITH([ocf],
230             [AS_HELP_STRING([--without-ocf], [build OCF-compliant cluster resource agents])],
231             ,
232             [OCF_SUBDIR='ocf'],
233             )
234 AC_SUBST(OCF_SUBDIR)
235
236 # LEX needs a check
237 AC_PROG_LEX
238 if test  "x${LEX}" != "xflex" -a "x${FLEX}" != "xlex"; then
239    AC_MSG_ERROR([Flex or lex required to build glusterfs.])
240 fi
241
242 dnl
243 dnl Word sizes...
244 dnl
245 AC_CHECK_SIZEOF(short)
246 AC_CHECK_SIZEOF(int)
247 AC_CHECK_SIZEOF(long)
248 AC_CHECK_SIZEOF(long long)
249 SIZEOF_SHORT=$ac_cv_sizeof_short
250 SIZEOF_INT=$ac_cv_sizeof_int
251 SIZEOF_LONG=$ac_cv_sizeof_long
252 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
253 AC_SUBST(SIZEOF_SHORT)
254 AC_SUBST(SIZEOF_INT)
255 AC_SUBST(SIZEOF_LONG)
256 AC_SUBST(SIZEOF_LONG_LONG)
257
258 # YACC needs a check
259 AC_PROG_YACC
260 if test "x${YACC}" = "xbyacc" -o "x${YACC}" = "xyacc" -o "x${YACC}" = "x"; then
261    AC_MSG_ERROR([GNU Bison required to build glusterfs.])
262 fi
263
264 AC_CHECK_TOOL([LD],[ld])
265
266 AC_CHECK_LIB([crypto], [MD5], , AC_MSG_ERROR([OpenSSL crypto library is required to build glusterfs]))
267
268 AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs]))
269
270 AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs])))
271
272 AC_CHECK_FUNC([gettext], [has_gettext=yes], AC_CHECK_LIB([intl], [gettext], , AC_MSG_ERROR([gettext support is required to build glusterfs])))
273
274 AC_CHECK_HEADERS([sys/xattr.h])
275
276 AC_CHECK_HEADERS([sys/extattr.h])
277
278 AC_CHECK_HEADERS([openssl/md5.h])
279
280 AC_CHECK_HEADERS([linux/falloc.h])
281
282 case $host_os in
283   darwin*)
284     if ! test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -ge 5; then
285       AC_MSG_ERROR([You need at least OS X 10.5 (Leopard) to build Glusterfs])
286     fi
287     ;;
288 esac
289
290 dnl Mac OS X does not have spinlocks
291 AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
292 if test "x${have_spinlock}" = "xyes"; then
293    AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
294 fi
295 AC_SUBST(HAVE_SPINLOCK)
296
297 dnl some os may not have GNU defined strnlen function
298 AC_CHECK_FUNC([strnlen], [have_strnlen=yes])
299 if test "x${have_strnlen}" = "xyes"; then
300    AC_DEFINE(HAVE_STRNLEN, 1, [define if found strnlen])
301 fi
302 AC_SUBST(HAVE_STRNLEN)
303
304
305 AC_CHECK_FUNC([setfsuid], [have_setfsuid=yes])
306 AC_CHECK_FUNC([setfsgid], [have_setfsgid=yes])
307
308 if test "x${have_setfsuid}" = "xyes" -a "x${have_setfsgid}" = "xyes"; then
309   AC_DEFINE(HAVE_SET_FSID, 1, [define if found setfsuid setfsgid])
310 fi
311
312
313 # FUSE section
314 AC_ARG_ENABLE([fuse-client],
315               AC_HELP_STRING([--disable-fuse-client],
316                              [Do not build the fuse client. NOTE: you cannot mount glusterfs without the client]))
317
318 BUILD_FUSE_CLIENT=no
319 if test "x$enable_fuse_client" != "xno"; then
320    FUSE_CLIENT_SUBDIR=fuse
321    BUILD_FUSE_CLIENT="yes"
322 fi
323
324 AC_ARG_ENABLE([bd-xlator],
325               AC_HELP_STRING([--enable-bd-xlator], [Build BD xlator]))
326
327 if test "x$enable_bd_xlator" != "xno"; then
328   AC_CHECK_LIB([lvm2app],
329                [lvm_init,lvm_lv_from_name],
330                [HAVE_BD_LIB="yes"],
331                [HAVE_BD_LIB="no"])
332
333 if test "x$HAVE_BD_LIB" = "xyes"; then
334     # lvm_lv_from_name() has been made public with lvm2-2.02.79
335     AC_CHECK_DECLS(
336                   [lvm_lv_from_name],
337                   [NEED_LVM_LV_FROM_NAME_DECL="no"],
338                   [NEED_LVM_LV_FROM_NAME_DECL="yes"],
339                   [[#include <lvm2app.h>]])
340   fi
341 fi
342
343 if test "x$enable_bd_xlator" = "xyes" -a "x$HAVE_BD_LIB" = "xno"; then
344    echo "BD xlator requested but required lvm2 development library not found."
345    exit 1
346 fi
347
348 BUILD_BD_XLATOR=no
349 if test "x${enable-bd-xlator}" != "xno" -a "x${HAVE_BD_LIB}" = "xyes"; then
350   BUILD_BD_XLATOR=yes
351   AC_DEFINE(HAVE_BD_XLATOR, 1, [define if lvm2app library found and bd xlator
352                             enabled])
353   if test "x$NEED_LVM_LV_FROM_NAME_DECL" = "xyes"; then
354     AC_DEFINE(NEED_LVM_LV_FROM_NAME_DECL, 1, [defined if lvm_lv_from_name()
355                   was not found in the lvm2app.h header, but can be linked])
356   fi
357 fi
358
359 AM_CONDITIONAL([ENABLE_BD_XLATOR], [test x$BUILD_BD_XLATOR = xyes])
360
361 # start encryption/crypt section
362
363 AC_CHECK_HEADERS([openssl/cmac.h], [have_cmac_h=yes], [have_cmac_h=no])
364
365 AC_ARG_ENABLE([crypt-xlator],
366         AC_HELP_STRING([--enable-crypt-xlator], [Build crypt encryption xlator]))
367
368 if test "x$enable_crypt_xlator" = "xyes" -a "x$have_cmac_h" = "xno"; then
369    echo "Encryption xlator requires OpenSSL with cmac.h"
370    exit 1
371 fi
372
373 BUILD_CRYPT_XLATOR=no
374 if test "x$enable_crypt_xlator" != "xno" -a "x$have_cmac_h" = "xyes"; then
375    BUILD_CRYPT_XLATOR=yes
376    AC_DEFINE(HAVE_CRYPT_XLATOR, 1, [enable building crypt encryption xlator])
377 fi
378
379 AM_CONDITIONAL([ENABLE_CRYPT_XLATOR], [test x$BUILD_CRYPT_XLATOR = xyes])
380
381 AC_SUBST(FUSE_CLIENT_SUBDIR)
382 # end FUSE section
383
384
385 # FUSERMOUNT section
386 AC_ARG_ENABLE([fusermount],
387               AC_HELP_STRING([--disable-fusermount],
388                              [Use system's fusermount]))
389
390 BUILD_FUSERMOUNT="yes"
391 if test "x$enable_fusermount" = "xno"; then
392   BUILD_FUSERMOUNT="no"
393 else
394   AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount])
395   FUSERMOUNT_SUBDIR="contrib/fuse-util"
396 fi
397
398 AC_SUBST(FUSERMOUNT_SUBDIR)
399 #end FUSERMOUNT section
400
401 # QEMU_BLOCK section
402
403 AC_ARG_ENABLE([qemu-block],
404                 AC_HELP_STRING([--enable-qemu-block],
405                         [Build QEMU Block formats translator]))
406
407 if test "x$enable_qemu_block" != "xno"; then
408   PKG_CHECK_MODULES([GLIB], [glib-2.0],
409                     [HAVE_GLIB_2="yes"],
410                     [HAVE_GLIB_2="no"])
411 fi
412
413 if test "x$enable_qemu_block" = "xyes" -a "x$HAVE_GLIB_2" = "xno"; then
414    echo "QEMU Block formats translator requires libglib-2.0, but missing."
415    exit 1
416 fi
417
418 BUILD_QEMU_BLOCK=no
419 if test "x${enable_qemu_block}" != "xno" -a "x${HAVE_GLIB_2}" = "xyes"; then
420   BUILD_QEMU_BLOCK=yes
421   AC_DEFINE(HAVE_QEMU_BLOCK, 1, [define if libglib-2.0 library found and QEMU
422                              Block translator enabled])
423 fi
424
425 AM_CONDITIONAL([ENABLE_QEMU_BLOCK], [test x$BUILD_QEMU_BLOCK = xyes])
426
427 # end QEMU_BLOCK section
428
429 # EPOLL section
430 AC_ARG_ENABLE([epoll],
431               AC_HELP_STRING([--disable-epoll],
432                              [Use poll instead of epoll.]))
433
434 BUILD_EPOLL=no
435 if test "x$enable_epoll" != "xno"; then
436    AC_CHECK_HEADERS([sys/epoll.h],
437                     [BUILD_EPOLL=yes],
438                     [BUILD_EPOLL=no])
439 fi
440 # end EPOLL section
441
442
443 # IBVERBS section
444 AC_ARG_ENABLE([ibverbs],
445               AC_HELP_STRING([--disable-ibverbs],
446                              [Do not build the ibverbs transport]))
447
448 if test "x$enable_ibverbs" != "xno"; then
449   AC_CHECK_LIB([ibverbs],
450                [ibv_get_device_list],
451                [HAVE_LIBIBVERBS="yes"],
452                [HAVE_LIBIBVERBS="no"])
453   AC_CHECK_LIB([rdmacm], [rdma_create_id], [HAVE_RDMACM="yes"], [HAVE_RDMACM="no"])
454 fi
455
456 if test "x$enable_ibverbs" = "xyes"; then
457    if test "x$HAVE_LIBIBVERBS" = "xno"; then
458       echo "ibverbs-transport requested, but libibverbs is not present."
459       exit 1
460    fi
461
462    if test "x$HAVE_RDMACM" = "xno"; then
463       echo "ibverbs-transport requested, but librdmacm is not present."
464       exit 1
465    fi
466 fi
467
468 BUILD_RDMA=no
469 BUILD_IBVERBS=no
470 if test "x$enable_ibverbs" != "xno" -a "x$HAVE_LIBIBVERBS" = "xyes" -a "x$HAVE_RDMACM" = "xyes"; then
471   IBVERBS_SUBDIR=ib-verbs
472   BUILD_IBVERBS=yes
473   RDMA_SUBDIR=rdma
474   BUILD_RDMA=yes
475 fi
476
477 AC_SUBST(IBVERBS_SUBDIR)
478 AC_SUBST(RDMA_SUBDIR)
479 # end IBVERBS section
480
481
482 # SYNCDAEMON section
483 AC_ARG_ENABLE([georeplication],
484               AC_HELP_STRING([--disable-georeplication],
485                              [Do not install georeplication components]))
486
487 BUILD_SYNCDAEMON=no
488 case $host_os in
489      linux*)
490 #do nothing
491        ;;
492      netbsd*)
493 #do nothing
494        ;;
495      *)
496 #disabling geo replication for non-linux platforms
497         enable_georeplication=no
498         ;;
499 esac
500 SYNCDAEMON_COMPILE=0
501 if test "x$enable_georeplication" != "xno"; then
502   SYNCDAEMON_SUBDIR=geo-replication
503   SYNCDAEMON_COMPILE=1
504
505   BUILD_SYNCDAEMON="yes"
506   AM_PATH_PYTHON([2.4])
507   echo -n "checking if python is python 2.x... "
508   if echo $PYTHON_VERSION | grep ^2; then
509     :
510   else
511     echo no
512     AC_MSG_ERROR([only python 2.x is supported])
513   fi
514   echo -n "checking if python has ctypes support... "
515   if "$PYTHON" -c 'import ctypes' 2>/dev/null; then
516     echo yes
517   else
518     echo no
519     AC_MSG_ERROR([python does not have ctypes support])
520   fi
521 fi
522 AC_SUBST(SYNCDAEMON_COMPILE)
523 AC_SUBST(SYNCDAEMON_SUBDIR)
524 # end SYNCDAEMON section
525
526 # CDC xlator - check if libz is present if so enable HAVE_LIB_Z
527 echo -n "checking if libz is present... "
528
529 PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0],
530                   [echo "yes (features requiring zlib enabled)"  AC_DEFINE(HAVE_LIB_Z, 1, [define if zlib is present])],
531                   [echo "no"] )
532
533 AC_SUBST(LIBZ_CFLAGS)
534 AC_SUBST(LIBZ_LIBS)
535 # end CDC xlator secion
536
537 # check for systemtap/dtrace
538 BUILD_SYSTEMTAP=no
539 AC_MSG_CHECKING([whether to include systemtap tracing support])
540 AC_ARG_ENABLE([systemtap],
541               [AS_HELP_STRING([--enable-systemtap],
542               [Enable inclusion of systemtap trace support])],
543               [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP="def"])
544
545 AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test "x${ENABLE_SYSTEMTAP}" = "xyes"])
546 AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
547
548 if test "x${ENABLE_SYSTEMTAP}" != "xno"; then
549     AC_CHECK_PROG(DTRACE, dtrace, "yes", "no")
550     AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND="yes"],
551                     [SDT_H_FOUND="no"])
552 fi
553
554 if test "x${ENABLE_SYSTEMTAP}" = "xyes"; then
555     if test "x${DTRACE}" = "xno"; then
556         AC_MSG_ERROR([dtrace not found])
557     elif test "$x{SDT_H_FOUND}" = "xno"; then
558         AC_MSG_ERROR([systemtap support needs sys/sdt.h header])
559     fi
560 fi
561
562 if test "x${DTRACE}" = "xyes" -a "x${SDT_H_FOUND}" = "xyes"; then
563     AC_MSG_CHECKING([x"${DTRACE}"xy"${SDT_H_FOUND}"y])
564     AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using  probes.])
565     BUILD_SYSTEMTAP=yes
566 fi
567 # end of systemtap/dtrace
568
569 # xml-output
570 AC_ARG_ENABLE([xml-output],
571               AC_HELP_STRING([--disable-xml-output],
572                              [Disable the xml output]))
573 BUILD_XML_OUTPUT="yes"
574 if test "x$enable_xml_output" != "xno"; then
575     #check if libxml is present if so enable HAVE_LIB_XML
576     m4_ifdef([AM_PATH_XML2],[AM_PATH_XML2([2.6.19])], [no_xml=yes])
577     if test "x${no_xml}" = "x"; then
578         AC_DEFINE([HAVE_LIB_XML], [1], [Define to 1 if using libxml2.])
579     else
580         if test "x$enable_georeplication" != "xno"; then
581            AC_MSG_ERROR([libxml2 devel libraries not found])
582         else
583            AC_MSG_WARN([libxml2 devel libraries not found disabling XML support])
584            BUILD_XML_OUTPUT="no"
585         fi
586
587     fi
588 else
589     if test "x$enable_georeplication" != "xno"; then
590        AC_MSG_ERROR([geo-replication requires xml output])
591     fi
592     BUILD_XML_OUTPUT="no"
593 fi
594 # end of xml-output
595
596 dnl FreeBSD > 5 has execinfo as a Ported library for giving a workaround
597 dnl solution to GCC backtrace functionality
598
599 AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes],
600                AC_CHECK_LIB([execinfo], [backtrace], [have_backtrace=yes]))
601 dnl               AC_MSG_ERROR([libexecinfo not found libexecinfo required.])))
602
603 if test "x${have_backtrace}" = "xyes"; then
604    AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
605 fi
606 AC_SUBST(HAVE_BACKTRACE)
607
608 dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
609 AC_CHECK_FUNC([malloc_stats], [have_malloc_stats=yes])
610 if test "x${have_malloc_stats}" = "xyes"; then
611    AC_DEFINE(HAVE_MALLOC_STATS, 1, [define if found malloc_stats])
612 fi
613 AC_SUBST(HAVE_MALLOC_STATS)
614
615 dnl Linux, Solaris, Cygwin
616 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
617 dnl FreeBSD, NetBSD
618 AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec])
619 case $host_os in
620         *netbsd*)
621         CFLAGS="${CFLAGS} -D_INCOMPLETE_XOPEN_C063"
622         ;;
623 esac
624 AC_CHECK_FUNC([linkat], [have_linkat=yes])
625 if test "x${have_linkat}" = "xyes"; then
626    AC_DEFINE(HAVE_LINKAT, 1, [define if found linkat])
627 fi
628 AC_SUBST(HAVE_LINKAT)
629
630 dnl check for Monotonic clock
631 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])))
632
633 dnl Add cmockery2 for unit testing
634 AC_CONFIG_SUBDIRS([cmockery2])
635 UNITTEST_CFLAGS='-g -Wall -DUNIT_TESTING=1 -DDEBUG -Werror -O0 --coverage'
636 UNITTEST_CPPFLAGS='-I$(top_srcdir)/cmockery2/src'
637 UNITTEST_LDADD='$(top_builddir)/cmockery2/libcmockery.la'
638 UNITTEST_LDFLAGS=-lgcov
639 CFLAGS="$CFLAGS ${UNITTEST_CPPFLAGS}"
640 AC_SUBST(UNITTEST_CFLAGS)
641 AC_SUBST(UNITTEST_CPPFLAGS)
642 AC_SUBST(UNITTEST_LDADD)
643 AC_SUBST(UNITTEST_LDFLAGS)
644
645 dnl Check for argp
646 AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))
647 AC_CONFIG_SUBDIRS(argp-standalone)
648
649 BUILD_ARGP_STANDALONE=no
650 if test "x${ac_cv_header_argp_h}" = "xno"; then
651    BUILD_ARGP_STANDALONE=yes
652    ARGP_STANDALONE_CPPFLAGS='-I${top_srcdir}/argp-standalone'
653    ARGP_STANDALONE_LDADD='${top_builddir}/argp-standalone/libargp.a'
654 fi
655
656 AC_SUBST(ARGP_STANDALONE_CPPFLAGS)
657 AC_SUBST(ARGP_STANDALONE_LDADD)
658
659 AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))
660
661 AC_CHECK_FUNC([llistxattr], [have_llistxattr=yes])
662 if test "x${have_llistxattr}" = "xyes"; then
663    AC_DEFINE(HAVE_LLISTXATTR, 1, [define if llistxattr exists])
664 fi
665
666 AC_CHECK_FUNC([fdatasync], [have_fdatasync=yes])
667 if test "x${have_fdatasync}" = "xyes"; then
668    AC_DEFINE(HAVE_FDATASYNC, 1, [define if fdatasync exists])
669 fi
670
671 AC_CHECK_FUNC([fallocate], [have_fallocate=yes])
672 if test "x${have_fallocate}" = "xyes"; then
673    AC_DEFINE(HAVE_FALLOCATE, 1, [define if fallocate exists])
674 fi
675
676 AC_CHECK_FUNC([posix_fallocate], [have_posix_fallocate=yes])
677 if test "x${have_posix_fallocate}" = "xyes"; then
678    AC_DEFINE(HAVE_POSIX_FALLOCATE, 1, [define if posix_fallocate exists])
679 fi
680
681
682 # Check the distribution where you are compiling glusterfs on
683
684 GF_DISTRIBUTION=
685 AC_CHECK_FILE([/etc/debian_version])
686 AC_CHECK_FILE([/etc/SuSE-release])
687 AC_CHECK_FILE([/etc/redhat-release])
688
689 if test "x$ac_cv_file__etc_debian_version" = "xyes"; then
690    GF_DISTRIBUTION=Debian
691 fi
692 if test "x$ac_cv_file__etc_SuSE_release" = "xyes"; then
693    GF_DISTRIBUTION=SuSE
694 fi
695 if test "x$ac_cv_file__etc_redhat_release" = "xyes"; then
696    GF_DISTRIBUTION=Redhat
697 fi
698
699 AC_SUBST(GF_DISTRIBUTION)
700
701 GF_HOST_OS=""
702 GF_LDFLAGS="-rdynamic"
703
704 # check for gcc -Werror=format-security
705 saved_CFLAGS=$CFLAGS
706 CFLAGS="-Wformat -Werror=format-security"
707 AC_MSG_CHECKING([whether $CC accepts -Werror=format-security])
708 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no])
709 echo $cc_werror_format_security
710 if test "x$cc_werror_format_security" = "xno"; then
711     CFLAGS="$saved_CFLAGS"
712 else
713     CFLAGS="$saved_CFLAGS $CFLAGS"
714 fi
715
716 # check for gcc -Werror=implicit-function-declaration
717 saved_CFLAGS=$CFLAGS
718 CFLAGS="-Werror=implicit-function-declaration"
719 AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration])
720 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no])
721 echo $cc_werror_implicit
722 if test "x$cc_werror_implicit" = "xno"; then
723     CFLAGS="$saved_CFLAGS"
724 else
725     CFLAGS="$saved_CFLAGS $CFLAGS"
726 fi
727
728 case $host_os in
729      linux*)
730         GF_HOST_OS="GF_LINUX_HOST_OS"
731         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS}"
732         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
733         GF_LDADD="${ARGP_STANDALONE_LDADD}"
734         GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\""
735         ;;
736      solaris*)
737         GF_HOST_OS="GF_SOLARIS_HOST_OS"
738         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -m64"
739         GF_LDFLAGS=""
740         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
741         GF_LDADD="${ARGP_STANDALONE_LDADD}"
742         GF_GLUSTERFS_LIBS="-lnsl -lresolv -lsocket"
743         BUILD_FUSE_CLIENT=no
744         FUSE_CLIENT_SUBDIR=""
745         ;;
746      *netbsd*)
747         GF_HOST_OS="GF_BSD_HOST_OS"
748         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_INCOMPLETE_XOPEN_C063"
749         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
750         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
751         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
752         GF_LDADD="${ARGP_STANDALONE_LDADD}"
753         if test "x$ac_cv_header_execinfo_h" = "xyes"; then
754            GF_GLUSTERFS_LIBS="-lexecinfo"
755         fi
756         GF_FUSE_LDADD="-lperfuse"
757         BUILD_FUSE_CLIENT=yes
758         LEXLIB=""
759         ;;
760      *bsd*)
761         GF_HOST_OS="GF_BSD_HOST_OS"
762         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS}"
763         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
764         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
765         GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
766         GF_LDADD="${ARGP_STANDALONE_LDADD}"
767         if test "x$ac_cv_header_execinfo_h" = "xyes"; then
768            GF_GLUSTERFS_LIBS="-lexecinfo"
769         fi
770         BUILD_FUSE_CLIENT=no
771         ;;
772      darwin*)
773         GF_HOST_OS="GF_DARWIN_HOST_OS"
774         LIBTOOL=glibtool
775         GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D__DARWIN_64_BIT_INO_T -bundle -undefined suppress -flat_namespace -D_XOPEN_SOURCE"
776         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
777         GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
778         GF_GLUSTERFS_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D__DARWIN_64_BIT_INO_T -undefined suppress -flat_namespace"
779         GF_LDADD="${ARGP_STANDALONE_LDADD}"
780         GF_FUSE_CFLAGS="-I\$(CONTRIBDIR)/macfuse"
781         ;;
782 esac
783
784 # enable debug section
785 AC_ARG_ENABLE([debug],
786               AC_HELP_STRING([--enable-debug],
787                              [Enable debug build options.]))
788
789 # syslog section
790 AC_ARG_ENABLE([syslog],
791               AC_HELP_STRING([--disable-syslog],
792                              [Disable syslog for logging]))
793
794 USE_SYSLOG="yes"
795 if test "x$enable_syslog" != "xno"; then
796   AC_DEFINE(GF_USE_SYSLOG, 1, [Use syslog for logging])
797 else
798   USE_SYSLOG="no"
799 fi
800 AM_CONDITIONAL([ENABLE_SYSLOG], [test x$USE_SYSLOG = xyes])
801 #end syslog section
802
803 BUILD_READLINE=no
804 AC_CHECK_LIB([readline -lcurses],[readline],[RLLIBS="-lreadline -lcurses"])
805 AC_CHECK_LIB([readline -ltermcap],[readline],[RLLIBS="-lreadline -ltermcap"])
806 AC_CHECK_LIB([readline -lncurses],[readline],[RLLIBS="-lreadline -lncurses"])
807
808 if test "x$RLLIBS" != "x"; then
809    AC_DEFINE(HAVE_READLINE, 1, [readline enabled CLI])
810    BUILD_READLINE=yes
811 fi
812
813 BUILD_LIBAIO=no
814 AC_CHECK_LIB([aio],[io_setup],[LIBAIO="-laio"])
815
816 if test "x$LIBAIO" != "x"; then
817    AC_DEFINE(HAVE_LIBAIO, 1, [libaio based POSIX enabled])
818    BUILD_LIBAIO=yes
819 fi
820
821 # glupy section
822 BUILD_GLUPY=no
823 have_python2=no
824 have_Python_h=no
825
826 AM_PATH_PYTHON()
827 if echo $PYTHON_VERSION | grep ^2; then
828   have_python2=yes
829 fi
830
831 # Save flags before testing python
832 saved_CFLAGS=$CFLAGS
833 saved_CPPFLAGS=$CPPFLAGS
834 saved_LDFLAGS=$LDFLAGS
835 CFLAGS=`${PYTHON}-config --cflags`
836 CPPFLAGS=$CFLAGS
837 LDFLAGS="-L`${PYTHON}-config --prefix`/lib `${PYTHON}-config --ldflags`"
838 AC_CHECK_HEADERS([python$PYTHON_VERSION/Python.h],[have_Python_h=yes],[])
839 AC_ARG_ENABLE([glupy],
840               AS_HELP_STRING([--enable-glupy],
841                              [build glupy]))
842 case x$enable_glupy in
843    xyes)
844       if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
845          BUILD_GLUPY=yes
846         PYTHONDEV_CFLAGS="$CFLAGS"
847         PYTHONDEV_CPPFLAGS="$CPPFLAGS"
848         PYTHONDEV_LDFLAGS="$LDFLAGS"
849         AC_SUBST(PYTHONDEV_CFLAGS)
850         AC_SUBST(PYTHONDEV_CPPFLAGS)
851         AC_SUBST(PYTHONDEV_LDFLAGS)
852       else
853          AC_MSG_ERROR([glupy requires python-devel/python-dev package and python2.x])
854       fi
855       ;;
856    xno)
857       ;;
858    *)
859       if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
860          BUILD_GLUPY=yes
861         PYTHONDEV_CFLAGS="$CFLAGS"
862         PYTHONDEV_CPPFLAGS="$CPPFLAGS"
863         PYTHONDEV_LDFLAGS="$LDFLAGS"
864         AC_SUBST(PYTHONDEV_CFLAGS)
865         AC_SUBST(PYTHONDEV_CPPFLAGS)
866         AC_SUBST(PYTHONDEV_LDFLAGS)
867       else
868          AC_MSG_WARN([
869         ---------------------------------------------------------------------------------
870          cannot build glupy. python 2.x and python-devel/python-dev package are required.
871         ---------------------------------------------------------------------------------])
872       fi
873       ;;
874 esac
875 # Restore flags
876 CFLAGS=$saved_CFLAGS
877 CPPFLAGS=$saved_CPPFLAGS
878 LDFLAGS=$saved_LDFLAGS
879
880 if test "x$BUILD_GLUPY" = "xyes"; then
881    BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"`
882    BUILD_PYTHON_LIB=python$PYTHON_VERSION
883    GLUPY_SUBDIR=glupy
884    GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile
885    GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile
886    echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB"
887    AC_SUBST(BUILD_PYTHON_INC)
888    AC_SUBST(BUILD_PYTHON_LIB)
889    AC_SUBST(GLUPY_SUBDIR)
890    AC_SUBST(GLUPY_SUBDIR_MAKEFILE)
891    AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE)
892 fi
893 # end glupy section
894
895 AC_SUBST(CFLAGS)
896 # end enable debug section
897
898 AC_SUBST(GF_HOST_OS)
899 AC_SUBST([GF_GLUSTERFS_LIBS])
900 AC_SUBST(GF_GLUSTERFS_CFLAGS)
901 AC_SUBST(GF_CFLAGS)
902 AC_SUBST(GF_LDFLAGS)
903 AC_SUBST(GF_LDADD)
904 AC_SUBST(GF_FUSE_LDADD)
905 AC_SUBST(GF_FUSE_CFLAGS)
906 AC_SUBST(RLLIBS)
907 AC_SUBST(LIBAIO)
908 AC_SUBST(AM_MAKEFLAGS)
909 AC_SUBST(AM_LIBTOOLFLAGS)
910
911 CONTRIBDIR='$(top_srcdir)/contrib'
912 AC_SUBST(CONTRIBDIR)
913
914 GF_CPPDEFINES='-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)'
915 GF_CPPINCLUDES='-I$(top_srcdir)/libglusterfs/src -I$(CONTRIBDIR)/uuid $(UNITTEST_CPPFLAGS)'
916 GF_CPPFLAGS="$GF_CPPDEFINES $GF_CPPINCLUDES"
917 AC_SUBST([GF_CPPFLAGS])
918
919 AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS")
920
921 AM_CONDITIONAL([GF_INSTALL_VAR_LIB_GLUSTERD], test ! -d ${localstatedir}/lib/glusterd && test -d ${sysconfdir}/glusterd )
922
923 dnl pkg-config versioning
924 GFAPI_VERSION="6.0.0"
925 LIBGFCHANGELOG_VERSION="0.0.1"
926 AC_SUBST(GFAPI_VERSION)
927 AC_SUBST(LIBGFCHANGELOG_VERSION)
928
929 dnl libtool versioning
930 LIBGFXDR_LT_VERSION="0:1:0"
931 LIBGFRPC_LT_VERSION="0:1:0"
932 LIBGLUSTERFS_LT_VERSION="0:1:0"
933 LIBGFCHANGELOG_LT_VERSION="0:1:0"
934 GFAPI_LT_VERSION="6:0:0"
935 AC_SUBST(LIBGFXDR_LT_VERSION)
936 AC_SUBST(LIBGFRPC_LT_VERSION)
937 AC_SUBST(LIBGLUSTERFS_LT_VERSION)
938 AC_SUBST(LIBGFCHANGELOG_LT_VERSION)
939 AC_SUBST(GFAPI_LT_VERSION)
940
941 AC_OUTPUT
942
943 echo
944 echo "GlusterFS configure summary"
945 echo "==========================="
946 echo "FUSE client          : $BUILD_FUSE_CLIENT"
947 echo "Infiniband verbs     : $BUILD_IBVERBS"
948 echo "epoll IO multiplex   : $BUILD_EPOLL"
949 echo "argp-standalone      : $BUILD_ARGP_STANDALONE"
950 echo "fusermount           : $BUILD_FUSERMOUNT"
951 echo "readline             : $BUILD_READLINE"
952 echo "georeplication       : $BUILD_SYNCDAEMON"
953 echo "Linux-AIO            : $BUILD_LIBAIO"
954 echo "Enable Debug         : $BUILD_DEBUG"
955 echo "systemtap            : $BUILD_SYSTEMTAP"
956 echo "Block Device xlator  : $BUILD_BD_XLATOR"
957 echo "glupy                : $BUILD_GLUPY"
958 echo "Use syslog           : $USE_SYSLOG"
959 echo "XML output           : $BUILD_XML_OUTPUT"
960 echo "QEMU Block formats   : $BUILD_QEMU_BLOCK"
961 echo "Encryption xlator    : $BUILD_CRYPT_XLATOR"
962 echo