1 diff --git a/mkspecs/common/g++-unix.conf b/mkspecs/common/g++-unix.conf
2 index a493cd5984..41342f5020 100644
3 --- a/mkspecs/common/g++-unix.conf
4 +++ b/mkspecs/common/g++-unix.conf
9 -QMAKE_LFLAGS_RELEASE += -Wl,-O1
10 +SYSTEM_LDFLAGS = $$(LDFLAGS)
11 +!isEmpty(SYSTEM_LDFLAGS) { eval(QMAKE_LFLAGS_RELEASE += $$(LDFLAGS)) } else { QMAKE_LFLAGS_RELEASE += -Wl,-O1 }
12 QMAKE_LFLAGS_NOUNDEF += -Wl,--no-undefined
13 diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf
14 index 1f919d270a..7ef6046326 100644
15 --- a/mkspecs/common/gcc-base.conf
16 +++ b/mkspecs/common/gcc-base.conf
17 @@ -40,9 +40,11 @@ QMAKE_CFLAGS_OPTIMIZE_SIZE = -Os
18 QMAKE_CFLAGS_DEPS += -M
19 QMAKE_CFLAGS_WARN_ON += -Wall -Wextra
20 QMAKE_CFLAGS_WARN_OFF += -w
21 -QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE
22 -QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -g
23 -QMAKE_CFLAGS_DEBUG += -g
24 +SYSTEM_CFLAGS = $$(CFLAGS)
25 +SYSTEM_DEBUG_CFLAGS = $$(DEBUG_CFLAGS)
26 +!isEmpty(SYSTEM_CFLAGS) { eval(QMAKE_CFLAGS_RELEASE += $$(CFLAGS)) } else { QMAKE_CFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE }
27 +!isEmpty(SYSTEM_CFLAGS) { eval(QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -g $$(CFLAGS)) } else { QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -g }
28 +!isEmpty(SYSTEM_DEBUG_CFLAGS) { eval(QMAKE_CFLAGS_DEBUG += $$(DEBUG_CFLAGS)) } else { QMAKE_CFLAGS_DEBUG += -g }
29 QMAKE_CFLAGS_SHLIB += $$QMAKE_CFLAGS_PIC
30 QMAKE_CFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_PIC
31 QMAKE_CFLAGS_APP += $$QMAKE_CFLAGS_PIC
32 @@ -59,9 +61,11 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
33 QMAKE_CXXFLAGS_DEPS += $$QMAKE_CFLAGS_DEPS
34 QMAKE_CXXFLAGS_WARN_ON += $$QMAKE_CFLAGS_WARN_ON
35 QMAKE_CXXFLAGS_WARN_OFF += $$QMAKE_CFLAGS_WARN_OFF
36 -QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE
37 -QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
38 -QMAKE_CXXFLAGS_DEBUG += $$QMAKE_CFLAGS_DEBUG
39 +SYSTEM_CXXFLAGS = $$(CXXFLAGS)
40 +SYSTEM_DEBUG_CXXFLAGS = $$(DEBUG_CXXFLAGS)
41 +!isEmpty(SYSTEM_CXXFLAGS) { eval(QMAKE_CXXFLAGS_RELEASE += $$(CXXFLAGS)) } else { QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_OPTIMIZE }
42 +!isEmpty(SYSTEM_CXXFLAGS) { eval(QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -g $$(CXXFLAGS)) } else { QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -g }
43 +!isEmpty(SYSTEM_DEBUG_CXXFLAGS) { eval(QMAKE_CXXFLAGS_DEBUG += $$(DEBUG_CXXFLAGS)) } else { QMAKE_CXXFLAGS_DEBUG += -g }
44 QMAKE_CXXFLAGS_SHLIB += $$QMAKE_CFLAGS_SHLIB
45 QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB
46 QMAKE_CXXFLAGS_APP += $$QMAKE_CFLAGS_APP