Passing libraries through $LDFLAGS is wrong and not guaranteed to work. Indeed, if the upstream build system is correctly written, it is very likely to fail. Assuming the upstream build system follows standard practices, you can pass the library via $LDLIBS or possibly $LIBS.