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 buildtools:buildtools third_party/waf:third_party/waf''')
50 'ctdb-script.options.5',
62 'ctdb_mutex_ceph_rados_helper.7',
69 env
= samba_utils
.LOAD_ENVIRONMENT()
71 return samba_version
.samba_version_file('%s/VERSION' % vdir
, vdir
, env
)
73 def get_version_string():
74 if Context
.g_module
.VERSION
:
75 return Context
.g_module
.VERSION
76 version
= get_version()
77 Context
.g_module
.VERSION
= version
.STRING
.replace('-', '.')
78 return Context
.g_module
.VERSION
81 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
83 opt
.RECURSE('lib/replace')
85 opt
.RECURSE('lib/util')
87 opt
.RECURSE('lib/talloc')
88 opt
.RECURSE('lib/tevent')
89 opt
.RECURSE('lib/tdb')
91 opt
.add_option('--enable-infiniband',
92 help=("Turn on infiniband support (default=no)"),
93 action
="store_true", dest
='ctdb_infiniband', default
=False)
94 opt
.add_option('--enable-pmda',
95 help=("Turn on PCP pmda support (default=no)"),
96 action
="store_true", dest
='ctdb_pmda', default
=False)
97 opt
.add_option('--enable-etcd-reclock',
98 help=("Enable etcd recovery lock helper (default=no)"),
99 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
101 opt
.add_option('--with-libcephfs',
102 help=("Directory under which libcephfs is installed"),
103 action
="store", dest
='libcephfs_dir', default
=None)
104 opt
.add_option('--enable-ceph-reclock',
105 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
106 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
108 opt
.add_option('--with-logdir',
109 help=("Path to log directory"),
110 action
="store", dest
='ctdb_logdir', default
=None)
111 opt
.add_option('--with-socketpath',
112 help=("path to CTDB daemon socket"),
113 action
="store", dest
='ctdb_sockpath', default
=None)
117 # No need to build python bindings for talloc/tevent/tdb
118 if conf
.IN_LAUNCH_DIR():
119 conf
.env
.standalone_ctdb
= True
120 Options
.options
.disable_python
= True
122 conf
.RECURSE('lib/replace')
124 conf
.CHECK_HEADERS(headers
='''sys/socket.h
132 conf
.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
133 define
='HAVE_AF_PACKET',
134 headers
='sys/socket.h linux/if_packet.h')
136 conf
.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
137 define
='HAVE_PACKETSOCKET',
138 headers
='sys/socket.h linux/if_packet.h')
140 if conf
.env
.standalone_ctdb
:
141 conf
.SAMBA_CHECK_PERL(mandatory
=True)
143 # This is just for consistency and to check the version for the
144 # build system, see Options.options.disable_python = True above
145 conf
.SAMBA_CHECK_PYTHON()
146 conf
.SAMBA_CHECK_PYTHON_HEADERS()
148 if conf
.CHECK_FOR_THIRD_PARTY():
149 conf
.RECURSE('third_party/popt')
150 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
151 conf
.RECURSE('third_party/socket_wrapper')
152 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
154 if not conf
.CHECK_POPT():
155 raise Errors
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
157 conf
.define('USING_SYSTEM_POPT', 1)
158 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
161 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
162 if not conf
.CHECK_SOCKET_WRAPPER():
163 raise Errors
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
165 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
166 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
168 conf
.RECURSE('lib/util')
170 conf
.RECURSE('lib/talloc')
171 conf
.RECURSE('lib/tevent')
172 conf
.RECURSE('lib/tdb')
174 conf
.CHECK_HEADERS('sched.h')
175 conf
.CHECK_HEADERS('procinfo.h')
176 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
177 Logs
.error('Need thread_setsched() on AIX')
179 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
180 Logs
.error('Need sched_setscheduler()')
182 conf
.CHECK_FUNCS('mlockall')
183 conf
.CHECK_FUNCS('getrusage', headers
="sys/time.h sys/resource.h")
185 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
186 conf
.DEFINE('ETIME', 'ETIMEDOUT')
188 if sys
.platform
.startswith('linux'):
189 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
191 if not conf
.CHECK_HEADERS('pcap.h'):
192 Logs
.error('Need libpcap')
194 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
195 Logs
.error('Need libpcap')
198 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
199 checklibc
=True, headers
='execinfo.h'):
200 Logs
.error('backtrace support not available')
203 if Options
.options
.ctdb_pmda
:
206 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
209 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
211 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
214 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
217 Logs
.error("PMDA support not available")
220 Logs
.info('Building with PMDA support')
221 conf
.define('HAVE_PMDA', 1)
222 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
223 'lib/pcp/pmdas/ctdb')
225 have_infiniband
= False
226 if Options
.options
.ctdb_infiniband
:
229 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
231 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
233 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
236 have_infiniband
= True
238 Logs
.error("Infiniband support not available")
241 Logs
.info('Building with Infiniband support')
242 conf
.define('HAVE_INFINIBAND', 1)
243 conf
.define('USE_INFINIBAND', 1)
245 have_etcd_reclock
= False
246 if Options
.options
.ctdb_etcd_reclock
:
248 conf
.check_python_module('etcd')
249 have_etcd_reclock
= True
251 Logs
.error('etcd support not available')
253 if have_etcd_reclock
:
254 Logs
.info('Building with etcd support')
255 conf
.env
.etcd_reclock
= have_etcd_reclock
257 if Options
.options
.ctdb_ceph_reclock
:
258 # Use custom libcephfs library path if provided. XXX The top level build
259 # explicitly sets LIBPATH_CEPH-COMMON when libcephfs_dir isn't provided.
260 if Options
.options
.libcephfs_dir
:
261 conf
.env
['CPPPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/include'
262 conf
.env
['LIBPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/lib'
263 conf
.env
['LIBPATH_CEPH-COMMON'] = conf
.env
['LIBPATH_RADOS'] + '/ceph'
265 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
266 conf
.CHECK_LIB('rados', shlib
=True)):
267 conf
.CHECK_LIB('ceph-common', shlib
=True)
268 Logs
.info('Building with Ceph librados recovery lock support')
269 conf
.define('HAVE_LIBRADOS', 1)
271 Logs
.error("Missing librados for Ceph recovery lock support")
274 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
275 conf
.env
.CTDB_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'share/ctdb')
276 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
277 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
278 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
279 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
281 if Options
.options
.ctdb_logdir
:
282 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
284 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
286 if Options
.options
.ctdb_sockpath
:
287 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
289 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
291 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
293 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
295 -DCTDB_DATADIR=\"%s\"
298 -DCTDB_RUNDIR=\"%s\"''' % (
299 conf
.env
.CTDB_HELPER_BINDIR
,
300 conf
.env
.CTDB_LOGDIR
,
301 conf
.env
.CTDB_DATADIR
,
302 conf
.env
.CTDB_ETCDIR
,
303 conf
.env
.CTDB_VARDIR
,
304 conf
.env
.CTDB_RUNDIR
))
306 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.CTDB_DATADIR
, 'tests')
307 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
309 # Allow unified compilation and separate compilation of utilities
311 if not conf
.env
.standalone_ctdb
:
312 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
314 if Context
.g_module
.top
== '.':
315 # Building from tarball
316 conf
.ADD_EXTRA_INCLUDES('#include')
318 # Building standalone CTDB from within Samba tree
319 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
320 conf
.ADD_EXTRA_INCLUDES('#ctdb')
321 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
323 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
324 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
325 conf
.SAMBA_CONFIG_H()
327 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
328 conf
.env
.ctdb_generate_manpages
= True
330 conf
.env
.ctdb_generate_manpages
= False
332 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
333 conf
.env
.ctdb_prebuilt_manpages
= []
334 manpages
= manpages_binary
+ manpages_misc
335 if conf
.env
.etcd_reclock
:
336 manpages
+= manpages_etcd
337 if conf
.env
.HAVE_LIBRADOS
:
338 manpages
+= manpages_ceph
340 if os
.path
.exists(os
.path
.join("doc", m
)):
341 Logs
.info(" %s: yes" % (m
))
342 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
344 Logs
.info(" %s: no" % (m
))
347 if bld
.env
.standalone_ctdb
:
348 # enable building of public headers in the build tree
349 bld
.env
.build_public_headers
= 'include/public'
351 if bld
.env
.standalone_ctdb
:
352 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
354 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
356 bld
.RECURSE('lib/replace')
357 if bld
.CHECK_FOR_THIRD_PARTY():
358 bld
.RECURSE('third_party/popt')
359 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
360 bld
.RECURSE('third_party/socket_wrapper')
362 bld
.RECURSE('lib/tdb_wrap')
363 bld
.RECURSE('lib/util')
364 bld
.RECURSE('lib/async_req')
366 bld
.RECURSE('lib/talloc')
367 bld
.RECURSE('lib/tevent')
368 bld
.RECURSE('lib/tdb')
370 if bld
.env
.standalone_ctdb
:
371 # If a combined build is implemented, CTDB will want to
372 # build against samba-util rather than samba-util-core.
373 # Similarly, other Samba subsystems expect samba-util. So,
374 # for a standalone build, just define a fake samba-util
375 # subsystem that pulls in samba-util-core.
376 bld
.SAMBA_SUBSYSTEM('samba-util',
378 deps
='samba-util-core')
380 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
381 source
=bld
.SUBDIR('tcp',
382 'tcp_connect.c tcp_init.c tcp_io.c'),
384 deps
='replace tdb talloc tevent')
387 if bld
.env
.HAVE_INFINIBAND
:
388 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
389 source
=bld
.SUBDIR('ib',
390 '''ibwrapper.c ibw_ctdb.c
393 deps
='replace talloc tevent tdb')
394 ib_deps
= ' ctdb-ib rdmacm ibverbs'
396 bld
.SAMBA_SUBSYSTEM('ctdb-system',
397 source
=bld
.SUBDIR('common',
398 'system_socket.c system.c'),
400 deps
='replace talloc tevent tdb pcap samba-util')
402 bld
.SAMBA_SUBSYSTEM('ctdb-common',
403 source
=bld
.SUBDIR('common',
404 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
407 deps
='''replace popt talloc tevent tdb popt ctdb-system
408 ctdb-protocol-util''')
410 bld
.SAMBA_SUBSYSTEM('ctdb-util',
411 source
=bld
.SUBDIR('common',
412 '''db_hash.c srvid.c reqid.c
413 pkt_read.c pkt_write.c comm.c
414 logging.c rb_tree.c tunable.c
417 run_event.c event_script.c
419 cmdline.c path.c conf.c line.c
421 deps
='''samba-util sys_rw tevent-util
422 replace talloc tevent tdb popt''')
424 bld
.SAMBA_SUBSYSTEM('ctdb-logging-conf',
425 source
='common/logging_conf.c',
426 deps
='ctdb-util talloc')
428 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
429 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
432 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
433 source
=bld
.SUBDIR('protocol',
434 '''protocol_header.c protocol_packet.c
445 deps
='ctdb-protocol-basic replace talloc tdb')
447 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
448 source
='protocol/protocol_util.c',
449 deps
='ctdb-util replace talloc tdb')
451 bld
.SAMBA_SUBSYSTEM('ctdb-client',
452 source
=bld
.SUBDIR('client',
453 '''client_connect.c client_call.c
454 client_message.c client_control.c
455 client_message_sync.c
456 client_control_sync.c
457 client_db.c client_util.c
461 deps
='replace talloc tevent tdb tdb-wrap')
463 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
464 source
=bld
.SUBDIR('common',
465 '''sock_daemon.c'''),
466 deps
='''samba-util ctdb-util ctdb-system tevent-util
467 LIBASYNC_REQ replace talloc tevent''')
469 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
470 source
=bld
.SUBDIR('server',
471 '''ipalloc_deterministic.c
472 ipalloc_nondeterministic.c
478 deps
='ctdb-protocol-util replace talloc tevent')
480 bld
.SAMBA_BINARY('ctdb-path',
481 source
='common/path_tool.c',
482 cflags
='-DCTDB_PATH_TOOL',
483 deps
='''ctdb-util samba-util talloc replace popt''',
484 install_path
='${CTDB_HELPER_BINDIR}')
486 bld
.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
487 source
='cluster/cluster_conf.c',
490 bld
.SAMBA_SUBSYSTEM('ctdb-database-conf',
491 source
='database/database_conf.c',
494 bld
.SAMBA_SUBSYSTEM('ctdb-event-conf',
495 source
='event/event_conf.c',
498 bld
.SAMBA_SUBSYSTEM('ctdb-failover-conf',
499 source
='failover/failover_conf.c',
502 bld
.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
503 source
='server/legacy_conf.c',
506 bld
.SAMBA_BINARY('ctdb-config',
507 source
='common/conf_tool.c',
508 cflags
='-DCTDB_CONF_TOOL',
509 deps
='''ctdb-logging-conf
515 ctdb-util samba-util talloc replace popt''',
516 install_path
='${CTDB_HELPER_BINDIR}')
518 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
519 source
=bld
.SUBDIR('event',
521 event_protocol_util.c
523 deps
='ctdb-protocol-basic')
525 bld
.SAMBA_LIBRARY('ctdb-event-client',
526 source
='event/event_client.c',
527 deps
='ctdb-event-protocol ctdb-util tevent talloc',
528 private_library
=True)
530 bld
.SAMBA_BINARY('ctdb-eventd',
531 source
=bld
.SUBDIR('event',
538 deps
='''ctdb-event-protocol
539 ctdb-event-conf ctdb-logging-conf
540 ctdb-server-util samba-util ctdb-util
541 talloc tevent replace popt''',
542 install_path
='${CTDB_HELPER_BINDIR}')
544 bld
.SAMBA_BINARY('ctdb-event',
545 source
='event/event_tool.c',
546 cflags
='-DCTDB_EVENT_TOOL',
547 deps
='''ctdb-event-client ctdb-event-protocol
548 ctdb-util samba-util talloc replace''',
549 install_path
='${CTDB_HELPER_BINDIR}')
551 bld
.SAMBA_BINARY('ctdbd',
552 source
='server/ctdbd.c ' +
554 '''ctdb_daemon.c ctdb_recoverd.c
555 ctdb_recover.c ctdb_freeze.c
556 ctdb_tunables.c ctdb_monitor.c
557 ctdb_server.c ctdb_control.c
558 ctdb_call.c ctdb_ltdb_server.c
559 ctdb_traverse.c eventscript.c
561 ctdb_persistent.c ctdb_keepalive.c
565 ctdb_vacuum.c ctdb_banning.c
568 ctdb_lock.c ctdb_fork.c
569 ctdb_tunnel.c ctdb_client.c
573 deps
='''ctdb-common ctdb-system ctdb-protocol
574 ctdb-tcp ctdb-util replace sys_rw popt
582 talloc tevent tdb-wrap tdb talloc_report''' +
584 install_path
='${SBINDIR}',
587 bld
.SAMBA_BINARY('ctdb',
588 source
='tools/ctdb.c',
589 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
590 ctdb-util ctdb-system samba-util sys_rw popt''',
591 install_path
='${BINDIR}',
594 bld
.SAMBA_BINARY('ctdb_killtcp',
595 source
='tools/ctdb_killtcp.c',
596 deps
='''ctdb-protocol-util ctdb-util ctdb-system
597 samba-util replace''',
598 install_path
='${CTDB_HELPER_BINDIR}')
600 bld
.SAMBA_BINARY('ltdbtool',
601 source
='tools/ltdbtool.c',
604 install_path
='${BINDIR}',
605 manpages
='ltdbtool.1')
607 bld
.SAMBA_BINARY('ctdb_lock_helper',
608 source
='server/ctdb_lock_helper.c',
609 deps
='''samba-util sys_rw ctdb-system tevent-util
610 talloc tevent tdb''',
612 install_path
='${CTDB_HELPER_BINDIR}')
614 bld
.SAMBA_BINARY('ctdb_recovery_helper',
615 source
='server/ctdb_recovery_helper.c',
616 deps
='''ctdb-client ctdb-protocol ctdb-util
617 samba-util sys_rw replace tdb''',
618 install_path
='${CTDB_HELPER_BINDIR}')
620 bld
.SAMBA_BINARY('ctdb_takeover_helper',
621 source
='server/ctdb_takeover_helper.c',
622 deps
='''ctdb-client ctdb-protocol ctdb-util
623 samba-util sys_rw replace ctdb-ipalloc popt''',
624 install_path
='${CTDB_HELPER_BINDIR}')
626 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
627 source
='server/ctdb_mutex_fcntl_helper.c',
628 deps
='''sys_rw ctdb-system tevent-util
632 install_path
='${CTDB_HELPER_BINDIR}')
634 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
635 source
='utils/smnotify/smnotify.x',
636 target
='utils/smnotify/smnotify.h',
637 rule
='rpcgen -h ${SRC} > ${TGT}')
639 xdr_buf_hack
= 'grep -Fv "register int32_t *buf;"'
641 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
642 source
='utils/smnotify/smnotify.x',
643 target
='utils/smnotify/gen_xdr.c',
644 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
646 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
647 source
='utils/smnotify/smnotify.x',
648 target
='utils/smnotify/gen_smnotify.c',
649 rule
='rpcgen -l ${SRC} > ${TGT}')
651 bld
.SAMBA_BINARY('smnotify',
652 source
=bld
.SUBDIR('utils/smnotify',
653 'smnotify.c gen_smnotify.c gen_xdr.c'),
654 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
655 includes
='utils utils/smnotify',
656 install_path
='${CTDB_HELPER_BINDIR}')
658 bld
.SAMBA_BINARY('ping_pong',
659 source
='utils/ping_pong/ping_pong.c',
661 install_path
='${BINDIR}',
662 manpages
='ping_pong.1')
664 if bld
.env
.HAVE_PMDA
:
665 bld
.SAMBA_BINARY('pmdactdb',
666 source
='utils/pmda/pmda_ctdb.c',
668 deps
='''ctdb-client ctdb-protocol ctdb-util
669 samba-util pcp_pmda pcp''',
670 install_path
='${CTDB_PMDADIR}')
671 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
673 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
675 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
677 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
679 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
681 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
684 if bld
.env
.HAVE_LIBRADOS
:
685 rados_inc
= ' include'
686 if bld
.CONFIG_GET('CPPPATH_RADOS') is not None:
687 rados_inc
= bld
.CONFIG_GET('CPPPATH_RADOS') + rados_inc
688 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
689 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
690 deps
='talloc tevent rados ceph-common',
692 install_path
='${CTDB_HELPER_BINDIR}')
694 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
695 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
696 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
697 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
698 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
699 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
700 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
701 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
702 sed_cmdline
= '-e "%s" ' * 8 % \
703 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
704 sed_expr6
, sed_expr7
, sed_expr8
)
706 manpages_extra
= manpages_misc
707 if bld
.env
.etcd_reclock
:
708 manpages_extra
+= manpages_etcd
709 if bld
.env
.HAVE_LIBRADOS
:
710 manpages_extra
+= manpages_ceph
711 for f
in manpages_binary
+ manpages_extra
:
713 bld
.SAMBA_GENERATOR(x
,
714 source
=os
.path
.join('doc', x
),
716 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
718 if bld
.env
.ctdb_generate_manpages
:
719 bld
.MANPAGES(' '.join(manpages_extra
), True)
721 for m
in bld
.env
.ctdb_prebuilt_manpages
:
722 bld
.SAMBA_GENERATOR(m
,
723 source
=os
.path
.join("doc", m
),
725 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
726 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
728 bld
.SAMBA_GENERATOR('ctdb-onnode',
729 source
='tools/onnode',
731 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
732 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
733 destname
='onnode', chmod
=MODE_755
)
735 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
736 source
='tools/ctdb_diagnostics',
737 target
='ctdb_diagnostics',
738 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
739 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
740 destname
='ctdb_diagnostics', chmod
=MODE_755
)
742 if bld
.env
.etcd_reclock
:
743 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
744 source
='utils/etcd/ctdb_etcd_lock',
745 target
='ctdb_etcd_lock',
746 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
747 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
748 destname
='ctdb_etcd_lock', chmod
=MODE_744
)
750 bld
.SAMBA_GENERATOR('ctdb-natgw',
751 source
='tools/ctdb_natgw',
753 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
754 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
755 destname
='ctdb_natgw', chmod
=MODE_755
)
757 bld
.SAMBA_GENERATOR('ctdb-lvs',
758 source
='tools/ctdb_lvs',
760 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
761 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
762 destname
='ctdb_lvs', chmod
=MODE_755
)
764 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
765 source
='config/ctdbd_wrapper',
766 target
='ctdbd_wrapper',
767 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
768 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
769 destname
='ctdbd_wrapper', chmod
=MODE_755
)
771 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
773 fl
= os
.path
.join(dirname
, f
)
774 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
776 mode
= os
.lstat(fl
).st_mode
& MODE_777
778 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
779 arg
['file_list'].append([fl
, mode
])
781 def SUBDIR_MODE(path
, trim_path
=None):
782 pd
= {'trim_path': trim_path
, 'file_list': []}
783 for dirname
, _subdirs
, fnames
in os
.walk(path
):
784 SUBDIR_MODE_callback(pd
, dirname
, fnames
)
785 return pd
['file_list']
787 event_script_subdirs
= [
795 if bld
.env
.standalone_ctdb
:
798 configdir
= 'ctdb/config'
800 for t
in event_script_subdirs
:
801 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
802 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
804 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
805 destname
=fmode
[0], chmod
=fmode
[1])
807 for t
in etc_subdirs
:
808 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
810 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
811 destname
=fmode
[0], chmod
=fmode
[1])
813 # If this is a direct install and there are no event scripts
814 # linked/enabled then enable some standard ones
815 if os
.environ
.get('DESTDIR') is None:
816 fmt
= 'events/legacy/%s.script'
817 required_script
= '00.ctdb'
818 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
819 fmt
% (required_script
))
820 if not os
.path
.islink(required_path
) and \
821 not os
.path
.exists(required_path
):
822 default_scripts
= [ required_script
,
827 for t
in default_scripts
:
828 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
829 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
830 bld
.symlink_as(name
, tgt
)
832 bld
.SAMBA_GENERATOR('ctdb-functions',
833 source
='config/functions',
835 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
836 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
839 'ctdb-crash-cleanup.sh',
840 'debug-hung-script.sh',
842 'nfs-linux-kernel-callout',
847 for t
in etc_scripts
:
848 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
849 destname
=t
, chmod
=MODE_755
)
851 bld
.SAMBA_GENERATOR('ctdb-sudoers',
852 source
='config/ctdb.sudoers',
853 target
='ctdb.sudoers',
854 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
855 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
858 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
859 'config/notification.README',
862 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
863 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
864 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
866 for d
in ['volatile', 'persistent', 'state']:
867 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
869 bld
.SAMBA_BINARY('errcode',
870 source
='tests/src/errcode.c',
872 install_path
='${CTDB_TEST_LIBEXECDIR}')
874 bld
.SAMBA_BINARY('sigcode',
875 source
='tests/src/sigcode.c',
877 install_path
='${CTDB_TEST_LIBEXECDIR}')
899 for target
in ctdb_unit_tests
:
900 src
= 'tests/src/' + target
+ '.c'
902 bld
.SAMBA_BINARY(target
,
904 deps
='''talloc tevent tdb tevent-util popt
905 LIBASYNC_REQ samba-util sys_rw''',
906 install_path
='${CTDB_TEST_LIBEXECDIR}')
908 bld
.SAMBA_BINARY('reqid_test',
909 source
='tests/src/reqid_test.c',
911 install_path
='${CTDB_TEST_LIBEXECDIR}')
913 bld
.SAMBA_BINARY('rb_test',
914 source
='tests/src/rb_test.c',
915 deps
='samba-util talloc',
916 install_path
='${CTDB_TEST_LIBEXECDIR}')
918 bld
.SAMBA_BINARY('ctdb_packet_parse',
919 source
='tests/src/ctdb_packet_parse.c',
920 deps
='talloc tevent tdb ctdb-protocol',
921 install_path
='${CTDB_TEST_LIBEXECDIR}')
923 bld
.SAMBA_BINARY('system_socket_test',
924 source
='tests/src/system_socket_test.c',
925 deps
='talloc ctdb-protocol-util pcap',
926 install_path
='${CTDB_TEST_LIBEXECDIR}')
928 bld
.SAMBA_BINARY('porting_tests',
929 source
='tests/src/porting_tests.c',
930 deps
='samba-util ctdb-system popt',
931 install_path
='${CTDB_TEST_LIBEXECDIR}')
933 bld
.SAMBA_BINARY('sock_daemon_test',
934 source
='tests/src/sock_daemon_test.c',
935 deps
='''ctdb-system talloc tevent tevent-util
936 LIBASYNC_REQ samba-util sys_rw''',
937 install_path
='${CTDB_TEST_LIBEXECDIR}')
939 bld
.SAMBA_BINARY('ctdb_io_test',
940 source
='tests/src/ctdb_io_test.c',
941 deps
='''talloc tevent tdb samba-util sys_rw''',
942 install_path
='${CTDB_TEST_LIBEXECDIR}')
945 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
946 source
=bld
.SUBDIR('tests/src',
947 'protocol_common_basic.c'),
948 deps
='replace talloc')
950 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
951 source
=bld
.SUBDIR('tests/src',
953 protocol_common_ctdb.c
956 deps
='ctdb-protocol-tests-basic replace talloc tdb')
958 bld
.SAMBA_BINARY('protocol_basic_test',
959 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
960 deps
='ctdb-protocol-tests-basic talloc',
961 install_path
='${CTDB_TEST_LIBEXECDIR}')
963 ctdb_protocol_tests
= [
964 'protocol_types_test',
965 'protocol_ctdb_test',
966 'protocol_util_test',
967 'protocol_types_compat_test',
968 'protocol_ctdb_compat_test',
971 for target
in ctdb_protocol_tests
:
972 src
= 'tests/src/' + target
+ '.c'
974 bld
.SAMBA_BINARY(target
,
976 deps
='''ctdb-protocol-tests-common
977 samba-util ctdb-util talloc tdb''',
978 install_path
='${CTDB_TEST_LIBEXECDIR}')
980 bld
.SAMBA_BINARY('event_protocol_test',
981 source
='event/event_protocol_test.c',
982 deps
='''ctdb-protocol-tests-basic
983 ctdb-protocol-basic talloc''',
984 install_path
='${CTDB_TEST_LIBEXECDIR}')
986 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
987 source
=bld
.SUBDIR('tests/src',
988 'cluster_wait.c test_options.c'),
990 deps
='samba-util replace popt talloc tevent tdb')
1000 'fetch_readonly_loop',
1003 'update_record_persistent',
1010 for target
in ctdb_tests
:
1011 src
= 'tests/src/' + target
+ '.c'
1013 bld
.SAMBA_BINARY(target
,
1016 deps
='''ctdb-client ctdb-protocol ctdb-util
1017 samba-util ctdb-tests-common''',
1018 install_path
='${CTDB_TEST_LIBEXECDIR}')
1020 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1021 source
='''tests/src/ctdb_takeover_tests.c
1022 tests/src/ipalloc_read_known_ips.c''',
1023 deps
='''replace popt tdb tevent talloc ctdb-system
1024 samba-util tdb-wrap talloc_report
1025 ctdb-ipalloc ctdb-protocol ctdb-util''',
1027 install_path
='${CTDB_TEST_LIBEXECDIR}')
1029 bld
.SAMBA_BINARY('fake_ctdbd',
1030 source
='''tests/src/fake_ctdbd.c
1031 tests/src/ipalloc_read_known_ips.c''',
1032 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
1033 ctdb-system samba-util tevent-util
1034 LIBASYNC_REQ popt''',
1035 install_path
='${CTDB_TEST_LIBEXECDIR}')
1037 bld
.SAMBA_BINARY('cluster_mutex_test',
1038 source
='tests/src/cluster_mutex_test.c',
1039 deps
='samba-util talloc tevent',
1040 install_path
='${CTDB_TEST_LIBEXECDIR}')
1042 if bld
.env
.HAVE_INFINIBAND
:
1043 bld
.SAMBA_BINARY('ibwrapper_test',
1044 source
='ib/ibwrapper_test.c',
1046 deps
='replace talloc ctdb-common sys_rw' +
1048 install_path
='${CTDB_TEST_LIBEXECDIR}')
1050 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux') and bld
.env
.DEVELOPER
:
1051 bld
.SAMBA_BINARY('test_mutex_raw',
1052 source
='tests/src/test_mutex_raw.c',
1054 install_path
='${CTDB_TEST_LIBEXECDIR}')
1071 if bld
.env
.standalone_ctdb
:
1074 testdir
= 'ctdb/tests'
1076 for t
in test_subdirs
:
1077 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
1079 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
1080 destname
=fmode
[0], chmod
=fmode
[1])
1082 # Install tests/scripts directory without test_wrap
1089 for t
in test_scripts
:
1090 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1091 os
.path
.join('tests/scripts', t
),
1092 destname
=os
.path
.join('scripts', t
))
1094 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
1095 bld
.env
.CTDB_TEST_LIBEXECDIR
)
1096 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
1097 source
='tests/scripts/test_wrap',
1099 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
1100 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
1101 destname
='test_wrap', chmod
=MODE_755
)
1103 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1104 source
='tests/scripts/script_install_paths.sh',
1105 target
='script_install_paths.sh',
1106 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1107 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1108 'script_install_paths.sh',
1109 destname
='script_install_paths.sh', chmod
=MODE_644
)
1111 sed_expr1
= 's@^\(export %s\)=.*@\\1=%s@' % (
1112 'CTDB_TEST_DIR', bld
.env
.CTDB_TEST_DATADIR
)
1113 sed_expr2
= 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
1114 bld
.SAMBA_GENERATOR('ctdb-test-runner',
1115 source
='tests/run_tests.sh',
1116 target
='ctdb_run_tests.sh',
1117 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1118 sed_expr1
, sed_expr2
))
1119 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1120 destname
='ctdb_run_tests', chmod
=MODE_755
)
1121 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
1124 bld
.SAMBA_GENERATOR('ctdb-local-daemons',
1125 source
='tests/local_daemons.sh',
1126 target
='ctdb_local_daemons.sh',
1127 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1128 sed_expr1
, sed_expr2
))
1129 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1130 destname
='ctdb_local_daemons', chmod
=MODE_755
)
1134 cmd
= 'tests/run_tests.sh -V tests/var'
1135 ret
= samba_utils
.RUN_COMMAND(cmd
)
1137 print('tests exited with exit status %d' % ret
)
1142 Options
.commands
.append('build')
1143 Options
.commands
.append('testonly')
1147 env
= samba_utils
.LOAD_ENVIRONMENT()
1148 cmd
= 'tests/run_tests.sh -e -S %s' % env
.SOCKET_WRAPPER_SO_PATH
1149 ret
= samba_utils
.RUN_COMMAND(cmd
)
1151 print('autotest exited with exit status %d' % ret
)
1155 def show_version(ctx
):
1156 print(get_version_string())
1160 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
1161 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
1162 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
1163 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
1164 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1166 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
1167 ret
= samba_utils
.RUN_COMMAND(cmd
)
1169 print('Command %s failed with exit status %d' % (cmd
, ret
))
1172 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
1173 ret
= samba_utils
.RUN_COMMAND(cmd
)
1175 print('Command %s failed with exit status %d' % (cmd
, ret
))
1180 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
1183 sed_expr1
= 's/@VERSION@/%s/g' % get_version_string()
1184 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1185 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1186 sed_expr1
, sed_expr2
, t
)
1187 ret
= samba_utils
.RUN_COMMAND(cmd
)
1189 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1191 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1193 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1195 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1196 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1203 Options
.commands
.append('manpages')
1204 Options
.commands
.append('distonly')
1208 opts
= os
.getenv('RPM_OPTIONS') or ''
1209 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1210 (opts
, get_version_string())
1211 ret
= samba_utils
.RUN_COMMAND(cmd
)
1213 print('rpmbuild exited with exit status %d' % ret
)
1218 Options
.commands
.append('manpages')
1219 Options
.commands
.append('distonly')
1220 Options
.commands
.append('rpmonly')
1224 "build 'tags' file using ctags"
1225 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
1226 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1227 print("Running: %s" % cmd
)
1228 ret
= samba_utils
.RUN_COMMAND(cmd
)
1230 print('ctags failed with exit status %d' % ret
)