makefile

Passing arguments to "make run"


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

Solution

  • 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"