0

this is my project tree structure:

srcdir/Makefile_parent.make
srcdir/src/Makefile_src.make
srcdir/data/Makefile_data.make
srcdir/other/Makefile_other.make

My question is how to pass from my "Makefile_parent.make" a value readable in the child makefiles..I have:

Makefile_parent.make

ParentData = foo
SUBDIRS = src data other

and later, I want to read it from the other makefiles, for example:

Makefile_src.make

GetParentData = $(ParentData)

But is not working is always empty..any ideas?

ldav1s
  • 15,885
  • 2
  • 53
  • 56
Joel
  • 1,805
  • 1
  • 22
  • 22

1 Answers1

0

In your Makefile_src.make, you need to add this line at the top of the file:

include Makefile_parent.make

Then there is a problem of including the same makefile multiple times. A solution for that (similar to #ifndef in header files ;) )

ifndef MAKEFILE_PARENT_MAKE
MAKEFILE_PARENT_MAKE := 1

...
...
...
...

endif

You need to do this for every makefile you think that might be included, and use a different variable name for each of those files.

Tuxdude
  • 47,485
  • 15
  • 109
  • 110