Fix Makefiles for non-GNU platforms