Reputation: 6651
I am trying to update some old Fortran code and I want to use a makefile to build it. Right now, my makefile looks like
FC = gfortran
FFLAGS = -O2
HDRS = global.h param.h coor.h
SRCS = xxx.f yyy.f zzz.f newstuff.f90 main.f
OBJS = $(SRCS:.f=.o)
OBJS := $(OBJS:.f90=.o)
runit: $(OBJS)
$(FC) $(FFLAGS) -o $@ $^
xxx.o yyy.o main.o : global.h
yyy.o zzz.o: coor.h
xxx.o yyy.o zzz.o main.o : param.h
xxx.o main.o : newstuff.o
clean:
rm runit *.o *.mod
.SUFFIXES: .f .f90 .o
.f.o:
$(FC) $(FFLAGS) -c $<
.f90.o:
$(FC) $(FFLAGS) -c $<
I have two questions. First, I edit newstuff.f90 and then issue make newstuff.o
, expecting a new newstuff.o
. Instead, I get the message that newstuff.o is up to date. This doesn't happen with any of the other source codes. What do I have to do to convince make that newstuff.o is indeed out of date?
Second, trying to hack a fix, I inserted the line (not shown above): newstuff.o : newstuff.f90
. But with that line in the makefile, make returns
m2c -o mpi_wrapper.o mpi_wrapper.mod
make: m2c: No such file or directory
Why does make go for this other utility m2c, whatever that is? How do I convince it to use gfortran? Thanks.
Upvotes: 0
Views: 1041
Reputation: 404
there is a default rule treating mod files as Modula files. You can disable this rule by adding this following line followed by a blank line to your Makefile:
%.o : %.mod
Upvotes: 1