use LDLIBS instead of LDFLAGS

LDLIBS are put behind the prerequisites by make's built-in rules so linking
won't fail with --as-needed.