7 # find the buildtools directory
9 while not os
.path
.exists(top
+'/buildtools') and len(top
.split('/')) < 5:
11 sys
.path
.insert(0, top
+ '/buildtools/wafsamba')
15 from waflib
import Options
, Logs
, Errors
, Context
17 from wafsamba
import samba_dist
, samba_utils
18 from samba_utils
import MODE_644
, MODE_744
, MODE_755
, MODE_777
20 if os
.path
.isfile('./VERSION'):
22 elif os
.path
.isfile('../VERSION'):
25 Logs
.error("VERSION file not found")
27 default_prefix
= Options
.default_prefix
= '/usr/local'
29 samba_dist
.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
30 lib/tevent:lib/tevent lib/tdb:lib/tdb
31 third_party/socket_wrapper:third_party/socket_wrapper
32 third_party/popt:third_party/popt
33 lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap
34 lib/ccan:lib/ccan libcli/util:libcli/util
35 lib/async_req:lib/async_req
36 lib/pthreadpool:lib/pthreadpool
37 lib/messaging:lib/messaging
38 buildtools:buildtools third_party/waf:third_party/waf''')
51 'ctdb-script.options.5',
63 'ctdb_mutex_ceph_rados_helper.7',
70 env
= samba_utils
.LOAD_ENVIRONMENT()
72 return samba_version
.samba_version_file('%s/VERSION' % vdir
, vdir
, env
)
74 def get_version_string():
75 if Context
.g_module
.VERSION
:
76 return Context
.g_module
.VERSION
77 version
= get_version()
78 Context
.g_module
.VERSION
= version
.STRING
.replace('-', '.')
79 return Context
.g_module
.VERSION
82 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
84 opt
.RECURSE('lib/replace')
86 opt
.RECURSE('lib/util')
88 opt
.RECURSE('lib/talloc')
89 opt
.RECURSE('lib/tevent')
90 opt
.RECURSE('lib/tdb')
92 opt
.add_option('--enable-infiniband',
93 help=("Turn on infiniband support (default=no)"),
94 action
="store_true", dest
='ctdb_infiniband', default
=False)
95 opt
.add_option('--enable-pmda',
96 help=("Turn on PCP pmda support (default=no)"),
97 action
="store_true", dest
='ctdb_pmda', default
=False)
98 opt
.add_option('--enable-etcd-reclock',
99 help=("Enable etcd recovery lock helper (default=no)"),
100 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
102 opt
.add_option('--with-libcephfs',
103 help=("Directory under which libcephfs is installed"),
104 action
="store", dest
='libcephfs_dir', default
=None)
105 opt
.add_option('--enable-ceph-reclock',
106 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
107 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
109 opt
.add_option('--with-logdir',
110 help=("Path to log directory"),
111 action
="store", dest
='ctdb_logdir', default
=None)
112 opt
.add_option('--with-socketpath',
113 help=("path to CTDB daemon socket"),
114 action
="store", dest
='ctdb_sockpath', default
=None)
118 # No need to build python bindings for talloc/tevent/tdb
119 if conf
.IN_LAUNCH_DIR():
120 conf
.env
.standalone_ctdb
= True
121 Options
.options
.disable_python
= True
123 conf
.RECURSE('lib/replace')
125 conf
.CHECK_HEADERS(headers
='''sys/socket.h
133 conf
.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
134 define
='HAVE_AF_PACKET',
135 headers
='sys/socket.h linux/if_packet.h')
137 conf
.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
138 define
='HAVE_PACKETSOCKET',
139 headers
='sys/socket.h linux/if_packet.h')
141 conf
.CHECK_CODE('''pthread_mutex_t m;
143 m.__data.__owner = pid;
145 'HAVE_PTHREAD_INTERNAL_MUTEX_OWNER',
147 msg
='Checking for internal POSIX mutex owner field')
148 if not conf
.env
.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER
:
149 # This is unsupported - please see note in debug_locks.sh
150 Logs
.info('Building without unsupported mutex debugging hack')
152 if conf
.env
.standalone_ctdb
:
153 conf
.SAMBA_CHECK_PERL(mandatory
=True)
155 # This is just for consistency and to check the version for the
156 # build system, see Options.options.disable_python = True above
157 conf
.SAMBA_CHECK_PYTHON()
158 conf
.SAMBA_CHECK_PYTHON_HEADERS()
160 # We just want gnutls_rnd for rand subsystem
161 conf
.CHECK_FUNCS_IN('gnutls_rnd', 'gnutls')
164 if conf
.CHECK_FOR_THIRD_PARTY():
165 conf
.RECURSE('third_party/popt')
166 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
167 conf
.RECURSE('third_party/socket_wrapper')
168 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
170 if not conf
.CHECK_POPT():
171 raise Errors
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
173 conf
.define('USING_SYSTEM_POPT', 1)
174 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
177 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
178 if not conf
.CHECK_SOCKET_WRAPPER():
179 raise Errors
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
181 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
182 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
184 conf
.RECURSE('lib/util')
186 conf
.RECURSE('lib/talloc')
187 conf
.RECURSE('lib/tevent')
188 conf
.RECURSE('lib/tdb')
190 conf
.CHECK_HEADERS('sched.h')
191 conf
.CHECK_HEADERS('procinfo.h')
192 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
193 Logs
.error('Need thread_setsched() on AIX')
195 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
196 Logs
.error('Need sched_setscheduler()')
198 conf
.CHECK_FUNCS('mlockall')
199 conf
.CHECK_FUNCS('getrusage', headers
="sys/time.h sys/resource.h")
201 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
202 conf
.DEFINE('ETIME', 'ETIMEDOUT')
204 if sys
.platform
.startswith('linux'):
205 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
207 if not conf
.CHECK_HEADERS('pcap.h'):
208 Logs
.error('Need libpcap')
210 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
211 Logs
.error('Need libpcap')
214 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
215 checklibc
=True, headers
='execinfo.h'):
216 Logs
.error('backtrace support not available')
219 if Options
.options
.ctdb_pmda
:
222 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
225 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
227 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
230 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
233 Logs
.error("PMDA support not available")
236 Logs
.info('Building with PMDA support')
237 conf
.define('HAVE_PMDA', 1)
238 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
239 'lib/pcp/pmdas/ctdb')
241 have_infiniband
= False
242 if Options
.options
.ctdb_infiniband
:
245 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
247 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
249 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
252 have_infiniband
= True
254 Logs
.error("Infiniband support not available")
257 Logs
.info('Building with Infiniband support')
258 conf
.define('HAVE_INFINIBAND', 1)
259 conf
.define('USE_INFINIBAND', 1)
261 have_etcd_reclock
= False
262 if Options
.options
.ctdb_etcd_reclock
:
264 conf
.check_python_module('etcd')
265 have_etcd_reclock
= True
267 Logs
.error('etcd support not available')
269 if have_etcd_reclock
:
270 Logs
.info('Building with etcd support')
271 conf
.env
.etcd_reclock
= have_etcd_reclock
273 if Options
.options
.libcephfs_dir
:
274 Logs
.error('''--with-libcephfs no longer supported, please use compiler
275 flags instead, e.g. GCC LIBRARY_PATH and C_INCLUDE_PATH''')
278 if Options
.options
.ctdb_ceph_reclock
:
279 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
280 conf
.CHECK_LIB('rados', shlib
=True)):
281 Logs
.info('Building with Ceph librados recovery lock support')
282 conf
.define('HAVE_LIBRADOS', 1)
284 Logs
.error("Missing librados for Ceph recovery lock support")
287 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
288 conf
.env
.CTDB_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'share/ctdb')
289 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
290 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
291 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
292 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
294 if Options
.options
.ctdb_logdir
:
295 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
297 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
299 if Options
.options
.ctdb_sockpath
:
300 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
302 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
304 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
306 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
308 -DCTDB_DATADIR=\"%s\"
311 -DCTDB_RUNDIR=\"%s\"''' % (
312 conf
.env
.CTDB_HELPER_BINDIR
,
313 conf
.env
.CTDB_LOGDIR
,
314 conf
.env
.CTDB_DATADIR
,
315 conf
.env
.CTDB_ETCDIR
,
316 conf
.env
.CTDB_VARDIR
,
317 conf
.env
.CTDB_RUNDIR
))
319 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.CTDB_DATADIR
, 'tests')
320 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
322 # Allow unified compilation and separate compilation of utilities
324 if not conf
.env
.standalone_ctdb
:
325 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
327 if Context
.g_module
.top
== '.':
328 # Building from tarball
329 conf
.ADD_EXTRA_INCLUDES('#include')
331 # Building standalone CTDB from within Samba tree
332 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
333 conf
.ADD_EXTRA_INCLUDES('#ctdb')
334 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
336 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
337 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
338 conf
.SAMBA_CONFIG_H()
340 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
341 conf
.env
.ctdb_generate_manpages
= True
343 conf
.env
.ctdb_generate_manpages
= False
345 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
346 conf
.env
.ctdb_prebuilt_manpages
= []
347 manpages
= manpages_binary
+ manpages_misc
348 if conf
.env
.etcd_reclock
:
349 manpages
+= manpages_etcd
350 if conf
.env
.HAVE_LIBRADOS
:
351 manpages
+= manpages_ceph
353 if os
.path
.exists(os
.path
.join("doc", m
)):
354 Logs
.info(" %s: yes" % (m
))
355 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
357 Logs
.info(" %s: no" % (m
))
360 if bld
.env
.standalone_ctdb
:
361 # enable building of public headers in the build tree
362 bld
.env
.build_public_headers
= 'include/public'
364 if bld
.env
.standalone_ctdb
:
365 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
367 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
369 bld
.RECURSE('lib/replace')
370 if bld
.CHECK_FOR_THIRD_PARTY():
371 bld
.RECURSE('third_party/popt')
372 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
373 bld
.RECURSE('third_party/socket_wrapper')
375 bld
.RECURSE('lib/tdb_wrap')
376 bld
.RECURSE('lib/util')
377 bld
.RECURSE('lib/async_req')
378 bld
.RECURSE('lib/pthreadpool')
379 bld
.RECURSE('lib/messaging')
381 bld
.RECURSE('lib/talloc')
382 bld
.RECURSE('lib/tevent')
383 bld
.RECURSE('lib/tdb')
385 if bld
.env
.standalone_ctdb
:
386 # If a combined build is implemented, CTDB will want to
387 # build against samba-util rather than samba-util-core.
388 # Similarly, other Samba subsystems expect samba-util. So,
389 # for a standalone build, just define a fake samba-util
390 # subsystem that pulls in samba-util-core.
391 bld
.SAMBA_SUBSYSTEM('samba-util',
393 deps
='samba-util-core')
395 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
396 source
=bld
.SUBDIR('tcp',
397 'tcp_connect.c tcp_init.c tcp_io.c'),
399 deps
='replace tdb talloc tevent')
402 if bld
.env
.HAVE_INFINIBAND
:
403 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
404 source
=bld
.SUBDIR('ib',
405 '''ibwrapper.c ibw_ctdb.c
408 deps
='replace talloc tevent tdb')
409 ib_deps
= ' ctdb-ib rdmacm ibverbs'
411 bld
.SAMBA_SUBSYSTEM('ctdb-system',
412 source
=bld
.SUBDIR('common',
413 'system_socket.c system.c'),
414 deps
='replace talloc tevent tdb pcap samba-util')
416 bld
.SAMBA_SUBSYSTEM('ctdb-common',
417 source
=bld
.SUBDIR('common',
418 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
421 deps
='''replace popt talloc tevent tdb popt ctdb-system
422 ctdb-protocol-util''')
424 bld
.SAMBA_SUBSYSTEM('ctdb-util',
425 source
=bld
.SUBDIR('common',
458 bld
.SAMBA_SUBSYSTEM('ctdb-logging-conf',
459 source
='common/logging_conf.c',
460 deps
='ctdb-util talloc')
462 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
463 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
466 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
467 source
=bld
.SUBDIR('protocol',
468 '''protocol_header.c protocol_packet.c
478 deps
='ctdb-protocol-basic replace talloc tdb')
480 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
481 source
='protocol/protocol_util.c',
482 deps
='ctdb-util replace talloc tdb')
484 bld
.SAMBA_SUBSYSTEM('ctdb-client',
485 source
=bld
.SUBDIR('client',
486 '''client_connect.c client_call.c
487 client_message.c client_control.c
488 client_message_sync.c
489 client_control_sync.c
490 client_db.c client_util.c
493 deps
='''ctdb-protocol
503 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
504 source
=bld
.SUBDIR('common',
505 '''sock_daemon.c'''),
506 deps
='''samba-util ctdb-util ctdb-system tevent-util
507 LIBASYNC_REQ replace talloc tevent''')
509 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
510 source
=bld
.SUBDIR('server',
511 '''ipalloc_deterministic.c
512 ipalloc_nondeterministic.c
518 deps
='ctdb-protocol-util replace talloc tevent')
520 bld
.SAMBA_BINARY('ctdb-path',
521 source
='common/path_tool.c',
522 cflags
='-DCTDB_PATH_TOOL',
523 deps
='''ctdb-util samba-util talloc replace popt''',
524 install_path
='${CTDB_HELPER_BINDIR}')
526 bld
.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
527 source
='cluster/cluster_conf.c',
530 bld
.SAMBA_SUBSYSTEM('ctdb-database-conf',
531 source
='database/database_conf.c',
534 bld
.SAMBA_SUBSYSTEM('ctdb-event-conf',
535 source
='event/event_conf.c',
538 bld
.SAMBA_SUBSYSTEM('ctdb-failover-conf',
539 source
='failover/failover_conf.c',
542 bld
.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
543 source
='server/legacy_conf.c',
546 bld
.SAMBA_BINARY('ctdb-config',
547 source
='common/conf_tool.c',
548 cflags
='-DCTDB_CONF_TOOL',
549 deps
='''ctdb-logging-conf
555 ctdb-util samba-util talloc replace popt''',
556 install_path
='${CTDB_HELPER_BINDIR}')
558 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
559 source
=bld
.SUBDIR('event',
561 event_protocol_util.c
563 deps
='ctdb-protocol-basic')
565 bld
.SAMBA_LIBRARY('ctdb-event-client',
566 source
='event/event_client.c',
567 deps
='ctdb-event-protocol ctdb-util tevent talloc',
568 private_library
=True)
570 bld
.SAMBA_BINARY('ctdb-eventd',
571 source
=bld
.SUBDIR('event',
578 deps
='''ctdb-event-protocol
579 ctdb-event-conf ctdb-logging-conf
580 ctdb-server-util samba-util ctdb-util
581 talloc tevent replace popt''',
582 install_path
='${CTDB_HELPER_BINDIR}')
584 bld
.SAMBA_BINARY('ctdb-event',
585 source
='event/event_tool.c',
586 cflags
='-DCTDB_EVENT_TOOL',
587 deps
='''ctdb-event-client ctdb-event-protocol
588 ctdb-util samba-util talloc replace''',
589 install_path
='${CTDB_HELPER_BINDIR}')
591 bld
.SAMBA_BINARY('ctdbd',
592 source
='server/ctdbd.c ' +
594 '''ctdb_daemon.c ctdb_recoverd.c
595 ctdb_recover.c ctdb_freeze.c
596 ctdb_tunables.c ctdb_monitor.c
597 ctdb_server.c ctdb_control.c
598 ctdb_call.c ctdb_ltdb_server.c
599 ctdb_traverse.c eventscript.c
601 ctdb_persistent.c ctdb_keepalive.c
605 ctdb_vacuum.c ctdb_banning.c
608 ctdb_lock.c ctdb_fork.c
609 ctdb_tunnel.c ctdb_client.c
613 deps
='''ctdb-common ctdb-system ctdb-protocol
614 ctdb-tcp ctdb-util replace sys_rw popt
622 talloc tevent tdb-wrap tdb talloc_report''' +
624 install_path
='${SBINDIR}',
627 bld
.SAMBA_BINARY('ctdb',
628 source
='tools/ctdb.c',
629 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
630 ctdb-util ctdb-system samba-util sys_rw popt''',
631 install_path
='${BINDIR}',
634 bld
.SAMBA_BINARY('ctdb_killtcp',
635 source
='tools/ctdb_killtcp.c',
636 deps
='''ctdb-protocol-util ctdb-util ctdb-system
637 samba-util replace''',
638 install_path
='${CTDB_HELPER_BINDIR}')
640 bld
.SAMBA_BINARY('ltdbtool',
641 source
='tools/ltdbtool.c',
644 install_path
='${BINDIR}',
645 manpages
='ltdbtool.1')
647 bld
.SAMBA_BINARY('ctdb_lock_helper',
648 source
='server/ctdb_lock_helper.c',
649 deps
='''samba-util sys_rw ctdb-system tevent-util
650 talloc tevent tdb''',
652 install_path
='${CTDB_HELPER_BINDIR}')
654 bld
.SAMBA_BINARY('ctdb_recovery_helper',
655 source
='server/ctdb_recovery_helper.c',
656 deps
='''ctdb-client ctdb-protocol ctdb-util
657 samba-util sys_rw replace tdb''',
658 install_path
='${CTDB_HELPER_BINDIR}')
660 bld
.SAMBA_BINARY('ctdb_takeover_helper',
661 source
='server/ctdb_takeover_helper.c',
662 deps
='''ctdb-client ctdb-protocol ctdb-util
663 samba-util sys_rw replace ctdb-ipalloc popt''',
664 install_path
='${CTDB_HELPER_BINDIR}')
666 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
667 source
='server/ctdb_mutex_fcntl_helper.c',
668 deps
='''sys_rw ctdb-system tevent-util ctdb-util
672 install_path
='${CTDB_HELPER_BINDIR}')
674 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
675 source
='utils/smnotify/smnotify.x',
676 target
='utils/smnotify/smnotify.h',
677 rule
='rpcgen -h ${SRC} > ${TGT}')
679 xdr_buf_hack
= 'grep -Fv "register int32_t *buf;"'
681 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
682 source
='utils/smnotify/smnotify.x',
683 target
='utils/smnotify/gen_xdr.c',
684 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
686 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
687 source
='utils/smnotify/smnotify.x',
688 target
='utils/smnotify/gen_smnotify.c',
689 rule
='rpcgen -l ${SRC} > ${TGT}')
691 bld
.SAMBA_BINARY('smnotify',
692 source
=bld
.SUBDIR('utils/smnotify',
693 'smnotify.c gen_smnotify.c gen_xdr.c'),
694 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
695 includes
='utils utils/smnotify',
696 install_path
='${CTDB_HELPER_BINDIR}')
698 bld
.SAMBA_BINARY('ping_pong',
699 source
='utils/ping_pong/ping_pong.c',
701 install_path
='${BINDIR}',
702 manpages
='ping_pong.1')
704 if bld
.env
.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER
:
705 bld
.SAMBA_BINARY('tdb_mutex_check',
706 source
='utils/tdb/tdb_mutex_check.c',
708 install_path
='${CTDB_HELPER_BINDIR}')
710 if bld
.env
.HAVE_PMDA
:
711 bld
.SAMBA_BINARY('pmdactdb',
712 source
='utils/pmda/pmda_ctdb.c',
713 deps
='''ctdb-client ctdb-protocol ctdb-util
714 samba-util pcp_pmda pcp''',
715 install_path
='${CTDB_PMDADIR}')
716 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
718 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
720 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
722 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
724 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
726 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
729 if bld
.env
.HAVE_LIBRADOS
:
730 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
731 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
732 deps
='talloc tevent rados',
734 install_path
='${CTDB_HELPER_BINDIR}')
736 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
737 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
738 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
739 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
740 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
741 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
742 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
743 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
744 sed_cmdline
= '-e "%s" ' * 8 % \
745 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
746 sed_expr6
, sed_expr7
, sed_expr8
)
748 manpages_extra
= list(manpages_misc
)
749 if bld
.env
.etcd_reclock
:
750 manpages_extra
+= manpages_etcd
751 if bld
.env
.HAVE_LIBRADOS
:
752 manpages_extra
+= manpages_ceph
753 for f
in manpages_binary
+ manpages_extra
:
755 bld
.SAMBA_GENERATOR(x
,
756 source
=os
.path
.join('doc', x
),
758 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
760 if bld
.env
.ctdb_generate_manpages
:
761 bld
.MANPAGES(' '.join(manpages_extra
), True)
763 for m
in bld
.env
.ctdb_prebuilt_manpages
:
764 bld
.SAMBA_GENERATOR(m
,
765 source
=os
.path
.join("doc", m
),
767 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
768 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
770 bld
.SAMBA_GENERATOR('ctdb-onnode',
771 source
='tools/onnode',
773 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
774 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
775 destname
='onnode', chmod
=MODE_755
)
777 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
778 source
='tools/ctdb_diagnostics',
779 target
='ctdb_diagnostics',
780 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
781 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
782 destname
='ctdb_diagnostics', chmod
=MODE_755
)
784 if bld
.env
.etcd_reclock
:
785 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
786 source
='utils/etcd/ctdb_etcd_lock',
787 target
='ctdb_etcd_lock',
788 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
789 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
790 destname
='ctdb_etcd_lock', chmod
=MODE_744
)
792 bld
.SAMBA_GENERATOR('ctdb-natgw',
793 source
='tools/ctdb_natgw',
795 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
796 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
797 destname
='ctdb_natgw', chmod
=MODE_755
)
799 bld
.SAMBA_GENERATOR('ctdb-lvs',
800 source
='tools/ctdb_lvs',
802 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
803 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
804 destname
='ctdb_lvs', chmod
=MODE_755
)
806 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
808 fl
= os
.path
.join(dirname
, f
)
809 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
811 mode
= os
.lstat(fl
).st_mode
& MODE_777
813 fl
= samba_utils
.os
.path
.relpath(fl
, arg
['trim_path'])
814 arg
['file_list'].append([fl
, mode
])
816 def SUBDIR_MODE(path
, trim_path
=None):
817 pd
= {'trim_path': trim_path
, 'file_list': []}
818 for dirname
, _subdirs
, fnames
in os
.walk(path
):
819 SUBDIR_MODE_callback(pd
, dirname
, fnames
)
820 return pd
['file_list']
822 event_script_subdirs
= [
830 if bld
.env
.standalone_ctdb
:
833 configdir
= 'ctdb/config'
835 for t
in event_script_subdirs
:
836 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
837 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
839 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
840 destname
=fmode
[0], chmod
=fmode
[1])
842 for t
in etc_subdirs
:
843 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
845 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
846 destname
=fmode
[0], chmod
=fmode
[1])
848 # If this is a direct install and there are no event scripts
849 # linked/enabled then enable some standard ones
850 if os
.environ
.get('DESTDIR') is None:
851 fmt
= 'events/legacy/%s.script'
852 required_script
= '00.ctdb'
853 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
854 fmt
% (required_script
))
855 if not os
.path
.islink(required_path
) and \
856 not os
.path
.exists(required_path
):
857 default_scripts
= [ required_script
,
862 for t
in default_scripts
:
863 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
864 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
865 bld
.symlink_as(name
, tgt
)
867 bld
.SAMBA_GENERATOR('ctdb-functions',
868 source
='config/functions',
870 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
871 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
874 'ctdb-crash-cleanup.sh',
875 'debug-hung-script.sh',
877 'nfs-linux-kernel-callout',
882 for t
in etc_scripts
:
883 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
884 destname
=t
, chmod
=MODE_755
)
886 bld
.SAMBA_GENERATOR('ctdb-sudoers',
887 source
='config/ctdb.sudoers',
888 target
='ctdb.sudoers',
889 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
890 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
893 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
894 'config/notification.README',
897 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
898 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
899 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
901 for d
in ['volatile', 'persistent', 'state']:
902 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
905 # Test-only below this point
908 if not bld
.env
.standalone_ctdb
and not bld
.CONFIG_GET('ENABLE_SELFTEST'):
911 bld
.SAMBA_BINARY('errcode',
912 source
='tests/src/errcode.c',
914 install_path
='${CTDB_TEST_LIBEXECDIR}')
916 bld
.SAMBA_BINARY('sigcode',
917 source
='tests/src/sigcode.c',
919 install_path
='${CTDB_TEST_LIBEXECDIR}')
942 for target
in ctdb_util_tests
:
943 src
= 'tests/src/' + target
+ '.c'
945 bld
.SAMBA_BINARY(target
,
947 deps
='''ctdb-tests-backtrace
957 install_path
='${CTDB_TEST_LIBEXECDIR}')
959 bld
.SAMBA_BINARY('reqid_test',
960 source
='tests/src/reqid_test.c',
961 deps
='samba-util talloc',
962 install_path
='${CTDB_TEST_LIBEXECDIR}')
964 bld
.SAMBA_BINARY('rb_test',
965 source
='tests/src/rb_test.c',
966 deps
='samba-util talloc',
967 install_path
='${CTDB_TEST_LIBEXECDIR}')
969 bld
.SAMBA_BINARY('ctdb_packet_parse',
970 source
='tests/src/ctdb_packet_parse.c',
971 deps
='talloc tevent tdb ctdb-protocol',
972 install_path
='${CTDB_TEST_LIBEXECDIR}')
974 bld
.SAMBA_BINARY('system_socket_test',
975 source
='tests/src/system_socket_test.c',
976 deps
='''ctdb-tests-backtrace
981 install_path
='${CTDB_TEST_LIBEXECDIR}')
983 bld
.SAMBA_BINARY('porting_tests',
984 source
='tests/src/porting_tests.c',
985 deps
='samba-util ctdb-system popt',
986 install_path
='${CTDB_TEST_LIBEXECDIR}')
988 bld
.SAMBA_BINARY('sock_daemon_test',
989 source
='tests/src/sock_daemon_test.c',
990 deps
='''ctdb-system talloc tevent tevent-util
991 LIBASYNC_REQ samba-util sys_rw''',
992 install_path
='${CTDB_TEST_LIBEXECDIR}')
994 bld
.SAMBA_BINARY('ctdb_io_test',
995 source
='tests/src/ctdb_io_test.c',
996 deps
='''talloc tevent tdb samba-util sys_rw''',
997 install_path
='${CTDB_TEST_LIBEXECDIR}')
999 bld
.SAMBA_BINARY('ctdb-db-test',
1000 source
='tests/src/db_test_tool.c',
1001 cflags
='-DCTDB_DB_TEST_TOOL',
1002 deps
='''ctdb-client ctdb-protocol
1003 ctdb-util samba-util talloc tevent replace''',
1004 install_path
='${CTDB_TEST_LIBEXECDIR}')
1006 for target
in ['tmon_ping_test', 'tmon_test']:
1007 src
= 'tests/src/' + target
+ '.c'
1009 bld
.SAMBA_BINARY(target
,
1012 ctdb-tests-backtrace
1022 install_path
='${CTDB_TEST_LIBEXECDIR}')
1024 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
1025 source
=bld
.SUBDIR('tests/src',
1026 'protocol_common_basic.c'),
1027 deps
='samba-util replace talloc')
1029 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
1030 source
=bld
.SUBDIR('tests/src',
1031 '''protocol_common.c
1032 protocol_common_ctdb.c
1034 deps
='ctdb-protocol-tests-basic replace talloc tdb')
1036 bld
.SAMBA_BINARY('protocol_basic_test',
1037 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
1038 deps
='ctdb-protocol-tests-basic talloc',
1039 install_path
='${CTDB_TEST_LIBEXECDIR}')
1041 ctdb_protocol_tests
= [
1042 'protocol_types_test',
1043 'protocol_ctdb_test',
1044 'protocol_util_test',
1045 'protocol_types_compat_test',
1046 'protocol_ctdb_compat_test',
1049 for target
in ctdb_protocol_tests
:
1050 src
= 'tests/src/' + target
+ '.c'
1052 bld
.SAMBA_BINARY(target
,
1054 deps
='''ctdb-protocol-tests-common
1055 samba-util ctdb-util talloc tdb''',
1056 install_path
='${CTDB_TEST_LIBEXECDIR}')
1058 bld
.SAMBA_BINARY('event_protocol_test',
1059 source
='event/event_protocol_test.c',
1060 deps
='''ctdb-protocol-tests-basic
1061 ctdb-protocol-basic talloc''',
1062 install_path
='${CTDB_TEST_LIBEXECDIR}')
1064 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
1065 source
=bld
.SUBDIR('tests/src',
1077 bld
.SAMBA_SUBSYSTEM('ctdb-tests-backtrace',
1078 source
=bld
.SUBDIR('tests/src',
1079 'test_backtrace.c'),
1091 'fetch_readonly_loop',
1094 'update_record_persistent',
1101 for target
in ctdb_tests
:
1102 src
= 'tests/src/' + target
+ '.c'
1104 bld
.SAMBA_BINARY(target
,
1107 deps
='''ctdb-client ctdb-protocol ctdb-util
1108 samba-util ctdb-tests-common''',
1109 install_path
='${CTDB_TEST_LIBEXECDIR}')
1111 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1112 source
='''tests/src/ctdb_takeover_tests.c
1113 tests/src/ipalloc_read_known_ips.c''',
1114 deps
='''replace popt tdb tevent talloc ctdb-system
1115 samba-util tdb-wrap talloc_report
1116 ctdb-ipalloc ctdb-protocol ctdb-util''',
1118 install_path
='${CTDB_TEST_LIBEXECDIR}')
1120 bld
.SAMBA_BINARY('fake_ctdbd',
1121 source
='''tests/src/fake_ctdbd.c
1122 tests/src/ipalloc_read_known_ips.c''',
1123 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
1124 ctdb-system samba-util tevent-util
1125 LIBASYNC_REQ popt''',
1126 install_path
='${CTDB_TEST_LIBEXECDIR}')
1128 bld
.SAMBA_BINARY('cluster_mutex_test',
1129 source
='tests/src/cluster_mutex_test.c',
1130 deps
='''ctdb-tests-backtrace
1135 install_path
='${CTDB_TEST_LIBEXECDIR}')
1137 if bld
.env
.HAVE_INFINIBAND
:
1138 bld
.SAMBA_BINARY('ibwrapper_test',
1139 source
='ib/ibwrapper_test.c',
1141 deps
='replace talloc ctdb-common sys_rw' +
1143 install_path
='${CTDB_TEST_LIBEXECDIR}')
1145 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux') and bld
.env
.DEVELOPER
:
1146 bld
.SAMBA_BINARY('test_mutex_raw',
1147 source
='tests/src/test_mutex_raw.c',
1149 install_path
='${CTDB_TEST_LIBEXECDIR}')
1158 if bld
.env
.standalone_ctdb
:
1161 testdir
= 'ctdb/tests'
1163 for t
in test_subdirs
:
1164 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
1166 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
1167 destname
=fmode
[0], chmod
=fmode
[1])
1169 # Install tests/scripts directory, excluding files that need munging
1174 'integration_local_daemons.bash',
1175 'integration_real_cluster.bash',
1179 for t
in test_scripts
:
1180 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1181 os
.path
.join('tests/scripts', t
),
1182 destname
=os
.path
.join('scripts', t
))
1184 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1185 'tests/scripts/test_wrap',
1186 destname
='scripts/test_wrap',
1189 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1190 source
='tests/scripts/script_install_paths.sh',
1191 target
='script_install_paths.sh',
1192 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1193 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1194 'script_install_paths.sh',
1195 destname
='script_install_paths.sh', chmod
=MODE_644
)
1197 sed_expr1
= 's@^\\(%s\\)=.*@\\1=%s@' % (
1198 'CTDB_TEST_DIR', bld
.env
.CTDB_TEST_DATADIR
)
1199 sed_expr2
= 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1200 bld
.SAMBA_GENERATOR('ctdb-test-runner',
1201 source
='tests/run_tests.sh',
1202 target
='ctdb_run_tests.sh',
1203 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1204 sed_expr1
, sed_expr2
))
1205 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1206 destname
='ctdb_run_tests', chmod
=MODE_755
)
1207 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
1210 bld
.SAMBA_GENERATOR('ctdb-local-daemons',
1211 source
='tests/local_daemons.sh',
1212 target
='ctdb_local_daemons.sh',
1213 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1214 sed_expr1
, sed_expr2
))
1215 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1216 destname
='ctdb_local_daemons', chmod
=MODE_755
)
1220 cmd
= 'tests/run_tests.sh'
1221 ret
= samba_utils
.RUN_COMMAND(cmd
)
1223 print('tests exited with exit status %d' % ret
)
1228 Options
.commands
.append('build')
1229 Options
.commands
.append('testonly')
1233 env
= samba_utils
.LOAD_ENVIRONMENT()
1234 cmd
= 'tests/run_tests.sh -eL -S %s' % env
.SOCKET_WRAPPER_SO_PATH
1235 ret
= samba_utils
.RUN_COMMAND(cmd
)
1237 print('autotest exited with exit status %d' % ret
)
1241 def show_version(ctx
):
1242 print(get_version_string())
1246 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
1247 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
1248 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
1249 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
1250 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1252 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
1253 ret
= samba_utils
.RUN_COMMAND(cmd
)
1255 print('Command %s failed with exit status %d' % (cmd
, ret
))
1258 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
1259 ret
= samba_utils
.RUN_COMMAND(cmd
)
1261 print('Command %s failed with exit status %d' % (cmd
, ret
))
1266 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
1269 sed_expr1
= 's/@VERSION@/%s/g' % get_version_string()
1270 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1271 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1272 sed_expr1
, sed_expr2
, t
)
1273 ret
= samba_utils
.RUN_COMMAND(cmd
)
1275 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1277 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1279 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1281 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1282 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1289 Options
.commands
.append('manpages')
1290 Options
.commands
.append('distonly')
1294 opts
= os
.getenv('RPM_OPTIONS') or ''
1295 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1296 (opts
, get_version_string())
1297 ret
= samba_utils
.RUN_COMMAND(cmd
)
1299 print('rpmbuild exited with exit status %d' % ret
)
1304 Options
.commands
.append('manpages')
1305 Options
.commands
.append('distonly')
1306 Options
.commands
.append('rpmonly')
1310 "build 'tags' file using ctags"
1311 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
1312 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1313 print("Running: %s" % cmd
)
1314 ret
= samba_utils
.RUN_COMMAND(cmd
)
1316 print('ctags failed with exit status %d' % ret
)