Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass multiple arguments from makefile

My task is to pass multiple arguments to one of my executable binary files. For example, I have a binary which takes 6 arguments, so it works fine when I type:

./a.out 1 2 3 4 5 6

I want to do the same using a makefile so that when I type make INPUT=1 2 3 4 5 6 it should execute the a.out with all the six arguments in the INPUT. I can do this if I pass the arguments with escape characters like:

make INPUT=1\ 2\ 3\ 4\ 5\ 6

but is there any way to make it execute like

make INPUT=1 2 3 4 5 6

makefile contents:

@gcc prime.c
@./a.out ${INPUT}
like image 407
Abhishek Gangwar Avatar asked Aug 11 '26 02:08

Abhishek Gangwar


1 Answers

Just put the args within quotations.

make INPUT="1 2 3 4 5 6"
like image 72
kaylum Avatar answered Aug 12 '26 18:08

kaylum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!