Skip to content

Instantly share code, notes, and snippets.

@chadrien
Created June 3, 2015 12:21
Show Gist options
  • Select an option

  • Save chadrien/edd9167f5325821aaec5 to your computer and use it in GitHub Desktop.

Select an option

Save chadrien/edd9167f5325821aaec5 to your computer and use it in GitHub Desktop.

Revisions

  1. chadrien created this gist Jun 3, 2015.
    14 changes: 14 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    SUPPORTED_COMMANDS := command1 command2
    SUPPORTS_MAKE_ARGS := $(findstring $(firstword $(MAKECMDGOALS)), $(SUPPORTED_COMMANDS))
    ifneq "$(SUPPORTS_MAKE_ARGS)" ""
    # use the rest as arguments for the command
    COMMAND_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
    # ...and turn them into do-nothing targets
    $(eval $(COMMAND_ARGS):;@:)
    endif

    command1:
    @command1 $(COMMAND_ARGS)

    command2:
    @command2 --option1 --option2=foo $(COMMAND_ARGS)