0

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.

1 Answer 1

1

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.

1
  • Thank u mad, target-specific variables is exactly what I was looking for :) Nov 22, 2022 at 2:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.