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''')
52 'ctdb-script.options.5',
64 'ctdb_mutex_ceph_rados_helper.7',
71 env
= samba_utils
.LOAD_ENVIRONMENT()
73 return samba_version
.samba_version_file('%s/VERSION' % vdir
, vdir
, env
)
75 def get_version_string():
76 if Context
.g_module
.VERSION
:
77 return Context
.g_module
.VERSION
78 version
= get_version()
79 Context
.g_module
.VERSION
= version
.STRING
.replace('-', '.')
80 return Context
.g_module
.VERSION
83 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
85 opt
.RECURSE('lib/replace')
87 opt
.RECURSE('lib/util')
89 opt
.RECURSE('lib/talloc')
90 opt
.RECURSE('lib/tevent')
91 opt
.RECURSE('lib/tdb')
93 opt
.add_option('--enable-infiniband',
94 help=("Turn on infiniband support (default=no)"),
95 action
="store_true", dest
='ctdb_infiniband', default
=False)
96 opt
.add_option('--enable-pmda',
97 help=("Turn on PCP pmda support (default=no)"),
98 action
="store_true", dest
='ctdb_pmda', default
=False)
99 opt
.add_option('--enable-etcd-reclock',
100 help=("Enable etcd recovery lock helper (default=no)"),
101 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
103 opt
.add_option('--with-libcephfs',
104 help=("Directory under which libcephfs is installed"),
105 action
="store", dest
='libcephfs_dir', default
=None)
106 opt
.add_option('--enable-ceph-reclock',
107 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
108 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
110 opt
.add_option('--with-logdir',
111 help=("Path to log directory"),
112 action
="store", dest
='ctdb_logdir', default
=None)
113 opt
.add_option('--with-socketpath',
114 help=("path to CTDB daemon socket"),
115 action
="store", dest
='ctdb_sockpath', default
=None)
119 # No need to build python bindings for talloc/tevent/tdb
120 if conf
.IN_LAUNCH_DIR():
121 conf
.env
.standalone_ctdb
= True
122 Options
.options
.disable_python
= True
124 conf
.RECURSE('lib/replace')
126 conf
.CHECK_HEADERS(headers
='''sys/socket.h
134 conf
.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
135 define
='HAVE_AF_PACKET',
136 headers
='sys/socket.h linux/if_packet.h')
138 conf
.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
139 define
='HAVE_PACKETSOCKET',
140 headers
='sys/socket.h linux/if_packet.h')
142 if conf
.env
.standalone_ctdb
:
143 conf
.SAMBA_CHECK_PERL(mandatory
=True)
145 # This is just for consistency and to check the version for the
146 # build system, see Options.options.disable_python = True above
147 conf
.SAMBA_CHECK_PYTHON()
148 conf
.SAMBA_CHECK_PYTHON_HEADERS()
150 # We just want gnutls_rnd for rand subsystem
151 conf
.CHECK_FUNCS_IN('gnutls_rnd', 'gnutls')
154 if conf
.CHECK_FOR_THIRD_PARTY():
155 conf
.RECURSE('third_party/popt')
156 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
157 conf
.RECURSE('third_party/socket_wrapper')
158 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
160 if not conf
.CHECK_POPT():
161 raise Errors
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
163 conf
.define('USING_SYSTEM_POPT', 1)
164 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
167 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
168 if not conf
.CHECK_SOCKET_WRAPPER():
169 raise Errors
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
171 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
172 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
174 conf
.RECURSE('lib/util')
176 conf
.RECURSE('lib/talloc')
177 conf
.RECURSE('lib/tevent')
178 conf
.RECURSE('lib/tdb')
180 conf
.CHECK_HEADERS('sched.h')
181 conf
.CHECK_HEADERS('procinfo.h')
182 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
183 Logs
.error('Need thread_setsched() on AIX')
185 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
186 Logs
.error('Need sched_setscheduler()')
188 conf
.CHECK_FUNCS('mlockall')
189 conf
.CHECK_FUNCS('getrusage', headers
="sys/time.h sys/resource.h")
191 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
192 conf
.DEFINE('ETIME', 'ETIMEDOUT')
194 if sys
.platform
.startswith('linux'):
195 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
197 if not conf
.CHECK_HEADERS('pcap.h'):
198 Logs
.error('Need libpcap')
200 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
201 Logs
.error('Need libpcap')
204 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
205 checklibc
=True, headers
='execinfo.h'):
206 Logs
.error('backtrace support not available')
209 if Options
.options
.ctdb_pmda
:
212 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
215 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
217 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
220 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
223 Logs
.error("PMDA support not available")
226 Logs
.info('Building with PMDA support')
227 conf
.define('HAVE_PMDA', 1)
228 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
229 'lib/pcp/pmdas/ctdb')
231 have_infiniband
= False
232 if Options
.options
.ctdb_infiniband
:
235 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
237 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
239 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
242 have_infiniband
= True
244 Logs
.error("Infiniband support not available")
247 Logs
.info('Building with Infiniband support')
248 conf
.define('HAVE_INFINIBAND', 1)
249 conf
.define('USE_INFINIBAND', 1)
251 have_etcd_reclock
= False
252 if Options
.options
.ctdb_etcd_reclock
:
254 conf
.check_python_module('etcd')
255 have_etcd_reclock
= True
257 Logs
.error('etcd support not available')
259 if have_etcd_reclock
:
260 Logs
.info('Building with etcd support')
261 conf
.env
.etcd_reclock
= have_etcd_reclock
263 if Options
.options
.libcephfs_dir
:
264 Logs
.error('''--with-libcephfs no longer supported, please use compiler
265 flags instead, e.g. GCC LIBRARY_PATH and C_INCLUDE_PATH''')
268 if Options
.options
.ctdb_ceph_reclock
:
269 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
270 conf
.CHECK_LIB('rados', shlib
=True)):
271 Logs
.info('Building with Ceph librados recovery lock support')
272 conf
.define('HAVE_LIBRADOS', 1)
274 Logs
.error("Missing librados for Ceph recovery lock support")
277 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
278 conf
.env
.CTDB_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'share/ctdb')
279 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
280 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
281 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
282 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
284 if Options
.options
.ctdb_logdir
:
285 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
287 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
289 if Options
.options
.ctdb_sockpath
:
290 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
292 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
294 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
296 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
298 -DCTDB_DATADIR=\"%s\"
301 -DCTDB_RUNDIR=\"%s\"''' % (
302 conf
.env
.CTDB_HELPER_BINDIR
,
303 conf
.env
.CTDB_LOGDIR
,
304 conf
.env
.CTDB_DATADIR
,
305 conf
.env
.CTDB_ETCDIR
,
306 conf
.env
.CTDB_VARDIR
,
307 conf
.env
.CTDB_RUNDIR
))
309 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.CTDB_DATADIR
, 'tests')
310 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
312 # Allow unified compilation and separate compilation of utilities
314 if not conf
.env
.standalone_ctdb
:
315 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
317 if Context
.g_module
.top
== '.':
318 # Building from tarball
319 conf
.ADD_EXTRA_INCLUDES('#include')
321 # Building standalone CTDB from within Samba tree
322 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
323 conf
.ADD_EXTRA_INCLUDES('#ctdb')
324 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
326 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
327 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
328 conf
.SAMBA_CONFIG_H()
330 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
331 conf
.env
.ctdb_generate_manpages
= True
333 conf
.env
.ctdb_generate_manpages
= False
335 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
336 conf
.env
.ctdb_prebuilt_manpages
= []
337 manpages
= manpages_binary
+ manpages_misc
338 if conf
.env
.etcd_reclock
:
339 manpages
+= manpages_etcd
340 if conf
.env
.HAVE_LIBRADOS
:
341 manpages
+= manpages_ceph
343 if os
.path
.exists(os
.path
.join("doc", m
)):
344 Logs
.info(" %s: yes" % (m
))
345 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
347 Logs
.info(" %s: no" % (m
))
350 if bld
.env
.standalone_ctdb
:
351 # enable building of public headers in the build tree
352 bld
.env
.build_public_headers
= 'include/public'
354 if bld
.env
.standalone_ctdb
:
355 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
357 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
359 bld
.RECURSE('lib/replace')
360 if bld
.CHECK_FOR_THIRD_PARTY():
361 bld
.RECURSE('third_party/popt')
362 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
363 bld
.RECURSE('third_party/socket_wrapper')
365 bld
.RECURSE('lib/tdb_wrap')
366 bld
.RECURSE('lib/util')
367 bld
.RECURSE('lib/async_req')
368 bld
.RECURSE('lib/pthreadpool')
369 bld
.RECURSE('lib/messaging')
371 bld
.RECURSE('lib/talloc')
372 bld
.RECURSE('lib/tevent')
373 bld
.RECURSE('lib/tdb')
375 if bld
.env
.standalone_ctdb
:
376 # If a combined build is implemented, CTDB will want to
377 # build against samba-util rather than samba-util-core.
378 # Similarly, other Samba subsystems expect samba-util. So,
379 # for a standalone build, just define a fake samba-util
380 # subsystem that pulls in samba-util-core.
381 bld
.SAMBA_SUBSYSTEM('samba-util',
383 deps
='samba-util-core')
385 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
386 source
=bld
.SUBDIR('tcp',
387 'tcp_connect.c tcp_init.c tcp_io.c'),
389 deps
='replace tdb talloc tevent')
392 if bld
.env
.HAVE_INFINIBAND
:
393 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
394 source
=bld
.SUBDIR('ib',
395 '''ibwrapper.c ibw_ctdb.c
398 deps
='replace talloc tevent tdb')
399 ib_deps
= ' ctdb-ib rdmacm ibverbs'
401 bld
.SAMBA_SUBSYSTEM('ctdb-system',
402 source
=bld
.SUBDIR('common',
403 'system_socket.c system.c'),
405 deps
='replace talloc tevent tdb pcap samba-util')
407 bld
.SAMBA_SUBSYSTEM('ctdb-common',
408 source
=bld
.SUBDIR('common',
409 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
412 deps
='''replace popt talloc tevent tdb popt ctdb-system
413 ctdb-protocol-util''')
415 bld
.SAMBA_SUBSYSTEM('ctdb-util',
416 source
=bld
.SUBDIR('common',
417 '''db_hash.c srvid.c reqid.c
418 pkt_read.c pkt_write.c comm.c
419 logging.c rb_tree.c tunable.c
422 run_event.c event_script.c
424 cmdline.c path.c conf.c line.c
426 deps
='''samba-util sys_rw tevent-util
427 replace talloc tevent tdb popt''')
429 bld
.SAMBA_SUBSYSTEM('ctdb-logging-conf',
430 source
='common/logging_conf.c',
431 deps
='ctdb-util talloc')
433 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
434 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
437 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
438 source
=bld
.SUBDIR('protocol',
439 '''protocol_header.c protocol_packet.c
450 deps
='ctdb-protocol-basic replace talloc tdb')
452 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
453 source
='protocol/protocol_util.c',
454 deps
='ctdb-util replace talloc tdb')
456 bld
.SAMBA_SUBSYSTEM('ctdb-client',
457 source
=bld
.SUBDIR('client',
458 '''client_connect.c client_call.c
459 client_message.c client_control.c
460 client_message_sync.c
461 client_control_sync.c
462 client_db.c client_util.c
466 deps
='replace talloc tevent tdb tdb-wrap')
468 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
469 source
=bld
.SUBDIR('common',
470 '''sock_daemon.c'''),
471 deps
='''samba-util ctdb-util ctdb-system tevent-util
472 LIBASYNC_REQ replace talloc tevent''')
474 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
475 source
=bld
.SUBDIR('server',
476 '''ipalloc_deterministic.c
477 ipalloc_nondeterministic.c
483 deps
='ctdb-protocol-util replace talloc tevent')
485 bld
.SAMBA_BINARY('ctdb-path',
486 source
='common/path_tool.c',
487 cflags
='-DCTDB_PATH_TOOL',
488 deps
='''ctdb-util samba-util talloc replace popt''',
489 install_path
='${CTDB_HELPER_BINDIR}')
491 bld
.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
492 source
='cluster/cluster_conf.c',
495 bld
.SAMBA_SUBSYSTEM('ctdb-database-conf',
496 source
='database/database_conf.c',
499 bld
.SAMBA_SUBSYSTEM('ctdb-event-conf',
500 source
='event/event_conf.c',
503 bld
.SAMBA_SUBSYSTEM('ctdb-failover-conf',
504 source
='failover/failover_conf.c',
507 bld
.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
508 source
='server/legacy_conf.c',
511 bld
.SAMBA_BINARY('ctdb-config',
512 source
='common/conf_tool.c',
513 cflags
='-DCTDB_CONF_TOOL',
514 deps
='''ctdb-logging-conf
520 ctdb-util samba-util talloc replace popt''',
521 install_path
='${CTDB_HELPER_BINDIR}')
523 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
524 source
=bld
.SUBDIR('event',
526 event_protocol_util.c
528 deps
='ctdb-protocol-basic')
530 bld
.SAMBA_LIBRARY('ctdb-event-client',
531 source
='event/event_client.c',
532 deps
='ctdb-event-protocol ctdb-util tevent talloc',
533 private_library
=True)
535 bld
.SAMBA_BINARY('ctdb-eventd',
536 source
=bld
.SUBDIR('event',
543 deps
='''ctdb-event-protocol
544 ctdb-event-conf ctdb-logging-conf
545 ctdb-server-util samba-util ctdb-util
546 talloc tevent replace popt''',
547 install_path
='${CTDB_HELPER_BINDIR}')
549 bld
.SAMBA_BINARY('ctdb-event',
550 source
='event/event_tool.c',
551 cflags
='-DCTDB_EVENT_TOOL',
552 deps
='''ctdb-event-client ctdb-event-protocol
553 ctdb-util samba-util talloc replace''',
554 install_path
='${CTDB_HELPER_BINDIR}')
556 bld
.SAMBA_BINARY('ctdbd',
557 source
='server/ctdbd.c ' +
559 '''ctdb_daemon.c ctdb_recoverd.c
560 ctdb_recover.c ctdb_freeze.c
561 ctdb_tunables.c ctdb_monitor.c
562 ctdb_server.c ctdb_control.c
563 ctdb_call.c ctdb_ltdb_server.c
564 ctdb_traverse.c eventscript.c
566 ctdb_persistent.c ctdb_keepalive.c
570 ctdb_vacuum.c ctdb_banning.c
573 ctdb_lock.c ctdb_fork.c
574 ctdb_tunnel.c ctdb_client.c
578 deps
='''ctdb-common ctdb-system ctdb-protocol
579 ctdb-tcp ctdb-util replace sys_rw popt
587 talloc tevent tdb-wrap tdb talloc_report''' +
589 install_path
='${SBINDIR}',
592 bld
.SAMBA_BINARY('ctdb',
593 source
='tools/ctdb.c',
594 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
595 ctdb-util ctdb-system samba-util sys_rw popt''',
596 install_path
='${BINDIR}',
599 bld
.SAMBA_BINARY('ctdb_killtcp',
600 source
='tools/ctdb_killtcp.c',
601 deps
='''ctdb-protocol-util ctdb-util ctdb-system
602 samba-util replace''',
603 install_path
='${CTDB_HELPER_BINDIR}')
605 bld
.SAMBA_BINARY('ltdbtool',
606 source
='tools/ltdbtool.c',
609 install_path
='${BINDIR}',
610 manpages
='ltdbtool.1')
612 bld
.SAMBA_BINARY('ctdb_lock_helper',
613 source
='server/ctdb_lock_helper.c',
614 deps
='''samba-util sys_rw ctdb-system tevent-util
615 talloc tevent tdb''',
617 install_path
='${CTDB_HELPER_BINDIR}')
619 bld
.SAMBA_BINARY('ctdb_recovery_helper',
620 source
='server/ctdb_recovery_helper.c',
621 deps
='''ctdb-client ctdb-protocol ctdb-util
622 samba-util sys_rw replace tdb''',
623 install_path
='${CTDB_HELPER_BINDIR}')
625 bld
.SAMBA_BINARY('ctdb_takeover_helper',
626 source
='server/ctdb_takeover_helper.c',
627 deps
='''ctdb-client ctdb-protocol ctdb-util
628 samba-util sys_rw replace ctdb-ipalloc popt''',
629 install_path
='${CTDB_HELPER_BINDIR}')
631 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
632 source
='server/ctdb_mutex_fcntl_helper.c',
633 deps
='''sys_rw ctdb-system tevent-util
637 install_path
='${CTDB_HELPER_BINDIR}')
639 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
640 source
='utils/smnotify/smnotify.x',
641 target
='utils/smnotify/smnotify.h',
642 rule
='rpcgen -h ${SRC} > ${TGT}')
644 xdr_buf_hack
= 'grep -Fv "register int32_t *buf;"'
646 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
647 source
='utils/smnotify/smnotify.x',
648 target
='utils/smnotify/gen_xdr.c',
649 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
651 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
652 source
='utils/smnotify/smnotify.x',
653 target
='utils/smnotify/gen_smnotify.c',
654 rule
='rpcgen -l ${SRC} > ${TGT}')
656 bld
.SAMBA_BINARY('smnotify',
657 source
=bld
.SUBDIR('utils/smnotify',
658 'smnotify.c gen_smnotify.c gen_xdr.c'),
659 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
660 includes
='utils utils/smnotify',
661 install_path
='${CTDB_HELPER_BINDIR}')
663 bld
.SAMBA_BINARY('ping_pong',
664 source
='utils/ping_pong/ping_pong.c',
666 install_path
='${BINDIR}',
667 manpages
='ping_pong.1')
669 if bld
.env
.HAVE_PMDA
:
670 bld
.SAMBA_BINARY('pmdactdb',
671 source
='utils/pmda/pmda_ctdb.c',
673 deps
='''ctdb-client ctdb-protocol ctdb-util
674 samba-util pcp_pmda pcp''',
675 install_path
='${CTDB_PMDADIR}')
676 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
678 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
680 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
682 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
684 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
686 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
689 if bld
.env
.HAVE_LIBRADOS
:
690 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
691 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
692 deps
='talloc tevent rados',
694 install_path
='${CTDB_HELPER_BINDIR}')
696 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
697 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
698 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
699 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
700 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
701 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
702 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
703 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
704 sed_cmdline
= '-e "%s" ' * 8 % \
705 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
706 sed_expr6
, sed_expr7
, sed_expr8
)
708 manpages_extra
= list(manpages_misc
)
709 if bld
.env
.etcd_reclock
:
710 manpages_extra
+= manpages_etcd
711 if bld
.env
.HAVE_LIBRADOS
:
712 manpages_extra
+= manpages_ceph
713 for f
in manpages_binary
+ manpages_extra
:
715 bld
.SAMBA_GENERATOR(x
,
716 source
=os
.path
.join('doc', x
),
718 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
720 if bld
.env
.ctdb_generate_manpages
:
721 bld
.MANPAGES(' '.join(manpages_extra
), True)
723 for m
in bld
.env
.ctdb_prebuilt_manpages
:
724 bld
.SAMBA_GENERATOR(m
,
725 source
=os
.path
.join("doc", m
),
727 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
728 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
730 bld
.SAMBA_GENERATOR('ctdb-onnode',
731 source
='tools/onnode',
733 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
734 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
735 destname
='onnode', chmod
=MODE_755
)
737 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
738 source
='tools/ctdb_diagnostics',
739 target
='ctdb_diagnostics',
740 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
741 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
742 destname
='ctdb_diagnostics', chmod
=MODE_755
)
744 if bld
.env
.etcd_reclock
:
745 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
746 source
='utils/etcd/ctdb_etcd_lock',
747 target
='ctdb_etcd_lock',
748 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
749 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
750 destname
='ctdb_etcd_lock', chmod
=MODE_744
)
752 bld
.SAMBA_GENERATOR('ctdb-natgw',
753 source
='tools/ctdb_natgw',
755 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
756 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
757 destname
='ctdb_natgw', chmod
=MODE_755
)
759 bld
.SAMBA_GENERATOR('ctdb-lvs',
760 source
='tools/ctdb_lvs',
762 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
763 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
764 destname
='ctdb_lvs', chmod
=MODE_755
)
766 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
767 source
='config/ctdbd_wrapper',
768 target
='ctdbd_wrapper',
769 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
770 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
771 destname
='ctdbd_wrapper', chmod
=MODE_755
)
773 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
775 fl
= os
.path
.join(dirname
, f
)
776 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
778 mode
= os
.lstat(fl
).st_mode
& MODE_777
780 fl
= samba_utils
.os
.path
.relpath(fl
, arg
['trim_path'])
781 arg
['file_list'].append([fl
, mode
])
783 def SUBDIR_MODE(path
, trim_path
=None):
784 pd
= {'trim_path': trim_path
, 'file_list': []}
785 for dirname
, _subdirs
, fnames
in os
.walk(path
):
786 SUBDIR_MODE_callback(pd
, dirname
, fnames
)
787 return pd
['file_list']
789 event_script_subdirs
= [
797 if bld
.env
.standalone_ctdb
:
800 configdir
= 'ctdb/config'
802 for t
in event_script_subdirs
:
803 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
804 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
806 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
807 destname
=fmode
[0], chmod
=fmode
[1])
809 for t
in etc_subdirs
:
810 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
812 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
813 destname
=fmode
[0], chmod
=fmode
[1])
815 # If this is a direct install and there are no event scripts
816 # linked/enabled then enable some standard ones
817 if os
.environ
.get('DESTDIR') is None:
818 fmt
= 'events/legacy/%s.script'
819 required_script
= '00.ctdb'
820 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
821 fmt
% (required_script
))
822 if not os
.path
.islink(required_path
) and \
823 not os
.path
.exists(required_path
):
824 default_scripts
= [ required_script
,
829 for t
in default_scripts
:
830 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
831 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
832 bld
.symlink_as(name
, tgt
)
834 bld
.SAMBA_GENERATOR('ctdb-functions',
835 source
='config/functions',
837 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
838 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
841 'ctdb-crash-cleanup.sh',
842 'debug-hung-script.sh',
844 'nfs-linux-kernel-callout',
849 for t
in etc_scripts
:
850 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
851 destname
=t
, chmod
=MODE_755
)
853 bld
.SAMBA_GENERATOR('ctdb-sudoers',
854 source
='config/ctdb.sudoers',
855 target
='ctdb.sudoers',
856 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
857 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
860 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
861 'config/notification.README',
864 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
865 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
866 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
868 for d
in ['volatile', 'persistent', 'state']:
869 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
872 # Test-only below this point
875 if not bld
.env
.standalone_ctdb
and not bld
.CONFIG_GET('ENABLE_SELFTEST'):
878 bld
.SAMBA_BINARY('errcode',
879 source
='tests/src/errcode.c',
881 install_path
='${CTDB_TEST_LIBEXECDIR}')
883 bld
.SAMBA_BINARY('sigcode',
884 source
='tests/src/sigcode.c',
886 install_path
='${CTDB_TEST_LIBEXECDIR}')
908 for target
in ctdb_unit_tests
:
909 src
= 'tests/src/' + target
+ '.c'
911 bld
.SAMBA_BINARY(target
,
913 deps
='''talloc tevent tdb tevent-util popt
914 LIBASYNC_REQ samba-util sys_rw''',
915 install_path
='${CTDB_TEST_LIBEXECDIR}')
917 bld
.SAMBA_BINARY('reqid_test',
918 source
='tests/src/reqid_test.c',
920 install_path
='${CTDB_TEST_LIBEXECDIR}')
922 bld
.SAMBA_BINARY('rb_test',
923 source
='tests/src/rb_test.c',
924 deps
='samba-util talloc',
925 install_path
='${CTDB_TEST_LIBEXECDIR}')
927 bld
.SAMBA_BINARY('ctdb_packet_parse',
928 source
='tests/src/ctdb_packet_parse.c',
929 deps
='talloc tevent tdb ctdb-protocol',
930 install_path
='${CTDB_TEST_LIBEXECDIR}')
932 bld
.SAMBA_BINARY('system_socket_test',
933 source
='tests/src/system_socket_test.c',
934 deps
='talloc ctdb-protocol-util pcap',
935 install_path
='${CTDB_TEST_LIBEXECDIR}')
937 bld
.SAMBA_BINARY('porting_tests',
938 source
='tests/src/porting_tests.c',
939 deps
='samba-util ctdb-system popt',
940 install_path
='${CTDB_TEST_LIBEXECDIR}')
942 bld
.SAMBA_BINARY('sock_daemon_test',
943 source
='tests/src/sock_daemon_test.c',
944 deps
='''ctdb-system talloc tevent tevent-util
945 LIBASYNC_REQ samba-util sys_rw''',
946 install_path
='${CTDB_TEST_LIBEXECDIR}')
948 bld
.SAMBA_BINARY('ctdb_io_test',
949 source
='tests/src/ctdb_io_test.c',
950 deps
='''talloc tevent tdb samba-util sys_rw''',
951 install_path
='${CTDB_TEST_LIBEXECDIR}')
953 bld
.SAMBA_BINARY('ctdb-db-test',
954 source
='tests/src/db_test_tool.c',
955 cflags
='-DCTDB_DB_TEST_TOOL',
956 deps
='''ctdb-client ctdb-protocol
957 ctdb-util samba-util talloc tevent replace''',
958 install_path
='${CTDB_TEST_LIBEXECDIR}')
960 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
961 source
=bld
.SUBDIR('tests/src',
962 'protocol_common_basic.c'),
963 deps
='replace talloc')
965 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
966 source
=bld
.SUBDIR('tests/src',
968 protocol_common_ctdb.c
971 deps
='ctdb-protocol-tests-basic replace talloc tdb')
973 bld
.SAMBA_BINARY('protocol_basic_test',
974 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
975 deps
='ctdb-protocol-tests-basic talloc',
976 install_path
='${CTDB_TEST_LIBEXECDIR}')
978 ctdb_protocol_tests
= [
979 'protocol_types_test',
980 'protocol_ctdb_test',
981 'protocol_util_test',
982 'protocol_types_compat_test',
983 'protocol_ctdb_compat_test',
986 for target
in ctdb_protocol_tests
:
987 src
= 'tests/src/' + target
+ '.c'
989 bld
.SAMBA_BINARY(target
,
991 deps
='''ctdb-protocol-tests-common
992 samba-util ctdb-util talloc tdb''',
993 install_path
='${CTDB_TEST_LIBEXECDIR}')
995 bld
.SAMBA_BINARY('event_protocol_test',
996 source
='event/event_protocol_test.c',
997 deps
='''ctdb-protocol-tests-basic
998 ctdb-protocol-basic talloc''',
999 install_path
='${CTDB_TEST_LIBEXECDIR}')
1001 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
1002 source
=bld
.SUBDIR('tests/src',
1003 'cluster_wait.c test_options.c'),
1005 deps
='samba-util replace popt talloc tevent tdb')
1015 'fetch_readonly_loop',
1018 'update_record_persistent',
1025 for target
in ctdb_tests
:
1026 src
= 'tests/src/' + target
+ '.c'
1028 bld
.SAMBA_BINARY(target
,
1031 deps
='''ctdb-client ctdb-protocol ctdb-util
1032 samba-util ctdb-tests-common''',
1033 install_path
='${CTDB_TEST_LIBEXECDIR}')
1035 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1036 source
='''tests/src/ctdb_takeover_tests.c
1037 tests/src/ipalloc_read_known_ips.c''',
1038 deps
='''replace popt tdb tevent talloc ctdb-system
1039 samba-util tdb-wrap talloc_report
1040 ctdb-ipalloc ctdb-protocol ctdb-util''',
1042 install_path
='${CTDB_TEST_LIBEXECDIR}')
1044 bld
.SAMBA_BINARY('fake_ctdbd',
1045 source
='''tests/src/fake_ctdbd.c
1046 tests/src/ipalloc_read_known_ips.c''',
1047 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
1048 ctdb-system samba-util tevent-util
1049 LIBASYNC_REQ popt''',
1050 install_path
='${CTDB_TEST_LIBEXECDIR}')
1052 bld
.SAMBA_BINARY('cluster_mutex_test',
1053 source
='tests/src/cluster_mutex_test.c',
1054 deps
='samba-util talloc tevent',
1055 install_path
='${CTDB_TEST_LIBEXECDIR}')
1057 if bld
.env
.HAVE_INFINIBAND
:
1058 bld
.SAMBA_BINARY('ibwrapper_test',
1059 source
='ib/ibwrapper_test.c',
1061 deps
='replace talloc ctdb-common sys_rw' +
1063 install_path
='${CTDB_TEST_LIBEXECDIR}')
1065 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux') and bld
.env
.DEVELOPER
:
1066 bld
.SAMBA_BINARY('test_mutex_raw',
1067 source
='tests/src/test_mutex_raw.c',
1069 install_path
='${CTDB_TEST_LIBEXECDIR}')
1078 if bld
.env
.standalone_ctdb
:
1081 testdir
= 'ctdb/tests'
1083 for t
in test_subdirs
:
1084 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
1086 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
1087 destname
=fmode
[0], chmod
=fmode
[1])
1089 # Install tests/scripts directory, excluding files that need munging
1094 'integration_local_daemons.bash',
1095 'integration_real_cluster.bash',
1099 for t
in test_scripts
:
1100 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1101 os
.path
.join('tests/scripts', t
),
1102 destname
=os
.path
.join('scripts', t
))
1104 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1105 'tests/scripts/test_wrap',
1106 destname
='scripts/test_wrap',
1109 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1110 source
='tests/scripts/script_install_paths.sh',
1111 target
='script_install_paths.sh',
1112 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1113 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1114 'script_install_paths.sh',
1115 destname
='script_install_paths.sh', chmod
=MODE_644
)
1117 sed_expr1
= 's@^\\(%s\\)=.*@\\1=%s@' % (
1118 'CTDB_TEST_DIR', bld
.env
.CTDB_TEST_DATADIR
)
1119 sed_expr2
= 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1120 bld
.SAMBA_GENERATOR('ctdb-test-runner',
1121 source
='tests/run_tests.sh',
1122 target
='ctdb_run_tests.sh',
1123 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1124 sed_expr1
, sed_expr2
))
1125 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1126 destname
='ctdb_run_tests', chmod
=MODE_755
)
1127 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
1130 bld
.SAMBA_GENERATOR('ctdb-local-daemons',
1131 source
='tests/local_daemons.sh',
1132 target
='ctdb_local_daemons.sh',
1133 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1134 sed_expr1
, sed_expr2
))
1135 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1136 destname
='ctdb_local_daemons', chmod
=MODE_755
)
1140 cmd
= 'tests/run_tests.sh'
1141 ret
= samba_utils
.RUN_COMMAND(cmd
)
1143 print('tests exited with exit status %d' % ret
)
1148 Options
.commands
.append('build')
1149 Options
.commands
.append('testonly')
1153 env
= samba_utils
.LOAD_ENVIRONMENT()
1154 cmd
= 'tests/run_tests.sh -eL -S %s' % env
.SOCKET_WRAPPER_SO_PATH
1155 ret
= samba_utils
.RUN_COMMAND(cmd
)
1157 print('autotest exited with exit status %d' % ret
)
1161 def show_version(ctx
):
1162 print(get_version_string())
1166 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
1167 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
1168 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
1169 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
1170 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1172 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
1173 ret
= samba_utils
.RUN_COMMAND(cmd
)
1175 print('Command %s failed with exit status %d' % (cmd
, ret
))
1178 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
1179 ret
= samba_utils
.RUN_COMMAND(cmd
)
1181 print('Command %s failed with exit status %d' % (cmd
, ret
))
1186 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
1189 sed_expr1
= 's/@VERSION@/%s/g' % get_version_string()
1190 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1191 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1192 sed_expr1
, sed_expr2
, t
)
1193 ret
= samba_utils
.RUN_COMMAND(cmd
)
1195 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1197 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1199 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1201 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1202 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1209 Options
.commands
.append('manpages')
1210 Options
.commands
.append('distonly')
1214 opts
= os
.getenv('RPM_OPTIONS') or ''
1215 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1216 (opts
, get_version_string())
1217 ret
= samba_utils
.RUN_COMMAND(cmd
)
1219 print('rpmbuild exited with exit status %d' % ret
)
1224 Options
.commands
.append('manpages')
1225 Options
.commands
.append('distonly')
1226 Options
.commands
.append('rpmonly')
1230 "build 'tags' file using ctags"
1231 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
1232 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1233 print("Running: %s" % cmd
)
1234 ret
= samba_utils
.RUN_COMMAND(cmd
)
1236 print('ctags failed with exit status %d' % ret
)