Detect correct library extension in Makefile