make caught in infinite loop

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
stef
Posts: 187
Joined: Tue Mar 13, 2007 6:38 pm
Location: Independent researcher
Contact:

make caught in infinite loop

#1 Unread post by stef »

I'm trying to run the upwelling example, and make gets caught in an infinite loop.
To reproduce:

I change the compiler and netcdf paths in the makefile:

Code: Select all

>> diff makefile path/to/original/makefile
142c142
<         FORT ?= gfortran
---
>         FORT ?= pgi
312,313c312,313
<    NETCDF_MODFILE := ../../include/netcdf.mod
< TYPESIZES_MODFILE := ../../include/typesizes.mod
---
>    NETCDF_MODFILE := netcdf.mod
> TYPESIZES_MODFILE := typesizes.mod

When I run “make”, there is an infinite loop

Code: Select all

makefile:239: INCLUDING FILE /home/stefan/make_macros.mk WHICH CONTAINS APPLICATION-DEPENDENT MAKE
DEFINITIONS
cp -f /usr/local/include/../../include/netcdf.mod Build
cp -f /usr/local/include/../../include/typesizes.mod Build
./ROMS/Bin/sfmakedepend …. > Build/MakeDepend
cp -p /home/stefan/make_macros.mk Build
makefile:235: INCLUDING FILE Build/make_macros.mk WHICH CONTAINS APPLICATION-DEPENDENT MAKE DEFINIT
IONS
cp -f /usr/local/include/../../include/netcdf.mod Build
…
Note that after sfmakedepend is redirected to Build/MakeDepend, it starts from the beginning. I can fix it by commenting out the line

Code: Select all

$(SFMAKEDEPEND) $(MDEPFLAGS) $(sources) > $(SCRATCH_DIR)/MakeDepend
in the

Code: Select all

$(SCRATCH_DIR)/MakeDepend
target, and running

Code: Select all

make depend

Code: Select all

make
Is there something wrong with the makefile, or with what I'm doing? I haven't worked with ROMS in ages....

Using GNU Make 4.2.1, GNU bash 4.3.46 on
Linux 4.7.4-1-ARCH x86_64 GNU/Linux

Thanks for your help, Stefan

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: make caught in infinite loop

#2 Unread post by kate »

There is something funny about what you are doing:

Code: Select all

cp -f /usr/local/include/../../include/netcdf.mod Build
cp -f /usr/local/include/../../include/typesizes.mod Build
This is going to copy /usr/include/netcdf.mod into Build. I guess that file exists since it didn't fail. However, make knows that you still don't have Build/../../include/netcdf.mod so it tries to create it again. This is the make rule you should be looking at:

Code: Select all

$(SCRATCH_DIR)/$(NETCDF_MODFILE): | $(SCRATCH_DIR)
        cp -f $(NETCDF_INCDIR)/$(NETCDF_MODFILE) $(SCRATCH_DIR)

stef
Posts: 187
Joined: Tue Mar 13, 2007 6:38 pm
Location: Independent researcher
Contact:

Re: make caught in infinite loop

#3 Unread post by stef »

That's it, thanks. Setting the right path in the platform dependent file solves it!

On a side note, this still leaves me wondering why the line after the prerequisites is executed (sfmakedepend), if the prerequisites are not fulfilled? Not urgent, though.

Post Reply