23

I am installing MOOG, and when I make -f Makefile.maclap I get the error:

$ make -f Makefile.maclap
g77 -w   -c -o Abfind.o Abfind.f
make: g77: No such file or directory
make: *** [Abfind.o] Error 1

After research online, I think that, since I have gcc-5, the command g77 doesn't exist on my computer.

So I used, based on a stack exchange question, alias g77=/usr/local/bin/gfortran-5 to try to compile the fortran code with gfortran.

Now, when I g77 I see gfortran-5: fatal error: no input files compilation terminated, indicating that g77 is working as a compiled.

But when I make -f Makefile.maclap I still get the error:

$ make -f Makefile.maclap
g77 -w   -c -o Abfind.o Abfind.f
make: g77: No such file or directory
make: *** [Abfind.o] Error 1

How can I get the make command to use fortran-5 to compile the file Abfind.o and Abfind.f?

How can I successfully complete the make and make install steps to get this software package running?

jww
  • 12,722

3 Answers3

10

The make program is only going to see names that are actually files (or directories). It does not know anything about shell aliases.

Rather than an alias, if you had g77 in your $PATH as a symbolic link, that would work. In many environments, if you have a $HOME/bin directory, that is automatically added to your $PATH. (If not, it is simple to do this manually, details depending upon your shell).

If it is the simpler case:

cd
mkdir bin
cd bin
ln -s /usr/local/bin/gfortran-5 g77

Then log out, and log in again (to let the shell's initialization scripts update the path, etc.)

9

If you don't want to make a symlink like @Thomas suggested, you can basically make an alias right in the Makefile like so by placing this line somewhere near the top of the Makefile:

G77 := /usr/local/bin/gfortran-5

and then, in your target somewhere, use it like:

$(G77) -w -c -o Abfind.o Abfind.f
mdszy
  • 173
2

Just use make's shell command.

$(g77 -w -c -o Abfind.o Abfind.f)

by wrapping the entire command in $() it executes it how the shell would execute it. If you run it on a machine with an alias, like yours, the alias will work. If you run it on a machine that has g77 installed natively then that will work also.

This is the portable way to solve your problem and does not require any machine specific changes to your makefile.

The symbolic link trick will only work with trivial aliases that just change the name of the command. If you have a non-trial alias that includes some default arguments then the symbolic link trick will not work.