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 'https://web.cels.anl.gov/projects/petsc/download/externalpackages/ck-0.4.5.tar.gz'] 9 self.functions = [] 10 self.includes = ['ck_spinlock.h'] 11 self.liblist = [['libck.a']] 12 self.downloaddirnames = ['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 'download-'+self.package+'-shared' not in self.framework.clArgDB) or self.argDB['download-'+self.package+'-shared']): 26 args.append('--without-pic') 27 28 # Concurrency configure errors out on certain standard configure arguments 29 return self.rmArgs(args,['--disable-cxx','--disable-fortran', '--disable-fc','--disable-f77','--disable-f90']) 30 31 def checkForCorrectness(self): 32 include = '#include <ck_spinlock.h>' 33 body = 'ck_spinlock_t ck_spinlock; ck_spinlock_init(&ck_spinlock);ck_spinlock_lock(&ck_spinlock);ck_spinlock_unlock(&ck_spinlock);' 34 oldFlags = self.compilers.CPPFLAGS 35 oldLibs = self.compilers.LIBS 36 self.compilers.CPPFLAGS += ' '+self.headers.toString(self.include) 37 self.compilers.LIBS = self.libraries.toString(self.lib)+' '+self.compilers.LIBS 38 self.pushLanguage('C') 39 if not self.checkLink(include, body): 40 raise RuntimeError('Concurrencykit cannot be used') 41 self.popLanguage() 42 self.compilers.CPPFLAGS = oldFlags 43 self.compilers.LIBS = oldLibs 44 45 def configureLibrary(self): 46 '''Calls the regular package configureLibrary and then does an additional test needed''' 47 if 'with-'+self.package+'-shared' in self.argDB: 48 self.argDB['with-'+self.package] = 1 49 config.package.Package.configureLibrary(self) 50 self.executeTest(self.checkForCorrectness) 51