Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 1 down vote accepted

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

share|improve this answer
    
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. – user2448138 Oct 9 '13 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. :) – medigeek Oct 9 '13 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. – user2448138 Oct 10 '13 at 6:13

You must log in to answer this question.

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