Restore incorrectly deleted function

... it's still used.
Fix -O/--output-option
Tweak handling of CXX_EXTRA_REQ_FLAGS and CXX_EXTRA_OPT_FLAGS

... in configure.ac.

Just accumulate the flags in shell-variables, and then validate them
all at the end.

This should make it more straight-forward to add new flags.
Try to use -pthread compiler option if we're using threads

Using threads in gcc/glibc, without using -pthread, results in a
broken program that fails in very confusing ways.

[Previously, we usually ended up using -pthread accidentally, because
OpenEXR's pkg-config CFLAGS configuration included it.  But we should
use it explicitly.]