PKGBUILD (7097B)
1 # Based on AUR petsc and petsc-git package. 2 3 # Contributor: Lucas H. Gabrielli <heitzmann@gmail.com> 4 # Contributor: Martin Diehl <aur@martin-diehl.net> 5 6 _base=petsc 7 pkgname=("${_base}"-git) 8 pkgver=3.17.1.46.gbf2c2650373 9 pkgrel=1 10 _mainver="${pkgver:0:6}" 11 pkgdesc="Portable, extensible toolkit for scientific computation" 12 arch=('i686' 'x86_64') 13 url="https://gitlab.com/petsc/${_base}" 14 license=('BSD') 15 options=(!staticlibs) 16 depends=('openmpi' 'lapack' 'fftw' 'zlib' 'cython' 17 'python-mpi4py' "python-numpy" "eigen>=3" "openblas") 18 makedepends=('gcc' 'gcc-fortran' 'cmake' 'sowing' "pkgconf" 19 'git' 'cython' 'chrpath' "hypre") 20 source=(git+${url}.git#branch=release 21 https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-"${_mainver}".tar.gz 22 test_optdepends.sh) 23 sha512sums=('SKIP' 24 'SKIP' 25 'a4e064c08730058d63120a22c12657a100e5330546d66c44bb85e5bf84df80a23a729b0266af3efce2c8148f0266ddca99eaf9c8ea88d323cebe1d0c18c45d09') 26 27 _config=linux-c-opt 28 _install_dir="/usr" 29 30 # From UPC: Building And Using Static And Shared "C" 31 # Libraries.html 32 # #+begin_QUOTE 33 # we need that all jump calls ("goto", in assembly speak) 34 # and subroutine calls will use relative addresses, and not 35 # absolute addresses. Thus, we need to use ... ~-fPIC~ or 36 # ~-fpic~ 37 # #+end_QUOTE 38 # 39 # From makepkg.conf 40 # -march (or -mcpu) builds exclusively for an architecture 41 # -mtune optimizes for an architecture, but builds for 42 # whole processor family 43 # 44 # -O3 optimises 45 # 46 # -D-FORTIFY-SOURCE=2 47 # | https://stackoverflow.com/a/16604146 48 # |- man 7 feature_test_macros 49 # checks to be performed to detect some buffer overflow 50 # errors when employing various string and memory 51 # manipulation functions ... some conforming programs 52 # might fail 53 # 54 # -fcf-protection 55 # | Info pages for gcc (gnu compiler collection) 56 # intended to protect against such threats as 57 # Return-oriented Programming (ROP), and similarly 58 # call/jmp-oriented programming (COP/JOP) 59 # 60 # -pipe 61 # | Info pages for gcc (controlling the kind of output) 62 # Use pipes rather than temporary files for communication 63 # between the various stages of compilation 64 # 65 # -fno-plt 66 # | Info pages for gcc (code generation conventions) 67 # leads to more efficient code by eliminating PLT stubs and 68 # exposing GOT loads to optimizations 69 # 70 # -fopenmp 71 # | Info pages for gcc (controlling c dialect) 72 # Enable handling of OpenMP directives 73 # 74 75 safe_flags="-Wp,-D-FORTIFY-SOURCE=2,-D_GLIBCXX_ASSERTIONS" 76 safe_flags+=" -fcf-protection -fno-plt" 77 safe_flags+=" -fstack-clash-protection -Wformat" 78 safe_flags+=" -Werror=format-security" 79 generic_flags="-pipe -fno-plt -fPIC -fopenmp" 80 generic_flags+=" -march=native" 81 generic_flags+=" -mtune=native ${safe_flags}" 82 opt_flags="${generic_flags} -O3" 83 generic_flags="${generic_flags} -O2" 84 85 export LANG=C 86 export OMPI_MCA_opal_cuda_support=0 87 export OMPI_MCA_mpi_oversubscribe=0 88 unset PETSC_DIR 89 export PETSC_ARCH=${_config} 90 91 pkgver() { 92 cd "${srcdir}"/"${_base}" 93 git describe --tags --match '*.*' | tr '-' '.' | sed 's-^v--' 94 } 95 96 build() { 97 98 CONFOPTS=( 99 --silent --enable-silent-rules 100 --ignoreWarnings=1 101 --prefix="${_install_dir}" 102 --COPTFLAGS="${opt_flags}" 103 --CXXOPTFLAGS="${opt_flags}" 104 --FOPTFLAGS="${opt_flags}" 105 --CFLAGS="${generic_flags}" 106 --CXXFLAGS="$generic_flags" 107 --CPPFLAGS="$generic_flags" 108 --FCFLAGS="$generic_flags" 109 --F90FLAGS="$generic_flags" 110 --FFLAGS="$generic_flags" 111 --MAKEFLAGS=${MAKEFLAGS} 112 --LDFLAGS=${LDFLAGS} 113 --with-debugging=no 114 --with-environment-variables=1 115 --with-cxx-dialect=auto 116 --with-mpi=1 117 --with-pic=1 118 --with-shared-libraries=1 119 --with-zlib=1 120 --with-petsc4py=1 121 --with-single-library=1 122 " $(sh ${srcdir}/test_optdepends.sh)") 123 124 cd "${srcdir}"/"${_base}" 125 python ./configure ${CONFOPTS[@]} 126 make -s ${MAKEFLAGS} all 127 # MPIEXEC="$(which mpiexec) --nooversubscribe" make -s ${MAKEFLAGS} all 128 } 129 130 check() { 131 cd "${srcdir}"/"${_base}" 132 make check 133 } 134 135 package_petsc-git() { 136 optdepends=( 137 "boost: Free peer-reviewed portable C++ source libraries" 138 "cgns: Recording and recovering computer data" 139 "eigen: Lightweight C++ template library for vector and matrix math" 140 "fftw: Fast-Fourier Transform" 141 "gdb: Debugging" 142 "hdf5: large files" 143 "hwloc: Portable Hardware Locality (abstraction of hierarchical architectures)" 144 "med>=4.0: Data Modelization and Exchanges (meshes)" 145 "metis: Partitioning library (for meshes)" 146 "mumps: Sparse solver library" 147 "openblas: Linear algebra libraries" 148 "opencl-headers: for opencl (GPU computing)" 149 "opencl: GPU computing" 150 "openmp: Parallel distributed tasks" 151 "png" 152 "scalapack: Parallel memory linear algebra" 153 "scotch: Partitioning with sparse matrices" 154 "suitesparse: Sparse matrix library" 155 "superlu: Subroutines for sparsse linear systems" 156 "yaml: configuration files") 157 provides=(${_base}="${_mainver}" petsc4py="${_mainver}") 158 conflicts=(${_base}) 159 160 # # From OpenCV (hack destination of petsc4py) 161 # _pythonpath=`python -c "from sysconfig import get_path; print(get_path('platlib'))"` 162 # sed -i "s%\(installLibPath = \)os.path.join(self.installDir, 'lib')%\1'${_pythonpath}'%" 163 unset PETSC_DIR 164 _build_dir="${srcdir}"/"${_base}" 165 166 make -C "${_build_dir}" \ 167 ${MAKEFLAGS} DESTDIR="${pkgdir}" install 168 169 export PETSC_DIR=${_install_dir} 170 171 # install licence (even though there is no such word as licenses) 172 install -Dm 644 ${_build_dir}/LICENSE \ 173 "${pkgdir}"/"${_install_dir}"/share/licenses/"${pkgname}"/LICENSE 174 175 mkdir -p "${pkgdir}"/etc/profile.d 176 echo "export PETSC_DIR=${_install_dir}" > \ 177 "${pkgdir}"/etc/profile.d/${_base}.sh 178 # echo "export PYTHONPATH=\$PYTHONPATH:/${_install_dir}/${_base}/${_config}/lib" \ 179 # >> "${pkgdir}"/etc/profile.d/${_base}.sh 180 chmod +x "${pkgdir}"/etc/profile.d/${_base}.sh 181 182 # show where the shared libraries are 183 install -dm 755 "${pkgdir}"/etc/ld.so.conf.d/ 184 echo "${_install_dir}/lib" > \ 185 "${pkgdir}"/etc/ld.so.conf.d/${_base}.conf 186 187 # install pkgconfig settings 188 install -Dm 644 "${_build_dir}/${_config}"/lib/pkgconfig/PETSc.pc \ 189 "${pkgdir}"/"${_install_dir}"/share/pkgconfig/PETSc.pc 190 191 # cd "${srcdir}"/"${_base}"/src/binding/petsc4py 192 # CFLAGS="$(echo "${CFLAGS}" | sed 's%-D[^[:space:]]*%%g')" python setup.py install --root="${pkgdir}" --optimize=1 --skip-build 193 # cd - 194 _pythonpath="${pkgdir}"/`python -c "from sysconfig import get_path; print(get_path('platlib'))"` 195 install -dm 755 ${_pythonpath} 196 ln -s "${pkgdir}"/"${_install_dir}"/lib/petsc4py ${_pythonpath} 197 } 198 199 package_petsc-doc () { 200 depends=() 201 optdepends=() 202 provides=(${_base}-doc) 203 replaces=(${_base}-doc) 204 conflicts=() 205 pkgdesc="Documentation for PETSc" 206 # Two options: compile the documentation or get it from 207 # the web. Downloading is easier. 208 [[ -d ${pkgdir}/${_install_dir}/share/doc ]] && \ 209 rm -fr "${pkgdir}"/"${_install_dir}"/share/doc 210 mkdir -p "${pkgdir}"/"${_install_dir}"/share/doc 211 cp -r "${srcdir}/${_base}-${_mainver}/docs" \ 212 "${pkgdir}"/"${_install_dir}"/share/doc/${_base} 213 }