ctdb-daemon: Move switch_from_server_to_client() to ctdb_daemon.c
[kai/samba-autobuild/.git] / ctdb / wscript
index aaefad3222a2e4ed8a11bd5f25ed8be1a7f1b68f..cea9e42a49ca84d1a2f9ebe0c4b3a3cce18593ed 100755 (executable)
@@ -192,16 +192,15 @@ def configure(conf):
     else:
         conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
                                               'ctdbd.socket')
+    conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
 
     conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
                        -DLOGDIR=\"%s\"
-                       -DSOCKPATH=\"%s\"
                        -DCTDB_ETCDIR=\"%s\"
                        -DCTDB_VARDIR=\"%s\"
                        -DCTDB_RUNDIR=\"%s\"''' % (
                     conf.env.CTDB_BINDIR,
                     conf.env.CTDB_LOGDIR,
-                    conf.env.CTDB_SOCKPATH,
                     conf.env.CTDB_ETCDIR,
                     conf.env.CTDB_VARDIR,
                     conf.env.CTDB_RUNDIR))
@@ -213,16 +212,14 @@ def configure(conf):
     # Allow unified compilation and separate compilation of utilities
     # to find includes
     if not conf.env.standalone_ctdb:
-        conf.ADD_EXTRA_INCLUDES('#ctdb/include')
+        conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
     else:
         if srcdir == '.':
             # Building from tarball
             conf.ADD_EXTRA_INCLUDES('#include')
-            conf.ADD_EXTRA_INCLUDES('#include/internal')
         else:
             # Building standalone CTDB from within Samba tree
             conf.ADD_EXTRA_INCLUDES('#ctdb/include')
-            conf.ADD_EXTRA_INCLUDES('#ctdb/include/internal')
             conf.ADD_EXTRA_INCLUDES('#ctdb')
         conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
 
@@ -230,6 +227,19 @@ def configure(conf):
         conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
         conf.SAMBA_CONFIG_H()
 
+    if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
+        conf.env.ctdb_generate_manpages = True
+    else:
+        conf.env.ctdb_generate_manpages = False
+
+        Logs.info("xsltproc unavailable, checking for pre-built manpages")
+        conf.env.ctdb_prebuilt_manpages = []
+        for m in manpages:
+            if os.path.exists(os.path.join("doc", m)):
+                Logs.info("  %s: yes" % (m))
+                conf.env.ctdb_prebuilt_manpages.append(m)
+            else:
+                Logs.info("  %s: no" % (m))
 
 def build(bld):
     if bld.env.standalone_ctdb:
@@ -260,6 +270,8 @@ def build(bld):
                                 dep_vars=['VERSION'])
         t.env.VERSION = VERSION
 
+    bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
+
     bld.RECURSE('lib/replace')
     if bld.CHECK_FOR_THIRD_PARTY():
         bld.RECURSE('third_party/popt')
@@ -274,7 +286,7 @@ def build(bld):
         bld.RECURSE('lib/socket_wrapper')
 
     if bld.env.standalone_ctdb:
-        # In a combined build is implemented, CTDB will wanted to
+        # If a combined build is implemented, CTDB will want to
         # build against samba-util rather than samba-util-core.
         # Similarly, other Samba subsystems expect samba-util.  So,
         # for a standalone build, just define a fake samba-util
@@ -286,7 +298,7 @@ def build(bld):
     bld.SAMBA_SUBSYSTEM('ctdb-tcp',
                         source=bld.SUBDIR('tcp',
                                           'tcp_connect.c tcp_init.c tcp_io.c'),
-                        includes='include include/internal',
+                        includes='include',
                         deps='replace tdb talloc tevent')
 
     ib_deps = ''
@@ -295,8 +307,8 @@ def build(bld):
                             source=bld.SUBDIR('ib',
                                               '''ibwrapper.c ibw_ctdb.c
                                                  ibw_ctdb_init.c'''),
-                            includes='include include/internal',
-                            deps='replace')
+                            includes='include',
+                            deps='replace talloc tevent')
         ib_deps = ' ctdb-ib rdmacm ibverbs'
 
     if sys.platform.startswith('linux'):
@@ -314,33 +326,57 @@ def build(bld):
 
     bld.SAMBA_SUBSYSTEM('ctdb-system',
                         source='common/system_common.c ' + CTDB_SYSTEM_SRC,
-                        includes='include include/internal',
+                        includes='include',
                         deps='replace talloc tevent tdb pcap')
 
     bld.SAMBA_SUBSYSTEM('ctdb-common',
                         source=bld.SUBDIR('common',
                                           '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
-                                             ctdb_message.c cmdline.c rb_tree.c
+                                             cmdline.c rb_tree.c
                                              ctdb_fork.c'''),
-                        includes='include include/internal common .',
+                        includes='include',
                         deps='replace popt talloc tevent tdb popt ctdb-system')
 
     bld.SAMBA_SUBSYSTEM('ctdb-common-util',
                         source=bld.SUBDIR('common',
                                           'system_util.c ctdb_logging.c'),
-                        includes='include include/internal',
+                        includes='include',
                         deps='replace tevent tdb')
 
     bld.SAMBA_SUBSYSTEM('ctdb-util',
                         source=bld.SUBDIR('common',
-                                          '''db_hash.c srvid.c'''),
-                        deps='replace talloc tevent tdb')
+                                          '''db_hash.c srvid.c reqid.c
+                                             pkt_read.c pkt_write.c comm.c
+                                             logging.c'''),
+                        deps='replace talloc tevent tdb tevent-unix-util')
+
+    bld.SAMBA_SUBSYSTEM('ctdb-protocol',
+                        source=bld.SUBDIR('protocol',
+                                          '''protocol_header.c protocol_packet.c
+                                             protocol_types.c protocol_call.c
+                                             protocol_message.c
+                                             protocol_control.c
+                                             protocol_client.c
+                                             protocol_util.c'''),
+                        includes='include',
+                        deps='replace talloc tdb')
 
     bld.SAMBA_SUBSYSTEM('ctdb-client',
                         source=bld.SUBDIR('client', 'ctdb_client.c'),
-                        includes='include include/internal',
+                        includes='include',
                         deps='''replace popt talloc tevent tdb
-                                samba-util tdb-wrap''')
+                                samba-util tdb-wrap ctdb-util''')
+
+    bld.SAMBA_SUBSYSTEM('ctdb-client2',
+                        source=bld.SUBDIR('client',
+                                          '''client_connect.c client_call.c
+                                             client_message.c client_control.c
+                                             client_message_sync.c
+                                             client_control_sync.c
+                                             client_db.c client_util.c
+                                          '''),
+                        includes='include',
+                        deps='replace talloc tevent tdb tdb-wrap')
 
     bld.SAMBA_SUBSYSTEM('ctdb-server',
                         source='server/ctdbd.c ' +
@@ -361,21 +397,22 @@ def build(bld):
                                              ctdb_statistics.c
                                              ctdb_update_record.c
                                              ctdb_lock.c'''),
-                        includes='include include/internal',
+                        includes='include',
                         deps='replace popt talloc tevent tdb talloc_report')
 
     bld.SAMBA_BINARY('ctdbd',
                      source='',
                      deps='''ctdb-server ctdb-client ctdb-common
-                             ctdb-common-util ctdb-tcp''' +
+                             ctdb-common-util ctdb-tcp ctdb-util''' +
                           ib_deps,
                      install_path='${SBINDIR}',
                      manpages='ctdbd.1')
 
     bld.SAMBA_BINARY('ctdb',
-                     source='tools/ctdb.c tools/ctdb_vacuum.c',
-                     deps='ctdb-client ctdb-common ctdb-common-util',
-                     includes='include include/internal',
+                     source='tools/ctdb.c',
+                     deps='''ctdb-client ctdb-common ctdb-common-util
+                             ctdb-util''',
+                     includes='include',
                      install_path='${BINDIR}',
                      manpages='ctdb.1')
 
@@ -389,15 +426,21 @@ def build(bld):
     bld.SAMBA_BINARY('ctdb_lock_helper',
                      source='server/ctdb_lock_helper.c',
                      deps='samba-util ctdb-common-util talloc tdb',
-                     includes='include include/internal',
+                     includes='include',
                      install_path='${BINDIR}')
 
     bld.SAMBA_BINARY('ctdb_event_helper',
                      source='server/ctdb_event_helper.c',
-                     includes='include include/internal',
+                     includes='include',
                      deps='samba-util ctdb-common-util replace tdb',
                      install_path='${BINDIR}')
 
+    bld.SAMBA_BINARY('ctdb_recovery_helper',
+                     source='server/ctdb_recovery_helper.c',
+                     deps='''ctdb-client2 ctdb-protocol ctdb-util
+                             samba-util replace tdb''',
+                     install_path='${BINDIR}')
+
     bld.SAMBA_GENERATOR('ctdb-smnotify-h',
                         source='utils/smnotify/smnotify.x',
                         target='utils/smnotify/smnotify.h',
@@ -431,7 +474,7 @@ def build(bld):
     if bld.env.HAVE_PMDA:
         bld.SAMBA_BINARY('pmdactdb',
                          source='utils/pmda/pmda_ctdb.c',
-                         includes='include include/internal',
+                         includes='include',
                          deps='''ctdb-client ctdb-common
                                  ctdb-common-util pcp_pmda pcp''',
                          install_path='${CTDB_PMDADIR}')
@@ -463,12 +506,12 @@ def build(bld):
                             target=x,
                             rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
 
-    if 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
+    if bld.env.ctdb_generate_manpages:
         bld.MANPAGES('''onnode.1 ctdbd_wrapper.1 ctdbd.conf.5
                         ctdb.7 ctdb-statistics.7 ctdb-tunables.7''',
                       True)
     else:
-        for m in manpages:
+        for m in bld.env.ctdb_prebuilt_manpages:
             bld.SAMBA_GENERATOR(m,
                                 source=os.path.join("doc", m),
                                 target=m,
@@ -574,6 +617,13 @@ def build(bld):
     ctdb_unit_tests = [
         'db_hash_test',
         'srvid_test',
+        'pkt_read_test',
+        'pkt_write_test',
+        'comm_test',
+        'comm_server_test',
+        'comm_client_test',
+        'protocol_types_test',
+        'protocol_client_test',
     ]
 
     for target in ctdb_unit_tests:
@@ -581,9 +631,14 @@ def build(bld):
 
         bld.SAMBA_BINARY(target,
                          source=src,
-                         deps='talloc tevent tdb',
+                         deps='talloc tevent tdb tevent-unix-util',
                          install_path='${CTDB_TEST_LIBDIR}')
 
+    bld.SAMBA_BINARY('reqid_test',
+                     source='tests/src/reqid_test.c',
+                     deps='samba-util',
+                     install_path='${CTDB_TEST_LIBDIR}')
+
     # Test binaries
     ctdb_tests = [
         'rb_test',
@@ -609,8 +664,9 @@ def build(bld):
 
         bld.SAMBA_BINARY(target,
                          source=src,
-                         includes='include include/internal',
-                         deps='ctdb-client ctdb-common ctdb-common-util',
+                         includes='include',
+                         deps='''ctdb-client ctdb-common ctdb-common-util
+                                 ctdb-util''',
                          install_path='${CTDB_TEST_LIBDIR}')
 
     bld.SAMBA_BINARY('ctdb_takeover_tests',
@@ -618,28 +674,29 @@ def build(bld):
                      deps='''replace popt tdb tevent talloc ctdb-system
                              samba-util tdb-wrap talloc_report''' +
                           ib_deps,
-                     includes='include include/internal',
+                     includes='include',
                      install_path='${CTDB_TEST_LIBDIR}')
 
     bld.SAMBA_BINARY('ctdb_functest',
                      source='tests/src/ctdb_functest.c',
                      deps='''replace tdb tevent talloc popt ctdb-system
                              samba-util tdb-wrap''',
-                     includes='include include/internal',
+                     includes='include',
                      install_path='${CTDB_TEST_LIBDIR}')
 
     bld.SAMBA_BINARY('ctdb_stubtest',
                      source='tests/src/ctdb_test.c',
                      deps='''replace tdb tevent talloc popt ctdb-system
                              samba-util tdb-wrap''',
-                     includes='include include/internal',
+                     includes='include',
                      install_path='${CTDB_TEST_LIBDIR}')
 
     if bld.env.HAVE_INFINIBAND:
         bld.SAMBA_BINARY('ibwrapper_test',
                          source='ib/ibwrapper_test.c',
-                         includes='include include/internal',
-                         deps='replace talloc ctdb-client ctdb-common ' +
+                         includes='include',
+                         deps='''replace talloc ctdb-client ctdb-common
+                                 ctdb-common-util''' +
                               ib_deps,
                          install_path='${CTDB_TEST_LIBDIR}')