Bug 1036894 part 9 - Replace all EXTRA_DSO_LDOPTS, SHARED_LIBRARY_LIBS and LIBS with EXTRA_LIBS, OS_LIBS or OS_LDFLAGS, appropriately. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 23 Jul 2014 13:31:02 +0900
changeset 195629 a0988e587a90
parent 195628 562e8494fb47
child 195630 108d2af6b1e6
push id46645
push usermh@glandium.org
push dateWed, 23 Jul 2014 04:33:55 +0000
treeherdermozilla-inbound@c71f854e6358 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1036894
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1036894 part 9 - Replace all EXTRA_DSO_LDOPTS, SHARED_LIBRARY_LIBS and LIBS with EXTRA_LIBS, OS_LIBS or OS_LDFLAGS, appropriately. r=gps OS_LIBS for libraries that are not part of the gecko tree, EXTRA_LIBS for libraries, such as NSPR, that are in the tree, but are not handled by moz.build just yet. Those EXTRA_LIBS may also come from a system library. However, in cases where the expanded variables are always empty for the in-tree case, OS_LIBS is used (as for, e.g. MOZ_ZLIB_LIBS). OS_LDFLAGS is used exclusively for non-library linker flags. Always pass EXTRA_LIBS before OS_LIBS on linker command lines. Forbid EXTRA_DSO_LDOPTS, SHARED_LIBRARY_LIBS and LIBS in Makefiles.
b2g/app/Makefile.in
browser/app/Makefile.in
browser/components/build/Makefile.in
config/config.mk
config/rules.mk
dom/plugins/test/testplugin/testplugin.mk
extensions/gnomevfs/Makefile.in
intl/unicharutil/tests/Makefile.in
ipc/app/Makefile.in
ipc/ipdl/test/cxx/app/Makefile.in
js/src/Makefile.in
js/src/gdb/Makefile.in
js/src/jsapi-tests/Makefile.in
js/src/shell/Makefile.in
js/xpconnect/shell/Makefile.in
js/xpconnect/tests/Makefile.in
js/xpconnect/tests/components/native/Makefile.in
layout/media/Makefile.in
media/libcubeb/tests/Makefile.in
media/mtransport/test/Makefile.in
media/webrtc/signaling/test/Makefile.in
modules/libmar/tool/Makefile.in
mozglue/build/Makefile.in
mozglue/tests/Makefile.in
netwerk/streamconv/test/Makefile.in
netwerk/test/Makefile.in
rdf/tests/rdfcat/Makefile.in
rdf/tests/rdfpoll/Makefile.in
rdf/tests/triplescat/Makefile.in
security/build/Makefile.in
security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in
security/sandbox/win/src/sandboxbroker/Makefile.in
startupcache/test/Makefile.in
storage/test/Makefile.in
testing/mochitest/ssltunnel/Makefile.in
toolkit/crashreporter/test/Makefile.in
toolkit/library/libxul.mk
toolkit/mozapps/update/updater/Makefile.in
toolkit/system/dbus/Makefile.in
toolkit/system/gnome/Makefile.in
tools/trace-malloc/Makefile.in
uriloader/exthandler/tests/Makefile.in
webapprt/gtk/Makefile.in
widget/gtk/mozgtk/gtk2/Makefile.in
widget/gtk/mozgtk/gtk3/Makefile.in
widget/xremoteclient/Makefile.in
xpcom/reflect/xptcall/tests/Makefile.in
xpcom/reflect/xptinfo/tests/Makefile.in
xpcom/sample/Makefile.in
xpcom/sample/program/Makefile.in
xpcom/tests/bug656331_component/Makefile.in
xpcom/tests/component/Makefile.in
xpcom/tests/component_no_aslr/Makefile.in
xpcom/tests/external/Makefile.in
xulrunner/examples/simple/components/src/Makefile.in
xulrunner/stub/Makefile.in
--- a/b2g/app/Makefile.in
+++ b/b2g/app/Makefile.in
@@ -5,34 +5,34 @@
 USE_RCS_MK := 1
 include $(topsrcdir)/config/makefiles/rcs.mk
 
 PREF_JS_EXPORTS = $(srcdir)/b2g.js
 
 ifndef LIBXUL_SDK
 
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-LIBS += \
+OS_LIBS += \
   -lui \
   -lEGL \
   -lhardware_legacy \
   -lhardware \
   -lcutils \
   $(MOZ_ZLIB_LIBS) \
   $(NULL)
 ifeq ($(ANDROID_VERSION),$(findstring $(ANDROID_VERSION),17 18 19))
-LIBS += \
+OS_LIBS += \
   -lgui \
   -lsuspend \
   $(NULL)
 endif
 endif
 
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-LIBS += \
+OS_LIBS += \
   -lbinder \
   -lutils \
   $(NULL)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,version)
 endif
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -21,21 +21,21 @@ DEFINES += \
 
 ifdef LIBXUL_SDK #{
 PREF_JS_EXPORTS += $(srcdir)/profile/channel-prefs.js
 endif #} LIBXUL_SDK
 
 # Build a binary bootstrapping with XRE_main
 
 ifdef MOZ_LINKER
-LIBS += $(MOZ_ZLIB_LIBS)
+OS_LIBS += $(MOZ_ZLIB_LIBS)
 endif
 
 ifdef HAVE_CLOCK_MONOTONIC
-LIBS += $(REALTIME_LIBS)
+OS_LIBS += $(REALTIME_LIBS)
 endif
 
 ifndef MOZ_WINCONSOLE
 ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
 endif
--- a/browser/components/build/Makefile.in
+++ b/browser/components/build/Makefile.in
@@ -5,24 +5,24 @@
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS	+= $(call EXPAND_LIBNAME,ole32 shell32 shlwapi)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,version)
 endif
 
-EXTRA_DSO_LDOPTS += \
+EXTRA_LIBS += \
 	$(NSPR_LIBS) \
 	$(NULL)
 
 # Mac: Need to link with CoreFoundation for Mac Migrators (PList reading code)
 # GTK2: Need to link with glib for GNOME shell service
 ifneq (,$(filter cocoa gtk2 gtk3,$(MOZ_WIDGET_TOOLKIT)))
-EXTRA_DSO_LDOPTS += \
+OS_LIBS += \
   $(TK_LIBS) \
   $(NULL)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 # Ensure that we don't embed a manifest referencing the CRT.
 EMBED_MANIFEST_AT =
--- a/config/config.mk
+++ b/config/config.mk
@@ -35,41 +35,44 @@ endif
 # responsibility between Makefile.in and mozbuild files.
 _MOZBUILD_EXTERNAL_VARIABLES := \
   ANDROID_GENERATED_RESFILES \
   ANDROID_RES_DIRS \
   CMSRCS \
   CMMSRCS \
   CPP_UNIT_TESTS \
   DIRS \
+  EXTRA_DSO_LDOPTS \
   EXTRA_PP_COMPONENTS \
   EXTRA_PP_JS_MODULES \
   FORCE_SHARED_LIB \
   FORCE_STATIC_LIB \
   FINAL_LIBRARY \
   HOST_CSRCS \
   HOST_CMMSRCS \
   HOST_LIBRARY_NAME \
   HOST_PROGRAM \
   HOST_SIMPLE_PROGRAMS \
   IS_COMPONENT \
   JAR_MANIFEST \
   JAVA_JAR_TARGETS \
   JS_MODULES_PATH \
   LD_VERSION_SCRIPT \
   LIBRARY_NAME \
+  LIBS \
   MAKE_FRAMEWORK \
   MODULE \
   MSVC_ENABLE_PGO \
   NO_DIST_INSTALL \
   PARALLEL_DIRS \
   PROGRAM \
   RESOURCE_FILES \
   SDK_HEADERS \
   SDK_LIBRARY \
+  SHARED_LIBRARY_LIBS \
   SHARED_LIBRARY_NAME \
   SIMPLE_PROGRAMS \
   SONAME \
   STATIC_LIBRARY_NAME \
   TEST_DIRS \
   TIERS \
   TOOL_DIRS \
   XPCSHELL_TESTS \
@@ -766,17 +769,17 @@ endif
 EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB)
 
 ifneq (,$(MOZ_LIBSTDCXX_TARGET_VERSION)$(MOZ_LIBSTDCXX_HOST_VERSION))
 ifneq ($(OS_ARCH),Darwin)
 CHECK_STDCXX = @$(TOOLCHAIN_PREFIX)objdump -p $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' > /dev/null && echo 'TEST-UNEXPECTED-FAIL | check_stdcxx | We do not want these libstdc++ symbols to be used:' && $(TOOLCHAIN_PREFIX)objdump -T $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' && false || true
 endif
 
 ifdef MOZ_LIBSTDCXX_TARGET_VERSION
-EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,stdc++compat,$(DEPTH)/build/unix/stdc++compat)
+OS_LIBS += $(call EXPAND_LIBNAME_PATH,stdc++compat,$(DEPTH)/build/unix/stdc++compat)
 endif
 ifdef MOZ_LIBSTDCXX_HOST_VERSION
 HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,host_stdc++compat,$(DEPTH)/build/unix/stdc++compat)
 endif
 endif
 
 ifeq (,$(filter $(OS_TARGET),WINNT Darwin))
 CHECK_TEXTREL = @$(TOOLCHAIN_PREFIX)readelf -d $(1) | grep TEXTREL > /dev/null && echo 'TEST-UNEXPECTED-FAIL | check_textrel | We do not want text relocations in libraries and programs' || true
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -700,17 +700,17 @@ ifdef MSMANIFEST_TOOL
 	fi
 endif	# MSVC with manifest tool
 ifdef MOZ_PROFILE_GENERATE
 # touch it a few seconds into the future to work around FAT's
 # 2-second granularity
 	touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
 endif
 else # !WINNT || GNU_CC
-	$(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(STLPORT_LIBS)
+	$(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(STLPORT_LIBS)
 	$(call CHECK_BINARY,$@)
 endif # WINNT && !GNU_CC
 
 ifdef ENABLE_STRIP
 	$(STRIP) $(STRIP_FLAGS) $@
 endif
 ifdef MOZ_POST_PROGRAM_COMMAND
 	$(MOZ_POST_PROGRAM_COMMAND) $@
@@ -756,17 +756,17 @@ ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
 	$(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
 ifdef MSMANIFEST_TOOL
 	@if test -f $@.manifest; then \
 		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
 		rm -f $@.manifest; \
 	fi
 endif	# MSVC with manifest tool
 else
-	$(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(STLPORT_LIBS)
+	$(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(STLPORT_LIBS)
 	$(call CHECK_BINARY,$@)
 endif # WINNT && !GNU_CC
 
 ifdef ENABLE_STRIP
 	$(STRIP) $(STRIP_FLAGS) $@
 endif
 ifdef MOZ_POST_PROGRAM_COMMAND
 	$(MOZ_POST_PROGRAM_COMMAND) $@
@@ -787,23 +787,23 @@ endif
 ifdef DTRACE_PROBE_OBJ
 EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
 OBJS += $(DTRACE_PROBE_OBJ)
 endif
 
 $(filter %.$(LIB_SUFFIX),$(LIBRARY)): $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
 	$(REPORT_BUILD)
 	$(RM) $(LIBRARY)
-	$(EXPAND_AR) $(AR_FLAGS) $(OBJS) $(SHARED_LIBRARY_LIBS)
+	$(EXPAND_AR) $(AR_FLAGS) $(OBJS) $(SHARED_LIBRARY_LIBS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS))
 
 $(filter-out %.$(LIB_SUFFIX),$(LIBRARY)): $(filter %.$(LIB_SUFFIX),$(LIBRARY)) $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
 # When we only build a library descriptor, blow out any existing library
 	$(REPORT_BUILD)
 	$(if $(filter %.$(LIB_SUFFIX),$(LIBRARY)),,$(RM) $(REAL_LIBRARY))
-	$(EXPAND_LIBS_GEN) -o $@ $(OBJS) $(SHARED_LIBRARY_LIBS)
+	$(EXPAND_LIBS_GEN) -o $@ $(OBJS) $(SHARED_LIBRARY_LIBS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS))
 
 ifeq ($(OS_ARCH),WINNT)
 # Import libraries are created by the rules creating shared libraries.
 # The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY),
 # but make will happily consider the import library before it is refreshed
 # when rebuilding the corresponding shared library. Defining an empty recipe
 # for import libraries forces make to wait for the shared library recipe to
 # have run before considering other targets that depend on the import library.
@@ -837,20 +837,20 @@ endif
 	$(REPORT_BUILD)
 ifndef INCREMENTAL_LINKER
 	$(RM) $@
 endif
 ifdef DTRACE_LIB_DEPENDENT
 ifndef XP_MACOSX
 	dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o  $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS))
 endif
-	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
+	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
 	@$(RM) $(DTRACE_PROBE_OBJ)
 else # ! DTRACE_LIB_DEPENDENT
-	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
+	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
 endif # DTRACE_LIB_DEPENDENT
 	$(call CHECK_BINARY,$@)
 
 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
 ifdef MSMANIFEST_TOOL
 ifdef EMBED_MANIFEST_AT
 	@if test -f $@.manifest; then \
 		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
--- a/dom/plugins/test/testplugin/testplugin.mk
+++ b/dom/plugins/test/testplugin/testplugin.mk
@@ -2,17 +2,17 @@
 # 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)
-EXTRA_DSO_LDOPTS = \
+OS_LIBS += \
                 $(MOZ_QT_LIBS) \
                 $(XLDFLAGS) \
                 $(XLIBS)
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 OS_LIBS  += $(call EXPAND_LIBNAME,msimg32)
 
@@ -35,10 +35,10 @@ 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)
-EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS)
+OS_LIBS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS)
 endif
--- a/extensions/gnomevfs/Makefile.in
+++ b/extensions/gnomevfs/Makefile.in
@@ -1,11 +1,11 @@
 # 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)
 
-EXTRA_DSO_LDOPTS += \
+OS_LIBS += \
 		   $(NSPR_LIBS) \
 		   $(MOZ_GNOMEVFS_LIBS) \
 		   $(NULL)
--- a/intl/unicharutil/tests/Makefile.in
+++ b/intl/unicharutil/tests/Makefile.in
@@ -1,8 +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/.
 
-LIBS		+= \
+EXTRA_LIBS		+= \
 	$(NSPR_LIBS) \
 	$(NULL)
--- a/ipc/app/Makefile.in
+++ b/ipc/app/Makefile.in
@@ -4,23 +4,23 @@
 
 ifneq ($(dir $(PROGRAM)),./)
   GENERATED_DIRS = $(dir $(PROGRAM))
 endif
 
 ifeq (android,$(MOZ_WIDGET_TOOLKIT))
 WRAP_LDFLAGS =
 else
-LIBS += \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NULL)
 endif
 
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-LIBS += \
+OS_LIBS += \
   -lbinder \
   -lutils \
   $(NULL)
 endif
 
 ifndef MOZ_WINCONSOLE
 ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
@@ -33,19 +33,16 @@ endif
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
 include $(topsrcdir)/config/config.mk
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),WINNT) #{
-
-LIBS += $(NSPR_LIBS)
-
 # Note the manifest file exists in the tree, so we use the explicit filename
 # here.
 EXTRA_DEPS += plugin-container.exe.manifest
 endif #}
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) #{
 
 libs::
--- a/ipc/ipdl/test/cxx/app/Makefile.in
+++ b/ipc/ipdl/test/cxx/app/Makefile.in
@@ -1,13 +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/.
 
 NSDISTMODE = copy
 
-LIBS += \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NULL)
-
-include $(topsrcdir)/config/config.mk
-
-include $(topsrcdir)/config/rules.mk
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -10,44 +10,42 @@ endif
 make_min_ver := 3.81
 ifneq ($(make_min_ver),$(firstword $(sort $(make_min_ver) $(MAKE_VERSION))))
 $(error GNU Make $(make_min_ver) or higher is required)
 endif
 
 TOPLEVEL_BUILD := 1
 
 run_for_side_effects := $(shell echo 'MAKE: $(MAKE)')
-LIBS		+= $(NSPR_LIBS)
+EXTRA_LIBS		+= $(NSPR_LIBS)
 
 DIST_INSTALL = 1
 
 ifdef JS_HAS_CTYPES
 ifdef MOZ_NATIVE_FFI
 LOCAL_INCLUDES = $(MOZ_FFI_CFLAGS)
 endif
 
 ifdef MOZ_NATIVE_FFI
-EXTRA_DSO_LDOPTS += $(MOZ_FFI_LIBS)
+OS_LIBS += $(MOZ_FFI_LIBS)
 else
-SHARED_LIBRARY_LIBS += \
+EXTRA_LIBS += \
     ctypes/libffi/.libs/libffi.$(LIB_SUFFIX) \
     $(NULL)
 endif
 
 # Windows needs this to be linked with a static library.
 ifndef MOZ_NATIVE_FFI
 DEFINES += -DFFI_BUILDING
 endif
 
 endif # JS_HAS_CTYPES
 
 DASH_R		= -r
 
-EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
-
 # Define keyword generator before rules.mk, see bug 323979 comment 50
 
 GARBAGE += jsautokw.h host_jskwgen$(HOST_BIN_SUFFIX)
 
 GARBAGE += selfhosted.out.h
 
 USE_HOST_CXX = 1
 
@@ -56,17 +54,17 @@ ifneq ($(OS_ARCH),Darwin)
 DTRACE_PROBE_OBJ = $(LIBRARY_NAME)-dtrace.$(OBJ_SUFFIX)
 endif
 MOZILLA_DTRACE_SRC = $(srcdir)/devtools/javascript-trace.d
 endif
 
 # Ensure symbol versions of shared library on Linux do not conflict
 # with those in libxul.
 ifeq (Linux,$(OS_TARGET))
-EXTRA_DSO_LDOPTS += -Wl,-version-script,symverscript
+OS_LDFLAGS += -Wl,-version-script,symverscript
 
 symverscript: symverscript.in
 	$(call py_action,preprocessor, \
 		-DVERSION='$(subst -,_,$(LIBRARY_NAME))' $< -o $@)
 
 EXTRA_DEPS += symverscript
 endif
 
@@ -198,33 +196,29 @@ distclean::
 ifneq ($(findstring -L,$(NSPR_LIBS)),)
 NSPR_STATIC_PATH = $(subst -L,,$(findstring -L,$(NSPR_LIBS)))
 else
 NSPR_STATIC_PATH = $(DIST)/lib
 endif
 
 # HP-UX does not require the extra linking of "-lm"
 ifeq (,$(filter HP-UX WINNT,$(OS_ARCH)))
-EXTRA_LIBS	+= -lm
+OS_LIBS	+= -lm
 endif
 
 CFLAGS += $(MOZ_ZLIB_CFLAGS)
-EXTRA_LIBS += $(MOZ_ZLIB_LIBS)
+OS_LIBS += $(MOZ_ZLIB_LIBS)
 
-ifdef MOZ_SHARED_ICU
-EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS)
-else
-SHARED_LIBRARY_LIBS += $(MOZ_ICU_LIBS)
-endif
+EXTRA_LIBS += $(MOZ_ICU_LIBS)
 
 ifeq ($(OS_ARCH),FreeBSD)
-EXTRA_LIBS	+= -pthread
+OS_LIBS	+= -pthread
 endif
 ifeq ($(OS_ARCH),Linux)
-EXTRA_LIBS	+= -ldl
+OS_LIBS	+= -ldl
 endif
 # Silence warnings on AIX/HP-UX from non-GNU compilers
 ifndef GNU_CC
 ifeq ($(OS_ARCH),AIX)
 # Suppress warnings from xlC
 # 1540-1281: offsetof() on null non-POD types
 # 1540-1608: anonymous unions using static data members
 CFLAGS		+= -qsuppress=1540-1281 -qsuppress=1540-1608
@@ -242,17 +236,17 @@ ifeq ($(OS_ARCH),SunOS)
 ifeq ($(TARGET_CPU),sparc)
 
 ifdef GNU_CC
 CFLAGS   += -mcpu=v9
 CXXFLAGS += -mcpu=v9
 endif # GNU_CC
 
 endif
-EXTRA_LIBS	+= -lposix4 -ldl -lnsl -lsocket
+OS_LIBS	+= -lposix4 -ldl -lnsl -lsocket
 endif
 
 SCRIPTS = $(JS_CONFIG_NAME)
 SDK_BINARY = $(JS_CONFIG_NAME)
 
 $(LIBRARY_NAME).pc: js.pc
 	cp $^ $@
 
--- a/js/src/gdb/Makefile.in
+++ b/js/src/gdb/Makefile.in
@@ -1,21 +1,22 @@
 # -*- Mode: makefile -*-
 #
 # 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/.
 
-LIBS += $(NSPR_LIBS) $(MOZ_ZLIB_LIBS)
+EXTRA_LIBS += $(NSPR_LIBS)
+OS_LIBS +=  $(MOZ_ZLIB_LIBS)
 
 ifdef MOZ_SHARED_ICU
-EXTRA_LIBS += $(MOZ_ICU_LIBS)
+OS_LIBS += $(MOZ_ICU_LIBS)
 endif
 
-EXTRA_LIBS += $(MOZ_FFI_LIBS)
+OS_LIBS += $(MOZ_FFI_LIBS)
 
 # Place a GDB Python auto-load file next to the gdb-tests executable, both
 # in the build directory and in the dist/bin directory.
 PP_TARGETS += GDB_AUTOLOAD
 GDB_AUTOLOAD := gdb-tests-gdb.py.in
 GDB_AUTOLOAD_FLAGS := -Dtopsrcdir=$(abspath $(srcdir)/..)
 
 INSTALL_TARGETS += GDB_INSTALL_AUTOLOAD
--- a/js/src/jsapi-tests/Makefile.in
+++ b/js/src/jsapi-tests/Makefile.in
@@ -1,25 +1,24 @@
 # -*- Mode: makefile -*-
 #
 # 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/.
 
-LIBS      += $(NSPR_LIBS) $(MOZ_ZLIB_LIBS)
+EXTRA_LIBS      += $(NSPR_LIBS)
+OS_LIBS += $(MOZ_ZLIB_LIBS)
 
 ifdef MOZ_SHARED_ICU
-EXTRA_LIBS += $(MOZ_ICU_LIBS)
+OS_LIBS += $(MOZ_ICU_LIBS)
 endif
 
-EXTRA_LIBS += $(MOZ_FFI_LIBS)
+OS_LIBS += $(MOZ_FFI_LIBS)
 
 ifdef QEMU_EXE
 MOZ_POST_PROGRAM_COMMAND = $(topsrcdir)/build/qemu-wrap --qemu $(QEMU_EXE) --libdir $(CROSS_LIB)
 endif
 
 # Place a GDB Python auto-load file next to the jsapi-tests executable in
 # the build directory.
 PP_TARGETS += JSAPI_TESTS_AUTOLOAD
 JSAPI_TESTS_AUTOLOAD := jsapi-tests-gdb.py.in
 JSAPI_TESTS_AUTOLOAD_FLAGS := -Dtopsrcdir=$(abspath $(srcdir)/..)
-
-include $(topsrcdir)/config/rules.mk
--- a/js/src/shell/Makefile.in
+++ b/js/src/shell/Makefile.in
@@ -1,20 +1,21 @@
 # -*- Mode: makefile -*-
 #
 # 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/.
 
-LIBS      += $(NSPR_LIBS) $(EDITLINE_LIBS) $(MOZ_ZLIB_LIBS)
+EXTRA_LIBS      += $(NSPR_LIBS)
+OS_LIBS += $(EDITLINE_LIBS) $(MOZ_ZLIB_LIBS)
 ifdef MOZ_NATIVE_FFI
-EXTRA_LIBS += $(MOZ_FFI_LIBS)
+OS_LIBS += $(MOZ_FFI_LIBS)
 endif
 ifdef MOZ_SHARED_ICU
-EXTRA_LIBS += $(MOZ_ICU_LIBS)
+OS_LIBS += $(MOZ_ICU_LIBS)
 endif
 
 ifeq ($(OS_ARCH),Darwin)
 ifeq ($(TARGET_CPU),x86_64)
 DARWIN_EXE_LDFLAGS += -pagezero_size 10000 -image_base 100000000
 endif
 endif
 
--- a/js/xpconnect/shell/Makefile.in
+++ b/js/xpconnect/shell/Makefile.in
@@ -1,12 +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/.
 
 SDK_BINARY	= $(PROGRAM)
 
-LIBS +=	$(NSPR_LIBS)
+EXTRA_LIBS +=	$(NSPR_LIBS)
 
 NSDISTMODE = copy
-
-include $(topsrcdir)/config/rules.mk
--- a/js/xpconnect/tests/Makefile.in
+++ b/js/xpconnect/tests/Makefile.in
@@ -1,8 +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/.
 
-LIBS += \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NULL)
--- a/js/xpconnect/tests/components/native/Makefile.in
+++ b/js/xpconnect/tests/components/native/Makefile.in
@@ -4,15 +4,15 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 componentdir = js/xpconnect/tests/components/native
 
 MANIFEST = xpctest.manifest
 MANIFEST_PATH = $(testxpcobjdir)/$(componentdir)
 PP_TARGETS += MANIFEST
 
-EXTRA_DSO_LDOPTS += \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NULL)
 
 LIB_FILES = $(SHARED_LIBRARY)
 LIB_DEST = $(testxpcobjdir)/$(componentdir)
 INSTALL_TARGETS += LIB
--- a/layout/media/Makefile.in
+++ b/layout/media/Makefile.in
@@ -1,15 +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 (WINNT,$(OS_TARGET))
-EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
+EXTRA_LIBS += $(NSPR_LIBS)
 OS_LIBS += $(call EXPAND_LIBNAME,usp10 ole32)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq (WINNT,$(OS_TARGET))
 symbols.def: symbols.def.in $(GLOBAL_DEPS)
 	$(call py_action,preprocessor,$(ACDEFINES) $< -o $@)
--- a/media/libcubeb/tests/Makefile.in
+++ b/media/libcubeb/tests/Makefile.in
@@ -1,15 +1,15 @@
 # -*- Mode: makefile; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- #
 # 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_TARGET),Darwin)
-  LIBS += -framework AudioUnit -framework CoreAudio
+  OS_LDFLAGS += -framework AudioUnit -framework CoreAudio
 else
   ifeq ($(OS_TARGET), OpenBSD)
-    LIBS += -lsndio
+    OS_LIBS += -lsndio
   else
-    LIBS += $(MOZ_ALSA_LIBS) \
+    OS_LIBS += $(MOZ_ALSA_LIBS) \
             $(MOZ_PULSEAUDIO_LIBS)
   endif
 endif
--- a/media/mtransport/test/Makefile.in
+++ b/media/mtransport/test/Makefile.in
@@ -1,29 +1,29 @@
 # -*- Mode: makefile; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- #
 # 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/.
 
-LIBS += \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NULL)
 
 ifdef MOZ_NATIVE_NSS
-LIBS += $(NSS_LIBS)
+EXTRA_LIBS += $(NSS_LIBS)
 else
 # Statically linking NSS libssl ensures that we can debug NSS too
-LIBS += \
+EXTRA_LIBS += \
   $(DEPTH)/dist/lib/$(LIB_PREFIX)ssl.$(LIB_SUFFIX) \
   $(DEPTH)/dist/lib/$(LIB_PREFIX)nss3.$(LIB_SUFFIX) \
   $(DEPTH)/dist/lib/$(LIB_PREFIX)nssutil3.$(LIB_SUFFIX) \
   $(NULL)
 endif
 
 ifeq ($(OS_TARGET), Android)
-LIBS += \
+EXTRA_LIBS += \
   $(STLPORT_LDFLAGS) \
   $(STLPORT_LIBS) \
   $(NULL)
 CPPFLAGS += \
   $(STLPORT_CPPFLAGS) \
   $(NULL)
 endif
--- a/media/webrtc/signaling/test/Makefile.in
+++ b/media/webrtc/signaling/test/Makefile.in
@@ -1,87 +1,89 @@
 # 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/. */
 
-LIBS += \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NSS_LIBS) \
+  $(NULL)
+
+OS_LIBS += \
   $(MOZ_WEBRTC_X11_LIBS) \
   $(REALTIME_LIBS) \
   $(NULL)
 
 ifdef MOZ_ALSA
-LIBS += \
+OS_LIBS += \
   $(MOZ_ALSA_LIBS) \
   $(NULL)
 endif
 
 ifeq ($(OS_TARGET),Android)
-LIBS += \
+EXTRA_LIBS += \
   $(STLPORT_LDFLAGS) \
   $(STLPORT_LIBS) \
   $(NULL)
 CPPFLAGS += \
   $(STLPORT_CPPFLAGS) \
   $(NULL)
 endif
 
 ifdef MOZ_NATIVE_JPEG
-LIBS += \
+OS_LIBS += \
   $(MOZ_JPEG_LIBS) \
   $(NULL)
 endif
 
 ifdef MOZ_NATIVE_LIBVPX
-LIBS += \
+OS_LIBS += \
   $(MOZ_LIBVPX_LIBS) \
   $(NULL)
 endif
 
 ifndef MOZ_TREE_PIXMAN
-LIBS += \
+OS_LIBS += \
   $(MOZ_PIXMAN_LIBS) \
   $(NULL)
 endif
 
 ifeq (gtk2,$(MOZ_WIDGET_TOOLKIT))
-LIBS += \
+OS_LIBS += \
   $(XLIBS) \
   $(MOZ_GTK2_LIBS) \
   -lgmodule-2.0 -lgthread-2.0 \
   $(NULL)
 endif
 
 ifeq (gtk3,$(MOZ_WIDGET_TOOLKIT))
-LIBS += \
+OS_LIBS += \
   $(MOZ_GTK3_LIBS) \
   $(FT2_LIBS) \
   $(NULL)
 endif
 
 ifeq (qt,$(MOZ_WIDGET_TOOLKIT))
-LIBS += \
+OS_LIBS += \
   $(XLIBS) \
   $(TK_LIBS) \
   $(MOZ_PANGO_LIBS) \
   $(NULL)
 endif
 
 ifneq (,$(filter Linux DragonFly FreeBSD NetBSD OpenBSD,$(OS_TARGET)))
-LIBS += \
+OS_LIBS += \
   $(MOZ_CAIRO_OSLIBS) \
   $(NULL)
 endif
 
 ifeq ($(OS_TARGET),Darwin)
-LIBS += \
+OS_LIBS += \
   $(TK_LIBS) \
   $(NULL)
 endif
 
 ifdef MOZ_NATIVE_ZLIB
-LIBS += $(MOZ_ZLIB_LIBS)
+OS_LIBS += $(MOZ_ZLIB_LIBS)
 endif
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/media/webrtc/webrtc-config.mk
-include $(topsrcdir)/config/rules.mk
--- a/modules/libmar/tool/Makefile.in
+++ b/modules/libmar/tool/Makefile.in
@@ -13,29 +13,29 @@ MOZ_GLUE_LDFLAGS =
 MOZ_GLUE_PROGRAM_LDFLAGS =
 
 HOST_CFLAGS += \
   -DNO_SIGN_VERIFY \
   $(DEFINES) \
   $(NULL)
 
 ifdef MOZ_ENABLE_SIGNMAR
-LIBS += \
+EXTRA_LIBS += \
   $(DIST)/lib/$(LIB_PREFIX)nss3.$(LIB_SUFFIX) \
   $(DIST)/lib/$(LIB_PREFIX)nssutil3.$(LIB_SUFFIX) \
   $(NSPR_LIBS) \
   $(NULL)
 endif
 
 ifeq ($(HOST_OS_ARCH),WINNT)
 HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME,ws2_32)
-EXTRA_LIBS += $(call EXPAND_LIBNAME,ws2_32)
+OS_LIBS += $(call EXPAND_LIBNAME,ws2_32)
 ifdef MOZ_ENABLE_SIGNMAR
-EXTRA_LIBS += $(call EXPAND_LIBNAME,crypt32)
-EXTRA_LIBS += $(call EXPAND_LIBNAME,advapi32)
+OS_LIBS += $(call EXPAND_LIBNAME,crypt32)
+OS_LIBS += $(call EXPAND_LIBNAME,advapi32)
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef CROSS_COMPILE
 ifdef HOST_NSPR_MDCPUCFG
 HOST_CFLAGS += -DMDCPUCFG=$(HOST_NSPR_MDCPUCFG)
--- a/mozglue/build/Makefile.in
+++ b/mozglue/build/Makefile.in
@@ -7,40 +7,40 @@ DIST_INSTALL = 1
 
 # For FORCE_SHARED_LIB
 include $(topsrcdir)/config/config.mk
 
 MOZ_GLUE_LDFLAGS = # Don't link against ourselves
 
 ifneq (,$(ZLIB_IN_MOZGLUE)$(MOZ_LINKER))
 ifdef MOZ_NATIVE_ZLIB
-EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
+EXTRA_LIBS += $(MOZ_ZLIB_LIBS)
 endif
 endif
 
 ifeq (WINNT,$(OS_TARGET))
 mozglue.def: mozglue.def.in
 	$(call py_action,preprocessor,$(if $(MOZ_REPLACE_MALLOC),-DMOZ_REPLACE_MALLOC) $(ACDEFINES) $< -o $@)
 
 GARBAGE += mozglue.def
 
 ifneq (,$(filter -DEFAULTLIB:mozcrt,$(MOZ_GLUE_LDFLAGS)))
 # Don't install the import library if we use mozcrt
 NO_INSTALL_IMPORT_LIBRARY = 1
 endif
 
 
-EXTRA_DSO_LDOPTS += \
+OS_LIBS += \
 	$(call EXPAND_LIBNAME,version) \
 	$(NULL)
 
 endif
 
 ifeq (Darwin_1,$(OS_TARGET)_$(MOZ_REPLACE_MALLOC))
-EXTRA_DSO_LDOPTS += \
+OS_LDFLAGS += \
   -Wl,-U,_replace_init \
   -Wl,-U,_replace_malloc \
   -Wl,-U,_replace_posix_memalign \
   -Wl,-U,_replace_aligned_alloc \
   -Wl,-U,_replace_calloc \
   -Wl,-U,_replace_realloc \
   -Wl,-U,_replace_free \
   -Wl,-U,_replace_memalign \
@@ -48,31 +48,31 @@ EXTRA_DSO_LDOPTS += \
   -Wl,-U,_replace_malloc_usable_size \
   -Wl,-U,_replace_malloc_good_size \
   -Wl,-U,_replace_jemalloc_stats \
   -Wl,-U,_replace_jemalloc_purge_freed_pages \
   -Wl,-U,_replace_jemalloc_free_dirty_pages \
   $(NULL)
 
 ifneq ($(MOZ_REPLACE_MALLOC_LINKAGE),compiler support)
-EXTRA_DSO_LDOPTS += -flat_namespace
+OS_LDFLAGS += -flat_namespace
 endif
 ifeq ($(MOZ_REPLACE_MALLOC_LINKAGE),dummy library)
-EXTRA_DSO_LDOPTS += -Wl,-weak_library,$(DEPTH)/memory/replace/dummy/$(DLL_PREFIX)replace_malloc$(DLL_SUFFIX)
+OS_LDFLAGS += -Wl,-weak_library,$(DEPTH)/memory/replace/dummy/$(DLL_PREFIX)replace_malloc$(DLL_SUFFIX)
 endif
 endif
 
 ifeq (android, $(MOZ_WIDGET_TOOLKIT))
 # To properly wrap jemalloc's pthread_atfork call.
-EXTRA_DSO_LDOPTS += -Wl,--wrap=pthread_atfork
+OS_LDFLAGS += -Wl,--wrap=pthread_atfork
 endif
 
 ifdef MOZ_LINKER
 ifeq (arm, $(TARGET_CPU))
-EXTRA_DSO_LDOPTS += -Wl,-version-script,$(srcdir)/arm-eabi-filter
+OS_LDFLAGS += -Wl,-version-script,$(srcdir)/arm-eabi-filter
 endif
 
 endif
 
 ifeq (Android, $(OS_TARGET))
 WRAP_LDFLAGS := $(filter -Wl%,$(WRAP_LDFLAGS))
 endif
 
--- a/mozglue/tests/Makefile.in
+++ b/mozglue/tests/Makefile.in
@@ -1,17 +1,17 @@
 # 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_LINKER
 # Only link against the linker, not mozglue
 MOZ_GLUE_PROGRAM_LDFLAGS =
 MOZ_GLUE_LDFLAGS =
-EXTRA_LIBS = $(MOZ_ZLIB_LIBS)
+OS_LIBS = $(MOZ_ZLIB_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_LINKER
 check::
 	@$(EXIT_ON_ERROR) ./TestZip$(BIN_SUFFIX) $(srcdir)
 endif
--- a/netwerk/streamconv/test/Makefile.in
+++ b/netwerk/streamconv/test/Makefile.in
@@ -1,10 +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/.
 
-LIBS		+= \
+EXTRA_LIBS		+= \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/netwerk/test/Makefile.in
+++ b/netwerk/test/Makefile.in
@@ -1,17 +1,17 @@
 # vim: noexpandtab ts=8 sw=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/.
 
 
 
-LIBS	+= \
+EXTRA_LIBS	+= \
 		  $(NSPR_LIBS) \
 		  $(NULL)
 
 DEFINES += $(TK_CFLAGS)
 
 include $(topsrcdir)/config/rules.mk
 
 check::
--- a/rdf/tests/rdfcat/Makefile.in
+++ b/rdf/tests/rdfcat/Makefile.in
@@ -1,12 +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/.
 
-LIBS		+= \
+EXTRA_LIBS	+= \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS += $(TK_CFLAGS)
--- a/rdf/tests/rdfpoll/Makefile.in
+++ b/rdf/tests/rdfpoll/Makefile.in
@@ -1,8 +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/.
 
-LIBS		+= \
+EXTRA_LIBS	+= \
 		$(NSPR_LIBS) \
 		$(NULL)
--- a/rdf/tests/triplescat/Makefile.in
+++ b/rdf/tests/triplescat/Makefile.in
@@ -1,12 +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/.
 
-LIBS		+= \
+EXTRA_LIBS	+= \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS += $(TK_CFLAGS)
--- a/security/build/Makefile.in
+++ b/security/build/Makefile.in
@@ -320,22 +320,22 @@ INSTALL_TARGETS += NSS_SDK_LIB
 ifdef MOZ_FOLD_LIBS
 ifeq (WINNT,$(OS_TARGET))
 SUFFIX = _s.$(LIB_SUFFIX)
 else
 SUFFIX = .$(LIB_SUFFIX)
 endif
 
 # Fold NSPR libs
-EXTRA_DSO_LDOPTS += $(DEPTH)/nsprpub/pr/src/$(LIB_PREFIX)nspr4$(SUFFIX)
-EXTRA_DSO_LDOPTS += $(DEPTH)/nsprpub/lib/ds/$(LIB_PREFIX)plds4$(SUFFIX)
-EXTRA_DSO_LDOPTS += $(DEPTH)/nsprpub/lib/libc/src/$(LIB_PREFIX)plc4$(SUFFIX)
+EXTRA_LIBS += $(DEPTH)/nsprpub/pr/src/$(LIB_PREFIX)nspr4$(SUFFIX)
+EXTRA_LIBS += $(DEPTH)/nsprpub/lib/ds/$(LIB_PREFIX)plds4$(SUFFIX)
+EXTRA_LIBS += $(DEPTH)/nsprpub/lib/libc/src/$(LIB_PREFIX)plc4$(SUFFIX)
 
 # Add all static libraries for nss, smime, ssl and nssutil
-SHARED_LIBRARY_LIBS += $(addprefix ../,$(NSS_STATIC_LIBS))
+EXTRA_LIBS += $(addprefix ../,$(NSS_STATIC_LIBS))
 
 nss_def_file := $(srcdir)/nss.def
 
 ifeq (WINNT,$(OS_TARGET))
 # Create a .def file based on the various .def files for nss, smime, ssl and
 # nssutil.
 nss3.def: $(nss_def_file) $(DEPTH)/db/sqlite3/src/sqlite-processed.def
 	echo LIBRARY nss3$(DLL_SUFFIX) > $@.tmp
@@ -363,17 +363,17 @@ endif # MOZ_FOLD_LIBS
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_FOLD_LIBS
 # Force the linker to include everything from the static libraries.
 EXPAND_LIBS_EXEC += --extract
 
 $(SHARED_LIBRARY): $(addprefix ../,$(NSS_STATIC_LIBS))
 
-EXTRA_DSO_LDOPTS += $(REALTIME_LIBS)
+OS_LIBS += $(REALTIME_LIBS)
 
 ifdef IMPORT_LIB_SUFFIX
 IMPORT_PREFIX = $(LIB_PREFIX)
 IMPORT_SUFFIX = .$(IMPORT_LIB_SUFFIX)
 else
 IMPORT_PREFIX = $(DLL_PREFIX)
 IMPORT_SUFFIX = $(DLL_SUFFIX)
 endif
--- a/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in
+++ b/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in
@@ -1,14 +1,14 @@
 # vim: noexpandtab ts=8 sw=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/.
 
 include $(topsrcdir)/config/config.mk
 
-LIBS += \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NSS_LIBS) \
   $(NULL)
 
 DEFINES += $(TK_CFLAGS)
--- a/security/sandbox/win/src/sandboxbroker/Makefile.in
+++ b/security/sandbox/win/src/sandboxbroker/Makefile.in
@@ -1,11 +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/.
 #
 MOZ_GLUE_LDFLAGS =
 
-SHARED_LIBRARY_LIBS += \
+EXTRA_LIBS += \
 	$(NSPR_LIBS) \
 	$(NULL)
 
 OS_LIBS += $(call EXPAND_LIBNAME,dbghelp)
--- a/startupcache/test/Makefile.in
+++ b/startupcache/test/Makefile.in
@@ -1,6 +1,6 @@
 #
 # 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/.
 
-LIBS += $(NSPR_LIBS)
+EXTRA_LIBS += $(NSPR_LIBS)
--- a/storage/test/Makefile.in
+++ b/storage/test/Makefile.in
@@ -1,9 +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/.
 
-LIBS += \
+EXTRA_LIBS += \
 	$(NSPR_LIBS) \
+	$(NULL)
+
+OS_LIBS += \
 	$(SQLITE_LIBS) \
 	$(NULL)
--- a/testing/mochitest/ssltunnel/Makefile.in
+++ b/testing/mochitest/ssltunnel/Makefile.in
@@ -1,9 +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/.
 
-LIBS = \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NSS_LIBS) \
   $(NULL)
--- a/toolkit/crashreporter/test/Makefile.in
+++ b/toolkit/crashreporter/test/Makefile.in
@@ -1,14 +1,14 @@
 #
 # 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_DSO_LDOPTS += $(NSPR_LIBS)
+EXTRA_LIBS += $(NSPR_LIBS)
 
 UNIT_FILES = $(SHARED_LIBRARY) $(EXTRA_JS_MODULES)
 UNIT_DEST = $(DEPTH)/_tests/xpcshell/$(relativesrcdir)/unit/
 INSTALL_TARGETS += UNIT
 
 UNIT_IPC_FILES = $(UNIT_FILES)
 UNIT_IPC_DEST = $(DEPTH)/_tests/xpcshell/$(relativesrcdir)/unit_ipc/
 INSTALL_TARGETS += UNIT_IPC
--- a/toolkit/library/libxul.mk
+++ b/toolkit/library/libxul.mk
@@ -13,93 +13,96 @@ endif #}
 
 ifdef MOZ_B2G_CAMERA #{
 OS_LIBS += -lstagefright -lstagefright_omx
 endif #}
 
 ifeq (Linux,$(OS_ARCH))
 ifneq (Android,$(OS_TARGET))
 OS_LIBS += -lrt
-EXTRA_DSO_LDOPTS += -Wl,-version-script,symverscript
+OS_LDFLAGS += -Wl,-version-script,symverscript
 
 symverscript: $(topsrcdir)/toolkit/library/symverscript.in
 	$(call py_action,preprocessor, \
 		-DVERSION='xul$(MOZILLA_SYMBOLVERSION)' $< -o $@)
 
 EXTRA_DEPS += symverscript
 endif
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 OS_LIBS += -lcups
 endif
 
-EXTRA_DSO_LDOPTS += \
+EXTRA_LIBS += \
   $(NSS_LIBS) \
+  $(NULL)
+
+OS_LIBS += \
   $(MOZ_CAIRO_OSLIBS) \
   $(MOZ_WEBRTC_X11_LIBS) \
   $(MOZ_APP_EXTRA_LIBS) \
   $(SQLITE_LIBS) \
   $(NULL)
 
 ifdef ENABLE_INTL_API
 ifneq (,$(JS_SHARED_LIBRARY)$(MOZ_NATIVE_ICU))
-EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS)
+OS_LIBS += $(MOZ_ICU_LIBS)
 endif
 endif
 
 ifdef MOZ_NATIVE_FFI
-EXTRA_DSO_LDOPTS += $(MOZ_FFI_LIBS)
+OS_LIBS += $(MOZ_FFI_LIBS)
 endif
 
 ifdef MOZ_NATIVE_JPEG
-EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
+OS_LIBS += $(MOZ_JPEG_LIBS)
 endif
 
 ifdef MOZ_NATIVE_PNG
-EXTRA_DSO_LDOPTS += $(MOZ_PNG_LIBS)
+OS_LIBS += $(MOZ_PNG_LIBS)
 endif
 
 ifdef MOZ_NATIVE_ZLIB
-EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
+OS_LIBS += $(MOZ_ZLIB_LIBS)
 endif
 
 ifdef MOZ_NATIVE_HUNSPELL
-EXTRA_DSO_LDOPTS += $(MOZ_HUNSPELL_LIBS)
+OS_LIBS += $(MOZ_HUNSPELL_LIBS)
 endif
 
 ifdef MOZ_NATIVE_LIBEVENT
-EXTRA_DSO_LDOPTS += $(MOZ_LIBEVENT_LIBS)
+OS_LIBS += $(MOZ_LIBEVENT_LIBS)
 endif
 
 ifdef MOZ_NATIVE_LIBVPX
-EXTRA_DSO_LDOPTS += $(MOZ_LIBVPX_LIBS)
+OS_LIBS += $(MOZ_LIBVPX_LIBS)
 endif
 
 ifndef MOZ_TREE_PIXMAN
-EXTRA_DSO_LDOPTS += $(MOZ_PIXMAN_LIBS)
+OS_LIBS += $(MOZ_PIXMAN_LIBS)
 endif
 
 ifdef MOZ_WEBRTC
 ifeq (WINNT,$(OS_TARGET))
 ifndef MOZ_HAS_WINSDK_WITH_D3D
-EXTRA_DSO_LDOPTS += \
+OS_LDFLAGS += \
   -LIBPATH:'$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_D3D_CPU_SUFFIX)' \
   $(NULL)
 endif
 OS_LIBS += $(call EXPAND_LIBNAME,secur32 crypt32 iphlpapi strmiids dmoguids wmcodecdspuuid amstrmid msdmo wininet)
 endif
 endif
 
 ifdef MOZ_ALSA
-EXTRA_DSO_LDOPTS += $(MOZ_ALSA_LIBS)
+OS_LIBS += $(MOZ_ALSA_LIBS)
 endif
 
 ifdef HAVE_CLOCK_MONOTONIC
-EXTRA_DSO_LDOPTS += $(REALTIME_LIBS)
+OS_LIBS += $(REALTIME_LIBS)
 endif
 
 ifeq (android,$(MOZ_WIDGET_TOOLKIT))
 OS_LIBS += -lGLESv2
 endif
 
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
 OS_LIBS += \
@@ -128,66 +131,66 @@ endif
 ifdef MOZ_WMF
 OS_LIBS += $(call EXPAND_LIBNAME,mfuuid wmcodecdspuuid strmiids)
 endif
 
 ifdef MOZ_DIRECTSHOW
 OS_LIBS += $(call EXPAND_LIBNAME,dmoguids wmcodecdspuuid strmiids msdmo)
 endif
 
-EXTRA_DSO_LDOPTS += $(ICONV_LIBS)
+OS_LIBS += $(ICONV_LIBS)
 
-EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
+EXTRA_LIBS += $(NSPR_LIBS)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 OS_LIBS += \
   $(TK_LIBS) \
   $(NULL)
 endif
 
 ifeq (OpenBSD,$(OS_ARCH))
-EXTRA_DSO_LDOPTS += -lsndio
+OS_LIBS += -lsndio
 endif
 
 ifdef MOZ_ENABLE_DBUS
-EXTRA_DSO_LDOPTS += $(MOZ_DBUS_GLIB_LIBS)
+OS_LIBS += $(MOZ_DBUS_GLIB_LIBS)
 endif
 
 ifdef MOZ_WIDGET_GTK
 ifdef MOZ_ENABLE_GTK3
-EXTRA_DSO_LDOPTS += $(filter-out -lgtk-3 -lgdk-3,$(TK_LIBS))
+OS_LIBS += $(filter-out -lgtk-3 -lgdk-3,$(TK_LIBS))
 else
-EXTRA_DSO_LDOPTS += $(TK_LIBS)
+OS_LIBS += $(TK_LIBS)
 endif
-EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS) $(XCOMPOSITE_LIBS) $(MOZ_PANGO_LIBS) $(XT_LIBS) -lgthread-2.0
-EXTRA_DSO_LDOPTS += $(FT2_LIBS)
+OS_LIBS += $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS) $(XCOMPOSITE_LIBS) $(MOZ_PANGO_LIBS) $(XT_LIBS) -lgthread-2.0
+OS_LIBS += $(FT2_LIBS)
 endif
 
 ifeq (qt,$(MOZ_WIDGET_TOOLKIT))
-EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(XT_LIBS) $(MOZ_QT_LIBS)
-EXTRA_DSO_LDOPTS += $(FT2_LIBS) $(MOZ_PANGO_LIBS)
+OS_LIBS += $(XLDFLAGS) $(XLIBS) $(XT_LIBS) $(MOZ_QT_LIBS)
+OS_LIBS += $(FT2_LIBS) $(MOZ_PANGO_LIBS)
 endif
 
 ifdef MOZ_TREE_FREETYPE
-EXTRA_DSO_LDOPTS += $(FT2_LIBS)
+OS_LIBS += $(FT2_LIBS)
 endif
 
 ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
-EXTRA_DSO_LDOPTS += $(MOZ_STARTUP_NOTIFICATION_LIBS)
+OS_LIBS += $(MOZ_STARTUP_NOTIFICATION_LIBS)
 endif
 
 ifdef MOZ_ENABLE_LIBPROXY
-EXTRA_DSO_LDOPTS += $(MOZ_LIBPROXY_LIBS)
+OS_LIBS += $(MOZ_LIBPROXY_LIBS)
 endif
 
 ifeq ($(OS_ARCH),SunOS)
 ifdef GNU_CC
-EXTRA_DSO_LDOPTS += -lelf
+OS_LIBS += -lelf
 else
-EXTRA_DSO_LDOPTS += -lelf -ldemangle
+OS_LIBS += -lelf -ldemangle
 endif
 endif
 
 ifeq ($(OS_ARCH),FreeBSD)
 OS_LIBS += $(call EXPAND_LIBNAME,util)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
@@ -196,22 +199,22 @@ ifdef ACCESSIBILITY
 OS_LIBS += $(call EXPAND_LIBNAME,oleacc)
 endif
 ifdef MOZ_METRO
 OS_LIBS += $(call EXPAND_LIBNAME,uiautomationcore runtimeobject)
 endif
 endif # WINNT
 
 ifdef MOZ_ENABLE_QT
-EXTRA_DSO_LDOPTS += $(MOZ_QT_LDFLAGS) $(XEXT_LIBS)
+LIBS += $(MOZ_QT_LDFLAGS) $(XEXT_LIBS)
 endif
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 ifdef MOZ_GSTREAMER
-EXTRA_DSO_LDOPTS += $(GSTREAMER_LIBS)
+LIBS += $(GSTREAMER_LIBS)
 endif
 endif
 
 # Generate GDB pretty printer-autoload files only on Linux. OSX's GDB is
 # too old to support Python pretty-printers; if this changes, we could make
 # this 'ifdef GNU_CC'.
 ifeq (Linux,$(OS_ARCH))
 # Create a GDB Python auto-load file alongside the libxul shared library in
@@ -230,17 +233,17 @@ endif
 # BFD ld doesn't create multiple PT_LOADs as usual when an unknown section
 # exists. Using an implicit linker script to make it fold that section in
 # .data.rel.ro makes it create multiple PT_LOADs. That implicit linker
 # script however makes gold misbehave, first because it doesn't like that
 # the linker script is given after crtbegin.o, and even past that, replaces
 # the default section rules with those from the script instead of
 # supplementing them. Which leads to a lib with a huge load of sections.
 ifdef LD_IS_BFD
-EXTRA_DSO_LDOPTS += $(topsrcdir)/toolkit/library/StaticXULComponents.ld
+OS_LDFLAGS += $(topsrcdir)/toolkit/library/StaticXULComponents.ld
 endif
 
 ifeq (WINNT,$(OS_TARGET))
 get_first_and_last = dumpbin -exports $1 | grep _NSModule@@ | sort -k 3 | sed -n 's/^.*?\([^@]*\)@@.*$$/\1/;1p;$$p'
 else
 get_first_and_last = $(TOOLCHAIN_PREFIX)nm -g $1 | grep _NSModule$$ | sort | sed -n 's/^.* _*\([^ ]*\)$$/\1/;1p;$$p'
 endif
 
--- a/toolkit/mozapps/update/updater/Makefile.in
+++ b/toolkit/mozapps/update/updater/Makefile.in
@@ -3,17 +3,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/.
 
 # Don't link the updater against libmozglue. See bug 687139
 MOZ_GLUE_LDFLAGS =
 MOZ_GLUE_PROGRAM_LDFLAGS =
 
 ifdef MOZ_NATIVE_BZ2
-LIBS += \
+OS_LIBS += \
   $(MOZ_BZ2_LIBS) \
   $(NULL)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 ws2_32 shell32 shlwapi)
 endif
 
@@ -51,13 +51,13 @@ libs::
 	sed -e 's/%APP_NAME%/$(MOZ_APP_DISPLAYNAME)/' $(srcdir)/macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \
 	  iconv -f UTF-8 -t UTF-16 > $(DIST)/bin/updater.app/Contents/Resources/English.lproj/InfoPlist.strings
 	$(NSINSTALL) -D $(DIST)/bin/updater.app/Contents/MacOS
 	$(NSINSTALL) $(DIST)/bin/updater $(DIST)/bin/updater.app/Contents/MacOS
 	rm -f $(DIST)/bin/updater
 endif
 
 ifeq ($(OS_ARCH),WINNT)
-EXTRA_LIBS += $(call EXPAND_LIBNAME,crypt32)
-EXTRA_LIBS += $(call EXPAND_LIBNAME,advapi32)
+OS_LIBS += $(call EXPAND_LIBNAME,crypt32)
+OS_LIBS += $(call EXPAND_LIBNAME,advapi32)
 endif
 
 CXXFLAGS += $(MOZ_BZ2_CFLAGS)
--- a/toolkit/system/dbus/Makefile.in
+++ b/toolkit/system/dbus/Makefile.in
@@ -1,12 +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/.
 
-EXTRA_DSO_LDOPTS += \
+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/gnome/Makefile.in
+++ b/toolkit/system/gnome/Makefile.in
@@ -1,14 +1,17 @@
 # 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_DSO_LDOPTS += \
+EXTRA_LIBS += \
 		$(NSPR_LIBS) \
+        $(NULL)
+
+OS_LIBS += \
 		$(MOZ_GCONF_LIBS) \
 		$(MOZ_GNOMEVFS_LIBS) \
 		$(GLIB_LIBS) \
 		$(MOZ_GIO_LIBS) \
 		$(MOZ_DBUS_GLIB_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/tools/trace-malloc/Makefile.in
+++ b/tools/trace-malloc/Makefile.in
@@ -16,33 +16,33 @@ PROGCSRCS = \
 
 PROGOBJS = $(PROGCSRCS:.c=.$(OBJ_SUFFIX))
 endif
 
 CPPSRCS += $(EXTRACPPSRCS)
 
 include $(topsrcdir)/config/config.mk
 
-LIBS		+= \
+EXTRA_LIBS	+= \
 		tmreader.$(OBJ_SUFFIX) \
 		adreader.$(OBJ_SUFFIX) \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 ifdef HAVE_BOUTELL_GD
 ifeq ($(OS_ARCH),WINNT)
 LOCAL_INCLUDES	+= \
 		-I'$(HAVE_BOUTELL_GD)' \
 		$(NULL)
-LIBS		+= \
+OS_LIBS		+= \
 		-lmozz_s \
 		'$(HAVE_BOUTELL_GD)/gd.lib' \
 		$(NULL)
 else
-LIBS		+= \
+OS_LIBS		+= \
 		-lgd \
 		$(NULL)
 endif
 
 DEFINES		+= \
 		-DHAVE_BOUTELL_GD \
 		$(NULL)
 endif
--- a/uriloader/exthandler/tests/Makefile.in
+++ b/uriloader/exthandler/tests/Makefile.in
@@ -1,13 +1,13 @@
 # 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/.
 
-LIBS +=		\
+EXTRA_LIBS +=		\
 		$(NSPR_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_WIDGET_GTK
 export PERSONAL_MAILCAP=$(abspath $(srcdir))/mailcap
 endif
--- a/webapprt/gtk/Makefile.in
+++ b/webapprt/gtk/Makefile.in
@@ -1,13 +1,13 @@
 # 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/.
 
-LIBS += \
+OS_LIBS += \
   $(TK_LIBS) \
   $(NULL)
 
 NSDISTMODE = copy
 
 PROGRAMS_DEST = $(DIST)/bin
 
 include $(topsrcdir)/config/rules.mk
--- a/widget/gtk/mozgtk/gtk2/Makefile.in
+++ b/widget/gtk/mozgtk/gtk2/Makefile.in
@@ -10,9 +10,9 @@ include $(topsrcdir)/config/rules.mk
 # because no symbols are used from them. But those dependencies need to be
 # kept for things to work properly.
 ifeq (,$(filter -Wl,--as-needed),$(LDFLAGS))
 no_as_needed = $1
 else
 no_as_needed = -Wl,--no-as-needed $1 -Wl,--as-needed
 endif
 
-EXTRA_DSO_LDOPTS += $(filter -L%,$(MOZ_GTK2_LIBS)) $(call no_as_needed,-lgtk-x11-2.0 -lgdk-x11-2.0)
+OS_LIBS += $(filter -L%,$(MOZ_GTK2_LIBS)) $(call no_as_needed,-lgtk-x11-2.0 -lgdk-x11-2.0)
--- a/widget/gtk/mozgtk/gtk3/Makefile.in
+++ b/widget/gtk/mozgtk/gtk3/Makefile.in
@@ -9,9 +9,9 @@ include $(topsrcdir)/config/rules.mk
 # because no symbols are used from them. But those dependencies need to be
 # kept for things to work properly.
 ifeq (,$(filter -Wl,--as-needed),$(LDFLAGS))
 no_as_needed = $1
 else
 no_as_needed = -Wl,--no-as-needed $1 -Wl,--as-needed
 endif
 
-EXTRA_DSO_LDOPTS += $(filter -L%,$(MOZ_GTK3_LIBS)) $(call no_as_needed,-lgtk-3 -lgdk-3)
+OS_LIBS += $(filter -L%,$(MOZ_GTK3_LIBS)) $(call no_as_needed,-lgtk-3 -lgdk-3)
--- a/widget/xremoteclient/Makefile.in
+++ b/widget/xremoteclient/Makefile.in
@@ -18,11 +18,16 @@ PROGCPPSRCS = \
 
 PROGOBJS = $(PROGCPPSRCS:.cpp=.$(OBJ_SUFFIX))
 
 CPPSRCS += \
   $(filter-out $(LIBCPPSRCS),$(PROGCPPSRCS)) \
   $(LIBCPPSRCS) \
   $(NULL)
 
-LIBS            = \
-		$(NSPR_LIBS) \
-		$(XLDFLAGS) $(XLIBS)
+EXTRA_LIBS += \
+	$(NSPR_LIBS) \
+	$(NULL)
+
+OS_LIBS += \
+	$(XLDFLAGS) \
+	$(XLIBS) \
+	$(NULL)
--- a/xpcom/reflect/xptcall/tests/Makefile.in
+++ b/xpcom/reflect/xptcall/tests/Makefile.in
@@ -1,8 +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/.
 
-LIBS		+= \
+EXTRA_LIBS		+= \
 		$(NSPR_LIBS) \
 		$(NULL)
--- a/xpcom/reflect/xptinfo/tests/Makefile.in
+++ b/xpcom/reflect/xptinfo/tests/Makefile.in
@@ -1,8 +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/.
 
-LIBS		+= \
+EXTRA_LIBS		+= \
 		$(NSPR_LIBS) \
 		$(NULL)
--- a/xpcom/sample/Makefile.in
+++ b/xpcom/sample/Makefile.in
@@ -1,18 +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/.
 
-# EXTRA_DSO_LDOPTS specifies linker flags when building a shared library
-# from this Makefile. We link against the "dependent glue" and against the
-# frozen XPCOM shared library.
-EXTRA_DSO_LDOPTS += \
+EXTRA_LIBS += \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 # Need to link with CoreFoundation on Mac
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-EXTRA_DSO_LDOPTS += \
+OS_LIBS += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
--- a/xpcom/sample/program/Makefile.in
+++ b/xpcom/sample/program/Makefile.in
@@ -1,11 +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/.
 
 # Need to link with CoreFoundation on Mac
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-LIBS            += \
+OS_LIBS            += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
--- a/xpcom/tests/bug656331_component/Makefile.in
+++ b/xpcom/tests/bug656331_component/Makefile.in
@@ -6,22 +6,22 @@
 # Blatantly copied from xpcom/tests/component.
 
 unittestlocation = xpcom/tests/unit
 
 MANIFEST = bug656331.manifest
 MANIFEST_PATH = $(testxpcobjdir)/$(unittestlocation)
 PP_TARGETS += MANIFEST
 
-EXTRA_DSO_LDOPTS += \
+EXTRA_LIBS += \
   $(NSPR_LIBS) \
   $(NULL)
 
 # Need to link with CoreFoundation on Mac
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-EXTRA_DSO_LDOPTS += \
+OS_LIBS += \
   $(TK_LIBS) \
   $(NULL)
 endif
 
 LIB_FILES = $(SHARED_LIBRARY)
 LIB_DEST = $(testxpcobjdir)/$(unittestlocation)
 INSTALL_TARGETS += LIB
--- a/xpcom/tests/component/Makefile.in
+++ b/xpcom/tests/component/Makefile.in
@@ -4,22 +4,22 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 unittestlocation = xpcom/tests/unit
 
 MANIFEST = testcomponent.manifest
 MANIFEST_PATH = $(testxpcobjdir)/$(unittestlocation)
 PP_TARGETS += MANIFEST
 
-EXTRA_DSO_LDOPTS += \
+EXTRA_LIBS += \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 # Need to link with CoreFoundation on Mac
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-EXTRA_DSO_LDOPTS += \
+OS_LIBS += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
 
 LIB_FILES = $(SHARED_LIBRARY)
 LIB_DEST = $(testxpcobjdir)/$(unittestlocation)
 INSTALL_TARGETS += LIB
--- a/xpcom/tests/component_no_aslr/Makefile.in
+++ b/xpcom/tests/component_no_aslr/Makefile.in
@@ -4,23 +4,23 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 unittestlocation = xpcom/tests/unit
 
 MANIFEST = testcompnoaslr.manifest
 MANIFEST_PATH = $(testxpcobjdir)/$(unittestlocation)
 PP_TARGETS += MANIFEST
 
-EXTRA_DSO_LDOPTS = \
+EXTRA_LIBS += \
 		$(NSPR_LIBS) \
 		$(NULL)
 
 # Need to link with CoreFoundation on Mac
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-EXTRA_DSO_LDOPTS += \
+OS_LIBS += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
 
 LIB_FILES = $(SHARED_LIBRARY)
 LIB_DEST = $(testxpcobjdir)/$(unittestlocation)
 INSTALL_TARGETS += LIB
 
--- a/xpcom/tests/external/Makefile.in
+++ b/xpcom/tests/external/Makefile.in
@@ -1,9 +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
-
-LIBS += \
+EXTRA_LIBS += \
 	$(NSPR_LIBS) \
 	$(NULL)
--- a/xulrunner/examples/simple/components/src/Makefile.in
+++ b/xulrunner/examples/simple/components/src/Makefile.in
@@ -1,8 +1,8 @@
 # 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/.
 
-EXTRA_DSO_LDOPTS += \
+EXTRA_LIBS += \
 	$(NSPR_LIBS) \
 	$(NULL)
--- a/xulrunner/stub/Makefile.in
+++ b/xulrunner/stub/Makefile.in
@@ -2,28 +2,24 @@
 # 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/.
 
 # Don't create a dependency on mozglue
 MOZ_GLUE_LDFLAGS =
 
 # Need to link with CoreFoundation on Mac
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-LIBS            += \
+OS_LIBS            += \
 		$(TK_LIBS) \
 		$(NULL)
 endif
 
 ifndef MOZ_WINCONSOLE
 ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
 endif
 endif
 
-include $(topsrcdir)/config/config.mk
-
-include $(topsrcdir)/config/rules.mk
-
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,shell32)
 endif