Fix LDFLAGS and work around a Fedora bug that broke pthread linking

The Fedora bug caused the DT_NEEDED for libpthread to be omitted, and
the missing -Wl before no-undefined prevented binutils from detecting it.

-export-dynamic is unnecessary for libraries, so this removes it, too.