adapt: add debug option to adapt scripts

Introduce a second parameter to all adaption scripts. If it is set
to "DEBUG", then the debug code is run.

Run for example:
examples/adapt/chromium-bsu_adapt64.sh `which chromium-bsu` DEBUG
libmemdisc: add locking to the output stream buffer

The general stream functions like fprintf() and fputs() only lock
the file but messages from different threads still can be
interleaved. So use flockfile(), fputs_unlocked() and funlockfile()
to lock the buffer as well.