I am trying to create a generate Makefile. Is there a way to test whether a python module exists and then perform different actions in the Makefile based on that?

I have tried something like this

```
all:

ifeq (,$(@ python -c 'import somemodule'))                                                                                                                                                                                                          
echo "DEF MODULE = 1" > settings.pxi                                                                                                                                                                                                     
else                                                                                                                                                                                                                                                 
echo "DEF MODULE = 0" > settings.pxi                                                                                                                                                                                                     
endif                                                                                                                                                                                                                                                
    python setup.py build_ext --build-lib . --build-temp build --pyrex-c-in-temp 

```

however doing this does not produce any result. Also if the module does not exist, python throws an error- how to store this information rather than simply crashing?