Home > front end >  Is there any way to get the target name which was inputted by user in the command line when using ma
Is there any way to get the target name which was inputted by user in the command line when using ma

Time:11-22

Now I'm writing a makefile for my C project, and I want to implement a RELEASE&DEBUG compilation branch, it's like the script within the makefile could know which target name the user inputted in the command line, then it can decide what kind of GCC options it will use to compile the current program, is there any way to achieve this? Thank U.

I tried to define a variable in the makefile and pass its value through the command line like make type=release, but this is not what I wanted.

CodePudding user response:

Assuming you're talking about GNU make then there is: look up the MAKECMDGOALS macro in the GNU make manual.

But, this is really not the right way to do things. I recommend that instead you look up target-specific variables in the manual and see if that gives any ideas.

  • Related