Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive $(MAKE) doesn't find right Makefile #38

Open
rjleveque opened this issue Jul 4, 2013 · 4 comments
Open

recursive $(MAKE) doesn't find right Makefile #38

rjleveque opened this issue Jul 4, 2013 · 4 comments
Assignees

Comments

@rjleveque
Copy link
Member

I've got a directory with a file setrun_restart.py but no setrun.py and Makefile_restart sets SETRUN_FILE=setrun_restart.py

I modified the Makefile.common to print out what setrun file it's using...

----------------------------------------------------------------------------

Make data files needed by Fortran code:

.data: $(SETRUN_FILE) $(MAKEFILE_LIST) ;
@echo Using setrun from $(SETRUN_FILE)
$(MAKE) data

data: $(MAKEFILE_LIST);
-rm -f .data
@echo Using setrun from $(SETRUN_FILE)
$(CLAW_PYTHON) $(SETRUN_FILE) $(CLAW_PKG)
touch .data

----------------------------------------------------------------------------

It works as expected if I do
$ make data -f Makefile_restart

but here's what happens if I "make .data..."

$ make .data -f Makefile_restart
Using setrun from setrun_restart.py
make data
rm -f .data
Using setrun from setrun.py
python setrun.py amrclaw
python: can't open file 'setrun.py': [Errno 2] No such file or directory

The $(MAKE) data command is to blame -- it's not using the right version of the Makefile for this recursive call. (I also have a Makefile in the directory and if I remove that then it says it doesn't know how to make data at all.)

My GNU Make book doesn't tell how to fix this. It says there's a variable $(MAKEFLAGS) that should be passed but say that this does not contain the -f flag in particular.

@ghost ghost assigned mandli Jul 4, 2013
@mandli
Copy link
Member

mandli commented Jul 12, 2013

So it's not keeping track of the correct Makefile?

@rjleveque
Copy link
Member Author

That's right - The $(MAKE) call from Makefile.common uses the Makefile in the apps directory rather than Makefile_restart (which did the "include Makefile.common").

@rjleveque
Copy link
Member Author

I'm running into this problem again, e.g. if there's a Makefile2 with

EXE = xclaw2
OUTDIR = _output2

then Make .exe -f Makefile2 creates xclaw2 fine but Make .output -f Makefile2 uses xclaw and writes to _output, taken from the original Makefile.

@mandli
Copy link
Member

mandli commented Dec 23, 2013

Does adding a conditional to the makefile variables work for what you are trying to do?

ifdef test1
    EXE = xclaw
    OUTDIR = _output
else
    EXE = xclaw2
    OUTDIR = _output2
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants