Changed how libraries are added to get them included in the right order.

Apparently changing to a new Ubuntu release made me aware of that
LDFLAGS adds flags _before_ object files, while LDLIBS adds flags
_after_ object files. Best is to let linker search libraries for
missing functions _after_ it has parsed the object files.

Everything is of course based on GNU make implicit rules:
http://www.gnu.org/software/make/manual/make.html#Catalogue-of-Rules