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 conf
.SAMBA_CHECK_PYTHON(mandatory
=False, version
=(2,5,0))
144 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
146 if conf
.CHECK_FOR_THIRD_PARTY():
147 conf
.RECURSE('third_party/popt')
148 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
149 conf
.RECURSE('third_party/socket_wrapper')
150 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
152 if not conf
.CHECK_POPT():
153 raise Errors
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
155 conf
.define('USING_SYSTEM_POPT', 1)
156 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
159 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
160 if not conf
.CHECK_SOCKET_WRAPPER():
161 raise Errors
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
163 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
164 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
166 conf
.RECURSE('lib/util')
168 conf
.RECURSE('lib/talloc')
169 conf
.RECURSE('lib/tevent')
170 conf
.RECURSE('lib/tdb')
172 conf
.CHECK_HEADERS('sched.h')
173 conf
.CHECK_HEADERS('procinfo.h')
174 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
175 Logs
.error('Need thread_setsched() on AIX')
177 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
178 Logs
.error('Need sched_setscheduler()')
180 conf
.CHECK_FUNCS('mlockall')
182 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
183 conf
.DEFINE('ETIME', 'ETIMEDOUT')
185 if sys
.platform
.startswith('linux'):
186 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
188 if not conf
.CHECK_HEADERS('pcap.h'):
189 Logs
.error('Need libpcap')
191 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
192 Logs
.error('Need libpcap')
195 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
196 checklibc
=True, headers
='execinfo.h'):
197 Logs
.error('backtrace support not available')
200 if Options
.options
.ctdb_pmda
:
203 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
206 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
208 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
211 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
214 Logs
.error("PMDA support not available")
217 Logs
.info('Building with PMDA support')
218 conf
.define('HAVE_PMDA', 1)
219 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
220 'lib/pcp/pmdas/ctdb')
222 have_infiniband
= False
223 if Options
.options
.ctdb_infiniband
:
226 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
228 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
230 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
233 have_infiniband
= True
235 Logs
.error("Infiniband support not available")
238 Logs
.info('Building with Infiniband support')
239 conf
.define('HAVE_INFINIBAND', 1)
240 conf
.define('USE_INFINIBAND', 1)
242 have_etcd_reclock
= False
243 if Options
.options
.ctdb_etcd_reclock
:
245 conf
.check_python_module('etcd')
246 have_etcd_reclock
= True
248 Logs
.error('etcd support not available')
250 if have_etcd_reclock
:
251 Logs
.info('Building with etcd support')
252 conf
.env
.etcd_reclock
= have_etcd_reclock
254 if Options
.options
.ctdb_ceph_reclock
:
255 # Use custom libcephfs library path if provided. XXX The top level build
256 # explicitly sets LIBPATH_CEPH-COMMON when libcephfs_dir isn't provided.
257 if Options
.options
.libcephfs_dir
:
258 conf
.env
['CPPPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/include'
259 conf
.env
['LIBPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/lib'
260 conf
.env
['LIBPATH_CEPH-COMMON'] = conf
.env
['LIBPATH_RADOS'] + '/ceph'
262 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
263 conf
.CHECK_LIB('rados', shlib
=True)):
264 conf
.CHECK_LIB('ceph-common', shlib
=True)
265 Logs
.info('Building with Ceph librados recovery lock support')
266 conf
.define('HAVE_LIBRADOS', 1)
268 Logs
.error("Missing librados for Ceph recovery lock support")
271 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
272 conf
.env
.CTDB_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'share/ctdb')
273 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
274 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
275 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
276 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
278 if Options
.options
.ctdb_logdir
:
279 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
281 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
283 if Options
.options
.ctdb_sockpath
:
284 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
286 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
288 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
290 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
292 -DCTDB_DATADIR=\"%s\"
295 -DCTDB_RUNDIR=\"%s\"''' % (
296 conf
.env
.CTDB_HELPER_BINDIR
,
297 conf
.env
.CTDB_LOGDIR
,
298 conf
.env
.CTDB_DATADIR
,
299 conf
.env
.CTDB_ETCDIR
,
300 conf
.env
.CTDB_VARDIR
,
301 conf
.env
.CTDB_RUNDIR
))
303 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.CTDB_DATADIR
, 'tests')
304 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
306 # Allow unified compilation and separate compilation of utilities
308 if not conf
.env
.standalone_ctdb
:
309 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
311 if Context
.g_module
.top
== '.':
312 # Building from tarball
313 conf
.ADD_EXTRA_INCLUDES('#include')
315 # Building standalone CTDB from within Samba tree
316 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
317 conf
.ADD_EXTRA_INCLUDES('#ctdb')
318 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
320 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
321 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
322 conf
.SAMBA_CONFIG_H()
324 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
325 conf
.env
.ctdb_generate_manpages
= True
327 conf
.env
.ctdb_generate_manpages
= False
329 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
330 conf
.env
.ctdb_prebuilt_manpages
= []
331 manpages
= manpages_binary
+ manpages_misc
332 if conf
.env
.etcd_reclock
:
333 manpages
+= manpages_etcd
334 if conf
.env
.HAVE_LIBRADOS
:
335 manpages
+= manpages_ceph
337 if os
.path
.exists(os
.path
.join("doc", m
)):
338 Logs
.info(" %s: yes" % (m
))
339 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
341 Logs
.info(" %s: no" % (m
))
343 def gen_ctdb_version(task
):
344 fp
= open(task
.outputs
[0].bldpath(task
.env
), 'w')
345 fp
.write('/* This file is auto-generated from waf */\n')
346 fp
.write('#include "version.h"\n')
348 fp
.write('#define CTDB_VERSION_STRING "%s"\n' % get_version_string())
353 if bld
.env
.standalone_ctdb
:
354 # enable building of public headers in the build tree
355 bld
.env
.build_public_headers
= 'include/public'
357 if bld
.env
.standalone_ctdb
:
358 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
360 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
361 target
='include/ctdb_version.h',
362 rule
=gen_ctdb_version
,
363 dep_vars
=['VERSION'])
364 t
.env
.VERSION
= get_version_string()
366 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
368 bld
.RECURSE('lib/replace')
369 if bld
.CHECK_FOR_THIRD_PARTY():
370 bld
.RECURSE('third_party/popt')
371 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
372 bld
.RECURSE('third_party/socket_wrapper')
374 bld
.RECURSE('lib/tdb_wrap')
375 bld
.RECURSE('lib/util')
376 bld
.RECURSE('lib/async_req')
378 bld
.RECURSE('lib/talloc')
379 bld
.RECURSE('lib/tevent')
380 bld
.RECURSE('lib/tdb')
382 if bld
.env
.standalone_ctdb
:
383 # If a combined build is implemented, CTDB will want to
384 # build against samba-util rather than samba-util-core.
385 # Similarly, other Samba subsystems expect samba-util. So,
386 # for a standalone build, just define a fake samba-util
387 # subsystem that pulls in samba-util-core.
388 bld
.SAMBA_SUBSYSTEM('samba-util',
390 deps
='samba-util-core')
392 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
393 source
=bld
.SUBDIR('tcp',
394 'tcp_connect.c tcp_init.c tcp_io.c'),
396 deps
='replace tdb talloc tevent')
399 if bld
.env
.HAVE_INFINIBAND
:
400 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
401 source
=bld
.SUBDIR('ib',
402 '''ibwrapper.c ibw_ctdb.c
405 deps
='replace talloc tevent tdb')
406 ib_deps
= ' ctdb-ib rdmacm ibverbs'
408 bld
.SAMBA_SUBSYSTEM('ctdb-system',
409 source
=bld
.SUBDIR('common',
410 'system_socket.c system.c'),
412 deps
='replace talloc tevent tdb pcap samba-util')
414 bld
.SAMBA_SUBSYSTEM('ctdb-common',
415 source
=bld
.SUBDIR('common',
416 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
419 deps
='''replace popt talloc tevent tdb popt ctdb-system
420 ctdb-protocol-util''')
422 bld
.SAMBA_SUBSYSTEM('ctdb-util',
423 source
=bld
.SUBDIR('common',
424 '''db_hash.c srvid.c reqid.c
425 pkt_read.c pkt_write.c comm.c
426 logging.c rb_tree.c tunable.c
429 run_event.c event_script.c
430 sock_client.c version.c
431 cmdline.c path.c conf.c line.c
433 deps
='''samba-util sys_rw tevent-util
434 replace talloc tevent tdb popt''')
436 bld
.SAMBA_SUBSYSTEM('ctdb-logging-conf',
437 source
='common/logging_conf.c',
438 deps
='ctdb-util talloc')
440 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
441 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
444 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
445 source
=bld
.SUBDIR('protocol',
446 '''protocol_header.c protocol_packet.c
457 deps
='ctdb-protocol-basic replace talloc tdb')
459 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
460 source
='protocol/protocol_util.c',
461 deps
='ctdb-util replace talloc tdb')
463 bld
.SAMBA_SUBSYSTEM('ctdb-client',
464 source
=bld
.SUBDIR('client',
465 '''client_connect.c client_call.c
466 client_message.c client_control.c
467 client_message_sync.c
468 client_control_sync.c
469 client_db.c client_util.c
473 deps
='replace talloc tevent tdb tdb-wrap')
475 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
476 source
=bld
.SUBDIR('common',
477 '''sock_daemon.c'''),
478 deps
='''samba-util ctdb-util ctdb-system tevent-util
479 LIBASYNC_REQ replace talloc tevent''')
481 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
482 source
=bld
.SUBDIR('server',
483 '''ipalloc_deterministic.c
484 ipalloc_nondeterministic.c
490 deps
='ctdb-protocol-util replace talloc tevent')
492 bld
.SAMBA_BINARY('ctdb-path',
493 source
='common/path_tool.c',
494 cflags
='-DCTDB_PATH_TOOL',
495 deps
='''ctdb-util samba-util talloc replace popt''',
496 install_path
='${CTDB_HELPER_BINDIR}')
498 bld
.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
499 source
='cluster/cluster_conf.c',
502 bld
.SAMBA_SUBSYSTEM('ctdb-database-conf',
503 source
='database/database_conf.c',
506 bld
.SAMBA_SUBSYSTEM('ctdb-event-conf',
507 source
='event/event_conf.c',
510 bld
.SAMBA_SUBSYSTEM('ctdb-failover-conf',
511 source
='failover/failover_conf.c',
514 bld
.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
515 source
='server/legacy_conf.c',
518 bld
.SAMBA_BINARY('ctdb-config',
519 source
='common/conf_tool.c',
520 cflags
='-DCTDB_CONF_TOOL',
521 deps
='''ctdb-logging-conf
527 ctdb-util samba-util talloc replace popt''',
528 install_path
='${CTDB_HELPER_BINDIR}')
530 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
531 source
=bld
.SUBDIR('event',
533 event_protocol_util.c
535 deps
='ctdb-protocol-basic')
537 bld
.SAMBA_LIBRARY('ctdb-event-client',
538 source
='event/event_client.c',
539 deps
='ctdb-event-protocol ctdb-util tevent talloc',
540 private_library
=True)
542 bld
.SAMBA_BINARY('ctdb-eventd',
543 source
=bld
.SUBDIR('event',
550 deps
='''ctdb-event-protocol
551 ctdb-event-conf ctdb-logging-conf
552 ctdb-server-util samba-util ctdb-util
553 talloc tevent replace popt''',
554 install_path
='${CTDB_HELPER_BINDIR}')
556 bld
.SAMBA_BINARY('ctdb-event',
557 source
='event/event_tool.c',
558 cflags
='-DCTDB_EVENT_TOOL',
559 deps
='''ctdb-event-client ctdb-event-protocol
560 ctdb-util samba-util talloc replace''',
561 install_path
='${CTDB_HELPER_BINDIR}')
563 bld
.SAMBA_BINARY('ctdbd',
564 source
='server/ctdbd.c ' +
566 '''ctdb_daemon.c ctdb_recoverd.c
567 ctdb_recover.c ctdb_freeze.c
568 ctdb_tunables.c ctdb_monitor.c
569 ctdb_server.c ctdb_control.c
570 ctdb_call.c ctdb_ltdb_server.c
571 ctdb_traverse.c eventscript.c
573 ctdb_persistent.c ctdb_keepalive.c
577 ctdb_vacuum.c ctdb_banning.c
580 ctdb_lock.c ctdb_fork.c
581 ctdb_tunnel.c ctdb_client.c
585 deps
='''ctdb-common ctdb-system ctdb-protocol
586 ctdb-tcp ctdb-util replace sys_rw popt
594 talloc tevent tdb-wrap tdb talloc_report''' +
596 install_path
='${SBINDIR}',
599 bld
.SAMBA_BINARY('ctdb',
600 source
='tools/ctdb.c',
601 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
602 ctdb-util ctdb-system samba-util sys_rw popt''',
603 install_path
='${BINDIR}',
606 bld
.SAMBA_BINARY('ctdb_killtcp',
607 source
='tools/ctdb_killtcp.c',
608 deps
='''ctdb-protocol-util ctdb-util ctdb-system
609 samba-util replace''',
610 install_path
='${CTDB_HELPER_BINDIR}')
612 bld
.SAMBA_BINARY('ltdbtool',
613 source
='tools/ltdbtool.c',
616 install_path
='${BINDIR}',
617 manpages
='ltdbtool.1')
619 bld
.SAMBA_BINARY('ctdb_lock_helper',
620 source
='server/ctdb_lock_helper.c',
621 deps
='''samba-util sys_rw ctdb-system tevent-util
622 talloc tevent tdb''',
624 install_path
='${CTDB_HELPER_BINDIR}')
626 bld
.SAMBA_BINARY('ctdb_recovery_helper',
627 source
='server/ctdb_recovery_helper.c',
628 deps
='''ctdb-client ctdb-protocol ctdb-util
629 samba-util sys_rw replace tdb''',
630 install_path
='${CTDB_HELPER_BINDIR}')
632 bld
.SAMBA_BINARY('ctdb_takeover_helper',
633 source
='server/ctdb_takeover_helper.c',
634 deps
='''ctdb-client ctdb-protocol ctdb-util
635 samba-util sys_rw replace ctdb-ipalloc popt''',
636 install_path
='${CTDB_HELPER_BINDIR}')
638 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
639 source
='server/ctdb_mutex_fcntl_helper.c',
640 deps
='sys_rw ctdb-system',
642 install_path
='${CTDB_HELPER_BINDIR}')
644 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
645 source
='utils/smnotify/smnotify.x',
646 target
='utils/smnotify/smnotify.h',
647 rule
='rpcgen -h ${SRC} > ${TGT}')
649 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
651 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
652 source
='utils/smnotify/smnotify.x',
653 target
='utils/smnotify/gen_xdr.c',
654 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
656 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
657 source
='utils/smnotify/smnotify.x',
658 target
='utils/smnotify/gen_smnotify.c',
659 rule
='rpcgen -l ${SRC} > ${TGT}')
661 bld
.SAMBA_BINARY('smnotify',
662 source
=bld
.SUBDIR('utils/smnotify',
663 'smnotify.c gen_smnotify.c gen_xdr.c'),
664 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
665 includes
='utils utils/smnotify',
666 install_path
='${CTDB_HELPER_BINDIR}')
668 bld
.SAMBA_BINARY('ping_pong',
669 source
='utils/ping_pong/ping_pong.c',
671 install_path
='${BINDIR}',
672 manpages
='ping_pong.1')
674 if bld
.env
.HAVE_PMDA
:
675 bld
.SAMBA_BINARY('pmdactdb',
676 source
='utils/pmda/pmda_ctdb.c',
678 deps
='''ctdb-client ctdb-protocol ctdb-util
679 samba-util pcp_pmda pcp''',
680 install_path
='${CTDB_PMDADIR}')
681 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
683 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
685 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
687 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
689 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
691 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
694 if bld
.env
.HAVE_LIBRADOS
:
695 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
696 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
697 deps
='talloc tevent rados ceph-common',
699 install_path
='${CTDB_HELPER_BINDIR}')
701 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
702 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
703 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
704 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
705 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
706 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
707 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
708 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
709 sed_cmdline
= '-e "%s" ' * 8 % \
710 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
711 sed_expr6
, sed_expr7
, sed_expr8
)
713 manpages_extra
= manpages_misc
714 if bld
.env
.etcd_reclock
:
715 manpages_extra
+= manpages_etcd
716 if bld
.env
.HAVE_LIBRADOS
:
717 manpages_extra
+= manpages_ceph
718 for f
in manpages_binary
+ manpages_extra
:
720 bld
.SAMBA_GENERATOR(x
,
721 source
=os
.path
.join('doc', x
),
723 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
725 if bld
.env
.ctdb_generate_manpages
:
726 bld
.MANPAGES(' '.join(manpages_extra
), True)
728 for m
in bld
.env
.ctdb_prebuilt_manpages
:
729 bld
.SAMBA_GENERATOR(m
,
730 source
=os
.path
.join("doc", m
),
732 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
733 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
735 bld
.SAMBA_GENERATOR('ctdb-onnode',
736 source
='tools/onnode',
738 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
739 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
740 destname
='onnode', chmod
=MODE_755
)
742 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
743 source
='tools/ctdb_diagnostics',
744 target
='ctdb_diagnostics',
745 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
746 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
747 destname
='ctdb_diagnostics', chmod
=MODE_755
)
749 if bld
.env
.etcd_reclock
:
750 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
751 source
='utils/etcd/ctdb_etcd_lock',
752 target
='ctdb_etcd_lock',
753 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
754 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
755 destname
='ctdb_etcd_lock', chmod
=MODE_744
)
757 bld
.SAMBA_GENERATOR('ctdb-natgw',
758 source
='tools/ctdb_natgw',
760 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
761 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
762 destname
='ctdb_natgw', chmod
=MODE_755
)
764 bld
.SAMBA_GENERATOR('ctdb-lvs',
765 source
='tools/ctdb_lvs',
767 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
768 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
769 destname
='ctdb_lvs', chmod
=MODE_755
)
771 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
772 source
='config/ctdbd_wrapper',
773 target
='ctdbd_wrapper',
774 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
775 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
776 destname
='ctdbd_wrapper', chmod
=MODE_755
)
778 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
780 fl
= os
.path
.join(dirname
, f
)
781 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
783 mode
= os
.lstat(fl
).st_mode
& MODE_777
785 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
786 arg
['file_list'].append([fl
, mode
])
788 def SUBDIR_MODE(path
, trim_path
=None):
789 pd
= {'trim_path': trim_path
, 'file_list': []}
790 for dirname
, _subdirs
, fnames
in os
.walk(path
):
791 SUBDIR_MODE_callback(pd
, dirname
, fnames
)
792 return pd
['file_list']
794 event_script_subdirs
= [
802 if bld
.env
.standalone_ctdb
:
805 configdir
= 'ctdb/config'
807 for t
in event_script_subdirs
:
808 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
809 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
811 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
812 destname
=fmode
[0], chmod
=fmode
[1])
814 for t
in etc_subdirs
:
815 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
817 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
818 destname
=fmode
[0], chmod
=fmode
[1])
820 # If this is a direct install and there are no event scripts
821 # linked/enabled then enable some standard ones
822 if os
.environ
.get('DESTDIR') is None:
823 fmt
= 'events/legacy/%s.script'
824 required_script
= '00.ctdb'
825 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
826 fmt
% (required_script
))
827 if not os
.path
.islink(required_path
) and \
828 not os
.path
.exists(required_path
):
829 default_scripts
= [ required_script
,
834 for t
in default_scripts
:
835 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
836 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
837 bld
.symlink_as(name
, tgt
)
839 bld
.SAMBA_GENERATOR('ctdb-functions',
840 source
='config/functions',
842 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
843 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
846 'ctdb-crash-cleanup.sh',
847 'debug-hung-script.sh',
849 'nfs-linux-kernel-callout',
854 for t
in etc_scripts
:
855 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
856 destname
=t
, chmod
=MODE_755
)
858 bld
.SAMBA_GENERATOR('ctdb-sudoers',
859 source
='config/ctdb.sudoers',
860 target
='ctdb.sudoers',
861 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
862 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
865 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
866 'config/notification.README',
869 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
870 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
871 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
873 for d
in ['volatile', 'persistent', 'state']:
874 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
876 bld
.SAMBA_BINARY('errcode',
877 source
='tests/src/errcode.c',
879 install_path
='${CTDB_TEST_LIBEXECDIR}')
881 bld
.SAMBA_BINARY('sigcode',
882 source
='tests/src/sigcode.c',
884 install_path
='${CTDB_TEST_LIBEXECDIR}')
906 for target
in ctdb_unit_tests
:
907 src
= 'tests/src/' + target
+ '.c'
909 bld
.SAMBA_BINARY(target
,
911 deps
='''talloc tevent tdb tevent-util popt
912 LIBASYNC_REQ samba-util sys_rw''',
913 install_path
='${CTDB_TEST_LIBEXECDIR}')
915 bld
.SAMBA_BINARY('reqid_test',
916 source
='tests/src/reqid_test.c',
918 install_path
='${CTDB_TEST_LIBEXECDIR}')
920 bld
.SAMBA_BINARY('rb_test',
921 source
='tests/src/rb_test.c',
922 deps
='samba-util talloc',
923 install_path
='${CTDB_TEST_LIBEXECDIR}')
925 bld
.SAMBA_BINARY('ctdb_packet_parse',
926 source
='tests/src/ctdb_packet_parse.c',
927 deps
='talloc tevent tdb ctdb-protocol',
928 install_path
='${CTDB_TEST_LIBEXECDIR}')
930 bld
.SAMBA_BINARY('system_socket_test',
931 source
='tests/src/system_socket_test.c',
932 deps
='talloc ctdb-protocol-util pcap',
933 install_path
='${CTDB_TEST_LIBEXECDIR}')
935 bld
.SAMBA_BINARY('porting_tests',
936 source
='tests/src/porting_tests.c',
937 deps
='samba-util ctdb-system popt',
938 install_path
='${CTDB_TEST_LIBEXECDIR}')
940 bld
.SAMBA_BINARY('sock_daemon_test',
941 source
='tests/src/sock_daemon_test.c',
942 deps
='''ctdb-system talloc tevent tevent-util
943 LIBASYNC_REQ samba-util sys_rw''',
944 install_path
='${CTDB_TEST_LIBEXECDIR}')
946 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
947 source
=bld
.SUBDIR('tests/src',
948 'protocol_common_basic.c'),
949 deps
='replace talloc')
951 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
952 source
=bld
.SUBDIR('tests/src',
954 protocol_common_ctdb.c
957 deps
='ctdb-protocol-tests-basic replace talloc tdb')
959 bld
.SAMBA_BINARY('protocol_basic_test',
960 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
961 deps
='ctdb-protocol-tests-basic talloc',
962 install_path
='${CTDB_TEST_LIBEXECDIR}')
964 ctdb_protocol_tests
= [
965 'protocol_types_test',
966 'protocol_ctdb_test',
967 'protocol_util_test',
968 'protocol_types_compat_test',
969 'protocol_ctdb_compat_test',
972 for target
in ctdb_protocol_tests
:
973 src
= 'tests/src/' + target
+ '.c'
975 bld
.SAMBA_BINARY(target
,
977 deps
='''ctdb-protocol-tests-common
978 samba-util ctdb-util talloc tdb''',
979 install_path
='${CTDB_TEST_LIBEXECDIR}')
981 bld
.SAMBA_BINARY('event_protocol_test',
982 source
='event/event_protocol_test.c',
983 deps
='''ctdb-protocol-tests-basic
984 ctdb-protocol-basic talloc''',
985 install_path
='${CTDB_TEST_LIBEXECDIR}')
987 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
988 source
=bld
.SUBDIR('tests/src',
989 'cluster_wait.c test_options.c'),
991 deps
='samba-util replace popt talloc tevent tdb')
1001 'fetch_readonly_loop',
1004 'update_record_persistent',
1011 for target
in ctdb_tests
:
1012 src
= 'tests/src/' + target
+ '.c'
1014 bld
.SAMBA_BINARY(target
,
1017 deps
='''ctdb-client ctdb-protocol ctdb-util
1018 samba-util ctdb-tests-common''',
1019 install_path
='${CTDB_TEST_LIBEXECDIR}')
1021 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1022 source
='''tests/src/ctdb_takeover_tests.c
1023 tests/src/ipalloc_read_known_ips.c''',
1024 deps
='''replace popt tdb tevent talloc ctdb-system
1025 samba-util tdb-wrap talloc_report
1026 ctdb-ipalloc ctdb-protocol ctdb-util''',
1028 install_path
='${CTDB_TEST_LIBEXECDIR}')
1030 bld
.SAMBA_BINARY('fake_ctdbd',
1031 source
='''tests/src/fake_ctdbd.c
1032 tests/src/ipalloc_read_known_ips.c''',
1033 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
1034 ctdb-system samba-util tevent-util
1035 LIBASYNC_REQ popt''',
1036 install_path
='${CTDB_TEST_LIBEXECDIR}')
1038 if bld
.env
.HAVE_INFINIBAND
:
1039 bld
.SAMBA_BINARY('ibwrapper_test',
1040 source
='ib/ibwrapper_test.c',
1042 deps
='replace talloc ctdb-common sys_rw' +
1044 install_path
='${CTDB_TEST_LIBEXECDIR}')
1046 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux'):
1047 bld
.SAMBA_BINARY('test_mutex_raw',
1048 source
='tests/src/test_mutex_raw.c',
1050 install_path
='${CTDB_TEST_LIBEXECDIR}')
1067 if bld
.env
.standalone_ctdb
:
1070 testdir
= 'ctdb/tests'
1072 for t
in test_subdirs
:
1073 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
1075 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
1076 destname
=fmode
[0], chmod
=fmode
[1])
1078 # Install tests/scripts directory without test_wrap
1085 for t
in test_scripts
:
1086 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1087 os
.path
.join('tests/scripts', t
),
1088 destname
=os
.path
.join('scripts', t
))
1090 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
1091 bld
.env
.CTDB_TEST_LIBEXECDIR
)
1092 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
1093 source
='tests/scripts/test_wrap',
1095 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
1096 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
1097 destname
='test_wrap', chmod
=MODE_755
)
1099 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1100 source
='tests/scripts/script_install_paths.sh',
1101 target
='script_install_paths.sh',
1102 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1103 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1104 'script_install_paths.sh',
1105 destname
='script_install_paths.sh', chmod
=MODE_644
)
1107 sed_expr1
= 's@^\(export %s\)=.*@\\1=%s@' % (
1108 'CTDB_TEST_DIR', bld
.env
.CTDB_TEST_DATADIR
)
1109 sed_expr2
= 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
1110 bld
.SAMBA_GENERATOR('ctdb-test-runner',
1111 source
='tests/run_tests.sh',
1112 target
='ctdb_run_tests.sh',
1113 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1114 sed_expr1
, sed_expr2
))
1115 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1116 destname
='ctdb_run_tests', chmod
=MODE_755
)
1117 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
1120 bld
.SAMBA_GENERATOR('ctdb-local-daemons',
1121 source
='tests/local_daemons.sh',
1122 target
='ctdb_local_daemons.sh',
1123 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1124 sed_expr1
, sed_expr2
))
1125 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1126 destname
='ctdb_local_daemons', chmod
=MODE_755
)
1130 cmd
= 'tests/run_tests.sh -V tests/var'
1131 ret
= samba_utils
.RUN_COMMAND(cmd
)
1133 print('tests exited with exit status %d' % ret
)
1138 Options
.commands
.append('build')
1139 Options
.commands
.append('testonly')
1143 env
= samba_utils
.LOAD_ENVIRONMENT()
1144 cmd
= 'tests/run_tests.sh -e -S %s -C' % env
.SOCKET_WRAPPER_SO_PATH
1145 ret
= samba_utils
.RUN_COMMAND(cmd
)
1147 print('autotest exited with exit status %d' % ret
)
1151 def show_version(ctx
):
1152 print(get_version_string())
1156 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
1157 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
1158 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
1159 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
1160 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1162 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
1163 ret
= samba_utils
.RUN_COMMAND(cmd
)
1165 print('Command %s failed with exit status %d' % (cmd
, ret
))
1168 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
1169 ret
= samba_utils
.RUN_COMMAND(cmd
)
1171 print('Command %s failed with exit status %d' % (cmd
, ret
))
1176 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
1178 version
= get_version()
1180 distfile
= open('.distversion', 'w')
1181 for field
in version
.vcs_fields
:
1182 distfile
.write('%s=%s\n' % (field
, str(version
.vcs_fields
[field
])))
1184 samba_dist
.DIST_FILES('ctdb/.distversion:.distversion', extend
=True)
1187 sed_expr1
= 's/@VERSION@/%s/g' % get_version_string()
1188 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1189 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1190 sed_expr1
, sed_expr2
, t
)
1191 ret
= samba_utils
.RUN_COMMAND(cmd
)
1193 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1195 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1197 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1199 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1200 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1207 Options
.commands
.append('manpages')
1208 Options
.commands
.append('distonly')
1212 opts
= os
.getenv('RPM_OPTIONS') or ''
1213 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1214 (opts
, get_version_string())
1215 ret
= samba_utils
.RUN_COMMAND(cmd
)
1217 print('rpmbuild exited with exit status %d' % ret
)
1222 Options
.commands
.append('manpages')
1223 Options
.commands
.append('distonly')
1224 Options
.commands
.append('rpmonly')
1228 "build 'tags' file using ctags"
1229 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
1230 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1231 print("Running: %s" % cmd
)
1232 ret
= samba_utils
.RUN_COMMAND(cmd
)
1234 print('ctags failed with exit status %d' % ret
)