7 # find the buildtools directory
9 while not os
.path
.exists(top
+'/buildtools') and len(top
.split('/')) < 5:
11 sys
.path
.insert(0, top
+ '/buildtools/wafsamba')
15 from waflib
import Options
, Logs
, Errors
, Context
17 from wafsamba
import samba_dist
, samba_utils
18 from samba_utils
import MODE_644
, MODE_744
, MODE_755
, MODE_777
20 if os
.path
.isfile('./VERSION'):
22 elif os
.path
.isfile('../VERSION'):
25 Logs
.error("VERSION file not found")
27 default_prefix
= Options
.default_prefix
= '/usr/local'
29 samba_dist
.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
30 lib/tevent:lib/tevent lib/tdb:lib/tdb
31 third_party/socket_wrapper:third_party/socket_wrapper
32 third_party/popt:third_party/popt
33 lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap
34 lib/ccan:lib/ccan libcli/util:libcli/util
35 lib/async_req:lib/async_req
36 lib/pthreadpool:lib/pthreadpool
37 lib/messaging:lib/messaging
38 buildtools:buildtools third_party/waf:third_party/waf''')
51 'ctdb-script.options.5',
63 'ctdb_mutex_ceph_rados_helper.7',
70 env
= samba_utils
.LOAD_ENVIRONMENT()
72 return samba_version
.samba_version_file('%s/VERSION' % vdir
, vdir
, env
)
74 def get_version_string():
75 if Context
.g_module
.VERSION
:
76 return Context
.g_module
.VERSION
77 version
= get_version()
78 Context
.g_module
.VERSION
= version
.STRING
.replace('-', '.')
79 return Context
.g_module
.VERSION
82 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
84 opt
.RECURSE('lib/replace')
86 opt
.RECURSE('lib/util')
88 opt
.RECURSE('lib/talloc')
89 opt
.RECURSE('lib/tevent')
90 opt
.RECURSE('lib/tdb')
92 opt
.add_option('--enable-infiniband',
93 help=("Turn on infiniband support (default=no)"),
94 action
="store_true", dest
='ctdb_infiniband', default
=False)
95 opt
.add_option('--enable-pmda',
96 help=("Turn on PCP pmda support (default=no)"),
97 action
="store_true", dest
='ctdb_pmda', default
=False)
98 opt
.add_option('--enable-etcd-reclock',
99 help=("Enable etcd recovery lock helper (default=no)"),
100 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
102 opt
.add_option('--with-libcephfs',
103 help=("Directory under which libcephfs is installed"),
104 action
="store", dest
='libcephfs_dir', default
=None)
105 opt
.add_option('--enable-ceph-reclock',
106 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
107 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
109 opt
.add_option('--with-logdir',
110 help=("Path to log directory"),
111 action
="store", dest
='ctdb_logdir', default
=None)
112 opt
.add_option('--with-socketpath',
113 help=("path to CTDB daemon socket"),
114 action
="store", dest
='ctdb_sockpath', default
=None)
118 # No need to build python bindings for talloc/tevent/tdb
119 if conf
.IN_LAUNCH_DIR():
120 conf
.env
.standalone_ctdb
= True
121 Options
.options
.disable_python
= True
123 conf
.RECURSE('lib/replace')
125 conf
.CHECK_HEADERS(headers
='''sys/socket.h
133 conf
.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
134 define
='HAVE_AF_PACKET',
135 headers
='sys/socket.h linux/if_packet.h')
137 conf
.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
138 define
='HAVE_PACKETSOCKET',
139 headers
='sys/socket.h linux/if_packet.h')
141 conf
.CHECK_CODE('''pthread_mutex_t m;
143 m.__data.__owner = pid;
145 'HAVE_PTHREAD_INTERNAL_MUTEX_OWNER',
147 msg
='Checking for internal POSIX mutex owner field')
148 if not conf
.env
.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER
:
149 # This is unsupported - please see note in debug_locks.sh
150 Logs
.info('Building without unsupported mutex debugging hack')
152 if conf
.env
.standalone_ctdb
:
153 conf
.SAMBA_CHECK_PERL(mandatory
=True)
155 # This is just for consistency and to check the version for the
156 # build system, see Options.options.disable_python = True above
157 conf
.SAMBA_CHECK_PYTHON()
158 conf
.SAMBA_CHECK_PYTHON_HEADERS()
160 # We just want gnutls_rnd for rand subsystem
161 conf
.CHECK_FUNCS_IN('gnutls_rnd', 'gnutls')
164 if conf
.CHECK_FOR_THIRD_PARTY():
165 conf
.RECURSE('third_party/popt')
166 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
167 conf
.RECURSE('third_party/socket_wrapper')
168 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
170 if not conf
.CHECK_POPT():
171 raise Errors
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
173 conf
.define('USING_SYSTEM_POPT', 1)
174 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
177 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
178 if not conf
.CHECK_SOCKET_WRAPPER():
179 raise Errors
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
181 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
182 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
184 conf
.RECURSE('lib/util')
186 conf
.RECURSE('lib/talloc')
187 conf
.RECURSE('lib/tevent')
188 conf
.RECURSE('lib/tdb')
190 conf
.CHECK_HEADERS('sched.h')
191 conf
.CHECK_HEADERS('procinfo.h')
192 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
193 Logs
.error('Need thread_setsched() on AIX')
195 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
196 Logs
.error('Need sched_setscheduler()')
198 conf
.CHECK_FUNCS('mlockall')
199 conf
.CHECK_FUNCS('getrusage', headers
="sys/time.h sys/resource.h")
201 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
202 conf
.DEFINE('ETIME', 'ETIMEDOUT')
204 if sys
.platform
.startswith('linux'):
205 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
207 if not conf
.CHECK_HEADERS('pcap.h'):
208 Logs
.error('Need libpcap')
210 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
211 Logs
.error('Need libpcap')
214 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
215 checklibc
=True, headers
='execinfo.h'):
216 Logs
.error('backtrace support not available')
219 if Options
.options
.ctdb_pmda
:
222 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
225 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
227 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
230 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
233 Logs
.error("PMDA support not available")
236 Logs
.info('Building with PMDA support')
237 conf
.define('HAVE_PMDA', 1)
238 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
239 'lib/pcp/pmdas/ctdb')
241 have_infiniband
= False
242 if Options
.options
.ctdb_infiniband
:
245 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
247 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
249 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
252 have_infiniband
= True
254 Logs
.error("Infiniband support not available")
257 Logs
.info('Building with Infiniband support')
258 conf
.define('HAVE_INFINIBAND', 1)
259 conf
.define('USE_INFINIBAND', 1)
261 have_etcd_reclock
= False
262 if Options
.options
.ctdb_etcd_reclock
:
264 conf
.check_python_module('etcd')
265 have_etcd_reclock
= True
267 Logs
.error('etcd support not available')
269 if have_etcd_reclock
:
270 Logs
.info('Building with etcd support')
271 conf
.env
.etcd_reclock
= have_etcd_reclock
273 if Options
.options
.libcephfs_dir
:
274 Logs
.error('''--with-libcephfs no longer supported, please use compiler
275 flags instead, e.g. GCC LIBRARY_PATH and C_INCLUDE_PATH''')
278 if Options
.options
.ctdb_ceph_reclock
:
279 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
280 conf
.CHECK_LIB('rados', shlib
=True)):
281 Logs
.info('Building with Ceph librados recovery lock support')
282 conf
.define('HAVE_LIBRADOS', 1)
284 Logs
.error("Missing librados for Ceph recovery lock support")
287 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
288 conf
.env
.CTDB_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'share/ctdb')
289 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
290 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
291 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
292 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
294 if Options
.options
.ctdb_logdir
:
295 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
297 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
299 if Options
.options
.ctdb_sockpath
:
300 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
302 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
304 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
306 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
308 -DCTDB_DATADIR=\"%s\"
311 -DCTDB_RUNDIR=\"%s\"''' % (
312 conf
.env
.CTDB_HELPER_BINDIR
,
313 conf
.env
.CTDB_LOGDIR
,
314 conf
.env
.CTDB_DATADIR
,
315 conf
.env
.CTDB_ETCDIR
,
316 conf
.env
.CTDB_VARDIR
,
317 conf
.env
.CTDB_RUNDIR
))
319 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.CTDB_DATADIR
, 'tests')
320 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
322 # Allow unified compilation and separate compilation of utilities
324 if not conf
.env
.standalone_ctdb
:
325 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
327 if Context
.g_module
.top
== '.':
328 # Building from tarball
329 conf
.ADD_EXTRA_INCLUDES('#include')
331 # Building standalone CTDB from within Samba tree
332 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
333 conf
.ADD_EXTRA_INCLUDES('#ctdb')
334 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
336 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
337 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
338 conf
.SAMBA_CONFIG_H()
340 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
341 conf
.env
.ctdb_generate_manpages
= True
343 conf
.env
.ctdb_generate_manpages
= False
345 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
346 conf
.env
.ctdb_prebuilt_manpages
= []
347 manpages
= manpages_binary
+ manpages_misc
348 if conf
.env
.etcd_reclock
:
349 manpages
+= manpages_etcd
350 if conf
.env
.HAVE_LIBRADOS
:
351 manpages
+= manpages_ceph
353 if os
.path
.exists(os
.path
.join("doc", m
)):
354 Logs
.info(" %s: yes" % (m
))
355 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
357 Logs
.info(" %s: no" % (m
))
360 if bld
.env
.standalone_ctdb
:
361 # enable building of public headers in the build tree
362 bld
.env
.build_public_headers
= 'include/public'
364 if bld
.env
.standalone_ctdb
:
365 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
367 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
369 bld
.RECURSE('lib/replace')
370 if bld
.CHECK_FOR_THIRD_PARTY():
371 bld
.RECURSE('third_party/popt')
372 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
373 bld
.RECURSE('third_party/socket_wrapper')
375 bld
.RECURSE('lib/tdb_wrap')
376 bld
.RECURSE('lib/util')
377 bld
.RECURSE('lib/async_req')
378 bld
.RECURSE('lib/pthreadpool')
379 bld
.RECURSE('lib/messaging')
381 bld
.RECURSE('lib/talloc')
382 bld
.RECURSE('lib/tevent')
383 bld
.RECURSE('lib/tdb')
385 if bld
.env
.standalone_ctdb
:
386 # If a combined build is implemented, CTDB will want to
387 # build against samba-util rather than samba-util-core.
388 # Similarly, other Samba subsystems expect samba-util. So,
389 # for a standalone build, just define a fake samba-util
390 # subsystem that pulls in samba-util-core.
391 bld
.SAMBA_SUBSYSTEM('samba-util',
393 deps
='samba-util-core')
395 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
396 source
=bld
.SUBDIR('tcp',
397 'tcp_connect.c tcp_init.c tcp_io.c'),
399 deps
='replace tdb talloc tevent')
402 if bld
.env
.HAVE_INFINIBAND
:
403 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
404 source
=bld
.SUBDIR('ib',
405 '''ibwrapper.c ibw_ctdb.c
408 deps
='replace talloc tevent tdb')
409 ib_deps
= ' ctdb-ib rdmacm ibverbs'
411 bld
.SAMBA_SUBSYSTEM('ctdb-system',
412 source
=bld
.SUBDIR('common',
413 'system_socket.c system.c'),
414 deps
='replace talloc tevent tdb pcap samba-util')
416 bld
.SAMBA_SUBSYSTEM('ctdb-common',
417 source
=bld
.SUBDIR('common',
418 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
421 deps
='''replace popt talloc tevent tdb popt ctdb-system
422 ctdb-protocol-util''')
424 bld
.SAMBA_SUBSYSTEM('ctdb-util',
425 source
=bld
.SUBDIR('common',
426 '''db_hash.c srvid.c reqid.c
427 pkt_read.c pkt_write.c comm.c
428 logging.c rb_tree.c tunable.c
431 run_event.c event_script.c
433 cmdline.c path.c conf.c line.c
435 deps
='''samba-util sys_rw tevent-util
436 replace talloc tevent tdb popt''')
438 bld
.SAMBA_SUBSYSTEM('ctdb-logging-conf',
439 source
='common/logging_conf.c',
440 deps
='ctdb-util talloc')
442 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
443 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
446 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
447 source
=bld
.SUBDIR('protocol',
448 '''protocol_header.c protocol_packet.c
458 deps
='ctdb-protocol-basic replace talloc tdb')
460 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
461 source
='protocol/protocol_util.c',
462 deps
='ctdb-util replace talloc tdb')
464 bld
.SAMBA_SUBSYSTEM('ctdb-client',
465 source
=bld
.SUBDIR('client',
466 '''client_connect.c client_call.c
467 client_message.c client_control.c
468 client_message_sync.c
469 client_control_sync.c
470 client_db.c client_util.c
473 deps
='''ctdb-protocol
483 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
484 source
=bld
.SUBDIR('common',
485 '''sock_daemon.c'''),
486 deps
='''samba-util ctdb-util ctdb-system tevent-util
487 LIBASYNC_REQ replace talloc tevent''')
489 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
490 source
=bld
.SUBDIR('server',
491 '''ipalloc_deterministic.c
492 ipalloc_nondeterministic.c
498 deps
='ctdb-protocol-util replace talloc tevent')
500 bld
.SAMBA_BINARY('ctdb-path',
501 source
='common/path_tool.c',
502 cflags
='-DCTDB_PATH_TOOL',
503 deps
='''ctdb-util samba-util talloc replace popt''',
504 install_path
='${CTDB_HELPER_BINDIR}')
506 bld
.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
507 source
='cluster/cluster_conf.c',
510 bld
.SAMBA_SUBSYSTEM('ctdb-database-conf',
511 source
='database/database_conf.c',
514 bld
.SAMBA_SUBSYSTEM('ctdb-event-conf',
515 source
='event/event_conf.c',
518 bld
.SAMBA_SUBSYSTEM('ctdb-failover-conf',
519 source
='failover/failover_conf.c',
522 bld
.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
523 source
='server/legacy_conf.c',
526 bld
.SAMBA_BINARY('ctdb-config',
527 source
='common/conf_tool.c',
528 cflags
='-DCTDB_CONF_TOOL',
529 deps
='''ctdb-logging-conf
535 ctdb-util samba-util talloc replace popt''',
536 install_path
='${CTDB_HELPER_BINDIR}')
538 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
539 source
=bld
.SUBDIR('event',
541 event_protocol_util.c
543 deps
='ctdb-protocol-basic')
545 bld
.SAMBA_LIBRARY('ctdb-event-client',
546 source
='event/event_client.c',
547 deps
='ctdb-event-protocol ctdb-util tevent talloc',
548 private_library
=True)
550 bld
.SAMBA_BINARY('ctdb-eventd',
551 source
=bld
.SUBDIR('event',
558 deps
='''ctdb-event-protocol
559 ctdb-event-conf ctdb-logging-conf
560 ctdb-server-util samba-util ctdb-util
561 talloc tevent replace popt''',
562 install_path
='${CTDB_HELPER_BINDIR}')
564 bld
.SAMBA_BINARY('ctdb-event',
565 source
='event/event_tool.c',
566 cflags
='-DCTDB_EVENT_TOOL',
567 deps
='''ctdb-event-client ctdb-event-protocol
568 ctdb-util samba-util talloc replace''',
569 install_path
='${CTDB_HELPER_BINDIR}')
571 bld
.SAMBA_BINARY('ctdbd',
572 source
='server/ctdbd.c ' +
574 '''ctdb_daemon.c ctdb_recoverd.c
575 ctdb_recover.c ctdb_freeze.c
576 ctdb_tunables.c ctdb_monitor.c
577 ctdb_server.c ctdb_control.c
578 ctdb_call.c ctdb_ltdb_server.c
579 ctdb_traverse.c eventscript.c
581 ctdb_persistent.c ctdb_keepalive.c
585 ctdb_vacuum.c ctdb_banning.c
588 ctdb_lock.c ctdb_fork.c
589 ctdb_tunnel.c ctdb_client.c
593 deps
='''ctdb-common ctdb-system ctdb-protocol
594 ctdb-tcp ctdb-util replace sys_rw popt
602 talloc tevent tdb-wrap tdb talloc_report''' +
604 install_path
='${SBINDIR}',
607 bld
.SAMBA_BINARY('ctdb',
608 source
='tools/ctdb.c',
609 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
610 ctdb-util ctdb-system samba-util sys_rw popt''',
611 install_path
='${BINDIR}',
614 bld
.SAMBA_BINARY('ctdb_killtcp',
615 source
='tools/ctdb_killtcp.c',
616 deps
='''ctdb-protocol-util ctdb-util ctdb-system
617 samba-util replace''',
618 install_path
='${CTDB_HELPER_BINDIR}')
620 bld
.SAMBA_BINARY('ltdbtool',
621 source
='tools/ltdbtool.c',
624 install_path
='${BINDIR}',
625 manpages
='ltdbtool.1')
627 bld
.SAMBA_BINARY('ctdb_lock_helper',
628 source
='server/ctdb_lock_helper.c',
629 deps
='''samba-util sys_rw ctdb-system tevent-util
630 talloc tevent tdb''',
632 install_path
='${CTDB_HELPER_BINDIR}')
634 bld
.SAMBA_BINARY('ctdb_recovery_helper',
635 source
='server/ctdb_recovery_helper.c',
636 deps
='''ctdb-client ctdb-protocol ctdb-util
637 samba-util sys_rw replace tdb''',
638 install_path
='${CTDB_HELPER_BINDIR}')
640 bld
.SAMBA_BINARY('ctdb_takeover_helper',
641 source
='server/ctdb_takeover_helper.c',
642 deps
='''ctdb-client ctdb-protocol ctdb-util
643 samba-util sys_rw replace ctdb-ipalloc popt''',
644 install_path
='${CTDB_HELPER_BINDIR}')
646 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
647 source
='server/ctdb_mutex_fcntl_helper.c',
648 deps
='''sys_rw ctdb-system tevent-util
652 install_path
='${CTDB_HELPER_BINDIR}')
654 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
655 source
='utils/smnotify/smnotify.x',
656 target
='utils/smnotify/smnotify.h',
657 rule
='rpcgen -h ${SRC} > ${TGT}')
659 xdr_buf_hack
= 'grep -Fv "register int32_t *buf;"'
661 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
662 source
='utils/smnotify/smnotify.x',
663 target
='utils/smnotify/gen_xdr.c',
664 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
666 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
667 source
='utils/smnotify/smnotify.x',
668 target
='utils/smnotify/gen_smnotify.c',
669 rule
='rpcgen -l ${SRC} > ${TGT}')
671 bld
.SAMBA_BINARY('smnotify',
672 source
=bld
.SUBDIR('utils/smnotify',
673 'smnotify.c gen_smnotify.c gen_xdr.c'),
674 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
675 includes
='utils utils/smnotify',
676 install_path
='${CTDB_HELPER_BINDIR}')
678 bld
.SAMBA_BINARY('ping_pong',
679 source
='utils/ping_pong/ping_pong.c',
681 install_path
='${BINDIR}',
682 manpages
='ping_pong.1')
684 if bld
.env
.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER
:
685 bld
.SAMBA_BINARY('tdb_mutex_check',
686 source
='utils/tdb/tdb_mutex_check.c',
688 install_path
='${CTDB_HELPER_BINDIR}')
690 if bld
.env
.HAVE_PMDA
:
691 bld
.SAMBA_BINARY('pmdactdb',
692 source
='utils/pmda/pmda_ctdb.c',
693 deps
='''ctdb-client ctdb-protocol ctdb-util
694 samba-util pcp_pmda pcp''',
695 install_path
='${CTDB_PMDADIR}')
696 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
698 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
700 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
702 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
704 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
706 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
709 if bld
.env
.HAVE_LIBRADOS
:
710 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
711 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
712 deps
='talloc tevent rados',
714 install_path
='${CTDB_HELPER_BINDIR}')
716 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
717 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
718 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
719 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
720 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
721 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
722 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
723 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
724 sed_cmdline
= '-e "%s" ' * 8 % \
725 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
726 sed_expr6
, sed_expr7
, sed_expr8
)
728 manpages_extra
= list(manpages_misc
)
729 if bld
.env
.etcd_reclock
:
730 manpages_extra
+= manpages_etcd
731 if bld
.env
.HAVE_LIBRADOS
:
732 manpages_extra
+= manpages_ceph
733 for f
in manpages_binary
+ manpages_extra
:
735 bld
.SAMBA_GENERATOR(x
,
736 source
=os
.path
.join('doc', x
),
738 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
740 if bld
.env
.ctdb_generate_manpages
:
741 bld
.MANPAGES(' '.join(manpages_extra
), True)
743 for m
in bld
.env
.ctdb_prebuilt_manpages
:
744 bld
.SAMBA_GENERATOR(m
,
745 source
=os
.path
.join("doc", m
),
747 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
748 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
750 bld
.SAMBA_GENERATOR('ctdb-onnode',
751 source
='tools/onnode',
753 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
754 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
755 destname
='onnode', chmod
=MODE_755
)
757 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
758 source
='tools/ctdb_diagnostics',
759 target
='ctdb_diagnostics',
760 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
761 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
762 destname
='ctdb_diagnostics', chmod
=MODE_755
)
764 if bld
.env
.etcd_reclock
:
765 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
766 source
='utils/etcd/ctdb_etcd_lock',
767 target
='ctdb_etcd_lock',
768 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
769 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
770 destname
='ctdb_etcd_lock', chmod
=MODE_744
)
772 bld
.SAMBA_GENERATOR('ctdb-natgw',
773 source
='tools/ctdb_natgw',
775 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
776 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
777 destname
='ctdb_natgw', chmod
=MODE_755
)
779 bld
.SAMBA_GENERATOR('ctdb-lvs',
780 source
='tools/ctdb_lvs',
782 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
783 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
784 destname
='ctdb_lvs', chmod
=MODE_755
)
786 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
788 fl
= os
.path
.join(dirname
, f
)
789 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
791 mode
= os
.lstat(fl
).st_mode
& MODE_777
793 fl
= samba_utils
.os
.path
.relpath(fl
, arg
['trim_path'])
794 arg
['file_list'].append([fl
, mode
])
796 def SUBDIR_MODE(path
, trim_path
=None):
797 pd
= {'trim_path': trim_path
, 'file_list': []}
798 for dirname
, _subdirs
, fnames
in os
.walk(path
):
799 SUBDIR_MODE_callback(pd
, dirname
, fnames
)
800 return pd
['file_list']
802 event_script_subdirs
= [
810 if bld
.env
.standalone_ctdb
:
813 configdir
= 'ctdb/config'
815 for t
in event_script_subdirs
:
816 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
817 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
819 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
820 destname
=fmode
[0], chmod
=fmode
[1])
822 for t
in etc_subdirs
:
823 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
825 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
826 destname
=fmode
[0], chmod
=fmode
[1])
828 # If this is a direct install and there are no event scripts
829 # linked/enabled then enable some standard ones
830 if os
.environ
.get('DESTDIR') is None:
831 fmt
= 'events/legacy/%s.script'
832 required_script
= '00.ctdb'
833 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
834 fmt
% (required_script
))
835 if not os
.path
.islink(required_path
) and \
836 not os
.path
.exists(required_path
):
837 default_scripts
= [ required_script
,
842 for t
in default_scripts
:
843 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
844 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
845 bld
.symlink_as(name
, tgt
)
847 bld
.SAMBA_GENERATOR('ctdb-functions',
848 source
='config/functions',
850 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
851 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
854 'ctdb-crash-cleanup.sh',
855 'debug-hung-script.sh',
857 'nfs-linux-kernel-callout',
862 for t
in etc_scripts
:
863 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
864 destname
=t
, chmod
=MODE_755
)
866 bld
.SAMBA_GENERATOR('ctdb-sudoers',
867 source
='config/ctdb.sudoers',
868 target
='ctdb.sudoers',
869 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
870 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
873 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
874 'config/notification.README',
877 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
878 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
879 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
881 for d
in ['volatile', 'persistent', 'state']:
882 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
885 # Test-only below this point
888 if not bld
.env
.standalone_ctdb
and not bld
.CONFIG_GET('ENABLE_SELFTEST'):
891 bld
.SAMBA_BINARY('errcode',
892 source
='tests/src/errcode.c',
894 install_path
='${CTDB_TEST_LIBEXECDIR}')
896 bld
.SAMBA_BINARY('sigcode',
897 source
='tests/src/sigcode.c',
899 install_path
='${CTDB_TEST_LIBEXECDIR}')
922 for target
in ctdb_unit_tests
:
923 src
= 'tests/src/' + target
+ '.c'
925 bld
.SAMBA_BINARY(target
,
927 deps
='''talloc tevent tdb tevent-util popt
928 LIBASYNC_REQ samba-util sys_rw''',
929 install_path
='${CTDB_TEST_LIBEXECDIR}')
931 bld
.SAMBA_BINARY('reqid_test',
932 source
='tests/src/reqid_test.c',
934 install_path
='${CTDB_TEST_LIBEXECDIR}')
936 bld
.SAMBA_BINARY('rb_test',
937 source
='tests/src/rb_test.c',
938 deps
='samba-util talloc',
939 install_path
='${CTDB_TEST_LIBEXECDIR}')
941 bld
.SAMBA_BINARY('ctdb_packet_parse',
942 source
='tests/src/ctdb_packet_parse.c',
943 deps
='talloc tevent tdb ctdb-protocol',
944 install_path
='${CTDB_TEST_LIBEXECDIR}')
946 bld
.SAMBA_BINARY('system_socket_test',
947 source
='tests/src/system_socket_test.c',
948 deps
='''ctdb-tests-common
953 install_path
='${CTDB_TEST_LIBEXECDIR}')
955 bld
.SAMBA_BINARY('porting_tests',
956 source
='tests/src/porting_tests.c',
957 deps
='samba-util ctdb-system popt',
958 install_path
='${CTDB_TEST_LIBEXECDIR}')
960 bld
.SAMBA_BINARY('sock_daemon_test',
961 source
='tests/src/sock_daemon_test.c',
962 deps
='''ctdb-system talloc tevent tevent-util
963 LIBASYNC_REQ samba-util sys_rw''',
964 install_path
='${CTDB_TEST_LIBEXECDIR}')
966 bld
.SAMBA_BINARY('ctdb_io_test',
967 source
='tests/src/ctdb_io_test.c',
968 deps
='''talloc tevent tdb samba-util sys_rw''',
969 install_path
='${CTDB_TEST_LIBEXECDIR}')
971 bld
.SAMBA_BINARY('ctdb-db-test',
972 source
='tests/src/db_test_tool.c',
973 cflags
='-DCTDB_DB_TEST_TOOL',
974 deps
='''ctdb-client ctdb-protocol
975 ctdb-util samba-util talloc tevent replace''',
976 install_path
='${CTDB_TEST_LIBEXECDIR}')
978 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
979 source
=bld
.SUBDIR('tests/src',
980 'protocol_common_basic.c'),
981 deps
='samba-util replace talloc')
983 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
984 source
=bld
.SUBDIR('tests/src',
986 protocol_common_ctdb.c
988 deps
='ctdb-protocol-tests-basic replace talloc tdb')
990 bld
.SAMBA_BINARY('protocol_basic_test',
991 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
992 deps
='ctdb-protocol-tests-basic talloc',
993 install_path
='${CTDB_TEST_LIBEXECDIR}')
995 ctdb_protocol_tests
= [
996 'protocol_types_test',
997 'protocol_ctdb_test',
998 'protocol_util_test',
999 'protocol_types_compat_test',
1000 'protocol_ctdb_compat_test',
1003 for target
in ctdb_protocol_tests
:
1004 src
= 'tests/src/' + target
+ '.c'
1006 bld
.SAMBA_BINARY(target
,
1008 deps
='''ctdb-protocol-tests-common
1009 samba-util ctdb-util talloc tdb''',
1010 install_path
='${CTDB_TEST_LIBEXECDIR}')
1012 bld
.SAMBA_BINARY('event_protocol_test',
1013 source
='event/event_protocol_test.c',
1014 deps
='''ctdb-protocol-tests-basic
1015 ctdb-protocol-basic talloc''',
1016 install_path
='${CTDB_TEST_LIBEXECDIR}')
1018 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
1019 source
=bld
.SUBDIR('tests/src',
1040 'fetch_readonly_loop',
1043 'update_record_persistent',
1050 for target
in ctdb_tests
:
1051 src
= 'tests/src/' + target
+ '.c'
1053 bld
.SAMBA_BINARY(target
,
1056 deps
='''ctdb-client ctdb-protocol ctdb-util
1057 samba-util ctdb-tests-common''',
1058 install_path
='${CTDB_TEST_LIBEXECDIR}')
1060 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1061 source
='''tests/src/ctdb_takeover_tests.c
1062 tests/src/ipalloc_read_known_ips.c''',
1063 deps
='''replace popt tdb tevent talloc ctdb-system
1064 samba-util tdb-wrap talloc_report
1065 ctdb-ipalloc ctdb-protocol ctdb-util''',
1067 install_path
='${CTDB_TEST_LIBEXECDIR}')
1069 bld
.SAMBA_BINARY('fake_ctdbd',
1070 source
='''tests/src/fake_ctdbd.c
1071 tests/src/ipalloc_read_known_ips.c''',
1072 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
1073 ctdb-system samba-util tevent-util
1074 LIBASYNC_REQ popt''',
1075 install_path
='${CTDB_TEST_LIBEXECDIR}')
1077 bld
.SAMBA_BINARY('cluster_mutex_test',
1078 source
='tests/src/cluster_mutex_test.c',
1079 deps
='''ctdb-tests-common
1084 install_path
='${CTDB_TEST_LIBEXECDIR}')
1086 if bld
.env
.HAVE_INFINIBAND
:
1087 bld
.SAMBA_BINARY('ibwrapper_test',
1088 source
='ib/ibwrapper_test.c',
1090 deps
='replace talloc ctdb-common sys_rw' +
1092 install_path
='${CTDB_TEST_LIBEXECDIR}')
1094 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux') and bld
.env
.DEVELOPER
:
1095 bld
.SAMBA_BINARY('test_mutex_raw',
1096 source
='tests/src/test_mutex_raw.c',
1098 install_path
='${CTDB_TEST_LIBEXECDIR}')
1107 if bld
.env
.standalone_ctdb
:
1110 testdir
= 'ctdb/tests'
1112 for t
in test_subdirs
:
1113 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
1115 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
1116 destname
=fmode
[0], chmod
=fmode
[1])
1118 # Install tests/scripts directory, excluding files that need munging
1123 'integration_local_daemons.bash',
1124 'integration_real_cluster.bash',
1128 for t
in test_scripts
:
1129 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1130 os
.path
.join('tests/scripts', t
),
1131 destname
=os
.path
.join('scripts', t
))
1133 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1134 'tests/scripts/test_wrap',
1135 destname
='scripts/test_wrap',
1138 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1139 source
='tests/scripts/script_install_paths.sh',
1140 target
='script_install_paths.sh',
1141 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1142 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1143 'script_install_paths.sh',
1144 destname
='script_install_paths.sh', chmod
=MODE_644
)
1146 sed_expr1
= 's@^\\(%s\\)=.*@\\1=%s@' % (
1147 'CTDB_TEST_DIR', bld
.env
.CTDB_TEST_DATADIR
)
1148 sed_expr2
= 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1149 bld
.SAMBA_GENERATOR('ctdb-test-runner',
1150 source
='tests/run_tests.sh',
1151 target
='ctdb_run_tests.sh',
1152 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1153 sed_expr1
, sed_expr2
))
1154 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1155 destname
='ctdb_run_tests', chmod
=MODE_755
)
1156 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
1159 bld
.SAMBA_GENERATOR('ctdb-local-daemons',
1160 source
='tests/local_daemons.sh',
1161 target
='ctdb_local_daemons.sh',
1162 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1163 sed_expr1
, sed_expr2
))
1164 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1165 destname
='ctdb_local_daemons', chmod
=MODE_755
)
1169 cmd
= 'tests/run_tests.sh'
1170 ret
= samba_utils
.RUN_COMMAND(cmd
)
1172 print('tests exited with exit status %d' % ret
)
1177 Options
.commands
.append('build')
1178 Options
.commands
.append('testonly')
1182 env
= samba_utils
.LOAD_ENVIRONMENT()
1183 cmd
= 'tests/run_tests.sh -eL -S %s' % env
.SOCKET_WRAPPER_SO_PATH
1184 ret
= samba_utils
.RUN_COMMAND(cmd
)
1186 print('autotest exited with exit status %d' % ret
)
1190 def show_version(ctx
):
1191 print(get_version_string())
1195 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
1196 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
1197 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
1198 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
1199 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1201 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
1202 ret
= samba_utils
.RUN_COMMAND(cmd
)
1204 print('Command %s failed with exit status %d' % (cmd
, ret
))
1207 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
1208 ret
= samba_utils
.RUN_COMMAND(cmd
)
1210 print('Command %s failed with exit status %d' % (cmd
, ret
))
1215 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
1218 sed_expr1
= 's/@VERSION@/%s/g' % get_version_string()
1219 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1220 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1221 sed_expr1
, sed_expr2
, t
)
1222 ret
= samba_utils
.RUN_COMMAND(cmd
)
1224 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1226 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1228 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1230 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1231 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1238 Options
.commands
.append('manpages')
1239 Options
.commands
.append('distonly')
1243 opts
= os
.getenv('RPM_OPTIONS') or ''
1244 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1245 (opts
, get_version_string())
1246 ret
= samba_utils
.RUN_COMMAND(cmd
)
1248 print('rpmbuild exited with exit status %d' % ret
)
1253 Options
.commands
.append('manpages')
1254 Options
.commands
.append('distonly')
1255 Options
.commands
.append('rpmonly')
1259 "build 'tags' file using ctags"
1260 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
1261 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1262 print("Running: %s" % cmd
)
1263 ret
= samba_utils
.RUN_COMMAND(cmd
)
1265 print('ctags failed with exit status %d' % ret
)