Given the following make target
.PHONY: my_target
my_target:
@python scripts/my_script.py $(arg)
one can the argument with an argument in the following manner
make my_target arg=my_arg
I used this approach to run a python script to create the file for this post
make til p=make/pass-arg-to-target
for the following make target
.PHONY: til
til:
@python scripts/til.py $(p)
It’s also possible to prepend the variable
p=make/pass-arg-to-target make til