Kousha
Kousha

Reputation: 36229

Makefile to pass all arguments to another file

I have a bin/test.sh file that I call from my makefile:

test:
    bin/test.sh

I like to pass ALL arguments (i.e. $@) to my test file so if I were to do make test -a arg1 -b arg2 -c arg3 -d my test file would get all of -a arg1 -b arg2 -c arg3 -d.

I don't want to define all of these arguments manually in test file; I just want to pass everything!

Upvotes: 0

Views: 66

Answers (1)

jhnc
jhnc

Reputation: 16817

make is invoked with a list of options followed by a list of targets.

So your example commandline will most likely gives errors about:

  • undefined options -a and -c
  • no rule to build targets arg1, arg2, etc

I think about the closest to what you seem to be asking for will be something like:

TEST_ARGS='-a arg1 -b arg2 -c arg3 -d' make test

with a Makefile containing:

test:
    bin/test.sh $(TEST_ARGS)

Upvotes: 3

Related Questions