Processing Arguments pased to Makefile

I have a makefile and want to allow passing -01 -02 -03 for the user to define
the level of optimization he wants. Doing this gets make to send an error.

make -03
make: invalid option -- '0'
make: invalid option -- '3'
Usage: make [options] [target] ...

Try setting an environment variable you can test in a makefile to modify the make variable that goes on compile lines.
Else, define different targets and set the variable differently in each, like 'make unopt' and 'make optimum'.

You can also remove debugging support (-g in some compilers) and strip the objects when you optimize harder.

I am trying to check if the environment variable is O2 and make is
complaining when I use the following:

ifeq ($(OPMZ), O2)
 @echo "OPTIMIZATION_LEVEL = $(OPMZ)"
endif

Did you export it?

This is the error

ifeq (02, O2)
/bin/sh: -c: line 0: syntax error near unexpected token `02,'
/bin/sh: -c: line 0: `ifeq (02, O2)'
make: *** [help] Error 2

---------- Post updated at 05:57 PM ---------- Previous update was at 05:12 PM ----------

Fixed it. Needed tab

---------- Post updated at 10:59 PM ---------- Previous update was at 05:57 PM ----------

I want to set OPMZ to O2 if the value of OPMZ is not
in O1, O2, or O3.

The following is not working

ifeq ($(OPMZ), O1)
# do nothing
else ifeq ($(OPMZ), O2)
# do nothing
else ifeq ($(OPMZ), O3)
# do nothing
else
OPMZ = 02
endif

Is this gnu make? You might want quoting on the constant, but gnu make seem pretty free-wheeling: GNU make - Conditional Parts of Makefiles

Normally, you just put the optimization arguments in an exported environment variable, and put them in the CFLAGS line. No optimization is a blank or unset variable. Either that, or a different make target name as I mentioned above.