Adapt to match new GCC behavior

Newer GCC versions pass the --as-needed switch by default. This means that if the library is not needed by anything that precedes it in the command line it is ignored.