Add missing dependencies
Split LDFLAGS and LDLIBS to handle ubuntu linker failure
The default/implicit linking rule places LDFLAGS before the object. This causes
the build to break on some systems with undefined symbol errors. Placing the
libraries in LDLIBS pushes them after the .o file, and fixes the error.