0

I found an example here showing how to implement the OR logic to check for different values for a flag.

But I just want to pass a single param without values (start, not start=yes) to 2 make commands: run and run_whatever (example names)

For the run command I am using:

ifeq (run,$(firstword $(MAKECMDGOALS)))
  # use the rest as arguments for "run"
  RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
  # ...and turn them into do-nothing targets
  $(eval $(RUN_ARGS):;@:)
endif

And

run:
    ./myprogram $(RUN_ARGS)

And I want to extend the ifeq condition to support:

run_whatever:
    ./myotherprogram $(RUN_ARGS)

And call them like: make run start, make run_whatever start

Z. M.
  • 329
  • 5
  • 13
  • Sorry but I don't quite understand. You say you want to _pass a single param without values_. Do you mean you want to just run `make run` or `make run_whatever` without any "extra arguments" (e.g. you don't need `RUN_ARGS` at all)? – MadScientist Mar 11 '21 at 13:16
  • @MadScientist Sorry, edited for clarity. I'm trying to call them like this: `make run start`, `make run version`, etc. – Z. M. Mar 11 '21 at 13:19

1 Answers1

0

In this situation you can use:

ifeq (,$(filter-out run run_whatever,$(firstword $(MAKECMDGOALS))))
MadScientist
  • 92,819
  • 9
  • 109
  • 136