APP=fftw
VERSION=3.3.8
BUILD=1sml
HOMEPAGE='http://www.fftw.org/'
DOWNLOAD='https://www.fftw.org/fftw-3.3.8.tar.gz'
DESC="Free collection of fast C routines for computing the Discrete Fourier Transform in one or more dimensions"
REQUIRES="gcc-libs"

build() {
  mkandenterbuilddir
  rm -rf $APP-$VERSION

  tar xf $SRCDIR/$APP-$VERSION.tar.?z*
  cd $APP-$VERSION
  fixbuilddirpermissions

  sed -i 's@-mtune=native@$CFLAGS@g' configure

  # Default compile options
  defconfopts() {
  [ "$ARCH" = "aarch64" ] && \
   ADDCONFIGOPTS="--enable-openmp" 
  ./configure \
    --prefix="" \
    --enable-shared \
    --disable-static \
    --enable-threads \
    $ADDCONFIGOPTS \
    $LIBOPTIONS
  }

  defmakeopts() {
  make 
  make install DESTDIR=$PKG
  make clean
  unset LIBOPTIONS
  }

  # Standard build
  defconfopts
  defmakeopts

  # Build with floating-point libs
  LIBOPTIONS=--enable-float
  defconfopts
  defmakeopts

  # Build with double-precision libs
  LIBOPTIONS=--enable-long-double
  defconfopts
  make 
  make install DESTDIR=$PKG

  cp COPY* $PKGDOCS/

  mkfinalpkg
}

SHA512SUMS="
a272fd08bf852011dfe0add9f374bac8d1f52798961eb9789677177d3e2455a706e7f56ab5bb2428445c799edb72ad3851cefe298a38f226f400505cda967269  fftw-3.3.8.tar.lz
"
