Move libs from AM_LDFLAGS to LIBS to fix linking with --as-needed

thanks to Adam Conrad <adconrad@ubuntu.com>