2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-06-04 18:21:19 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Fftw < Formula
|
2010-07-01 19:37:36 +00:00
|
|
|
homepage 'http://www.fftw.org'
|
2013-01-14 16:05:41 +00:00
|
|
|
url 'http://www.fftw.org/fftw-3.3.3.tar.gz'
|
|
|
|
sha1 '11487180928d05746d431ebe7a176b52fe205cf9'
|
2009-06-04 18:21:19 +00:00
|
|
|
|
2014-02-24 15:11:24 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any
|
|
|
|
sha1 "9aeaea9d8cfacda9b6b4a2be377e5cff1c639de6" => :mavericks
|
|
|
|
sha1 "d59acf1f5bd1ac955ab930fbbef2a2efc8ee3a55" => :mountain_lion
|
|
|
|
sha1 "272dc2ed950d7ddf59dee0eaf00499c7fd965f95" => :lion
|
|
|
|
end
|
|
|
|
|
2013-01-18 17:15:30 +00:00
|
|
|
option "with-fortran", "Enable Fortran bindings"
|
|
|
|
|
2013-06-26 02:14:36 +00:00
|
|
|
depends_on :fortran => :optional
|
2013-06-24 03:29:13 +00:00
|
|
|
|
2009-06-04 18:21:19 +00:00
|
|
|
def install
|
2010-07-01 19:37:36 +00:00
|
|
|
args = ["--enable-shared",
|
|
|
|
"--disable-debug",
|
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--enable-threads",
|
|
|
|
"--disable-dependency-tracking"]
|
2013-11-06 13:36:05 +00:00
|
|
|
simd_args = ["--enable-sse2"]
|
|
|
|
simd_args << "--enable-avx" if ENV.compiler == :clang and Hardware::CPU.avx? and !build.bottle?
|
2010-07-01 19:37:36 +00:00
|
|
|
|
2013-06-26 02:14:36 +00:00
|
|
|
args << "--disable-fortran" unless build.with? "fortran"
|
2010-07-01 19:37:36 +00:00
|
|
|
|
2010-04-11 14:08:07 +00:00
|
|
|
# single precision
|
2013-11-06 13:36:05 +00:00
|
|
|
# enable-sse2 and enable-avx works for both single and double precision
|
|
|
|
system "./configure", "--enable-single", *(args + simd_args)
|
2009-06-04 18:21:19 +00:00
|
|
|
system "make install"
|
2009-08-07 14:41:43 +00:00
|
|
|
|
2010-04-11 14:08:07 +00:00
|
|
|
# clean up so we can compile the double precision variant
|
|
|
|
system "make clean"
|
|
|
|
|
|
|
|
# double precision
|
2013-11-06 13:36:05 +00:00
|
|
|
# enable-sse2 and enable-avx works for both single and double precision
|
|
|
|
system "./configure", *(args + simd_args)
|
2010-04-11 14:08:07 +00:00
|
|
|
system "make install"
|
|
|
|
|
|
|
|
# clean up so we can compile the long-double precision variant
|
|
|
|
system "make clean"
|
|
|
|
|
|
|
|
# long-double precision
|
2010-07-01 19:37:36 +00:00
|
|
|
# no SIMD optimization available
|
2010-08-08 17:20:15 +00:00
|
|
|
system "./configure", "--enable-long-double", *args
|
2010-04-11 14:08:07 +00:00
|
|
|
system "make install"
|
2009-06-04 18:21:19 +00:00
|
|
|
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.split
|
|
|
|
system './fftw'
|
|
|
|
end
|
2010-04-11 14:08:07 +00:00
|
|
|
end
|