build: cope with subsystems with no enabled modules
authorAndrew Tridgell <tridge@samba.org>
Sat, 20 Mar 2010 11:55:04 +0000 (22:55 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:26:58 +0000 (20:26 +1000)
This happens for the notify subsystem on non-Linux systems

buildtools/wafsamba/samba_deps.py
buildtools/wafsamba/wafsamba.py

index b737e65e86dcdba6936b12657cc095d2393cdd0d..a475b448a21506cf9689c377f8e82a8670780340 100644 (file)
@@ -197,14 +197,20 @@ def add_init_functions(self):
 
     sentinal = getattr(self, 'init_function_sentinal', 'NULL')
 
+    targets    = LOCAL_CACHE(bld, 'TARGET_TYPE')
+
     cflags = getattr(self, 'samba_cflags', [])[:]
     for m in modules:
         bld.ASSERT(m in subsystems,
                    "No init_function defined for module '%s' in target '%s'" % (m, self.sname))
         init_fn_list = []
         for d in subsystems[m]:
-            init_fn_list.append(d['INIT_FUNCTION'])
-        cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentinal))
+            if targets[d['TARGET']] != 'DISABLED':
+                init_fn_list.append(d['INIT_FUNCTION'])
+        if init_fn_list == []:
+            cflags.append('-DSTATIC_%s_MODULES=%s' % (m, sentinal))
+        else:
+            cflags.append('-DSTATIC_%s_MODULES=%s' % (m, ','.join(init_fn_list) + ',' + sentinal))
     self.ccflags = cflags
 
 
index acb88452953d2987a2b90dda73c5bcb5f4e13588..7324f8ff48c6e73919f7925ded2940f4868fb054 100644 (file)
@@ -278,6 +278,11 @@ def SAMBA_MODULE(bld, modname, source,
                  local_include=True,
                  enabled=True):
 
+    # we add the init function regardless of whether the module
+    # is enabled or not, as we need to generate a null list if
+    # all disabled
+    bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
+
     if internal_module:
         # treat internal modules as subsystems for now
         SAMBA_SUBSYSTEM(bld, modname, source,
@@ -288,12 +293,6 @@ def SAMBA_MODULE(bld, modname, source,
                         cflags=cflags,
                         local_include=local_include,
                         enabled=enabled)
-        # even though we're treating it as a subsystem, we need to
-        # add it to the init_function list
-        # TODO: we should also create an implicit dependency
-        # between the subsystem target and this target
-        if enabled:
-            bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
         return
 
     if not enabled:
@@ -308,9 +307,6 @@ def SAMBA_MODULE(bld, modname, source,
     if not SET_TARGET_TYPE(bld, modname, 'MODULE'):
         return
 
-
-    bld.ADD_INIT_FUNCTION(subsystem, modname, init_function)
-
     if subsystem is not None:
         deps += ' ' + subsystem