123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- # This package tries to compile PETSc with a working branch
- # of the git sources (either main or release) and its
- # documentation. It prevents the use of non-free software
- # and finds most optional dependencies. The petsc package
- # from AUR is still recommended if you don't care about the
- # documentation, freedom or extra compatibility. If you find
- # any similarities to the petsc-git package it's because I was
- # the owner and maintainer of that package until I decided to
- # host this one.
- # Maintainer: eDgar <edgar |at] openmail cc>
- # Contributor: Martin Diehl <aur@martin-diehl.net>
- # Contributor: Lucas H. Gabrielli <heitzmann@gmail.com> (creator)
- _base=petsc
- pkgname=("${_base}"-free+opts "${_base}"-doc-bin)
- pkgver=3.20.5.910.gec4bd5ab864
- pkgrel=1
- _mainver="${pkgver:0:6}"
- pkgdesc="Portable, extensible toolkit for scientific computation"
- arch=('i686' 'x86_64')
- url="https://gitlab.com/petsc/${_base}"
- license=('BSD')
- # DAMASK requires PETSc's static libraries
- options=(staticlibs)
- depends=('openmpi' 'lapack' 'fftw' 'zlib' 'cython'
- 'python-mpi4py' "python-numpy" "eigen>=3" "blas-openblas")
- # Force version to force recompilation of HYPRE
- hypre=$(pacman -Qs hypre | head -n 1 | cut -f2 -d' ')
- makedepends=('gcc' 'gcc-fortran' 'cmake' 'sowing' "pkgconf"
- 'git' 'cython' 'chrpath' "hypre=${hypre}")
- source=("git+${url}.git#branch=main"
- "https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-with-docs-3.19.5.tar.gz"
- # "https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-with-docs-${_mainver}.tar.gz"
- test_optdepends.sh
- 0001-sowing-minversion1_1_26.patch)
- sha512sums=('SKIP'
- 'b00026074349f3995312b407044def7a104f62e9ba68e1b571e7f09ddb8aa56aa64bea5e5f9e5546d4d6866c37278d8b40334af2697bd0f837ca3981229d700a'
- '49bf2d313582a51d5ce866a9b5a640266a8132e817d2f5266c70f3b77ef3c49eac12a2a3bdcf773c8b030a3f7a47d5f4d7c082ff3f49a05bd8d18847453a1c0a'
- '3c156d1c465c10ba0a3c79b829f98ecc05e48b8f002a3a382f86ac834faaa34108d522f04757af38257f4a4e1292d8d8b79c9c039ecb9ea25444d902a384907f')
- install=petsc.install
- _config=linux-c-opt
- _install_dir="/usr"
- # From UPC: Building And Using Static And Shared "C"
- # Libraries.html
- # #+begin_QUOTE
- # we need that all jump calls ("goto", in assembly speak)
- # and subroutine calls will use relative addresses, and not
- # absolute addresses. Thus, we need to use ... ~-fPIC~ or
- # ~-fpic~
- # #+end_QUOTE
- #
- # From makepkg.conf
- # -march (or -mcpu) builds exclusively for an architecture
- # -mtune optimizes for an architecture, but builds for
- # whole processor family
- #
- # -O3 optimises
- #
- # -D-FORTIFY-SOURCE=2
- # | https://stackoverflow.com/a/16604146
- # |- man 7 feature_test_macros
- # checks to be performed to detect some buffer overflow
- # errors when employing various string and memory
- # manipulation functions ... some conforming programs
- # might fail
- #
- # -fcf-protection
- # | Info pages for gcc (gnu compiler collection)
- # intended to protect against such threats as
- # Return-oriented Programming (ROP), and similarly
- # call/jmp-oriented programming (COP/JOP)
- #
- # -pipe
- # | Info pages for gcc (controlling the kind of output)
- # Use pipes rather than temporary files for communication
- # between the various stages of compilation
- #
- # -fno-plt
- # | Info pages for gcc (code generation conventions)
- # leads to more efficient code by eliminating PLT stubs and
- # exposing GOT loads to optimizations
- #
- # -fopenmp
- # | Info pages for gcc (controlling c dialect)
- # Enable handling of OpenMP directives
- safe_flags="-Wp,-D-FORTIFY-SOURCE=2,-D_GLIBCXX_ASSERTIONS"
- safe_flags+=" -fcf-protection -fno-plt"
- safe_flags+=" -fstack-clash-protection -Wformat"
- safe_flags+=" -Werror=format-security"
- generic_flags="-march=native -mtune=native"
- generic_flags+=" -pipe -fno-plt -fPIC -fopenmp"
- generic_flags+="${safe_flags}"
- opt_flags="${generic_flags} -O3"
- generic_flags="${generic_flags} -O2"
- export LANG=C
- # Try to mute warnings from missing CUDA
- # https://github.com/open-mpi/ompi/issues/4405
- export OMPI_MCA_opal_cuda_support=0
- # (muting may not work:
- # https://github.com/open-mpi/ompi/issues/10049)
- export OMPI_MCA_opal_warn_on_missing_libcuda=0
- # export OMPI_MCA_mpi_oversubscribe=0
- unset PETSC_DIR
- export PETSC_ARCH=${_config}
- prepare() {
- cd "${srcdir}"/"${_base}"
- # patch -Np1 -i "${srcdir}"/hypre_global_error.error_flag-0.patch
- patch -Np1 -i "${srcdir}"/0001-sowing-minversion1_1_26.patch
- }
- pkgver() {
- cd "${srcdir}"/"${_base}"
- git describe --tags --match '*.*' | tr '-' '.' | sed 's-^v--'
- }
- build() {
- CONFOPTS=(
- --silent --enable-silent-rules
- --ignoreWarnings=1
- --prefix="${_install_dir}"
- --COPTFLAGS="${opt_flags}"
- --CXXOPTFLAGS="${opt_flags}"
- --FOPTFLAGS="${opt_flags}"
- --CFLAGS="${generic_flags}"
- --CXXFLAGS="$generic_flags"
- --CPPFLAGS="$generic_flags"
- --FCFLAGS="$generic_flags"
- --F90FLAGS="$generic_flags"
- --FFLAGS="$generic_flags"
- --MAKEFLAGS=${MAKEFLAGS}
- --LDFLAGS=${LDFLAGS}
- --with-environment-variables=1
- --with-cxx-dialect=auto
- --with-mpi=1
- --with-pic=1
- --with-shared-libraries=1
- --with-zlib=1
- --with-petsc4py=1
- --with-mpi-f90module-visibility=0
- --with-cuda=0
- # Disabled for DAMASK
- # --with-scalar-type=complex
- " $(sh ${srcdir}/test_optdepends.sh)")
- # --with-single-library=1
- cd "${srcdir}"/"${_base}"
- export PETSC_DIR="${srcdir}"/"${_base}"
- python ./configure ${CONFOPTS[@]}
- make -s ${MAKEFLAGS} all
- make DESTDIR=${srcdir}/tmp install
- }
- check() {
- cd "${srcdir}"/"${_base}"
- if [ -z "$(ldconfig -p | grep libcuda.so.1)" ]; then
- export OMPI_MCA_opal_warn_on_missing_libcuda=0
- fi
- export OMPI_MCA_plm_rsh_agent=sh
- PYTHONPATH=${srcdir}/tmp/${_install_dir}/lib:${PYTHONPATH} make check ||
- printf "Tests failed\n"
- }
- package_petsc-free+opts() {
- optdepends=(
- "boost: Free peer-reviewed portable C++ source libraries"
- "cgns: Recording and recovering computer data"
- "eigen: Lightweight C++ template library for vector and matrix math"
- "fftw: Fast-Fourier Transform"
- "gdb: Debugging"
- "hdf5: large files"
- "hwloc: Portable Hardware Locality (abstraction of hierarchical architectures)"
- "med>=4.0: Data Modelization and Exchanges (meshes)"
- "metis: Partitioning library (for meshes)"
- "mumps: Sparse solver library"
- "netcdf-openmpi: Management of array-data"
- "openblas: Linear algebra libraries"
- "opencl: GPU computing"
- "opencl-headers: for opencl (GPU computing)"
- "opencl-clhpp: for opencl C++ compatibility (GPU computing)"
- "openmp: Parallel distributed tasks"
- "libpng"
- "scalapack: Parallel memory linear algebra"
- "scotch: Partitioning with sparse matrices"
- "suitesparse: Sparse matrix library"
- "superlu: Subroutines for sparsse linear systems"
- "tetgen: For meshing (tetrahedral mesh and 3D Delaunay triangulator)"
- "libyaml: configuration files")
- provides=(${_base}="${_mainver}"
- petsc4py="${_mainver}"
- ${_base}="${pkgver}-${pkgrel}"
- petsc4py="${pkgver}-${pkgrel}")
- conflicts=(${_base} ${_base}-git)
- # # From OpenCV (hack destination of petsc4py)
- # _pythonpath=`python -c "from sysconfig import get_path; print(get_path('platlib'))"`
- # sed -i "s%\(installLibPath = \)os.path.join(self.installDir, 'lib')%\1'${_pythonpath}'%"
- unset PETSC_DIR
- _build_dir="${srcdir}"/"${_base}"
- make -C "${_build_dir}" \
- ${MAKEFLAGS} DESTDIR="${pkgdir}" install
- export PETSC_DIR=${_install_dir}
- # install licence (even though there is no such word as licenses)
- install -Dm 644 ${_build_dir}/LICENSE \
- "${pkgdir}"/"${_install_dir}"/share/licenses/"${pkgname}"/LICENSE
- mkdir -p "${pkgdir}"/etc/profile.d
- echo "export PETSC_DIR=${_install_dir}" > \
- "${pkgdir}"/etc/profile.d/${_base}.sh
- echo "export OMPI_MCA_opal_cuda_support=0 OMPI_MCA_opal_warn_on_missing_libcuda=0" >> \
- "${pkgdir}"/etc/profile.d/${_base}.sh
- # echo "export PYTHONPATH=\$PYTHONPATH:/${_install_dir}/${_base}/${_config}/lib" \
- # >> "${pkgdir}"/etc/profile.d/${_base}.sh
- chmod +x "${pkgdir}"/etc/profile.d/${_base}.sh
- # show where the shared libraries are
- install -dm 755 "${pkgdir}"/etc/ld.so.conf.d/
- echo "${_install_dir}/lib" > \
- "${pkgdir}"/etc/ld.so.conf.d/${_base}.conf
- # install pkgconfig settings
- install -Dm 644 "${_build_dir}/${_config}"/lib/pkgconfig/PETSc.pc \
- "${pkgdir}"/"${_install_dir}"/share/pkgconfig/PETSc.pc
- # cd "${srcdir}"/"${_base}"/src/binding/petsc4py
- # CFLAGS="$(echo "${CFLAGS}" | sed 's%-D[^[:space:]]*%%g')" python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
- # cd -
- _pythonpath="${pkgdir}"/`python -c "from sysconfig import get_path; print(get_path('platlib'))"`
- install -dm 755 ${_pythonpath}
- ln -s "${_install_dir}"/lib/petsc4py ${_pythonpath}
- }
- package_petsc-doc-bin () {
- depends=()
- optdepends=()
- provides=(${_base}-doc)
- conflicts=()
- pkgdesc="Documentation for PETSc"
- # Two options: compile the documentation or get it from
- # the web. Downloading is easier.
- [[ -d ${pkgdir}/${_install_dir}/share/doc ]] && \
- rm -fr "${pkgdir}"/"${_install_dir}"/share/doc
- mkdir -p "${pkgdir}"/"${_install_dir}"/share/doc
- cp -r "${srcdir}/${_base}-"*"/docs" \
- "${pkgdir}"/"${_install_dir}"/share/doc/${_base}
- }
|