At the top of my Makefile, before any of the rules, I have the following:
ifeq ($(ENVIRONMENT),LOCAL)
TARGET := local_target
else
TARGET := hello
end
exit is a shell command, so you could use the shell assignment operator (i.e.: !=) inside the Makefile to call exit:
TARGET != exit -1
This would be actually equivalent to:
TARGET := $(shell exit -1)
Note again that this calls a shell that in turns runs the shell's exit built-in, i.e.: it does not exit make. The typical approach for exiting while processing a makefile is to call GNU Make's error built-in function instead:
$(error Error-message-here)
Putting everything together:
ifeq ($(ENVIRONMENT),LOCAL)
TARGET := local_target
else # indent with spaces, not a tab
$(error ENVIRONMENT not set to LOCAL)
endif