summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: dd088c9c15f86525bb5e8134e3209682100c7c10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Maintainer: Lucas H. Gabrielli <heitzmann@gmail.com>

pkgname=petsc-git
pkgver=20191031
pkgrel=1
_config=linux-c-opt
pkgdesc="Portable, extensible toolkit for scientific computation"
provides=(petsc)
conflicts=(petsc)
arch=('i686' 'x86_64')
url="https://www.mcs.anl.gov/petsc/"
license=('BSD')
depends=('python2' 'openmpi' 'boost' 'lapack' 'fftw' 'hdf5')
makedepends=('gcc' 'gcc-fortran' 'cmake')
install=petsc.install
source=(petsc::git+https://gitlab.com/petsc/petsc#branch=maint
        patch.diff)
sha256sums=('SKIP'
            'fdf016437dd94f33316e734e35858476aeea1ca0f3ab4d0ee36029b016498de7')

_petsc_arch="arch-${_config}"


pkgver() {
  cd petsc
  git log --format="%cd" --date=short -1 | sed 's/-//g'
}


prepare() {
  # force using python2
  MATCH='\(/usr/bin/env\|/usr/bin/\)python[[:digit:].]*'
  while IFS= read file; do
    sed -i "s#$MATCH#\\1python2#" "$file"
  done < <( find ${srcdir} -name "*" -type f -exec grep -le "$MATCH" \{\} + )

  cd "${srcdir}/petsc"
  patch -p1 < ../patch.diff
}


build() {
  cd petsc

  CONFOPTS='--with-shared-libraries=1 --COPTFLAGS=-O3 --CXXOPTFLAGS=-O3 --with-cxx-dialect=C++11 --with-mpi=1 --with-fftw=1 --with-hdf5=1 --with-zlib=1'

  # if --with-debugging=1 is set then PETSC_ARCH is automatically set to
  # "linux-c-debug" for some things, so _config should be changed to "linux-c-debug"
  #CONFOPTS="${CONFOPTS} --with-debugging=1"

  # Removed pastix due to incompatibility with current MPI (2019-10-31)
  for external_pkg in amd eigen hypre metis mumps parmetis party ptscotch scalapack suitesparse sundials superlu superlu_dist
  do
    CONFOPTS="${CONFOPTS} --download-${external_pkg}=1"
  done

  export PETSC_DIR="${srcdir}/petsc"
  export PETSC_ARCH="${_petsc_arch}"

  python2 ./configure LDFLAGS="$LDFLAGS" --prefix=/opt/petsc/${_config} ${CONFOPTS}

  make all
}


package() {
  cd petsc

  _build_dir="${srcdir}/petsc"
  _install_dir=/opt/petsc/${_config}

  export PETSC_DIR=${_build_dir}
  export PETSC_ARCH="${_petsc_arch}"

  make DESTDIR="${pkgdir}" install

  # documentation
  # Note: the hyperlinks between documentation, tutorials and examples are
  # not perfect yet
  #mkdir -p ${pkgdir}/usr/share/doc/petsc/
  #cp -r ${_build_dir}/docs ${pkgdir}/usr/share/doc/petsc/

  # src for tutorials
  #find ./src -path '*examples*' -type f -exec \
  #  install -Dm 644 "{}" "${pkgdir}/usr/share/doc/petsc/{}" \;

  # html versions of header files
  #mkdir -p ${pkgdir}/usr/share/doc/petsc/include
  #cp -r ${_build_dir}/include/*.html ${pkgdir}/usr/share/doc/petsc/include/

  # install licence (even though there is no such word as licenses)
  install -Dm 644 ${_build_dir}/LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE

  mkdir -p "${pkgdir}/etc/profile.d"
  echo "export PETSC_DIR=${_install_dir}" > "${pkgdir}/etc/profile.d/petsc.sh"
  chmod +x "${pkgdir}/etc/profile.d/petsc.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/petsc.conf"

	sed -i "s#-L${_build_dir}/${_petsc_arch}/lib ##" "${pkgdir}${_install_dir}/lib/pkgconfig/PETSc.pc"
  sed -i \
    -e "s#prefix=.*#prefix=${_install_dir}#" \
    -e "s#libdir=.*#libdir=\${prefix}/lib#" \
    -e "s#includedir=.*#includedir=\${prefix}/include#" \
    "${pkgdir}${_install_dir}/lib/pkgconfig/superlu.pc"
  sed -i \
    -e "s#prefix=.*#prefix=${_install_dir}#" \
    -e "s#libdir=.*#libdir=\${prefix}/lib#" \
    -e "s#includedir=.*#includedir=\${prefix}/include#" \
    "${pkgdir}${_install_dir}/lib/pkgconfig/superlu_dist.pc"
  sed -i \
    -e "s#prefix=.*#prefix=${_install_dir};#" \
    -e "s#libdir=.*#libdir=\${prefix}/lib;#" \
    "${pkgdir}${_install_dir}/lib/petsc/bin/sundials-config"

  # install pkgconfig settings
  #install -Dm 644 "${_build_dir}/${_petsc_arch}/lib/pkgconfig/PETSc.pc" "${pkgdir}/usr/share/pkgconfig/PETSc.pc"
}