glusterfs
/
configure.ac
1948 строк · 68.3 Кб
1dnl Copyright (c) 2006-2016 Red Hat, Inc. <http://www.redhat.com>
2dnl This file is part of GlusterFS.
3dnl
4dnl This file is licensed to you under your choice of the GNU Lesser
5dnl General Public License, version 3 or any later version (LGPLv3 or
6dnl later), or the GNU General Public License, version 2 (GPLv2), in all
7dnl cases as published by the Free Software Foundation.
8
9// clang-format off
10AC_INIT([glusterfs],[m4_esyscmd([build-aux/pkg-version --version])],[gluster-users@gluster.org],[],[https://github.com/gluster/glusterfs.git])
11
12AC_SUBST([PACKAGE_RELEASE],
13[m4_esyscmd([build-aux/pkg-version --release])])
14
15AM_INIT_AUTOMAKE([tar-pax foreign])
16
17# Removes warnings when using automake 1.14 around (...but option 'subdir-objects' is disabled )
18#but libglusterfs fails to build with contrib (Then are not set up that way?)
19#AM_INIT_AUTOMAKE([subdir-objects])
20
21m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
22
23AC_CONFIG_HEADERS([config.h site.h])
24
25AC_CONFIG_FILES([Makefile
26libglusterfs/Makefile
27libglusterfs/src/Makefile
28geo-replication/src/peer_gsec_create
29geo-replication/src/peer_mountbroker
30geo-replication/src/peer_mountbroker.py
31geo-replication/src/peer_georep-sshkey.py
32extras/peer_add_secret_pub
33geo-replication/syncdaemon/conf.py
34geo-replication/gsyncd.conf
35extras/snap_scheduler/conf.py
36glusterfsd/Makefile
37glusterfsd/src/Makefile
38rpc/Makefile
39rpc/rpc-lib/Makefile
40rpc/rpc-lib/src/Makefile
41rpc/rpc-transport/Makefile
42rpc/rpc-transport/socket/Makefile
43rpc/rpc-transport/socket/src/Makefile
44rpc/xdr/Makefile
45rpc/xdr/src/Makefile
46xlators/Makefile
47xlators/meta/Makefile
48xlators/meta/src/Makefile
49xlators/mount/Makefile
50xlators/mount/fuse/Makefile
51xlators/mount/fuse/src/Makefile
52xlators/mount/fuse/utils/mount.glusterfs
53xlators/mount/fuse/utils/mount_glusterfs
54xlators/mount/fuse/utils/Makefile
55xlators/storage/Makefile
56xlators/storage/posix/Makefile
57xlators/storage/posix/src/Makefile
58xlators/cluster/Makefile
59xlators/cluster/afr/Makefile
60xlators/cluster/afr/src/Makefile
61xlators/cluster/dht/Makefile
62xlators/cluster/dht/src/Makefile
63xlators/cluster/ec/Makefile
64xlators/cluster/ec/src/Makefile
65xlators/performance/Makefile
66xlators/performance/write-behind/Makefile
67xlators/performance/write-behind/src/Makefile
68xlators/performance/read-ahead/Makefile
69xlators/performance/read-ahead/src/Makefile
70xlators/performance/readdir-ahead/Makefile
71xlators/performance/readdir-ahead/src/Makefile
72xlators/performance/io-threads/Makefile
73xlators/performance/io-threads/src/Makefile
74xlators/performance/io-cache/Makefile
75xlators/performance/io-cache/src/Makefile
76xlators/performance/quick-read/Makefile
77xlators/performance/quick-read/src/Makefile
78xlators/performance/open-behind/Makefile
79xlators/performance/open-behind/src/Makefile
80xlators/performance/md-cache/Makefile
81xlators/performance/md-cache/src/Makefile
82xlators/performance/nl-cache/Makefile
83xlators/performance/nl-cache/src/Makefile
84xlators/debug/Makefile
85xlators/debug/sink/Makefile
86xlators/debug/sink/src/Makefile
87xlators/debug/trace/Makefile
88xlators/debug/trace/src/Makefile
89xlators/debug/error-gen/Makefile
90xlators/debug/error-gen/src/Makefile
91xlators/debug/delay-gen/Makefile
92xlators/debug/delay-gen/src/Makefile
93xlators/debug/io-stats/Makefile
94xlators/debug/io-stats/src/Makefile
95xlators/protocol/Makefile
96xlators/protocol/auth/Makefile
97xlators/protocol/auth/addr/Makefile
98xlators/protocol/auth/addr/src/Makefile
99xlators/protocol/auth/login/Makefile
100xlators/protocol/auth/login/src/Makefile
101xlators/protocol/client/Makefile
102xlators/protocol/client/src/Makefile
103xlators/protocol/server/Makefile
104xlators/protocol/server/src/Makefile
105xlators/features/Makefile
106xlators/features/arbiter/Makefile
107xlators/features/arbiter/src/Makefile
108xlators/features/thin-arbiter/Makefile
109xlators/features/thin-arbiter/src/Makefile
110xlators/features/changelog/Makefile
111xlators/features/changelog/src/Makefile
112xlators/features/changelog/lib/Makefile
113xlators/features/changelog/lib/src/Makefile
114xlators/features/locks/Makefile
115xlators/features/locks/src/Makefile
116xlators/features/simple-quota/Makefile
117xlators/features/simple-quota/src/Makefile
118xlators/features/quota/Makefile
119xlators/features/quota/src/Makefile
120xlators/features/marker/Makefile
121xlators/features/marker/src/Makefile
122xlators/features/selinux/Makefile
123xlators/features/selinux/src/Makefile
124xlators/features/sdfs/Makefile
125xlators/features/sdfs/src/Makefile
126xlators/features/read-only/Makefile
127xlators/features/read-only/src/Makefile
128xlators/features/compress/Makefile
129xlators/features/compress/src/Makefile
130xlators/features/namespace/Makefile
131xlators/features/namespace/src/Makefile
132xlators/features/quiesce/Makefile
133xlators/features/quiesce/src/Makefile
134xlators/features/barrier/Makefile
135xlators/features/barrier/src/Makefile
136xlators/features/index/Makefile
137xlators/features/index/src/Makefile
138xlators/features/gfid-access/Makefile
139xlators/features/gfid-access/src/Makefile
140xlators/features/trash/Makefile
141xlators/features/trash/src/Makefile
142xlators/features/snapview-server/Makefile
143xlators/features/snapview-server/src/Makefile
144xlators/features/snapview-client/Makefile
145xlators/features/snapview-client/src/Makefile
146xlators/features/upcall/Makefile
147xlators/features/upcall/src/Makefile
148xlators/features/shard/Makefile
149xlators/features/shard/src/Makefile
150xlators/features/bit-rot/Makefile
151xlators/features/bit-rot/src/Makefile
152xlators/features/bit-rot/src/stub/Makefile
153xlators/features/bit-rot/src/bitd/Makefile
154xlators/features/leases/Makefile
155xlators/features/leases/src/Makefile
156xlators/features/cloudsync/Makefile
157xlators/features/cloudsync/src/Makefile
158xlators/features/utime/Makefile
159xlators/features/utime/src/Makefile
160xlators/features/cloudsync/src/cloudsync-plugins/Makefile
161xlators/features/cloudsync/src/cloudsync-plugins/src/Makefile
162xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/Makefile
163xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/Makefile
164xlators/features/cloudsync/src/cloudsync-plugins/src/cvlt/Makefile
165xlators/features/cloudsync/src/cloudsync-plugins/src/cvlt/src/Makefile
166xlators/features/metadisp/Makefile
167xlators/features/metadisp/src/Makefile
168xlators/playground/Makefile
169xlators/playground/template/Makefile
170xlators/playground/template/src/Makefile
171xlators/system/Makefile
172xlators/system/posix-acl/Makefile
173xlators/system/posix-acl/src/Makefile
174xlators/nfs/Makefile
175xlators/nfs/server/Makefile
176xlators/nfs/server/src/Makefile
177xlators/mgmt/Makefile
178xlators/mgmt/glusterd/Makefile
179xlators/mgmt/glusterd/src/Makefile
180cli/Makefile
181cli/src/Makefile
182doc/Makefile
183extras/Makefile
184extras/glusterd.vol
185extras/cliutils/Makefile
186extras/init.d/Makefile
187extras/init.d/glusterd.plist
188extras/init.d/glusterd-Debian
189extras/init.d/glusterd-Redhat
190extras/init.d/glusterd-FreeBSD
191extras/init.d/glusterd-SuSE
192extras/init.d/glustereventsd-Debian
193extras/init.d/glustereventsd-Redhat
194extras/init.d/glustereventsd-FreeBSD
195extras/ganesha/Makefile
196extras/ganesha/config/Makefile
197extras/ganesha/scripts/Makefile
198extras/ganesha/ocf/Makefile
199extras/systemd/Makefile
200extras/systemd/glusterd.service
201extras/systemd/glustereventsd.service
202extras/systemd/glusterfssharedstorage.service
203extras/systemd/gluster-ta-volume.service
204extras/run-gluster.tmpfiles
205extras/benchmarking/Makefile
206extras/command-completion/Makefile
207extras/hook-scripts/Makefile
208extras/ocf/Makefile
209extras/ocf/glusterd
210extras/ocf/volume
211extras/LinuxRPM/Makefile
212extras/geo-rep/Makefile
213extras/geo-rep/schedule_georep.py
214extras/firewalld/Makefile
215extras/hook-scripts/add-brick/Makefile
216extras/hook-scripts/add-brick/pre/Makefile
217extras/hook-scripts/add-brick/post/Makefile
218extras/hook-scripts/create/Makefile
219extras/hook-scripts/create/post/Makefile
220extras/hook-scripts/delete/Makefile
221extras/hook-scripts/delete/pre/Makefile
222extras/hook-scripts/start/Makefile
223extras/hook-scripts/start/post/Makefile
224extras/hook-scripts/set/Makefile
225extras/hook-scripts/set/post/Makefile
226extras/hook-scripts/stop/Makefile
227extras/hook-scripts/stop/pre/Makefile
228extras/hook-scripts/reset/Makefile
229extras/hook-scripts/reset/post/Makefile
230extras/hook-scripts/reset/pre/Makefile
231extras/python/Makefile
232extras/snap_scheduler/Makefile
233events/Makefile
234events/src/Makefile
235events/src/eventsapiconf.py
236events/tools/Makefile
237contrib/fuse-util/Makefile
238contrib/umountd/Makefile
239glusterfs-api.pc
240libgfchangelog.pc
241api/Makefile
242api/src/Makefile
243api/examples/Makefile
244geo-replication/Makefile
245geo-replication/src/Makefile
246geo-replication/syncdaemon/Makefile
247tools/Makefile
248tools/gfind_missing_files/Makefile
249heal/Makefile
250heal/src/Makefile
251glusterfs.spec
252tools/glusterfind/src/tool.conf
253tools/glusterfind/glusterfind
254tools/glusterfind/Makefile
255tools/glusterfind/src/Makefile
256tools/setgfid2path/Makefile
257tools/setgfid2path/src/Makefile])
258
259AC_CANONICAL_HOST
260
261AC_PROG_CC
262AC_DISABLE_STATIC
263LT_INIT
264AC_SUBST([shrext_cmds])
265
266AC_CHECK_PROG([RPCGEN], [rpcgen], [yes], [no])
267
268if test "x$RPCGEN" = "xno"; then
269AC_MSG_ERROR([`rpcgen` not found, glusterfs needs `rpcgen` exiting..])
270fi
271
272# Force 'char' type to be signed
273CFLAGS="${CFLAGS} -fsigned-char"
274
275# Initialize CFLAGS before usage
276AC_ARG_ENABLE([debug],
277AS_HELP_STRING([--enable-debug],[Enable debug build options.]))
278if test "x$enable_debug" = "xyes"; then
279BUILD_DEBUG=yes
280GF_CFLAGS="${GF_CFLAGS} -g -O0 -DDEBUG"
281else
282BUILD_DEBUG=no
283fi
284
285SANITIZER=none
286
287AC_ARG_ENABLE([asan],
288AS_HELP_STRING([--enable-asan],[Enable Address Sanitizer support]))
289if test "x$enable_asan" = "xyes"; then
290SANITIZER=asan
291AC_CHECK_LIB([asan], [_init], ,
292[AC_MSG_ERROR([--enable-asan requires libasan.so, exiting])])
293if test "x$ac_cv_lib_asan__init" = xyes; then
294AC_MSG_CHECKING([whether asan API can be used])
295saved_CFLAGS=${CFLAGS}
296CFLAGS="${CFLAGS} -fsanitize=address"
297AC_COMPILE_IFELSE(
298[AC_LANG_PROGRAM([
299[#include <sanitizer/common_interface_defs.h>]],
300[[__sanitizer_finish_switch_fiber(0, 0, 0)]])],
301[ASAN_API=yes], [ASAN_API=no])
302AC_MSG_RESULT([$ASAN_API])
303if test x$ASAN_API = "xyes"; then
304AC_DEFINE(HAVE_ASAN_API, 1, [Define if asan API can be used.])
305fi
306CFLAGS=${saved_CFLAGS}
307fi
308GF_CFLAGS="${GF_CFLAGS} -O2 -g -fsanitize=address -fno-omit-frame-pointer"
309
310dnl See: https://groups.google.com/d/msg/address-sanitizer/SD590XDinfQ/NMUPj_G0BgAJ
311GF_LDFLAGS="${GF_LDFLAGS} -fsanitize=address"
312fi
313
314AC_ARG_ENABLE([tsan],
315AS_HELP_STRING([--enable-tsan],[Enable Thread Sanitizer support]))
316if test "x$enable_tsan" = "xyes"; then
317if test "x$SANITIZER" != "xnone"; then
318AC_MSG_ERROR([only one sanitizer can be enabled at once])
319fi
320SANITIZER=tsan
321AC_CHECK_LIB([tsan], [_init], ,
322[AC_MSG_ERROR([--enable-tsan requires libtsan.so, exiting])])
323if test "x$ac_cv_lib_tsan__init" = xyes; then
324AC_MSG_CHECKING([whether tsan API can be used])
325saved_CFLAGS=${CFLAGS}
326CFLAGS="${CFLAGS} -fsanitize=thread"
327AC_COMPILE_IFELSE(
328[AC_LANG_PROGRAM([
329[#include <sanitizer/tsan_interface.h>]],
330[[__tsan_create_fiber(0)]])],
331[TSAN_API=yes], [TSAN_API=no])
332AC_MSG_RESULT([$TSAN_API])
333if test x$TSAN_API = "xyes"; then
334AC_DEFINE(HAVE_TSAN_API, 1, [Define if tsan API can be used.])
335fi
336CFLAGS=${saved_CFLAGS}
337fi
338GF_CFLAGS="${GF_CFLAGS} -O2 -g -fsanitize=thread -fno-omit-frame-pointer"
339GF_LDFLAGS="${GF_LDFLAGS} -fsanitize=thread"
340fi
341
342AC_ARG_ENABLE([ubsan],
343AS_HELP_STRING([--enable-ubsan],[Enable Undefined Behavior Sanitizer support]))
344if test "x$enable_ubsan" = "xyes"; then
345if test "x$SANITIZER" != "xnone"; then
346AC_MSG_ERROR([only one sanitizer can be enabled at once])
347fi
348SANITIZER=ubsan
349AC_CHECK_LIB([ubsan], [_init], ,
350[AC_MSG_ERROR([--enable-ubsan requires libubsan.so, exiting])])
351GF_CFLAGS="${GF_CFLAGS} -O2 -g -fsanitize=undefined -fno-omit-frame-pointer"
352GF_LDFLAGS="${GF_LDFLAGS} -fsanitize=undefined"
353fi
354
355# Initialize CFLAGS before usage
356BUILD_TCMALLOC=no
357USE_MEMPOOL=yes
358AC_ARG_WITH([tcmalloc],
359[AS_HELP_STRING([--without-tcmalloc],[Use gluster based mempool])],
360[with_tcmalloc="no"], [with_tcmalloc="yes"])
361if test "x$with_tcmalloc" = "xyes"; then
362AC_CHECK_LIB([tcmalloc_minimal], [malloc], [],
363[AC_MSG_ERROR([tcmalloc library needs to be present])])
364BUILD_TCMALLOC=yes
365GF_CFLAGS="${GF_CFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"
366GF_LDFLAGS="-ltcmalloc_minimal ${GF_LDFLAGS}"
367AC_DEFINE(GF_DISABLE_MEMPOOL, 1, [Disable the Gluster memory pooler.])
368USE_MEMPOOL=no
369fi
370
371
372dnl When possible, prefer libtirpc over glibc rpc.
373dnl
374dnl On newer linux with only libtirpc, use libtirpc. (Specifying
375dnl --without-libtirpc is an error.)
376dnl
377dnl on older linux with glibc rpc and WITH libtirpc, use libtirpc
378dnl by default except when configured with --without-libtirpc.
379dnl
380dnl on old linux with glibc rpc and WITHOUT libtirpc, default to
381dnl use glibc rpc.
382dnl
383AC_ARG_WITH([libtirpc],
384[AS_HELP_STRING([--without-libtirpc],[Use legacy glibc RPC.])],
385[with_libtirpc="no"], [with_libtirpc="yes"])
386
387dnl For --without-libtirpc, check whether legacy glibc rpc is available.
388if test "x$with_libtirpc" = "xno"; then
389AC_CHECK_HEADER([rpc/types.h], ,
390AC_MSG_ERROR([Your C library lacks support for RPC. Please use libtirpc instead.]))
391fi
392
393dnl ipv6-default is off by default
394dnl
395dnl ipv6-default requires libtirpc. (glibc rpc does not support IPv6.)
396dnl ipv6-default can only be enabled if libtipc is enabled.
397dnl
398AC_ARG_WITH([ipv6-default],
399AS_HELP_STRING([--with-ipv6-default],[Set IPv6 as default.]),
400[with_ipv6_default=${with_libtirpc}], [with_ipv6_default="no"])
401
402if test x$cross_compiling != xyes; then
403AC_CHECK_FILE([/etc/centos-release])
404if test "x$ac_cv_file__etc_centos_release" = "xyes"; then
405if grep "release 6" /etc/centos-release; then
406with_ipv6_default="no"
407fi
408fi
409fi
410
411dnl On some distributions '-ldl' isn't automatically added to LIBS
412AC_CHECK_LIB([dl], [dlopen], [LIB_DL=-ldl])
413AC_SUBST(LIB_DL)
414
415AC_ARG_ENABLE([privport_tracking],
416AS_HELP_STRING([--disable-privport_tracking],[Disable internal tracking of privileged ports.]))
417TRACK_PRIVPORTS="yes"
418if test x"$enable_privport_tracking" = x"no"; then
419TRACK_PRIVPORTS="no"
420AC_DEFINE(GF_DISABLE_PRIVPORT_TRACKING, 1,
421[Disable internal tracking of privileged ports.])
422fi
423
424case $host_os in
425darwin*)
426# macOS version checking became a bit complicated since 11.x
427# It is preferred to match against kernel version now instead of product version
428# Darwin kernel is versioned as A.B.C where
429# A = Kernel Version Major, starts from 5 (OS X Puma), incremented by 1 for each new release
430# B = Kernel Version Minor
431# C = Kernel Version Patch
432
433# Should be greater than OS X Lion i.e. KernelMajor 11
434DARWIN_KERNEL_MAJOR="`/usr/bin/uname -r | cut -d . -f 1`"
435if ! test $DARWIN_KERNEL_MAJOR -ge 11; then
436AC_MSG_ERROR([You need at least OS X 10.7 (Lion) to build Glusterfs])
437fi
438# OSX version lesser than 9 has llvm/clang optimization issues which leads to various segfaults
439# If OS X Mavericks or lower i.e KernelMajor = 13
440if test $DARWIN_KERNEL_MAJOR -lt 13; then
441GF_CFLAGS="${GF_CFLAGS} -g -O0 -DDEBUG"
442fi
443;;
444esac
445
446# --enable-valgrind prevents calling dlclose(), this leaks memory
447AC_ARG_ENABLE([valgrind],
448AS_HELP_STRING([--enable-valgrind@<:@=memcheck,drd@:>@],[Enable valgrind for resource leak (memcheck, which is
449the default) or thread synchronization (drd) debugging.]))
450case x$enable_valgrind in
451xmemcheck|xyes)
452AC_DEFINE(RUN_WITH_MEMCHECK, 1,
453[Define if all processes should run under 'valgrind --tool=memcheck'.])
454VALGRIND_TOOL=memcheck
455;;
456xdrd)
457AC_DEFINE(RUN_WITH_DRD, 1,
458[Define if all processes should run under 'valgrind --tool=drd'.])
459VALGRIND_TOOL=drd
460;;
461x|xno)
462VALGRIND_TOOL=no
463;;
464*)
465AC_MSG_ERROR([Please specify --enable-valgrind@<:@=memcheck,drd@:>@])
466;;
467esac
468
469if test "x$VALGRIND_TOOL" != xno; then
470AC_MSG_CHECKING([whether valgrind API can be used])
471AC_COMPILE_IFELSE(
472[AC_LANG_PROGRAM([
473[#include <valgrind/valgrind.h>]],
474[[VALGRIND_STACK_DEREGISTER(VALGRIND_STACK_REGISTER(0, 0))]])],
475[HAVE_VALGRIND_API=yes], [HAVE_VALGRIND_API=no])
476AC_MSG_RESULT([$HAVE_VALGRIND_API])
477if test x$HAVE_VALGRIND_API = "xyes"; then
478AC_DEFINE(HAVE_VALGRIND_API, 1, [Define if valgrind API can be used.])
479fi
480fi
481
482AC_ARG_WITH([previous-options],
483[AS_HELP_STRING([--with-previous-options],
484[read config.status for configure options])
485],
486[ if test -r ./config.status && \
487args=$(grep 'ac_cs_config=' config.status | \
488sed -e 's/.*"\(.*\)".*/\1/' -e "s/'//g" -e "s/--with-previous-options//g") ; then
489echo "###"
490echo "### Rerunning as '$0 $args'"
491echo "###"
492exec $0 $args
493fi
494])
495
496AC_ARG_WITH(pkgconfigdir,
497[ --with-pkgconfigdir=DIR pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
498[pkgconfigdir=$withval],
499[pkgconfigdir='${libdir}/pkgconfig'])
500AC_SUBST(pkgconfigdir)
501
502AC_ARG_WITH(mountutildir,
503[ --with-mountutildir=DIR mount helper utility in DIR @<:@/sbin@:>@],
504[mountutildir=$withval],
505[mountutildir='/sbin'])
506AC_SUBST(mountutildir)
507
508AC_ARG_WITH(systemddir,
509[ --with-systemddir=DIR systemd service files in DIR @<:@PREFIX/lib/systemd/system@:>@],
510[systemddir=$withval],
511[systemddir='${prefix}/lib/systemd/system'])
512AC_SUBST(systemddir)
513AM_CONDITIONAL([USE_SYSTEMD], test [ -d '/usr/lib/systemd/system' ])
514
515AC_ARG_WITH(initdir,
516[ --with-initdir=DIR init.d scripts in DIR @<:@/etc/init.d@:>@],
517[initdir=$withval],
518[initdir='/etc/init.d'])
519AC_SUBST(initdir)
520
521AC_ARG_WITH(launchddir,
522[ --with-launchddir=DIR launchd services in DIR @<:@/Library/LaunchDaemons@:>@],
523[launchddir=$withval],
524[launchddir='/Library/LaunchDaemons'])
525AC_SUBST(launchddir)
526
527AC_ARG_WITH(tmpfilesdir,
528AS_HELP_STRING([--with-tmpfilesdir=DIR],[tmpfiles config in DIR, disabled by default]),
529[tmpfilesdir=$withval],
530[tmpfilesdir=''])
531AC_SUBST(tmpfilesdir)
532
533AC_ARG_WITH([ocf],
534[AS_HELP_STRING([--without-ocf], [build OCF-compliant cluster resource agents])],
535,
536[OCF_SUBDIR='ocf'],
537)
538AC_SUBST(OCF_SUBDIR)
539
540AC_ARG_WITH([server],
541[AS_HELP_STRING([--without-server], [do not build server components])],
542[with_server=$withval],
543[with_server='yes'],
544)
545AM_CONDITIONAL([WITH_SERVER], [test x$with_server = xyes])
546
547# LEX needs a check
548AC_PROG_LEX([noyywrap])
549if test "x${LEX}" != "xflex" -a "x${FLEX}" != "xlex"; then
550AC_MSG_ERROR([Flex or lex required to build glusterfs.])
551fi
552
553dnl
554dnl Word sizes...
555dnl
556AC_CHECK_SIZEOF(short)
557AC_CHECK_SIZEOF(int)
558AC_CHECK_SIZEOF(long)
559AC_CHECK_SIZEOF(long long)
560SIZEOF_SHORT=$ac_cv_sizeof_short
561SIZEOF_INT=$ac_cv_sizeof_int
562SIZEOF_LONG=$ac_cv_sizeof_long
563SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
564AC_SUBST(SIZEOF_SHORT)
565AC_SUBST(SIZEOF_INT)
566AC_SUBST(SIZEOF_LONG)
567AC_SUBST(SIZEOF_LONG_LONG)
568
569# size of time_t
570AC_CHECK_SIZEOF(time_t)
571SIZEOF_TIME_T=$ac_cv_sizeof_time_t
572AC_SUBST(SIZEOF_TIME_T)
573
574# YACC needs a check
575AC_PROG_YACC
576if test "x${YACC}" = "xbyacc" -o "x${YACC}" = "xyacc" -o "x${YACC}" = "x"; then
577AC_MSG_ERROR([GNU Bison required to build glusterfs.])
578fi
579
580AC_CHECK_TOOL([LD],[ld])
581
582AC_CHECK_LIB([crypto], [MD5], , AC_MSG_ERROR([OpenSSL crypto library is required to build glusterfs]))
583
584AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs]))
585
586AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs])))
587
588AC_CHECK_LIB([intl], [gettext])
589
590AC_CHECK_HEADERS([sys/xattr.h])
591
592AC_CHECK_HEADERS([sys/ioctl.h], AC_DEFINE(HAVE_IOCTL_IN_SYS_IOCTL_H, 1, [have sys/ioctl.h]))
593
594AC_CHECK_HEADERS([sys/extattr.h])
595
596AC_CHECK_HEADERS([openssl/dh.h])
597
598AC_CHECK_HEADERS([openssl/ecdh.h])
599
600AC_CHECK_LIB([ssl], [SSL_CTX_get0_param], [AC_DEFINE([HAVE_SSL_CTX_GET0_PARAM], [1], [define if found OpenSSL SSL_CTX_get0_param])])
601
602dnl Math library
603AC_CHECK_LIB([m], [pow], [MATH_LIB='-lm'], [MATH_LIB=''])
604AC_SUBST(MATH_LIB)
605
606dnl depend on libuuid.so
607PKG_CHECK_MODULES([UUID], [uuid],
608[have_uuid=yes
609AC_DEFINE(HAVE_LIBUUID, 1, [have libuuid.so])
610PKGCONFIG_UUID=uuid],
611[have_uuid=no])
612AM_CONDITIONAL([HAVE_LIBUUID], [test x$have_uuid = xyes])
613
614dnl older version of libuuid (from e2fsprogs) require including uuid/uuid.h
615saved_CFLAGS=${CFLAGS}
616CFLAGS="${CFLAGS} ${UUID_CFLAGS}"
617AC_CHECK_HEADER([uuid.h], [], [AC_CHECK_HEADER([uuid/uuid.h])],
618[[#if HAVE_UUID_H
619#include <uuid.h>
620#endif
621]])
622CFLAGS=${saved_CFLAGS}
623if test "x$ac_cv_header_uuid_uuid_h" = "xyes"; then
624UUID_CFLAGS="${UUID_CFLAGS} -I$(pkg-config --variable=includedir uuid)/uuid"
625have_uuid=yes
626fi
627
628if test "x$have_uuid" != "xyes"; then
629case $host_os in
630*freebsd*)
631AC_MSG_ERROR([e2fsprogs-libuuid is required to build glusterfs])
632;;
633linux*)
634AC_MSG_ERROR([libuuid is required to build glusterfs])
635;;
636*)
637AC_MSG_ERROR([a Linux compatible libuuid is required to build glusterfs])
638;;
639esac
640fi
641
642dnl libglusterfs needs uuid.h, practically everything depends on it
643GF_CFLAGS="${GF_CFLAGS} ${UUID_CFLAGS}"
644dnl PKGCONFIG_UUID is used for the dependency in *.pc.in files
645AC_SUBST(PKGCONFIG_UUID)
646
647dnl Check for xxhash library.
648PKG_CHECK_MODULES([XXHASH], [libxxhash],
649[have_libxxhash=yes
650AC_DEFINE(HAVE_LIBXXHASH, 1, [Define to 1 if you have libxxhash.so.])],
651[have_libxxhash=no])
652AM_CONDITIONAL([HAVE_LIBXXHASH], [test x$have_libxxhash = xyes])
653
654dnl Note xxhsum binary is required to run gfid2path tests.
655if test "x$have_libxxhash" = "xyes"; then
656AC_CHECK_PROG([XXHSUM], [xxhsum], [yes], [no])
657if test "x$XXHSUM" = "xno"; then
658AC_MSG_WARN([install 'xxhsum' binary if you plan to run the tests.])
659fi
660GF_CFLAGS="${GF_CFLAGS} ${XXHASH_CFLAGS}"
661fi
662
663dnl NetBSD does not support POSIX ACLs :-(
664case $host_os in
665*netbsd* | darwin*)
666AC_MSG_WARN([platform does not support POSIX ACLs... disabling them])
667ACL_LIBS=''
668USE_POSIX_ACLS='0'
669BUILD_POSIX_ACLS='no'
670;;
671*)
672AC_CHECK_HEADERS([sys/acl.h], ,
673AC_MSG_ERROR([Support for POSIX ACLs is required]))
674USE_POSIX_ACLS='1'
675BUILD_POSIX_ACLS='yes'
676case $host_os in
677linux*)
678ACL_LIBS='-lacl'
679;;
680solaris*)
681ACL_LIBS='-lsec'
682;;
683*freebsd*)
684ACL_LIBS='-lc'
685;;
686darwin*)
687ACL_LIBS='-lc'
688;;
689esac
690if test "x${ACL_LIBS}" = "x-lacl"; then
691AC_CHECK_HEADERS([acl/libacl.h], , AC_MSG_ERROR([libacl is required for building on ${host_os}]))
692fi
693;;
694esac
695AC_SUBST(ACL_LIBS)
696AC_SUBST(USE_POSIX_ACLS)
697
698# libglusterfs/checksum
699AC_CHECK_HEADERS([openssl/md5.h])
700
701# Zlib is used by libglusterfs checksum and cdc xlator.
702PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [have_zlib=yes], [have_zlib=no])
703if test x$have_zlib = xyes; then
704AC_DEFINE(HAVE_ZLIB, 1, [Define if zlib is found.])
705AC_SUBST([ZLIB_CFLAGS])
706AC_SUBST([ZLIB_LIBS])
707else
708AC_MSG_ERROR([zlib is required to build glusterfs])
709fi
710
711AC_CHECK_HEADERS([linux/falloc.h])
712
713AC_CHECK_HEADERS([linux/oom.h], AC_DEFINE(HAVE_LINUX_OOM_H, 1, [have linux/oom.h]))
714
715dnl some os may not have GNU defined strnlen function
716AC_CHECK_FUNC([strnlen], [have_strnlen=yes])
717if test "x${have_strnlen}" = "xyes"; then
718AC_DEFINE(HAVE_STRNLEN, 1, [define if found strnlen])
719fi
720AC_SUBST(HAVE_STRNLEN)
721
722
723AC_CHECK_FUNC([setfsuid], [have_setfsuid=yes])
724AC_CHECK_FUNC([setfsgid], [have_setfsgid=yes])
725
726if test "x${have_setfsuid}" = "xyes" -a "x${have_setfsgid}" = "xyes"; then
727AC_DEFINE(HAVE_SET_FSID, 1, [define if found setfsuid setfsgid])
728fi
729
730dnl test umount2 function
731AC_CHECK_FUNC([umount2], [have_umount2=yes])
732
733if test "x${have_umount2}" = "xyes"; then
734AC_DEFINE(HAVE_UMOUNT2, 1, [define if found umount2])
735fi
736
737dnl Check Python Availability
738have_python=no
739dnl if the user has not specified a python, pick one
740if test -z "${PYTHON}"; then
741case $host_os in
742freebsd*)
743if test -x /usr/local/bin/python3; then
744PYTHON=/usr/local/bin/python3
745else
746PYTHON=/usr/local/bin/python2
747fi
748;;
749*)
750if test -x /usr/bin/python3; then
751PYTHON=/usr/bin/python3
752else
753PYTHON=/usr/bin/python2
754fi
755;;
756esac
757fi
758AM_PATH_PYTHON([2.6],,[:])
759if test -n "${PYTHON}"; then
760have_python=yes
761fi
762AM_CONDITIONAL(HAVE_PYTHON, test "x$have_python" = "xyes")
763
764dnl Use pkg-config to get runtime search path missing from ${PYTHON}-config
765dnl Just do "true" on failure so that configure does not bail out
766dnl Note: python 2.6's devel pkg (e.g. in CentOS/RHEL 6) does not have
767dnl pkg-config files, so this work-around instead
768if test "x${PYTHON_VERSION}" = "x2.6"; then
769PYTHON_CFLAGS=$(python-config --includes)
770PYTHON_LIBS=$(python-config --libs)
771else
772PKG_CHECK_MODULES([PYTHON], "python-${PYTHON_VERSION}",,true)
773fi
774
775PYTHON_CFLAGS=$(echo ${PYTHON_CFLAGS} | sed -e 's|-I|-isystem |')
776
777BUILD_PYTHON_SITE_PACKAGES=${pythondir}
778AC_SUBST(BUILD_PYTHON_SITE_PACKAGES)
779
780# Eval two times to expand fully. First eval replaces $exec_prefix into $prefix
781# Second eval will expand $prefix
782build_python_site_packages_temp="${pythondir}"
783eval build_python_site_packages_temp=\"${build_python_site_packages_temp}\"
784eval build_python_site_packages_temp=\"${build_python_site_packages_temp}\"
785BUILD_PYTHON_SITE_PACKAGES_EXPANDED=${build_python_site_packages_temp}
786AC_SUBST(BUILD_PYTHON_SITE_PACKAGES_EXPANDED)
787
788# FUSE section
789AC_ARG_ENABLE([fuse-client],
790AS_HELP_STRING([--disable-fuse-client],[Do not build the fuse client. NOTE: you cannot mount glusterfs without the client]))
791
792BUILD_FUSE_CLIENT=no
793if test "x$enable_fuse_client" != "xno"; then
794FUSE_CLIENT_SUBDIR=fuse
795BUILD_FUSE_CLIENT="yes"
796fi
797
798AC_SUBST(FUSE_CLIENT_SUBDIR)
799
800AC_ARG_ENABLE([fuse-notifications],
801AS_HELP_STRING([--disable-fuse-notifications], [Disable FUSE notifications]))
802
803AS_IF([test "x$enable_fuse_notifications" != "xno"], [
804AC_DEFINE([HAVE_FUSE_NOTIFICATIONS], [1], [Use FUSE notifications])
805])
806
807# end FUSE section
808
809dnl Find out OpenSSL trusted certificates path
810AC_MSG_CHECKING([for OpenSSL trusted certificates path])
811SSL_CERT_PATH=$(openssl version -d | sed -e 's|OPENSSLDIR: "\(.*\)".*|\1|')
812if test -d "${SSL_CERT_PATH}" 1>/dev/null 2>&1; then
813AC_MSG_RESULT([$SSL_CERT_PATH])
814AC_DEFINE_UNQUOTED(SSL_CERT_PATH, ["$SSL_CERT_PATH"], [Path to OpenSSL trusted certificates.])
815AC_SUBST(SSL_CERT_PATH)
816else
817AC_MSG_ERROR([Unable to detect path to OpenSSL trusted certificates])
818fi
819
820AC_CHECK_LIB([ssl], TLS_method, [HAVE_OPENSSL_1_1="yes"], [HAVE_OPENSSL_1_1="no"])
821if test "x$HAVE_OPENSSL_1_1" = "xyes"; then
822AC_DEFINE([HAVE_TLS_METHOD], [1], [Using OpenSSL-1.1 TLS_method])
823else
824AC_CHECK_LIB([ssl], TLSv1_2_method, [AC_DEFINE([HAVE_TLSV1_2_METHOD], [1], [Using OpenSSL-1.0 TLSv1_2_method])])
825fi
826
827
828# FUSERMOUNT section
829AC_ARG_ENABLE([fusermount],
830AS_HELP_STRING([--disable-fusermount],[Use system's fusermount]))
831
832BUILD_FUSERMOUNT="yes"
833if test "x$enable_fusermount" = "xno"; then
834BUILD_FUSERMOUNT="no"
835else
836AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount])
837FUSERMOUNT_SUBDIR="contrib/fuse-util"
838fi
839
840AC_SUBST(FUSERMOUNT_SUBDIR)
841#end FUSERMOUNT section
842
843# EPOLL section
844AC_ARG_ENABLE([epoll],
845AS_HELP_STRING([--disable-epoll],[Use poll instead of epoll.]))
846
847BUILD_EPOLL=no
848if test "x$enable_epoll" != "xno"; then
849AC_CHECK_HEADERS([sys/epoll.h],
850[BUILD_EPOLL=yes],
851[BUILD_EPOLL=no])
852fi
853# end EPOLL section
854
855# SYNCDAEMON section
856AC_ARG_ENABLE([georeplication],
857AS_HELP_STRING([--disable-georeplication],[Do not install georeplication components]))
858
859BUILD_SYNCDAEMON=no
860case $host_os in
861freebsd*)
862#do nothing
863;;
864linux*)
865#do nothing
866;;
867netbsd*)
868#do nothing
869;;
870*)
871#disabling geo replication for non-linux platforms
872enable_georeplication=no
873;;
874esac
875SYNCDAEMON_COMPILE=0
876if test "x${with_server}" = "xyes" -a "x${enable_georeplication}" != "xno"; then
877if test "x${have_python}" = "xno" ; then
878AC_MSG_ERROR([only python 2 and 3 are supported])
879else
880SYNCDAEMON_SUBDIR=geo-replication
881SYNCDAEMON_COMPILE=1
882
883BUILD_SYNCDAEMON="yes"
884AC_MSG_CHECKING([if python has ctypes support...])
885if "${PYTHON}" -c 'import ctypes' 2>/dev/null; then
886AC_MSG_RESULT("yes")
887else
888AC_MSG_ERROR([python does not have ctypes support])
889fi
890fi
891fi
892AC_SUBST(SYNCDAEMON_COMPILE)
893AC_SUBST(SYNCDAEMON_SUBDIR)
894# end SYNCDAEMON section
895
896# only install scripts from extras/geo-rep when enabled
897if test "x${with_server}" = "xyes" -a "x$enable_georeplication" != "xno"; then
898GEOREP_EXTRAS_SUBDIR=geo-rep
899fi
900AC_SUBST(GEOREP_EXTRAS_SUBDIR)
901AM_CONDITIONAL(USE_GEOREP, test "x$enable_georeplication" != "xno")
902
903# METADISP section
904AC_ARG_ENABLE([metadisp],
905AS_HELP_STRING([--enable-metadisp],[Enable the metadata dispersal xlator]))
906BUILD_METADISP=no
907if test "x${enable_metadisp}" = "xyes"; then
908BUILD_METADISP=yes
909fi
910AM_CONDITIONAL([BUILD_METADISP], [test "x$BUILD_METADISP" = "xyes"])
911# end METADISP section
912
913# Events section
914AC_ARG_ENABLE([events],
915AS_HELP_STRING([--disable-events],[Do not install Events components]))
916
917BUILD_EVENTS=no
918EVENTS_ENABLED=0
919EVENTS_SUBDIR=
920if test "x$enable_events" != "xno"; then
921EVENTS_SUBDIR=events
922EVENTS_ENABLED=1
923
924BUILD_EVENTS="yes"
925
926if test "x${have_python}" = "xno"; then
927if test "x${enable_events}" = "xyes"; then
928AC_MSG_ERROR([python 2 or 3 required. exiting.])
929fi
930AC_MSG_WARN([python not found, disabling events])
931EVENTS_SUBDIR=
932EVENTS_ENABLED=0
933BUILD_EVENTS="no"
934else
935AC_DEFINE(USE_EVENTS, 1, [define if events enabled])
936fi
937fi
938AC_SUBST(EVENTS_ENABLED)
939AC_SUBST(EVENTS_SUBDIR)
940AM_CONDITIONAL([BUILD_EVENTS], [test "x${BUILD_EVENTS}" = "xyes"])
941# end Events section
942
943#start firewalld section
944BUILD_FIREWALLD="no"
945AC_ARG_ENABLE([firewalld],
946AS_HELP_STRING([--enable-firewalld],[enable installation configuration for firewalld]),
947[BUILD_FIREWALLD="${enableval}"], [BUILD_FIREWALLD="no"])
948
949if test "x${with_server}" = "xyes" -a "x${BUILD_FIREWALLD}" = "xyes"; then
950if !(test -d /usr/lib/firewalld/services 1>/dev/null 2>&1) ; then
951BUILD_FIREWALLD="no (firewalld not installed)"
952fi
953fi
954AM_CONDITIONAL([USE_FIREWALLD],test ["x${BUILD_FIREWALLD}" = "xyes"])
955
956#endof firewald section
957
958# xml-output
959AC_ARG_ENABLE([xml-output],
960AS_HELP_STRING([--disable-xml-output],[Disable the xml output]))
961BUILD_XML_OUTPUT="yes"
962if test "x$enable_xml_output" != "xno"; then
963PKG_CHECK_MODULES([XML], [libxml-2.0], [], [no_xml="yes"])
964if test "x${no_xml}" = "x"; then
965AC_DEFINE([HAVE_LIB_XML], [1], [Define to 1 if using libxml2.])
966else
967if test "x$enable_georeplication" != "xno"; then
968AC_MSG_ERROR([libxml2 devel libraries not found])
969else
970AC_MSG_WARN([libxml2 devel libraries not found disabling XML support])
971BUILD_XML_OUTPUT="no"
972fi
973
974fi
975else
976if test "x$enable_georeplication" != "xno"; then
977AC_MSG_ERROR([geo-replication requires xml output])
978fi
979BUILD_XML_OUTPUT="no"
980fi
981# end of xml-output
982
983dnl cloudsync section
984BUILD_CLOUDSYNC="no"
985AC_CHECK_LIB([curl], [curl_easy_setopt], [LIBCURL="-lcurl"])
986if test -n "$LIBCURL";then
987HAVE_LIBCURL="yes"
988fi
989AC_CHECK_HEADERS([openssl/hmac.h openssl/evp.h openssl/bio.h openssl/buffer.h], [HAVE_OPENSSL="yes"])
990if test "x$HAVE_LIBCURL" = "xyes" -a "x$HAVE_OPENSSL" = "xyes";then
991HAVE_AMAZONS3="yes"
992fi
993AM_CONDITIONAL([BUILD_AMAZONS3_PLUGIN], [test "x$HAVE_AMAZONS3" = "xyes"])
994if test "x$HAVE_AMAZONS3" = "xyes";then
995BUILD_CLOUDSYNC="yes"
996fi
997BUILD_CVLT_PLUGIN="no"
998case $host_os in
999#enable cvlt plugin only for linux platforms
1000linux*)
1001BUILD_CVLT_PLUGIN="yes"
1002BUILD_CLOUDSYNC="yes"
1003;;
1004*)
1005;;
1006esac
1007AM_CONDITIONAL([BUILD_CVLT_PLUGIN], [test "x$BUILD_CVLT_PLUGIN" = "xyes"])
1008AM_CONDITIONAL([BUILD_CLOUDSYNC], [test "x$BUILD_CLOUDSYNC" = "xyes"])
1009dnl end cloudsync section
1010
1011dnl SELinux feature enablement
1012case $host_os in
1013linux*)
1014AC_ARG_ENABLE([selinux],
1015AS_HELP_STRING([--disable-selinux],[Disable SELinux features]),
1016[USE_SELINUX="${enableval}"], [USE_SELINUX="yes"])
1017;;
1018*)
1019USE_SELINUX=no
1020;;
1021esac
1022AM_CONDITIONAL(USE_SELINUX, test "x${USE_SELINUX}" = "xyes")
1023dnl end of SELinux feature enablement
1024
1025AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes])
1026if test "x${have_backtrace}" = "xyes"; then
1027AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
1028fi
1029AC_SUBST(HAVE_BACKTRACE)
1030AM_CONDITIONAL([HAVE_BACKTRACE], [test x$have_backtrace = xyes])
1031
1032dnl Old (before C11) compiler can compile (but not link) this:
1033dnl
1034dnl int main () {
1035dnl _Static_assert(1, "True");
1036dnl return 0;
1037dnl }
1038dnl
1039dnl assuming that _Static_assert is an implicitly declared function. So
1040dnl we're trying to link just to make sure that this is not the case.
1041
1042AC_MSG_CHECKING([whether $CC supports C11 _Static_assert])
1043AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[_Static_assert(1, "True");]])],[STATIC_ASSERT=yes],[STATIC_ASSERT=no])
1044
1045AC_MSG_RESULT([$STATIC_ASSERT])
1046if test x$STATIC_ASSERT = "xyes"; then
1047AC_DEFINE(HAVE_STATIC_ASSERT, 1, [Define if C11 _Static_assert is supported.])
1048fi
1049
1050if test "x${have_backtrace}" != "xyes"; then
1051AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[double x=0.0; x=ceil(0.0);]])],[],[AC_MSG_ERROR(need math library for libexecinfo)])
1052fi
1053
1054dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
1055dnl try mallinfo2 first, fallback to mallinfo if not available
1056AC_CHECK_FUNC([mallinfo2], [have_mallinfo2=yes])
1057if test "x${have_mallinfo2}" = "xyes"; then
1058AC_DEFINE(HAVE_MALLINFO2, 1, [define if found mallinfo2])
1059else
1060AC_CHECK_FUNC([mallinfo], [have_mallinfo=yes])
1061if test "x${have_mallinfo}" = "xyes"; then
1062AC_DEFINE(HAVE_MALLINFO, 1, [define if found mallinfo])
1063fi
1064fi
1065AC_SUBST(HAVE_MALLINFO2)
1066AC_SUBST(HAVE_MALLINFO)
1067
1068dnl Linux, Solaris, Cygwin
1069AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
1070dnl FreeBSD, NetBSD
1071AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec])
1072case $host_os in
1073*netbsd*)
1074GF_CFLAGS="${GF_CFLAGS} -D_INCOMPLETE_XOPEN_C063 -DCONFIG_MACHINE_BSWAP_H"
1075;;
1076esac
1077AC_CHECK_FUNC([linkat], [have_linkat=yes])
1078if test "x${have_linkat}" = "xyes"; then
1079AC_DEFINE(HAVE_LINKAT, 1, [define if found linkat])
1080fi
1081AC_SUBST(HAVE_LINKAT)
1082
1083dnl prefer futimens for nanosecond resolution
1084AC_CHECK_FUNC([futimens], [have_futimens=yes])
1085if test "x${have_futimens}" = "xyes"; then
1086AC_DEFINE(HAVE_FUTIMENS, 1, [define if found futimens])
1087else
1088AC_CHECK_FUNC([futimes], [have_futimes=yes])
1089if test "x${have_futimes}" = "xyes"; then
1090AC_DEFINE(HAVE_FUTIMES, 1, [define if found futimes])
1091else
1092AC_MSG_ERROR([This system doesn't support neither futimens() nor futimes()])
1093fi
1094fi
1095AC_SUBST(HAVE_FUTIMENS)
1096AC_SUBST(HAVE_FUTIMES)
1097
1098dnl check for Monotonic clock
1099AC_CHECK_LIB([rt], [clock_gettime], ,
1100AC_MSG_WARN([System doesn't have monotonic clock using contrib]))
1101
1102dnl check for argp, FreeBSD has the header in /usr/local/include
1103case $host_os in
1104*freebsd*)
1105CFLAGS="${CFLAGS} -isystem /usr/local/include"
1106ARGP_LDADD=-largp
1107;;
1108*netbsd*)
1109ARGP_LDADD=-largp
1110;;
1111esac
1112dnl argp-standalone does not provide a pkg-config file
1113AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))
1114if test "x$ac_cv_header_argp_h" != "xyes"; then
1115AC_MSG_ERROR([argp.h not found, install libargp or argp-standalone])
1116fi
1117AC_SUBST(ARGP_LDADD)
1118
1119dnl Check for atomic operation support
1120AC_MSG_CHECKING([for gcc __atomic builtins])
1121AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int v; __atomic_load_n(&v, __ATOMIC_ACQUIRE);]])],[have_atomic_builtins=yes],[have_atomic_builtins=no])
1122if test "x${have_atomic_builtins}" = "xyes"; then
1123AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [define if __atomic_*() builtins are available])
1124fi
1125AC_SUBST(HAVE_ATOMIC_BUILTINS)
1126AC_MSG_RESULT([$have_atomic_builtins])
1127
1128dnl __sync_*() will not be needed if __atomic_*() is available
1129AC_MSG_CHECKING([for gcc __sync builtins])
1130AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[__sync_synchronize();]])],[have_sync_builtins=yes],[have_sync_builtins=no])
1131if test "x${have_sync_builtins}" = "xyes"; then
1132AC_DEFINE(HAVE_SYNC_BUILTINS, 1, [define if __sync_*() builtins are available])
1133fi
1134AC_SUBST(HAVE_SYNC_BUILTINS)
1135AC_MSG_RESULT([$have_sync_builtins])
1136
1137AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))
1138
1139AC_CHECK_FUNC([llistxattr], [have_llistxattr=yes])
1140if test "x${have_llistxattr}" = "xyes"; then
1141AC_DEFINE(HAVE_LLISTXATTR, 1, [define if llistxattr exists])
1142fi
1143
1144AC_CHECK_FUNC([fdatasync], [have_fdatasync=no])
1145if test "x${have_fdatasync}" = "xyes"; then
1146AC_DEFINE(HAVE_FDATASYNC, 1, [define if fdatasync exists])
1147fi
1148
1149AC_CHECK_FUNC([fallocate], [have_fallocate=yes])
1150if test "x${have_fallocate}" = "xyes"; then
1151AC_DEFINE(HAVE_FALLOCATE, 1, [define if fallocate exists])
1152fi
1153
1154AC_CHECK_FUNC([posix_fallocate], [have_posix_fallocate=yes])
1155if test "x${have_posix_fallocate}" = "xyes"; then
1156AC_DEFINE(HAVE_POSIX_FALLOCATE, 1, [define if posix_fallocate exists])
1157fi
1158
1159# On fedora-29, copy_file_range syscall and the libc API both are present.
1160# Whereas, on some machines such as centos-7, RHEL-7, the API is not there.
1161# Only the system call is present. So, this change is to determine whether
1162# the API is present or not. If not, then check whether the system call is
1163# present or not. Accordingly sys_copy_file_range function will first call
1164# the API if it is there. Otherwise it will call syscall(SYS_copy_file_range).
1165AC_CHECK_FUNC([copy_file_range], [have_copy_file_range=yes])
1166if test "x${have_copy_file_range}" = "xyes"; then
1167AC_DEFINE(HAVE_COPY_FILE_RANGE, 1, [define if copy_file_range exists])
1168else
1169OLD_CFLAGS=${CFLAGS}
1170CFLAGS="-D_GNU_SOURCE"
1171AC_CHECK_DECL([SYS_copy_file_range], , , [#include <sys/syscall.h>])
1172if test "x${ac_cv_have_decl_SYS_copy_file_range}" = "xyes"; then
1173AC_DEFINE(HAVE_COPY_FILE_RANGE_SYS, 1, [define if SYS_copy_file_range is available])
1174fi
1175CFLAGS=${OLD_CFLAGS}
1176fi
1177
1178AC_CHECK_FUNC([syncfs], [have_syncfs=yes])
1179if test "x${have_syncfs}" = "xyes"; then
1180AC_DEFINE(HAVE_SYNCFS, 1, [define if syncfs exists])
1181else
1182OLD_CFLAGS=${CFLAGS}
1183CFLAGS="-D_GNU_SOURCE"
1184AC_CHECK_DECL([SYS_syncfs], , , [#include <sys/syscall.h>])
1185if test "x${ac_cv_have_decl_SYS_syncfs}" = "xyes"; then
1186AC_DEFINE(HAVE_SYNCFS_SYS, 1, [define if SYS_syncfs is available])
1187fi
1188CFLAGS=${OLD_CFLAGS}
1189fi
1190
1191BUILD_NANOSECOND_TIMESTAMPS=no
1192AC_CHECK_FUNC([utimensat], [have_utimensat=yes])
1193if test "x${have_utimensat}" = "xyes"; then
1194BUILD_NANOSECOND_TIMESTAMPS=yes
1195AC_DEFINE(HAVE_UTIMENSAT, 1, [define if utimensat exists])
1196fi
1197
1198OLD_CFLAGS=${CFLAGS}
1199CFLAGS="-D_GNU_SOURCE"
1200AC_CHECK_DECL([SEEK_HOLE], , , [#include <unistd.h>])
1201if test "x${ac_cv_have_decl_SEEK_HOLE}" = "xyes"; then
1202AC_DEFINE(HAVE_SEEK_HOLE, 1, [define if SEEK_HOLE is available])
1203fi
1204CFLAGS=${OLD_CFLAGS}
1205
1206AC_CHECK_FUNC([accept4], [have_accept4=yes])
1207if test "x${have_accept4}" = "xyes"; then
1208AC_DEFINE(HAVE_ACCEPT4, 1, [define if accept4 exists])
1209fi
1210
1211AC_CHECK_FUNC([paccept], [have_paccept=yes])
1212if test "x${have_paccept}" = "xyes"; then
1213AC_DEFINE(HAVE_PACCEPT, 1, [define if paccept exists])
1214fi
1215
1216AC_CHECK_FUNC([pipe2], [have_pipe2=yes])
1217if test "x${have_pipe2}" = "xyes"; then
1218AC_DEFINE(HAVE_PIPE2, 1, [Define if (Linux-specific) pipe2() exists.])
1219fi
1220
1221dnl Looking for OS-dependent non-POSIX function to set thread name.
1222
1223PTHREAD_SETNAME_FOUND=no
1224
1225dnl Linux-like version assuming glibc (so _GNU_SOURCE).
1226if test x$PTHREAD_SETNAME_FOUND = xno; then
1227AC_MSG_CHECKING([for pthread_setname_np(thread, name)])
1228saved_CFLAGS=${CFLAGS}
1229CFLAGS="-D_GNU_SOURCE -pthread ${saved_CFLAGS}"
1230AC_LINK_IFELSE(
1231[AC_LANG_PROGRAM([
1232[#include <pthread.h>]],
1233[[pthread_t t; pthread_setname_np(t, "name");]])],
1234[pthread_setname_np_two_args=yes], [pthread_setname_np_two_args=no])
1235AC_MSG_RESULT([$pthread_setname_np_two_args])
1236CFLAGS="$saved_CFLAGS"
1237
1238if test x$pthread_setname_np_two_args = xyes; then
1239AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_TWO_ARGS, 1,
1240[Define if 'pthread_setname_np(thread, name)' is present.])
1241PTHREAD_SETNAME_FOUND=yes
1242fi
1243fi
1244
1245dnl NetBSD-like version with three arguments.
1246if test x$PTHREAD_SETNAME_FOUND = xno; then
1247AC_MSG_CHECKING([for pthread_setname_np(thread, name, arg)])
1248saved_CFLAGS=${CFLAGS}
1249CFLAGS="-pthread ${saved_CFLAGS}"
1250AC_LINK_IFELSE(
1251[AC_LANG_PROGRAM([
1252[#include <pthread.h>]],
1253[[pthread_t t; pthread_setname_np(t, "name", NULL);]])],
1254[pthread_setname_np_three_args=yes], [pthread_setname_np_three_args=no])
1255AC_MSG_RESULT([$pthread_setname_np_three_args])
1256CFLAGS="$saved_CFLAGS"
1257
1258if test x$pthread_setname_np_three_args = xyes; then
1259AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_THREE_ARGS, 1,
1260[Define if 'pthread_setname_np(thread, name, arg)' is present.])
1261PTHREAD_SETNAME_FOUND=yes
1262fi
1263fi
1264
1265dnl FreeBSD provides pthread_np.h header file and both (not sure
1266dnl for versions older than 13.0) 'pthread_setname_np(thread, name)'
1267dnl and 'pthread_set_name_np(thread, name)'.
1268
1269if test x$PTHREAD_SETNAME_FOUND = xno; then
1270AC_MSG_CHECKING([for pthread_set_name_np(thread, name)])
1271saved_CFLAGS=${CFLAGS}
1272CFLAGS="-pthread ${saved_CFLAGS}"
1273AC_LINK_IFELSE(
1274[AC_LANG_PROGRAM([
1275[#include <pthread_np.h>]],
1276[[pthread_t t; pthread_set_name_np(t, "name");]])],
1277[pthread_set_name_np=yes], [pthread_set_name_np=no])
1278AC_MSG_RESULT([$pthread_set_name_np])
1279CFLAGS="$saved_CFLAGS"
1280
1281if test x$pthread_set_name_np = xyes; then
1282AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1,
1283[Define if 'pthread_set_name_np(thread, name)' is present.])
1284PTHREAD_SETNAME_FOUND=yes
1285fi
1286fi
1287
1288if test x$PTHREAD_SETNAME_FOUND = xno; then
1289AC_MSG_WARN([Unable to detect function to set thread name])
1290fi
1291
1292# Check the distribution where you are compiling glusterfs on.
1293# For cross-compiling, you're advised to specify it manually.
1294
1295GF_DISTRIBUTION=
1296
1297if test x$cross_compiling != xyes; then
1298AC_CHECK_FILE([/etc/debian_version])
1299AC_CHECK_FILE([/etc/SuSE-release])
1300AC_CHECK_FILE([/etc/redhat-release])
1301
1302if test "x$ac_cv_file__etc_debian_version" = "xyes"; then
1303GF_DISTRIBUTION=Debian
1304fi
1305if test "x$ac_cv_file__etc_SuSE_release" = "xyes"; then
1306GF_DISTRIBUTION=SuSE
1307fi
1308if test "x$ac_cv_file__etc_redhat_release" = "xyes"; then
1309GF_DISTRIBUTION=Redhat
1310fi
1311else
1312GF_DISTRIBUTION=Unspecified
1313fi
1314
1315AC_SUBST(GF_DISTRIBUTION)
1316
1317GF_HOST_OS=""
1318GF_LDFLAGS="${GF_LDFLAGS} -rdynamic"
1319
1320dnl see --with-libtirpc option check above, libtirpc(-devel) is required for
1321dnl ipv6-default
1322if test "x${with_libtirpc}" = "xyes" || test "x${with_ipv6_default}" = "xyes" ; then
1323PKG_CHECK_MODULES([TIRPC], [libtirpc],
1324[with_libtirpc="yes"; GF_CFLAGS="$GF_CFLAGS $TIRPC_CFLAGS"; GF_LDFLAGS="$GF_LDFLAGS $TIRPC_LIBS";],
1325[with_libtirpc="missing"; with_ipv6_default="no"])
1326fi
1327
1328if test "x${with_libtirpc}" = "xyes" ; then
1329AC_DEFINE(HAVE_LIBTIRPC, 1, [Using libtirpc])
1330fi
1331
1332if test "x${with_libtirpc}" = "xmissing" ; then
1333AC_CHECK_HEADERS([rpc/rpc.h],[
1334AC_MSG_WARN([
1335---------------------------------------------------------------------------------
1336libtirpc (and/or ipv6-default) were enabled but libtirpc-devel is not installed.
1337Disabling libtirpc and ipv6-default and falling back to legacy glibc rpc headers.
1338This is a transitional warning message. Eventually it will be an error message.
1339---------------------------------------------------------------------------------])],[
1340AC_MSG_ERROR([
1341---------------------------------------------------------------------------------
1342libtirpc (and/or ipv6-default) were enabled but libtirpc-devel is not installed
1343and there were no legacy glibc rpc headers and library to fall back to.
1344---------------------------------------------------------------------------------])])
1345fi
1346
1347if test "x$with_ipv6_default" = "xyes" ; then
1348GF_CFLAGS="$GF_CFLAGS -DIPV6_DEFAULT"
1349fi
1350
1351USE_BRICKMUX="no"
1352if test "x$enable_brickmux" = "xyes" ; then
1353USE_BRICKMUX="yes"
1354AC_DEFINE(GF_ENABLE_BRICKMUX, 1, [Enable Brick Mux.])
1355fi
1356
1357dnl check for gcc -Werror=format-security
1358saved_CFLAGS=$CFLAGS
1359CFLAGS="-Wformat -Werror=format-security"
1360AC_MSG_CHECKING([whether $CC accepts -Werror=format-security])
1361AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no])
1362echo $cc_werror_format_security
1363if test "x$cc_werror_format_security" = "xyes"; then
1364GF_CFLAGS="$GF_CFLAGS ${CFLAGS}"
1365fi
1366CFLAGS="$saved_CFLAGS"
1367
1368dnl check for gcc -Werror=implicit-function-declaration
1369saved_CFLAGS=$CFLAGS
1370CFLAGS="-Werror=implicit-function-declaration"
1371AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration])
1372AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no])
1373echo $cc_werror_implicit
1374if test "x$cc_werror_implicit" = "xyes"; then
1375GF_CFLAGS="${GF_CFLAGS} ${CFLAGS}"
1376fi
1377CFLAGS="$saved_CFLAGS"
1378
1379dnl clang is mostly GCC-compatible, but its version is much lower,
1380dnl so we have to check for it.
1381AC_MSG_CHECKING([if compiling with clang])
1382
1383AC_COMPILE_IFELSE(
1384[AC_LANG_PROGRAM([], [[
1385#ifndef __clang__
1386not clang
1387#endif
1388]])],
1389[CLANG=yes], [CLANG=no])
1390
1391AC_MSG_RESULT([$CLANG])
1392
1393if test "x$CLANG" = "xyes"; then
1394GF_CFLAGS="${GF_CFLAGS} -Wno-gnu"
1395fi
1396
1397if test "x$ac_cv_header_execinfo_h" = "xno"; then
1398# The reason is that __builtin_frame_address(n) for n > 0 seems
1399# to just crash on most platforms when -fomit-stack-pointer is
1400# specified, which seems to be the default for many platforms on
1401# -O2. The documentation says that __builtin_frame_address()
1402# should return NULL in case it can't get the frame, but it
1403# seems to crash instead.
1404
1405# execinfo.c in ./contrib/libexecinfo uses __builtin_frame_address(n)
1406# for providing cross platform backtrace*() functions.
1407if test "x$CLANG" = "xno"; then
1408GF_CFLAGS="${GF_CFLAGS} -fno-omit-frame-pointer"
1409fi
1410fi
1411
1412old_prefix=$prefix
1413if test "x$prefix" = xNONE; then
1414prefix=$ac_default_prefix
1415fi
1416old_exec_prefix=$exec_prefix
1417if test "x$exec_prefix" = xNONE; then
1418exec_prefix="$(eval echo $prefix)"
1419fi
1420GLUSTERFS_LIBEXECDIR="$(eval echo $libexecdir)/glusterfs"
1421prefix=$old_prefix
1422exec_prefix=$old_exec_prefix
1423
1424### Dirty hacky stuff to make LOCALSTATEDIR work
1425if test "x$prefix" = xNONE; then
1426test "${localstatedir}" = '${prefix}/var' && localstatedir=$ac_default_prefix/var
1427localstatedir=/var
1428fi
1429localstatedir="$(eval echo ${localstatedir})"
1430LOCALSTATEDIR=$localstatedir
1431
1432GLUSTERFSD_MISCDIR="$(eval echo ${localstatedir})/lib/misc/glusterfsd"
1433
1434old_prefix=$prefix
1435if test "x$prefix" = xNONE; then
1436prefix=$ac_default_prefix
1437fi
1438GLUSTERD_VOLFILE="$(eval echo ${sysconfdir})/glusterfs/glusterd.vol"
1439prefix=$old_prefix
1440
1441
1442GFAPI_EXTRA_LDFLAGS='-Wl,--version-script=$(top_srcdir)/api/src/gfapi.map'
1443case $host_os in
1444linux*)
1445GF_HOST_OS="GF_LINUX_HOST_OS"
1446GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\""
1447GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd"
1448;;
1449solaris*)
1450GF_HOST_OS="GF_SOLARIS_HOST_OS"
1451GF_CFLAGS="${GF_CFLAGS} -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -m64"
1452BUILD_FUSE_CLIENT=no
1453FUSE_CLIENT_SUBDIR=""
1454GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd"
1455;;
1456*netbsd*)
1457GF_HOST_OS="GF_BSD_HOST_OS"
1458GF_CFLAGS="${GF_CFLAGS} -D_INCOMPLETE_XOPEN_C063"
1459GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
1460GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
1461GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\""
1462GF_LDADD="${ARGP_LDADD}"
1463if test "x$ac_cv_header_execinfo_h" = "xyes"; then
1464GF_LDFLAGS="${GF_LDFLAGS} -lexecinfo"
1465fi
1466GF_FUSE_LDADD="-lperfuse"
1467BUILD_FUSE_CLIENT=yes
1468LEXLIB=""
1469BUILD_FUSERMOUNT=no
1470FUSERMOUNT_SUBDIR=""
1471GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
1472;;
1473*freebsd*)
1474GF_HOST_OS="GF_BSD_HOST_OS"
1475GF_CFLAGS="${GF_CFLAGS} -DO_DSYNC=0"
1476GF_CFLAGS="${GF_CFLAGS} -Dxdr_quad_t=xdr_longlong_t"
1477GF_CFLAGS="${GF_CFLAGS} -Dxdr_u_quad_t=xdr_u_longlong_t"
1478GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\""
1479GF_LDADD="${ARGP_LDADD}"
1480if test "x$ac_cv_header_execinfo_h" = "xyes"; then
1481GF_LDFLAGS="${GF_LDFLAGS} -lexecinfo"
1482fi
1483BUILD_FUSE_CLIENT=yes
1484BUILD_FUSERMOUNT=no
1485FUSERMOUNT_SUBDIR=""
1486GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
1487;;
1488darwin*)
1489GF_HOST_OS="GF_DARWIN_HOST_OS"
1490LIBTOOL=glibtool
1491GF_CFLAGS="${GF_CFLAGS} -D_REENTRANT -D_XOPEN_SOURCE "
1492GF_CFLAGS="${GF_CFLAGS} -D_DARWIN_USE_64_BIT_INODE "
1493GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
1494GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
1495GF_LDADD="${ARGP_LDADD}"
1496GF_LDFLAGS="${GF_LDFLAGS}"
1497GF_FUSE_CFLAGS="-I\$(CONTRIBDIR)/macfuse"
1498BUILD_FUSERMOUNT="no"
1499FUSERMOUNT_SUBDIR=""
1500GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
1501GFAPI_EXTRA_LDFLAGS='-Wl,-alias_list,$(top_srcdir)/api/src/gfapi.aliases'
1502;;
1503esac
1504
1505# LTO section
1506AC_ARG_ENABLE([lto],
1507AS_HELP_STRING([--disable-lto],[Disable buidling with LTO]))
1508
1509LTO_BUILD=no
1510AS_IF([ test "x$BUILD_DEBUG" = "xno" && test "x$enable_lto" != "xno" ], [
1511CC_VER=`"$CC" -dumpversion 2>/dev/null | cut -f 1 -d '.'`
1512AS_IF([ test ! -z "$CC_VER" && test "$CC_VER" -ge "10" ], [
1513GF_CFLAGS="${GF_CFLAGS} -flto"
1514GF_LDFLAGS="${GF_LDFLAGS} -flto"
1515LTO_BUILD=yes
1516AC_MSG_NOTICE([building with LTO])],
1517[AC_MSG_NOTICE([not using LTO for gcc_ver=$CC_VER]) ])
1518], [
1519AC_MSG_NOTICE([LTO is disabled])
1520])
1521
1522dnl ------------------------------
1523dnl Checking posix_spawn(3) sanity
1524dnl ------------------------------
1525
1526AC_ARG_ENABLE(posix_spawn,
1527AS_HELP_STRING([--disable-posix_spawn],
1528[Disable usage of posix_spawn when calling out]),
1529AC_MSG_CHECKING([if posix_spawn returns properly on failure])
1530[ case "$enableval" in
1531no)
1532AC_MSG_RESULT(no)
1533posix_spawn=no
1534;;
1535*) AC_MSG_RESULT(yes)
1536posix_spawn=yes
1537;;
1538esac ],
1539AC_MSG_CHECKING([if posix_spawn returns properly on failure])
1540AC_RUN_IFELSE([AC_LANG_SOURCE([[
1541/*
1542* Test posix_spawn(3) return value on failure,
1543* adapted from and because of
1544* https://sourceware.org/bugzilla/show_bug.cgi?id=18433
1545*/
1546#include <stdio.h>
1547#include <spawn.h>
1548#include <errno.h>
1549
1550int main()
1551{
1552extern char **environ;
1553char *argv[[]] = { "3a7e588d3bdc4a069dbef540886ecf78", 0 };
1554pid_t pid = -1;
1555int ret = ret = posix_spawn(&pid, argv[[0]], 0, 0, argv, environ);
1556return ret == ENOENT ? 0 : 1;
1557}
1558]])
1559],
1560AC_MSG_RESULT(yes)
1561posix_spawn=yes,
1562AC_MSG_RESULT(no)
1563posix_spawn=no,
1564AC_MSG_RESULT(yes)
1565posix_spawn=yes
1566))
1567AM_CONDITIONAL([USE_POSIX_SPAWN], [test x$posix_spawn = xyes])
1568
1569# Default value for sbindir
1570prefix_temp=$prefix
1571exec_prefix_temp=$exec_prefix
1572
1573test "${prefix}" = "NONE" && prefix="${ac_default_prefix}"
1574test "${exec_prefix}" = "NONE" && exec_prefix='${prefix}'
1575sbintemp="${sbindir}"
1576eval sbintemp=\"${sbintemp}\"
1577eval sbintemp=\"${sbintemp}\"
1578SBIN_DIR=${sbintemp}
1579
1580sysconfdirtemp="${sysconfdir}"
1581eval sysconfdirtemp=\"${sysconfdirtemp}\"
1582SYSCONF_DIR=${sysconfdirtemp}
1583
1584prefix=$prefix_temp
1585exec_prefix=$exec_prefix_temp
1586
1587AC_SUBST(SBIN_DIR)
1588AC_SUBST(SYSCONF_DIR)
1589
1590# lazy umount emulation
1591UMOUNTD_SUBDIR=""
1592if test "x${GF_HOST_OS}" != "xGF_LINUX_HOST_OS" ; then
1593UMOUNTD_SUBDIR="contrib/umountd"
1594fi
1595AC_SUBST(UMOUNTD_SUBDIR)
1596
1597
1598# enable debug section
1599AC_ARG_ENABLE([debug],
1600AS_HELP_STRING([--enable-debug],[Enable debug build options.]))
1601
1602dnl Add readline support in CLI if available.
1603PKG_CHECK_MODULES([READLINE], [readline], [BUILD_READLINE="yes"],
1604[BUILD_READLINE="no"])
1605if test x$BUILD_READLINE = xyes; then
1606AC_DEFINE(HAVE_READLINE, 1, [Enable CLI readline support.])
1607fi
1608
1609# bash-completion script installation directory
1610# PKG_CHECK_VAR should be used but is not available in some distributions
1611bashcompdir="$(pkg-config --variable=completionsdir bash-completion 2>/dev/null)"
1612if test "x${bashcompdir}" = "x"; then
1613bashcompdir="${sysconfdir}/bash_completion.d"
1614fi
1615AC_SUBST(bashcompdir)
1616
1617BUILD_LIBAIO=no
1618AC_CHECK_LIB([aio],[io_setup],[LIBAIO="-laio"])
1619
1620if test -n "$LIBAIO"; then
1621AC_DEFINE(HAVE_LIBAIO, 1, [libaio based POSIX enabled])
1622BUILD_LIBAIO=yes
1623fi
1624
1625BUILD_LINUX_IO_URING="no"
1626BUILD_LIBURING="no"
1627
1628case $host_os in
1629linux*)
1630AC_ARG_ENABLE([linux_io_uring],
1631AS_HELP_STRING([--disable-linux-io_uring],[Disable io-uring support.]))
1632
1633if test "x$enable_linux_io_uring" != "xno" ; then
1634AC_CHECK_HEADERS([liburing.h],
1635[AC_DEFINE(HAVE_LIBURING, 1, [io-uring based POSIX enabled]) LIBURING="-luring"],
1636AC_MSG_ERROR([Install liburing library and headers or use --disable-linux-io_uring]))
1637BUILD_LIBURING=yes
1638
1639AC_CHECK_HEADER([linux/io_uring.h],
1640[
1641AC_DEFINE([HAVE_IO_URING], [1], "io_uring support")
1642BUILD_LINUX_IO_URING="yes"
1643])
1644fi
1645;;
1646esac
1647
1648AM_CONDITIONAL([BUILD_LINUX_IO_URING], [test x$BUILD_LINUX_IO_URING = xyes])
1649
1650dnl gnfs section
1651BUILD_GNFS="no"
1652RPCBIND_SERVICE=""
1653AC_ARG_ENABLE([gnfs],
1654AS_HELP_STRING([--enable-gnfs],[Enable legacy gnfs server xlator.]))
1655if test "x${with_server}" = "xyes" -a "x$enable_gnfs" = "xyes"; then
1656BUILD_GNFS="yes"
1657GF_CFLAGS="$GF_CFLAGS -DBUILD_GNFS"
1658RPCBIND_SERVICE="rpcbind.service"
1659fi
1660AM_CONDITIONAL([BUILD_GNFS], [test x$BUILD_GNFS = xyes])
1661AC_SUBST(BUILD_GNFS)
1662AC_SUBST(RPCBIND_SERVICE)
1663dnl end gnfs section
1664
1665dnl Check for userspace-rcu
1666PKG_CHECK_MODULES([URCU], [liburcu-bp], [],
1667[AC_CHECK_HEADERS([urcu-bp.h],
1668[URCU_LIBS='-lurcu-bp'],
1669AC_MSG_ERROR([liburcu-bp not found]))])
1670PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.8], [],
1671[PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.7],
1672[AC_DEFINE(URCU_OLD, 1, [Define if liburcu 0.6 or 0.7 is found])
1673USE_CONTRIB_URCU='yes'],
1674[AC_CHECK_HEADERS([urcu/cds.h],
1675[AC_DEFINE(URCU_OLD, 1, [Define if liburcu 0.6 or 0.7 is found])
1676URCU_CDS_LIBS='-lurcu-cds'
1677USE_CONTRIB_URCU='yes'],
1678[AC_MSG_ERROR([liburcu-cds not found])])])])
1679
1680BUILD_UNITTEST="no"
1681AC_ARG_ENABLE([cmocka],
1682AS_HELP_STRING([--enable-cmocka],[Enable cmocka build options.]))
1683if test "x$enable_cmocka" = "xyes"; then
1684BUILD_UNITTEST="yes"
1685PKG_CHECK_MODULES([UNITTEST], [cmocka >= 1.0.1], [BUILD_UNITTEST="yes"],
1686[AC_MSG_ERROR([cmocka library is required to build glusterfs])]
1687)
1688fi
1689AM_CONDITIONAL([UNITTEST], [test x$BUILD_UNITTEST = xyes])
1690
1691dnl Define UNIT_TESTING only for building cmocka binaries.
1692UNITTEST_CFLAGS="${UNITTEST_CFLAGS} -DUNIT_TESTING=1"
1693
1694dnl Add cmocka for unit tests
1695case $host_os in
1696freebsd*)
1697dnl remove --coverage on FreeBSD due to a known llvm packaging bug
1698UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0"
1699UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}"
1700;;
1701*)
1702UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0 --coverage"
1703UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}"
1704;;
1705esac
1706
1707AC_SUBST(UNITTEST_CFLAGS)
1708AC_SUBST(UNITTEST_LDFLAGS)
1709
1710AC_SUBST(CFLAGS)
1711# end enable debug section
1712
1713dnl do not add -lresolv for freebsd
1714case $host_os in
1715freebsd*)
1716RESOLV_LIBS=""
1717;;
1718*)
1719RESOLV_LIBS="-lresolv"
1720;;
1721esac
1722
1723AC_SUBST(RESOLV_LIBS)
1724
1725# EC dynamic code generation section
1726
1727EC_DYNAMIC_SUPPORT="none"
1728EC_DYNAMIC_ARCH="none"
1729
1730AC_ARG_ENABLE([ec-dynamic],
1731AS_HELP_STRING([--disable-ec-dynamic],[Disable all dynamic code generation extensions for EC module]))
1732
1733AC_ARG_ENABLE([ec-dynamic-intel],
1734AS_HELP_STRING([--disable-ec-dynamic-intel],[Disable all INTEL dynamic code generation extensions for EC module]))
1735
1736AC_ARG_ENABLE([ec-dynamic-arm],
1737AS_HELP_STRING([--disable-ec-dynamic-arm],[Disable all ARM dynamic code generation extensions for EC module]))
1738
1739AC_ARG_ENABLE([ec-dynamic-x64],
1740AS_HELP_STRING([--disable-ec-dynamic-x64],[Disable dynamic INTEL x64 code generation for EC module]))
1741
1742AC_ARG_ENABLE([ec-dynamic-sse],
1743AS_HELP_STRING([--disable-ec-dynamic-sse],[Disable dynamic INTEL SSE code generation for EC module]))
1744
1745AC_ARG_ENABLE([ec-dynamic-avx],
1746AS_HELP_STRING([--disable-ec-dynamic-avx],[Disable dynamic INTEL AVX code generation for EC module]))
1747
1748AC_ARG_ENABLE([ec-dynamic-neon],
1749AS_HELP_STRING([--disable-ec-dynamic-neon],[Disable dynamic ARM NEON code generation for EC module]))
1750
1751if test "x$enable_ec_dynamic" != "xno"; then
1752case $host in
1753x86_64*)
1754if test "x$enable_ec_dynamic_intel" != "xno"; then
1755if test "x$enable_ec_dynamic_x64" != "xno"; then
1756EC_DYNAMIC_SUPPORT="$EC_DYNAMIC_SUPPORT x64"
1757AC_DEFINE(USE_EC_DYNAMIC_X64, 1, [Defined if using dynamic INTEL x64 code])
1758fi
1759if test "x$enable_ec_dynamic_sse" != "xno"; then
1760EC_DYNAMIC_SUPPORT="$EC_DYNAMIC_SUPPORT sse"
1761AC_DEFINE(USE_EC_DYNAMIC_SSE, 1, [Defined if using dynamic INTEL SSE code])
1762fi
1763if test "x$enable_ec_dynamic_avx" != "xno"; then
1764EC_DYNAMIC_SUPPORT="$EC_DYNAMIC_SUPPORT avx"
1765AC_DEFINE(USE_EC_DYNAMIC_AVX, 1, [Defined if using dynamic INTEL AVX code])
1766fi
1767
1768if test "x$EC_DYNAMIC_SUPPORT" != "xnone"; then
1769EC_DYNAMIC_ARCH="intel"
1770fi
1771fi
1772;;
1773arm*)
1774if test "x$enable_ec_dynamic_arm" != "xno"; then
1775if test "x$enable_ec_dynamic_neon" != "xno"; then
1776EC_DYNAMIC_SUPPORT="$EC_DYNAMIC_SUPPORT neon"
1777AC_DEFINE(USE_EC_DYNAMIC_NEON, 1, [Defined if using dynamic ARM NEON code])
1778fi
1779
1780if test "x$EC_DYNAMIC_SUPPORT" != "xnone"; then
1781EC_DYNAMIC_ARCH="arm"
1782fi
1783fi
1784;;
1785esac
1786
1787EC_DYNAMIC_SUPPORT="${EC_DYNAMIC_SUPPORT#none }"
1788fi
1789
1790AM_CONDITIONAL([ENABLE_EC_DYNAMIC_INTEL], [test "x$EC_DYNAMIC_ARCH" = "xintel"])
1791AM_CONDITIONAL([ENABLE_EC_DYNAMIC_ARM], [test "x$EC_DYNAMIC_ARCH" = "xarm"])
1792
1793AM_CONDITIONAL([ENABLE_EC_DYNAMIC_X64], [test "x${EC_DYNAMIC_SUPPORT##*x64*}" = "x"])
1794AM_CONDITIONAL([ENABLE_EC_DYNAMIC_SSE], [test "x${EC_DYNAMIC_SUPPORT##*sse*}" = "x"])
1795AM_CONDITIONAL([ENABLE_EC_DYNAMIC_AVX], [test "x${EC_DYNAMIC_SUPPORT##*avx*}" = "x"])
1796AM_CONDITIONAL([ENABLE_EC_DYNAMIC_NEON], [test "x${EC_DYNAMIC_SUPPORT##*neon*}" = "x"])
1797
1798AC_SUBST(USE_EC_DYNAMIC_X64)
1799AC_SUBST(USE_EC_DYNAMIC_SSE)
1800AC_SUBST(USE_EC_DYNAMIC_AVX)
1801AC_SUBST(USE_EC_DYNAMIC_NEON)
1802
1803# end EC dynamic code generation section
1804
1805dnl libglusterfs.so uses math functions
1806GF_LDADD="${GF_LDADD} ${MATH_LIB}"
1807
1808case $host_os in
1809dnl Can't use libtool's portable "-no-undefined" as it seems to be ignored on Linux
1810linux*)
1811GF_NO_UNDEFINED='-Wl,--no-undefined'
1812;;
1813darwin*)
1814GF_NO_UNDEFINED='-Wl,-undefined'
1815;;
1816*)
1817dnl There's an issue on FreeBSD with reference to __progname used in some parts of code
1818GF_NO_UNDEFINED=''
1819;;
1820esac
1821dnl GF_XLATOR_DEFAULT_LDFLAGS is for most xlators that expose a common set of symbols
1822GF_XLATOR_DEFAULT_LDFLAGS='-avoid-version -export-symbols $(top_srcdir)/xlators/xlator.sym $(UUID_LIBS) $(GF_NO_UNDEFINED) $(TIRPC_LIBS)'
1823dnl GF_XLATOR_LDFLAGS is for xlators that expose extra symbols, e.g. dht
1824GF_XLATOR_LDFLAGS='-avoid-version $(UUID_LIBS) $(GF_NO_UNDEFINED) $(TIRPC_LIBS)'
1825
1826AC_SUBST(GF_HOST_OS)
1827AC_SUBST(GF_CFLAGS)
1828AC_SUBST(GF_LDFLAGS)
1829AC_SUBST(GF_LDADD)
1830AC_SUBST(GF_FUSE_LDADD)
1831AC_SUBST(GF_FUSE_CFLAGS)
1832AC_SUBST(RLLIBS)
1833AC_SUBST(LIBAIO)
1834AC_SUBST(LIBURING)
1835AC_SUBST(AM_MAKEFLAGS)
1836AC_SUBST(AM_LIBTOOLFLAGS)
1837AC_SUBST(GF_NO_UNDEFINED)
1838AC_SUBST(GF_XLATOR_DEFAULT_LDFLAGS)
1839AC_SUBST(GF_XLATOR_LDFLAGS)
1840AC_SUBST(GF_XLATOR_MGNT_LIBADD)
1841
1842case $host_os in
1843*freebsd*)
1844GF_XLATOR_MGNT_LIBADD="-lutil -lprocstat"
1845;;
1846esac
1847
1848CONTRIBDIR='$(top_srcdir)/contrib'
1849AC_SUBST(CONTRIBDIR)
1850
1851GF_CPPDEFINES='-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)'
1852GF_CPPINCLUDES='-include $(top_builddir)/config.h -include $(top_builddir)/site.h -I$(top_srcdir)/libglusterfs/src -I$(top_builddir)/libglusterfs/src'
1853if test "x${USE_CONTRIB_URCU}" = "xyes"; then
1854GF_CPPINCLUDES="${GF_CPPINCLUDES} -I\$(CONTRIBDIR)/userspace-rcu"
1855fi
1856GF_CPPFLAGS="$GF_CPPFLAGS $GF_CPPDEFINES $GF_CPPINCLUDES"
1857AC_SUBST([GF_CPPFLAGS])
1858
1859dnl Note GF_BSD_HOST_OS and GF_SOLARIS_HOST_OS are not used
1860dnl through Makefile.am and so not defined as conditionals.
1861AM_CONDITIONAL([GF_LINUX_HOST_OS], test "${GF_HOST_OS}" = "GF_LINUX_HOST_OS")
1862AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS")
1863
1864AC_SUBST(GLUSTERD_WORKDIR)
1865AM_CONDITIONAL([GF_INSTALL_GLUSTERD_WORKDIR], test ! -d "${GLUSTERD_WORKDIR}" && test -d "${sysconfdir}/glusterd" )
1866AC_SUBST(GLUSTERD_VOLFILE)
1867AC_SUBST(GLUSTERFS_LIBEXECDIR)
1868AC_SUBST(GLUSTERFSD_MISCDIR)
1869
1870dnl pkg-config versioning
1871dnl
1872dnl Once we released gluster-api.pc with version=7. Since then we undid the
1873dnl library versioning and replaced it with symbol-versioning. The current
1874dnl libgfapi.so has version 0, but the symbols have the version from the main
1875dnl package at the time they were added.
1876dnl
1877dnl Because other packages (like samba) use the pkg-config version, we can not
1878dnl drop it, or decrease the version easily. The simplest solution is to keep
1879dnl the version=7 and add sub-digits for the actual package/symbol versions.
1880GFAPI_VERSION="7."${PACKAGE_VERSION}
1881LIBGFCHANGELOG_VERSION="0.0.1"
1882AC_SUBST(GFAPI_VERSION)
1883AC_SUBST(LIBGFCHANGELOG_VERSION)
1884
1885dnl libtool versioning
1886LIBGFXDR_LT_VERSION="0:1:0"
1887LIBGFRPC_LT_VERSION="0:1:0"
1888LIBGLUSTERFS_LT_VERSION="0:1:0"
1889LIBGFCHANGELOG_LT_VERSION="0:1:0"
1890GFAPI_LT_VERSION="0:0:0"
1891AC_SUBST(LIBGFXDR_LT_VERSION)
1892AC_SUBST(LIBGFRPC_LT_VERSION)
1893AC_SUBST(LIBGLUSTERFS_LT_VERSION)
1894AC_SUBST(LIBGFCHANGELOG_LT_VERSION)
1895AC_SUBST(GFAPI_LT_VERSION)
1896AC_SUBST(GFAPI_EXTRA_LDFLAGS)
1897
1898GFAPI_LIBS="${ACL_LIBS}"
1899AC_SUBST(GFAPI_LIBS)
1900
1901dnl this change necessary for run-tests.sh
1902AC_CONFIG_FILES([tests/env.rc],[ln -s ${ac_abs_builddir}/env.rc ${ac_abs_srcdir}/env.rc 2>/dev/null])
1903
1904AC_OUTPUT
1905
1906echo
1907echo "GlusterFS configure summary"
1908echo "==========================="
1909echo "FUSE client : $BUILD_FUSE_CLIENT"
1910echo "epoll IO multiplex : $BUILD_EPOLL"
1911echo "fusermount : $BUILD_FUSERMOUNT"
1912echo "readline : $BUILD_READLINE"
1913echo "georeplication : $BUILD_SYNCDAEMON"
1914echo "Linux-AIO : $BUILD_LIBAIO"
1915echo "Linux io_uring : $BUILD_LINUX_IO_URING"
1916echo "Use liburing : $BUILD_LIBURING"
1917echo "Enable Debug : $BUILD_DEBUG"
1918echo "Run with Valgrind : $VALGRIND_TOOL"
1919echo "Sanitizer enabled : $SANITIZER"
1920echo "XML output : $BUILD_XML_OUTPUT"
1921echo "Unit Tests : $BUILD_UNITTEST"
1922echo "Track priv ports : $TRACK_PRIVPORTS"
1923echo "POSIX ACLs : $BUILD_POSIX_ACLS"
1924echo "SELinux features : $USE_SELINUX"
1925echo "firewalld-config : $BUILD_FIREWALLD"
1926echo "Events : $BUILD_EVENTS"
1927echo "EC dynamic support : $EC_DYNAMIC_SUPPORT"
1928echo "Use memory pools : $USE_MEMPOOL"
1929echo "Nanosecond m/atimes : $BUILD_NANOSECOND_TIMESTAMPS"
1930echo "Server components : $with_server"
1931echo "Legacy gNFS server : $BUILD_GNFS"
1932echo "IPV6 default : $with_ipv6_default"
1933echo "Use TIRPC : $with_libtirpc"
1934echo "With Python : ${PYTHON_VERSION}"
1935echo "Cloudsync : $BUILD_CLOUDSYNC"
1936echo "Metadata dispersal : $BUILD_METADISP"
1937echo "Link with TCMALLOC : $BUILD_TCMALLOC"
1938echo "Enable Brick Mux : $USE_BRICKMUX"
1939echo "Building with LTO : $LTO_BUILD"
1940echo
1941
1942if test "x$SANITIZER" != "xnone"; then
1943UC_SANITIZER=$(echo ${SANITIZER} | tr 'a-z' 'A-Z')
1944echo "Note: since glusterfs processes are daemon processes, use"
1945echo "'export ${UC_SANITIZER}_OPTIONS=log_path=/path/to/xxx.log' to collect"
1946echo "sanitizer output. Further details and more options can be"
1947echo "found at https://github.com/google/sanitizers."
1948fi
1949