Remove cast, detect platform in makefile