homebrew-core/Formula/fftw.rb

84 lines
2.6 KiB
Ruby
Raw Normal View History

require 'formula'
2011-03-10 05:11:03 +00:00
class Fftw < Formula
homepage 'http://www.fftw.org'
2014-05-12 09:38:45 +00:00
url 'http://www.fftw.org/fftw-3.3.4.tar.gz'
sha1 'fd508bac8ac13b3a46152c54b7ac885b69734262'
2014-02-24 15:11:24 +00:00
bottle do
cellar :any
2014-11-05 22:50:27 +00:00
revision 2
sha1 "23ca4d2d44d13a4831cbeb8600425389050ca601" => :yosemite
sha1 "5103995b587d5223f54c20ce64023aea5220de11" => :mavericks
sha1 "7874a8fe1eeb52096a428778da61564358f6729e" => :mountain_lion
2014-02-24 15:11:24 +00:00
end
option "with-fortran", "Enable Fortran bindings"
option :universal
option "with-mpi", "Enable MPI parallel transforms"
2013-06-26 02:14:36 +00:00
depends_on :fortran => :optional
depends_on :mpi => [:cc, :optional]
def install
args = ["--enable-shared",
"--disable-debug",
"--prefix=#{prefix}",
"--enable-threads",
"--disable-dependency-tracking"]
simd_args = ["--enable-sse2"]
simd_args << "--enable-avx" if ENV.compiler == :clang and Hardware::CPU.avx? and !build.bottle?
args << "--disable-fortran" if build.without? "fortran"
args << "--enable-mpi" if build.with? "mpi"
ENV.universal_binary if build.universal?
# single precision
# enable-sse2 and enable-avx works for both single and double precision
system "./configure", "--enable-single", *(args + simd_args)
system "make install"
# clean up so we can compile the double precision variant
system "make clean"
# double precision
# enable-sse2 and enable-avx works for both single and double precision
system "./configure", *(args + simd_args)
system "make install"
# clean up so we can compile the long-double precision variant
system "make clean"
# long-double precision
# no SIMD optimization available
2010-08-08 17:20:15 +00:00
system "./configure", "--enable-long-double", *args
system "make install"
end
2013-06-02 21:03:36 +00:00
test do
# Adapted from the sample usage provided in the documentation:
# http://www.fftw.org/fftw3_doc/Complex-One_002dDimensional-DFTs.html
(testpath/'fftw.c').write <<-TEST_SCRIPT.undent
#include <fftw3.h>
int main(int argc, char* *argv)
{
fftw_complex *in, *out;
fftw_plan p;
long N = 1;
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(p); /* repeat as needed */
fftw_destroy_plan(p);
fftw_free(in); fftw_free(out);
2013-06-07 14:54:29 +00:00
return 0;
2013-06-02 21:03:36 +00:00
}
TEST_SCRIPT
system ENV.cc, '-o', 'fftw', 'fftw.c', '-lfftw3', *ENV.cflags.to_s.split
2013-06-02 21:03:36 +00:00
system './fftw'
end
end