Bug 1042878 - part 2 - move MOZ_CAIRO_CFLAGS et al additions to C*FLAGS into moz.build; r=glandium
authorNathan Froyd <froydnj@mozilla.com>
Thu, 24 Jul 2014 11:55:33 -0400
changeset 208288 6c0cfdafc568627e7deabaa129a0b79df5ec0e65
parent 208287 baf9b70bdc7f4c145b3915594825cc28fac9f047
child 208289 0fb23fd8244e69573f6eb0c922032b071ce7f007
push idunknown
push userunknown
push dateunknown
reviewersglandium
bugs1042878
milestone34.0a1
Bug 1042878 - part 2 - move MOZ_CAIRO_CFLAGS et al additions to C*FLAGS into moz.build; r=glandium
accessible/atk/Makefile.in
accessible/atk/moz.build
accessible/base/Makefile.in
accessible/base/moz.build
browser/components/shell/Makefile.in
browser/components/shell/moz.build
chrome/Makefile.in
chrome/moz.build
content/media/Makefile.in
content/media/gstreamer/Makefile.in
content/media/gstreamer/moz.build
content/media/moz.build
content/media/webm/Makefile.in
content/media/webm/moz.build
dom/base/Makefile.in
dom/base/moz.build
dom/bluetooth/Makefile.in
dom/bluetooth/moz.build
dom/bluetooth2/Makefile.in
dom/bluetooth2/moz.build
dom/canvas/Makefile.in
dom/canvas/moz.build
dom/ipc/Makefile.in
dom/ipc/moz.build
dom/plugins/base/Makefile.in
dom/plugins/base/android/Makefile.in
dom/plugins/base/android/moz.build
dom/plugins/base/moz.build
dom/plugins/ipc/Makefile.in
dom/plugins/ipc/moz.build
dom/plugins/test/testplugin/testplugin.mk
dom/plugins/test/testplugin/testplugin.mozbuild
dom/src/geolocation/Makefile.in
dom/src/geolocation/moz.build
dom/system/qt/Makefile.in
dom/system/qt/moz.build
extensions/gio/Makefile.in
extensions/gio/moz.build
extensions/gnomevfs/Makefile.in
extensions/gnomevfs/moz.build
extensions/spellcheck/hunspell/src/Makefile.in
extensions/spellcheck/hunspell/src/moz.build
gfx/2d/Makefile.in
gfx/2d/moz.build
gfx/cairo/cairo/src/Makefile.in
gfx/cairo/cairo/src/moz.build
gfx/gl/Makefile.in
gfx/gl/moz.build
gfx/ipc/Makefile.in
gfx/ipc/moz.build
gfx/layers/Makefile.in
gfx/layers/moz.build
gfx/skia/Makefile.in
gfx/skia/generate_mozbuild.py
gfx/skia/moz.build
gfx/src/Makefile.in
gfx/src/moz.build
gfx/tests/gtest/Makefile.in
gfx/tests/gtest/moz.build
gfx/thebes/Makefile.in
gfx/thebes/moz.build
hal/Makefile.in
hal/moz.build
image/decoders/icon/gtk/Makefile.in
image/decoders/icon/gtk/moz.build
image/decoders/icon/qt/Makefile.in
image/decoders/icon/qt/moz.build
image/src/Makefile.in
image/src/moz.build
intl/locale/Makefile.in
intl/locale/moz.build
intl/lwbrk/Makefile.in
intl/lwbrk/moz.build
intl/unicharutil/tables/Makefile.in
intl/unicharutil/tables/moz.build
intl/unicharutil/util/Makefile.in
intl/unicharutil/util/internal/Makefile.in
intl/unicharutil/util/internal/moz.build
intl/unicharutil/util/moz.build
ipc/dbus/Makefile.in
ipc/dbus/moz.build
ipc/ipdl/Makefile.in
ipc/ipdl/moz.build
layout/base/Makefile.in
layout/base/moz.build
layout/build/Makefile.in
layout/build/moz.build
layout/generic/Makefile.in
layout/generic/moz.build
media/libcubeb/src/Makefile.in
media/libcubeb/src/moz.build
netwerk/base/src/Makefile.in
netwerk/base/src/moz.build
netwerk/system/qt/Makefile.in
netwerk/system/qt/moz.build
netwerk/wifi/Makefile.in
netwerk/wifi/moz.build
rdf/tests/rdfcat/Makefile.in
rdf/tests/rdfcat/moz.build
rdf/tests/triplescat/Makefile.in
rdf/tests/triplescat/moz.build
security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in
security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
storage/build/Makefile.in
storage/build/moz.build
storage/src/Makefile.in
storage/src/moz.build
testing/tools/screenshot/Makefile.in
testing/tools/screenshot/moz.build
toolkit/components/downloads/Makefile.in
toolkit/components/downloads/moz.build
toolkit/components/jsdownloads/src/Makefile.in
toolkit/components/jsdownloads/src/moz.build
toolkit/components/protobuf/Makefile.in
toolkit/components/protobuf/moz.build
toolkit/components/remote/Makefile.in
toolkit/components/remote/moz.build
toolkit/components/url-classifier/Makefile.in
toolkit/components/url-classifier/moz.build
toolkit/library/Makefile.in
toolkit/library/moz.build
toolkit/mozapps/update/updater/Makefile.in
toolkit/mozapps/update/updater/moz.build
toolkit/system/dbus/Makefile.in
toolkit/system/dbus/moz.build
toolkit/system/gnome/Makefile.in
toolkit/system/gnome/moz.build
toolkit/system/unixproxy/Makefile.in
toolkit/system/unixproxy/moz.build
toolkit/xre/Makefile.in
toolkit/xre/moz.build
uriloader/exthandler/Makefile.in
uriloader/exthandler/moz.build
view/Makefile.in
view/moz.build
webapprt/gtk/Makefile.in
webapprt/gtk/moz.build
widget/cocoa/Makefile.in
widget/cocoa/moz.build
widget/gtk/Makefile.in
widget/gtk/moz.build
widget/gtkxtbin/Makefile.in
widget/gtkxtbin/moz.build
widget/qt/Makefile.in
widget/qt/moz.build
widget/shared/Makefile.in
widget/shared/moz.build
widget/shared/x11/Makefile.in
widget/shared/x11/moz.build
widget/windows/Makefile.in
widget/windows/moz.build
widget/windows/winrt/Makefile.in
widget/windows/winrt/moz.build
widget/xpwidgets/Makefile.in
widget/xpwidgets/moz.build
xpcom/base/Makefile.in
xpcom/base/moz.build
xpcom/build/Makefile.in
xpcom/build/moz.build
xpcom/components/Makefile.in
xpcom/components/moz.build
deleted file mode 100644
--- a/accessible/atk/Makefile.in
+++ /dev/null
@@ -1,14 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_ENABLE_GTK
-CFLAGS      += $(TK_CFLAGS)
-CXXFLAGS    += $(TK_CFLAGS)
-endif
-
-ifdef MOZ_ENABLE_DBUS
-CXXFLAGS += $(MOZ_DBUS_CFLAGS)
-endif
--- a/accessible/atk/moz.build
+++ b/accessible/atk/moz.build
@@ -36,8 +36,15 @@ LOCAL_INCLUDES += [
     '/accessible/generic',
     '/accessible/html',
     '/accessible/xpcom',
     '/accessible/xul',
     '/other-licenses/atk-1.0',
 ]
 
 FINAL_LIBRARY = 'xul'
+
+if CONFIG['MOZ_ENABLE_GTK']:
+    CFLAGS += CONFIG['TK_CFLAGS']
+    CXXFLAGS += CONFIG['TK_CFLAGS']
+
+if CONFIG['MOZ_ENABLE_DBUS']:
+    CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
deleted file mode 100644
--- a/accessible/base/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_ENABLE_GTK
-CXXFLAGS        += $(MOZ_CAIRO_CFLAGS)
-endif
--- a/accessible/base/moz.build
+++ b/accessible/base/moz.build
@@ -85,8 +85,11 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'co
         '/accessible/mac',
     ]
 else:
     LOCAL_INCLUDES += [
         '/accessible/other',
     ]
 
 FINAL_LIBRARY = 'xul'
+
+if CONFIG['MOZ_ENABLE_GTK']:
+    CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
deleted file mode 100644
--- a/browser/components/shell/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
-
-clobber::
-	rm -f $(DIST)/lib/$(LIBRARY_NAME).lib
--- a/browser/components/shell/moz.build
+++ b/browser/components/shell/moz.build
@@ -42,8 +42,10 @@ if SOURCES:
 
 EXTRA_COMPONENTS += [
     'nsSetDefaultBrowser.js',
     'nsSetDefaultBrowser.manifest',
 ]
 
 for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'):
     DEFINES[var] = '"%s"' % CONFIG[var]
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/chrome/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_ENABLE_GTK
-CXXFLAGS          += $(TK_CFLAGS)
-endif
--- a/chrome/moz.build
+++ b/chrome/moz.build
@@ -34,8 +34,11 @@ GENERATED_INCLUDES += [
     '/xpcom',
 ]
 
 LOCAL_INCLUDES += [
     '/netwerk/base/src',
     '/netwerk/protocol/res',
     '/xpcom/components'
 ]
+
+if CONFIG['MOZ_ENABLE_GTK']:
+    CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/content/media/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CFLAGS   += $(GSTREAMER_CFLAGS)
-CXXFLAGS += $(GSTREAMER_CFLAGS)
deleted file mode 100644
--- a/content/media/gstreamer/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this file,
-# You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CFLAGS		+= $(GSTREAMER_CFLAGS)
-CXXFLAGS	+= $(GSTREAMER_CFLAGS)
-
-
--- a/content/media/gstreamer/moz.build
+++ b/content/media/gstreamer/moz.build
@@ -31,8 +31,10 @@ else:
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/content/html/content/src',
 ]
 
+CFLAGS += CONFIG['GSTREAMER_CFLAGS']
+CXXFLAGS += CONFIG['GSTREAMER_CFLAGS']
--- a/content/media/moz.build
+++ b/content/media/moz.build
@@ -206,8 +206,11 @@ if CONFIG['MOZ_DIRECTSHOW']:
 
 DEFINES['MOZILLA_INTERNAL_API'] = True
 
 if CONFIG['MOZ_OMX_DECODER']:
     DEFINES['MOZ_OMX_DECODER'] = True
 
 if CONFIG['ANDROID_VERSION'] > '15':
     DEFINES['MOZ_OMX_WEBM_DECODER'] = True
+
+CFLAGS += CONFIG['GSTREAMER_CFLAGS']
+CXXFLAGS += CONFIG['GSTREAMER_CFLAGS']
deleted file mode 100644
--- a/content/media/webm/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += \
-		$(MOZ_LIBVPX_CFLAGS) \
-		$(NULL)
-
--- a/content/media/webm/moz.build
+++ b/content/media/webm/moz.build
@@ -16,11 +16,13 @@ UNIFIED_SOURCES += [
 ]
 
 if CONFIG['MOZ_WEBM_ENCODER']:
     EXPORTS += ['WebMWriter.h']
     UNIFIED_SOURCES += ['EbmlComposer.cpp',
                         'WebMWriter.cpp',
     ]
 
+CXXFLAGS += CONFIG['MOZ_LIBVPX_CFLAGS']
+
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
deleted file mode 100644
--- a/dom/base/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_X11
-CXXFLAGS += $(TK_CFLAGS)
-LDFLAGS += $(TK_LIBS)
-endif
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -185,8 +185,11 @@ for var in ('MOZ_B2G_RIL', 'MOZ_B2G_FM')
     if CONFIG[var]:
         DEFINES[var] = True
 
 if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
     DEFINES['HAVE_SIDEBAR'] = True
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
+
+if CONFIG['MOZ_X11']:
+    CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/dom/bluetooth/Makefile.in
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2012 Mozilla Foundation and Mozilla contributors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-ifneq (,$(MOZ_B2G_BT))
-
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-ifdef MOZ_B2G_BT_BLUEZ
-LOCAL_INCLUDES += $(MOZ_DBUS_CFLAGS)
-endif #MOZ_B2G_BT_BLUEZ
-else
-ifdef MOZ_ENABLE_DBUS
-LOCAL_INCLUDES += $(MOZ_DBUS_CFLAGS)
-CFLAGS += $(MOZ_DBUS_GLIB_CFLAGS)
-CXXFLAGS += $(MOZ_DBUS_GLIB_CFLAGS)
-endif #MOZ_ENABLE_DBUS
-endif #MOZ_WIDGET_TOOLKIT
-endif #MOZ_B2G_BT
--- a/dom/bluetooth/moz.build
+++ b/dom/bluetooth/moz.build
@@ -23,16 +23,17 @@ if CONFIG['MOZ_B2G_BT']:
 
     if CONFIG['MOZ_B2G_RIL']:
         SOURCES += [
             'BluetoothRilListener.cpp',
         ]
 
     if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
         if CONFIG['MOZ_B2G_BT_BLUEZ']:
+            CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
             SOURCES += [
                 'bluez/BluetoothA2dpManager.cpp',
                 'bluez/BluetoothDBusService.cpp',
                 'bluez/BluetoothHfpManager.cpp',
                 'bluez/BluetoothOppManager.cpp',
                 'bluez/BluetoothSocket.cpp',
                 'bluez/BluetoothUnixSocketConnector.cpp',
                 'bluez/BluetoothUtils.cpp',
@@ -66,16 +67,20 @@ if CONFIG['MOZ_B2G_BT']:
                     'bluedroid/hfp-fallback/BluetoothHfpManager.cpp',
                 ]
                 LOCAL_INCLUDES += [
                     'bluedroid/hfp-fallback',
                 ]
 
             DEFINES['MOZ_B2G_BT_BLUEDROID'] = True
     elif CONFIG['MOZ_ENABLE_DBUS']:
+        CFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
+        CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+        CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
+        CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
         SOURCES += [
             'bluez/BluetoothDBusService.cpp',
             'bluez/BluetoothHfpManager.cpp',
         ]
         LOCAL_INCLUDES += [
             'bluez',
         ]
         DEFINES['MOZ_BLUETOOTH_DBUS'] = True
deleted file mode 100644
--- a/dom/bluetooth2/Makefile.in
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2012 Mozilla Foundation and Mozilla contributors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-ifneq (,$(MOZ_B2G_BT))
-
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-ifdef MOZ_B2G_BT_BLUEZ
-LOCAL_INCLUDES += $(MOZ_DBUS_CFLAGS)
-endif #MOZ_B2G_BT_BLUEZ
-else
-ifdef MOZ_ENABLE_DBUS
-LOCAL_INCLUDES += $(MOZ_DBUS_CFLAGS)
-CFLAGS += $(MOZ_DBUS_GLIB_CFLAGS)
-CXXFLAGS += $(MOZ_DBUS_GLIB_CFLAGS)
-endif #MOZ_ENABLE_DBUS
-endif #MOZ_WIDGET_TOOLKIT
-endif #MOZ_B2G_BT
--- a/dom/bluetooth2/moz.build
+++ b/dom/bluetooth2/moz.build
@@ -25,16 +25,17 @@ if CONFIG['MOZ_B2G_BT']:
 
     if CONFIG['MOZ_B2G_RIL']:
         SOURCES += [
             'BluetoothRilListener.cpp',
         ]
 
     if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
         if CONFIG['MOZ_B2G_BT_BLUEZ']:
+            CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
             SOURCES += [
                 'bluez/BluetoothA2dpManager.cpp',
                 'bluez/BluetoothDBusService.cpp',
                 'bluez/BluetoothHfpManager.cpp',
                 'bluez/BluetoothOppManager.cpp',
                 'bluez/BluetoothSocket.cpp',
                 'bluez/BluetoothUnixSocketConnector.cpp',
                 'bluez/BluetoothUtils.cpp',
@@ -68,16 +69,20 @@ if CONFIG['MOZ_B2G_BT']:
                     'bluedroid/hfp-fallback/BluetoothHfpManager.cpp',
                 ]
                 LOCAL_INCLUDES += [
                     'bluedroid/hfp-fallback',
                 ]
 
             DEFINES['MOZ_B2G_BT_BLUEDROID'] = True
     elif CONFIG['MOZ_ENABLE_DBUS']:
+        CFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
+        CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+        CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
+        CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
         SOURCES += [
             'bluez/BluetoothDBusService.cpp',
             'bluez/BluetoothHfpManager.cpp',
         ]
         LOCAL_INCLUDES += [
             'bluez',
         ]
         DEFINES['MOZ_BLUETOOTH_DBUS'] = True
deleted file mode 100644
--- a/dom/canvas/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-# 
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS	+= $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
-
--- a/dom/canvas/moz.build
+++ b/dom/canvas/moz.build
@@ -119,8 +119,11 @@ LOCAL_INCLUDES += [
     '/content/xul/content/src',
     '/dom/base',
     '/image/src',
     '/js/xpconnect/src',
     '/layout/generic',
     '/layout/style',
     '/layout/xul',
 ]
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/dom/ipc/Makefile.in
+++ /dev/null
@@ -1,7 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -142,8 +142,10 @@ if CONFIG['ENABLE_TESTS']:
     LOCAL_INCLUDES += [
       'ipc/glue',
     ]
 
 JAR_MANIFESTS += ['jar.mn']
 
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
 MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/dom/plugins/base/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += \
-  $(MOZ_CAIRO_CFLAGS) \
-  $(TK_CFLAGS) \
-  $(NULL)
deleted file mode 100644
--- a/dom/plugins/base/android/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-CXXFLAGS += \
-  $(MOZ_CAIRO_CFLAGS) \
-  $(NULL)
--- a/dom/plugins/base/android/moz.build
+++ b/dom/plugins/base/android/moz.build
@@ -32,8 +32,10 @@ LOCAL_INCLUDES += [
     '/dom/plugins/base',
     '/dom/plugins/base/android/include',
     '/gfx/gl',
     '/widget/android',
     '/widget/xpwidgets',
 ]
 
 DEFINES['MOZ_APP_NAME'] = '"%s"' % CONFIG['MOZ_APP_NAME']
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
--- a/dom/plugins/base/moz.build
+++ b/dom/plugins/base/moz.build
@@ -118,8 +118,11 @@ if CONFIG['OS_ARCH'] == 'WINNT':
         '/xpcom/base',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 DEFINES['SK_BUILD_FOR_ANDROID_NDK'] = True
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/dom/plugins/ipc/Makefile.in
+++ /dev/null
@@ -1,16 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifneq ($(MOZ_WIDGET_TOOLKIT),gtk3)
-CXXFLAGS += $(TK_CFLAGS)
-else
-# Force build against gtk+2 for struct offsets and such.
-CXXFLAGS += $(MOZ_GTK2_CFLAGS)
-endif
-
-CXXFLAGS += \
-  $(MOZ_CAIRO_CFLAGS) \
-  $(NULL)
--- a/dom/plugins/ipc/moz.build
+++ b/dom/plugins/ipc/moz.build
@@ -121,8 +121,15 @@ include('/ipc/chromium/chromium-config.m
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '../base',
     '/xpcom/base/',
 ]
 
 DEFINES['FORCE_PR_LOG'] = True
 
+if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gtk3':
+    CXXFLAGS += CONFIG['TK_CFLAGS']
+else:
+    # Force build against gtk+2 for struct offsets and such.
+    CXXFLAGS += CONFIG['MOZ_GTK2_CFLAGS']
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
--- a/dom/plugins/test/testplugin/testplugin.mk
+++ b/dom/plugins/test/testplugin/testplugin.mk
@@ -1,17 +1,15 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
 include $(topsrcdir)/config/config.mk
-CXXFLAGS        += $(MOZ_QT_CFLAGS)
-CFLAGS          += $(MOZ_QT_CFLAGS)
 OS_LIBS += \
                 $(MOZ_QT_LIBS) \
                 $(XLDFLAGS) \
                 $(XLIBS)
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 OS_LIBS  += $(call EXPAND_LIBNAME,msimg32)
@@ -33,12 +31,10 @@ INSTALL_TARGETS += \
 else
 TEST_PLUGIN_DEST = $(DIST)/plugins
 INSTALL_TARGETS += TEST_PLUGIN
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifneq (,$(filter gtk2 gtk3,$(MOZ_WIDGET_TOOLKIT)))
-CXXFLAGS        += $(MOZ_GTK2_CFLAGS)
-CFLAGS          += $(MOZ_GTK2_CFLAGS)
 OS_LIBS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS)
 endif
--- a/dom/plugins/test/testplugin/testplugin.mozbuild
+++ b/dom/plugins/test/testplugin/testplugin.mozbuild
@@ -47,8 +47,16 @@ DISABLE_STL_WRAPPING = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     RCFILE  = 'nptest.rc'
     RESFILE = 'nptest.res'
     DEFFILE = SRCDIR + '/nptest.def'
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa' and '64' in CONFIG['OS_TEST']:
     EXTRA_DSO_LDOPTS += ['-framework Carbon']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
+    CXXFLAGS += CONFIG['MOZ_GTK2_CFLAGS']
+    CFLAGS += CONFIG['MOZ_GTK2_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
+    CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
+    CFLAGS += CONFIG['MOZ_QT_CFLAGS']
deleted file mode 100644
--- a/dom/src/geolocation/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_ENABLE_QT5GEOPOSITION
-CXXFLAGS += $(MOZ_QT_CFLAGS)
-endif
--- a/dom/src/geolocation/moz.build
+++ b/dom/src/geolocation/moz.build
@@ -24,16 +24,17 @@ LOCAL_INCLUDES += [
     '/dom/base',
     '/dom/ipc',
 ]
 
 if CONFIG['MOZ_ENABLE_QT5GEOPOSITION']:
     LOCAL_INCLUDES += [
         '/dom/system/qt',
     ]
+    CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     LOCAL_INCLUDES += [
         '/dom/system/android',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     LOCAL_INCLUDES += [
         '/dom/system/gonk',
deleted file mode 100644
--- a/dom/system/qt/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_ENABLE_QT5GEOPOSITION
-CXXFLAGS += $(MOZ_QT_CFLAGS)
-endif
--- a/dom/system/qt/moz.build
+++ b/dom/system/qt/moz.build
@@ -7,16 +7,18 @@
 if CONFIG['MOZ_ENABLE_QT5GEOPOSITION']:
     GENERATED_SOURCES += [
         'moc_QTMLocationProvider.cpp',
     ]
     SOURCES += [
         'QTMLocationProvider.cpp',
     ]
 
+    CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
+
     LOCAL_INCLUDES += [
         '/dom/src/geolocation',
     ]
 
 if CONFIG['MOZ_ENABLE_QT5FEEDBACK']:
     SOURCES += [
         'QtHapticFeedback.cpp',
     ]
deleted file mode 100644
--- a/extensions/gio/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-# vim:set ts=8 sw=8 sts=8 noet:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-LOCAL_INCLUDES	= $(MOZ_GIO_CFLAGS)
--- a/extensions/gio/moz.build
+++ b/extensions/gio/moz.build
@@ -6,8 +6,10 @@
 
 SOURCES += [
     'nsGIOProtocolHandler.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['MOZ_GIO_CFLAGS']
--- a/extensions/gnomevfs/Makefile.in
+++ b/extensions/gnomevfs/Makefile.in
@@ -1,11 +1,9 @@
 # vim:set ts=8 sw=8 sts=8 noet:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-LOCAL_INCLUDES	= $(MOZ_GNOMEVFS_CFLAGS)
-
 OS_LIBS += \
 		   $(NSPR_LIBS) \
 		   $(MOZ_GNOMEVFS_LIBS) \
 		   $(NULL)
--- a/extensions/gnomevfs/moz.build
+++ b/extensions/gnomevfs/moz.build
@@ -17,8 +17,10 @@ IS_COMPONENT = True
 # to install gnome-vfs2 in order to use the rest of mozilla ;-)
 FORCE_SHARED_LIB = True
 
 USE_LIBS += [
     'mozalloc',
     'xpcomglue_s',
     'xul',
 ]
+
+CXXFLAGS += CONFIG['MOZ_GNOMEVFS_CFLAGS']
deleted file mode 100644
--- a/extensions/spellcheck/hunspell/src/Makefile.in
+++ /dev/null
@@ -1,12 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_NATIVE_HUNSPELL
-# MOZ_HUNSPELL_CFLAGS is extracted through pkgconfig during configure,
-# even though the variable doesn't show up in configure.in.
-CXXFLAGS += $(MOZ_HUNSPELL_CFLAGS)
-endif
-
--- a/extensions/spellcheck/hunspell/src/moz.build
+++ b/extensions/spellcheck/hunspell/src/moz.build
@@ -23,16 +23,18 @@ if not CONFIG['MOZ_NATIVE_HUNSPELL']:
         'hunzip.cxx',
         'phonet.cxx',
         'replist.cxx',
         'suggestmgr.cxx',
     ]
     # This variable is referenced in configure.in.  Make sure to change that file
     # too if you need to change this variable.
     DEFINES['HUNSPELL_STATIC'] = True
+else:
+    CXXFLAGS += CONFIG['MOZ_HUNSPELL_CFLAGS']
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/editor/libeditor/base',
     '/extensions/spellcheck/src',
 ]
--- a/gfx/2d/Makefile.in
+++ b/gfx/2d/Makefile.in
@@ -1,17 +1,10 @@
-#
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),$(findstring $(MOZ_WIDGET_TOOLKIT),android gtk2 gtk3 gonk qt))
-OS_CXXFLAGS += $(CAIRO_FT_CFLAGS)
-endif
-
 include $(topsrcdir)/config/rules.mk
 
 # Due to bug 796023, we can't have -DUNICODE and -D_UNICODE; defining those
 # macros changes the type of LOGFONT to LOGFONTW instead of LOGFONTA. This
 # changes the symbol names of exported C++ functions that use LOGFONT.
 DEFINES := $(filter-out -DUNICODE -D_UNICODE,$(DEFINES))
-
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
--- a/gfx/2d/moz.build
+++ b/gfx/2d/moz.build
@@ -142,8 +142,13 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('and
 DEFINES['SK_A32_SHIFT'] = 24
 DEFINES['SK_R32_SHIFT'] = 16
 DEFINES['SK_G32_SHIFT'] = 8
 DEFINES['SK_B32_SHIFT'] = 0
 
 if CONFIG['MOZ_DEBUG']:
     DEFINES['GFX_LOG_DEBUG'] = True
     DEFINES['GFX_LOG_WARNING'] = True
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk', 'qt'):
+    CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
--- a/gfx/cairo/cairo/src/Makefile.in
+++ b/gfx/cairo/cairo/src/Makefile.in
@@ -3,29 +3,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 ifdef GNU_CC
 ifeq ($(OS_TARGET),Android)
 MODULE_OPTIMIZE_FLAGS = -O2
 endif
 endif
 
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
-OS_INCLUDES += $(MOZ_QT_CFLAGS)
-endif
-
-ifdef MOZ_X11
-OS_INCLUDES += $(XCFLAGS)
-endif
-
-ifdef MOZ_ENABLE_CAIRO_FT
-OS_INCLUDES += $(CAIRO_FT_CFLAGS)
-endif
-
 INSTALL_TARGETS += cairo_features
 cairo_features_FILES := cairo-features.h
 cairo_features_DEST = $(DIST)/include/cairo
 cairo_features_TARGET := export
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef GNU_CC
--- a/gfx/cairo/cairo/src/moz.build
+++ b/gfx/cairo/cairo/src/moz.build
@@ -212,8 +212,17 @@ if CONFIG['GNU_CC']:
         '-Wno-type-limits',
     ]
     if CONFIG['CLANG_CXX']:
         CFLAGS += [
             '-Wno-incompatible-pointer-types',
             '-Wno-tautological-compare',
             '-Wno-tautological-constant-out-of-range-compare',
         ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
+    CFLAGS += CONFIG['MOZ_QT_CFLAGS']
+
+if CONFIG['MOZ_X11']:
+    CFLAGS += CONFIG['XCFLAGS']
+
+if CONFIG['MOZ_ENABLE_CAIRO_FT']:
+    CFLAGS += CONFIG['CAIRO_FT_CFLAGS']
--- a/gfx/gl/Makefile.in
+++ b/gfx/gl/Makefile.in
@@ -1,10 +1,7 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES := $(filter-out -DUNICODE,$(DEFINES))
-
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
-CFLAGS   += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -150,8 +150,13 @@ FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_D3DCOMPILER_VISTA_DLL']:
     DEFINES['MOZ_D3DCOMPILER_VISTA_DLL'] = CONFIG['MOZ_D3DCOMPILER_VISTA_DLL']
 if CONFIG['MOZ_D3DCOMPILER_XP_DLL']:
     DEFINES['MOZ_D3DCOMPILER_XP_DLL'] = CONFIG['MOZ_D3DCOMPILER_XP_DLL']
 
 if CONFIG['MOZ_ANDROID_OMTC']:
     DEFINES['MOZ_ANDROID_OMTC'] = True
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
+CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/gfx/ipc/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
--- a/gfx/ipc/moz.build
+++ b/gfx/ipc/moz.build
@@ -24,8 +24,11 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind
 
 SOURCES += [
     'SharedDIB.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/gfx/layers/Makefile.in
+++ b/gfx/layers/Makefile.in
@@ -1,11 +1,9 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 include $(topsrcdir)/config/rules.mk
 
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
-
 PremultiplyTables.h: $(srcdir)/genTables.py
 	$(PYTHON) $(srcdir)/genTables.py
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -385,8 +385,11 @@ CXXFLAGS += [
         'frameworks/base/include/media/stagefright',
         'frameworks/base/include/media/stagefright/openmax',
         'frameworks/av/include/media/stagefright',
         'frameworks/native/include/media/openmax',
     ]
 ]
 
 MOCHITEST_MANIFESTS += ['apz/test/mochitest.ini']
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/gfx/skia/Makefile.in
+++ b/gfx/skia/Makefile.in
@@ -1,25 +1,11 @@
 # 
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),$(findstring $(MOZ_WIDGET_TOOLKIT),android gonk))
-OS_CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(CAIRO_FT_CFLAGS)
-endif
-
-ifdef MOZ_WIDGET_GTK
-OS_CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(MOZ_PANGO_CFLAGS) $(CAIRO_FT_CFLAGS)
-endif
-
-ifeq (qt,$(MOZ_WIDGET_TOOLKIT))
-OS_CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(MOZ_PANGO_CFLAGS) $(CAIRO_FT_CFLAGS)
-endif
-
-include $(topsrcdir)/config/rules.mk
-
 ifeq ($(CPU_ARCH)_$(GNU_CC),arm_1)
 # The assembly uses the frame pointer register (r7 in Thumb/r11 in
 # ARM), the compiler doesn't like that.
 CXXFLAGS := $(filter-out -fno-omit-frame-pointer,$(CXXFLAGS)) -fomit-frame-pointer
 CFLAGS := $(filter-out -fno-omit-frame-pointer,$(CFLAGS)) -fomit-frame-pointer
 endif
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -111,16 +111,23 @@ DEFINES['GR_IMPLEMENTATION'] = 1
 
 if CONFIG['GNU_CXX']:
     CXXFLAGS += [
         '-Wno-overloaded-virtual',
         '-Wno-unused-function',
     ]
     if not CONFIG['CLANG_CXX']:
         CXXFLAGS += ['-Wno-logical-op']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk', 'qt'):
+    CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+    CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'qt'):
+    CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 """
 
 import json
 
 platforms = ['linux', 'mac', 'android', 'win']
 
 custom_includes = {
   'trunk/src/ports/SkAtomics_android.h': True,
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -919,8 +919,15 @@ DEFINES['GR_IMPLEMENTATION'] = 1
 
 if CONFIG['GNU_CXX']:
     CXXFLAGS += [
         '-Wno-overloaded-virtual',
         '-Wno-unused-function',
     ]
     if not CONFIG['CLANG_CXX']:
         CXXFLAGS += ['-Wno-logical-op']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk', 'qt'):
+    CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+    CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'qt'):
+    CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
deleted file mode 100644
--- a/gfx/src/Makefile.in
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
-
-ifdef MOZ_WIDGET_GTK
-CXXFLAGS += $(MOZ_PANGO_CFLAGS)
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
-CXXFLAGS += $(MOZ_QT_CFLAGS)
-endif
--- a/gfx/src/moz.build
+++ b/gfx/src/moz.build
@@ -65,8 +65,17 @@ SOURCES += [
     'nsDeviceContext.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_GTK']:
+    CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
+    CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
deleted file mode 100644
--- a/gfx/tests/gtest/Makefile.in
+++ /dev/null
@@ -1,5 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-OS_CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
--- a/gfx/tests/gtest/moz.build
+++ b/gfx/tests/gtest/moz.build
@@ -41,8 +41,10 @@ include('/ipc/chromium/chromium-config.m
 
 LOCAL_INCLUDES += [
     '/gfx/2d',
     '/gfx/2d/unittest',
     '/gfx/layers',
 ]
 
 FINAL_LIBRARY = 'xul-gtest'
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
--- a/gfx/thebes/Makefile.in
+++ b/gfx/thebes/Makefile.in
@@ -5,29 +5,10 @@
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 ACDEFINES +=	-UWIN32_LEAN_AND_MEAN
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES := $(filter-out -DUNICODE,$(DEFINES))
 
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
-CFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),android)
-CXXFLAGS += $(CAIRO_FT_CFLAGS)
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
-CXXFLAGS += $(CAIRO_FT_CFLAGS)
-endif
-
-ifdef MOZ_WIDGET_GTK
-CXXFLAGS += $(MOZ_PANGO_CFLAGS)
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
-CXXFLAGS += $(CAIRO_FT_CFLAGS) $(MOZ_PANGO_CFLAGS)
-endif
-
 DeprecatedPremultiplyTables.h: $(srcdir)/genTables.py
 	$(PYTHON) $(srcdir)/genTables.py
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -270,17 +270,28 @@ LOCAL_INCLUDES += [
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk', 'qt'):
     DEFINES['MOZ_ENABLE_FREETYPE'] = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'):
         if CONFIG[var]:
             DEFINES[var] = True
 
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
+CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CFLAGS += CONFIG['TK_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk', 'qt'):
+    CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
+
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     # This is set for "normal Android", that is, when Gecko is running on
     # top of the android java runtime.
     DEFINES['MOZ_USING_ANDROID_JAVA_WIDGETS'] = True
 
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'qt'):
+    CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
+
 DEFINES['GRAPHITE2_STATIC'] = True
 
 if CONFIG['OS_TARGET'] == 'WINNT':
     DEFINES['OTS_DLL'] = True
deleted file mode 100644
--- a/hal/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CFLAGS          += $(GLIB_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
-CXXFLAGS        += $(GLIB_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
--- a/hal/moz.build
+++ b/hal/moz.build
@@ -190,8 +190,13 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk
     # So that we can call nsScreenManagerGonk::GetConfiguration().
     LOCAL_INCLUDES += [
         '/widget/gonk',
         '/widget/xpwidgets'
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     CXXFLAGS += ['-I%s/hardware/libhardware_legacy/include' % CONFIG['ANDROID_SOURCE']]
+
+CFLAGS += CONFIG['GLIB_CFLAGS']
+CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+CXXFLAGS += CONFIG['GLIB_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
deleted file mode 100644
--- a/image/decoders/icon/gtk/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_ENABLE_GNOMEUI
-CXXFLAGS += $(MOZ_GNOMEUI_CFLAGS)
-else
-CXXFLAGS += $(TK_CFLAGS)
-endif
--- a/image/decoders/icon/gtk/moz.build
+++ b/image/decoders/icon/gtk/moz.build
@@ -6,8 +6,13 @@
 
 SOURCES += [
     'nsIconChannel.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
+
+if CONFIG['MOZ_ENABLE_GNOMEUI']:
+    CXXFLAGS += CONFIG['MOZ_GNOMEUI_CFLAGS']
+else:
+    CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/image/decoders/icon/qt/Makefile.in
+++ /dev/null
@@ -1,7 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(MOZ_QT_CFLAGS)
--- a/image/decoders/icon/qt/moz.build
+++ b/image/decoders/icon/qt/moz.build
@@ -14,8 +14,10 @@ EXTRA_COMPONENTS += [
     'gtkqticonsconverter.manifest',
 ]
 
 EXTRA_PP_COMPONENTS += [
     'gtkqticonsconverter.js',
 ]
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
deleted file mode 100644
--- a/image/src/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-# Because imgFrame.cpp includes "cairo.h"
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
--- a/image/src/moz.build
+++ b/image/src/moz.build
@@ -57,8 +57,11 @@ LOCAL_INCLUDES += [
     '/content/svg/content/src',
     # We need to instantiate the decoders
     '/image/decoders',
     # Because VectorImage.cpp includes nsSVGUtils.h and nsSVGEffects.h
     '/layout/svg',
     # For URI-related functionality
     '/netwerk/base/src',
 ]
+
+# Because imgFrame.cpp includes "cairo.h"
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
deleted file mode 100644
--- a/intl/locale/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-ifeq ($(MOZ_WIDGET_TOOLKIT), qt)
-OS_INCLUDES	+= $(MOZ_QT_CFLAGS)
-endif
-
-include $(topsrcdir)/config/rules.mk
-
--- a/intl/locale/moz.build
+++ b/intl/locale/moz.build
@@ -55,8 +55,11 @@ FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/intl/uconv',
 ]
 
 RESOURCE_FILES += [
     'langGroups.properties',
     'language.properties',
 ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
+    CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
deleted file mode 100644
--- a/intl/lwbrk/Makefile.in
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_WIDGET_GTK
-CXXFLAGS	+= \
-		$(MOZ_PANGO_CFLAGS) \
-		$(NULL)
-endif
--- a/intl/lwbrk/moz.build
+++ b/intl/lwbrk/moz.build
@@ -42,8 +42,11 @@ else:
     ]
     SOURCES += [
         'rulebrk.c',
     ]
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'xul'
+
+if CONFIG['MOZ_WIDGET_GTK']:
+    CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
deleted file mode 100644
--- a/intl/unicharutil/tables/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifeq ($(MOZ_WIDGET_TOOLKIT), qt)
-CFLAGS          += $(MOZ_QT_CFLAGS)
-CXXFLAGS        += $(MOZ_QT_CFLAGS)
-endif
--- a/intl/unicharutil/tables/moz.build
+++ b/intl/unicharutil/tables/moz.build
@@ -7,8 +7,12 @@
 RESOURCE_FILES.entityTables = [
     'htmlEntityVersions.properties',
     'html40Latin1.properties',
     'html40Symbols.properties',
     'html40Special.properties',
     'mathml20.properties',
     'transliterate.properties',
 ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
+    CFLAGS += CONFIG['MOZ_QT_CFLAGS']
+    CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
--- a/intl/unicharutil/util/Makefile.in
+++ b/intl/unicharutil/util/Makefile.in
@@ -3,14 +3,8 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # This makefile builds the unicharutil_external_s library which should be used
 # by frozen (dependent) linkage components. Internal-linkage code should use
 # unicharutil_s which is built in the internal/ subdirectory.
 
 DIST_INSTALL = 1
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef ENABLE_INTL_API
-LOCAL_INCLUDES += $(MOZ_ICU_CFLAGS)
-endif
--- a/intl/unicharutil/util/internal/Makefile.in
+++ b/intl/unicharutil/util/internal/Makefile.in
@@ -2,13 +2,9 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # This makefile builds the version of unicharutils_s static library which uses
 # internal linkage. Components that use frozen (external) linkage should use
 # unicharutil_external_s.
 
-ifdef ENABLE_INTL_API
-LOCAL_INCLUDES += $(MOZ_ICU_CFLAGS)
-endif
-
 DIST_INSTALL = 1
--- a/intl/unicharutil/util/internal/moz.build
+++ b/intl/unicharutil/util/internal/moz.build
@@ -9,8 +9,11 @@ include('../objs.mozbuild')
 UNIFIED_SOURCES += intl_unicharutil_util_cppsrcs
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '..',
     '../../src',
 ]
+
+if CONFIG['ENABLE_INTL_API']:
+    CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
--- a/intl/unicharutil/util/moz.build
+++ b/intl/unicharutil/util/moz.build
@@ -33,8 +33,11 @@ LOCAL_INCLUDES += [
 
 USE_STATIC_LIBS = True
 
 if CONFIG['_MSC_VER']:
     DEFINES['_USE_ANSI_CPP'] = True
     # Don't include directives about which CRT to use
     CFLAGS += ['-Zl']
     CXXFLAGS += ['-Zl']
+
+if CONFIG['ENABLE_INTL_API']:
+    CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
deleted file mode 100644
--- a/ipc/dbus/Makefile.in
+++ /dev/null
@@ -1,14 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this file,
-# You can obtain one at http://mozilla.org/MPL/2.0/.
-
-ifdef MOZ_ENABLE_DBUS
-	LOCAL_INCLUDES += $(MOZ_DBUS_CFLAGS)
-endif
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_ENABLE_DBUS
-	CFLAGS          += $(MOZ_DBUS_GLIB_CFLAGS)
-	CXXFLAGS        += $(MOZ_DBUS_GLIB_CFLAGS)
-endif
--- a/ipc/dbus/moz.build
+++ b/ipc/dbus/moz.build
@@ -14,8 +14,14 @@ SOURCES += [
     'RawDBusConnection.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 FAIL_ON_WARNINGS = True
+
+if CONFIG['MOZ_ENABLE_DBUS']:
+    CFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
+    CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+    CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
+    CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
--- a/ipc/ipdl/Makefile.in
+++ b/ipc/ipdl/Makefile.in
@@ -16,12 +16,8 @@ include $(topsrcdir)/config/rules.mk
 export:: $(ALL_IPDLSRCS)
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
 	  $(PLY_INCLUDE) \
 	  $(srcdir)/ipdl.py \
 	  --outheaders-dir=_ipdlheaders \
 	  --outcpp-dir=. \
 	  $(IPDLDIRS:%=-I%) \
 	  $^
-
-# We #include some things in the dom/plugins/ directory that rely on
-# toolkit libraries.
-CXXFLAGS    += $(TK_CFLAGS)
--- a/ipc/ipdl/moz.build
+++ b/ipc/ipdl/moz.build
@@ -9,8 +9,12 @@ if CONFIG['MOZ_IPDL_TESTS']:
 
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 GENERATED_INCLUDES += ['/ipc/ipdl/_ipdlheaders']
+
+# We #include some things in the dom/plugins/ directory that rely on
+# toolkit libraries.
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/layout/base/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
--- a/layout/base/moz.build
+++ b/layout/base/moz.build
@@ -131,8 +131,10 @@ LOCAL_INCLUDES += [
     '/view',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['tests/chrome/chrome.ini']
 BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
deleted file mode 100644
--- a/layout/build/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_GSTREAMER
-CXXFLAGS += $(GSTREAMER_CFLAGS)
-endif
--- a/layout/build/moz.build
+++ b/layout/build/moz.build
@@ -126,9 +126,12 @@ if CONFIG['MOZ_WEBSPEECH']:
         '/content/media/webspeech/synth',
     ]
 
 if CONFIG['MOZ_FFMPEG']:
     LOCAL_INCLUDES += [
         '/content/media/fmp4/ffmpeg/include',
     ]
 
+if CONFIG['MOZ_GSTREAMER']:
+    CXXFLAGS += CONFIG['GSTREAMER_CFLAGS']
+
 FINAL_LIBRARY = 'xul'
deleted file mode 100644
--- a/layout/generic/Makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += \
-		$(MOZ_CAIRO_CFLAGS) \
-		$(NULL)
-
-ifdef MOZ_WIDGET_GTK
-CXXFLAGS += $(TK_CFLAGS)
-endif
-
-ifdef MOZ_ENABLE_QT
-CXXFLAGS += $(MOZ_QT_CFLAGS)
-endif
--- a/layout/generic/moz.build
+++ b/layout/generic/moz.build
@@ -137,8 +137,16 @@ LOCAL_INCLUDES += [
 JAR_MANIFESTS += ['jar.mn']
 
 RESOURCE_FILES.html = [
     'folder.png',
 ]
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_GTK']:
+    CXXFLAGS += CONFIG['TK_CFLAGS']
+
+if CONFIG['MOZ_ENABLE_QT']:
+    CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
deleted file mode 100644
--- a/media/libcubeb/src/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-include $(topsrcdir)/config/rules.mk
-
-CFLAGS += \
-        $(MOZ_ALSA_CFLAGS) \
-        $(MOZ_PULSEAUDIO_CFLAGS) \
-        $(NULL)
--- a/media/libcubeb/src/moz.build
+++ b/media/libcubeb/src/moz.build
@@ -69,8 +69,11 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk
     CFLAGS += [
         '-I%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [
             'frameworks/wilhelm/include',
             'system/media/wilhelm/include',
         ]
     ]
 
 FAIL_ON_WARNINGS = True
+
+CFLAGS += CONFIG['MOZ_ALSA_CFLAGS']
+CFLAGS += CONFIG['MOZ_PULSEAUDIO_CFLAGS']
deleted file mode 100644
--- a/netwerk/base/src/Makefile.in
+++ /dev/null
@@ -1,15 +0,0 @@
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-ifdef MOZ_ENABLE_QTNETWORK
-	OS_INCLUDES += $(MOZ_QT_CFLAGS)
-endif
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_ENABLE_LIBCONIC
-	OS_INCLUDES += $(GLIB_CFLAGS) $(LIBCONIC_CFLAGS)
-endif
--- a/netwerk/base/src/moz.build
+++ b/netwerk/base/src/moz.build
@@ -129,8 +129,11 @@ if 'rtsp' in CONFIG['NECKO_PROTOCOLS']:
 
 if CONFIG['MOZ_ENABLE_QTNETWORK']:
     LOCAL_INCLUDES += [
         '/netwerk/system/qt',
     ]
 
 if CONFIG['ENABLE_TESTS']:
     DEFINES['PREDICTOR_TESTS'] = True
+
+if CONFIG['MOZ_ENABLE_QTNETWORK']:
+    CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
deleted file mode 100644
--- a/netwerk/system/qt/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-OS_INCLUDES += $(MOZ_QT_CFLAGS)
--- a/netwerk/system/qt/moz.build
+++ b/netwerk/system/qt/moz.build
@@ -15,8 +15,9 @@ GENERATED_SOURCES += [
 
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '../../base/src',
 ]
 
+CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
deleted file mode 100644
--- a/netwerk/wifi/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-ifeq ($(OS_ARCH),SunOS)
-OS_INCLUDES += $(GLIB_CFLAGS)
-endif
-
-ifdef NECKO_WIFI_DBUS
-OS_INCLUDES += $(MOZ_DBUS_GLIB_CFLAGS)
-endif
--- a/netwerk/wifi/moz.build
+++ b/netwerk/wifi/moz.build
@@ -39,18 +39,22 @@ elif CONFIG['OS_ARCH'] == 'FreeBSD':
     UNIFIED_SOURCES += [
         'nsWifiScannerFreeBSD.cpp',
     ]
 elif CONFIG['OS_ARCH'] == 'WINNT':
     UNIFIED_SOURCES += [
         'nsWifiScannerWin.cpp',
     ]
 elif CONFIG['OS_ARCH'] == 'SunOS':
+    CXXFLAGS += CONFIG['GLIB_CFLAGS']
     UNIFIED_SOURCES += [
         'nsWifiScannerSolaris.cpp',
     ]
 
 if CONFIG['NECKO_WIFI_DBUS']:
     UNIFIED_SOURCES += [
         'nsWifiScannerDBus.cpp',
     ]
 
+if CONFIG['NECKO_WIFI_DBUS']:
+    CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+
 FINAL_LIBRARY = 'xul'
--- a/rdf/tests/rdfcat/Makefile.in
+++ b/rdf/tests/rdfcat/Makefile.in
@@ -1,12 +1,8 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 EXTRA_LIBS	+= \
 		$(NSPR_LIBS) \
 		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
--- a/rdf/tests/rdfcat/moz.build
+++ b/rdf/tests/rdfcat/moz.build
@@ -10,8 +10,10 @@ SOURCES += [
     'rdfcat.cpp',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'xpcomglue_s',
     'xul',
 ]
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/rdf/tests/triplescat/Makefile.in
+++ b/rdf/tests/triplescat/Makefile.in
@@ -1,12 +1,8 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 EXTRA_LIBS	+= \
 		$(NSPR_LIBS) \
 		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
--- a/rdf/tests/triplescat/moz.build
+++ b/rdf/tests/triplescat/moz.build
@@ -10,8 +10,10 @@ SOURCES += [
     'triplescat.cpp',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'xpcomglue_s',
     'xul',
 ]
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in
+++ b/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in
@@ -5,10 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 include $(topsrcdir)/config/config.mk
 
 EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NSS_LIBS) \
   $(NULL)
-
-DEFINES += $(TK_CFLAGS)
--- a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
+++ b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
@@ -21,8 +21,10 @@ LOCAL_INCLUDES += [
 ]
 
 USE_LIBS += [
     'mozalloc',
     'mozillapkix',
     'pkixtestutil',
     'tlsserver',
 ]
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/storage/build/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-CXXFLAGS += $(SQLITE_CFLAGS)
--- a/storage/build/moz.build
+++ b/storage/build/moz.build
@@ -12,8 +12,10 @@ SOURCES += [
     'mozStorageModule.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += ['../src']
+
+CXXFLAGS += CONFIG['SQLITE_CFLAGS']
deleted file mode 100644
--- a/storage/src/Makefile.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-CXXFLAGS += $(SQLITE_CFLAGS)
--- a/storage/src/moz.build
+++ b/storage/src/moz.build
@@ -64,8 +64,10 @@ if CONFIG['MOZ_MEMORY'] and (not CONFIG[
 # This is the default value.  If we ever change it when compiling sqlite, we
 # will need to change it here as well.
 DEFINES['SQLITE_MAX_LIKE_PATTERN_LENGTH'] = 50000
 
 LOCAL_INCLUDES += [
     '/db/sqlite3/src',
     '/dom/base',
 ]
+
+CXXFLAGS += CONFIG['SQLITE_CFLAGS']
--- a/testing/tools/screenshot/Makefile.in
+++ b/testing/tools/screenshot/Makefile.in
@@ -1,16 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 ifdef MOZ_WIDGET_GTK
 ifdef MOZ_X11
 
-LOCAL_INCLUDES = $(TK_CFLAGS)
 OS_LIBS += $(TK_LIBS) $(XSS_LIBS)
 
 endif # X11
 endif # GTK
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 
 OS_LIBS += $(call EXPAND_LIBNAME,gdiplus)
--- a/testing/tools/screenshot/moz.build
+++ b/testing/tools/screenshot/moz.build
@@ -4,16 +4,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 if CONFIG['MOZ_WIDGET_GTK'] and CONFIG['MOZ_X11']:
     PROGRAM = 'screentopng'
     SOURCES += [
         'gdk-screenshot.cpp',
     ]
+    CXXFLAGS += CONFIG['TK_CFLAGS']
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     PROGRAM = 'screenshot'
     SOURCES += [
         'win32-screenshot.cpp',
     ]
     USE_STATIC_LIBS = True
     if CONFIG['GNU_CC']:
         WIN32_EXE_LDFLAGS += ['-municode']
deleted file mode 100644
--- a/toolkit/components/downloads/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
-
--- a/toolkit/components/downloads/moz.build
+++ b/toolkit/components/downloads/moz.build
@@ -56,8 +56,10 @@ FAIL_ON_WARNINGS = True
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../protobuf',
     '/ipc/chromium/src'
 ]
 
 DEFINES['GOOGLE_PROTOBUF_NO_RTTI'] = True
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/toolkit/components/jsdownloads/src/Makefile.in
+++ /dev/null
@@ -1,7 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
--- a/toolkit/components/jsdownloads/src/moz.build
+++ b/toolkit/components/jsdownloads/src/moz.build
@@ -22,8 +22,10 @@ EXTRA_JS_MODULES += [
 ]
 
 EXTRA_PP_JS_MODULES += [
     'DownloadIntegration.jsm',
     'DownloadUIHelper.jsm',
 ]
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/toolkit/components/protobuf/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
--- a/toolkit/components/protobuf/moz.build
+++ b/toolkit/components/protobuf/moz.build
@@ -52,8 +52,10 @@ if CONFIG['GNU_CXX']:
     CXXFLAGS += [
         '-Wno-null-conversion',
         '-Wno-sign-compare',
     ]
 elif CONFIG['_MSC_VER']:
     CXXFLAGS += [
         '-wd4099', # mismatched class/struct tags
     ]
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/toolkit/components/remote/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-# 
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
--- a/toolkit/components/remote/moz.build
+++ b/toolkit/components/remote/moz.build
@@ -19,8 +19,10 @@ if CONFIG['MOZ_ENABLE_GTK']:
         'nsGTKRemoteService.cpp',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
     SOURCES += [
         'nsQtRemoteService.cpp',
     ]
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/toolkit/components/url-classifier/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += \
-  $(SQLITE_CFLAGS) \
-  $(NULL)
--- a/toolkit/components/url-classifier/moz.build
+++ b/toolkit/components/url-classifier/moz.build
@@ -66,8 +66,9 @@ MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../build',
     '/ipc/chromium/src',
 ]
 
+CXXFLAGS += CONFIG['SQLITE_CFLAGS']
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -1,16 +1,12 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-CXXFLAGS += $(TK_CFLAGS)
-endif
-
 include $(topsrcdir)/toolkit/library/libxul.mk
 # Please don't remove the following comment, because it does some magic:
 # libxul.mk adds FT2_LIBS, NSS_LIBS and NSPR_LIBS, but we want to have the
 # string in this file to trigger a dependency on freetype2, nss and nspr.
 
 ifeq (WINNT_1,$(OS_TARGET)_$(MOZ_PROFILE_USE))
 # Wrap linker to measure peak virtual memory usage.
 LD := $(PYTHON) $(topsrcdir)/build/link.py linker-vsize $(LD)
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -82,8 +82,11 @@ if CONFIG['MOZ_WIDGET_GTK'] and CONFIG['
 
 if CONFIG['MOZ_JPROF']:
     USE_LIBS += [
         'jprof',
     ]
 
 # This needs to be last
 USE_LIBS += ['StaticXULComponentsEnd']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
+    CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/toolkit/mozapps/update/updater/Makefile.in
+++ b/toolkit/mozapps/update/updater/Makefile.in
@@ -13,17 +13,16 @@ OS_LIBS += \
   $(NULL)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 ws2_32 shell32 shlwapi)
 endif
 
 ifdef MOZ_WIDGET_GTK
-OS_CXXFLAGS += $(TK_CFLAGS)
 OS_LIBS += $(TK_LIBS)
 endif
 
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) #{
 OS_LIBS += -lcutils -lsysutils
 # clear out all the --wrap flags and remove dependency on mozglue for Gonk
 WRAP_LDFLAGS :=
 endif #}
--- a/toolkit/mozapps/update/updater/moz.build
+++ b/toolkit/mozapps/update/updater/moz.build
@@ -94,8 +94,11 @@ if CONFIG['_MSC_VER']:
     WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
 elif CONFIG['OS_ARCH'] == 'WINNT':
     WIN32_EXE_LDFLAGS += ['-municode']
 
 if CONFIG['MOZ_UPDATE_CHANNEL'] in ('beta', 'release', 'esr'):
     DEFINES['MAR_SIGNING_RELEASE_BETA'] = '1'
 elif CONFIG['MOZ_UPDATE_CHANNEL'] in ('nightly', 'aurora', 'nightly-elm', 'nightly-profiling', 'nightly-oak', 'nightly-ux'):
     DEFINES['MAR_SIGNING_AURORA_NIGHTLY'] = '1'
+
+if CONFIG['MOZ_WIDGET_GTK']:
+    CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/toolkit/system/dbus/Makefile.in
+++ b/toolkit/system/dbus/Makefile.in
@@ -6,10 +6,8 @@ EXTRA_LIBS += \
 	$(NSPR_LIBS) \
     $(NULL)
 
 OS_LIBS += \
 	$(MOZ_DBUS_GLIB_LIBS) \
 	$(NULL)
                 
 include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
--- a/toolkit/system/dbus/moz.build
+++ b/toolkit/system/dbus/moz.build
@@ -14,8 +14,11 @@ LIBRARY_NAME = 'dbusservice'
 
 IS_COMPONENT = True
 
 USE_LIBS += [
     'mozalloc',
     'xpcomglue_s',
     'xul',
 ]
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
--- a/toolkit/system/gnome/Makefile.in
+++ b/toolkit/system/gnome/Makefile.in
@@ -8,24 +8,8 @@ EXTRA_LIBS += \
 
 OS_LIBS += \
 		$(MOZ_GCONF_LIBS) \
 		$(MOZ_GNOMEVFS_LIBS) \
 		$(GLIB_LIBS) \
 		$(MOZ_GIO_LIBS) \
 		$(MOZ_DBUS_GLIB_LIBS) \
 		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += \
-	$(MOZ_GCONF_CFLAGS) \
-	$(MOZ_GNOMEVFS_CFLAGS) \
-	$(MOZ_GIO_CFLAGS) \
-	$(GLIB_CFLAGS) \
-	$(MOZ_DBUS_GLIB_CFLAGS) \
-	$(NULL)
-
-ifdef MOZ_ENABLE_GTK
-CXXFLAGS += \
-	$(TK_CFLAGS) \
-	$(NULL)
-endif
--- a/toolkit/system/gnome/moz.build
+++ b/toolkit/system/gnome/moz.build
@@ -33,8 +33,17 @@ LOCAL_INCLUDES += [
     '/toolkit/components/build/',
 ]
 
 USE_LIBS += [
     'mozalloc',
     'xpcomglue_s',
     'xul',
 ]
+
+CXXFLAGS += CONFIG['MOZ_GCONF_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_GNOMEVFS_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_GIO_CFLAGS']
+CXXFLAGS += CONFIG['GLIB_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+
+if CONFIG['MOZ_ENABLE_GTK']:
+    CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/toolkit/system/unixproxy/Makefile.in
+++ /dev/null
@@ -1,7 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-ifdef MOZ_ENABLE_LIBPROXY
-CXXFLAGS += $(MOZ_LIBPROXY_CFLAGS)
-endif # MOZ_ENABLE_LIBPROXY
--- a/toolkit/system/unixproxy/moz.build
+++ b/toolkit/system/unixproxy/moz.build
@@ -1,15 +1,16 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 if CONFIG['MOZ_ENABLE_LIBPROXY']:
+    CXXFLAGS += CONFIG['MOZ_LIBPROXY_CFLAGS']
     SOURCES += [
         'nsLibProxySettings.cpp',
     ]
 else:
     SOURCES += [
         'nsUnixSystemProxySettings.cpp',
     ]
 
--- a/toolkit/xre/Makefile.in
+++ b/toolkit/xre/Makefile.in
@@ -7,22 +7,16 @@
 
 USE_RCS_MK=1
 include $(topsrcdir)/config/makefiles/makeutils.mk
 
 milestone_txt = $(topsrcdir)/config/milestone.txt
 
 include $(topsrcdir)/config/rules.mk
 
-CXXFLAGS += $(TK_CFLAGS) $(MOZ_DBUS_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
-
-ifdef MOZ_WIDGET_GTK
-CXXFLAGS += $(MOZ_PANGO_CFLAGS)
-endif
-
 # Should version be optional or required ?
 TOOLKIT_EM_VERSION=$(shell $(PERL) $(topsrcdir)/config/milestone.pl --topsrcdir=$(topsrcdir))
 $(call warnIfEmpty,TOOLKIT_EM_VERSION)
 
 # Valid if null: {warn,error}IfEmpty
 DEFINES += -DTOOLKIT_EM_VERSION='"$(TOOLKIT_EM_VERSION)"'
 
 MOZ_SOURCE_STAMP ?= $(firstword $(shell hg -R $(topsrcdir) parent --template='{node|short}\n' 2>/dev/null))
--- a/toolkit/xre/moz.build
+++ b/toolkit/xre/moz.build
@@ -155,8 +155,14 @@ LOCAL_INCLUDES += [
     '/xpcom/build',
 ]
 
 if CONFIG['MOZ_ENABLE_XREMOTE']:
     LOCAL_INCLUDES += [
         '/widget/xremoteclient',
     ]
 
+CXXFLAGS += CONFIG['TK_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_GTK']:
+    CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
deleted file mode 100644
--- a/uriloader/exthandler/Makefile.in
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-ifdef MOZ_ENABLE_DBUS
-OS_INCLUDES   += $(TK_CFLAGS) $(MOZ_DBUS_CFLAGS)
-endif
-
-include $(topsrcdir)/config/rules.mk
-
-ifneq (,$(filter qt gtk2 gtk3, $(MOZ_WIDGET_TOOLKIT)))
-CXXFLAGS += $(TK_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
-endif
--- a/uriloader/exthandler/moz.build
+++ b/uriloader/exthandler/moz.build
@@ -131,8 +131,15 @@ FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/content/base/src',
     '/dom/base',
     '/dom/ipc',
     '/netwerk/base/src',
     '/netwerk/protocol/http',
 ]
 
+if CONFIG['MOZ_ENABLE_DBUS']:
+    CXXFLAGS += CONFIG['TK_CFLAGS']
+    CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('qt', 'gtk2', 'gtk3'):
+    CXXFLAGS += CONFIG['TK_CFLAGS']
+    CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
deleted file mode 100644
--- a/view/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
--- a/view/moz.build
+++ b/view/moz.build
@@ -15,8 +15,10 @@ SOURCES += [
     'nsViewManager.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
--- a/webapprt/gtk/Makefile.in
+++ b/webapprt/gtk/Makefile.in
@@ -7,16 +7,12 @@ OS_LIBS += \
   $(NULL)
 
 NSDISTMODE = copy
 
 PROGRAMS_DEST = $(DIST)/bin
 
 include $(topsrcdir)/config/rules.mk
 
-CXXFLAGS += \
-	$(TK_CFLAGS) \
-	$(NULL)
-
 GRE_BUILDID := $(shell cat $(DEPTH)/config/buildid)
 DEFINES += -DGRE_BUILDID=$(GRE_BUILDID)
 
 webapprt.$(OBJ_SUFFIX): $(DEPTH)/config/buildid
--- a/webapprt/gtk/moz.build
+++ b/webapprt/gtk/moz.build
@@ -21,8 +21,10 @@ LOCAL_INCLUDES += [
     '/xpcom/build',
 ]
 
 USE_LIBS += [
     'xpcomglue',
 ]
 
 DISABLE_STL_WRAPPING = True
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/widget/cocoa/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(TK_CFLAGS)
--- a/widget/cocoa/moz.build
+++ b/widget/cocoa/moz.build
@@ -122,8 +122,9 @@ RESOURCE_FILES.cursors += [
 # $(DIST)/bin/res/MainMenu/nib. Instead, we call __setattr__ directly to create
 # an attribute with the correct name.
 RESOURCE_FILES.__setattr__('MainMenu.nib', [
     'resources/MainMenu.nib/classes.nib',
     'resources/MainMenu.nib/info.nib',
     'resources/MainMenu.nib/keyedobjects.nib',
 ])
 
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/widget/gtk/Makefile.in
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CFLAGS          += $(MOZ_STARTUP_NOTIFICATION_CFLAGS)
-CXXFLAGS        += $(MOZ_CAIRO_CFLAGS) $(MOZ_STARTUP_NOTIFICATION_CFLAGS)
-
-CFLAGS          += $(TK_CFLAGS)
-CXXFLAGS        += $(TK_CFLAGS)
-
-ifdef MOZ_ENABLE_DBUS
-CXXFLAGS        += $(MOZ_DBUS_GLIB_CFLAGS)
-endif
--- a/widget/gtk/moz.build
+++ b/widget/gtk/moz.build
@@ -98,8 +98,18 @@ LOCAL_INCLUDES += [
 if CONFIG['MOZ_X11']:
     LOCAL_INCLUDES += [
         '../shared/x11',
     ]
 
 DEFINES['CAIRO_GFX'] = True
 
 DEFINES['MOZ_APP_NAME'] = '"%s"' % CONFIG['MOZ_APP_NAME']
+
+CFLAGS += CONFIG['MOZ_STARTUP_NOTIFICATION_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_STARTUP_NOTIFICATION_CFLAGS']
+
+CFLAGS += CONFIG['TK_CFLAGS']
+CXXFLAGS += CONFIG['TK_CFLAGS']
+
+if CONFIG['MOZ_ENABLE_DBUS']:
+    CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
deleted file mode 100644
--- a/widget/gtkxtbin/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-include $(topsrcdir)/config/rules.mk
-
-CFLAGS		+= $(MOZ_GTK2_CFLAGS)
--- a/widget/gtkxtbin/moz.build
+++ b/widget/gtkxtbin/moz.build
@@ -10,8 +10,10 @@ EXPORTS += [
 
 SOURCES += [
     'gtk2xtbin.c',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 DEFINES['_IMPL_GTKXTBIN_API'] = True
+
+CFLAGS += CONFIG['MOZ_GTK2_CFLAGS']
deleted file mode 100644
--- a/widget/qt/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS	+= $(MOZ_QT_CFLAGS) $(MOZ_CAIRO_CFLAGS)
-CFLAGS		+= $(MOZ_QT_CFLAGS) $(MOZ_CAIRO_CFLAGS)
--- a/widget/qt/moz.build
+++ b/widget/qt/moz.build
@@ -53,8 +53,13 @@ if CONFIG['OS_ARCH'] == 'Linux':
 
 if CONFIG['OS_ARCH'] == 'SunOS' and not CONFIG['GNU_CC']:
     # When using Sun's WorkShop compiler, including
     # /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
     # causes most of these compiles to fail with:
     # line 29: Error: Multiple declaration for std::tm.
     # So, this gets around the problem.
     DEFINES['_TIME_H'] = 1
+
+CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+CFLAGS += CONFIG['MOZ_QT_CFLAGS']
+CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
deleted file mode 100644
--- a/widget/shared/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS	+= $(TK_CFLAGS)
--- a/widget/shared/moz.build
+++ b/widget/shared/moz.build
@@ -13,8 +13,10 @@ UNIFIED_SOURCES += [
     'WidgetEventImpl.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/widget/shared/x11/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS   += $(TK_CFLAGS)
--- a/widget/shared/x11/moz.build
+++ b/widget/shared/x11/moz.build
@@ -4,8 +4,10 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 SOURCES += [
     'keysym2ucs.c',
 ]
 
 FINAL_LIBRARY = 'xul'
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/widget/windows/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
--- a/widget/windows/moz.build
+++ b/widget/windows/moz.build
@@ -106,8 +106,10 @@ LOCAL_INCLUDES += [
 
 DEFINES['MOZ_UNICODE'] = True
 
 for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'):
     if CONFIG[var]:
         DEFINES[var] = True
 
 RESFILE = 'widget.res'
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
--- a/widget/windows/winrt/Makefile.in
+++ b/widget/windows/winrt/Makefile.in
@@ -12,10 +12,8 @@ GARBAGE += $(MIDL_GENERATED_FILES) done_
 
 do_interfaces_gen: UIABridge.idl
 	$(MIDL) $(srcdir)/UIABridge.idl -I $(srcdir)
 	touch $@
 
 export:: do_interfaces_gen
 
 include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
--- a/widget/windows/winrt/moz.build
+++ b/widget/windows/winrt/moz.build
@@ -44,8 +44,10 @@ LOCAL_INCLUDES += [
     '/xpcom/base',
 ]
 
 DEFINES['MOZ_UNICODE'] = True
 
 for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'):
     if CONFIG[var]:
         DEFINES[var] = True
+
+CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
deleted file mode 100644
--- a/widget/xpwidgets/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-CXXFLAGS	+= $(TK_CFLAGS)
--- a/widget/xpwidgets/moz.build
+++ b/widget/xpwidgets/moz.build
@@ -92,8 +92,10 @@ if widget_dir in ('gtk3', 'gtk2'):
 
 LOCAL_INCLUDES += [
     '../%s' % widget_dir,
 ]
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_ENABLE_D3D10_LAYER']:
     DEFINES['MOZ_ENABLE_D3D10_LAYER'] = True
+
+CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/xpcom/base/Makefile.in
+++ b/xpcom/base/Makefile.in
@@ -8,20 +8,16 @@ errorlist_FILES := \
   ErrorListCDefines.h \
   ErrorListCxxDefines.h \
   $(NULL)
 errorlist_DEST = $(DIST)/include
 errorlist_TARGET := export
 
 include $(topsrcdir)/config/rules.mk
 
-ifdef MOZ_WIDGET_GTK
-CXXFLAGS        += $(TK_CFLAGS)
-endif
-
 # We generate ErrorListCxxDefines.h from ErrorList.h using regex.  The -n option
 # suppresses printing the pattern space, and the p at the end prints it anyway,
 # so we don't print lines that don't match the pattern to start with.
 ErrorListCxxDefines.h: ErrorList.h Makefile
 	echo '// IWYU pragma: private, include "nsError.h"' > $@
 	sed -n 's/.*ERROR(\([A-Z_0-9]*\).*/#define \1 nsresult::\1/p' < $< >> $@
 
 ErrorListCDefines.h: ErrorList.h Makefile
--- a/xpcom/base/moz.build
+++ b/xpcom/base/moz.build
@@ -151,8 +151,11 @@ FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../build',
     '/xpcom/ds',
 ]
 
 if CONFIG['MOZ_OPTIMIZE']:
     DEFINES['MOZ_OPTIMIZE'] = True
+
+if CONFIG['MOZ_WIDGET_GTK']:
+    CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/xpcom/build/Makefile.in
+++ /dev/null
@@ -1,12 +0,0 @@
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-include $(topsrcdir)/config/rules.mk
-
-ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-CXXFLAGS	+= $(TK_CFLAGS)
-endif
--- a/xpcom/build/moz.build
+++ b/xpcom/build/moz.build
@@ -92,8 +92,11 @@ LOCAL_INCLUDES += [
     '/chrome',
     '/docshell/base',
 ]
 
 if CONFIG['MOZ_VPX']:
     LOCAL_INCLUDES += [
         '/media/libvpx',
     ]
+
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
+    CXXFLAGS += CONFIG['TK_CFLAGS']
deleted file mode 100644
--- a/xpcom/components/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(topsrcdir)/config/rules.mk
-
-ifdef MOZ_WIDGET_GTK
-CXXFLAGS        += $(TK_CFLAGS)
-endif
--- a/xpcom/components/moz.build
+++ b/xpcom/components/moz.build
@@ -48,8 +48,11 @@ GENERATED_INCLUDES += ['..']
 LOCAL_INCLUDES += [
     '../base',
     '../build',
     '../ds',
     '../reflect/xptinfo',
     '/chrome',
     '/modules/libjar',
 ]
+
+if CONFIG['MOZ_WIDGET_GTK']:
+    CXXFLAGS += CONFIG['TK_CFLAGS']