Makefile relinks everytime

Hi guys, I'm a firsttime poster. My makefile is relinking everytime, even if nothing changes. Is there anyway to have it stop doing this?

Here the makefile:

F77C    = /usr/bin/f77 -O
VERSION =9.4
VPATH = ../poten
# executables that can be built from this makefile

OH3S  = ../exe/poly.oh3.serial.exe  

OBJ = dattim.o dateclock.o givtst.o intbsv3.o poly40.o \
polyrr.o headr.o interface.o polysz.o ef.o \
hooks.o ivtstm.o polyag.o rtpjac.o \
energetics.o intbsv1.o main.o acespoly.o \
polyhl.o fromblas.o intbsv2.o poly31.o polymq.o dummy_mpi.o

POT:../poten/oh3.f

.f.o:
        $(F77C) -c $<
.c.o:
        cc -c $<

OH3S:$(OBJ) dummy_mpi.o oh3.o setup4.o surf4.o coord4.o chain4.o
        $(F77C) -o $(OH3S) $(OBJ) dummy_mpi.o oh3.o setup4.o surf4.o coord4.o chain4.o

And here is the interactive output when I run it:

/usr/bin/f77 -O -o ../exe/poly9.4.oh3.serial.exe dattim.o dateclock.o givtst.o intbsv3.o poly40.o polyrr.o headr.o interface.o polysz.o ef.o hooks.o ivtstm.o polyag.o rtpjac.o energetics.o intbsv1.o main.o acespoly.o polyhl.o fromblas.o intbsv2.o poly31.o polymq.o dummy_mpi.o dummy_mpi.o oh3.o setup4.o surf4.o coord4.o chain4.o

Everything is working fine, I just want to get it to stop relinking even when nothing changes. Thanks!

One reason might me that the time stamp of your source files is greater than the generated object files. In such a case, every time the make utility will assume that object files are older as compaired to source file.

In such case, Change the time stamp of all the relavent source files using touch command.

This should solve your problem.

This line is improbable:
OH3S:$(OBJ) dummy_mpi.o oh3.o setup4.o surf4.o coord4.o chain4.o

maybe it should be:
$(OH3S):$(OBJ) dummy_mpi.o oh3.o setup4.o surf4.o coord4.o chain4.o

but it's hard to say for sure with such a messy makefile. I really don't know what this line is supposed to be for:
POT:../poten/oh3.f

but as near as I can tell it exerts no influence over the final result. I guess it might do something if you invoke make with "make POT". But that would not yield the result you give.

The source files are older than the objects, and the objects are older than the executable. Is there any other reason that Make would relink?

See this post. :rolleyes:

This line is correct:
OH3S:$(OBJ) dummy_mpi.o oh3.o setup4.o surf4.o coord4.o chain4.o

Yes, the purpose for this line:
POT:../poten/oh3.f
is for 'Make POT'.

But why is it relinking?

That line claims to make a file called OH3S but probably doesn't. Would it really kill you to try changing it to:
$(OH3S)

I tried changing it to:

$(OH3S):$(OBJ) dummy_mpi.o oh3.o setup4.o surf4.o coord4.o chain4.o

but now it says that there is no rule when I 'gmake OH3S':

gmake: *** No rule to make target `OH3S'. Stop.

And it's right. You have variables and targets mixed up. You want to make a file called george? You use the command:
make george
You don't use "make fred".

In your case, do you want to make a file called OH3S or do you want to make a file called ../exe/poly.oh3.serial.exe. Depending on which it is, do one of these:
make ../exe/poly.oh3.serial.exe
make OH3S

Your "make POT" will redo the commands each time as well. I doubt that it creates a file called POT.

Try leaving my change in and adding, near the top, certainly as the first rule:

OH3S:$(OH3S)

Thanks for the help. Just one more thing. When I make the executable, it only works if I make it in exactly the way that it appears in the Makefile. So if I type "gmake ../exe/poly.oh3.serial.exe" it works. But if I try to make the file by typing the absolute path and not the relative path, it doesn't work. Is there any way to use absolute and relative paths with Makefile?

If you put the

OH3S:$(OH3S)

in then OH3S is both a variable and a target. And then your "gmake OH3S" should work again. At least I think so. I have never done that. I don't use gmake, but with plain old make, if you type the command:
make
(no target at all) it will look for the first target and make that. I gotta believe that gmake does that too. So by making
OH3S:$(OH3S)
the first line, it will be the default target. But must of us would do stuff like
default:$(OH3S)
to make it more clear to a reader. But whatever rule is first is the default.