amazingmo's Avatar
amazingmo 3
1 Asked
0 Answered
0 Best
0
No one has voted on this question yet :(
3 years, 3 months ago

How do I find the original target in a makefile?

My makefile can be invoked by any one of many top level makefiles. Some of the top level makefiles use a default target of 'lib', or 'releaselib', or 'debuglib'. When my makefile is invoked, I just know that 'lib' is a prerequisite of something, but I would like to be able to figure out the top-level target of the dependency tree.
Tip for best answer: M$0.00
Separate topics with commas, or by pressing return. Use the delete or backspace key to edit or remove existing topics.

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$

What is Your Answer?

0
0
0

1 Answer

0
abbotofunreason's Avatar
abbotofunreason | 3 years, 3 months ago
4
Are you looking for your lower level makefile to behave differently depending on what the top-level target was? If so, I think you'd have to have the top-level make files export the target name into an environment variable and have your makefile read that (and check $(MAKELEVEL), too, if you're using gnumake).

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$
abbotofunreason's Avatar
abbotofunreason | 3 years, 3 months ago Report

I should have said that answer assumes you are calling make with $(MAKE) or something. It doesn't help if your top-level make file is getting the lower-level one through an include.

Report Abuse

Post Reply Cancel

Learn something new with our FREE educational apps!

Private lessons in the comfort of your own home. Get back in shape or finally pick up a guitar with our great experts guiding you the whole way!
Learn Guitar
Learn Hip Hop
Learn Pilates