From da23b811b8ddb44dc8675030d65ba3147e6ec20d Mon Sep 17 00:00:00 2001
From: "Jose E. Roman" <jroman@dsic.upv.es>
Date: Mon, 16 Apr 2018 20:56:35 +0200
Subject: [PATCH] install.py: support the case when destdir is different from
 installdir

Fixes Issue #12
Requested-by: Drew Parsons
---
 config/install.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/config/install.py b/config/install.py
index 25f0948..19fabec 100755
--- a/config/install.py
+++ b/config/install.py
@@ -12,7 +12,7 @@ class Installer:
     if len(args)<6:
       print('********************************************************************')
       print('Installation script error - not enough arguments:')
-      print('./config/install.py SLEPC_DIR PETSC_DIR PETSC_ARCH DESTDIR LIB_SUFFIX RANLIB')
+      print('./config/install.py SLEPC_DIR PETSC_DIR DESTDIR PETSC_ARCH LIB_SUFFIX RANLIB')
       print('********************************************************************')
       sys.exit(1)
     self.rootDir     = args[0]
@@ -24,8 +24,23 @@ class Installer:
     self.copies = []
     return
 
+  def readDestDir(self, src):
+    try:
+      f = open(src)
+      for l in f.readlines():
+        r = l.split('=',1)
+        if len(r)!=2: continue
+        if r[0].strip() == 'SLEPC_DESTDIR':
+          break
+      f.close()
+    except:
+      print('********************************************************************')
+      print('Error reading SLEPC_DESTDIR from slepcvariables')
+      print('********************************************************************')
+      sys.exit(1)
+    return r[1].strip()
+
   def setupDirectories(self):
-    self.installDir        = self.destDir
     self.archDir           = os.path.join(self.rootDir, self.arch)
     self.rootIncludeDir    = os.path.join(self.rootDir, 'include')
     self.archIncludeDir    = os.path.join(self.rootDir, self.arch, 'include')
@@ -38,6 +53,7 @@ class Installer:
     self.destConfDir       = os.path.join(self.destDir, 'lib','slepc','conf')
     self.destLibDir        = os.path.join(self.destDir, 'lib')
     self.destBinDir        = os.path.join(self.destDir, 'lib','slepc','bin')
+    self.installDir        = self.readDestDir(os.path.join(self.archConfDir,'slepcvariables'))
     self.installIncludeDir = os.path.join(self.installDir, 'include')
     self.installBinDir     = os.path.join(self.installDir, 'lib','slepc','bin')
     self.rootShareDir      = os.path.join(self.rootDir, 'share')
-- 
2.10.5

