contrib: qt: pass the CPPFLAGS/LDFLAGS to the configure script
We need to pass the compiler definition so they are know during the configure phase. Otherwise the system libraries are not detected.
Extracted some commits/code from !2693 (merged) without updating the Qt version for now.