fixed errno error and added SO detection to Makefile