Reputation: 1
I would like to know if it is possible to pass arguments to the make command like this :
make file.class
So the aim here is to compile the java file and compile it from the file.java. I know there might be easier ways, but I don't have the choice (school work).
The problem here is I don't know how to pass an argument like that, and catch it in the makefile. Do you have a hint for me ?
Thanks in advance !
Upvotes: 0
Views: 193
Reputation: 100836
Make is not a programming language, and a makefile is not a program. At least, not the way you are thinking about it. It doesn't accept general arguments and you're not able to write a makefile as a "program" that will "catch" arguments.
Make parses its command line and treats all argument as either variable assignments (if they have an =
) or targets to be built. That's it, there's no way you can change that behavior.
Luckily, that's exactly what you want: you need to write a makefile that contains a rule with a target of file.class
; then when you run make file.class
make will build that target using the recipe you provide.
See this introduction to writing makefiles and try to adapt it to your situation. If you have problems that you can't figure out and the docs don't help, post your makefile as a new question in SO and describe exactly what the problem is and what you want to happen, including cut/paste of errors etc.
Upvotes: 1