Robert M
Robert M

Reputation: 41

How to install FFTW-2.1.5 on an M1 MacBook Pro?

I'm trying to install fftw-2.1.5 as it is required by the GADGET3 code version I need to use. I had no issues building it on my Linux machine (running Ubuntu 22.04), but on my M1 MacBook Pro (running macOS Monterey 12.4) it crashes at the configure step.

Running:

./configure --prefix=path/to/local/install \
            --enable-mpi \
            --enable-type-prefix \ 
            --with-gcc

I got the following error message:

checking build system type... configure: error: /bin/sh ./config.sub -apple-darwin21.5.0 failed

It seems that the configure script is not properly parsing the details of the MacBook, hence it crashes before testing the rest of the dependencies...

Upvotes: 1

Views: 885

Answers (1)

Robert M
Robert M

Reputation: 41

Disclaimer: I am fairly new to macOS and I have never had to use autotools before.

I found a similar issue here, so credits to the people that documented it there. I am unsure if all the following steps are required but they certainly solved my issue:

  1. I renamed configure.in to configure.ac
  2. I downloaded and applied all the patches from this website. I simply copied the text of each patch into new files patch_filename and ran $ patch < patch_filename in the main fftw-2.1.5 directory. As I renamed configure.in to configure.ac, when applying patch 05_ac_define_syntax.diff it will prompt the user to specify the path to the file to patch, i.e. configure.ac.
  3. (OPTIONAL) I also needed OpenMP support so additionally I needed to modify lines 249, 251, 253, 255 and 257 so that the variables omp_enabler and CFLAGS read as omp_enabler="$CC -fopenmp" and CFLAGS="$save_CFLAGS -fopenmp", where CC=gcc in my case.
  4. I ran $ autoupdate followed by $ autoreconf -vfi in the main fftw-2.1.5 directory.
  5. I ran the configure script with the desired flags, e.g. for double precision + MPI support:
$ ./configure --prefix=path/to/local/install \
              --enable-mpi \
              --enable-type-prefix \
              --with-gcc \
              LDFLAGS=-L/opt/homebrew/lib \
              CFLAGS=-I/opt/hombrew/include

  1. Finally, the standard make into make check and make install did the trick

Upvotes: 2

Related Questions