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
='''ctdb-protocol-util
413 if bld
.env
.HAVE_INFINIBAND
:
414 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
415 source
=bld
.SUBDIR('ib',
416 '''ibwrapper.c ibw_ctdb.c
419 deps
='replace talloc tevent tdb')
420 ib_deps
= ' ctdb-ib rdmacm ibverbs'
422 bld
.SAMBA_SUBSYSTEM('ctdb-system',
423 source
=bld
.SUBDIR('common',
424 'system_socket.c system.c'),
425 deps
='''ctdb-protocol
435 bld
.SAMBA_SUBSYSTEM('ctdb-common',
436 source
=bld
.SUBDIR('common',
437 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
440 deps
='''replace popt talloc tevent tdb popt ctdb-system
441 ctdb-protocol-util''')
443 bld
.SAMBA_SUBSYSTEM('ctdb-util',
444 source
=bld
.SUBDIR('common',
475 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
476 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
479 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
480 source
=bld
.SUBDIR('protocol',
481 '''protocol_header.c protocol_packet.c
491 deps
='ctdb-protocol-basic replace talloc tdb')
493 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
494 source
='protocol/protocol_util.c',
495 deps
='replace talloc tdb')
497 bld
.SAMBA_SUBSYSTEM('ctdb-client',
498 source
=bld
.SUBDIR('client',
499 '''client_connect.c client_call.c
500 client_message.c client_control.c
501 client_message_sync.c
502 client_control_sync.c
503 client_db.c client_util.c
506 deps
='''ctdb-protocol
516 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
517 source
=bld
.SUBDIR('common',
518 '''sock_daemon.c'''),
519 deps
='''samba-util ctdb-util ctdb-system tevent-util
520 LIBASYNC_REQ replace talloc tevent''')
522 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
523 source
=bld
.SUBDIR('server',
524 '''ipalloc_deterministic.c
525 ipalloc_nondeterministic.c
531 deps
='ctdb-protocol-util replace talloc tevent')
533 bld
.SAMBA_BINARY('ctdb-path',
534 source
='common/path_tool.c',
535 cflags
='-DCTDB_PATH_TOOL',
536 deps
='''ctdb-util samba-util talloc replace popt''',
537 install_path
='${CTDB_HELPER_BINDIR}')
539 bld
.SAMBA_SUBSYSTEM('ctdb-conf',
540 source
='''conf/conf.c
549 deps
='''ctdb-util talloc replace''')
551 bld
.SAMBA_SUBSYSTEM('ctdb-conf-util',
552 source
='''conf/node.c
554 deps
='''ctdb-protocol
561 bld
.SAMBA_BINARY('ctdb-config',
562 source
='conf/conf_tool.c',
563 cflags
='-DCTDB_CONF_TOOL',
565 ctdb-util samba-util talloc replace popt''',
566 install_path
='${CTDB_HELPER_BINDIR}')
568 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
569 source
=bld
.SUBDIR('event',
571 event_protocol_util.c
573 deps
='ctdb-protocol-basic')
575 bld
.SAMBA_LIBRARY('ctdb-event-client',
576 source
='event/event_client.c',
577 deps
='ctdb-event-protocol ctdb-util tevent talloc',
578 private_library
=True)
580 bld
.SAMBA_BINARY('ctdb-eventd',
581 source
=bld
.SUBDIR('event',
588 deps
='''ctdb-event-protocol
590 ctdb-server-util samba-util ctdb-util
591 talloc tevent replace popt''',
592 install_path
='${CTDB_HELPER_BINDIR}')
594 bld
.SAMBA_BINARY('ctdb-event',
595 source
='event/event_tool.c',
596 cflags
='-DCTDB_EVENT_TOOL',
597 deps
='''ctdb-event-client ctdb-event-protocol
598 ctdb-util samba-util talloc replace''',
599 install_path
='${CTDB_HELPER_BINDIR}')
601 bld
.SAMBA_BINARY('ctdbd',
602 source
='server/ctdbd.c ' +
604 '''ctdb_daemon.c ctdb_recoverd.c
605 ctdb_recover.c ctdb_freeze.c
606 ctdb_tunables.c ctdb_monitor.c
607 ctdb_server.c ctdb_control.c
608 ctdb_call.c ctdb_ltdb_server.c
609 ctdb_traverse.c eventscript.c
611 ctdb_persistent.c ctdb_keepalive.c
615 ctdb_vacuum.c ctdb_banning.c
618 ctdb_lock.c ctdb_fork.c
619 ctdb_tunnel.c ctdb_client.c
640 install_path
='${SBINDIR}',
643 bld
.SAMBA_BINARY('ctdb',
644 source
='tools/ctdb.c',
656 install_path
='${BINDIR}',
659 bld
.SAMBA_BINARY('ctdb_killtcp',
660 source
='tools/ctdb_killtcp.c',
661 deps
='''ctdb-protocol-util ctdb-util ctdb-system
662 samba-util replace''',
663 install_path
='${CTDB_HELPER_BINDIR}')
665 bld
.SAMBA_BINARY('ltdbtool',
666 source
='tools/ltdbtool.c',
669 install_path
='${BINDIR}',
670 manpages
='ltdbtool.1')
672 bld
.SAMBA_BINARY('ctdb_lock_helper',
673 source
='server/ctdb_lock_helper.c',
674 deps
='''samba-util sys_rw ctdb-system tevent-util
675 talloc tevent tdb''',
677 install_path
='${CTDB_HELPER_BINDIR}')
679 bld
.SAMBA_BINARY('ctdb_recovery_helper',
680 source
='server/ctdb_recovery_helper.c',
681 deps
='''ctdb-client ctdb-protocol ctdb-util
682 samba-util sys_rw replace tdb''',
683 install_path
='${CTDB_HELPER_BINDIR}')
685 bld
.SAMBA_BINARY("statd_callout",
686 source
="failover/statd_callout.c",
687 install_path
="${CTDB_HELPER_BINDIR}")
689 bld
.SAMBA_BINARY('ctdb_takeover_helper',
690 source
='server/ctdb_takeover_helper.c',
691 deps
='''ctdb-client ctdb-protocol ctdb-util
692 samba-util sys_rw replace ctdb-ipalloc popt''',
693 install_path
='${CTDB_HELPER_BINDIR}')
695 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
696 source
='server/ctdb_mutex_fcntl_helper.c',
697 deps
='''sys_rw ctdb-system tevent-util ctdb-util
701 install_path
='${CTDB_HELPER_BINDIR}')
703 bld
.SAMBA_BINARY('ctdb_smnotify_helper',
704 source
=('failover/smnotify_helper.c'),
705 deps
='sys_rw replace',
706 install_path
='${CTDB_HELPER_BINDIR}')
708 bld
.SAMBA_BINARY('ping_pong',
709 source
='utils/ping_pong/ping_pong.c',
711 install_path
='${BINDIR}',
712 manpages
='ping_pong.1')
714 if bld
.env
.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER
:
715 bld
.SAMBA_BINARY('tdb_mutex_check',
716 source
='utils/tdb/tdb_mutex_check.c',
718 install_path
='${CTDB_HELPER_BINDIR}')
720 if bld
.env
.HAVE_PMDA
:
721 bld
.SAMBA_BINARY('pmdactdb',
722 source
='utils/pmda/pmda_ctdb.c',
723 deps
='''ctdb-client ctdb-protocol ctdb-util
724 samba-util pcp_pmda pcp''',
725 install_path
='${CTDB_PMDADIR}')
726 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
728 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
730 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
732 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
734 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
736 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
739 if bld
.env
.HAVE_LIBRADOS
:
740 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
741 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
742 deps
='talloc tevent rados',
744 install_path
='${CTDB_HELPER_BINDIR}')
746 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
747 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
748 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
749 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
750 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
751 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
752 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
753 sed_expr8
= 's|/usr/local/share/ctdb|%s|g' % (bld
.env
.CTDB_DATADIR
)
754 sed_cmdline
= '-e "%s" ' * 8 % \
755 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
756 sed_expr6
, sed_expr7
, sed_expr8
)
758 manpages_extra
= list(manpages_misc
)
759 if bld
.env
.etcd_reclock
:
760 manpages_extra
+= manpages_etcd
761 if bld
.env
.HAVE_LIBRADOS
:
762 manpages_extra
+= manpages_ceph
763 for f
in manpages_binary
+ manpages_extra
:
765 bld
.SAMBA_GENERATOR(x
,
766 source
=os
.path
.join('doc', x
),
768 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
770 if bld
.env
.ctdb_generate_manpages
:
771 bld
.MANPAGES(' '.join(manpages_extra
), True)
773 for m
in bld
.env
.ctdb_prebuilt_manpages
:
774 bld
.SAMBA_GENERATOR(m
,
775 source
=os
.path
.join("doc", m
),
777 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
778 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
780 bld
.SAMBA_GENERATOR('ctdb-onnode',
781 source
='tools/onnode',
783 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
784 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
785 destname
='onnode', chmod
=MODE_755
)
787 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
788 source
='tools/ctdb_diagnostics',
789 target
='ctdb_diagnostics',
790 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
791 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
792 destname
='ctdb_diagnostics', chmod
=MODE_755
)
794 if bld
.env
.etcd_reclock
:
795 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
796 source
='utils/etcd/ctdb_etcd_lock',
797 target
='ctdb_etcd_lock',
798 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
799 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
800 destname
='ctdb_etcd_lock', chmod
=MODE_744
)
802 bld
.SAMBA_GENERATOR('ctdb-natgw',
803 source
='tools/ctdb_natgw',
805 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
806 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
807 destname
='ctdb_natgw', chmod
=MODE_755
)
809 bld
.SAMBA_GENERATOR('ctdb-lvs',
810 source
='tools/ctdb_lvs',
812 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
813 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
814 destname
='ctdb_lvs', chmod
=MODE_755
)
816 bld
.SAMBA_GENERATOR("ctdb-statd-callout-helper",
817 source
="tools/statd_callout_helper",
818 target
="statd_callout_helper",
819 rule
=f
"sed {sed_cmdline} ${{SRC}} > ${{TGT}}")
820 bld
.INSTALL_FILES("${CTDB_HELPER_BINDIR}", "statd_callout_helper",
821 destname
="statd_callout_helper", chmod
=MODE_755
)
823 bld
.symlink_as(os
.path
.join(bld
.env
.CTDB_ETCDIR
, "statd-callout"),
824 os
.path
.join(bld
.env
.CTDB_HELPER_BINDIR
, "statd_callout"))
826 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
828 fl
= os
.path
.join(dirname
, f
)
829 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
831 mode
= os
.lstat(fl
).st_mode
& MODE_777
833 fl
= samba_utils
.os
.path
.relpath(fl
, arg
['trim_path'])
834 arg
['file_list'].append([fl
, mode
])
836 def SUBDIR_MODE(path
, trim_path
=None):
837 pd
= {'trim_path': trim_path
, 'file_list': []}
838 for dirname
, _subdirs
, fnames
in os
.walk(path
):
839 SUBDIR_MODE_callback(pd
, dirname
, fnames
)
840 return pd
['file_list']
842 event_script_subdirs
= [
850 if bld
.env
.standalone_ctdb
:
853 configdir
= 'ctdb/config'
855 for t
in event_script_subdirs
:
856 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
857 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
859 bld
.INSTALL_FILES(bld
.env
.CTDB_DATADIR
, 'config/%s' % fmode
[0],
860 destname
=fmode
[0], chmod
=fmode
[1])
862 for t
in etc_subdirs
:
863 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
865 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
866 destname
=fmode
[0], chmod
=fmode
[1])
868 # If this is a direct install and there are no event scripts
869 # linked/enabled then enable some standard ones
870 if os
.environ
.get('DESTDIR') is None:
871 fmt
= 'events/legacy/%s.script'
872 required_script
= '00.ctdb'
873 required_path
= os
.path
.join(bld
.env
.CTDB_ETCDIR
,
874 fmt
% (required_script
))
875 if not os
.path
.islink(required_path
) and \
876 not os
.path
.exists(required_path
):
877 default_scripts
= [ required_script
,
883 for t
in default_scripts
:
884 tgt
= os
.path
.join(bld
.env
.CTDB_DATADIR
, fmt
% (t
))
885 name
= os
.path
.join(bld
.env
.CTDB_ETCDIR
, fmt
% (t
))
886 bld
.symlink_as(name
, tgt
)
888 bld
.SAMBA_GENERATOR('ctdb-functions',
889 source
='config/functions',
891 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
892 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
895 'ctdb-backup-persistent-tdbs.sh',
896 'ctdb-crash-cleanup.sh',
897 'debug-hung-script.sh',
899 'nfs-linux-kernel-callout',
903 for t
in etc_scripts
:
904 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
905 destname
=t
, chmod
=MODE_755
)
907 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
908 'config/notification.README',
911 bld
.INSTALL_DIR(bld
.env
.CTDB_LOGDIR
)
912 bld
.INSTALL_DIR(bld
.env
.CTDB_RUNDIR
)
913 bld
.INSTALL_DIR(bld
.env
.CTDB_VARDIR
)
915 for d
in ['volatile', 'persistent', 'state']:
916 bld
.INSTALL_DIR(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
919 # Test-only below this point
922 if not bld
.env
.standalone_ctdb
and not bld
.CONFIG_GET('ENABLE_SELFTEST'):
925 bld
.SAMBA_BINARY('errcode',
926 source
='tests/src/errcode.c',
928 install_path
='${CTDB_TEST_LIBEXECDIR}')
930 bld
.SAMBA_BINARY('sigcode',
931 source
='tests/src/sigcode.c',
933 install_path
='${CTDB_TEST_LIBEXECDIR}')
955 for target
in ctdb_util_tests
:
956 src
= 'tests/src/' + target
+ '.c'
958 bld
.SAMBA_BINARY(target
,
960 deps
='''ctdb-tests-backtrace
970 install_path
='${CTDB_TEST_LIBEXECDIR}')
972 bld
.SAMBA_BINARY('reqid_test',
973 source
='tests/src/reqid_test.c',
974 deps
='samba-util talloc',
975 install_path
='${CTDB_TEST_LIBEXECDIR}')
977 bld
.SAMBA_BINARY('rb_test',
978 source
='tests/src/rb_test.c',
979 deps
='samba-util talloc',
980 install_path
='${CTDB_TEST_LIBEXECDIR}')
982 bld
.SAMBA_BINARY('ctdb_packet_parse',
983 source
='tests/src/ctdb_packet_parse.c',
984 deps
='talloc tevent tdb ctdb-protocol',
985 install_path
='${CTDB_TEST_LIBEXECDIR}')
987 bld
.SAMBA_BINARY('system_socket_test',
988 source
='tests/src/system_socket_test.c',
989 deps
='''ctdb-tests-backtrace
994 install_path
='${CTDB_TEST_LIBEXECDIR}')
996 bld
.SAMBA_BINARY('porting_tests',
997 source
='tests/src/porting_tests.c',
998 deps
='samba-util ctdb-system popt',
999 install_path
='${CTDB_TEST_LIBEXECDIR}')
1001 bld
.SAMBA_BINARY('sock_daemon_test',
1002 source
='tests/src/sock_daemon_test.c',
1003 deps
='''ctdb-system talloc tevent tevent-util
1004 LIBASYNC_REQ samba-util sys_rw''',
1005 install_path
='${CTDB_TEST_LIBEXECDIR}')
1007 bld
.SAMBA_BINARY('ctdb_io_test',
1008 source
='tests/src/ctdb_io_test.c',
1009 deps
='''talloc tevent tdb samba-util sys_rw''',
1010 install_path
='${CTDB_TEST_LIBEXECDIR}')
1012 bld
.SAMBA_BINARY('ctdb-db-test',
1013 source
='tests/src/db_test_tool.c',
1014 cflags
='-DCTDB_DB_TEST_TOOL',
1015 deps
='''ctdb-client ctdb-protocol
1016 ctdb-util samba-util talloc tevent replace''',
1017 install_path
='${CTDB_TEST_LIBEXECDIR}')
1019 for target
in ['tmon_ping_test', 'tmon_test']:
1020 src
= 'tests/src/' + target
+ '.c'
1022 bld
.SAMBA_BINARY(target
,
1025 ctdb-tests-backtrace
1035 install_path
='${CTDB_TEST_LIBEXECDIR}')
1037 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
1038 source
=bld
.SUBDIR('tests/src',
1039 'protocol_common_basic.c'),
1040 deps
='samba-util replace talloc')
1042 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
1043 source
=bld
.SUBDIR('tests/src',
1044 '''protocol_common.c
1045 protocol_common_ctdb.c
1047 deps
='ctdb-protocol-tests-basic replace talloc tdb')
1049 bld
.SAMBA_BINARY('protocol_basic_test',
1050 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
1051 deps
='ctdb-protocol-tests-basic talloc',
1052 install_path
='${CTDB_TEST_LIBEXECDIR}')
1054 ctdb_protocol_tests
= [
1055 'protocol_types_test',
1056 'protocol_ctdb_test',
1057 'protocol_util_test',
1058 'protocol_types_compat_test',
1059 'protocol_ctdb_compat_test',
1062 for target
in ctdb_protocol_tests
:
1063 src
= 'tests/src/' + target
+ '.c'
1065 bld
.SAMBA_BINARY(target
,
1067 deps
='''ctdb-protocol-tests-common
1068 samba-util talloc tdb''',
1069 install_path
='${CTDB_TEST_LIBEXECDIR}')
1071 bld
.SAMBA_BINARY('event_protocol_test',
1072 source
='event/event_protocol_test.c',
1073 deps
='''ctdb-protocol-tests-basic
1074 ctdb-protocol-basic talloc''',
1075 install_path
='${CTDB_TEST_LIBEXECDIR}')
1077 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
1078 source
=bld
.SUBDIR('tests/src',
1090 bld
.SAMBA_SUBSYSTEM('ctdb-tests-backtrace',
1091 source
=bld
.SUBDIR('tests/src',
1092 'test_backtrace.c'),
1104 'fetch_readonly_loop',
1107 'update_record_persistent',
1114 for target
in ctdb_tests
:
1115 src
= 'tests/src/' + target
+ '.c'
1117 bld
.SAMBA_BINARY(target
,
1120 deps
='''ctdb-client ctdb-protocol ctdb-util
1121 samba-util ctdb-tests-common''',
1122 install_path
='${CTDB_TEST_LIBEXECDIR}')
1124 bld
.SAMBA_BINARY('ctdb_takeover_tests',
1125 source
='''tests/src/ctdb_takeover_tests.c
1126 tests/src/ipalloc_read_known_ips.c''',
1127 deps
='''replace popt tdb tevent talloc ctdb-system
1128 samba-util tdb-wrap talloc_report
1129 ctdb-ipalloc ctdb-protocol ctdb-util''',
1131 install_path
='${CTDB_TEST_LIBEXECDIR}')
1133 bld
.SAMBA_BINARY('fake_ctdbd',
1134 source
='''tests/src/fake_ctdbd.c
1135 tests/src/ipalloc_read_known_ips.c''',
1136 deps
='''ctdb-conf-util
1145 install_path
='${CTDB_TEST_LIBEXECDIR}')
1147 bld
.SAMBA_BINARY('cluster_mutex_test',
1148 source
='tests/src/cluster_mutex_test.c',
1149 deps
='''ctdb-tests-backtrace
1154 install_path
='${CTDB_TEST_LIBEXECDIR}')
1156 if bld
.env
.HAVE_INFINIBAND
:
1157 bld
.SAMBA_BINARY('ibwrapper_test',
1158 source
='ib/ibwrapper_test.c',
1160 deps
='replace talloc ctdb-common sys_rw' +
1162 install_path
='${CTDB_TEST_LIBEXECDIR}')
1164 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux') and bld
.env
.DEVELOPER
:
1165 bld
.SAMBA_BINARY('test_mutex_raw',
1166 source
='tests/src/test_mutex_raw.c',
1168 install_path
='${CTDB_TEST_LIBEXECDIR}')
1177 if bld
.env
.standalone_ctdb
:
1180 testdir
= 'ctdb/tests'
1182 for t
in test_subdirs
:
1183 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
1185 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
1186 destname
=fmode
[0], chmod
=fmode
[1])
1188 # Install tests/scripts directory, excluding files that need munging
1193 'integration_local_daemons.bash',
1194 'integration_real_cluster.bash',
1198 for t
in test_scripts
:
1199 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1200 os
.path
.join('tests/scripts', t
),
1201 destname
=os
.path
.join('scripts', t
))
1203 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1204 'tests/scripts/test_wrap',
1205 destname
='scripts/test_wrap',
1208 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1209 source
='tests/scripts/script_install_paths.sh',
1210 target
='script_install_paths.sh',
1211 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1212 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1213 'script_install_paths.sh',
1214 destname
='script_install_paths.sh', chmod
=MODE_644
)
1216 sed_expr1
= 's@^\\(%s\\)=.*@\\1=%s@' % (
1217 'CTDB_TEST_DIR', bld
.env
.CTDB_TEST_DATADIR
)
1218 sed_expr2
= 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1219 bld
.SAMBA_GENERATOR('ctdb-test-runner',
1220 source
='tests/run_tests.sh',
1221 target
='ctdb_run_tests.sh',
1222 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1223 sed_expr1
, sed_expr2
))
1224 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1225 destname
='ctdb_run_tests', chmod
=MODE_755
)
1226 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
1229 bld
.SAMBA_GENERATOR('ctdb-local-daemons',
1230 source
='tests/local_daemons.sh',
1231 target
='ctdb_local_daemons.sh',
1232 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1233 sed_expr1
, sed_expr2
))
1234 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1235 destname
='ctdb_local_daemons', chmod
=MODE_755
)
1239 cmd
= 'tests/run_tests.sh'
1240 ret
= samba_utils
.RUN_COMMAND(cmd
)
1242 print('tests exited with exit status %d' % ret
)
1247 Options
.commands
.append('build')
1248 Options
.commands
.append('testonly')
1252 env
= samba_utils
.LOAD_ENVIRONMENT()
1253 cmd
= 'tests/run_tests.sh -eL -S %s' % env
.SOCKET_WRAPPER_SO_PATH
1254 ret
= samba_utils
.RUN_COMMAND(cmd
)
1256 print('autotest exited with exit status %d' % ret
)
1260 def show_version(ctx
):
1261 print(get_version_string())
1265 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
1266 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
1267 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
1268 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
1269 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1271 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
1272 ret
= samba_utils
.RUN_COMMAND(cmd
)
1274 print('Command %s failed with exit status %d' % (cmd
, ret
))
1277 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
1278 ret
= samba_utils
.RUN_COMMAND(cmd
)
1280 print('Command %s failed with exit status %d' % (cmd
, ret
))
1285 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
1288 sed_expr1
= 's/@VERSION@/%s/g' % get_version_string()
1289 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1290 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1291 sed_expr1
, sed_expr2
, t
)
1292 ret
= samba_utils
.RUN_COMMAND(cmd
)
1294 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1296 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1298 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1300 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1301 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1308 Options
.commands
.append('manpages')
1309 Options
.commands
.append('distonly')
1313 opts
= os
.getenv('RPM_OPTIONS') or ''
1314 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1315 (opts
, get_version_string())
1316 ret
= samba_utils
.RUN_COMMAND(cmd
)
1318 print('rpmbuild exited with exit status %d' % ret
)
1323 Options
.commands
.append('manpages')
1324 Options
.commands
.append('distonly')
1325 Options
.commands
.append('rpmonly')
1329 "build 'tags' file using ctags"
1330 source_root
= os
.path
.dirname(Context
.g_module
.root_path
)
1331 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1332 print("Running: %s" % cmd
)
1333 ret
= samba_utils
.RUN_COMMAND(cmd
)
1335 print('ctags failed with exit status %d' % ret
)