Repository: spack/spack

Issue:
Installation of cblas fails

Summary

Trying to install cblas with spack, I get the following error:

### Expected Result

cblas to be installed

### Actual Result

```console
$ spack install cblas@2015-06-06%gcc@5.4.0
==> openblas is already installed in /astro/soft/common/spack/v20180409/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/openblas-0.3.2-urum665bl2gtocrs7lmoeh4aq6c5umyg
==> Installing cblas
==> Using cached archive: /astro/soft/common/spack/v20180409/spack/var/spack/cache/cblas/cblas-2015-06-06.tgz
==> Staging archive: /astro/soft/common/spack/v20180409/spack/var/spack/stage/cblas-2015-06-06-4bkh6snhxwy7i5dxil5ww2x3fs7dn64t/cblas.tgz
==> Created stage in /astro/soft/common/spack/v20180409/spack/var/spack/stage/cblas-2015-06-06-4bkh6snhxwy7i5dxil5ww2x3fs7dn64t
==> Ran patch() for cblas
==> Building cblas [Package]
==> Executing phase: 'install'
==> Error: ProcessError: Command exited with status 2:
    'make' 'all'

3 errors found in build log:
     182    c_sblat1.f:218:48:
     183    
     184                    CALL STEST1(SASUMTEST(N,SX,INCX),STEMP,STEMP,SFAC)
     185                                                    1
     186    Warning: Rank mismatch in argument 'strue1' at (1) (scalar and rank-1)
     187    f90  -o xscblat1 c_sblat1.o c_sblas1.o ../lib/cblas_LINUX.a /astro/soft/common/spack/v20180409/spack/opt/spack/linux-centos7-x8
            6_64/gcc-5.4.0/openblas-0.3.2-urum665bl2gtocrs7lmoeh4aq6c5umyg/lib/libblas.a
  >> 188    gfortran: error: /astro/soft/common/spack/v20180409/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/openblas-0.3.2-urum665bl2gto
            crs7lmoeh4aq6c5umyg/lib/libblas.a: No such file or directory
  >> 189    make[1]: *** [xscblat1] Error 1
     190    make[1]: Leaving directory `/tmp/revaz/spack-stage/spack-stage-NM12P0/CBLAS/testing'
  >> 191    make: *** [alltst] Error 2

```

### Steps to reproduce the issue

```console
spack install cblas@2015-06-06%gcc@5.4.0
```

### Information on your system

- Done in centos 7
- spack up to date



Discussion:
Can you try building with `spack install -j1 cblas`? I'm wondering if this package can't be built in parallel.
Thanks for this so quick answer !

Unfortunately, with -j1 the problem remains

```code
$ spack install -j1 cblas@2015-06-06%gcc@5.4.0
==> openblas is already installed in /astro/soft/common/spack/v20180409/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/openblas-0.3.2-urum665bl2gtocrs7lmoeh4aq6c5umyg
==> Installing cblas
==> Using cached archive: /astro/soft/common/spack/v20180409/spack/var/spack/cache/cblas/cblas-2015-06-06.tgz
==> Staging archive: /astro/soft/common/spack/v20180409/spack/var/spack/stage/cblas-2015-06-06-4bkh6snhxwy7i5dxil5ww2x3fs7dn64t/cblas.tgz
==> Created stage in /astro/soft/common/spack/v20180409/spack/var/spack/stage/cblas-2015-06-06-4bkh6snhxwy7i5dxil5ww2x3fs7dn64t
==> Ran patch() for cblas
==> Building cblas [Package]
==> Executing phase: 'install'
==> Error: ProcessError: Command exited with status 2:
    'make' 'all'

3 errors found in build log:
     182    c_sblat1.f:218:48:
     183    
     184                    CALL STEST1(SASUMTEST(N,SX,INCX),STEMP,STEMP,SFAC)
     185                                                    1
     186    Warning: Rank mismatch in argument 'strue1' at (1) (scalar and rank-1)
     187    f90  -o xscblat1 c_sblat1.o c_sblas1.o ../lib/cblas_LINUX.a /astro/soft/common/spack/v20180409/spack/opt/spack/linux-centos7-x8
            6_64/gcc-5.4.0/openblas-0.3.2-urum665bl2gtocrs7lmoeh4aq6c5umyg/lib/libblas.a
  >> 188    gfortran: error: /astro/soft/common/spack/v20180409/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/openblas-0.3.2-urum665bl2gto
            crs7lmoeh4aq6c5umyg/lib/libblas.a: No such file or directory
  >> 189    make[1]: *** [xscblat1] Error 1
     190    make[1]: Leaving directory `/tmp/revaz/spack-stage/spack-stage-Cz26z_/CBLAS/testing'
  >> 191    make: *** [alltst] Error 2

```

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/cblas/package.py b/var/spack/repos/builtin/packages/cblas/package.py
--- a/var/spack/repos/builtin/packages/cblas/package.py
+++ b/var/spack/repos/builtin/packages/cblas/package.py
@@ -42,10 +42,10 @@ class Cblas(Package):
     def patch(self):
         mf = FileFilter('Makefile.in')
 
-        mf.filter('^BLLIB =.*', 'BLLIB = %s/libblas.a' %
-                  self.spec['blas'].prefix.lib)
+        mf.filter('^BLLIB =.*', 'BLLIB = {0}'.format(
+                  ' '.join(self.spec['blas'].libs.libraries)))
         mf.filter('^CC =.*', 'CC = cc')
-        mf.filter('^FC =.*', 'FC = f90')
+        mf.filter('^FC =.*', 'FC = fc')
 
     def install(self, spec, prefix):
         make('all')
@@ -53,6 +53,6 @@ def install(self, spec, prefix):
         mkdirp(prefix.include)
 
         # Rename the generated lib file to libcblas.a
-        install('./lib/cblas_LINUX.a', '%s/libcblas.a' % prefix.lib)
-        install('./include/cblas.h', '%s' % prefix.include)
-        install('./include/cblas_f77.h', '%s' % prefix.include)
+        install('lib/cblas_LINUX.a', prefix.lib.join('libcblas.a'))
+        install('include/cblas.h', prefix.include)
+        install('include/cblas_f77.h', prefix.include)


Test patch: