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',
630 install_path
='${CTDB_HELPER_BINDIR}')
632 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
633 source
='utils/smnotify/smnotify.x',
634 target
='utils/smnotify/smnotify.h',
635 rule
='rpcgen -h ${SRC} > ${TGT}')
637 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
639 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
640 source
='utils/smnotify/smnotify.x',
641 target
='utils/smnotify/gen_xdr.c',
642 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
644 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
645 source
='utils/smnotify/smnotify.x',
646 target
='utils/smnotify/gen_smnotify.c',
647 rule
='rpcgen -l ${SRC} > ${TGT}')
649 bld
.SAMBA_BINARY('smnotify',
650 source
=bld
.SUBDIR('utils/smnotify',
651 'smnotify.c gen_smnotify.c gen_xdr.c'),
652 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
653 includes
='utils utils/smnotify',
654 install_path
='${CTDB_HELPER_BINDIR}')
656 bld
.SAMBA_BINARY('ping_pong',
657 source
='utils/ping_pong/ping_pong.c',
659 install_path
='${BINDIR}',
660 manpages
='ping_pong.1')
662 if bld
.env
.HAVE_PMDA
:
663 bld
.SAMBA_BINARY('pmdactdb',
664 source
='utils/pmda/pmda_ctdb.c',
666 deps
='''ctdb-client ctdb-protocol ctdb-util
667 samba-util pcp_pmda pcp''',
668 install_path
='${CTDB_PMDADIR}')
669 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
671 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
673 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
675 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
677 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
679 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
682 if bld
.env
.HAVE_LIBRADOS
:
683 rados_inc
= ' include'
684 if bld
.CONFIG_GET('CPPPATH_RADOS') is not None:
685 rados_inc
= bld
.CONFIG_GET('CPPPATH_RADOS') + rados_inc
686 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
687 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
688 deps
='talloc tevent rados ceph-common',
690 install_path
='${CTDB_HELPER_BINDIR}')
692 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
693 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
694 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
695 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
696 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
697 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
698 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
699 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
700 sed_cmdline
= '-e "%s" ' * 8 % \
701 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
702 sed_expr6
, sed_expr7
, sed_expr8
)
704 manpages_extra
= manpages_misc
705 if bld
.env
.etcd_reclock
:
706 manpages_extra
+= manpages_etcd
707 if bld
.env
.HAVE_LIBRADOS
:
708 manpages_extra
+= manpages_ceph
709 for f
in manpages_binary
+ manpages_extra
:
711 bld
.SAMBA_GENERATOR(x
,
712 source
=os
.path
.join('doc', x
),
714 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
716 if bld
.env
.ctdb_generate_manpages
:
717 bld
.MANPAGES(' '.join(manpages_extra
), True)
719 for m
in bld
.env
.ctdb_prebuilt_manpages
:
720 bld
.SAMBA_GENERATOR(m
,
721 source
=os
.path
.join("doc", m
),
723 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
724 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
726 bld
.SAMBA_GENERATOR('ctdb-onnode',
727 source
='tools/onnode',
729 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
730 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
731 destname
='onnode', chmod
=MODE_755
)
733 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
734 source
='tools/ctdb_diagnostics',
735 target
='ctdb_diagnostics',
736 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
737 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
738 destname
='ctdb_diagnostics', chmod
=MODE_755
)
740 if bld
.env
.etcd_reclock
:
741 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
742 source
='utils/etcd/ctdb_etcd_lock',
743 target
='ctdb_etcd_lock',
744 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
745 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
746 destname
='ctdb_etcd_lock', chmod
=MODE_744
)
748 bld
.SAMBA_GENERATOR('ctdb-natgw',
749 source
='tools/ctdb_natgw',
751 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
752 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
753 destname
='ctdb_natgw', chmod
=MODE_755
)
755 bld
.SAMBA_GENERATOR('ctdb-lvs',
756 source
='tools/ctdb_lvs',
758 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
759 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
760 destname
='ctdb_lvs', chmod
=MODE_755
)
762 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
763 source
='config/ctdbd_wrapper',
764 target
='ctdbd_wrapper',
765 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
766 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
767 destname
='ctdbd_wrapper', chmod
=MODE_755
)
769 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
771 fl
= os
.path
.join(dirname
, f
)
772 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
774 mode
= os
.lstat(fl
).st_mode
& MODE_777
776 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
777 arg
['file_list'].append([fl
, mode
])
779 def SUBDIR_MODE(path
, trim_path
=None):
780 pd
= {'trim_path': trim_path
, 'file_list': []}
781 for dirname
, _subdirs
, fnames
in os
.walk(path
):
782 SUBDIR_MODE_callback(pd
, dirname
, fnames
)
783 return pd
['file_list']
785 event_script_subdirs
= [
793 if bld
.env
.standalone_ctdb
:
796 configdir
= 'ctdb/config'
798 for t
in event_script_subdirs
:
799 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
800 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
802 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
803 destname
=fmode
[0], chmod
=fmode
[1])
805 for t
in etc_subdirs
:
806 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
808 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
809 destname
=fmode
[0], chmod
=fmode
[1])
811 # If this is a direct install and there are no event scripts
812 # linked/enabled then enable some standard ones
813 if os
.environ
.get('DESTDIR') is None:
814 fmt
= 'events/legacy/%s.script'
815 required_script
= '00.ctdb'
816 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
817 fmt
% (required_script
))
818 if not os
.path
.islink(required_path
) and \
819 not os
.path
.exists(required_path
):
820 default_scripts
= [ required_script
,
825 for t
in default_scripts
:
826 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
827 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
828 bld
.symlink_as(name
, tgt
)
830 bld
.SAMBA_GENERATOR('ctdb-functions',
831 source
='config/functions',
833 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
834 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
837 'ctdb-crash-cleanup.sh',
838 'debug-hung-script.sh',
840 'nfs-linux-kernel-callout',
845 for t
in etc_scripts
:
846 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
847 destname
=t
, chmod
=MODE_755
)
849 bld
.SAMBA_GENERATOR('ctdb-sudoers',
850 source
='config/ctdb.sudoers',
851 target
='ctdb.sudoers',
852 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
853 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
856 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
857 'config/notification.README',
860 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
861 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
862 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
864 for d
in ['volatile', 'persistent', 'state']:
865 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
867 bld
.SAMBA_BINARY('errcode',
868 source
='tests/src/errcode.c',
870 install_path
='${CTDB_TEST_LIBEXECDIR}')
872 bld
.SAMBA_BINARY('sigcode',
873 source
='tests/src/sigcode.c',
875 install_path
='${CTDB_TEST_LIBEXECDIR}')
897 for target
in ctdb_unit_tests
:
898 src
= 'tests/src/' + target
+ '.c'
900 bld
.SAMBA_BINARY(target
,
902 deps
='''talloc tevent tdb tevent-util popt
903 LIBASYNC_REQ samba-util sys_rw''',
904 install_path
='${CTDB_TEST_LIBEXECDIR}')
906 bld
.SAMBA_BINARY('reqid_test',
907 source
='tests/src/reqid_test.c',
909 install_path
='${CTDB_TEST_LIBEXECDIR}')
911 bld
.SAMBA_BINARY('rb_test',
912 source
='tests/src/rb_test.c',
913 deps
='samba-util talloc',
914 install_path
='${CTDB_TEST_LIBEXECDIR}')
916 bld
.SAMBA_BINARY('ctdb_packet_parse',
917 source
='tests/src/ctdb_packet_parse.c',
918 deps
='talloc tevent tdb ctdb-protocol',
919 install_path
='${CTDB_TEST_LIBEXECDIR}')
921 bld
.SAMBA_BINARY('system_socket_test',
922 source
='tests/src/system_socket_test.c',
923 deps
='talloc ctdb-protocol-util pcap',
924 install_path
='${CTDB_TEST_LIBEXECDIR}')
926 bld
.SAMBA_BINARY('porting_tests',
927 source
='tests/src/porting_tests.c',
928 deps
='samba-util ctdb-system popt',
929 install_path
='${CTDB_TEST_LIBEXECDIR}')
931 bld
.SAMBA_BINARY('sock_daemon_test',
932 source
='tests/src/sock_daemon_test.c',
933 deps
='''ctdb-system talloc tevent tevent-util
934 LIBASYNC_REQ samba-util sys_rw''',
935 install_path
='${CTDB_TEST_LIBEXECDIR}')
937 bld
.SAMBA_BINARY('ctdb_io_test',
938 source
='tests/src/ctdb_io_test.c',
939 deps
='''talloc tevent tdb samba-util sys_rw''',
940 install_path
='${CTDB_TEST_LIBEXECDIR}')
943 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
944 source
=bld
.SUBDIR('tests/src',
945 'protocol_common_basic.c'),
946 deps
='replace talloc')
948 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
949 source
=bld
.SUBDIR('tests/src',
951 protocol_common_ctdb.c
954 deps
='ctdb-protocol-tests-basic replace talloc tdb')
956 bld
.SAMBA_BINARY('protocol_basic_test',
957 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
958 deps
='ctdb-protocol-tests-basic talloc',
959 install_path
='${CTDB_TEST_LIBEXECDIR}')
961 ctdb_protocol_tests
= [
962 'protocol_types_test',
963 'protocol_ctdb_test',
964 'protocol_util_test',
965 'protocol_types_compat_test',
966 'protocol_ctdb_compat_test',
969 for target
in ctdb_protocol_tests
:
970 src
= 'tests/src/' + target
+ '.c'
972 bld
.SAMBA_BINARY(target
,
974 deps
='''ctdb-protocol-tests-common
975 samba-util ctdb-util talloc tdb''',
976 install_path
='${CTDB_TEST_LIBEXECDIR}')
978 bld
.SAMBA_BINARY('event_protocol_test',
979 source
='event/event_protocol_test.c',
980 deps
='''ctdb-protocol-tests-basic
981 ctdb-protocol-basic talloc''',
982 install_path
='${CTDB_TEST_LIBEXECDIR}')
984 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
985 source
=bld
.SUBDIR('tests/src',
986 'cluster_wait.c test_options.c'),
988 deps
='samba-util replace popt talloc tevent tdb')
998 'fetch_readonly_loop',
1001 'update_record_persistent',
1008 for target
in ctdb_tests
:
1009 src
= 'tests/src/' + target
+ '.c'
1011 bld
.SAMBA_BINARY(target
,
1014 deps
='''ctdb-client ctdb-protocol ctdb-util
1015 samba-util ctdb-tests-common''',
1016 install_path
='${CTDB_TEST_LIBEXECDIR}')
1018 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1019 source
='''tests/src/ctdb_takeover_tests.c
1020 tests/src/ipalloc_read_known_ips.c''',
1021 deps
='''replace popt tdb tevent talloc ctdb-system
1022 samba-util tdb-wrap talloc_report
1023 ctdb-ipalloc ctdb-protocol ctdb-util''',
1025 install_path
='${CTDB_TEST_LIBEXECDIR}')
1027 bld
.SAMBA_BINARY('fake_ctdbd',
1028 source
='''tests/src/fake_ctdbd.c
1029 tests/src/ipalloc_read_known_ips.c''',
1030 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
1031 ctdb-system samba-util tevent-util
1032 LIBASYNC_REQ popt''',
1033 install_path
='${CTDB_TEST_LIBEXECDIR}')
1035 if bld
.env
.HAVE_INFINIBAND
:
1036 bld
.SAMBA_BINARY('ibwrapper_test',
1037 source
='ib/ibwrapper_test.c',
1039 deps
='replace talloc ctdb-common sys_rw' +
1041 install_path
='${CTDB_TEST_LIBEXECDIR}')
1043 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux'):
1044 bld
.SAMBA_BINARY('test_mutex_raw',
1045 source
='tests/src/test_mutex_raw.c',
1047 install_path
='${CTDB_TEST_LIBEXECDIR}')
1064 if bld
.env
.standalone_ctdb
:
1067 testdir
= 'ctdb/tests'
1069 for t
in test_subdirs
:
1070 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
1072 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
1073 destname
=fmode
[0], chmod
=fmode
[1])
1075 # Install tests/scripts directory without test_wrap
1082 for t
in test_scripts
:
1083 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1084 os
.path
.join('tests/scripts', t
),
1085 destname
=os
.path
.join('scripts', t
))
1087 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
1088 bld
.env
.CTDB_TEST_LIBEXECDIR
)
1089 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
1090 source
='tests/scripts/test_wrap',
1092 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
1093 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
1094 destname
='test_wrap', chmod
=MODE_755
)
1096 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1097 source
='tests/scripts/script_install_paths.sh',
1098 target
='script_install_paths.sh',
1099 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1100 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1101 'script_install_paths.sh',
1102 destname
='script_install_paths.sh', chmod
=MODE_644
)
1104 sed_expr1
= 's@^\(export %s\)=.*@\\1=%s@' % (
1105 'CTDB_TEST_DIR', bld
.env
.CTDB_TEST_DATADIR
)
1106 sed_expr2
= 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
1107 bld
.SAMBA_GENERATOR('ctdb-test-runner',
1108 source
='tests/run_tests.sh',
1109 target
='ctdb_run_tests.sh',
1110 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1111 sed_expr1
, sed_expr2
))
1112 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1113 destname
='ctdb_run_tests', chmod
=MODE_755
)
1114 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
1117 bld
.SAMBA_GENERATOR('ctdb-local-daemons',
1118 source
='tests/local_daemons.sh',
1119 target
='ctdb_local_daemons.sh',
1120 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1121 sed_expr1
, sed_expr2
))
1122 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1123 destname
='ctdb_local_daemons', chmod
=MODE_755
)
1127 cmd
= 'tests/run_tests.sh -V tests/var'
1128 ret
= samba_utils
.RUN_COMMAND(cmd
)
1130 print('tests exited with exit status %d' % ret
)
1135 Options
.commands
.append('build')
1136 Options
.commands
.append('testonly')
1140 env
= samba_utils
.LOAD_ENVIRONMENT()
1141 cmd
= 'tests/run_tests.sh -e -S %s' % env
.SOCKET_WRAPPER_SO_PATH
1142 ret
= samba_utils
.RUN_COMMAND(cmd
)
1144 print('autotest exited with exit status %d' % ret
)
1148 def show_version(ctx
):
1149 print(get_version_string())
1153 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
1154 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
1155 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
1156 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
1157 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1159 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
1160 ret
= samba_utils
.RUN_COMMAND(cmd
)
1162 print('Command %s failed with exit status %d' % (cmd
, ret
))
1165 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
1166 ret
= samba_utils
.RUN_COMMAND(cmd
)
1168 print('Command %s failed with exit status %d' % (cmd
, ret
))
1173 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
1176 sed_expr1
= 's/@VERSION@/%s/g' % get_version_string()
1177 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1178 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1179 sed_expr1
, sed_expr2
, t
)
1180 ret
= samba_utils
.RUN_COMMAND(cmd
)
1182 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1184 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1186 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1188 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1189 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1196 Options
.commands
.append('manpages')
1197 Options
.commands
.append('distonly')
1201 opts
= os
.getenv('RPM_OPTIONS') or ''
1202 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1203 (opts
, get_version_string())
1204 ret
= samba_utils
.RUN_COMMAND(cmd
)
1206 print('rpmbuild exited with exit status %d' % ret
)
1211 Options
.commands
.append('manpages')
1212 Options
.commands
.append('distonly')
1213 Options
.commands
.append('rpmonly')
1217 "build 'tags' file using ctags"
1218 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
1219 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1220 print("Running: %s" % cmd
)
1221 ret
= samba_utils
.RUN_COMMAND(cmd
)
1223 print('ctags failed with exit status %d' % ret
)