Jed Brown avatar Jed Brown committed 54a8e6c

config: move featureTestMacros to separate module

Matt says that PETSc.Configure depends on everything, so the dependency
in missing.py was a dependency loop (but BuildSystem's topological sort
ignores the loop and silently makes an arbitrary ordering decision).
This commit eliminates the loop by putting configureFeatureTestMacros in
a separate module.

Comments (0)

Files changed (3)

config/PETSc/Configure.py

       self.addDefine('Prefetch(a,b,c)', ' ')
     self.popLanguage()
 
-  def configureFeatureTestMacros(self):
-    '''Checks if certain feature test macros are support'''
-    if self.checkCompile('#define _POSIX_C_SOURCE 200112L\n#include <sysctl.h>',''):
-       self.addDefine('_POSIX_C_SOURCE_200112L', '1')
-    if self.checkCompile('#define _BSD_SOURCE\n#include<stdlib.h>',''):
-       self.addDefine('_BSD_SOURCE', '1')
-    if self.checkCompile('#define _GNU_SOURCE\n#include <sched.h>','cpu_set_t mset;\nCPU_ZERO(&mset);'):
-       self.addDefine('_GNU_SOURCE', '1')
-
   def configureAtoll(self):
     '''Checks if atoll exists'''
     if self.checkLink('#define _POSIX_C_SOURCE 200112L\n#include <stdlib.h>','long v = atoll("25")') or self.checkLink ('#include <stdlib.h>','long v = atoll("25")'):
     self.executeTest(self.configureInstall)
     self.executeTest(self.configureGCOV)
     self.executeTest(self.configureFortranFlush)
-    self.executeTest(self.configureFeatureTestMacros)
     self.executeTest(self.configureAtoll)
     # dummy rules, always needed except for remote builds
     self.addMakeRule('remote','')

config/PETSc/utilities/featureTestMacros.py

+import config.base
+
+class Configure(config.base.Configure):
+    def __init__(self, framework):
+        config.base.Configure.__init__(self, framework)
+
+    def setupDependencies(self, framework):
+        config.base.Configure.setupDependencies(self, framework)
+        self.compilers = framework.require('config.compilers', self)
+        self.functions = framework.require('config.functions', self)
+        self.headers   = framework.require('config.headers', self)
+
+    def configureFeatureTestMacros(self):
+        '''Checks if certain feature test macros are support'''
+        if self.checkCompile('#define _POSIX_C_SOURCE 200112L\n#include <sysctl.h>',''):
+            self.addDefine('_POSIX_C_SOURCE_200112L', '1')
+        if self.checkCompile('#define _BSD_SOURCE\n#include<stdlib.h>',''):
+            self.addDefine('_BSD_SOURCE', '1')
+        if self.checkCompile('#define _GNU_SOURCE\n#include <sched.h>','cpu_set_t mset;\nCPU_ZERO(&mset);'):
+            self.addDefine('_GNU_SOURCE', '1')
+
+    def configure(self):
+        self.executeTest(self.configureFeatureTestMacros)

config/PETSc/utilities/missing.py

     self.compilers = framework.require('config.compilers', self)
     self.functions = framework.require('config.functions', self)
     self.libraries = framework.require('config.libraries', self)
-    self.petscConf = framework.require('PETSc.Configure', self)
+    self.ftm = framework.require('PETSc.utilities.featureTestMacros', self)
     return
 
   def featureTestMacros(self):
     features = ''
-    if self.petscConf.defines.get('_POSIX_C_SOURCE_200112L'):
+    if self.ftm.defines.get('_POSIX_C_SOURCE_200112L'):
       features += '#define _POSIX_C_SOURCE 200112L\n'
-    if self.petscConf.defines.get('_BSD_SOURCE'):
+    if self.ftm.defines.get('_BSD_SOURCE'):
       features += '#define _BSD_SOURCE\n'
-    if self.petscConf.defines.get('_GNU_SOURCE'):
+    if self.ftm.defines.get('_GNU_SOURCE'):
       features += '#define _GNU_SOURCE\n'
     return features
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.