# Testcase run by default. To disable: rpm(or rpmbuild) -ba --define 'dotests 0' openblas*.spec %{!?dotests: %define dotests 1} %global _pkgconfigdir %{_libdir}/pkgconfig Summary: An optimized BLAS library based on GotoBLAS2 Name: openblas Version: 0.3.8 Release: 1 License: BSD Group: Development/Libraries URL: https://github.com/xianyi/OpenBLAS #Source0: https://github.com/xianyi/OpenBLAS/archive/v%{version}/OpenBLAS-%{version}.tar.gz Source0: https://github.com/xianyi/OpenBLAS/archive/v%{version}/OpenBLAS-%{version}.zip Patch0: openblas-Dont_cross_compile.patch # Patch reduced vs version for 0.3.6 Patch1: openblas-0.3.8-power8-aix.patch # Patch2: openblas-power8-big-endian-fix.patch Patch3: openblas-0.3.8-AIX-TARGETS.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: gcc-gfortran >= 6.3.0 BuildRequires: libgomp >= 6.3.0 Requires: libgcc >= 6.3.0 Requires: gcc-gfortran >= 6.3.0 Requires: libgomp >= 6.3.0 %description OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version. It is an open source implementation of the BLAS (Basic Linear Algebra Subprograms) API with many hand-crafted optimizations for specific processor types.OpenBLAS adds optimized implementations of linear algebra kernels for several processor architectures. This version contains POWER 6 and POWER 8 builds. Depending on the processor running mode, either POWER6 or POWER8 files (libraries, headers, pkgconfig (.pc file)) will be set as default. This is done by the post installation script of this rpm. %prep %setup -q -n OpenBLAS-%{version} %patch0 -p0 %patch3 -p1 rm -rf /tmp/%{name}-%{version}-power6 cp -pr . /tmp/%{name}-%{version}-power6 rm -fr * mv /tmp/%{name}-%{version}-power6 power6 cp -pr power6 power8 cd power8 %patch1 -p1 # %patch2 -p1 %build PATH=/opt/freeware/bin:$PATH export CC="gcc -maix64" export CXX="g++ -maix64" export FC="gfortran -maix64" for arch in power8 power6 do cd $arch make BINARY=64 TARGET=$(echo $arch | /usr/bin/tr '[a-z]' '[A-Z]') if [ "%{dotests}" == 1 ] then cd utest gcc -maix64 -I.. -I. utest_main2.c ../libopenblas.a -lgomp -lpthread -lm -o utest2 ./utest2 cd .. fi #This needs CreateExportList which comes from XLC fileset. #So better we use the one from GNU libtool #/usr/vac/bin/CreateExportList -X64 openblas.exp libopenblas.a `echo /usr/bin/nm -X32_64 | /usr/bin/sed -e 's/B\([^B]*\)$/P\1/'` -PCpgl libopenblas.a | \ /usr/bin/awk '{ if ((($ 2 == "T") || ($ 2 == "D") || ($ 2 == "B") || ($ 2 == "W") || ($ 2 == "V") || ($ 2 == "Z")) \ && (substr($ 1,1,1) != ".")) { if (($ 2 == "W") || ($ 2 == "V") || ($ 2 == "Z")) { print $ 1 " weak" } \ else { print $ 1 } } }' | /usr/bin/sort -u > openblas.exp export LDFLAGS="-lm -lpthread -lgfortran -lgomp -Wl,-bE:openblas.exp -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bbigtoc" gcc -maix64 -shared libopenblas_${arch}p-r%{version}.a -o libopenblas.so.0 $LDFLAGS unset LDFLAGS cd .. done %install [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} PATH=/opt/freeware/bin:$PATH export CC="gcc -maix64" export CXX="g++ -maix64" export FC="gfortran -maix64" for arch in power8 power6 do TARGET=$(echo $arch | /usr/bin/tr '[a-z]' '[A-Z]') cd $arch make install DESTDIR=${RPM_BUILD_ROOT} PREFIX=%{_prefix} mkdir ${RPM_BUILD_ROOT}%{_includedir}/OpenBLAS_${TARGET} /usr/bin/mv ${RPM_BUILD_ROOT}%{_includedir}/*.h ${RPM_BUILD_ROOT}%{_includedir}/OpenBLAS_${TARGET} mkdir ${RPM_BUILD_ROOT}%{_libdir}/OpenBLAS_${TARGET} /usr/bin/mv ${RPM_BUILD_ROOT}%{_libdir}/pkgconfig ${RPM_BUILD_ROOT}%{_libdir}/OpenBLAS_${TARGET} /usr/bin/rm ${RPM_BUILD_ROOT}/%{_libdir}/libopenblas.* /usr/bin/ar -X64 -q ${RPM_BUILD_ROOT}/%{_libdir}/OpenBLAS_${TARGET}/libopenblas.a libopenblas.so.0 cd .. done #create symbolic links in the original path towards POWER8 files cd ${RPM_BUILD_ROOT}%{_includedir} ln -sf OpenBLAS_POWER8/* . cd ${RPM_BUILD_ROOT}%{_libdir} ln -sf OpenBLAS_POWER8/libopenblas.a . mkdir ${RPM_BUILD_ROOT}%{_pkgconfigdir} cd ${RPM_BUILD_ROOT}%{_pkgconfigdir} ln -sf ../OpenBLAS_POWER8/pkgconfig/openblas.pc . %pre # Processor Version: PV_7_Compat # Processor Version: PV_6_Compat # Processor Version: PV_5_Compat ProcVersion=`prtconf | grep "Processor Version:" | awk -F_ '{ print $2}'` #echo $ProcVersion if [ $ProcVersion -lt 6 ] then echo "This rpm will only work with Power6 (and above) compatibility mode." echo "prtconf: " prtconf | grep "Processor Version:" exit 1 fi %post ProcVersion=`prtconf | grep "Processor Version:" | awk -F_ '{ print $2}'` if [ $ProcVersion -lt 8 ] then cd %{_includedir} ; ln -sf OpenBLAS_POWER6/* . cd %{_libdir} ; ln -sf OpenBLAS_POWER6/libopenblas.a . cd %{_pkgconfigdir} ; ln -sf ../OpenBLAS_POWER6/pkgconfig/openblas.pc . echo "Since the Machine Processor Version is below Power 8, Power 6 code built OpenBLAS library, headers & pkgconfig files are made default." fi %clean [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} %files %defattr(-,root,system) %doc power8/LICENSE power8/README.md power8/USAGE.md power8/GotoBLAS_00License.txt %{_libdir}/libopenblas.a %{_libdir}/pkgconfig/openblas.pc %{_libdir}/OpenBLAS_POWER6 %{_libdir}/OpenBLAS_POWER8 %{_includedir}/* %changelog * Thu Aug 29 2019 Ayappan P - 0.3.6-1 - Update to 0.3.6 - Power8 code build as well * Wed Mar 20 2019 Ayappan P - 0.3.5-1 - First port to AIX Toolbox