1import config.package 2import os 3 4class Configure(config.package.GNUPackage): 5 def __init__(self, framework): 6 config.package.GNUPackage.__init__(self, framework) 7 self.download = ['http://concurrencykit.org/releases/ck-0.4.5.tar.gz'] 8 self.functions = [] 9 self.includes = ['ck_spinlock.h'] 10 self.liblist = [['libck.a']] 11 self.downloadonWindows = 0 12 self.downloadfilename = 'ck' 13 14 def setupDependencies(self, framework): 15 config.package.GNUPackage.setupDependencies(self, framework) 16 self.languages = framework.require('PETSc.options.languages', self) 17 18 def formGNUConfigureArgs(self): 19 if not self.languages.clanguage == 'C': 20 raise RuntimeError('Concurrencykit cannot be used with --with-clanguage=cxx since it cannot be included in C++ code\nUse --with-clanguage=c but you can still compile your application with C++') 21 22 args = config.package.GNUPackage.formGNUConfigureArgs(self) 23 24 # CK configure is buggy and ignores --disable-shared; you must turn off PIC to turn off shared libraries 25 if not ((self.argDB['with-shared-libraries'] and not self.framework.clArgDB.has_key('download-'+self.package+'-shared')) or self.argDB['download-'+self.package+'-shared']): 26 args.append('--without-pic') 27 28 # configure errors out on certain standard configure arguments 29 rejects = ['--disable-cxx','--disable-fortran', '--disable-fc','--disable-f77','--disable-f90'] 30 self.logPrint('ConcurrencyKit is rejecting configure arguments '+str(rejects)) 31 return [arg for arg in args if not arg in rejects] 32 33 def checkForCorrectness(self): 34 include = '#include <ck_spinlock.h>' 35 body = 'ck_spinlock_t ck_spinlock; ck_spinlock_init(&ck_spinlock);ck_spinlock_lock(&ck_spinlock);ck_spinlock_unlock(&ck_spinlock);' 36 oldFlags = self.compilers.CPPFLAGS 37 oldLibs = self.compilers.LIBS 38 self.compilers.CPPFLAGS += ' '+self.headers.toString(self.include) 39 self.compilers.LIBS = self.libraries.toString(self.lib)+' '+self.compilers.LIBS 40 self.pushLanguage('C') 41 if not self.checkLink(include, body): 42 raise RuntimeError('Concurrencykit cannot be used') 43 self.popLanguage() 44 self.compilers.CPPFLAGS = oldFlags 45 self.compilers.LIBS = oldLibs 46 47 def configureLibrary(self): 48 '''Calls the regular package configureLibrary and then does an additional test needed''' 49 if 'with-'+self.package+'-shared' in self.argDB: 50 self.argDB['with-'+self.package] = 1 51 config.package.Package.configureLibrary(self) 52 self.executeTest(self.checkForCorrectness) 53