Skip to content
Advertisement

variable to switch the pre-requisites for a target in a Makefile

I wish to use ‘MY_TYPE’ to switch the prerequisites for the target ‘top’.

based on MY_TYPE Can I select the pre-requisites required

For example, for

MY_TYPE=FOO , I wish to have $(BUILD) $(TARGETS) $(X_LOCALS) as pre-requisites for top

MY_TYPE=BAR , I wish to have $(BUILD) $(TARGETS) $(Y_LOCALS) as pre-requisites for top

How can I achieve it?

Below is a simple code snippet.

JavaScript

Happy to take your thoughts.

Advertisement

Answer

Nothing easier, just use conditionals:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement