Reputation: 143
I'm trying to figure out how to run a program with inputs from the command line using a makefile.
For example, let's say I have a program foo that takes in two integers and adds them and returns the result. In the make file when I type in make test for example it'll go into my makefile and it'd look like this
test:
./foo 1 1
./foo 2 2
and so on, but when I'm trying to do it it doesn't run. Is there something I am missing?
Upvotes: 0
Views: 71
Reputation: 67829
You can get the absolute path of your Makefile with:
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
Then, you can build your executable path with:
exe_path := $(mkfile_path)/../program
Finally, invoque foo
with its path:
$(exe_path)/foo 1 1
Upvotes: 1