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.gitcommit = '09fe8f0fe689bea60354eb3e9977fd8452c05573' 8 self.download = ['git://https://github.com/bldenton/EGADSlite.git'] 9 self.functions = [] 10 self.includes = [] 11 self.hastests = 1 12 return 13 14 def setupDependencies(self, framework): 15 config.package.GNUPackage.setupDependencies(self, framework) 16 return 17 18 def createMakefile(self): 19 makeinc = os.path.join(self.packageDir, 'make.inc') 20 g = open(makeinc,'w') 21 g.write(''' 22include $(PETSC_DIR)/lib/petsc/conf/variables 23 24CFLAGS = -DLITE -Iinclude 25 26INCDIR = include 27SRCDIR = src 28LIBBASE = libegadslite 29LIBNAME = ${LIBBASE}.${AR_LIB_SUFFIX} 30LIBSRC.h = $(INCDIR)/egads.h $(INCDIR)/egadsErrors.h $(INCDIR)/egadsInternals.h $(INCDIR)/egadsTris.h \ 31 $(INCDIR)/egadsTypes.h $(INCDIR)/emp.h $(INCDIR)/liteClasses.h 32LIBSRC.c = $(SRCDIR)/liteAttrs.c $(SRCDIR)/liteBase.c $(SRCDIR)/liteGeom.c $(SRCDIR)/liteImport.c \ 33 $(SRCDIR)/liteMemory.c $(SRCDIR)/liteTopo.c $(SRCDIR)/egadsTess.c $(SRCDIR)/egadsTris.c \ 34 $(SRCDIR)/egadsQuads.c $(SRCDIR)/egadsTessInp.c $(SRCDIR)/egadsRobust.c \ 35 $(SRCDIR)/emp.c $(SRCDIR)/evaluate.c $(SRCDIR)/rational.c 36LIBSRC.o = $(LIBSRC.c:%.c=%.o) 37 38lib : $(LIBNAME) ; 39 40$(LIBSRC.o) : $(LIBSRC.h) 41 42define ARCHIVE_RECIPE_WIN32FE_LIB 43 @$(RM) $@ $@.args 44 @cygpath -w $^ > $@.args 45 $(AR) $(AR_FLAGS) $@ @$@.args 46 @$(RM) $@.args 47endef 48 49define ARCHIVE_RECIPE_DEFAULT 50 @$(RM) $@ 51 $(AR) $(AR_FLAGS) $@ $^ 52 $(RANLIB) $@ 53endef 54 55$(LIBNAME) : $(LIBSRC.o) 56 $(if $(findstring win32fe lib,$(AR)),$(ARCHIVE_RECIPE_WIN32FE_LIB),$(ARCHIVE_RECIPE_DEFAULT)) 57 58COMPILE.c = $(CC) $(PCC_FLAGS) $(CFLAGS) $(CCPPFLAGS) $(TARGET_ARCH) -c 59 60# This is unusual; usually prefix would default to /usr/local 61prefix ?= $(PETSC_DIR)/$(PETSC_ARCH) 62libdir = $(prefix)/lib 63includedir = $(prefix)/include 64INSTALL = install 65INSTALL_DATA = $(INSTALL) -m644 66MKDIR_P = mkdir -p 67 68install-egads: $(LIBNAME) 69 $(MKDIR_P) "$(DESTDIR)$(includedir)" "$(DESTDIR)$(libdir)" 70 $(INSTALL_DATA) $(LIBSRC.h) "$(DESTDIR)$(includedir)/" 71 $(INSTALL_DATA) $(LIBNAME) "$(DESTDIR)$(libdir)/" 72 73clean: 74 $(RM) $(LIBNAME) $(LIBSRC.o) 75 76.PHONY: lib clean install-egads 77 ''') 78 g.close() 79 return 80 81 # the install is delayed until postProcess() since egads install requires PETSc to have created its build/makefiles before installing 82 # note that egads can (and is) built before PETSc is built. 83 def Install(self): 84 self.createMakefile() 85 return self.installDir 86 87 def configureLibrary(self): 88 ''' Since egads cannot be built until after PETSc configure is complete we need to just assume the downloaded library will work''' 89 if 'with-egads' in self.framework.clArgDB: 90 raise RuntimeError('egads does not support --with-egads; only --download-egads') 91 if 'with-egads-dir' in self.framework.clArgDB: 92 self.egadsDir = self.framework.argDB['with-egads-dir'] 93 if 'with-egads-include' in self.framework.clArgDB: 94 raise RuntimeError('egads does not support --with-egads-include; only --download-egads') 95 if 'with-egads-lib' in self.framework.clArgDB: 96 raise RuntimeError('egads does not support --with-egads-lib; only --download-egads') 97 if 'with-egads-shared' in self.framework.clArgDB: 98 raise RuntimeError('egads does not support --with-egads-shared') 99 100 if not hasattr(self,'egadsDir'): 101 self.checkDownload() 102 self.egadsDir = self.installDir 103 self.include = [os.path.join(self.egadsDir,'include')] 104 self.lib = [os.path.join(self.egadsDir,'lib','libegadslite.a')] 105 self.found = 1 106 self.dlib = self.lib 107 if not hasattr(self.framework, 'packages'): 108 self.framework.packages = [] 109 self.framework.packages.append(self) 110 111 def postProcess(self): 112 if not hasattr(self,'installDir'): 113 return 114 try: 115 self.logPrintBox('Compiling egads; this may take several minutes') 116 # uses the regular PETSc library builder and then moves result 117 # turn off any compiler optimizations as they may break egads 118 self.setCompilers.pushLanguage('C') 119 cflags = self.checkNoOptFlag()+' '+self.getSharedFlag(self.setCompilers.getCompilerFlags())+' '+self.getPointerSizeFlag(self.setCompilers.getCompilerFlags())+' '+self.getWindowsNonOptFlags(self.setCompilers.getCompilerFlags())+' '+self.getDebugFlags(self.setCompilers.getCompilerFlags()) 120 self.setCompilers.popLanguage() 121 output,err,ret = config.package.GNUPackage.executeShellCommand(self.make.make+' -f make.inc PETSC_DIR=' + self.petscdir.dir + ' clean lib PCC_FLAGS="' + cflags + '"', timeout=1000, log = self.log, cwd=self.packageDir) 122 self.log.write(output+err) 123 self.logPrintBox('Installing egads; this may take several minutes') 124 # TODO: This message should not be printed if egads is install in PETSc arch directory; need self.printSudoPasswordMessage() defined in package.py 125 self.installDirProvider.printSudoPasswordMessage(1) 126 output,err,ret = config.package.GNUPackage.executeShellCommand(self.installSudo+self.make.make+' -f make.inc PETSC_DIR='+self.petscdir.dir+' prefix='+self.installDir+' install-egads',timeout=1000, log = self.log, cwd=self.packageDir) 127 self.log.write(output+err) 128 except RuntimeError as e: 129 raise RuntimeError('Error running make on egads: '+str(e)) 130