Makefile: Passing command line arguments to file i

2020-05-24 05:36发布

Inside my Makfile I have the following,

smktestrun: smktest
    @../projects/test.sh

And I call this using:

Make smktestrun

But sometimes I need to pass an parameter/argument along with this file (test.sh)

So basically I would like:

test.sh -abc

But if i just pass the argument in the Makefile itself, the argument is not taken as simply the sheel script is executed.

So is there a way I could specify in the Makefile that an argument needs to be passed with that file?

Thanks.

2条回答
狗以群分
2楼-- · 2020-05-24 06:03

Something like

smktestrun: smktest
        @../projects/test.sh $(TESTARGS)

Then call the Makefile with

$ make smktestrun TESTARGS="-abc"
查看更多
等我变得足够好
3楼-- · 2020-05-24 06:04

You could define a variable in Makefile.

smktestrun: smktest
    @../projects/test.sh ${ARG}

Then the command line of make is:

make smktestrun ARG="something"
查看更多
登录 后发表回答