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
19 if os
.path
.isfile('./VERSION'):
21 elif os
.path
.isfile('../VERSION'):
24 Logs
.error("VERSION file not found")
26 default_prefix
= Options
.default_prefix
= '/usr/local'
28 samba_dist
.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
29 lib/tevent:lib/tevent lib/tdb:lib/tdb
30 third_party/socket_wrapper:third_party/socket_wrapper
31 third_party/popt:third_party/popt
32 lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap
33 lib/ccan:lib/ccan libcli/util:libcli/util
34 lib/async_req:lib/async_req
35 buildtools:buildtools third_party/waf:third_party/waf''')
49 'ctdb-script.options.5',
61 'ctdb_mutex_ceph_rados_helper.7',
68 env
= samba_utils
.LOAD_ENVIRONMENT()
70 return samba_version
.samba_version_file('%s/VERSION' % vdir
, vdir
, env
)
72 def get_version_string():
73 if Context
.g_module
.VERSION
:
74 return Context
.g_module
.VERSION
75 version
= get_version()
76 Context
.g_module
.VERSION
= version
.STRING
.replace('-', '.')
77 return Context
.g_module
.VERSION
80 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
82 opt
.RECURSE('lib/replace')
84 opt
.RECURSE('lib/util')
86 opt
.RECURSE('lib/talloc')
87 opt
.RECURSE('lib/tevent')
88 opt
.RECURSE('lib/tdb')
90 opt
.add_option('--enable-infiniband',
91 help=("Turn on infiniband support (default=no)"),
92 action
="store_true", dest
='ctdb_infiniband', default
=False)
93 opt
.add_option('--enable-pmda',
94 help=("Turn on PCP pmda support (default=no)"),
95 action
="store_true", dest
='ctdb_pmda', default
=False)
96 opt
.add_option('--enable-etcd-reclock',
97 help=("Enable etcd recovery lock helper (default=no)"),
98 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
100 opt
.add_option('--with-libcephfs',
101 help=("Directory under which libcephfs is installed"),
102 action
="store", dest
='libcephfs_dir', default
=None)
103 opt
.add_option('--enable-ceph-reclock',
104 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
105 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
107 opt
.add_option('--with-logdir',
108 help=("Path to log directory"),
109 action
="store", dest
='ctdb_logdir', default
=None)
110 opt
.add_option('--with-socketpath',
111 help=("path to CTDB daemon socket"),
112 action
="store", dest
='ctdb_sockpath', default
=None)
116 # No need to build python bindings for talloc/tevent/tdb
117 if conf
.IN_LAUNCH_DIR():
118 conf
.env
.standalone_ctdb
= True
119 Options
.options
.disable_python
= True
121 conf
.RECURSE('lib/replace')
123 conf
.CHECK_HEADERS(headers
='''sys/socket.h
131 conf
.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
132 define
='HAVE_AF_PACKET',
133 headers
='sys/socket.h linux/if_packet.h')
135 conf
.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
136 define
='HAVE_PACKETSOCKET',
137 headers
='sys/socket.h linux/if_packet.h')
139 if conf
.env
.standalone_ctdb
:
140 conf
.SAMBA_CHECK_PERL(mandatory
=True)
142 conf
.SAMBA_CHECK_PYTHON(mandatory
=False, version
=(2,5,0))
143 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
145 if conf
.CHECK_FOR_THIRD_PARTY():
146 conf
.RECURSE('third_party/popt')
147 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
148 conf
.RECURSE('third_party/socket_wrapper')
149 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
151 if not conf
.CHECK_POPT():
152 raise Errors
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
154 conf
.define('USING_SYSTEM_POPT', 1)
155 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
158 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
159 if not conf
.CHECK_SOCKET_WRAPPER():
160 raise Errors
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
162 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
163 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
165 conf
.RECURSE('lib/util')
167 conf
.RECURSE('lib/talloc')
168 conf
.RECURSE('lib/tevent')
169 conf
.RECURSE('lib/tdb')
171 conf
.CHECK_HEADERS('sched.h')
172 conf
.CHECK_HEADERS('procinfo.h')
173 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
174 Logs
.error('Need thread_setsched() on AIX')
176 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
177 Logs
.error('Need sched_setscheduler()')
179 conf
.CHECK_FUNCS('mlockall')
181 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
182 conf
.DEFINE('ETIME', 'ETIMEDOUT')
184 if sys
.platform
.startswith('linux'):
185 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
187 if not conf
.CHECK_HEADERS('pcap.h'):
188 Logs
.error('Need libpcap')
190 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
191 Logs
.error('Need libpcap')
194 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
195 checklibc
=True, headers
='execinfo.h'):
196 Logs
.error('backtrace support not available')
199 if Options
.options
.ctdb_pmda
:
202 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
205 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
207 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
210 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
213 Logs
.error("PMDA support not available")
216 Logs
.info('Building with PMDA support')
217 conf
.define('HAVE_PMDA', 1)
218 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
219 'lib/pcp/pmdas/ctdb')
221 have_infiniband
= False
222 if Options
.options
.ctdb_infiniband
:
225 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
227 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
229 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
232 have_infiniband
= True
234 Logs
.error("Infiniband support not available")
237 Logs
.info('Building with Infiniband support')
238 conf
.define('HAVE_INFINIBAND', 1)
239 conf
.define('USE_INFINIBAND', 1)
241 have_etcd_reclock
= False
242 if Options
.options
.ctdb_etcd_reclock
:
244 conf
.check_python_module('etcd')
245 have_etcd_reclock
= True
247 Logs
.error('etcd support not available')
249 if have_etcd_reclock
:
250 Logs
.info('Building with etcd support')
251 conf
.env
.etcd_reclock
= have_etcd_reclock
253 if Options
.options
.ctdb_ceph_reclock
:
254 # Use custom libcephfs library path if provided. XXX The top level build
255 # explicitly sets LIBPATH_CEPH-COMMON when libcephfs_dir isn't provided.
256 if Options
.options
.libcephfs_dir
:
257 conf
.env
['CPPPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/include'
258 conf
.env
['LIBPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/lib'
259 conf
.env
['LIBPATH_CEPH-COMMON'] = conf
.env
['LIBPATH_RADOS'] + '/ceph'
261 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
262 conf
.CHECK_LIB('rados', shlib
=True)):
263 conf
.CHECK_LIB('ceph-common', shlib
=True)
264 Logs
.info('Building with Ceph librados recovery lock support')
265 conf
.define('HAVE_LIBRADOS', 1)
267 Logs
.error("Missing librados for Ceph recovery lock support")
270 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
271 conf
.env
.CTDB_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'share/ctdb')
272 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
273 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
274 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
275 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
277 if Options
.options
.ctdb_logdir
:
278 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
280 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
282 if Options
.options
.ctdb_sockpath
:
283 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
285 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
287 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
289 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
291 -DCTDB_DATADIR=\"%s\"
294 -DCTDB_RUNDIR=\"%s\"''' % (
295 conf
.env
.CTDB_HELPER_BINDIR
,
296 conf
.env
.CTDB_LOGDIR
,
297 conf
.env
.CTDB_DATADIR
,
298 conf
.env
.CTDB_ETCDIR
,
299 conf
.env
.CTDB_VARDIR
,
300 conf
.env
.CTDB_RUNDIR
))
302 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.CTDB_DATADIR
, 'tests')
303 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
305 # Allow unified compilation and separate compilation of utilities
307 if not conf
.env
.standalone_ctdb
:
308 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
310 if Context
.g_module
.top
== '.':
311 # Building from tarball
312 conf
.ADD_EXTRA_INCLUDES('#include')
314 # Building standalone CTDB from within Samba tree
315 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
316 conf
.ADD_EXTRA_INCLUDES('#ctdb')
317 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
319 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
320 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
321 conf
.SAMBA_CONFIG_H()
323 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
324 conf
.env
.ctdb_generate_manpages
= True
326 conf
.env
.ctdb_generate_manpages
= False
328 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
329 conf
.env
.ctdb_prebuilt_manpages
= []
330 manpages
= manpages_binary
+ manpages_misc
331 if conf
.env
.etcd_reclock
:
332 manpages
+= manpages_etcd
333 if conf
.env
.HAVE_LIBRADOS
:
334 manpages
+= manpages_ceph
336 if os
.path
.exists(os
.path
.join("doc", m
)):
337 Logs
.info(" %s: yes" % (m
))
338 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
340 Logs
.info(" %s: no" % (m
))
342 def gen_ctdb_version(task
):
343 fp
= file(task
.outputs
[0].bldpath(task
.env
), 'w')
344 fp
.write('/* This file is auto-generated from waf */\n')
345 fp
.write('#include "version.h"\n')
347 fp
.write('#define CTDB_VERSION_STRING "%s"\n' % get_version_string())
352 if bld
.env
.standalone_ctdb
:
353 # enable building of public headers in the build tree
354 bld
.env
.build_public_headers
= 'include/public'
356 if bld
.env
.standalone_ctdb
:
357 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
359 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
360 target
='include/ctdb_version.h',
361 rule
=gen_ctdb_version
,
362 dep_vars
=['VERSION'])
363 t
.env
.VERSION
= get_version_string()
365 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
367 bld
.RECURSE('lib/replace')
368 if bld
.CHECK_FOR_THIRD_PARTY():
369 bld
.RECURSE('third_party/popt')
370 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
371 bld
.RECURSE('third_party/socket_wrapper')
373 bld
.RECURSE('lib/tdb_wrap')
374 bld
.RECURSE('lib/util')
375 bld
.RECURSE('lib/async_req')
377 bld
.RECURSE('lib/talloc')
378 bld
.RECURSE('lib/tevent')
379 bld
.RECURSE('lib/tdb')
381 if bld
.env
.standalone_ctdb
:
382 # If a combined build is implemented, CTDB will want to
383 # build against samba-util rather than samba-util-core.
384 # Similarly, other Samba subsystems expect samba-util. So,
385 # for a standalone build, just define a fake samba-util
386 # subsystem that pulls in samba-util-core.
387 bld
.SAMBA_SUBSYSTEM('samba-util',
389 deps
='samba-util-core')
391 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
392 source
=bld
.SUBDIR('tcp',
393 'tcp_connect.c tcp_init.c tcp_io.c'),
395 deps
='replace tdb talloc tevent')
398 if bld
.env
.HAVE_INFINIBAND
:
399 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
400 source
=bld
.SUBDIR('ib',
401 '''ibwrapper.c ibw_ctdb.c
404 deps
='replace talloc tevent tdb')
405 ib_deps
= ' ctdb-ib rdmacm ibverbs'
407 bld
.SAMBA_SUBSYSTEM('ctdb-system',
408 source
=bld
.SUBDIR('common',
409 'system_socket.c system.c'),
411 deps
='replace talloc tevent tdb pcap samba-util')
413 bld
.SAMBA_SUBSYSTEM('ctdb-common',
414 source
=bld
.SUBDIR('common',
415 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
418 deps
='''replace popt talloc tevent tdb popt ctdb-system
419 ctdb-protocol-util''')
421 bld
.SAMBA_SUBSYSTEM('ctdb-util',
422 source
=bld
.SUBDIR('common',
423 '''db_hash.c srvid.c reqid.c
424 pkt_read.c pkt_write.c comm.c
425 logging.c rb_tree.c tunable.c
428 run_event.c event_script.c
429 sock_client.c version.c
430 cmdline.c path.c conf.c line.c
432 deps
='''samba-util sys_rw tevent-util
433 replace talloc tevent tdb popt''')
435 bld
.SAMBA_SUBSYSTEM('ctdb-logging-conf',
436 source
='common/logging_conf.c',
437 deps
='ctdb-util talloc')
439 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
440 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
443 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
444 source
=bld
.SUBDIR('protocol',
445 '''protocol_header.c protocol_packet.c
456 deps
='ctdb-protocol-basic replace talloc tdb')
458 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
459 source
='protocol/protocol_util.c',
460 deps
='ctdb-util replace talloc tdb')
462 bld
.SAMBA_SUBSYSTEM('ctdb-client',
463 source
=bld
.SUBDIR('client',
464 '''client_connect.c client_call.c
465 client_message.c client_control.c
466 client_message_sync.c
467 client_control_sync.c
468 client_db.c client_util.c
472 deps
='replace talloc tevent tdb tdb-wrap')
474 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
475 source
=bld
.SUBDIR('common',
476 '''sock_daemon.c'''),
477 deps
='''samba-util ctdb-util ctdb-system tevent-util
478 LIBASYNC_REQ replace talloc tevent''')
480 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
481 source
=bld
.SUBDIR('server',
482 '''ipalloc_deterministic.c
483 ipalloc_nondeterministic.c
489 deps
='ctdb-protocol-util replace talloc tevent')
491 bld
.SAMBA_BINARY('ctdb-path',
492 source
='common/path_tool.c',
493 cflags
='-DCTDB_PATH_TOOL',
494 deps
='''ctdb-util samba-util talloc replace popt''',
495 install_path
='${CTDB_HELPER_BINDIR}')
497 bld
.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
498 source
='cluster/cluster_conf.c',
501 bld
.SAMBA_SUBSYSTEM('ctdb-database-conf',
502 source
='database/database_conf.c',
505 bld
.SAMBA_SUBSYSTEM('ctdb-event-conf',
506 source
='event/event_conf.c',
509 bld
.SAMBA_SUBSYSTEM('ctdb-failover-conf',
510 source
='failover/failover_conf.c',
513 bld
.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
514 source
='server/legacy_conf.c',
517 bld
.SAMBA_BINARY('ctdb-config',
518 source
='common/conf_tool.c',
519 cflags
='-DCTDB_CONF_TOOL',
520 deps
='''ctdb-logging-conf
526 ctdb-util samba-util talloc replace popt''',
527 install_path
='${CTDB_HELPER_BINDIR}')
529 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
530 source
=bld
.SUBDIR('event',
532 event_protocol_util.c
534 deps
='ctdb-protocol-basic')
536 bld
.SAMBA_LIBRARY('ctdb-event-client',
537 source
='event/event_client.c',
538 deps
='ctdb-event-protocol ctdb-util tevent talloc',
539 private_library
=True)
541 bld
.SAMBA_BINARY('ctdb-eventd',
542 source
=bld
.SUBDIR('event',
549 deps
='''ctdb-event-protocol
550 ctdb-event-conf ctdb-logging-conf
551 ctdb-server-util samba-util ctdb-util
552 talloc tevent replace popt''',
553 install_path
='${CTDB_HELPER_BINDIR}')
555 bld
.SAMBA_BINARY('ctdb-event',
556 source
='event/event_tool.c',
557 cflags
='-DCTDB_EVENT_TOOL',
558 deps
='''ctdb-event-client ctdb-event-protocol
559 ctdb-util samba-util talloc replace''',
560 install_path
='${CTDB_HELPER_BINDIR}')
562 bld
.SAMBA_BINARY('ctdbd',
563 source
='server/ctdbd.c ' +
565 '''ctdb_daemon.c ctdb_recoverd.c
566 ctdb_recover.c ctdb_freeze.c
567 ctdb_tunables.c ctdb_monitor.c
568 ctdb_server.c ctdb_control.c
569 ctdb_call.c ctdb_ltdb_server.c
570 ctdb_traverse.c eventscript.c
572 ctdb_persistent.c ctdb_keepalive.c
576 ctdb_vacuum.c ctdb_banning.c
579 ctdb_lock.c ctdb_fork.c
580 ctdb_tunnel.c ctdb_client.c
584 deps
='''ctdb-common ctdb-system ctdb-protocol
585 ctdb-tcp ctdb-util replace sys_rw popt
593 talloc tevent tdb-wrap tdb talloc_report''' +
595 install_path
='${SBINDIR}',
598 bld
.SAMBA_BINARY('ctdb',
599 source
='tools/ctdb.c',
600 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
601 ctdb-util ctdb-system samba-util sys_rw popt''',
602 install_path
='${BINDIR}',
605 bld
.SAMBA_BINARY('ctdb_killtcp',
606 source
='tools/ctdb_killtcp.c',
607 deps
='''ctdb-protocol-util ctdb-util ctdb-system
608 samba-util replace''',
609 install_path
='${CTDB_HELPER_BINDIR}')
611 bld
.SAMBA_BINARY('ltdbtool',
612 source
='tools/ltdbtool.c',
615 install_path
='${BINDIR}',
616 manpages
='ltdbtool.1')
618 bld
.SAMBA_BINARY('ctdb_lock_helper',
619 source
='server/ctdb_lock_helper.c',
620 deps
='''samba-util sys_rw ctdb-system tevent-util
621 talloc tevent tdb''',
623 install_path
='${CTDB_HELPER_BINDIR}')
625 bld
.SAMBA_BINARY('ctdb_recovery_helper',
626 source
='server/ctdb_recovery_helper.c',
627 deps
='''ctdb-client ctdb-protocol ctdb-util
628 samba-util sys_rw replace tdb''',
629 install_path
='${CTDB_HELPER_BINDIR}')
631 bld
.SAMBA_BINARY('ctdb_takeover_helper',
632 source
='server/ctdb_takeover_helper.c',
633 deps
='''ctdb-client ctdb-protocol ctdb-util
634 samba-util sys_rw replace ctdb-ipalloc popt''',
635 install_path
='${CTDB_HELPER_BINDIR}')
637 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
638 source
='server/ctdb_mutex_fcntl_helper.c',
639 deps
='sys_rw ctdb-system',
641 install_path
='${CTDB_HELPER_BINDIR}')
643 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
644 source
='utils/smnotify/smnotify.x',
645 target
='utils/smnotify/smnotify.h',
646 rule
='rpcgen -h ${SRC} > ${TGT}')
648 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
650 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
651 source
='utils/smnotify/smnotify.x',
652 target
='utils/smnotify/gen_xdr.c',
653 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
655 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
656 source
='utils/smnotify/smnotify.x',
657 target
='utils/smnotify/gen_smnotify.c',
658 rule
='rpcgen -l ${SRC} > ${TGT}')
660 bld
.SAMBA_BINARY('smnotify',
661 source
=bld
.SUBDIR('utils/smnotify',
662 'smnotify.c gen_smnotify.c gen_xdr.c'),
663 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
664 includes
='utils utils/smnotify',
665 install_path
='${CTDB_HELPER_BINDIR}')
667 bld
.SAMBA_BINARY('ping_pong',
668 source
='utils/ping_pong/ping_pong.c',
670 install_path
='${BINDIR}',
671 manpages
='ping_pong.1')
673 if bld
.env
.HAVE_PMDA
:
674 bld
.SAMBA_BINARY('pmdactdb',
675 source
='utils/pmda/pmda_ctdb.c',
677 deps
='''ctdb-client ctdb-protocol ctdb-util
678 samba-util pcp_pmda pcp''',
679 install_path
='${CTDB_PMDADIR}')
680 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
682 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
684 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
686 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
688 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
690 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
693 if bld
.env
.HAVE_LIBRADOS
:
694 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
695 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
696 deps
='talloc tevent rados ceph-common',
698 install_path
='${CTDB_HELPER_BINDIR}')
700 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
701 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
702 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
703 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
704 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
705 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
706 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
707 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
708 sed_cmdline
= '-e "%s" ' * 8 % \
709 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
710 sed_expr6
, sed_expr7
, sed_expr8
)
712 manpages_extra
= manpages_misc
713 if bld
.env
.etcd_reclock
:
714 manpages_extra
+= manpages_etcd
715 if bld
.env
.HAVE_LIBRADOS
:
716 manpages_extra
+= manpages_ceph
717 for f
in manpages_binary
+ manpages_extra
:
719 bld
.SAMBA_GENERATOR(x
,
720 source
=os
.path
.join('doc', x
),
722 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
724 if bld
.env
.ctdb_generate_manpages
:
725 bld
.MANPAGES(' '.join(manpages_extra
), True)
727 for m
in bld
.env
.ctdb_prebuilt_manpages
:
728 bld
.SAMBA_GENERATOR(m
,
729 source
=os
.path
.join("doc", m
),
731 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
732 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
734 bld
.SAMBA_GENERATOR('ctdb-onnode',
735 source
='tools/onnode',
737 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
738 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
739 destname
='onnode', chmod
=0o755)
741 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
742 source
='tools/ctdb_diagnostics',
743 target
='ctdb_diagnostics',
744 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
745 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
746 destname
='ctdb_diagnostics', chmod
=0o755)
748 if bld
.env
.etcd_reclock
:
749 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
750 source
='utils/etcd/ctdb_etcd_lock',
751 target
='ctdb_etcd_lock',
752 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
753 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
754 destname
='ctdb_etcd_lock', chmod
=0o744)
756 bld
.SAMBA_GENERATOR('ctdb-natgw',
757 source
='tools/ctdb_natgw',
759 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
760 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
761 destname
='ctdb_natgw', chmod
=0o755)
763 bld
.SAMBA_GENERATOR('ctdb-lvs',
764 source
='tools/ctdb_lvs',
766 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
767 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
768 destname
='ctdb_lvs', chmod
=0o755)
770 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
771 source
='config/ctdbd_wrapper',
772 target
='ctdbd_wrapper',
773 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
774 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
775 destname
='ctdbd_wrapper', chmod
=0o755)
777 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
779 fl
= os
.path
.join(dirname
, f
)
780 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
782 mode
= os
.lstat(fl
).st_mode
& 0o777
784 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
785 arg
['file_list'].append([fl
, mode
])
787 def SUBDIR_MODE(path
, trim_path
=None):
788 pd
= {'trim_path': trim_path
, 'file_list': []}
789 os
.path
.walk(path
, SUBDIR_MODE_callback
, pd
)
790 return pd
['file_list']
792 event_script_subdirs
= [
800 if bld
.env
.standalone_ctdb
:
803 configdir
= 'ctdb/config'
805 for t
in event_script_subdirs
:
806 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
807 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
809 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
810 destname
=fmode
[0], chmod
=fmode
[1])
812 for t
in etc_subdirs
:
813 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
815 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
816 destname
=fmode
[0], chmod
=fmode
[1])
818 # If this is a direct install and there are no event scripts
819 # linked/enabled then enable some standard ones
820 if os
.environ
.get('DESTDIR') is None:
821 fmt
= 'events/legacy/%s.script'
822 required_script
= '00.ctdb'
823 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
824 fmt
% (required_script
))
825 if not os
.path
.islink(required_path
) and \
826 not os
.path
.exists(required_path
):
827 default_scripts
= [ required_script
,
832 for t
in default_scripts
:
833 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
834 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
835 bld
.symlink_as(name
, tgt
)
837 bld
.SAMBA_GENERATOR('ctdb-functions',
838 source
='config/functions',
840 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
841 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
844 'ctdb-crash-cleanup.sh',
845 'debug-hung-script.sh',
847 'nfs-linux-kernel-callout',
852 for t
in etc_scripts
:
853 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
854 destname
=t
, chmod
=0o755)
856 bld
.SAMBA_GENERATOR('ctdb-sudoers',
857 source
='config/ctdb.sudoers',
858 target
='ctdb.sudoers',
859 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
860 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
863 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
864 'config/notification.README',
867 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
868 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
869 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
871 for d
in ['volatile', 'persistent', 'state']:
872 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
874 bld
.SAMBA_BINARY('errcode',
875 source
='tests/src/errcode.c',
877 install_path
='${CTDB_TEST_LIBEXECDIR}')
879 bld
.SAMBA_BINARY('sigcode',
880 source
='tests/src/sigcode.c',
882 install_path
='${CTDB_TEST_LIBEXECDIR}')
904 for target
in ctdb_unit_tests
:
905 src
= 'tests/src/' + target
+ '.c'
907 bld
.SAMBA_BINARY(target
,
909 deps
='''talloc tevent tdb tevent-util popt
910 LIBASYNC_REQ samba-util sys_rw''',
911 install_path
='${CTDB_TEST_LIBEXECDIR}')
913 bld
.SAMBA_BINARY('reqid_test',
914 source
='tests/src/reqid_test.c',
916 install_path
='${CTDB_TEST_LIBEXECDIR}')
918 bld
.SAMBA_BINARY('rb_test',
919 source
='tests/src/rb_test.c',
920 deps
='samba-util talloc',
921 install_path
='${CTDB_TEST_LIBEXECDIR}')
923 bld
.SAMBA_BINARY('ctdb_packet_parse',
924 source
='tests/src/ctdb_packet_parse.c',
925 deps
='talloc tevent tdb ctdb-protocol',
926 install_path
='${CTDB_TEST_LIBEXECDIR}')
928 bld
.SAMBA_BINARY('system_socket_test',
929 source
='tests/src/system_socket_test.c',
930 deps
='talloc ctdb-protocol-util pcap',
931 install_path
='${CTDB_TEST_LIBEXECDIR}')
933 bld
.SAMBA_BINARY('porting_tests',
934 source
='tests/src/porting_tests.c',
935 deps
='samba-util ctdb-system popt',
936 install_path
='${CTDB_TEST_LIBEXECDIR}')
938 bld
.SAMBA_BINARY('sock_daemon_test',
939 source
='tests/src/sock_daemon_test.c',
940 deps
='''ctdb-system talloc tevent tevent-util
941 LIBASYNC_REQ samba-util sys_rw''',
942 install_path
='${CTDB_TEST_LIBEXECDIR}')
944 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
945 source
=bld
.SUBDIR('tests/src',
946 'protocol_common_basic.c'),
947 deps
='replace talloc')
949 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
950 source
=bld
.SUBDIR('tests/src',
952 protocol_common_ctdb.c
955 deps
='ctdb-protocol-tests-basic replace talloc tdb')
957 bld
.SAMBA_BINARY('protocol_basic_test',
958 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
959 deps
='ctdb-protocol-tests-basic talloc',
960 install_path
='${CTDB_TEST_LIBEXECDIR}')
962 ctdb_protocol_tests
= [
963 'protocol_types_test',
964 'protocol_ctdb_test',
965 'protocol_util_test',
966 'protocol_types_compat_test',
967 'protocol_ctdb_compat_test',
970 for target
in ctdb_protocol_tests
:
971 src
= 'tests/src/' + target
+ '.c'
973 bld
.SAMBA_BINARY(target
,
975 deps
='''ctdb-protocol-tests-common
976 samba-util ctdb-util talloc tdb''',
977 install_path
='${CTDB_TEST_LIBEXECDIR}')
979 bld
.SAMBA_BINARY('event_protocol_test',
980 source
='event/event_protocol_test.c',
981 deps
='''ctdb-protocol-tests-basic
982 ctdb-protocol-basic talloc''',
983 install_path
='${CTDB_TEST_LIBEXECDIR}')
985 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
986 source
=bld
.SUBDIR('tests/src',
987 'cluster_wait.c test_options.c'),
989 deps
='samba-util replace popt talloc tevent tdb')
999 'fetch_readonly_loop',
1002 'update_record_persistent',
1009 for target
in ctdb_tests
:
1010 src
= 'tests/src/' + target
+ '.c'
1012 bld
.SAMBA_BINARY(target
,
1015 deps
='''ctdb-client ctdb-protocol ctdb-util
1016 samba-util ctdb-tests-common''',
1017 install_path
='${CTDB_TEST_LIBEXECDIR}')
1019 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1020 source
='''tests/src/ctdb_takeover_tests.c
1021 tests/src/ipalloc_read_known_ips.c''',
1022 deps
='''replace popt tdb tevent talloc ctdb-system
1023 samba-util tdb-wrap talloc_report
1024 ctdb-ipalloc ctdb-protocol ctdb-util''',
1026 install_path
='${CTDB_TEST_LIBEXECDIR}')
1028 bld
.SAMBA_BINARY('fake_ctdbd',
1029 source
='''tests/src/fake_ctdbd.c
1030 tests/src/ipalloc_read_known_ips.c''',
1031 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
1032 ctdb-system samba-util tevent-util
1033 LIBASYNC_REQ popt''',
1034 install_path
='${CTDB_TEST_LIBEXECDIR}')
1036 if bld
.env
.HAVE_INFINIBAND
:
1037 bld
.SAMBA_BINARY('ibwrapper_test',
1038 source
='ib/ibwrapper_test.c',
1040 deps
='replace talloc ctdb-common sys_rw' +
1042 install_path
='${CTDB_TEST_LIBEXECDIR}')
1044 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux'):
1045 bld
.SAMBA_BINARY('test_mutex_raw',
1046 source
='tests/src/test_mutex_raw.c',
1048 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
=0o755)
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
=0o644)
1104 sed_expr1
= 's@^\(export %s\)=.*@\\1=%s\\nexport %s=\"%s\"@''' % (
1105 'CTDB_TEST_DIR
', bld.env.CTDB_TEST_DATADIR,
1106 'TEST_BIN_DIR
', bld.env.CTDB_TEST_LIBEXECDIR)
1107 sed_expr2 = 's
@^\
(export CTDB_TESTS_ARE_INSTALLED\
)=false
@\\1=true
@'
1108 bld.SAMBA_GENERATOR('ctdb
-test
-runner
',
1109 source='tests
/run_tests
.sh
',
1110 target='ctdb_run_tests
.sh
',
1111 rule='sed
-e
"%s" -e
"%s" ${SRC}
> ${TGT}
' % (
1112 sed_expr1, sed_expr2))
1113 bld.INSTALL_FILES('${BINDIR}
', 'ctdb_run_tests
.sh
',
1114 destname='ctdb_run_tests
', chmod=0o755)
1115 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests
'),
1120 cmd = 'tests
/run_tests
.sh
-V tests
/var
'
1121 ret = samba_utils.RUN_COMMAND(cmd)
1123 print('tests exited with exit status
%d' % ret)
1128 Options.commands.append('build
')
1129 Options.commands.append('testonly
')
1133 env = samba_utils.LOAD_ENVIRONMENT()
1134 cmd = 'tests
/run_tests
.sh
-e
-S
%s -C
' % env.SOCKET_WRAPPER_SO_PATH
1135 ret = samba_utils.RUN_COMMAND(cmd)
1137 print('autotest exited with exit status
%d' % ret)
1141 def show_version(ctx):
1142 print(get_version_string())
1146 BASE_URL = 'http
://docbook
.sourceforge
.net
/release
/xsl
/current
'
1147 MAN_XSL = '%s/manpages
/docbook
.xsl
' % BASE_URL
1148 HTML_XSL = '%s/html
/docbook
.xsl
' % BASE_URL
1149 CMD_TEMPLATE = 'xsltproc
--xinclude
-o
%s --nonet
%s %s'
1150 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1152 cmd = CMD_TEMPLATE % ('doc
/%s' % t, MAN_XSL, 'doc
/%s.xml
' % t)
1153 ret = samba_utils.RUN_COMMAND(cmd)
1155 print('Command
%s failed with exit status
%d' % (cmd, ret))
1158 cmd = CMD_TEMPLATE % ('doc
/%s.html
' % t, HTML_XSL, 'doc
/%s.xml
' % t)
1159 ret = samba_utils.RUN_COMMAND(cmd)
1161 print('Command
%s failed with exit status
%d' % (cmd, ret))
1166 samba_dist.DIST_FILES('VERSION
:VERSION
', extend=True)
1168 version = get_version()
1170 distfile = file('.distversion
', 'w
')
1171 for field in version.vcs_fields:
1172 distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
1174 samba_dist.DIST_FILES('ctdb
/.distversion
:.distversion
', extend=True)
1177 sed_expr1 = 's
/@VERSION@/%s/g
' % get_version_string()
1178 sed_expr2 = 's
/@RELEASE@/%s/g
' % '1'
1179 cmd = 'sed
-e
"%s" -e
"%s" packaging
/RPM
/ctdb
.spec
.in > %s' % (
1180 sed_expr1, sed_expr2, t)
1181 ret = samba_utils.RUN_COMMAND(cmd)
1183 print('Command
"%s" failed with exit status
%d' % (cmd, ret))
1185 samba_dist.DIST_FILES('ctdb
/%s:%s' % (t, t), extend=True)
1187 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1189 samba_dist.DIST_FILES('ctdb
/doc
/%s:doc
/%s' % (t, t), extend=True)
1190 samba_dist.DIST_FILES('ctdb
/doc
/%s.html
:doc
/%s.html
' % (t, t),
1197 Options.commands.append('manpages
')
1198 Options.commands.append('distonly
')
1202 opts = os.getenv('RPM_OPTIONS
') or ''
1203 cmd = 'rpmbuild
-ta
--clean
--rmsource
%s ctdb
-%s.tar
.gz
' % \
1204 (opts, get_version_string())
1205 ret = samba_utils.RUN_COMMAND(cmd)
1207 print('rpmbuild exited with exit status
%d' % ret)
1212 Options.commands.append('manpages
')
1213 Options.commands.append('distonly
')
1214 Options.commands.append('rpmonly
')
1218 "build 'tags
' file using ctags"
1219 source_root = os.path.dirname(Context.g_module.root_path)
1220 cmd = 'ctags $
(find
%s -name
"*.[ch]")' % source_root
1221 print("Running: %s" % cmd)
1222 ret = samba_utils.RUN_COMMAND(cmd)
1224 print('ctags failed with exit status
%d' % ret)