autotools and latest gcc version

Running an old autotools build I just found it didn’t work no more. The command in error was:
# gcc -lpthread -o foo foo.o

Manually putting -lpthread at the end was ok but as I was using autotools I couldn’t just change the order and – above all – it was fine for gcc to expect the library *after* the object file!

The solution – suggested on #gcc by ngladitz – was to use the right autotools variable for adding libraries.

After RTFM I just:
– foo_LDFLAGS=-lpthread # autotools put flags before …
+ foo_LDADD=-lpthread # … and libraries after

cleaning up and rebuilding fixed everything!