I think the simple solution here is to generate separate makefiles for each host. Like Makefile.linux etc... Then have master makefile that invokes it based on system flags.
A bit more sophisticated solution would use some form of diff to "fix" one common makefile...