#!/bin/bash # Script to make the LAPACK/LAPACK95 libraries. # Exit Codes found in /usr/include/sysexits.h # Adding ACC_SET_GMAKE_JOBS to build as requested in RT#67548 #set -x # Function to configure, make and then install the Package - contains Package Specific build configuration func_configure_make_install () { [ "${BUILD_TYPE}" == "debug" ] \ && CMAKE_BUILD_TYPE="Debug" \ || CMAKE_BUILD_TYPE="Release" [ -d ${UTIL_DIR}/bin ] \ && PATH=${UTIL_DIR}/bin${PATH:+:${PATH}} [ "${CMAKE_BINARY}" ] \ || CMAKE_BINARY=cmake cd ${WORK_DIR} export FORTRAN="${FC}" export LOADER="${FC}" # Removed incompatable nofor_main LDFLAGS for SHARED library builds, as requested in RT#54929 [ "${FC}" == "ifort" ] && FFLAGS="-nofor_main ${FFLAGS}" && LDFLAGS=" ${LDFLAGS}" export OPTS="${FFLAGS}" export DRVOPTS=${OPTS} export NOOPT=${OPTS} export LOADOPTS=${LDFLAGS} export BUILD_DEPRECATED="Yes" [ "${FC}" == "gfortran" ] && export TIMER="INT_ETIME" || export TIMER="EXT_ETIME" # Fix for Intel ifort SHARED only library builds as requested in RT#63875 # As documented in https://github.com/xianyi/OpenBLAS/pull/1104 if [ "${FC}" == "ifort" ] ; then sed -i "s%SSCAL, SSTERF, XERBLA, CLASCL, CSTEQR%SSCAL, SSTERF, XERBLA, CLASCL, CSTEQR,%g" SRC/chbev_2stage.f sed -i "s%DLASCL, DSCAL, DSTEQR, DSTERF, XERBLA%DLASCL, DSCAL, DSTEQR, DSTERF, XERBLA,%g" SRC/dsbev_2stage.f sed -i "s%SLASCL, SSCAL, SSTEQR, SSTERF, XERBLA%SLASCL, SSCAL, SSTEQR, SSTERF, XERBLA,%g" SRC/ssbev_2stage.f sed -i "s%DSCAL, DSTERF, XERBLA, ZLASCL, ZSTEQR%DSCAL, DSTERF, XERBLA, ZLASCL, ZSTEQR,%g" SRC/zhbev_2stage.f sed -i "s%XERBLA, ZCOPY, ZDSCAL, ZGEMV, ZLATRS%XERBLA, ZCOPY, ZDSCAL, ZGEMV, ZLATRS,%g" SRC/ztrevc3.f fi if [ ! -e ALREADY_BUILT ] ; then mkdir lib [ -d SRC/VARIANTS/LIB ] || mkdir SRC/VARIANTS/LIB [ -d ${BUILD_TYPE} ] || ln -s ../../${BUILD_TYPE} ${BUILD_TYPE} func_print_compiler_linker_flags func_create_makeinc_Makefile # For SHARED only library builds as requested in RT#63875 if [ "${BUILD_SHARED_ONLY}" -ne 1 ] ; then if [ ! -L bin ] ; then # Only build libraies, not test binaries, as requested in RT#54929 ${GMAKE} -j ${ACC_SET_GMAKE_JOBS} lib export RETVAL=$? if [ "${RETVAL}" -eq 0 ] ; then [ -L ../bin ] && rm -f ../bin && ln -s TESTING ../bin [ ! -e libblas.a ] && cp lib/*.a ${OUTPUT_DIR}/lib/ fi else ${GMAKE} -j ${ACC_SET_GMAKE_JOBS} lib export RETVAL=$? if [ "${RETVAL}" -eq 0 ] ; then [ ! -e libblas.a ] && cp lib/*.a ${OUTPUT_DIR}/lib/ fi fi fi # For cmake SHARED library builds, as requested in RT#54929 if [ "${BUILD_SHARED}" -eq 1 ] ; then echo -e "Building SHARED Libraries...\n" mkdir BUILD cd BUILD if [ "${ARGUMENTS[1]}" == "-test" ] ; then TEST_STATUS=ON else TEST_STATUS=OFF fi ${CMAKE_BINARY} \ -DCMAKE_INSTALL_PREFIX=${OUTPUT_DIR} \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_TESTING=${TEST_STATUS} \ -DBUILD_DEPRECATED=YES \ -DCBLAS=OFF \ -DLAPACKE=ON \ -DLAPACKE_WITH_TMG=ON \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DCMAKE_INSTALL_LIBDIR=${OUTPUT_DIR}/lib \ -DCMAKE_Fortran_MODULE_DIRECTORY=${OUTPUT_DIR}/modules \ -DCMAKE_Fortran_COMPILER=${FC} \ -DCMAKE_Fortran_COMPILER_WORKS=TRUE \ -DCMAKE_C_COMPILER_WORKS=TRUE \ ../ ${CMAKE_BINARY} --build . -j ${ACC_SET_GMAKE_JOBS} --target install export RETVAL=$? fi # LAPACK95 separated from Lapack, as requested in RT#54929 #if [ "${RETVAL}" -eq 0 ] ; then # unset PACKAGE_VERSION # cd ${WORK_DIR}/LAPACK95 # ./acc_build ${ARGUMENTS[0]} ${ARGUMENTS[1]} # export RETVAL=$? #fi fi if [ "${ARGUMENTS[1]}" == "-test" ] ; then echo -e "\nBuilding tests for `echo ${PACKAGE_VERSION}`...\n" [ ${BUILD_SHARED} ] && ctest || ${GMAKE} test export RETVAL=$? # LAPACK95 separated from Lapack, as requested in RT#54929 #if [ "${RETVAL}" -eq 0 ] ; then # unset PACKAGE_VERSION # cd LAPACK95 # ./acc_build ${ARGUMENTS[0]} ${ARGUMENTS[1]} # export RETVAL=$? #fi fi if ( [ `uname` == "Darwin" ] && [ "${FC}" == "ifort" ] && [ "${RETVAL}" -eq 0 ] ) ; then ln -s /opt/intel/lib/* ${OUTPUT_DIR}/lib/ &> /dev/null 2>&1 ; fi unset FORTRAN unset LOADER unset OPTS unset DRVOPTS unset NOOPT unset LOADOPTS } # Function that contains Package Specific files and directories to be cleaned up func_remove_package () { # LAPACK95 separated from Lapack, as requested in RT#54929 rm -f ${OUTPUT_DIR}/include/lapack* rm -rf ${OUTPUT_DIR}/lib/cmake/lapack* rm -f ${OUTPUT_DIR}/lib/libblas.* rm -f ${OUTPUT_DIR}/lib/libcblas.* rm -f ${OUTPUT_DIR}/lib/liblapack.* rm -f ${OUTPUT_DIR}/lib/libtmglib.* #rm -f ${OUTPUT_DIR}/lib/lapack95.* #rm -f ${OUTPUT_DIR}/lib/liblapack95.* rm -f ${OUTPUT_DIR}/lib/liblapacke.* rm -f ${OUTPUT_DIR}/lib/pkgconfig/blas.* rm -f ${OUTPUT_DIR}/lib/pkgconfig/lapack*.* rm -f ${OUTPUT_DIR}/lib/pkgconfig/blas.* #rm -f ${OUTPUT_DIR}/modules/f77_lapack.mod #rm -f ${OUTPUT_DIR}/modules/f95_lapack.mod #rm -f ${OUTPUT_DIR}/modules/la_auxmod.mod #rm -f ${OUTPUT_DIR}/modules/la_precision.mod rm -f `pwd`/bin rm -rf ${BUILD_TYPE} } # Function that create Bmad Distribution Specific make.inc and Makefile files. func_create_makeinc_Makefile () { # Modify LAPACKE/src/Makefile, if ACC_COMPILER_TOOLSET is set to "mingw" # MSYS/MinGW: `ar` can't handle too many arguments. # See: http://trac.haskell.org/gtk2hs/ticket/1146 # Changes requested by Thomas Gläßle if [[ $ACC_COMPILER_TOOLSET == mingw* ]] ; then sed -i 's;$(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ) $(ALLXOBJ) $(DEPRECATED);echo $^ | xargs --max-args=100 $(ARCH) $(ARCHFLAGS) $@;g' LAPACKE/src/Makefile fi # Create default make.inc file cat <<\EOF > make.inc #################################################################### # LAPACK make include file. # # LAPACK, Version 3.7.0 # # December 2016 # # # # Modified for Cornell CLASSE BMAD_DIST A. De Falco 26-May-2017 # #################################################################### # SHELL = /bin/bash # # Modify the FORTRAN and OPTS definitions to refer to the # compiler and desired compiler options for your machine. NOOPT # refers to the compiler options desired when NO OPTIMIZATION is # selected. Define LOADER and LOADOPTS to refer to the loader and # desired load options for your machine. # #FORTRAN = #OPTS = #DRVOPTS = #NOOPT = #LOADER = #LOADOPTS = #TIMER = # # Timer for the SECOND and DSECND routines # # Default : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME # TIMER = EXT_ETIME # For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_ # TIMER = EXT_ETIME_ # For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME # TIMER = INT_ETIME # If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...) # SECOND and DSECND will use a call to the INTERNAL FUNCTION CPU_TIME # TIMER = INT_CPU_TIME # If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0 # TIMER = NONE # # Configuration LAPACKE: Native C interface to LAPACK # To generate LAPACKE library: type 'make lapackelib' # Configuration file: turned off (default) # Complex types: C99 (default) # Name pattern: mixed case (default) # (64-bit) Data model: LP64 (default) # # CC is the C compiler, normally invoked with options CFLAGS. # CC=gcc CFLAGS = -O3 # # The archiver and the flag(s) to use when building archive (library) # If you system has no ranlib, set RANLIB = echo. # ARCH = ar ARCHFLAGS= cr RANLIB = ranlib # # Location of the extended-precision BLAS (XBLAS) Fortran library # used for building and testing extended-precision routines. The # relevant routines will be compiled and XBLAS will be linked only if # USEXBLAS is defined. # # USEXBLAS = Yes XBLASLIB = # XBLASLIB = -lxblas # # Using Deprecated routines for LAPACK95 compatibility. # # BUILD_DEPRECATED = Yes # # The location of the libraries to which you will link. (The # machine-specific, optimized BLAS library should be used whenever # possible.) # BLASLIB = ../../lib/libblas.a CBLASLIB = ../../lib/libcblas.a LAPACKLIB = lib/liblapack.a TMGLIB = lib/libtmglib.a LAPACKELIB = lib/liblapacke.a EOF if [[ $ACC_COMPILER_TOOLSET == mingw* ]] ; then echo "CC=gcc" >> make.inc fi # Create top level Makefile file cat <<\EOF > Makefile # # Top Level Makefile for LAPACK # Version 3.4.2 # Sept 2012 # # Modified for Cornell CLASSE BMAD_DIST A. De Falco 26-May-2017 include make.inc all: lapack_install lib lib: blaslib variants lapacklib lapackelib tmglib cblaslib clean: cleanlib cleantesting cleanblas_testing cleancblas_testing lapack_install: ( cd INSTALL; $(MAKE) ; ./testlsame; ./testslamch; ./testdlamch; \ ./testsecond; ./testdsecnd; ./testieee; ./testversion ) blaslib: ( cd BLAS/SRC; $(MAKE) ) cblaslib: ( cd CBLAS; $(MAKE) ) lapacklib: lapack_install ( cd SRC; $(MAKE) ) lapackelib: lapacklib ( cd LAPACKE; $(MAKE) ) cblas_example: cblaslib blaslib ( cd CBLAS/examples; $(MAKE) ) lapacke_example: lapackelib ( cd LAPACKE/example; $(MAKE) ) variants: ( cd SRC/VARIANTS ; $(MAKE) ) tmglib: ( cd TESTING/MATGEN; $(MAKE) ) lapack_testing: lib ( cd TESTING ; $(MAKE) ) ./lapack_testing.py variants_testing: lib variants ( cd TESTING ; rm -f xlintst* ; $(MAKE) VARLIB='SRC/VARIANTS/LIB/cholrl.a' ; \ mv stest.out stest_cholrl.out ; mv dtest.out dtest_cholrl.out ; mv ctest.out ctest_cholrl.out ; mv ztest.out ztest_cholrl.out ) ( cd TESTING ; rm -f xlintst* ; $(MAKE) VARLIB='SRC/VARIANTS/LIB/choltop.a' ; \ mv stest.out stest_choltop.out ; mv dtest.out dtest_choltop.out ; mv ctest.out ctest_choltop.out ; mv ztest.out ztest_choltop.out ) ( cd TESTING ; rm -f xlintst* ; $(MAKE) VARLIB='SRC/VARIANTS/LIB/lucr.a' ; \ mv stest.out stest_lucr.out ; mv dtest.out dtest_lucr.out ; mv ctest.out ctest_lucr.out ; mv ztest.out ztest_lucr.out ) ( cd TESTING ; rm -f xlintst* ; $(MAKE) VARLIB='SRC/VARIANTS/LIB/lull.a' ; \ mv stest.out stest_lull.out ; mv dtest.out dtest_lull.out ; mv ctest.out ctest_lull.out ; mv ztest.out ztest_lull.out ) ( cd TESTING ; rm -f xlintst* ; $(MAKE) VARLIB='SRC/VARIANTS/LIB/lurec.a' ; \ mv stest.out stest_lurec.out ; mv dtest.out dtest_lurec.out ; mv ctest.out ctest_lurec.out ; mv ztest.out ztest_lurec.out ) ( cd TESTING ; rm -f xlintst* ; $(MAKE) VARLIB='SRC/VARIANTS/LIB/qrll.a' ; \ mv stest.out stest_qrll.out ; mv dtest.out dtest_qrll.out ; mv ctest.out ctest_qrll.out ; mv ztest.out ztest_qrll.out ) blas_testing: ( cd BLAS/TESTING; $(MAKE) -f Makeblat1 ) ( cd BLAS; ./xblat1s > sblat1.out ; \ ./xblat1d > dblat1.out ; \ ./xblat1c > cblat1.out ; \ ./xblat1z > zblat1.out ) ( cd BLAS/TESTING; $(MAKE) -f Makeblat2 ) ( cd BLAS; ./xblat2s < sblat2.in ; \ ./xblat2d < dblat2.in ; \ ./xblat2c < cblat2.in ; \ ./xblat2z < zblat2.in ) ( cd BLAS/TESTING; $(MAKE) -f Makeblat3 ) ( cd BLAS; ./xblat3s < sblat3.in ; \ ./xblat3d < dblat3.in ; \ ./xblat3c < cblat3.in ; \ ./xblat3z < zblat3.in ) cblas_testing: blaslib ( cd CBLAS; $(MAKE) cblas_testing ) ( cd CBLAS; $(MAKE) runtst ) html: @echo "LAPACK HTML PAGES GENRATION with Doxygen" doxygen DOCS/Doxyfile @echo "==================" @echo "LAPACK HTML PAGES GENRATED in DOCS/explore-html" @echo "Usage: open DOCS/explore-html/index.html" @echo "Online version available at http://www.netlib.org/lapack/explore-html/" @echo "==================" man: @echo "LAPACK MAN PAGES GENRATION with Doxygen" doxygen DOCS/Doxyfile_man @echo "==================" @echo "LAPACK MAN PAGES GENRATED in DOCS/MAN" @echo "Set your MANPATH env variable accordingly" @echo "Usage: man dgetrf.f" @echo "==================" cleanlib: ( cd INSTALL; $(MAKE) clean ) ( cd BLAS/SRC; $(MAKE) clean ) ( cd SRC; $(MAKE) clean ) ( cd SRC/VARIANTS; $(MAKE) clean ) ( cd TESTING/MATGEN; $(MAKE) clean ) ( cd lapacke; $(MAKE) clean ) cleanblas_testing: ( cd BLAS/TESTING; $(MAKE) -f Makeblat1 clean ) ( cd BLAS/TESTING; $(MAKE) -f Makeblat2 clean ) ( cd BLAS/TESTING; $(MAKE) -f Makeblat3 clean ) ( cd BLAS; rm -f xblat* ) cleancblas_testing: ( cd CBLAS/testing; $(MAKE) clean ) cleantesting: ( cd TESTING/LIN; $(MAKE) clean ) ( cd TESTING/EIG; $(MAKE) clean ) ( cd TESTING; rm -f xlin* xeig* ) cleanall: cleanlib cleanblas_testing cleantesting rm -f *.a TESTING/*.out INSTALL/test* BLAS/*.out test: lapacke_example blas_testing cblas_example cblas_testing variants_testing lapack_testing EOF }