Do Mac OSX test in Makefile rather than shell

This seemed be failing in some cases, so I have replaced the shell conditional with a Makefile conditional.