Fix Makefile to work with -Wl,--as-needed