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 'http://ftp.mcs.anl.gov/pub/petsc/externalpackages/ck-0.4.5.tar.gz'] 9 self.functions = [] 10 self.includes = ['ck_spinlock.h'] 11 self.liblist = [['libck.a']] 12 self.downloadonWindows = 0 13 self.downloaddirnames = ['ck-'] 14 15 def setupDependencies(self, framework): 16 config.package.GNUPackage.setupDependencies(self, framework) 17 self.languages = framework.require('PETSc.options.languages', self) 18 19 def formGNUConfigureArgs(self): 20 if not self.languages.clanguage == 'C': 21 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++') 22 23 args = config.package.GNUPackage.formGNUConfigureArgs(self) 24 25 # CK configure is buggy and ignores --disable-shared; you must turn off PIC to turn off shared libraries 26 if not ((self.argDB['with-shared-libraries'] and 'download-'+self.package+'-shared' not in self.framework.clArgDB) or self.argDB['download-'+self.package+'-shared']): 27 args.append('--without-pic') 28 29 # Concurrency configure errors out on certain standard configure arguments 30 return self.rmArgs(args,['--disable-cxx','--disable-fortran', '--disable-fc','--disable-f77','--disable-f90']) 31 32 def checkForCorrectness(self): 33 include = '#include <ck_spinlock.h>' 34 body = 'ck_spinlock_t ck_spinlock; ck_spinlock_init(&ck_spinlock);ck_spinlock_lock(&ck_spinlock);ck_spinlock_unlock(&ck_spinlock);' 35 oldFlags = self.compilers.CPPFLAGS 36 oldLibs = self.compilers.LIBS 37 self.compilers.CPPFLAGS += ' '+self.headers.toString(self.include) 38 self.compilers.LIBS = self.libraries.toString(self.lib)+' '+self.compilers.LIBS 39 self.pushLanguage('C') 40 if not self.checkLink(include, body): 41 raise RuntimeError('Concurrencykit cannot be used') 42 self.popLanguage() 43 self.compilers.CPPFLAGS = oldFlags 44 self.compilers.LIBS = oldLibs 45 46 def configureLibrary(self): 47 '''Calls the regular package configureLibrary and then does an additional test needed''' 48 if 'with-'+self.package+'-shared' in self.argDB: 49 self.argDB['with-'+self.package] = 1 50 config.package.Package.configureLibrary(self) 51 self.executeTest(self.checkForCorrectness) 52