Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing arguments to "make run"

Tags:

makefile

I use Makefiles.

I have a target called run which runs the build target. Simplified, it looks like the following:

prog: ....   ...  run: prog   ./prog 

Is there any way to pass arguments? So that

make run asdf --> ./prog asdf make run the dog kicked the cat --> ./prog the dog kicked the cat 
like image 642
anon Avatar asked Feb 06 '10 20:02

anon


People also ask

What is passing an argument?

Unless an argument is passed by value (BYVALUE), a reference to an argument, not its value, is generally passed to a subroutine or function. This is known as passing arguments by reference, or BYADDR.

What is $@ in Makefile?

The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file.


1 Answers

I don't know a way to do what you want exactly, but a workaround might be:

run: ./prog     ./prog $(ARGS) 

Then:

make ARGS="asdf" run # or make run ARGS="asdf" 
like image 102
Jakob Borg Avatar answered Sep 28 '22 07:09

Jakob Borg