exporting variable to child instance of make

hi,
I am trying to export a variable from the parent makefile to a child instance of my makefile within the same directory.

the relevant code in my parent makefile is:
1
2
3
4
5
6
7
libvar := $(notdir $(basename ../src/file1))
export libvar

.PHONY: library

library:
make -f makechild libvar=file1
in the child makefile, i.e. makechild, I have the following relevant code:
LVAR: =
fname := $(addprefix lib, $(LVAR))

but obviously I am missing something because echo $(fname) returns 'lib' (instead of libfile1)when I run the make command in the parent makefile.

can you pls. help me fix the code so I can export the value of libvar into LVAR
Last edited on
closed account (S6k9GNh0)
This is not related to C++, thus, I would suggest this not be answered here.
Who the heck are you?!!

Compiling programs is most certainly related to C++, especially with an extremely common tool like make. If you want to be elitist about stuff, go join comp.lang.c++ and do it there. This forum has proven to be pretty open to anything C++ related -- including tools used to compile. It has also proven to be pretty well maintained, so I think that if the OP does post something inappropriate, he will be properly advised.


@OP
A quick check with google shows me you have already posted in a very useful spot over at the Unix and Linux Forums. I don't know the answer off the top of my head, but you can always peruse the Make documentation as well.
http://www.gnu.org/software/make/manual/

Good luck!
thanks...I just figured out I was making a dumb error,
I should keep the variable names the same in both the parent and child makefile.
so, in my child makefile, I renamed LVAR to libvar and it worked.
.....just in case anyone might be interested.
Topic archived. No new replies allowed.