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)
101 opt
.add_option('--enable-pcap',
102 help=("Use pcap for packet capture (default=no)"),
103 action
="store_true", dest
='ctdb_pcap', default
=False)
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 Options
.options
.ctdb_pcap
or not sys
.platform
.startswith('linux'):
205 conf
.DEFINE('ENABLE_PCAP', 1)
206 if not conf
.env
.ENABLE_PCAP
:
207 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
209 conf
.find_program('pcap-config', var
='PCAP_CONFIG')
210 if conf
.env
.PCAP_CONFIG
:
211 conf
.CHECK_CFG(path
=conf
.env
.PCAP_CONFIG
,
212 args
="--cflags --libs",
215 if not conf
.CHECK_HEADERS('pcap.h'):
216 Logs
.error('Need libpcap')
218 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
219 Logs
.error('Need libpcap')
221 conf
.CHECK_FUNCS_IN('pcap_set_immediate_mode', 'pcap', headers
='pcap.h')
223 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
224 checklibc
=True, headers
='execinfo.h'):
225 Logs
.error('backtrace support not available')
228 if Options
.options
.ctdb_pmda
:
231 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
234 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
236 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
239 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
242 Logs
.error("PMDA support not available")
245 Logs
.info('Building with PMDA support')
246 conf
.define('HAVE_PMDA', 1)
247 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
248 'lib/pcp/pmdas/ctdb')
250 have_infiniband
= False
251 if Options
.options
.ctdb_infiniband
:
254 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
256 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
258 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
261 have_infiniband
= True
263 Logs
.error("Infiniband support not available")
266 Logs
.info('Building with Infiniband support')
267 conf
.define('HAVE_INFINIBAND', 1)
268 conf
.define('USE_INFINIBAND', 1)
270 have_etcd_reclock
= False
271 if Options
.options
.ctdb_etcd_reclock
:
273 conf
.check_python_module('etcd')
274 have_etcd_reclock
= True
276 Logs
.error('etcd support not available')
278 if have_etcd_reclock
:
279 Logs
.info('Building with etcd support')
280 conf
.env
.etcd_reclock
= have_etcd_reclock
282 if Options
.options
.ctdb_ceph_reclock
:
283 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
284 conf
.CHECK_LIB('rados', shlib
=True)):
285 Logs
.info('Building with Ceph librados recovery lock support')
286 conf
.define('HAVE_LIBRADOS', 1)
288 Logs
.error("Missing librados for Ceph recovery lock support")
291 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
292 conf
.env
.CTDB_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'share/ctdb')
293 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
294 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
295 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
296 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
298 if Options
.options
.ctdb_logdir
:
299 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
301 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
303 if Options
.options
.ctdb_sockpath
:
304 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
306 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
308 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
310 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
312 -DCTDB_DATADIR=\"%s\"
315 -DCTDB_RUNDIR=\"%s\"''' % (
316 conf
.env
.CTDB_HELPER_BINDIR
,
317 conf
.env
.CTDB_LOGDIR
,
318 conf
.env
.CTDB_DATADIR
,
319 conf
.env
.CTDB_ETCDIR
,
320 conf
.env
.CTDB_VARDIR
,
321 conf
.env
.CTDB_RUNDIR
))
323 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.CTDB_DATADIR
, 'tests')
324 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
326 # Allow unified compilation and separate compilation of utilities
328 if not conf
.env
.standalone_ctdb
:
329 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
331 if Context
.g_module
.top
== '.':
332 # Building from tarball
333 conf
.ADD_EXTRA_INCLUDES('#include')
335 # Building standalone CTDB from within Samba tree
336 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
337 conf
.ADD_EXTRA_INCLUDES('#ctdb')
338 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
340 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
341 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
342 conf
.SAMBA_CONFIG_H()
344 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
345 conf
.env
.ctdb_generate_manpages
= True
347 conf
.env
.ctdb_generate_manpages
= False
349 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
350 conf
.env
.ctdb_prebuilt_manpages
= []
351 manpages
= manpages_binary
+ manpages_misc
352 if conf
.env
.etcd_reclock
:
353 manpages
+= manpages_etcd
354 if conf
.env
.HAVE_LIBRADOS
:
355 manpages
+= manpages_ceph
357 if os
.path
.exists(os
.path
.join("doc", m
)):
358 Logs
.info(" %s: yes" % (m
))
359 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
361 Logs
.info(" %s: no" % (m
))
364 if bld
.env
.standalone_ctdb
:
365 # enable building of public headers in the build tree
366 bld
.env
.build_public_headers
= 'include/public'
368 if bld
.env
.standalone_ctdb
:
369 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
371 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
373 bld
.RECURSE('lib/replace')
374 if bld
.CHECK_FOR_THIRD_PARTY():
375 bld
.RECURSE('third_party/popt')
376 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
377 bld
.RECURSE('third_party/socket_wrapper')
379 bld
.RECURSE('lib/tdb_wrap')
380 bld
.RECURSE('lib/util')
381 bld
.RECURSE('lib/async_req')
382 bld
.RECURSE('lib/pthreadpool')
383 bld
.RECURSE('lib/messaging')
385 bld
.RECURSE('lib/talloc')
386 bld
.RECURSE('lib/tevent')
387 bld
.RECURSE('lib/tdb')
389 if bld
.env
.standalone_ctdb
:
390 # If a combined build is implemented, CTDB will want to
391 # build against samba-util rather than samba-util-core.
392 # Similarly, other Samba subsystems expect samba-util. So,
393 # for a standalone build, just define a fake samba-util
394 # subsystem that pulls in samba-util-core.
395 bld
.SAMBA_SUBSYSTEM('samba-util',
397 deps
='samba-util-core')
399 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
400 source
=bld
.SUBDIR('tcp',
401 'tcp_connect.c tcp_init.c tcp_io.c'),
403 deps
='replace tdb talloc tevent ctdb-protocol-util')
406 if bld
.env
.HAVE_INFINIBAND
:
407 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
408 source
=bld
.SUBDIR('ib',
409 '''ibwrapper.c ibw_ctdb.c
412 deps
='replace talloc tevent tdb')
413 ib_deps
= ' ctdb-ib rdmacm ibverbs'
415 bld
.SAMBA_SUBSYSTEM('ctdb-system',
416 source
=bld
.SUBDIR('common',
417 'system_socket.c system.c'),
418 deps
='replace talloc tevent tdb pcap samba-util')
420 bld
.SAMBA_SUBSYSTEM('ctdb-common',
421 source
=bld
.SUBDIR('common',
422 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
425 deps
='''replace popt talloc tevent tdb popt ctdb-system
426 ctdb-protocol-util''')
428 bld
.SAMBA_SUBSYSTEM('ctdb-util',
429 source
=bld
.SUBDIR('common',
460 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
461 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
464 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
465 source
=bld
.SUBDIR('protocol',
466 '''protocol_header.c protocol_packet.c
476 deps
='ctdb-protocol-basic replace talloc tdb')
478 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
479 source
='protocol/protocol_util.c',
480 deps
='replace talloc tdb')
482 bld
.SAMBA_SUBSYSTEM('ctdb-client',
483 source
=bld
.SUBDIR('client',
484 '''client_connect.c client_call.c
485 client_message.c client_control.c
486 client_message_sync.c
487 client_control_sync.c
488 client_db.c client_util.c
491 deps
='''ctdb-protocol
501 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
502 source
=bld
.SUBDIR('common',
503 '''sock_daemon.c'''),
504 deps
='''samba-util ctdb-util ctdb-system tevent-util
505 LIBASYNC_REQ replace talloc tevent''')
507 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
508 source
=bld
.SUBDIR('server',
509 '''ipalloc_deterministic.c
510 ipalloc_nondeterministic.c
516 deps
='ctdb-protocol-util replace talloc tevent')
518 bld
.SAMBA_BINARY('ctdb-path',
519 source
='common/path_tool.c',
520 cflags
='-DCTDB_PATH_TOOL',
521 deps
='''ctdb-util samba-util talloc replace popt''',
522 install_path
='${CTDB_HELPER_BINDIR}')
524 bld
.SAMBA_SUBSYSTEM('ctdb-conf',
525 source
='''conf/conf.c
534 deps
='''ctdb-util talloc replace''')
536 bld
.SAMBA_SUBSYSTEM('ctdb-conf-util',
537 source
='''conf/node.c
539 deps
='''ctdb-protocol
546 bld
.SAMBA_BINARY('ctdb-config',
547 source
='conf/conf_tool.c',
548 cflags
='-DCTDB_CONF_TOOL',
550 ctdb-util samba-util talloc replace popt''',
551 install_path
='${CTDB_HELPER_BINDIR}')
553 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
554 source
=bld
.SUBDIR('event',
556 event_protocol_util.c
558 deps
='ctdb-protocol-basic')
560 bld
.SAMBA_LIBRARY('ctdb-event-client',
561 source
='event/event_client.c',
562 deps
='ctdb-event-protocol ctdb-util tevent talloc',
563 private_library
=True)
565 bld
.SAMBA_BINARY('ctdb-eventd',
566 source
=bld
.SUBDIR('event',
573 deps
='''ctdb-event-protocol
575 ctdb-server-util samba-util ctdb-util
576 talloc tevent replace popt''',
577 install_path
='${CTDB_HELPER_BINDIR}')
579 bld
.SAMBA_BINARY('ctdb-event',
580 source
='event/event_tool.c',
581 cflags
='-DCTDB_EVENT_TOOL',
582 deps
='''ctdb-event-client ctdb-event-protocol
583 ctdb-util samba-util talloc replace''',
584 install_path
='${CTDB_HELPER_BINDIR}')
586 bld
.SAMBA_BINARY('ctdbd',
587 source
='server/ctdbd.c ' +
589 '''ctdb_daemon.c ctdb_recoverd.c
590 ctdb_recover.c ctdb_freeze.c
591 ctdb_tunables.c ctdb_monitor.c
592 ctdb_server.c ctdb_control.c
593 ctdb_call.c ctdb_ltdb_server.c
594 ctdb_traverse.c eventscript.c
596 ctdb_persistent.c ctdb_keepalive.c
600 ctdb_vacuum.c ctdb_banning.c
603 ctdb_lock.c ctdb_fork.c
604 ctdb_tunnel.c ctdb_client.c
625 install_path
='${SBINDIR}',
628 bld
.SAMBA_BINARY('ctdb',
629 source
='tools/ctdb.c',
641 install_path
='${BINDIR}',
644 bld
.SAMBA_BINARY('ctdb_killtcp',
645 source
='tools/ctdb_killtcp.c',
646 deps
='''ctdb-protocol-util ctdb-util ctdb-system
647 samba-util replace''',
648 install_path
='${CTDB_HELPER_BINDIR}')
650 bld
.SAMBA_BINARY('ltdbtool',
651 source
='tools/ltdbtool.c',
654 install_path
='${BINDIR}',
655 manpages
='ltdbtool.1')
657 bld
.SAMBA_BINARY('ctdb_lock_helper',
658 source
='server/ctdb_lock_helper.c',
659 deps
='''samba-util sys_rw ctdb-system tevent-util
660 talloc tevent tdb''',
662 install_path
='${CTDB_HELPER_BINDIR}')
664 bld
.SAMBA_BINARY('ctdb_recovery_helper',
665 source
='server/ctdb_recovery_helper.c',
666 deps
='''ctdb-client ctdb-protocol ctdb-util
667 samba-util sys_rw replace tdb''',
668 install_path
='${CTDB_HELPER_BINDIR}')
670 bld
.SAMBA_BINARY("statd_callout",
671 source
="failover/statd_callout.c",
672 install_path
="${CTDB_HELPER_BINDIR}")
674 bld
.SAMBA_BINARY('ctdb_takeover_helper',
675 source
='server/ctdb_takeover_helper.c',
676 deps
='''ctdb-client ctdb-protocol ctdb-util
677 samba-util sys_rw replace ctdb-ipalloc popt''',
678 install_path
='${CTDB_HELPER_BINDIR}')
680 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
681 source
='server/ctdb_mutex_fcntl_helper.c',
682 deps
='''sys_rw ctdb-system tevent-util ctdb-util
686 install_path
='${CTDB_HELPER_BINDIR}')
688 bld
.SAMBA_BINARY('ctdb_smnotify_helper',
689 source
=('failover/smnotify_helper.c'),
690 deps
='sys_rw replace',
691 install_path
='${CTDB_HELPER_BINDIR}')
693 bld
.SAMBA_BINARY('ping_pong',
694 source
='utils/ping_pong/ping_pong.c',
696 install_path
='${BINDIR}',
697 manpages
='ping_pong.1')
699 if bld
.env
.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER
:
700 bld
.SAMBA_BINARY('tdb_mutex_check',
701 source
='utils/tdb/tdb_mutex_check.c',
703 install_path
='${CTDB_HELPER_BINDIR}')
705 if bld
.env
.HAVE_PMDA
:
706 bld
.SAMBA_BINARY('pmdactdb',
707 source
='utils/pmda/pmda_ctdb.c',
708 deps
='''ctdb-client ctdb-protocol ctdb-util
709 samba-util pcp_pmda pcp''',
710 install_path
='${CTDB_PMDADIR}')
711 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
713 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
715 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
717 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
719 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
721 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
724 if bld
.env
.HAVE_LIBRADOS
:
725 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
726 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
727 deps
='talloc tevent rados',
729 install_path
='${CTDB_HELPER_BINDIR}')
731 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
732 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
733 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
734 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
735 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
736 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
737 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
738 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
739 sed_cmdline
= '-e "%s" ' * 8 % \
740 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
741 sed_expr6
, sed_expr7
, sed_expr8
)
743 manpages_extra
= list(manpages_misc
)
744 if bld
.env
.etcd_reclock
:
745 manpages_extra
+= manpages_etcd
746 if bld
.env
.HAVE_LIBRADOS
:
747 manpages_extra
+= manpages_ceph
748 for f
in manpages_binary
+ manpages_extra
:
750 bld
.SAMBA_GENERATOR(x
,
751 source
=os
.path
.join('doc', x
),
753 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
755 if bld
.env
.ctdb_generate_manpages
:
756 bld
.MANPAGES(' '.join(manpages_extra
), True)
758 for m
in bld
.env
.ctdb_prebuilt_manpages
:
759 bld
.SAMBA_GENERATOR(m
,
760 source
=os
.path
.join("doc", m
),
762 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
763 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
765 bld
.SAMBA_GENERATOR('ctdb-onnode',
766 source
='tools/onnode',
768 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
769 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
770 destname
='onnode', chmod
=MODE_755
)
772 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
773 source
='tools/ctdb_diagnostics',
774 target
='ctdb_diagnostics',
775 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
776 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
777 destname
='ctdb_diagnostics', chmod
=MODE_755
)
779 if bld
.env
.etcd_reclock
:
780 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
781 source
='utils/etcd/ctdb_etcd_lock',
782 target
='ctdb_etcd_lock',
783 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
784 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
785 destname
='ctdb_etcd_lock', chmod
=MODE_744
)
787 bld
.SAMBA_GENERATOR('ctdb-natgw',
788 source
='tools/ctdb_natgw',
790 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
791 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
792 destname
='ctdb_natgw', chmod
=MODE_755
)
794 bld
.SAMBA_GENERATOR('ctdb-lvs',
795 source
='tools/ctdb_lvs',
797 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
798 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
799 destname
='ctdb_lvs', chmod
=MODE_755
)
801 bld
.SAMBA_GENERATOR("ctdb-statd-callout-helper",
802 source
="tools/statd_callout_helper",
803 target
="statd_callout_helper",
804 rule
=f
"sed {sed_cmdline} ${{SRC}} > ${{TGT}}")
805 bld
.INSTALL_FILES("${CTDB_HELPER_BINDIR}", "statd_callout_helper",
806 destname
="statd_callout_helper", chmod
=MODE_755
)
808 bld
.symlink_as(os
.path
.join(bld
.env
.CTDB_ETCDIR
, "statd-callout"),
809 os
.path
.join(bld
.env
.CTDB_HELPER_BINDIR
, "statd_callout"))
811 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
813 fl
= os
.path
.join(dirname
, f
)
814 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
816 mode
= os
.lstat(fl
).st_mode
& MODE_777
818 fl
= samba_utils
.os
.path
.relpath(fl
, arg
['trim_path'])
819 arg
['file_list'].append([fl
, mode
])
821 def SUBDIR_MODE(path
, trim_path
=None):
822 pd
= {'trim_path': trim_path
, 'file_list': []}
823 for dirname
, _subdirs
, fnames
in os
.walk(path
):
824 SUBDIR_MODE_callback(pd
, dirname
, fnames
)
825 return pd
['file_list']
827 event_script_subdirs
= [
835 if bld
.env
.standalone_ctdb
:
838 configdir
= 'ctdb/config'
840 for t
in event_script_subdirs
:
841 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
842 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
844 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
845 destname
=fmode
[0], chmod
=fmode
[1])
847 for t
in etc_subdirs
:
848 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
850 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
851 destname
=fmode
[0], chmod
=fmode
[1])
853 # If this is a direct install and there are no event scripts
854 # linked/enabled then enable some standard ones
855 if os
.environ
.get('DESTDIR') is None:
856 fmt
= 'events/legacy/%s.script'
857 required_script
= '00.ctdb'
858 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
859 fmt
% (required_script
))
860 if not os
.path
.islink(required_path
) and \
861 not os
.path
.exists(required_path
):
862 default_scripts
= [ required_script
,
868 for t
in default_scripts
:
869 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
870 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
871 bld
.symlink_as(name
, tgt
)
873 bld
.SAMBA_GENERATOR('ctdb-functions',
874 source
='config/functions',
876 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
877 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
880 'ctdb-backup-persistent-tdbs.sh',
881 'ctdb-crash-cleanup.sh',
882 'debug-hung-script.sh',
884 'nfs-linux-kernel-callout',
888 for t
in etc_scripts
:
889 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
890 destname
=t
, chmod
=MODE_755
)
892 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
893 'config/notification.README',
896 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
897 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
898 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
900 for d
in ['volatile', 'persistent', 'state']:
901 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
904 # Test-only below this point
907 if not bld
.env
.standalone_ctdb
and not bld
.CONFIG_GET('ENABLE_SELFTEST'):
910 bld
.SAMBA_BINARY('errcode',
911 source
='tests/src/errcode.c',
913 install_path
='${CTDB_TEST_LIBEXECDIR}')
915 bld
.SAMBA_BINARY('sigcode',
916 source
='tests/src/sigcode.c',
918 install_path
='${CTDB_TEST_LIBEXECDIR}')
940 for target
in ctdb_util_tests
:
941 src
= 'tests/src/' + target
+ '.c'
943 bld
.SAMBA_BINARY(target
,
945 deps
='''ctdb-tests-backtrace
955 install_path
='${CTDB_TEST_LIBEXECDIR}')
957 bld
.SAMBA_BINARY('reqid_test',
958 source
='tests/src/reqid_test.c',
959 deps
='samba-util talloc',
960 install_path
='${CTDB_TEST_LIBEXECDIR}')
962 bld
.SAMBA_BINARY('rb_test',
963 source
='tests/src/rb_test.c',
964 deps
='samba-util talloc',
965 install_path
='${CTDB_TEST_LIBEXECDIR}')
967 bld
.SAMBA_BINARY('ctdb_packet_parse',
968 source
='tests/src/ctdb_packet_parse.c',
969 deps
='talloc tevent tdb ctdb-protocol',
970 install_path
='${CTDB_TEST_LIBEXECDIR}')
972 bld
.SAMBA_BINARY('system_socket_test',
973 source
='tests/src/system_socket_test.c',
974 deps
='''ctdb-tests-backtrace
979 install_path
='${CTDB_TEST_LIBEXECDIR}')
981 bld
.SAMBA_BINARY('porting_tests',
982 source
='tests/src/porting_tests.c',
983 deps
='samba-util ctdb-system popt',
984 install_path
='${CTDB_TEST_LIBEXECDIR}')
986 bld
.SAMBA_BINARY('sock_daemon_test',
987 source
='tests/src/sock_daemon_test.c',
988 deps
='''ctdb-system talloc tevent tevent-util
989 LIBASYNC_REQ samba-util sys_rw''',
990 install_path
='${CTDB_TEST_LIBEXECDIR}')
992 bld
.SAMBA_BINARY('ctdb_io_test',
993 source
='tests/src/ctdb_io_test.c',
994 deps
='''talloc tevent tdb samba-util sys_rw''',
995 install_path
='${CTDB_TEST_LIBEXECDIR}')
997 bld
.SAMBA_BINARY('ctdb-db-test',
998 source
='tests/src/db_test_tool.c',
999 cflags
='-DCTDB_DB_TEST_TOOL',
1000 deps
='''ctdb-client ctdb-protocol
1001 ctdb-util samba-util talloc tevent replace''',
1002 install_path
='${CTDB_TEST_LIBEXECDIR}')
1004 for target
in ['tmon_ping_test', 'tmon_test']:
1005 src
= 'tests/src/' + target
+ '.c'
1007 bld
.SAMBA_BINARY(target
,
1010 ctdb-tests-backtrace
1020 install_path
='${CTDB_TEST_LIBEXECDIR}')
1022 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
1023 source
=bld
.SUBDIR('tests/src',
1024 'protocol_common_basic.c'),
1025 deps
='samba-util replace talloc')
1027 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
1028 source
=bld
.SUBDIR('tests/src',
1029 '''protocol_common.c
1030 protocol_common_ctdb.c
1032 deps
='ctdb-protocol-tests-basic replace talloc tdb')
1034 bld
.SAMBA_BINARY('protocol_basic_test',
1035 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
1036 deps
='ctdb-protocol-tests-basic talloc',
1037 install_path
='${CTDB_TEST_LIBEXECDIR}')
1039 ctdb_protocol_tests
= [
1040 'protocol_types_test',
1041 'protocol_ctdb_test',
1042 'protocol_util_test',
1043 'protocol_types_compat_test',
1044 'protocol_ctdb_compat_test',
1047 for target
in ctdb_protocol_tests
:
1048 src
= 'tests/src/' + target
+ '.c'
1050 bld
.SAMBA_BINARY(target
,
1052 deps
='''ctdb-protocol-tests-common
1053 samba-util talloc tdb''',
1054 install_path
='${CTDB_TEST_LIBEXECDIR}')
1056 bld
.SAMBA_BINARY('event_protocol_test',
1057 source
='event/event_protocol_test.c',
1058 deps
='''ctdb-protocol-tests-basic
1059 ctdb-protocol-basic talloc''',
1060 install_path
='${CTDB_TEST_LIBEXECDIR}')
1062 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
1063 source
=bld
.SUBDIR('tests/src',
1075 bld
.SAMBA_SUBSYSTEM('ctdb-tests-backtrace',
1076 source
=bld
.SUBDIR('tests/src',
1077 'test_backtrace.c'),
1089 'fetch_readonly_loop',
1092 'update_record_persistent',
1099 for target
in ctdb_tests
:
1100 src
= 'tests/src/' + target
+ '.c'
1102 bld
.SAMBA_BINARY(target
,
1105 deps
='''ctdb-client ctdb-protocol ctdb-util
1106 samba-util ctdb-tests-common''',
1107 install_path
='${CTDB_TEST_LIBEXECDIR}')
1109 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1110 source
='''tests/src/ctdb_takeover_tests.c
1111 tests/src/ipalloc_read_known_ips.c''',
1112 deps
='''replace popt tdb tevent talloc ctdb-system
1113 samba-util tdb-wrap talloc_report
1114 ctdb-ipalloc ctdb-protocol ctdb-util''',
1116 install_path
='${CTDB_TEST_LIBEXECDIR}')
1118 bld
.SAMBA_BINARY('fake_ctdbd',
1119 source
='''tests/src/fake_ctdbd.c
1120 tests/src/ipalloc_read_known_ips.c''',
1121 deps
='''ctdb-conf-util
1130 install_path
='${CTDB_TEST_LIBEXECDIR}')
1132 bld
.SAMBA_BINARY('cluster_mutex_test',
1133 source
='tests/src/cluster_mutex_test.c',
1134 deps
='''ctdb-tests-backtrace
1139 install_path
='${CTDB_TEST_LIBEXECDIR}')
1141 if bld
.env
.HAVE_INFINIBAND
:
1142 bld
.SAMBA_BINARY('ibwrapper_test',
1143 source
='ib/ibwrapper_test.c',
1145 deps
='replace talloc ctdb-common sys_rw' +
1147 install_path
='${CTDB_TEST_LIBEXECDIR}')
1149 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux') and bld
.env
.DEVELOPER
:
1150 bld
.SAMBA_BINARY('test_mutex_raw',
1151 source
='tests/src/test_mutex_raw.c',
1153 install_path
='${CTDB_TEST_LIBEXECDIR}')
1162 if bld
.env
.standalone_ctdb
:
1165 testdir
= 'ctdb/tests'
1167 for t
in test_subdirs
:
1168 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
1170 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
1171 destname
=fmode
[0], chmod
=fmode
[1])
1173 # Install tests/scripts directory, excluding files that need munging
1178 'integration_local_daemons.bash',
1179 'integration_real_cluster.bash',
1183 for t
in test_scripts
:
1184 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1185 os
.path
.join('tests/scripts', t
),
1186 destname
=os
.path
.join('scripts', t
))
1188 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1189 'tests/scripts/test_wrap',
1190 destname
='scripts/test_wrap',
1193 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1194 source
='tests/scripts/script_install_paths.sh',
1195 target
='script_install_paths.sh',
1196 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1197 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1198 'script_install_paths.sh',
1199 destname
='script_install_paths.sh', chmod
=MODE_644
)
1201 sed_expr1
= 's@^\\(%s\\)=.*@\\1=%s@' % (
1202 'CTDB_TEST_DIR', bld
.env
.CTDB_TEST_DATADIR
)
1203 sed_expr2
= 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1204 bld
.SAMBA_GENERATOR('ctdb-test-runner',
1205 source
='tests/run_tests.sh',
1206 target
='ctdb_run_tests.sh',
1207 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1208 sed_expr1
, sed_expr2
))
1209 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1210 destname
='ctdb_run_tests', chmod
=MODE_755
)
1211 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
1214 bld
.SAMBA_GENERATOR('ctdb-local-daemons',
1215 source
='tests/local_daemons.sh',
1216 target
='ctdb_local_daemons.sh',
1217 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1218 sed_expr1
, sed_expr2
))
1219 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1220 destname
='ctdb_local_daemons', chmod
=MODE_755
)
1224 cmd
= 'tests/run_tests.sh'
1225 ret
= samba_utils
.RUN_COMMAND(cmd
)
1227 print('tests exited with exit status %d' % ret
)
1232 Options
.commands
.append('build')
1233 Options
.commands
.append('testonly')
1237 env
= samba_utils
.LOAD_ENVIRONMENT()
1238 cmd
= 'tests/run_tests.sh -eL -S %s' % env
.SOCKET_WRAPPER_SO_PATH
1239 ret
= samba_utils
.RUN_COMMAND(cmd
)
1241 print('autotest exited with exit status %d' % ret
)
1245 def show_version(ctx
):
1246 print(get_version_string())
1250 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
1251 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
1252 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
1253 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
1254 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1256 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
1257 ret
= samba_utils
.RUN_COMMAND(cmd
)
1259 print('Command %s failed with exit status %d' % (cmd
, ret
))
1262 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
1263 ret
= samba_utils
.RUN_COMMAND(cmd
)
1265 print('Command %s failed with exit status %d' % (cmd
, ret
))
1270 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
1273 sed_expr1
= 's/@VERSION@/%s/g' % get_version_string()
1274 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1275 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1276 sed_expr1
, sed_expr2
, t
)
1277 ret
= samba_utils
.RUN_COMMAND(cmd
)
1279 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1281 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1283 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1285 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1286 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1293 Options
.commands
.append('manpages')
1294 Options
.commands
.append('distonly')
1298 opts
= os
.getenv('RPM_OPTIONS') or ''
1299 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1300 (opts
, get_version_string())
1301 ret
= samba_utils
.RUN_COMMAND(cmd
)
1303 print('rpmbuild exited with exit status %d' % ret
)
1308 Options
.commands
.append('manpages')
1309 Options
.commands
.append('distonly')
1310 Options
.commands
.append('rpmonly')
1314 "build 'tags' file using ctags"
1315 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
1316 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1317 print("Running: %s" % cmd
)
1318 ret
= samba_utils
.RUN_COMMAND(cmd
)
1320 print('ctags failed with exit status %d' % ret
)