Strange behaviour after recursively calling another makefile

205 Views Asked by At

I have a main makefile in the root directory of my project. There is another makefile inside the include directory. The second makefile uses the include keyword to call some other makefiles in other projects which I have no control over it. I cannot directly include this makefile as it has some targets which have the same name as the ones that I have. As a workaround, I decided to use recursive calling. When I run this makefile through the shell, using the following command, it works nicely:

my_project$ make -C include -f Second_Makefile

But when I call it through the main Makefile as follows, it does not behave normally meaning that it reports some project specific errors rooted from the included files inside the second makefile which are very hard to locate.

all:
    @$(MAKE) -C include -f Second_Makefile

I also tried the following line, but it did not help:

cd include; @$(MAKE) -f Second_Makefile

I think there should be difference between recursive calling and direct calling but I don't know what it is.

0

There are 0 best solutions below