added --prefix option to configure script to specify symlink location

This commit is contained in:
Martin Diehl 2014-02-28 07:47:11 +00:00
parent fe13bb16fe
commit f146359c04
4 changed files with 63 additions and 34 deletions

View File

@ -11,6 +11,20 @@ fi
[[ -f $HOME/.damask/damask.conf ]] && source $HOME/.damask/damask.conf || source /etc/damask.conf
# if DAMASK_BIN is present and not in $PATH, add it
if [[ "x$DAMASK_BIN" != "x" && ! `echo ":$PATH:" | grep $DAMASK_BIN:` ]]; then
export PATH=$DAMASK_BIN:$PATH
fi
SOLVER=`which DAMASK_spectral`
if [ "x$SOLVER" == "x" ]; then
export SOLVER='Not found!'
fi
PROCESSING=`which postResults`
if [ "x$PROCESSING" == "x" ]; then
export PROCESSING='Not found!'
fi
echo "DAMASK_spectral `which DAMASK_spectral`"
# disable output in case of scp
if [ ! -z "$PS1" ]; then
@ -21,6 +35,8 @@ if [ ! -z "$PS1" ]; then
echo
echo Using environment with ...
echo "DAMASK $DAMASK_ROOT"
([[ "x$SOLVER" != "x" ]] && echo "Spectral Solver $SOLVER")
([[ "x$PROCESSING" != "x" ]] && echo "Post Processing $PROCESSING")
echo "Multithreading DAMASK_NUM_THREADS=$DAMASK_NUM_THREADS"
echo "Compiler F90=$F90"
([[ "x$IMKL_ROOT" != "x" ]] && echo "IMKL $IMKL_ROOT") || \
@ -31,7 +47,6 @@ if [ ! -z "$PS1" ]; then
echo "HDF5 $HDF5_ROOT (for future use)"
echo
fi
# http://superuser.com/questions/220059/what-parameters-has-ulimit
ulimit -s unlimited 2>/dev/null # maximum stack size (kB)
ulimit -h unlimited 2>/dev/null # maximum heap size (kB)

37
configure vendored
View File

@ -42,7 +42,8 @@ if compiler == None: compiler ={True:'ifort',False:'gfortran'}[\
#--- default option values --------------------------------------------------------------------------
BLAS_order = ['IMKL','ACML','LAPACK']
defaults={'F90':compiler,
defaults={'DAMASK_BIN':'depending on access rights',
'F90':compiler,
'FFTW_ROOT':'/usr/local',
'MSC_ROOT' :'/msc',
'HDF5_ROOT':'/usr/local',
@ -54,6 +55,8 @@ defaults={'F90':compiler,
[os.getenv('MKLROOT') != None]},
'spectralOptions':{}}
#--- if local config file exists, read, otherwise assume global config file ------------------------
if os.path.isfile(os.path.join(os.getenv('HOME'),'.damask/damask.conf')):
configFile = os.path.join(os.getenv('HOME'),'.damask/damask.conf')
@ -72,18 +75,20 @@ try:
pass
if key == 'DAMASK_NUM_THREADS':
defaults['DAMASK_NUM_THREADS'] = int(value)
if key == 'DAMASK_BIN':
defaults['DAMASK_BIN'] = value
for theKey in ['F90','FFTW_ROOT','HDF5_ROOT','MSC_ROOT','spectralOptions']:
if key == theKey:
defaults[key] = value
for theKey in reversed(BLAS_order):
if key == theKey+'_ROOT' and (value != None or value != ''):
defaults['blasType'] = key
defaults['blasRoot'][key] = value
defaults['blasType'] = theKey
defaults['blasRoot'][theKey] = value
except IOError:
pass
parser.add_option('--prefix', dest='prefix', type='string', metavar='string',
help='location of (links to) DAMASK executables [%default]')
parser.add_option('--with-fc', dest='compiler', type='string', metavar='string',
help='F90 compiler [%default]')
parser.add_option('--with-fftw-dir', dest='fftwRoot', type='string', metavar='string',
@ -101,6 +106,7 @@ parser.add_option('--with-blas-dir', dest='blasRoot', type='string', met
parser.add_option('--with-spectral-options', dest='spectraloptions', type='string', action='extend', metavar='<string LIST>',
help='options for compilation of spectral solver')
parser.set_defaults(prefix = defaults['DAMASK_BIN'])
parser.set_defaults(compiler = defaults['F90'])
parser.set_defaults(fftwRoot = defaults['FFTW_ROOT'])
parser.set_defaults(mscRoot = defaults['MSC_ROOT'])
@ -109,7 +115,6 @@ parser.set_defaults(threads = defaults['DAMASK_NUM_THREADS'])
parser.set_defaults(blasType = defaults['blasType'])
#--- set default for blasRoot depending on current option (or default) for blasType --------------------
blasType = defaults['blasType'].upper()
for i, arg in enumerate(sys.argv):
if arg.startswith('--with-blas-type'):
@ -180,7 +185,6 @@ else:
print('Error: Unknown BLAS/LAPACK library: %s'%options.blasType)
sys.exit(1)
#--- read config file if present to keep comments and order ---------------------------------------
output = []
try:
@ -190,6 +194,9 @@ try:
if (not line.strip() or items[0].startswith('#')):
pass
if items[0] == 'DAMASK_BIN':
line = '%s=%s\n'%(items[0],options.prefix)
options.prefix ='depending on access rights'
if items[0] == 'F90':
line = '%s=%s\n'%(items[0],options.compiler)
options.compiler =''
@ -224,6 +231,8 @@ except IOError:
#--- write remaining options --------------------------------------------------------------------------
for opt, value in options.__dict__.items():
if opt == 'prefix' and value !='depending on access rights':
output.append('DAMASK_BIN=%s\n'%value)
if opt == 'compiler' and value !='':
output.append('F90=%s\n'%value)
if opt == 'fftwRoot' and value !='':
@ -240,14 +249,12 @@ for opt, value in options.__dict__.items():
for spectralOption in options.spectraloptions:
output.append(spectralOption+'\n')
#--- decide where do save the data ----------------------------------------------------------------------
root=os.access('/etc/', os.W_OK)
if root:
configFileNew = '/etc/damask.conf'
else:
configFileNew = os.path.join(os.getenv('HOME'),'.damask/damask.conf')
if not os.path.isdir(os.path.join(os.getenv('HOME'),'.damask')):
os.mkdir(os.path.join(os.getenv('HOME'),'.damask'))
#--- decide where do save the data -------------------------------------------------------------------
if os.access('/etc/', os.W_OK): # super user (no home)
configDir = '/etc'
else: # normal user
configDir = os.path.join(os.getenv('HOME'),'.damask')
configFileNew = os.path.join(configDir,'damask.conf')
print('\n-----\n writing values to %s\n-----'%configFileNew)
with open(configFileNew,'w') as f:

View File

@ -12,11 +12,15 @@ MarcReleases =[2011,2012,2013,2013.1]
baseDir = damask.Environment('../../').relPath('code/')
try:
binDir = damask.Environment().options['DAMASK_BIN']
except:
root=os.access('/usr/local/bin', os.W_OK)
if root:
binDir = '/usr/local/bin'
else:
binDir = os.path.join(os.getenv('HOME'),'bin')
if not os.path.isdir(binDir):
os.mkdir(binDir)

View File

@ -7,6 +7,17 @@ from damask import Environment
damaskEnv = Environment()
baseDir = damaskEnv.relPath('processing/')
codeDir = damaskEnv.relPath('code/')
try:
binDir = damaskEnv.options['DAMASK_BIN']
except:
root=os.access('/usr/local/bin', os.W_OK)
if root:
binDir = '/usr/local/bin'
else:
binDir = os.path.join(os.getenv('HOME'),'bin')
if not os.path.isdir(binDir):
os.mkdir(binDir)
#define ToDo list
bin_link = { \
@ -82,14 +93,6 @@ bin_link = { \
],
}
root=os.access('/usr/local/bin', os.W_OK)
if root:
binDir = '/usr/local/bin'
else:
binDir = os.path.join(os.getenv('HOME'),'bin')
if not os.path.isdir(binDir):
os.mkdir(binDir)
for dir in bin_link:
for file in bin_link[dir]:
src = os.path.abspath(os.path.join(baseDir,dir,file))