Make the makefile compatible with *BSD.
Merge pull request #402 from pooya/shayan/bsd

Make the makefile compatible with *BSD.