Browse Source

suitesparse: update to 5.4.0

git-svn-id: http://trac.vinelinux.org/repos/projects/specs@12305 ec354946-7b23-47d6-9f5a-488ba84defc7
ara_t 4 years ago
parent
commit
e054ae24f9
1 changed files with 408 additions and 296 deletions
  1. 408 296
      s/suitesparse/suitesparse-vl.spec

+ 408 - 296
s/suitesparse/suitesparse-vl.spec

@@ -1,25 +1,60 @@
-Name:           suitesparse
-Version:        4.4.6
-Release:        2%{?_dist_release}
-Summary:        A collection of sparse matrix libraries
-Summary(ja):    疎行列ライブラリ集
+%define pkg_name    suitesparse
+%define pkg_version 5.4.0
+%define pkg_release 1%{?_dist_release}
+
+%global amd_version_major 2
+%global btf_version_major 1
+%global camd_version_major 2
+%global ccolamd_version_major 2
+%global cholmod_version_major 3
+%global colamd_version_major 2
+%global csparse_version_major 3
+%global cxsparse_version_major 3
+%global klu_version_major 1
+%global ldl_version_major 2
+%global rbio_version_major 2
+%global spqr_version_major 2
+%global SuiteSparse_config_major 5
+%global umfpack_version_major 5
 
-Group:          System Environment/Libraries
-License:        LGPLv2+ and GPLv2+
-URL:            http://www.cise.ufl.edu/research/sparse/SuiteSparse
+### CXSparse is a superset of CSparse, and the two share common header
+### names, so it does not make sense to build both. CXSparse is built
+### by default, but CSparse can be built instead by defining
+### enable_csparse as 1 below.
+%define enable_csparse 0
+
+# Whether to build a separate version of libraries linked against an ILP64 BLAS
+%if 0%{?__isa_bits} == 64
+%global build64 1
+%endif
 
-Source0:        https://github.com/jluttine/suitesparse/archive/v%{version}.tar.gz
-# Source0:        http://www.cise.ufl.edu/research/sparse/SuiteSparse/SuiteSparse-%{version}.tar.gz
-# Move #include <math.h> out of StuiteSparse_config.h and into SuiteSparse_config.c
-Patch0:         suitesparse-math.patch
+
+Name:        %{pkg_name}
+Version:     %{pkg_version}
+Release:     %{pkg_release}
+
+Summary:     A collection of sparse matrix libraries
+Summary(ja): 疎行列ライブラリ集
+
+Group:       System Environment/Libraries
+License:     (LGPLv2+ or BSD) and LGPLv2+ and GPLv2+
+URL:         http://faculty.cse.tamu.edu/davis/suitesparse.html
+
+Source0:     http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-%{version}.tar.gz
+
+# # Move #include <math.h> out of StuiteSparse_config.h and into SuiteSparse_config.c
+# Patch0:      suitesparse-math.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
-BuildRequires:  blas-devel
-BuildRequires:  lapack-devel
-%ifnarch s390 s390x
-BuildRequires:  tbb-devel
-%global with_tbb 1
+
+BuildRequires:  openblas-devel
+%if 0%{?build64}
+BuildRequires:  openblas64-devel
 %endif
+BuildRequires:  tbb-devel
+
+Provides:       ufsparse = %{version}-%{release}
+
 
 %description
 suitesparse is a collection of libraries for computations involving sparse
@@ -62,317 +97,317 @@ Requires:       %{name}-devel = %{version}-%{release}
 The suitesparse-static package contains the statically linkable
 version of the suitesparse libraries.
 
-#'
 
-%prep
-%setup -q
-# %patch0 -p1 -b .math
+%if 0%{?build64}
+%package -n %{name}64
+Summary:        A collection of sparse matrix libraries (ILP64 version)
 
-%build
-%define amd_version 2.4.1
-%define amd_version_major 2
-%define btf_version 1.2.1
-%define btf_version_major 1
-%define camd_version 2.4.1
-%define camd_version_major 2
-%define ccolamd_version 2.9.1
-%define ccolamd_version_major 2
-%define cholmod_version 3.0.6
-%define cholmod_version_major 3
-%define colamd_version 2.9.1
-%define colamd_version_major 2
-%define csparse_version 3.1.4
-%define csparse_version_major 3
-%define cxsparse_version 3.1.4
-%define cxsparse_version_major 3
-%define klu_version 1.3.3
-%define klu_version_major 1
-%define ldl_version 2.2.1
-%define ldl_version_major 2
-%define rbio_version 2.2.1
-%define rbio_version_major 2
-%define spqr_version 2.0.2
-%define spqr_version_major 2
-%define SuiteSparse_config_ver 4.4.6
-%define SuiteSparse_config_major 4
-%define umfpack_version 5.7.1
-%define umfpack_version_major 5
-### CHOLMOD can also be compiled to use the METIS library, but it is not
-### used here because its licensing terms exclude it from Fedora Extras.
-### To compile with METIS, define enable_metis as 1 below.
-%define enable_metis 0
-### CXSparse is a superset of CSparse, and the two share common header
-### names, so it does not make sense to build both. CXSparse is built
-### by default, but CSparse can be built instead by defining
-### enable_csparse as 1 below.
-%define enable_csparse 0
+%description -n %{name}64
+The suitesparse collection compiled against an ILP64 BLAS library.
 
-mkdir -p Doc/{AMD,BTF,CAMD,CCOLAMD,CHOLMOD,COLAMD,KLU,LDL,UMFPACK,SPQR,RBio} Lib Include
-
-# SuiteSparse_config needs to come first
-pushd SuiteSparse_config
-  make CFLAGS="$RPM_OPT_FLAGS -fPIC"
-  ar x libsuitesparseconfig.a
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libsuitesparseconfig.so.%{SuiteSparse_config_major} -o \
-        libsuitesparseconfig.so.%{SuiteSparse_config_ver} ../SuiteSparse_config/*.o -lm
-    ln -sf libsuitesparseconfig.so.%{SuiteSparse_config_ver} libsuitesparseconfig.so.%{SuiteSparse_config_major}
-    ln -sf libsuitesparseconfig.so.%{SuiteSparse_config_ver} libsuitesparseconfig.so
-    cp -p ../SuiteSparse_config/*.a ./
-  popd
-  cp -p *.h ../Include
-popd
 
-pushd AMD
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
-  popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libamd.so.%{amd_version_major} -o \
-        libamd.so.%{amd_version} ../AMD/Lib/*.o \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major} -lm
-    ln -sf libamd.so.%{amd_version} libamd.so.%{amd_version_major}
-    ln -sf libamd.so.%{amd_version} libamd.so
-    cp -p ../AMD/Lib/*.a ./
-  popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/License.txt Doc/ChangeLog Doc/*.pdf ../Doc/AMD
-popd
+%package -n %{name}64-devel
+Summary:        Development headers for SuiteSparse (ILP64 version)
+Requires:       %{name}-devel = %{version}-%{release}
+Requires:       %{name}64 = %{version}-%{release}
 
-pushd BTF
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
-  popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libbtf.so.%{btf_version_major} -o \
-        libbtf.so.%{btf_version} ../BTF/Lib/*.o
-    ln -sf libbtf.so.%{btf_version} libbtf.so.%{btf_version_major}
-    ln -sf libbtf.so.%{btf_version} libbtf.so
-    cp -p ../BTF/Lib/*.a ./
-  popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/* ../Doc/BTF
-popd
+%description -n %{name}64-devel
+The suitesparse64-devel package contains files needed for developing
+applications which use the suitesparse libraries (ILP64 version).
 
-pushd CAMD
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
-  popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libcamd.so.%{camd_version_major} -o \
-        libcamd.so.%{camd_version} ../CAMD/Lib/*.o \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major} -lm
-    ln -sf libcamd.so.%{camd_version} libcamd.so.%{camd_version_major}
-    ln -sf libcamd.so.%{camd_version} libcamd.so
-    cp -p ../CAMD/Lib/*.a ./
-  popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/ChangeLog Doc/License Doc/*.pdf ../Doc/CAMD
-popd
 
-pushd CCOLAMD
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
-  popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libccolamd.so.%{ccolamd_version_major} -o \
-        libccolamd.so.%{ccolamd_version} ../CCOLAMD/Lib/*.o \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major} -lm
-    ln -sf libccolamd.so.%{ccolamd_version} libccolamd.so.%{ccolamd_version_major}
-    ln -sf libccolamd.so.%{ccolamd_version} libccolamd.so
-    cp -p ../CCOLAMD/Lib/*.a ./
-  popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/* ../Doc/CCOLAMD
-popd
+%package -n %{name}64-static
+Summary:        Static version of SuiteSparse libraries (ILP64 version)
+Requires:       %{name}-devel = %{version}-%{release}
 
-pushd COLAMD
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
-  popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libcolamd.so.%{colamd_version_major} -o \
-        libcolamd.so.%{colamd_version} ../COLAMD/Lib/*.o \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major} -lm
-    ln -sf libcolamd.so.%{colamd_version} libcolamd.so.%{colamd_version_major}
-    ln -sf libcolamd.so.%{colamd_version} libcolamd.so
-    cp -p ../COLAMD/Lib/*.a ./
-  popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/* ../Doc/COLAMD
+%description -n %{name}64-static
+The suitesparse64-static package contains the statically linkable
+version of the suitesparse libraries (ILP64 version).
+
+
+%package -n %{name}64_
+Summary:        A collection of sparse matrix libraries (ILP64 version)
+
+%description -n %{name}64_
+The suitesparse collection compiled against an ILP64 BLAS library.
+
+
+%package -n %{name}64_-devel
+Summary:        Development headers for SuiteSparse (ILP64 version)
+Requires:       %{name}-devel = %{version}-%{release}
+Requires:       %{name}64_ = %{version}-%{release}
+
+%description -n %{name}64_-devel
+The suitesparse64_-devel package contains files needed for developing
+applications which use the suitesparse libraries (ILP64 version) compiled
+against a BLAS library with the "64_" symbol name suffix (see openblas-*64_
+packages).
+
+
+%package -n %{name}64_-static
+Summary:        Static version of SuiteSparse libraries (ILP64 version)
+Requires:       %{name}-devel = %{version}-%{release}
+
+%description -n %{name}64_-static
+The suitesparse64_-static package contains the statically linkable
+version of the suitesparse libraries (ILP64 version) compiled against a
+BLAS library with the "64_" symbol name suffix (see openblas-*64_ packages).
+%endif
+
+%package doc
+Summary:        Documentation files for SuiteSparse
+BuildArch:      noarch
+Requires:       %{name} = %{version}-%{release}
+
+%description doc
+This package contains documentation files for %{name}.
+
+
+%prep
+%setup -c -q
+
+pushd SuiteSparse
+  # Remove bundled metis
+  rm -r metis*
+  # Makefiles look for metis.h specifically
+  ln -s %{_includedir}/metis/*.h include/
+
+  # Fix pragma ivdep so gcc understands it.
+  for fil in $(grep -Frl 'pragma ivdep' .); do
+    sed -i.orig 's/pragma ivdep/pragma GCC ivdep/' $fil
+    touch -r ${fil}.orig $fil
+    rm -f ${fil}.orig
+  done
+
+  # drop non-standard -O3 and duplicate -fexceptions from default CFLAGS
+  sed -i -e '/^  CF =/ s/ -O3 -fexceptions//' SuiteSparse_config/SuiteSparse_config.mk
+
+  # Allow adding a suffix to the library name
+  sed -i -e '/SO.*=/s/$(LIBRARY).so/$(LIBRARY)$(LIBRARY_SUFFIX).so/' \
+         -e '/AR_TARGET *=/s/$(LIBRARY).a/$(LIBRARY)$(LIBRARY_SUFFIX).a/' SuiteSparse_config/SuiteSparse_config.mk
+  sed -i -e 's/-l\(amd\|btf\|camd\|ccolamd\|cholmod\|colamd\|csparse\|cxsparse\|klu\|ldl\|rbio\|spqr\|suitesparseconfig\|umfpack\)/-l\1$(LIBRARY_SUFFIX)/g' \
+    $(find -name Makefile\* -o -name \*.mk)
 popd
 
-%if "%{?enable_metis}" == "1"
-CHOLMOD_FLAGS="$RPM_OPT_FLAGS -I%{_includedir}/metis -fPIC"
-%else
-CHOLMOD_FLAGS="$RPM_OPT_FLAGS -DNPARTITION -fPIC"
+%if 0%{?build64}
+cp -a SuiteSparse SuiteSparse64
+cp -a SuiteSparse SuiteSparse64_
 %endif
-pushd CHOLMOD
-  pushd Lib
-    make CFLAGS="$CHOLMOD_FLAGS"
+
+
+%build
+for build in SuiteSparse %{?build64:SuiteSparse64 SuiteSparse64_}
+do
+  pushd $build
+
+  # TODO - Try to use upstream makefile - will build more components
+  mkdir -p Doc/{AMD,BTF,CAMD,CCOLAMD,CHOLMOD,COLAMD,KLU,LDL,UMFPACK,SPQR,RBio} Include
+
+  export CFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/metis"
+  export LAPACK=""
+  # Set flags for ILP64 build
+  if [ $build = SuiteSparse64 ]
+  then
+     export CFLAGS="$CFLAGS -DBLAS64"
+     export BLAS=-lopenblas64
+     export LIBRARY_SUFFIX=64
+  elif [ $build = SuiteSparse64_ ]
+  then
+     export CFLAGS="$CFLAGS -DBLAS64 -DSUN64"
+     export BLAS=-lopenblas64_
+     export LIBRARY_SUFFIX=64_
+  else
+     export BLAS=-lopenblas
+  fi   
+   
+  # SuiteSparse_config needs to come first
+  pushd SuiteSparse_config
+    %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    cp -p *.h ../Include
   popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libcholmod.so.%{cholmod_version_major} -o \
-        libcholmod.so.%{cholmod_version} ../CHOLMOD/Lib/*.o \
-        libamd.so.%{amd_version_major} \
-        libcamd.so.%{camd_version_major} libcolamd.so.%{colamd_version_major} \
-        libccolamd.so.%{ccolamd_version_major} \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major} -lm \
-  -llapack -lblas -lgfortran
-#        -L%{_libdir}/atlas %{atlaslibs} \
-    ln -sf libcholmod.so.%{cholmod_version} libcholmod.so.%{cholmod_version_major}
-    ln -sf libcholmod.so.%{cholmod_version} libcholmod.so
-    cp -p ../CHOLMOD/Lib/*.a ./
+
+  pushd AMD
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/License.txt Doc/lesser.txt Doc/ChangeLog Doc/*.pdf ../Doc/AMD
   popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/*.pdf ../Doc/CHOLMOD
-  cp -p Cholesky/License.txt ../Doc/CHOLMOD/Cholesky_License.txt
-  cp -p Core/License.txt ../Doc/CHOLMOD/Core_License.txt
-  cp -p MatrixOps/License.txt ../Doc/CHOLMOD/MatrixOps_License.txt
-  cp -p Partition/License.txt ../Doc/CHOLMOD/Partition_License.txt
-  cp -p Supernodal/License.txt ../Doc/CHOLMOD/Supernodal_License.txt
-popd
 
-%if "%{?enable_csparse}" == "1"
-pushd CSparse
-  pushd Source
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
-    cp -p cs.h ../../Include
+  pushd BTF
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/* ../Doc/BTF
   popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libcsparse.so.%{csparse_version_major} -o \
-        libcsparse.so.%{csparse_version} ../CSparse/Source/*.o -lm
-    ln -sf libcsparse.so.%{csparse_version} libcsparse.so.%{csparse_version_major}
-    ln -sf libcsparse.so.%{csparse_version} libcsparse.so
-    cp -p ../CSparse/Source/*.a ./
+
+  pushd CAMD
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/ChangeLog Doc/License.txt Doc/*.pdf ../Doc/CAMD
   popd
-  mkdir ../Doc/CSparse/
-  cp -p Doc/* ../Doc/CSparse
-popd
 
-%else
-pushd CXSparse
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
+  pushd CCOLAMD
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/* ../Doc/CCOLAMD
   popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libcxsparse.so.%{cxsparse_version_major} -o \
-        libcxsparse.so.%{cxsparse_version} ../CXSparse/Lib/*.o -lm
-    ln -sf libcxsparse.so.%{cxsparse_version} libcxsparse.so.%{cxsparse_version_major}
-    ln -sf libcxsparse.so.%{cxsparse_version} libcxsparse.so
-    cp -p ../CXSparse/Lib/*.a ./
+
+  pushd COLAMD
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/* ../Doc/COLAMD
   popd
-  cp -p Include/cs.h ../Include
-  mkdir ../Doc/CXSparse/
-  cp -p Doc/* ../Doc/CXSparse
-popd
-%endif
 
-pushd KLU
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
+  pushd CHOLMOD
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/*.pdf ../Doc/CHOLMOD
+    cp -p Cholesky/lesser.txt ../Doc/CHOLMOD/Cholesky_License.txt
+    cp -p Core/lesser.txt ../Doc/CHOLMOD/Core_License.txt
+    cp -p MatrixOps/gpl.txt ../Doc/CHOLMOD/MatrixOps_License.txt
+    cp -p Partition/lesser.txt ../Doc/CHOLMOD/Partition_License.txt
+    cp -p Supernodal/gpl.txt ../Doc/CHOLMOD/Supernodal_License.txt
   popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libklu.so.%{klu_version_major} -o \
-        libklu.so.%{klu_version} ../KLU/Lib/*.o \
-        libamd.so.%{amd_version_major} libcolamd.so.%{colamd_version_major} \
-        libbtf.so.%{btf_version_major} \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major}
-    ln -sf libklu.so.%{klu_version} libklu.so.%{klu_version_major}
-    ln -sf libklu.so.%{klu_version} libklu.so
-    cp -p ../KLU/Lib/*.a ./
+
+  %if "%{?enable_csparse}" == "1"
+  pushd CSparse
+    pushd Source
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+      cp -p cs.h ../../Include
+    popd
+    mkdir ../Doc/CSparse/
+    cp -p Doc/* ../Doc/CSparse
   popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/lesser.txt ../Doc/KLU
-popd
 
-pushd LDL
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
+  %else
+  pushd CXSparse
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/cs.h ../Include
+    mkdir ../Doc/CXSparse/
+    cp -p Doc/* ../Doc/CXSparse
   popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libldl.so.%{ldl_version_major} -o \
-        libldl.so.%{ldl_version} ../LDL/Lib/*.o
-    ln -sf libldl.so.%{ldl_version} libldl.so.%{ldl_version_major}
-    ln -sf libldl.so.%{ldl_version} libldl.so
-    cp -p ../LDL/Lib/*.a ./
+  %endif
+
+  pushd KLU
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/lesser.txt ../Doc/KLU
   popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/ChangeLog Doc/lesser.txt Doc/*.pdf ../Doc/LDL
-popd
 
-pushd UMFPACK
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC" 
-  popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,libumfpack.so.%{umfpack_version_major} -o \
-        libumfpack.so.%{umfpack_version} ../UMFPACK/Lib/*.o \
-        libamd.so.%{amd_version_major} \
-        libcholmod.so.%{cholmod_version_major} \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major} -lm \
-  -llapack -lblas -lgfortran
-#        -L%{_libdir}/atlas %{atlaslibs} \
-    ln -sf libumfpack.so.%{umfpack_version} libumfpack.so.%{umfpack_version_major}
-    ln -sf libumfpack.so.%{umfpack_version} libumfpack.so
-    cp -p ../UMFPACK/Lib/*.a ./
+  pushd LDL
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/ChangeLog Doc/lesser.txt Doc/*.pdf ../Doc/LDL
   popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/License Doc/ChangeLog Doc/gpl.txt Doc/*.pdf ../Doc/UMFPACK
-popd
 
-pushd SPQR
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS %{?with_tbb:-DHAVE_TBB} -DNPARTITION -fPIC"
+  pushd UMFPACK
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/License.txt Doc/ChangeLog Doc/gpl.txt Doc/*.pdf ../Doc/UMFPACK
   popd
-  pushd ../Lib
-    g++ -shared -Wl,-soname,libspqr.so.%{spqr_version_major} -o \
-        libspqr.so.%{spqr_version} ../SPQR/Lib/*.o \
-        -L%{_libdir} \
-        %{?with_tbb:-ltbb} \
-        libcholmod.so.%{cholmod_version_major} \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major} -lm \
-  -llapack -lblas -lgfortran
-#        -L%{_libdir}/atlas -L%{_libdir} %{atlaslibs} \
-    ln -sf libspqr.so.%{spqr_version} libspqr.so.%{spqr_version_major}
-    ln -sf libspqr.so.%{spqr_version} libspqr.so
-    cp -p ../SPQR/Lib/*.a ./
+
+  pushd SPQR
+    pushd Lib
+    %make_build CFLAGS="$CFLAGS -DHAVE_TBB -DNPARTITION" TBB=-ltbb \
+                BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h* ../Include
+    cp -p README{,_SPQR}.txt
+    cp -p README_SPQR.txt Doc/* ../Doc/SPQR
   popd
-  cp -p Include/*.h* ../Include
-  cp -p README{,_SPQR}.txt
-  cp -p README_SPQR.txt Doc/* ../Doc/SPQR
-popd
 
-pushd RBio
-  pushd Lib
-    make CFLAGS="$RPM_OPT_FLAGS -fPIC"
+  pushd RBio
+    pushd Lib
+      %make_build CFLAGS="$CFLAGS" BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX"
+    popd
+    cp -p Include/*.h ../Include
+    cp -p README.txt Doc/ChangeLog Doc/License.txt ../Doc/RBio
   popd
-  pushd ../Lib
-    gcc -shared -Wl,-soname,librbio.so.%{rbio_version_major} -o \
-        librbio.so.%{rbio_version} ../RBio/Lib/*.o \
-        libsuitesparseconfig.so.%{SuiteSparse_config_major}
-    ln -sf librbio.so.%{rbio_version} librbio.so.%{rbio_version_major}
-    ln -sf librbio.so.%{rbio_version} librbio.so
-    cp -p ../RBio/Lib/*.a ./
+
   popd
-  cp -p Include/*.h ../Include
-  cp -p README.txt Doc/ChangeLog Doc/License.txt ../Doc/RBio
-popd
+done
+
 
 %install
-rm -rf ${RPM_BUILD_ROOT}
 mkdir -p ${RPM_BUILD_ROOT}%{_libdir}
 mkdir -p ${RPM_BUILD_ROOT}%{_includedir}/%{name}
-pushd Lib
-  for f in *.a *.so*; do
-    cp -a $f ${RPM_BUILD_ROOT}%{_libdir}/$f
-  done
-popd
-pushd Include
-  for f in *.h *.hpp;  do
-    cp -a $f ${RPM_BUILD_ROOT}%{_includedir}/%{name}/$f
-  done
-popd
+cp -a SuiteSparse/Include/*.{h,hpp} ${RPM_BUILD_ROOT}%{_includedir}/%{name}/
+for build in SuiteSparse %{?build64:SuiteSparse64 SuiteSparse64_}
+do
+  pushd $build
+    cp -a */Lib/*.a lib/*.so* ${RPM_BUILD_ROOT}%{_libdir}/
+    chmod 755 ${RPM_BUILD_ROOT}%{_libdir}/*.so.*
+
+    # collect licenses in one place to ship as base package documentation
+    rm -rf Licenses
+    mkdir Licenses
+    find */ -iname lesser.txt -o -iname license.txt -o -iname gpl.txt -o \
+        -iname license | while read f; do
+            b="${f%%/*}"
+            r="${f#$b}"
+            x="$(echo "$r" | sed 's|/doc/|/|gi')"
+            install -m0644 -D "$f" "./Licenses/$b/$x"
+        done
+
+    # hardlink duplicate documentation files
+    hardlink -cvf Docs/ Licenses/
+  popd
+done
+
+
+%check
+TESTDIRS="AMD CAMD CCOLAMD CHOLMOD COLAMD KLU LDL SPQR RBio UMFPACK"
+%if "%{?enable_csparse}" == "1"
+TESTDIRS="$TESTDIRS CSparse"
+%else
+TESTDIRS="$TESTDIRS CXSparse"
+%endif
+for build in SuiteSparse %{?build64:SuiteSparse64 SuiteSparse64_}
+do
+  pushd $build
+    export CFLAGS="$RPM_OPT_FLAGS -I%{_includedir}/metis"
+    export LAPACK=""
+    # Set flags for ILP64 build
+    if [ $build = SuiteSparse64 ]
+    then
+       export CFLAGS="$CFLAGS -DBLAS64"
+       export BLAS=-lopenblas64
+       export LIBRARY_SUFFIX=64
+    elif [ $build = SuiteSparse64_ ]
+    then
+       export CFLAGS="$CFLAGS -DBLAS64 -DSUN64"
+       export BLAS=-lopenblas64_
+       export LIBRARY_SUFFIX=64_
+    else
+       export BLAS=-lopenblas
+    fi
+
+    for d in $TESTDIRS ; do
+        %make_build -C $d/Demo \
+                    CFLAGS="$CFLAGS" LIB="%{?__global_ldflags} -lm -lrt" \
+                    BLAS="$BLAS" LIBRARY_SUFFIX="$LIBRARY_SUFFIX" \
+                    SPQR_CONFIG=-DHAVE_TBB TBB=-ltbb
+    done
+  popd
+done
 
 
 %clean
@@ -384,21 +419,98 @@ rm -rf ${RPM_BUILD_ROOT}
 
 
 %files
-%defattr(-,root,root)
-%doc Doc/*
-%{_libdir}/lib*.so.*
+%license SuiteSparse/Licenses
+%{_libdir}/libamd.so.%{amd_version_major}*
+%{_libdir}/libbtf.so.%{btf_version_major}*
+%{_libdir}/libcamd.so.%{camd_version_major}*
+%{_libdir}/libccolamd.so.%{ccolamd_version_major}*
+%{_libdir}/libcholmod.so.%{cholmod_version_major}*
+%{_libdir}/libcolamd.so.%{colamd_version_major}*
+%if "%{?enable_csparse}" == "1"
+%{_libdir}/libcsparse.so.%{csparse_version_major}*
+%endif
+%{_libdir}/libcxsparse.so.%{cxsparse_version_major}*
+%{_libdir}/libklu.so.%{klu_version_major}*
+%{_libdir}/libldl.so.%{ldl_version_major}*
+%{_libdir}/librbio.so.%{rbio_version_major}*
+%{_libdir}/libspqr.so.%{spqr_version_major}*
+%{_libdir}/libsuitesparseconfig.so.%{SuiteSparse_config_major}*
+%{_libdir}/libumfpack.so.%{umfpack_version_major}*
 
 %files devel
-%defattr(-,root,root)
 %{_includedir}/%{name}
 %{_libdir}/lib*.so
+%if 0%{?build64}
+%exclude %{_libdir}/lib*64*.so
+%endif
 
 %files static
-%defattr(-,root,root)
 %{_libdir}/lib*.a
+%if 0%{?build64}
+%exclude %{_libdir}/lib*64*.a
+%endif
+
+%if 0%{?build64}
+%files -n %{name}64
+%license SuiteSparse64/Licenses
+%{_libdir}/libamd64.so.%{amd_version_major}*
+%{_libdir}/libbtf64.so.%{btf_version_major}*
+%{_libdir}/libcamd64.so.%{camd_version_major}*
+%{_libdir}/libccolamd64.so.%{ccolamd_version_major}*
+%{_libdir}/libcholmod64.so.%{cholmod_version_major}*
+%{_libdir}/libcolamd64.so.%{colamd_version_major}*
+%if "%{?enable_csparse}" == "1"
+%{_libdir}/libcsparse64.so.%{csparse_version_major}*
+%endif
+%{_libdir}/libcxsparse64.so.%{cxsparse_version_major}*
+%{_libdir}/libklu64.so.%{klu_version_major}*
+%{_libdir}/libldl64.so.%{ldl_version_major}*
+%{_libdir}/librbio64.so.%{rbio_version_major}*
+%{_libdir}/libspqr64.so.%{spqr_version_major}*
+%{_libdir}/libsuitesparseconfig64.so.%{SuiteSparse_config_major}*
+%{_libdir}/libumfpack64.so.%{umfpack_version_major}*
+
+%files -n %{name}64-devel
+%{_libdir}/lib*64.so
+
+%files -n %{name}64-static
+%{_libdir}/lib*64.a
+
+%files -n %{name}64_
+%license SuiteSparse64_/Licenses
+%{_libdir}/libamd64_.so.%{amd_version_major}*
+%{_libdir}/libbtf64_.so.%{btf_version_major}*
+%{_libdir}/libcamd64_.so.%{camd_version_major}*
+%{_libdir}/libccolamd64_.so.%{ccolamd_version_major}*
+%{_libdir}/libcholmod64_.so.%{cholmod_version_major}*
+%{_libdir}/libcolamd64_.so.%{colamd_version_major}*
+%if "%{?enable_csparse}" == "1"
+%{_libdir}/libcsparse64_.so.%{csparse_version_major}*
+%endif
+%{_libdir}/libcxsparse64_.so.%{cxsparse_version_major}*
+%{_libdir}/libklu64_.so.%{klu_version_major}*
+%{_libdir}/libldl64_.so.%{ldl_version_major}*
+%{_libdir}/librbio64_.so.%{rbio_version_major}*
+%{_libdir}/libspqr64_.so.%{spqr_version_major}*
+%{_libdir}/libsuitesparseconfig64_.so.%{SuiteSparse_config_major}*
+%{_libdir}/libumfpack64_.so.%{umfpack_version_major}*
+
+%files -n %{name}64_-devel
+%{_libdir}/lib*64_.so
+
+%files -n %{name}64_-static
+%{_libdir}/lib*64_.a
+%endif
+
+%files doc
+%doc SuiteSparse/Doc/*
 
 
 %changelog
+* Sun Nov 03 2019 Toshiaki Ara <ara_t@384.jp> 5.4.0-1
+- update to 5.4.0
+- Build ILP64 version
+
 * Fri Jan 25 2019 Toshiaki Ara <ara_t@384.jp> 4.4.6-2
 - rebuild with gfortran-8.2.0