autogen: enhance autogen.sh

We take the code from Warzone 2100 3.1.1 as they've implemented it
already very well and also use GPLv2.

This gives us better checks and better output.
linuxhooking: add '-ldl' to LD_FLAGS explicitly

We've noticed with 'ldd' that our libs are built without the libdl
import. So add it explixitly.