3

I am a newbie to the use of make files.

I have added a new module in project using make.inc

The structure of project is like:-

/Project/build.sh
/Project/make.inc

/Project/Module1/Makefile
/Project/Module2/Makefile
/Project/Module3/Makefile
/Project/Module4/Makefile

/Project/my_module/Makefile

Initially project the has 4 other modules each of which are compilable using make.inc

The module I have added till now is getting compiled with its own Makefile. Now I have included the make.inc path in this make file to reuse the CFLAGS already defined in make.inc as many flags are same for all modules. Now I am able to compile the whole project using build.sh using make.inc .

But when I compile my module alone with Makefile , its giving error as the the CFLAGS are defined in the make.inc and the Variable carrying the value of path of the module is also defined there.

How can I get that path when I run this make file only

I want to know How can make it compilable using both make file and make.inc

TIA

1 Answer 1

1

I think there should be a main Makefile in the root directory that contains a command such as include ./make.inc.

Or add on top of each subfolder\Makefile file: include ../make.inc

I found a nice example at: http://owen.sj.ca.us/~rk/howto/slides/make/slides/makerecurs.html

3
  • Thanks medigeek the idea include ../make.inc does work. Only thing is I want to do it in a way controlled by the means of variable. using ../ is a kind of hardcoding but it surely works. Commented Oct 9, 2013 at 7:23
  • ../ takes you back to the parent/root directory. It's a relative directory, not full path. I don't understand what you're looking for unfortunately. I think ../ is OS-independent if that is what you mean. :) Commented Oct 9, 2013 at 9:57
  • I was just trying to use the variable defined in Project makefile for directory path instead of ../ . I am able to achieve so by using build.sh exporting variable there and then passing it to the lower makefiles. but when build.sh didnt run and I try to compile using module Makefile that variable is undeclared. Commented Oct 10, 2013 at 6:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .