Passing optional arguments from makefile to shell script

34 views Asked by At

I have a makefile as follows

do-something:
    sh ./Scripts/do-something.sh "$(name)"

and running it as follows:

make do-something name=Foo  

calls the script as expected.

sh ./Scripts/do-something "Foo"

The problem:

The script also takes a couple of optional arguments, --noBar and --noBaz, so I can call it like

sh ./Scripts/do-something "Foo" --noBar

What I want to do is to call the makefile with those arguments and pass them down to the script, e.g.

make do-something name=Foo --noBar --noBaz

I've got as far as:

make do-something name=Foo ARGS="--noBar --noBaz"

do-something:
    sh ./Scripts/do-something.sh "$(name)" $(ARGS)

but this seems a bit clunky. Is there a way to do this without the ARGS=?

0

There are 0 answers