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

The structure of project is like:-




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

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

But when I compile my module alone with Makefile , its giving error as the the CFLAGS are defined in the 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


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 ./

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

I found a nice example at:

share|improve this answer
Thanks medigeek the idea include ../ 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 exporting variable there and then passing it to the lower makefiles. but when 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 .