summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7e8132bb4cbb2226649e77f21e67c255ef772f70 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Maintainer (lib32): Nocifer <apmichalopoulos at gmail dot com>
# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ronald van Haren <ronald.archlinux.org>
# Contributor: David Runge <dvzrv@archlinux.org>
# Contributor: damir <damir@archlinux.org>
# Contributor: Adam <adam900710@gmail.com>
# Contributor: GordonGR <ntheo1979@gmail.com>
# Contributor: josephgbr <rafael.f.f1@gmail.com>

_pkgname=fftw
pkgname=lib32-$_pkgname
pkgver=3.3.10
pkgrel=3
pkgdesc='A library for computing the discrete Fourier transform (DFT) (32 bit)'
arch=('x86_64')
url='https://www.fftw.org'
license=('GPL2')
depends=("$_pkgname" 'lib32-gcc-libs')
makedepends=('cmake' 'gcc-fortran')
provides=('libfftw3q_threads.so' 'libfftw3q_omp.so' 'libfftw3q.so'
          'libfftw3l_threads.so' 'libfftw3l_omp.so' 'libfftw3l.so'
          'libfftw3f_threads.so' 'libfftw3f_omp.so' 'libfftw3f.so'
          'libfftw3_threads.so' 'libfftw3_omp.so' 'libfftw3.so')
source=("https://www.fftw.org/$_pkgname-$pkgver.tar.gz")
sha256sums=('56c932549852cddcfafdab3820b0200c7742675be92179e59e6215b340e26467')

_build_types=(single double long-double quad)

prepare() {
  local _i

  # fix wrong soname in FFTW3LibraryDepends.cmake
  sed -e 's/3.6.9/3.6.10/' -i $_pkgname-$pkgver/CMakeLists.txt

  mv -v $_pkgname-$pkgver $_pkgname-$pkgver-single
  for _i in {1..3}; do
    cp -av $_pkgname-$pkgver-single $_pkgname-$pkgver-"${_build_types[$_i]}"
  done
}

build() {
  local _name
  local _configure=(
    ./configure
    --prefix=/usr
    --enable-shared
    --enable-threads
    --enable-openmp
    #--enable-mpi
    --libdir=/usr/lib32
  )
  local _configure_single=(
    --enable-sse
    --enable-avx
    --enable-single
  )
  local _configure_double=(
    --enable-sse2
    --enable-avx
  )
  local _configure_long_double=(
    --enable-long-double
  )
  local _configure_quad=(
    --disable-mpi
    --enable-quad-precision
  )
  local _cmake_options=(
    -B build
    -S $_pkgname-$pkgver-$_build_types
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_BUILD_TYPE=None
    -D ENABLE_OPENMP=ON
    -D ENABLE_THREADS=ON
    -D ENABLE_FLOAT=ON
    -D ENABLE_LONG_DOUBLE=ON
    -D ENABLE_QUAD_PRECISION=ON
    -D ENABLE_SSE=ON
    -D ENABLE_SSE2=ON
    -D ENABLE_AVX=ON
    -D ENABLE_AVX2=ON
  )

  # create missing FFTW3LibraryDepends.cmake
  # https://bugs.archlinux.org/task/67604
  cmake "${_cmake_options[@]}"
  # fix broken IMPORTED_LOCATION: https://github.com/FFTW/fftw3/issues/130#issuecomment-1030280157
  sed -e 's|\(IMPORTED_LOCATION_NONE\).*|\1 "/usr/lib32/libfftw3.so.3"|' -i build/FFTW3LibraryDepends.cmake

  export F77='gfortran'
  export CC='gcc -m32'
  export CXX='g++ -m32'
  export PKG_CONFIG_PATH='/usr/lib32/pkgconfig'
  # use upstream default CFLAGS while keeping our -march/-mtune
  CFLAGS+=" -O3 -fomit-frame-pointer -malign-double -fstrict-aliasing -ffast-math"

  for _name in "${_build_types[@]}"; do
    (
      cd $_pkgname-$pkgver-$_name
      case $_name in
        single)
        "${_configure[@]}" "${_configure_single[@]}"
        ;;
        double)
        "${_configure[@]}" "${_configure_double[@]}"
        ;;
        long-double)
        "${_configure[@]}" "${_configure_long_double[@]}"
        ;;
        quad)
        "${_configure[@]}" "${_configure_quad[@]}"
        ;;
      esac
      # fix overlinking because of libtool
      sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
    )
  done

  for _name in "${_build_types[@]}"; do
    make -C $_pkgname-$pkgver-$_name
  done
}

package() {
  local _name

  for _name in "${_build_types[@]}"; do
    make DESTDIR="$pkgdir" install -C $_pkgname-$pkgver-$_name
  done
  #install -vDm 644 $_pkgname-$pkgver-$_build_types/{AUTHORS,ChangeLog,NEWS,README,TODO} -t "$pkgdir/usr/share/doc/$_pkgname"
  # install missing FFTW3LibraryDepends.cmake
  install -vDm 644 build/FFTW3LibraryDepends.cmake -t "$pkgdir/usr/lib32/cmake/fftw3/"

  rm -rf "${pkgdir}/usr"/{bin,include,share}
}