Refactor OS detection in Makefile.lib.