Merge the last PGO-green inbound changeset to m-c.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 27 Aug 2012 22:11:26 -0400
changeset 105643 8af2ff9c601856448aa399f743fbfec8e1a9334d
parent 105601 ee5484eb9f4a8449f6d53abe9cfe4331e481c3bf (current diff)
parent 105642 a7f0beb4637490aef47f653e429b4fe653829cde (diff)
child 105670 09ecfa4faa7612a4b8950083bc8a03d90521ccab
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
milestone18.0a1
Merge the last PGO-green inbound changeset to m-c.
b2g/confvars.sh
build/unix/build-clang/create-manifest.py
config/makedep.cpp
config/makedep.exe
config/mkdepend/Makefile.in
config/mkdepend/cppsetup.c
config/mkdepend/def.h
config/mkdepend/ifparser.c
config/mkdepend/ifparser.h
config/mkdepend/imakemdep.h
config/mkdepend/include.c
config/mkdepend/main.c
config/mkdepend/mkdepend.man
config/mkdepend/parse.c
config/mkdepend/pr.c
js/src/config/mkdepend/Makefile.in
js/src/config/mkdepend/cppsetup.c
js/src/config/mkdepend/def.h
js/src/config/mkdepend/ifparser.c
js/src/config/mkdepend/ifparser.h
js/src/config/mkdepend/imakemdep.h
js/src/config/mkdepend/include.c
js/src/config/mkdepend/main.c
js/src/config/mkdepend/mkdepend.man
js/src/config/mkdepend/parse.c
js/src/config/mkdepend/pr.c
layout/base/FrameLayerBuilder.cpp
layout/base/FrameLayerBuilder.h
--- a/allmakefiles.sh
+++ b/allmakefiles.sh
@@ -102,22 +102,16 @@ if [ "$OS_ARCH" != "WINNT" -a "$OS_ARCH"
   fi
   if [ "$USE_ELF_HACK" ]; then
     add_makefiles "
       build/unix/elfhack/Makefile
     "
   fi
 fi
 
-if [ "$COMPILER_DEPEND" = "" -a "$MOZ_NATIVE_MAKEDEPEND" = "" ]; then
-  add_makefiles "
-    config/mkdepend/Makefile
-  "
-fi
-
 if [ "$ENABLE_MARIONETTE" ]; then
   add_makefiles "
     testing/marionette/Makefile
     testing/marionette/components/Makefile
   "
 fi
 
 if [ "$ENABLE_TESTS" ]; then
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -439,16 +439,17 @@ pref("marionette.defaultPrefs.port", 282
 #endif
 
 #ifdef MOZ_UPDATER
 pref("app.update.enabled", true);
 pref("app.update.auto", true);
 pref("app.update.silent", true);
 pref("app.update.mode", 0);
 pref("app.update.incompatible.mode", 0);
+pref("app.update.stage.enabled", true);
 pref("app.update.service.enabled", true);
 
 // The URL hosting the update manifest.
 pref("app.update.url", "http://update.boot2gecko.org/m2.5/updates.xml");
 // Interval at which update manifest is fetched.  In units of seconds.
 pref("app.update.interval", 3600); // 1 hour
 // First interval to elapse before checking for update.  In units of
 // milliseconds.  Capped at 10 seconds.
--- a/b2g/components/DirectoryProvider.js
+++ b/b2g/components/DirectoryProvider.js
@@ -17,17 +17,18 @@ function DirectoryProvider() {
 
 DirectoryProvider.prototype = {
   classID: Components.ID("{9181eb7c-6f87-11e1-90b1-4f59d80dd2e5}"),
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider]),
 
   getFile: function dp_getFile(prop, persistent) {
 #ifdef MOZ_WIDGET_GONK
-    let localProps = ["cachePDir", "webappsDir", "PrefD", "indexedDBPDir", "permissionDBPDir"];
+    let localProps = ["cachePDir", "webappsDir", "PrefD", "indexedDBPDir",
+      "permissionDBPDir", "UpdRootD"];
     if (localProps.indexOf(prop) != -1) {
       prop.persistent = true;
       let file = Cc["@mozilla.org/file/local;1"]
                    .createInstance(Ci.nsILocalFile)
       file.initWithPath(LOCAL_DIR);
       return file;
     }
 #endif
--- a/b2g/components/UpdatePrompt.js
+++ b/b2g/components/UpdatePrompt.js
@@ -74,16 +74,16 @@ UpdatePrompt.prototype = {
     this._selfDestructTimer = timer;
 #endif
   },
 
   showUpdateInstalled: function UP_showUpdateInstalled() { },
 
   showUpdateError: function UP_showUpdateError(aUpdate) {
     if (aUpdate.state == "failed") {
-      log("Failed to download update");
+      log("Failed to download update, errorCode: " + aUpdate.errorCode);
     }
   },
 
   showUpdateHistory: function UP_showUpdateHistory(aParent) { },
 };
 
 const NSGetFactory = XPCOMUtils.generateNSGetFactory([UpdatePrompt]);
--- a/b2g/confvars.sh
+++ b/b2g/confvars.sh
@@ -33,8 +33,9 @@ else
 MOZ_XULRUNNER=
 MOZ_PLACES=1
 fi
 
 MOZ_APP_ID={3c2e2abc-06d4-11e1-ac3b-374f68613e61}
 MOZ_EXTENSION_MANAGER=1
 
 MOZ_SYS_MSG=1
+MOZ_TOOLKIT_SEARCH=
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -339,18 +339,16 @@
 @BINPATH@/components/nsBrowserContentHandler.js
 @BINPATH@/components/nsBrowserGlue.js
 @BINPATH@/components/nsSetDefaultBrowser.manifest
 @BINPATH@/components/nsSetDefaultBrowser.js
 @BINPATH@/components/BrowserPlaces.manifest
 @BINPATH@/components/nsPrivateBrowsingService.manifest
 @BINPATH@/components/nsPrivateBrowsingService.js
 @BINPATH@/components/toolkitsearch.manifest
-@BINPATH@/components/nsSearchService.js
-@BINPATH@/components/nsSearchSuggestions.js
 @BINPATH@/components/nsTryToClose.manifest
 @BINPATH@/components/nsTryToClose.js
 @BINPATH@/components/passwordmgr.manifest
 @BINPATH@/components/nsLoginInfo.js
 @BINPATH@/components/nsLoginManager.js
 @BINPATH@/components/nsLoginManagerPrompter.js
 @BINPATH@/components/storage-Legacy.js
 @BINPATH@/components/storage-mozStorage.js
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -435,24 +435,16 @@ var gMainPane = {
           return this._folderToIndex(currentDirPref.value);
         }
         return 0;
       break;
     }
   },
 
   /**
-   * Displays the Add-ons Manager.
-   */
-  showAddonsMgr: function ()
-  {
-    openUILinkIn("about:addons", "tab");
-  },
-
-  /**
    * Hide/show the "Show my windows and tabs from last time" option based
    * on the value of the browser.privatebrowsing.autostart pref.
    */
   updateBrowserStartupLastSession: function()
   {
     let pbAutoStartPref = document.getElementById("browser.privatebrowsing.autostart");
     let startupPref = document.getElementById("browser.startup.page");
     let menu = document.getElementById("browserStartupPage");
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -161,27 +161,8 @@
               onsynctopreference="return gMainPane.getFolderListPref();"/>
     </hbox>
     <radio id="alwaysAsk"
            value="false"
            label="&alwaysAsk.label;"
            accesskey="&alwaysAsk.accesskey;"/>
   </radiogroup>
 </groupbox>
-
-<hbox class="bottomBox" data-category="paneGeneral" hidden="true">
-  <groupbox id="addonsMgrGroup"
-            orient="horizontal"
-            flex="1">
-    <caption label="&addonsMgr.label;"/>
-
-    <description control="manageAddons"
-#ifdef XP_WIN
-                 flex="1">&manageAddonsDescWin.label;</description>
-#else
-                 flex="1">&manageAddonsDescUnix2.label;</description>
-#endif
-    <button id="manageAddons"
-            label="&manageAddons.label;"
-            accesskey="&manageAddons.accesskey;"
-            oncommand="gMainPane.showAddonsMgr();"/>
-  </groupbox>
-</hbox>
--- a/browser/components/preferences/main.js
+++ b/browser/components/preferences/main.js
@@ -432,24 +432,16 @@ var gMainPane = {
           return this._folderToIndex(currentDirPref.value);
         }
         return 0;
       break;
     }
   },
 
   /**
-   * Displays the Add-ons Manager.
-   */
-  showAddonsMgr: function ()
-  {
-    openUILinkIn("about:addons", "window");
-  },
-
-  /**
    * Hide/show the "Show my windows and tabs from last time" option based
    * on the value of the browser.privatebrowsing.autostart pref.
    */
   updateBrowserStartupLastSession: function()
   {
     let pbAutoStartPref = document.getElementById("browser.privatebrowsing.autostart");
     let startupPref = document.getElementById("browser.startup.page");
     let menu = document.getElementById("browserStartupPage");
--- a/browser/components/preferences/main.xul
+++ b/browser/components/preferences/main.xul
@@ -153,27 +153,11 @@
                   onsynctopreference="return gMainPane.getFolderListPref();"/>
         </hbox>
         <radio id="alwaysAsk" value="false"
                label="&alwaysAsk.label;"
                accesskey="&alwaysAsk.accesskey;"/>
       </radiogroup>
     </groupbox>
 
-    <hbox class="bottomBox">
-      <groupbox id="addonsMgrGroup" orient="horizontal" flex="1">
-        <caption label="&addonsMgr.label;"/>
-
-        <description control="manageAddons"
-#ifdef XP_WIN
-                     flex="1">&manageAddonsDescWin.label;</description>
-#else
-                     flex="1">&manageAddonsDescUnix2.label;</description>
-#endif
-        <button id="manageAddons" label="&manageAddons.label;"
-                accesskey="&manageAddons.accesskey;"
-                oncommand="gMainPane.showAddonsMgr();"/>
-      </groupbox>
-    </hbox>
-
   </prefpane>
 
 </overlay>
--- a/browser/locales/en-US/chrome/browser/preferences/main.dtd
+++ b/browser/locales/en-US/chrome/browser/preferences/main.dtd
@@ -29,14 +29,8 @@
 <!ENTITY saveTo.label "Save files to">
 <!ENTITY saveTo.accesskey "v">
 <!ENTITY chooseFolderWin.label        "Browse…">
 <!ENTITY chooseFolderWin.accesskey    "o">
 <!ENTITY chooseFolderMac.label        "Choose…">
 <!ENTITY chooseFolderMac.accesskey    "e">
 <!ENTITY alwaysAsk.label "Always ask me where to save files">
 <!ENTITY alwaysAsk.accesskey "A">
-
-<!ENTITY addonsMgr.label               "Add-ons">
-<!ENTITY manageAddonsDescWin.label     "Change options for your add-ons">
-<!ENTITY manageAddonsDescUnix2.label   "Change preferences for your add-ons">
-<!ENTITY manageAddons.label            "Manage Add-ons…">
-<!ENTITY manageAddons.accesskey        "M">
--- a/build/macosx/common
+++ b/build/macosx/common
@@ -1,17 +1,12 @@
 if [ -d "$topsrcdir/clang" ]; then
     # mozilla-central based build
     export CC=$topsrcdir/clang/bin/clang
     export CXX=$topsrcdir/clang/bin/clang++
 elif [ -d "$topsrcdir/../clang" ]; then
     # comm-central based build
     export CC=$topsrcdir/../clang/bin/clang
     export CXX=$topsrcdir/../clang/bin/clang++
-else
-    # SeaMonkey does not have clang installed so need
-    # to set CC and CXX here.
-    export CC=/usr/bin/gcc-4.2
-    export CXX=/usr/bin/g++-4.2
 fi
 
 ac_add_options --enable-stdcxx-compat
 ac_add_options --with-ccache
--- a/build/mobile/robocop/PaintedSurface.java.in
+++ b/build/mobile/robocop/PaintedSurface.java.in
@@ -7,32 +7,33 @@ package @ANDROID_PACKAGE_NAME@;
 
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileInputStream;
 import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
 
 public class PaintedSurface {
-    private String mFileName = null;
-    private int mWidth = -1;
-    private int mHeight = -1;
-    private MappedByteBuffer mPixelBuffer = null;
+    private String mFileName;
+    private int mWidth;
+    private int mHeight;
+    private FileInputStream mPixelFile;
+    private MappedByteBuffer mPixelBuffer;
 
     public PaintedSurface(String filename, int width, int height) {
         mFileName = filename;
         mWidth = width;
         mHeight = height;
-        
+
         try {
             File f = new File(filename);
             int pixelSize = (int)f.length();
-            
-            FileInputStream pixelFile = new FileInputStream(filename);
-            mPixelBuffer = pixelFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, pixelSize);
+
+            mPixelFile = new FileInputStream(filename);
+            mPixelBuffer = mPixelFile.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, pixelSize);
         } catch (java.io.FileNotFoundException e) {
             FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
         } catch (java.io.IOException e) {
             FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
         }
     }
 
     public final int getPixelAt(int x, int y) {
@@ -53,10 +54,17 @@ public class PaintedSurface {
         int index = (x + ((mHeight - y - 1) * mWidth)) * 4;
         int b1 = mPixelBuffer.get(index) & 0xFF;
         int b2 = mPixelBuffer.get(index + 1) & 0xFF;
         int b3 = mPixelBuffer.get(index + 2) & 0xFF;
         int b4 = mPixelBuffer.get(index + 3) & 0xFF;
         int value = (b1 << 24) + (b2 << 16) + (b3 << 8) + (b4 << 0);
         return value;
     }
+
+    public void close() {
+        try {
+            mPixelFile.close();
+        } catch (Exception e) {
+            FennecNativeDriver.log(FennecNativeDriver.LogLevel.DEBUG, e);
+        }
+    }
 }
-
--- a/build/unix/build-clang/build-clang.py
+++ b/build/unix/build-clang/build-clang.py
@@ -9,16 +9,18 @@ moz_version = "moz0"
 ##############################################
 
 import os
 import os.path
 import shutil
 import tarfile
 import subprocess
 import platform
+import sys
+import simplejson
 
 def check_run(args):
     r = subprocess.call(args)
     assert r == 0
 
 def run_in(path, args):
     d = os.getcwd()
     os.chdir(path)
@@ -65,16 +67,39 @@ llvm_source_dir = source_dir + "/llvm"
 clang_source_dir = source_dir + "/clang"
 compiler_rt_source_dir = source_dir + "/compiler-rt"
 
 def build_one_stage(env, stage_dir, is_stage_one):
     def f():
         build_one_stage_aux(stage_dir, is_stage_one)
     with_env(env, f)
 
+def build_tooltool_manifest():
+    def key_sort(item):
+        item = item[0]
+        if item == 'size':
+            return 0
+        if item == 'digest':
+            return 1
+        if item == 'algorithm':
+            return 3
+        return 4
+
+    basedir = os.path.split(os.path.realpath(sys.argv[0]))[0]
+    tooltool = basedir + '/tooltool.py'
+    setup = basedir + '/setup.sh'
+    manifest = 'clang.manifest'
+    check_run(['python', tooltool, '-m', 'clang.manifest', 'add',
+               setup, 'clang.tar.bz2'])
+    data = simplejson.load(file('clang.manifest'))
+    data = [{'clang_version' : 'r%s' % llvm_revision }] + data
+    out = file('clang.manifest','w')
+    simplejson.dump(data, out, indent=0, item_sort_key=key_sort)
+    out.write('\n')
+
 isDarwin = platform.system() == "Darwin"
 
 def build_one_stage_aux(stage_dir, is_stage_one):
     os.mkdir(stage_dir)
 
     build_dir = stage_dir + "/build"
     inst_dir = stage_dir + "/clang"
 
@@ -131,8 +156,9 @@ if not isDarwin:
     extra_cflags += " -fgnu89-inline"
 
 stage2_dir = build_dir + '/stage2'
 build_one_stage({"CC"  : stage1_inst_dir + "/bin/clang %s" % extra_cflags,
                  "CXX" : stage1_inst_dir + "/bin/clang++ %s" % extra_cxxflags},
                 stage2_dir, False)
 
 build_tar_package("tar", "clang.tar.bz2", stage2_dir, "clang")
+build_tooltool_manifest()
deleted file mode 100755
--- a/build/unix/build-clang/create-manifest.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/python
-
-import os
-import os.path
-import simplejson
-import sys
-import subprocess
-import urllib
-import glob
-
-def check_run(args):
-    r = subprocess.call(args)
-    assert r == 0
-
-old_files = glob.glob('*.manifest')
-for f in old_files:
-    try:
-        os.unlink(f)
-    except:
-        pass
-
-basedir = os.path.split(os.path.realpath(sys.argv[0]))[0]
-tooltool = basedir + '/tooltool.py'
-setup = basedir + '/setup.sh'
-
-check_run(['python', tooltool, '-m', 'linux32.manifest', 'add',
-           'clang-linux32.tar.bz2', setup])
-check_run(['python', tooltool, '-m', 'linux64.manifest', 'add',
-           'clang-linux64.tar.bz2', setup])
-check_run(['python', tooltool, '-m', 'darwin.manifest', 'add',
-           'clang-darwin.tar.bz2', setup])
-
-def key_sort(item):
-    item = item[0]
-    if item == 'size':
-        return 0
-    if item == 'digest':
-        return 1
-    if item == 'algorithm':
-        return 3
-    return 4
-
-rev = os.path.basename(os.getcwd()).split('-')[1]
-
-for platform in ['darwin', 'linux32', 'linux64']:
-    old_name = 'clang-' + platform + '.tar.bz2'
-    manifest = platform + '.manifest'
-    data = eval(file(manifest).read())
-    new_name = data[1]['digest']
-    data[1]['filename'] = 'clang.tar.bz2'
-    data = [{'clang_version' : 'r%s' % rev }] + data
-    out = file(manifest,'w')
-    simplejson.dump(data, out, indent=0, item_sort_key=key_sort)
-    out.write('\n')
-    os.rename(old_name, new_name)
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -39,22 +39,16 @@ endif
 ifdef NSBUILDROOT
 override NSBUILDROOT :=
 endif
 
 ifdef GNU_CC
 MODULE_OPTIMIZE_FLAGS = -O3
 endif
 
-ifndef COMPILER_DEPEND
-ifndef MOZ_NATIVE_MAKEDEPEND
-DIRS		+= mkdepend
-endif
-endif
-
 include $(topsrcdir)/config/config.mk
 
 # Do not install util programs
 NO_INSTALL=1
 
 include $(topsrcdir)/config/rules.mk
 
 HOST_CFLAGS += -DUNICODE -D_UNICODE
@@ -140,23 +134,16 @@ ifndef CROSS_COMPILE
 ifdef USE_ELF_DYNSTR_GC
 elf-dynstr-gc: elf-dynstr-gc.c $(GLOBAL_DEPS)
 	$(CC) $(COMPILE_CFLAGS) $(GLIB_CFLAGS) -o $@ $< $(LDFLAGS) $(GLIB_LIBS) 
 endif
 endif
 
 FORCE:
 
-ifndef COMPILER_DEPEND
-ifdef MKDEPEND_DIR
-clean clobber realclean clobber_all::
-	cd $(MKDEPEND_DIR); $(MAKE) $@
-endif
-endif
-
 PYUNITS := \
   unit-Expression.py \
   unit-Preprocessor.py \
   unit-nsinstall.py \
   unit-printprereleasesuffix.py \
   unit-JarMaker.py \
   unit-buildlist.py \
   unit-expandlibs.py \
--- a/config/config.mk
+++ b/config/config.mk
@@ -574,24 +574,16 @@ endif # MOZ_OPTIMIZE
 endif # OS_ARCH=Darwin
 
 ifdef MOZ_USING_CCACHE
 ifdef CLANG_CXX
 export CCACHE_CPP2=1
 endif
 endif
 
-ifdef MOZ_NATIVE_MAKEDEPEND
-MKDEPEND_DIR =
-MKDEPEND = $(MOZ_NATIVE_MAKEDEPEND)
-else
-MKDEPEND_DIR = $(CONFIG_TOOLS)/mkdepend
-MKDEPEND = $(MKDEPEND_DIR)/mkdepend$(BIN_SUFFIX)
-endif
-
 # Set link flags according to whether we want a console.
 ifdef MOZ_WINCONSOLE
 ifeq ($(MOZ_WINCONSOLE),1)
 ifeq ($(OS_ARCH),OS2)
 BIN_FLAGS	+= -Zlinker -PM:VIO
 endif
 ifeq ($(OS_ARCH),WINNT)
 ifdef GNU_CC
@@ -627,17 +619,17 @@ endif
 #
 # Include any personal overrides the user might think are needed.
 #
 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
 -include $(MY_CONFIG)
 
 ######################################################################
 
-GARBAGE		+= $(DEPENDENCIES) $(MKDEPENDENCIES) $(MKDEPENDENCIES).bak core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
+GARBAGE		+= $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
 
 ifeq ($(OS_ARCH),Darwin)
 ifndef NSDISTMODE
 NSDISTMODE=absolute_symlink
 endif
 PWD := $(CURDIR)
 endif
 
@@ -751,16 +743,19 @@ ifdef TIERS
 DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
 STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
 endif
 
 OPTIMIZE_JARS_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/optimizejars.py)
 
 CREATE_PRECOMPLETE_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/createprecomplete.py)
 
+# MDDEPDIR is the subdirectory where dependency files are stored
+MDDEPDIR := .deps
+
 EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/pythonpath.py -I$(DEPTH)/config $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp --target $@)
 EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/pythonpath.py -I$(DEPTH)/config $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp)
 EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR)
 EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC)
 EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC)
 EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist -- $(LD)
 EXPAND_MKSHLIB_ARGS = --uselist
 ifdef SYMBOL_ORDER
deleted file mode 100644
--- a/config/makedep.cpp
+++ /dev/null
@@ -1,853 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; 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/. */
-
-// Dependency building hack
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <afxcoll.h>
-#include <afxtempl.h>
-
-int mainReturn = 0;
-BOOL b16 = FALSE;
-BOOL bSimple = FALSE;
-
-FILE *pAltFile = stdout;
-
-CStringArray includeDirectories;
-
-// turn a file, relative path or other into an absolute path
-// This function copied from MFC 1.52
-BOOL PASCAL _AfxFullPath(LPSTR lpszPathOut, LPCSTR lpszFileIn)
-        // lpszPathOut = buffer of _MAX_PATH
-        // lpszFileIn = file, relative path or absolute path
-        // (both in ANSI character set)
-{
-        OFSTRUCT of;
-        if (OpenFile(lpszFileIn, &of, OF_PARSE) != HFILE_ERROR)
-        {
-                // of.szPathName is in the OEM character set
-                OemToAnsi(of.szPathName, lpszPathOut);
-                AnsiUpper(lpszPathOut); // paths in upper case just to be sure
-                return TRUE;
-        }
-        else
-        {
-                TRACE1("Warning: could not parse the path %Fs\n", lpszFileIn);
-                lstrcpy(lpszPathOut, lpszFileIn);  // take it literally
-                AnsiUpper(lpszPathOut); // paths in upper case just to be sure
-                return FALSE;
-        }
-}
-
-void AddIncludeDirectory( char *pString ){
-    CString s = pString;
-	int len = s.GetLength();
-    if(len > 0 && s[len - 1] != '\\' ){
-        s += "\\";
-    }
-    includeDirectories.Add(s);
-}
-
-BOOL FileExists( const char *pString ){
-    struct _stat buf;
-    int result;
-
-    result = _stat( pString, &buf );
-    return (result == 0);
-}
-
-void FixPathName(CString& str) {
-	str.MakeUpper();		// all upper case
-
-	// now switch all forward slashes to back slashes
-	int index;
-	while ((index = str.Find('/')) != -1) {
-		str.SetAt(index, '\\');
-	}
-}
-
-void FATName(CString& csLONGName)
-{
-    //  Only relevant for 16 bits.
-    if(b16) {
-        //  Convert filename to FAT (8.3) equivalent.
-        char aBuffer[2048];
-
-        if(GetShortPathName(csLONGName, aBuffer, 2048)) {
-            csLONGName = aBuffer;
-        }
-    }
-}
-
-
-class CFileRecord {
-public:
-    CString m_shortName;
-    CString m_pathName;
-    CPtrArray m_includes;  // pointers to CFileRecords in fileMap
-    BOOL m_bVisited;
-    BOOL m_bSystem;
-    BOOL m_bSource;
-    static CMapStringToPtr fileMap;      // contains all allocated CFileRecords
-    static CStringArray orderedFileNames;
-    static CMapStringToPtr includeMap;   // pointer to CFileRecords in fileMap
-    static CMapStringToPtr noDependMap;
-
-    CFileRecord( const char *shortName, const char* pFullName, BOOL bSystem, BOOL bSource):
-                m_shortName( shortName ),
-                m_pathName(),
-                m_includes(),
-                m_bVisited(FALSE),
-                m_bSource( bSource ),
-                m_bSystem(bSystem){
-
-		m_pathName = pFullName;
-		FixPathName(m_pathName);				// all upper case for consistency
-		ASSERT(FindFileRecord(m_pathName) == NULL);	// make sure it's not already in the map
-        fileMap[m_pathName] = this;			// add this to the filemap, using the appropriate name as the key
-		if (bSource) {
-			orderedFileNames.Add(m_pathName);	// remember the order we saw source files in
-		}
-    }
-
-    // 
-    // open the file and grab all the includes.
-    //
-    void ProcessFile(){
-        FILE *f;
-		CString fullName;
-        BOOL bSystem;
-		DWORD lineCntr = 0;
-		char *a = new char[2048];
-        memset(a, 0, 2048);
-		char srcPath[_MAX_PATH];
-
-		// construct the full path
-		if (!_AfxFullPath(srcPath, m_pathName)) {
-			strcpy(srcPath, m_pathName);
-		}
-
-		// strip off the source filename to end up with just the path
-		LPSTR pTemp = strrchr(srcPath, '\\');
-		if (pTemp) {
-			*(pTemp + 1) = 0;
-		}
-
-        f = fopen(m_pathName, "r");
-        if(f != NULL && f != (FILE *)-1)  {
-			setvbuf(f, NULL, _IOFBF, 32768);		// use a large file buffer
-            while(fgets(a, 2047, f)) {
-				// if the string "//{{NO_DEPENDENCIES}}" is at the start of one of the 
-				// first 10 lines of a file, don't build dependencies on it or any
-				// of the files it includes
-				if (lineCntr < 10) {
-					static char* pDependStr = "//{{NO_DEPENDENCIES}}";
-					if (strncmp(a, pDependStr, strlen(pDependStr)) == 0) {
-						noDependMap[m_pathName] = 0;	// add it to the noDependMap
-						break;							// no need for further processing of this file
-					}
-				}
-				++lineCntr;
-				// have to handle a variety of legal syntaxes that we find in our source files:
-				//    #include
-				// #   include
-                // #include
-				// if the first non-whitespace char is a '#', consider this line
-				pTemp = a;
-				pTemp += strspn(pTemp, " \t");			// skip whitespace
-				if (*pTemp == '#') {
-					++pTemp;							// skip the '#'
-					pTemp += strspn(pTemp, " \t");		// skip more whitespace
-					if( !strncmp(pTemp, "include", 7) ){
-						pTemp += 7;						// skip the "include"
-						pTemp += strspn(pTemp, " \t");	// skip more whitespace
-						bSystem = (*pTemp == '<');		// mark if it's a system include or not
-                        // forget system files -- we just have to search all the paths
-                        // every time and never find them! This change alone speeds a full
-                        // depend run on my system from 5 minutes to 3:15
-						// if (bSystem || (*pTemp == '"')) {
-                        if (*pTemp == '"') {
-							LPSTR pStart = pTemp + 1;	// mark the start of the string
-							pTemp = pStart + strcspn(pStart, ">\" ");	// find the end of the string
-							*pTemp = 0;					// terminate the string
-
-							// construct the full pathname from the path part of the 
-							// source file and the name listed here
-							fullName = srcPath;
-							fullName += pStart;
-							CFileRecord *pAddMe = AddFile( pStart, fullName, bSystem );
-							if (pAddMe) {
-								m_includes.Add(pAddMe);
-							}
-						}
-					}
-				}
-            }
-            fclose(f);
-        }
-        delete [] a;
-    }
-
-    void PrintIncludes(){
-        int i = 0;
-        while( i < m_includes.GetSize() ){
-            CFileRecord *pRec = (CFileRecord*) m_includes[i];
-
-            //  Don't write out files that don't exist or are not in the namespace
-            //      of the programs using it (netscape_AppletMozillaContext.h doesn't
-            //      mix well with 16 bits).
-			// Also don't write out files that are in the noDependMap
-			void*	lookupJunk;
-            if( !pRec->m_bVisited && pRec->m_pathName.GetLength() != 0 && !noDependMap.Lookup(pRec->m_pathName, lookupJunk)) {
-
-				// not supposed to have a file in the list that doesn't exist
-				ASSERT(FileExists(pRec->m_pathName));
-
-                CString csOutput;
-                csOutput = pRec->m_pathName;
-                FATName(csOutput);
-
-				fprintf(pAltFile, "\\\n    %s ", (const char *) csOutput );
-
-				// mark this one as done so we don't do it more than once
-                pRec->m_bVisited = TRUE;
-
-                pRec->PrintIncludes();
-            }
-            i++;
-        }
-    }
-
-    void PrintDepend(){
-        CFileRecord *pRec;
-        BOOL bFound;
-        POSITION next;
-        CString name;
-
-		// clear all the m_bVisisted flags so we can use it to keep track
-		// of whether we've already output this file as a dependency
-        next = fileMap.GetStartPosition();
-        while( next ){
-            fileMap.GetNextAssoc( next, name, *(void**)&pRec );
-            pRec->m_bVisited = FALSE;
-        }
-
-        char fname[_MAX_FNAME];
-
-		if (pRec->m_pathName.GetLength() != 0) {
-            if( bSimple ){
-    			fprintf(pAltFile, "\n\n\n%s:\t", m_pathName );
-            }
-            else {
-                CString csOutput;
-                csOutput = m_pathName;
-                FATName(csOutput);
-
-    			_splitpath( csOutput, NULL, NULL, fname, NULL );
-
-    			fprintf(pAltFile, "\n\n\n$(OUTDIR)\\%s.obj: %s ", fname, (const char*) csOutput );
-            }
-	        m_bVisited = TRUE;		// mark it as done so we won't do it again
-	        PrintIncludes();
-		}
-    }
-
-
-    static CString NormalizeFileName( const char* pName ){
-        return CString(pName);
-    }
-
-    static CFileRecord* FindFileRecord( const char *pName ){
-		CFileRecord* pRec = NULL;
-		CString name(pName);
-		FixPathName(name);
-		fileMap.Lookup(name, (void*&)pRec);
-		return(pRec);
-    }
-public:
-    static CFileRecord* AddFile( const char* pShortName, const char* pFullName, BOOL bSystem = FALSE, 
-                BOOL bSource = FALSE ){
-
-		char fullName[_MAX_PATH];
-		BOOL bFound = FALSE;
-		CString foundName;
-		CString fixedShortName;
-        CString s;
-
-        // normalize the name
-        fixedShortName = pShortName;
-        FixPathName(fixedShortName);
-        pShortName = fixedShortName;
-
-        // if it is source, we might be getting an obj file.  If we do,
-        //  convert it to a c or c++ file.
-        if( bSource && (strcmp(GetExt(pShortName),".obj") == 0) ){
-            char path_buffer[_MAX_PATH];
-            char fname[_MAX_FNAME] = "";
-            CString s;
-
-            _splitpath( pShortName, NULL, NULL, fname, NULL );
-            if( FileExists( s = CString(fname) + ".cpp") ){
-                pShortName = s;
-                pFullName = s;
-            }
-            else if( FileExists( s = CString(fname) + ".c" ) ){
-                pShortName = s;
-                pFullName = s;
-            }
-            else {
-                return 0;
-            }
-        }
-
-		// if pFullName was not constructed, construct it here based on the current directory
-		if (!pFullName) {
-			_AfxFullPath(fullName, pShortName);
-			pFullName = fullName;
-		}
-		
-		// first check to see if we already have this exact file
-		CFileRecord *pRec = FindFileRecord(pFullName);
-
-        // if not found and not a source file check the header list --
-        // all files we've found in include directories are in the includeMap.
-        // we can save gobs of time by getting it from there
-        if (!pRec && !bSource)
-            includeMap.Lookup(fixedShortName, (void*&)pRec);
-
-        if (!pRec) {
-            // not in one of our lists, start scrounging on disk
-
-            // check the fullname first
-            if (FileExists(pFullName)) {
-                foundName = pFullName;
-                bFound = TRUE;
-            }
-            else {
-                // if still not found, search the include paths
-                int i = 0;
-                while( i < includeDirectories.GetSize() ){
-                    if( FileExists( includeDirectories[i] + pShortName ) ){
-                        foundName = includeDirectories[i] + pShortName;
-                        bFound = TRUE;
-                        break;
-                    }
-                    i++;
-                }
-            }
-        }
-        else {
-            // we found it
-            bFound = TRUE;
-        }
-
-		// source files are not allowed to be missing
-		if (bSource && !pRec && !bFound) {
-			fprintf(stderr, "Source file: %s doesn't exist\n", pFullName);
-			mainReturn = -1;		// exit with an error, don't write out the results
-		}
-
-#ifdef _DEBUG
-		if (!pRec && !bFound && !bSystem) {
-			fprintf(stderr, "Header not found: %s (%s)\n", pShortName, pFullName);
-		}
-#endif
-
-		// if none of the above logic found it already in the list, 
-        // must be a new file, add it to the list
-        if (bFound && (pRec == NULL)) {
-            pRec = new CFileRecord( pShortName, foundName, bSystem, bSource);
-
-			// if this one isn't a source file add it to the includeMap
-			// for performance reasons (so we can find it there next time rather
-			// than having to search the file system again)
-			if (!bSource) {
-				includeMap[pShortName] = pRec;
-			}
-        }
-        return pRec;
-    }
-
-
-    static void PrintDependancies(){
-        CFileRecord *pRec;
-        BOOL bFound;
-        POSITION next;
-        CString name;
-
-		// use orderedFileNames to preserve order
-		for (int pos = 0; pos < orderedFileNames.GetSize(); pos++) {
-			pRec = FindFileRecord(orderedFileNames[pos]);
-            if(pRec && pRec->m_bSource ){
-                pRec->PrintDepend();
-			}
-		}
-    }
-
-
-    void PrintDepend2(){
-        CFileRecord *pRec;
-        int i;
-
-        if( m_includes.GetSize() != 0 ){
-			fprintf(pAltFile, "\n\n\n%s: \\\n",m_pathName );
-            i = 0;
-            while( i < m_includes.GetSize() ){
-                pRec = (CFileRecord*) m_includes[i];
-    			fprintf(pAltFile, "\t\t\t%s\t\\\n",pRec->m_pathName );
-                i++;
-            }
-        }
-    }
-
-    static void PrintDependancies2(){
-        CFileRecord *pRec;
-        BOOL bFound;
-        POSITION next;
-        CString name;
-
-        next = fileMap.GetStartPosition();
-        while( next ){
-            fileMap.GetNextAssoc( next, name, *(void**)&pRec );
-            pRec->PrintDepend2();
-        }
-    }
-
-
-    static void PrintTargets(const char *pMacroName, const char *pDelimiter){
-        CFileRecord *pRec;
-        BOOL bFound;
-        POSITION next;
-        CString name;
-
-        BOOL bNeedDelimiter = FALSE;
-		fprintf(pAltFile, "%s = ", pMacroName);        
-
-		// use orderedFileNames to preserve target order
-		for (int pos = 0; pos < orderedFileNames.GetSize(); pos++) {
-			pRec = FindFileRecord(orderedFileNames[pos]);
-			ASSERT(pRec);
-
-            if( pRec && pRec->m_bSource && pRec->m_pathName.GetLength() != 0){
-                char fname[_MAX_FNAME];
-
-                CString csOutput;
-                csOutput = pRec->m_pathName;
-                FATName(csOutput);
-
-                _splitpath( csOutput, NULL, NULL, fname, NULL );
-
-                if(bNeedDelimiter)  {
-                    fprintf(pAltFile, "%s\n", pDelimiter);
-                    bNeedDelimiter = FALSE;
-                }
-
-				fprintf(pAltFile, "     $(OUTDIR)\\%s.obj   ", fname );
-                bNeedDelimiter = TRUE;
-            }
-        }
-		fprintf(pAltFile, "\n\n\n");        
-    }
-
-    static CString DirDefine( const char *pPath ){
-        char path_buffer[_MAX_PATH];
-        char dir[_MAX_DIR] = "";
-        char dir2[_MAX_DIR] = "";
-        char fname[_MAX_FNAME] = "";
-        char ext[_MAX_EXT] = "";
-        CString s;
-
-        _splitpath( pPath, 0, dir, 0, ext );
-
-        BOOL bDone = FALSE;
-
-        while( dir && !bDone){
-            // remove the trailing slash
-            dir[ strlen(dir)-1] = 0;
-            _splitpath( dir, 0, dir2, fname, 0 );
-            if( strcmp( fname, "SRC" ) == 0 ){
-                strcpy( dir, dir2 );
-            }
-            else {
-                bDone = TRUE;
-            }
-        }
-        s = CString(fname) + "_" + (ext+1);
-        return s;
-    }
-
-
-    static void PrintSources(){
-        int i;
-        CString dirName, newDirName;
-
-        for( i=0; i< orderedFileNames.GetSize(); i++ ){
-            newDirName= DirDefine( orderedFileNames[i] );
-            if( newDirName != dirName ){
-                fprintf( pAltFile, "\n\n\nFILES_%s= $(FILES_%s) \\", 
-                        (const char*)newDirName, (const char*)newDirName );
-                dirName = newDirName;
-            }
-            fprintf( pAltFile, "\n\t%s^", (const char*)orderedFileNames[i] );
-        }
-    }
-
-    static CString SourceDirName( const char *pPath, BOOL bFileName){
-        char path_buffer[_MAX_PATH];
-        char drive[_MAX_DRIVE] = "";
-        char dir[_MAX_DIR] = "";
-        char fname[_MAX_FNAME] = "";
-        char ext[_MAX_EXT] = "";
-        CString s;
-
-        _splitpath( pPath, drive, dir, fname, ext );
-
-        s = CString(drive) + dir;
-        if( bFileName ){
-            s += CString("FNAME") + ext;
-        }
-        else {
-            // remove the trailing slash
-            s = s.Left( s.GetLength() - 1 );
-        }
-        return s;
-    }
-
-
-    static CString GetExt( const char *pPath){
-        char ext[_MAX_EXT] = "";
-
-        _splitpath( pPath, 0,0,0, ext );
-
-        CString s = CString(ext);
-        s.MakeLower();
-        return s;
-    }
-
-    static void PrintBuildRules(){
-        int i;
-        CString dirName;
-        
-        CMapStringToPtr dirList;
-
-        for( i=0; i< orderedFileNames.GetSize(); i++ ){
-            dirList[ SourceDirName(orderedFileNames[i], TRUE) ]= 0;
-        }
-
-        POSITION next;
-        CString name;
-        void *pVal;
-
-        next = dirList.GetStartPosition();
-        while( next ){
-            dirList.GetNextAssoc( next, name, pVal);
-            CString dirDefine = DirDefine( name );
-            CString ext = GetExt( name );
-            name = SourceDirName( name, FALSE );
-            CString response = dirDefine.Left(8);
-
-            fprintf( pAltFile, 
-                "\n\n\n{%s}%s{$(OUTDIR)}.obj:\n"
-                "\t@rem <<$(OUTDIR)\\%s.cl\n"
-                "\t$(CFILEFLAGS)\n"
-                "\t$(CFLAGS_%s)\n"
-                "<<KEEP\n"
-                "\t$(CPP) @$(OUTDIR)\\%s.cl %%s\n",
-                (const char*)name,
-                (const char*)ext,
-                (const char*)response,
-                (const char*)dirDefine,
-                (const char*)response
-            );
-
-            fprintf( pAltFile, 
-                "\n\n\nBATCH_%s:\n"
-                "\t@rem <<$(OUTDIR)\\%s.cl\n"
-                "\t$(CFILEFLAGS)\n"
-                "\t$(CFLAGS_%s)\n"
-                "\t$(FILES_%s)\n"
-                "<<KEEP\n"
-                "\t$(TIMESTART)\n"
-                "\t$(CPP) @$(OUTDIR)\\%s.cl\n"
-                "\t$(TIMESTOP)\n",
-                (const char*)dirDefine,
-                (const char*)response,
-                (const char*)dirDefine,
-                (const char*)dirDefine,
-                (const char*)response
-            );
-        }
-
-        //
-        // Loop through one more time and build the final batch build
-        //  rule
-        //
-        fprintf( pAltFile, 
-            "\n\n\nBATCH_BUILD_OBJECTS:\t\t\\\n");
-
-        next = dirList.GetStartPosition();
-        while( next ){
-            dirList.GetNextAssoc( next, name, pVal);
-            CString dirDefine = DirDefine( name );
-
-            fprintf( pAltFile, 
-                "\tBATCH_%s\t\t\\\n", dirDefine );
-        }
-
-        fprintf( pAltFile, 
-            "\n\n");
-    }
-        
-
-    static void ProcessFiles(){
-        CFileRecord *pRec;
-        BOOL bFound;
-        POSITION next;
-        CString name;
-
-		// search all the files for headers, adding each one to the list when found
-		// rather than do it recursively, it simple marks each one it's done
-		// and starts over, stopping only when all are marked as done
-
-        next = fileMap.GetStartPosition();
-        while( next ){
-            fileMap.GetNextAssoc( next, name, *(void**)&pRec );
-            if( pRec->m_bVisited == FALSE && pRec->m_bSystem == FALSE ){
-				// mark this file as already done so we don't read it again
-				// to find its headers
-                pRec->m_bVisited = TRUE;
-                pRec->ProcessFile();
-                // Start searching from the beginning again
-				// because ProcessFile may have added new files 
-				// and changed the GetNextAssoc order
-                next = fileMap.GetStartPosition();       
-
-            }
-        }
-    }
-
-
-};
-
-CMapStringToPtr CFileRecord::fileMap;           // contains all allocated CFileRecords
-CStringArray CFileRecord::orderedFileNames;
-CMapStringToPtr CFileRecord::includeMap;        // pointers to CFileRecords in fileMap
-CMapStringToPtr CFileRecord::noDependMap;       // no data, just an index
-
-int main( int argc, char** argv ){
-    int i = 1;
-    char *pStr;
-    static int iRecursion = 0;	//	Track levels of recursion.
-	static CString outputFileName;
-    
-    //	Entering.
-    iRecursion++;
-
-    while( i < argc ){
-        if( argv[i][0] == '-' || argv[i][0] == '/' ){
-            switch( argv[i][1] ){
-
-            case 'i':
-            case 'I':
-                if( argv[i][2] != 0 ){
-                    pStr = &(argv[i][2]);
-                }
-                else {
-                    i++;
-                    pStr = argv[i];
-                }
-                if( pStr == 0 || *pStr == '-' || *pStr == '/' ){
-                    goto usage;
-                }
-                else {
-                    AddIncludeDirectory( pStr );
-                }
-                break;
-
-            case 'f':
-            case 'F':
-                if( argv[i][2] != 0 ){
-                    pStr = &(argv[i][2]);
-                }
-                else {
-                    i++;
-                    pStr = argv[i];
-                }
-                if( pStr == 0 || *pStr == '-' || *pStr == '/'){
-                    goto usage;
-                }
-                else {
-                    CStdioFile f;
-                    CString s;
-                    if( f.Open( pStr, CFile::modeRead ) ){
-                        while(f.ReadString(s)){
-                            s.TrimLeft();
-                            s.TrimRight();
-                            if( s.GetLength() ){
-                                CFileRecord::AddFile( s, NULL, FALSE, TRUE );
-                            }
-                        } 
-                        f.Close();
-                    }
-                    else {
-                        fprintf(stderr,"makedep: file not found: %s", pStr );
-                        exit(-1);
-                    }
-                }
-                break;
-
-            case 'o':
-            case 'O':
-                if( argv[i][2] != 0 ){
-                    pStr = &(argv[i][2]);
-                }
-                else {
-                    i++;
-                    pStr = argv[i];
-                }
-                if( pStr == 0 || *pStr == '-' || *pStr == '/'){
-                    goto usage;
-                }
-                else {
-                    CStdioFile f;
-                    CString s;
-					outputFileName = pStr;
-					if(!(pAltFile = fopen(pStr, "w+")))	{
-                        fprintf(stderr, "makedep: file not found: %s", pStr );
-                        exit(-1);
-                    }
-                }
-                break;
-
-            case '1':
-                if( argv[i][2] == '6')  {
-                    b16 = TRUE;
-                }
-                break;
-
-            case 's':
-            case 'S':
-                bSimple = TRUE;
-                break;
-
-
-
-            case 'h':
-            case 'H':
-            case '?':
-            usage:
-                fprintf(stderr, "usage: makedep -I <dirname> -F <filelist> <filename>\n"
-                       "  -I <dirname>    Directory name, can be repeated\n"
-                       "  -F <filelist>   List of files to scan, one per line\n"
-                       "  -O <outputFile> File to write output, default stdout\n");
-                exit(-1);
-            }
-        }
-        else if( argv[i][0] == '@' ){
-        	//	file contains our commands.
-	        CStdioFile f;
-    	    CString s;
-    	    int iNewArgc = 0;
-    	    char **apNewArgv = new char*[5000];
-			memset(apNewArgv, 0, sizeof(apNewArgv));
-
-			//	First one is always the name of the exe.
-			apNewArgv[0] = argv[0];
-			iNewArgc++;
-
-			const char *pTraverse;
-			const char *pBeginArg;
-	        if( f.Open( &argv[i][1], CFile::modeRead ) ){
-    	        while( iNewArgc < 5000 && f.ReadString(s) )	{
-					//	Scan the string for args, and do the right thing.
-					pTraverse = (const char *)s;
-					while(iNewArgc < 5000 && *pTraverse)	{
-						if(isspace(*pTraverse))	{
-								pTraverse++;
-								continue;
-						}
-
-						//	Extract to next space.
-						pBeginArg = pTraverse;
-						do	{
-							pTraverse++;
-						}
-						while(*pTraverse && !isspace(*pTraverse));
-						apNewArgv[iNewArgc] = new char[pTraverse - pBeginArg + 1];
-						memset(apNewArgv[iNewArgc], 0, pTraverse - pBeginArg + 1);
-						strncpy(apNewArgv[iNewArgc], pBeginArg, pTraverse - pBeginArg);
-						iNewArgc++;
-					}
-	            } 
-    	        f.Close();
-        	}
-        	
-        	//	Recurse if needed.
-        	if(iNewArgc > 1)	{
-        		main(iNewArgc, apNewArgv);
-        	}
-        	
-        	//	Free off the argvs (but not the very first one which we didn't allocate).
-        	while(iNewArgc > 1)	{
-        		iNewArgc--;
-        		delete [] apNewArgv[iNewArgc];
-        	}
-        	delete [] apNewArgv;
-        }
-        else {
-            CFileRecord::AddFile( argv[i], NULL, FALSE, TRUE );
-        }
-        i++;
-    }
-    
-    //	Only of the very bottom level of recursion do we do this.
-    if(iRecursion == 1)	{
-
-		// only write the results out if no errors encountered
-		if (mainReturn == 0) {
-			CFileRecord::ProcessFiles();
-            if( !bSimple ){
-        		CFileRecord::PrintTargets("OBJ_FILES", "\\");
-                if(b16) {
-    			    CFileRecord::PrintTargets("LINK_OBJS", "+\\");
-                }
-                else    {
-    			    CFileRecord::PrintTargets("LINK_OBJS", "^");
-                }
-                CFileRecord::PrintSources();
-                CFileRecord::PrintBuildRules();
-            }
-    		CFileRecord::PrintDependancies();
-		}
-	    
-		if(pAltFile != stdout)	{
-			fclose(pAltFile);
-			if (mainReturn != 0) {
-				remove(outputFileName);	// kill output file if returning an error
-			}
-		}
-	}
-	iRecursion--;
-
-    if (iRecursion == 0 )
-    {
-        // last time through -- clean up allocated CFileRecords!
-        CFileRecord *pFRec;
-        CString     name;
-        POSITION    next;
-
-        next = CFileRecord::fileMap.GetStartPosition();
-        while( next ){
-            CFileRecord::fileMap.GetNextAssoc( next, name, *(void**)&pFRec );
-            delete pFRec;
-        }
-    }
-
-    return mainReturn;
-}
deleted file mode 100755
index f56cde80a5947f18fb9e22b7015aa3d607894a2a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/config/mkdepend/Makefile.in
+++ /dev/null
@@ -1,51 +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/.
-
-DEPTH		= @DEPTH@
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-USE_STATIC_LIBS = 1
-
-MODULE		 = mkdepend
-HOST_PROGRAM	 = mkdepend$(BIN_SUFFIX)
-ifdef GNU_CC
-MODULE_OPTIMIZE_FLAGS = -O3
-else
-ifeq ($(OS_ARCH),SunOS)
-MODULE_OPTIMIZE_FLAGS = -fast
-endif
-endif
-
-ifeq ($(OS_ARCH),WINNT)
-ifndef GNU_CC
-MODULE_OPTIMIZE_FLAGS = -Ox
-endif
-endif
-
-HOST_CSRCS	= \
-		cppsetup.c \
-		ifparser.c \
-		include.c \
-		main.c \
-		parse.c \
-		pr.c \
-		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-HOST_CFLAGS	+= -DINCLUDEDIR=\"/usr/include\" -DOBJSUFFIX=\".$(OBJ_SUFFIX)\"
-
-ifdef GNU_CC
-_GCCDIR		= $(shell $(CC) -print-file-name=include)
-HOST_CFLAGS	+= -DPREINCDIR=\"$(_GCCDIR)\"
-endif
-
-export:: $(HOST_PROGRAM)
-
-$(HOST_OBJS): def.h ifparser.h imakemdep.h
deleted file mode 100644
--- a/config/mkdepend/cppsetup.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* $Xorg: cppsetup.c,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $ */
-/*
-
-Copyright (c) 1993, 1994, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/config/makedepend/cppsetup.c,v 3.11 2001/12/17 20:52:22 dawes Exp $ */
-
-#include "def.h"
-
-#ifdef	CPP
-/*
- * This file is strictly for the sake of cpy.y and yylex.c (if
- * you indeed have the source for cpp).
- */
-#define IB 1
-#define SB 2
-#define NB 4
-#define CB 8
-#define QB 16
-#define WB 32
-#define SALT '#'
-#if defined(pdp11) || defined(vax) || defined(ns16000) || defined(mc68000) || defined(ibm032)
-#define COFF 128
-#else
-#define COFF 0
-#endif
-/*
- * These variables used by cpy.y and yylex.c
- */
-extern char	*outp, *inp, *newp, *pend;
-extern char	*ptrtab;
-extern char	fastab[];
-extern char	slotab[];
-
-/*
- * cppsetup
- */
-struct filepointer	*currentfile;
-struct inclist		*currentinc;
-
-int
-cppsetup(char *line, struct filepointer *filep, struct inclist *inc)
-{
-	char *p, savec;
-	static boolean setupdone = FALSE;
-	boolean	value;
-
-	if (!setupdone) {
-		cpp_varsetup();
-		setupdone = TRUE;
-	}
-
-	currentfile = filep;
-	currentinc = inc;
-	inp = newp = line;
-	for (p=newp; *p; p++)
-		;
-
-	/*
-	 * put a newline back on the end, and set up pend, etc.
-	 */
-	*p++ = '\n';
-	savec = *p;
-	*p = '\0';
-	pend = p;
-
-	ptrtab = slotab+COFF;
-	*--inp = SALT; 
-	outp=inp; 
-	value = yyparse();
-	*p = savec;
-	return(value);
-}
-
-struct symtab **lookup(symbol)
-	char	*symbol;
-{
-	static struct symtab    *undefined;
-	struct symtab   **sp;
-
-	sp = isdefined(symbol, currentinc, NULL);
-	if (sp == NULL) {
-		sp = &undefined;
-		(*sp)->s_value = NULL;
-	}
-	return (sp);
-}
-
-pperror(tag, x0,x1,x2,x3,x4)
-	int	tag,x0,x1,x2,x3,x4;
-{
-	warning("\"%s\", line %d: ", currentinc->i_file, currentfile->f_line);
-	warning(x0,x1,x2,x3,x4);
-}
-
-
-yyerror(s)
-	register char	*s;
-{
-	fatalerr("Fatal error: %s\n", s);
-}
-#else /* not CPP */
-
-#include "ifparser.h"
-struct _parse_data {
-    struct filepointer *filep;
-    struct inclist *inc;
-    char *filename;
-    const char *line;
-};
-
-static const char *
-my_if_errors (IfParser *ip, const char *cp, const char *expecting)
-{
-    struct _parse_data *pd = (struct _parse_data *) ip->data;
-    int lineno = pd->filep->f_line;
-    char *filename = pd->filename;
-    char prefix[300];
-    int prefixlen;
-    int i;
-
-    sprintf (prefix, "\"%s\":%d", filename, lineno);
-    prefixlen = strlen(prefix);
-    fprintf (stderr, "%s:  %s", prefix, pd->line);
-    i = cp - pd->line;
-    if (i > 0 && pd->line[i-1] != '\n') {
-	putc ('\n', stderr);
-    }
-    for (i += prefixlen + 3; i > 0; i--) {
-	putc (' ', stderr);
-    }
-    fprintf (stderr, "^--- expecting %s\n", expecting);
-    return NULL;
-}
-
-
-#define MAXNAMELEN 256
-
-static struct symtab **
-lookup_variable (IfParser *ip, const char *var, int len)
-{
-    char tmpbuf[MAXNAMELEN + 1];
-    struct _parse_data *pd = (struct _parse_data *) ip->data;
-
-    if (len > MAXNAMELEN)
-	return 0;
-
-    strncpy (tmpbuf, var, len);
-    tmpbuf[len] = '\0';
-    return isdefined (tmpbuf, pd->inc, NULL);
-}
-
-
-static int
-my_eval_defined (IfParser *ip, const char *var, int len)
-{
-    if (lookup_variable (ip, var, len))
-	return 1;
-    else
-	return 0;
-}
-
-#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
-
-static long
-my_eval_variable (IfParser *ip, const char *var, int len)
-{
-    long val;
-    struct symtab **s;
-
-    s = lookup_variable (ip, var, len);
-    if (!s)
-	return 0;
-    do {
-	var = (*s)->s_value;
-	if (!isvarfirstletter(*var) || !strcmp((*s)->s_name, var))
-	    break;
-	s = lookup_variable (ip, var, strlen(var));
-    } while (s);
-
-    var = ParseIfExpression(ip, var, &val);
-    if (var && *var) debug(4, ("extraneous: '%s'\n", var));
-    return val;
-}
-
-int
-cppsetup(char *filename,
-	 char *line,
-	 struct filepointer *filep,
-	 struct inclist *inc)
-{
-    IfParser ip;
-    struct _parse_data pd;
-    long val = 0;
-
-    pd.filep = filep;
-    pd.inc = inc;
-    pd.line = line;
-    pd.filename = filename;
-    ip.funcs.handle_error = my_if_errors;
-    ip.funcs.eval_defined = my_eval_defined;
-    ip.funcs.eval_variable = my_eval_variable;
-    ip.data = (char *) &pd;
-
-    (void) ParseIfExpression (&ip, line, &val);
-    if (val)
-	return IF;
-    else
-	return IFFALSE;
-}
-#endif /* CPP */
-
deleted file mode 100644
--- a/config/mkdepend/def.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/* $Xorg: def.h,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
-/*
-
-Copyright (c) 1993, 1994, 1998 The Open Group.
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/config/makedepend/def.h,v 3.14 2003/01/17 17:09:49 tsi Exp $ */
-
-#ifndef NO_X11
-#include <X11/Xos.h>
-#include <X11/Xfuncproto.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#if 0
-#ifndef X_NOT_POSIX
-#ifndef _POSIX_SOURCE
-#define _POSIX_SOURCE
-#endif
-#endif
-#endif
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#define MAXDEFINES	512
-#define MAXFILES	1024
-#define MAXINCFILES	256	/* "-include" files */
-#define MAXDIRS		1024
-#define SYMTABINC	10	/* must be > 1 for define() to work right */
-#define	TRUE		1
-#define	FALSE		0
-
-/* the following must match the directives table in main.c */
-#define	IF		0
-#define	IFDEF		1
-#define	IFNDEF		2
-#define	ELSE		3
-#define	ENDIF		4
-#define	DEFINE		5
-#define	UNDEF		6
-#define	INCLUDE		7
-#define	LINE		8
-#define	PRAGMA		9
-#define ERROR           10
-#define IDENT           11
-#define SCCS            12
-#define ELIF            13
-#define EJECT           14
-#define WARNING         15
-#define INCLUDENEXT     16
-#define IFFALSE         17     /* pseudo value --- never matched */
-#define ELIFFALSE       18     /* pseudo value --- never matched */
-#define INCLUDEDOT      19     /* pseudo value --- never matched */
-#define IFGUESSFALSE    20     /* pseudo value --- never matched */
-#define ELIFGUESSFALSE  21     /* pseudo value --- never matched */
-#define INCLUDENEXTDOT  22     /* pseudo value --- never matched */
-
-#ifdef DEBUG
-extern int	_debugmask;
-/*
- * debug levels are:
- * 
- *     0	show ifn*(def)*,endif
- *     1	trace defined/!defined
- *     2	show #include
- *     3	show #include SYMBOL
- *     4-6	unused
- */
-#define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }
-#else
-#define	debug(level,arg) /**/
-#endif /* DEBUG */
-
-typedef	unsigned char boolean;
-
-struct symtab {
-	char	*s_name;
-	char	*s_value;
-};
-
-/* possible i_flag */
-#define DEFCHECKED	(1<<0)	/* whether defines have been checked */
-#define NOTIFIED	(1<<1)	/* whether we have revealed includes */
-#define MARKED		(1<<2)	/* whether it's in the makefile */
-#define SEARCHED	(1<<3)	/* whether we have read this */
-#define FINISHED	(1<<4)	/* whether we are done reading this */
-#define INCLUDED_SYM	(1<<5)	/* whether #include SYMBOL was found
-				   Can't use i_list if TRUE */
-struct	inclist {
-	char		*i_incstring;	/* string from #include line */
-	char		*i_file;	/* path name of the include file */
-	struct inclist	**i_list;	/* list of files it itself includes */
-	int		i_listlen;	/* length of i_list */
-	struct symtab	**i_defs;	/* symbol table for this file and its
-					   children when merged */
-	int		i_ndefs;	/* current # defines */
-	boolean		*i_merged;      /* whether we have merged child
-					   defines */
-	unsigned char   i_flags;
-};
-
-struct filepointer {
-	char	*f_name;
-	char	*f_p;
-	char	*f_base;
-	char	*f_end;
-	long	f_len;
-	long	f_line;
-	long	cmdinc_count;
-	char	**cmdinc_list;
-	long	cmdinc_line;
-};
-
-#include <stdlib.h>
-#if defined(macII) && !defined(__STDC__)  /* stdlib.h fails to define these */
-char *malloc(), *realloc();
-#endif /* macII */
-
-char			*copy(char *str);
-int                     match(char *str, char **list);
-char			*base_name(char *file);
-char			*getnextline(struct filepointer *fp);
-struct symtab		**slookup(char *symbol, struct inclist *file);
-struct symtab		**isdefined(char *symbol, struct inclist *file,
-				    struct inclist **srcfile);
-struct symtab		**fdefined(char *symbol, struct inclist *file,
-				   struct inclist **srcfile);
-struct filepointer	*getfile(char *file);
-void                    included_by(struct inclist *ip, 
-				    struct inclist *newfile);
-struct inclist		*newinclude(char *newfile, char *incstring);
-void                    inc_clean (void);
-struct inclist		*inc_path(char *file, char *include, int type);
-
-void                    freefile(struct filepointer *fp);
-
-void                    define2(char *name, char *val, struct inclist *file);
-void                    define(char *def, struct inclist *file);
-void                    undefine(char *symbol, struct inclist *file);
-int                     find_includes(struct filepointer *filep, 
-				      struct inclist *file, 
-				      struct inclist *file_red, 
-				      int recursion, boolean failOK);
-
-void                    recursive_pr_include(struct inclist *head, 
-					     char *file, char *base);
-void                    add_include(struct filepointer *filep, 
-				    struct inclist *file, 
-				    struct inclist *file_red, 
-				    char *include, int type,
-				    boolean failOK);
-
-int                     cppsetup(char *filename,
-				 char *line,
-				 struct filepointer *filep,
-				 struct inclist *inc);
-
-
-extern void fatalerr(char *, ...);
-extern void warning(char *, ...);
-extern void warning1(char *, ...);
deleted file mode 100644
--- a/config/mkdepend/ifparser.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * $Xorg: ifparser.c,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
- *
- * Copyright 1992 Network Computing Devices, Inc.
- * 
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Network Computing Devices may not be
- * used in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Network Computing Devices makes
- * no representations about the suitability of this software for any purpose.
- * It is provided ``as is'' without express or implied warranty.
- * 
- * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- * 
- * Author:  Jim Fulton
- *          Network Computing Devices, Inc.
- * 
- * Simple if statement processor
- *
- * This module can be used to evaluate string representations of C language
- * if constructs.  It accepts the following grammar:
- * 
- *     EXPRESSION	:=	VALUE
- * 			 |	VALUE  BINOP	EXPRESSION
- *			 |	VALUE	'?'	EXPRESSION ':'	EXPRESSION
- * 
- *     VALUE		:=	'('  EXPRESSION  ')'
- * 			 |	'!'  VALUE
- * 			 |	'-'  VALUE
- * 			 |	'+'  VALUE
- *			 |	'~'  VALUE
- * 			 |	'defined'  '('  variable  ')'
- * 			 |	'defined'  variable
- *			 |	# variable '(' variable-list ')'
- * 			 |	variable
- * 			 |	number
- * 
- *     BINOP		:=	'*'	|  '/'	|  '%'
- * 			 |	'+'	|  '-'
- * 			 |	'<<'	|  '>>'
- * 			 |	'<'	|  '>'	|  '<='  |  '>='
- * 			 |	'=='	|  '!='
- * 			 |	'&'	|  '^'  |  '|'
- * 			 |	'&&'	|  '||'
- * 
- * The normal C order of precedence is supported.
- * 
- * 
- * External Entry Points:
- * 
- *     ParseIfExpression		parse a string for #if
- */
-/* $XFree86: xc/config/makedepend/ifparser.c,v 3.11 2002/09/23 01:48:08 tsi Exp $ */
-
-#include "ifparser.h"
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-/****************************************************************************
-		   Internal Macros and Utilities for Parser
- ****************************************************************************/
-
-#define DO(val) if (!(val)) return NULL
-#define CALLFUNC(ggg,fff) (*((ggg)->funcs.fff))
-#define SKIPSPACE(ccc) while (isspace(*ccc)) ccc++
-#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
-
-
-static const char *
-parse_variable (IfParser *g, const char *cp, const char **varp)
-{
-    SKIPSPACE (cp);
-
-    if (!isvarfirstletter (*cp))
-	return CALLFUNC(g, handle_error) (g, cp, "variable name");
-
-    *varp = cp;
-    /* EMPTY */
-    for (cp++; isalnum(*cp) || *cp == '_'; cp++) ;
-    return cp;
-}
-
-
-static const char *
-parse_number (IfParser *g, const char *cp, long *valp)
-{
-    long base = 10;
-    SKIPSPACE (cp);
-
-    if (!isdigit(*cp))
-	return CALLFUNC(g, handle_error) (g, cp, "number");
-
-    *valp = 0;
-
-    if (*cp == '0') {
-	cp++;
-	if ((*cp == 'x') || (*cp == 'X')) {
-	    base = 16;
-	    cp++;
-	} else {
-	    base = 8;
-	}
-    }
-
-    /* Ignore overflows and assume ASCII, what source is usually written in */
-    while (1) {
-	int increment = -1;
-	if (base == 8) {
-	    if ((*cp >= '0') && (*cp <= '7'))
-		increment = *cp++ - '0';
-	} else if (base == 16) {
-	    if ((*cp >= '0') && (*cp <= '9'))
-		increment = *cp++ - '0';
-	    else if ((*cp >= 'A') &&  (*cp <= 'F'))
-		increment = *cp++ - ('A' - 10);
-	    else if ((*cp >= 'a') && (*cp <= 'f'))
-		increment = *cp++ - ('a' - 10);
-	} else {	/* Decimal */
-	    if ((*cp >= '0') && (*cp <= '9'))
-		increment = *cp++ - '0';
-	}
-	if (increment < 0)
-	    break;
-	*valp = (*valp * base) + increment;
-    }
-
-    /* Skip trailing qualifiers */
-    while (*cp == 'U' || *cp == 'u' || *cp == 'L' || *cp == 'l') cp++;
-    return cp;
-}
-
-static const char *
-parse_character (IfParser *g, const char *cp, long *valp)
-{
-    char val;
-
-    SKIPSPACE (cp);
-    if (*cp == '\\')
-	switch (cp[1]) {
-	case 'n': val = '\n'; break;
-	case 't': val = '\t'; break;
-	case 'v': val = '\v'; break;
-	case 'b': val = '\b'; break;
-	case 'r': val = '\r'; break;
-	case 'f': val = '\f'; break;
-	case 'a': val = '\a'; break;
-	case '\\': val = '\\'; break;
-	case '?': val = '\?'; break;
-	case '\'': val = '\''; break;
-	case '\"': val = '\"'; break;
-	case 'x': val = (char) strtol (cp + 2, NULL, 16); break;
-	default: val = (char) strtol (cp + 1, NULL, 8); break;
-	}
-    else
-	val = *cp;
-    while (*cp != '\'') cp++;
-    *valp = (long) val;
-    return cp;
-}
-
-static const char *
-parse_value (IfParser *g, const char *cp, long *valp)
-{
-    const char *var, *varend;
-
-    *valp = 0;
-
-    SKIPSPACE (cp);
-    if (!*cp)
-	return cp;
-
-    switch (*cp) {
-      case '(':
-	DO (cp = ParseIfExpression (g, cp + 1, valp));
-	SKIPSPACE (cp);
-	if (*cp != ')') 
-	    return CALLFUNC(g, handle_error) (g, cp, ")");
-
-	return cp + 1;			/* skip the right paren */
-
-      case '!':
-	DO (cp = parse_value (g, cp + 1, valp));
-	*valp = !(*valp);
-	return cp;
-
-      case '-':
-	DO (cp = parse_value (g, cp + 1, valp));
-	*valp = -(*valp);
-	return cp;
-
-      case '+':
-	DO (cp = parse_value (g, cp + 1, valp));
-	return cp;
-
-      case '~':
-	DO (cp = parse_value (g, cp + 1, valp));
-	*valp = ~(*valp);
-	return cp;
-
-      case '#':
-	DO (cp = parse_variable (g, cp + 1, &var));
-	SKIPSPACE (cp);
-	if (*cp != '(')
-	    return CALLFUNC(g, handle_error) (g, cp, "(");
-	do {
-	    DO (cp = parse_variable (g, cp + 1, &var));
-	    SKIPSPACE (cp);
-	} while (*cp && *cp != ')');
-	if (*cp != ')')
-	    return CALLFUNC(g, handle_error) (g, cp, ")");
-	*valp = 1; /* XXX */
-	return cp + 1;
-
-      case '\'':
-	DO (cp = parse_character (g, cp + 1, valp));
-	if (*cp != '\'')
-	    return CALLFUNC(g, handle_error) (g, cp, "'");
-	return cp + 1;
-
-      case 'd':
-	if (strncmp (cp, "defined", 7) == 0 && !isalnum(cp[7])) {
-	    int paren = 0;
-	    int len;
-
-	    cp += 7;
-	    SKIPSPACE (cp);
-	    if (*cp == '(') {
-		paren = 1;
-		cp++;
-	    }
-	    DO (cp = parse_variable (g, cp, &var));
-	    len = cp - var;
-	    SKIPSPACE (cp);
-	    if (paren && *cp != ')')
-		return CALLFUNC(g, handle_error) (g, cp, ")");
-	    *valp = (*(g->funcs.eval_defined)) (g, var, len);
-	    return cp + paren;		/* skip the right paren */
-	}
-	/* fall out */
-    }
-
-    if (isdigit(*cp)) {
-	DO (cp = parse_number (g, cp, valp));
-    } else if (!isvarfirstletter(*cp))
-	return CALLFUNC(g, handle_error) (g, cp, "variable or number");
-    else {
-	DO (cp = parse_variable (g, cp, &var));
-	varend = cp;
-	SKIPSPACE(cp);
-	if (*cp != '(') {
-	    *valp = (*(g->funcs.eval_variable)) (g, var, varend - var);
-	} else {
-	    do {
-		long dummy;
-		DO (cp = ParseIfExpression (g, cp + 1, &dummy));
-		SKIPSPACE(cp);
-		if (*cp == ')')
-		    break;
-		if (*cp != ',')
-		    return CALLFUNC(g, handle_error) (g, cp, ",");
-	    } while (1);
-
-	    *valp = 1;	/* XXX */
-	    cp++;
-	}
-    }
-    
-    return cp;
-}
-
-
-
-static const char *
-parse_product (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_value (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '*':
-	DO (cp = parse_product (g, cp + 1, &rightval));
-	*valp = (*valp * rightval);
-	break;
-
-      case '/':
-	DO (cp = parse_product (g, cp + 1, &rightval));
-	if (rightval == 0)
-	  return CALLFUNC(g, handle_error) (g, cp, "0");
-	*valp = (*valp / rightval);
-	break;
-
-      case '%':
-	DO (cp = parse_product (g, cp + 1, &rightval));
-	*valp = (*valp % rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_sum (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_product (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '+':
-	DO (cp = parse_sum (g, cp + 1, &rightval));
-	*valp = (*valp + rightval);
-	break;
-
-      case '-':
-	DO (cp = parse_sum (g, cp + 1, &rightval));
-	*valp = (*valp - rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_shift (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_sum (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '<':
-	if (cp[1] == '<') {
-	    DO (cp = parse_shift (g, cp + 2, &rightval));
-	    *valp = (*valp << rightval);
-	}
-	break;
-
-      case '>':
-	if (cp[1] == '>') {
-	    DO (cp = parse_shift (g, cp + 2, &rightval));
-	    *valp = (*valp >> rightval);
-	}
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_inequality (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_shift (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '<':
-	if (cp[1] == '=') {
-	    DO (cp = parse_inequality (g, cp + 2, &rightval));
-	    *valp = (*valp <= rightval);
-	} else {
-	    DO (cp = parse_inequality (g, cp + 1, &rightval));
-	    *valp = (*valp < rightval);
-	}
-	break;
-
-      case '>':
-	if (cp[1] == '=') {
-	    DO (cp = parse_inequality (g, cp + 2, &rightval));
-	    *valp = (*valp >= rightval);
-	} else {
-	    DO (cp = parse_inequality (g, cp + 1, &rightval));
-	    *valp = (*valp > rightval);
-	}
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_equality (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_inequality (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '=':
-	if (cp[1] == '=')
-	    cp++;
-	DO (cp = parse_equality (g, cp + 1, &rightval));
-	*valp = (*valp == rightval);
-	break;
-
-      case '!':
-	if (cp[1] != '=')
-	    break;
-	DO (cp = parse_equality (g, cp + 2, &rightval));
-	*valp = (*valp != rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_band (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_equality (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '&':
-	if (cp[1] != '&') {
-	    DO (cp = parse_band (g, cp + 1, &rightval));
-	    *valp = (*valp & rightval);
-	}
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_bxor (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_band (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '^':
-	DO (cp = parse_bxor (g, cp + 1, &rightval));
-	*valp = (*valp ^ rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_bor (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_bxor (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '|':
-	if (cp[1] != '|') {
-	    DO (cp = parse_bor (g, cp + 1, &rightval));
-	    *valp = (*valp | rightval);
-	}
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_land (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_bor (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '&':
-	if (cp[1] != '&')
-	    return CALLFUNC(g, handle_error) (g, cp, "&&");
-	DO (cp = parse_land (g, cp + 2, &rightval));
-	*valp = (*valp && rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_lor (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_land (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '|':
-	if (cp[1] != '|')
-	    return CALLFUNC(g, handle_error) (g, cp, "||");
-	DO (cp = parse_lor (g, cp + 2, &rightval));
-	*valp = (*valp || rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_cond(IfParser *g, const char *cp, long *valp)
-{
-    long trueval, falseval;
-
-    DO (cp = parse_lor (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '?':
-	DO (cp = parse_cond (g, cp + 1, &trueval));
-	SKIPSPACE (cp);
-	if (*cp != ':')
-	    return CALLFUNC(g, handle_error) (g, cp, ":");
-	DO (cp = parse_cond (g, cp + 1, &falseval));
-	*valp = (*valp ? trueval : falseval);
-	break;
-    }
-    return cp;
-}
-
-
-/****************************************************************************
-			     External Entry Points
- ****************************************************************************/
-
-const char *
-ParseIfExpression (IfParser *g, const char *cp, long *valp)
-{
-    return parse_cond (g, cp, valp);
-}
deleted file mode 100644
--- a/config/mkdepend/ifparser.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * $Xorg: ifparser.h,v 1.3 2000/08/17 19:41:51 cpqbld Exp $
- *
- * Copyright 1992 Network Computing Devices, Inc.
- * 
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Network Computing Devices may not be
- * used in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Network Computing Devices makes
- * no representations about the suitability of this software for any purpose.
- * It is provided ``as is'' without express or implied warranty.
- * 
- * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- * 
- * Author:  Jim Fulton
- *          Network Computing Devices, Inc.
- * 
- * Simple if statement processor
- *
- * This module can be used to evaluate string representations of C language
- * if constructs.  It accepts the following grammar:
- * 
- *     EXPRESSION	:=	VALUE
- * 			 |	VALUE  BINOP	EXPRESSION
- *			 |	VALUE	'?'	EXPRESSION ':'	EXPRESSION
- * 
- *     VALUE		:=	'('  EXPRESSION  ')'
- * 			 |	'!'  VALUE
- * 			 |	'-'  VALUE
- *			 |	'~'  VALUE
- * 			 |	'defined'  '('  variable  ')'
- * 			 |	variable
- * 			 |	number
- * 
- *     BINOP		:=	'*'	|  '/'	|  '%'
- * 			 |	'+'	|  '-'
- * 			 |	'<<'	|  '>>'
- * 			 |	'<'	|  '>'	|  '<='  |  '>='
- * 			 |	'=='	|  '!='
- * 			 |	'&'	|  '^'  |  '|'
- * 			 |	'&&'	|  '||'
- * 
- * The normal C order of precedence is supported.
- * 
- * 
- * External Entry Points:
- * 
- *     ParseIfExpression		parse a string for #if
- */
-
-/* $XFree86: xc/config/makedepend/ifparser.h,v 3.5 2001/07/25 15:04:40 dawes Exp $ */
-
-#include <stdio.h>
-
-typedef int Bool;
-#define False 0
-#define True 1
-
-typedef struct _if_parser {
-    struct {				/* functions */
-	const char *(*handle_error) (struct _if_parser *, const char *,
-				     const char *);
-	long (*eval_variable) (struct _if_parser *, const char *, int);
-	int (*eval_defined) (struct _if_parser *, const char *, int);
-    } funcs;
-    char *data;
-} IfParser;
-
-const char *ParseIfExpression (
-    IfParser *, 
-    const char *, 
-    long *
-);
-
deleted file mode 100644
--- a/config/mkdepend/imakemdep.h
+++ /dev/null
@@ -1,733 +0,0 @@
-
-/* $XConsortium: imakemdep.h,v 1.83 95/04/07 19:47:46 kaleb Exp $ */
-/* $XFree86: xc/config/imake/imakemdep.h,v 3.12 1995/07/08 10:22:17 dawes Exp $ */
-/*
-
-Copyright (c) 1993, 1994  X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-
-*/
-
-
-/* 
- * This file contains machine-dependent constants for the imake utility.
- * When porting imake, read each of the steps below and add in any necessary
- * definitions.  In general you should *not* edit ccimake.c or imake.c!
- */
-
-#ifdef CCIMAKE
-/*
- * Step 1:  imake_ccflags
- *     Define any special flags that will be needed to get imake.c to compile.
- *     These will be passed to the compile along with the contents of the
- *     make variable BOOTSTRAPCFLAGS.
- */
-#ifdef hpux
-#ifdef hp9000s800
-#define imake_ccflags "-DSYSV"
-#else
-#define imake_ccflags "-Wc,-Nd4000,-Ns3000 -DSYSV"
-#endif
-#endif
-
-#if defined(macII) || defined(_AUX_SOURCE)
-#define imake_ccflags "-DmacII -DSYSV"
-#endif
-
-#ifdef stellar
-#define imake_ccflags "-DSYSV"
-#endif
-
-#if defined(USL) || defined(Oki) || defined(NCR)
-#define imake_ccflags "-Xc -DSVR4"
-#endif
-
-#ifdef sony
-#if defined(SYSTYPE_SYSV) || defined(_SYSTYPE_SYSV)
-#define imake_ccflags "-DSVR4"
-#else
-#include <sys/param.h>
-#if NEWSOS < 41
-#define imake_ccflags "-Dbsd43 -DNOSTDHDRS"
-#else
-#if NEWSOS < 42
-#define imake_ccflags "-Dbsd43"
-#endif
-#endif
-#endif
-#endif
-
-#ifdef _CRAY
-#define imake_ccflags "-DSYSV -DUSG"
-#endif
-
-#if defined(_IBMR2) || defined(aix)
-#define imake_ccflags "-Daix -DSYSV"
-#endif
-
-#ifdef Mips
-#  if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43)
-#    define imake_ccflags "-DBSD43"
-#  else 
-#    define imake_ccflags "-DSYSV"
-#  endif
-#endif 
-
-#ifdef is68k
-#define imake_ccflags "-Dluna -Duniosb"
-#endif
-
-#ifdef SYSV386
-# ifdef SVR4
-#  define imake_ccflags "-Xc -DSVR4"
-# else
-#  define imake_ccflags "-DSYSV"
-# endif
-#endif
-
-#ifdef SVR4
-# ifdef i386
-#  define imake_ccflags "-Xc -DSVR4"
-# endif
-#endif
-
-#ifdef SYSV
-# ifdef i386
-#  define imake_ccflags "-DSYSV"
-# endif
-#endif
-
-#ifdef __convex__
-#define imake_ccflags "-fn -tm c1"
-#endif
-
-#ifdef apollo
-#define imake_ccflags "-DX_NOT_POSIX"
-#endif
-
-#ifdef WIN32
-#define imake_ccflags "-nologo -batch -D__STDC__"
-#endif
-
-#ifdef __uxp__
-#define imake_ccflags "-DSVR4 -DANSICPP"
-#endif
-
-#ifdef __sxg__
-#define imake_ccflags "-DSYSV -DUSG -DNOSTDHDRS"
-#endif
-
-#ifdef sequent
-#define imake_ccflags "-DX_NOT_STDC_ENV -DX_NOT_POSIX"
-#endif
-
-#ifdef _SEQUENT_
-#define imake_ccflags "-DSYSV -DUSG"
-#endif
-
-#if defined(SX) || defined(PC_UX)
-#define imake_ccflags "-DSYSV"
-#endif
-
-#ifdef nec_ews_svr2
-#define imake_ccflags "-DUSG"
-#endif
-
-#if defined(nec_ews_svr4) || defined(_nec_ews_svr4) || defined(_nec_up) || defined(_nec_ft)
-#define imake_ccflags "-DSVR4"
-#endif
-
-#ifdef	MACH
-#define imake_ccflags "-DNOSTDHDRS"
-#endif
-
-/* this is for OS/2 under EMX. This won't work with DOS */
-#if defined(__EMX__) 
-#define imake_ccflags "-DBSD43"
-#endif
-
-#else /* not CCIMAKE */
-#ifndef MAKEDEPEND
-/*
- * Step 2:  dup2
- *     If your OS doesn't have a dup2() system call to duplicate one file
- *     descriptor onto another, define such a mechanism here (if you don't
- *     already fall under the existing category(ies).
- */
-#if defined(SYSV) && !defined(_CRAY) && !defined(Mips) && !defined(_SEQUENT_)
-#define	dup2(fd1,fd2)	((fd1 == fd2) ? fd1 : (close(fd2), \
-					       fcntl(fd1, F_DUPFD, fd2)))
-#endif
-
-
-/*
- * Step 3:  FIXUP_CPP_WHITESPACE
- *     If your cpp collapses tabs macro expansions into a single space and
- *     replaces escaped newlines with a space, define this symbol.  This will
- *     cause imake to attempt to patch up the generated Makefile by looking
- *     for lines that have colons in them (this is why the rules file escapes
- *     all colons).  One way to tell if you need this is to see whether or not
- *     your Makefiles have no tabs in them and lots of @@ strings.
- */
-#if defined(sun) || defined(SYSV) || defined(SVR4) || defined(hcx) || defined(WIN32) || (defined(AMOEBA) && defined(CROSS_COMPILE))
-#define FIXUP_CPP_WHITESPACE
-#endif
-#ifdef WIN32
-#define REMOVE_CPP_LEADSPACE
-#define INLINE_SYNTAX
-#define MAGIC_MAKE_VARS
-#endif
-#ifdef __minix_vmd
-#define FIXUP_CPP_WHITESPACE
-#endif
-
-/*
- * Step 4:  USE_CC_E, DEFAULT_CC, DEFAULT_CPP
- *     If you want to use cc -E instead of cpp, define USE_CC_E.
- *     If use cc -E but want a different compiler, define DEFAULT_CC.
- *     If the cpp you need is not in /lib/cpp, define DEFAULT_CPP.
- */
-#ifdef hpux
-#define USE_CC_E
-#endif
-#ifdef WIN32
-#define USE_CC_E
-#define DEFAULT_CC "cl"
-#endif
-#ifdef apollo
-#define DEFAULT_CPP "/usr/lib/cpp"
-#endif
-#if defined(_IBMR2) && !defined(DEFAULT_CPP)
-#define DEFAULT_CPP "/usr/lpp/X11/Xamples/util/cpp/cpp"
-#endif
-#if defined(sun) && defined(SVR4)
-#define DEFAULT_CPP "/usr/ccs/lib/cpp"
-#endif
-#ifdef __bsdi__
-#define DEFAULT_CPP "/usr/bin/cpp"
-#endif
-#ifdef __uxp__
-#define DEFAULT_CPP "/usr/ccs/lib/cpp"
-#endif
-#ifdef __sxg__
-#define DEFAULT_CPP "/usr/lib/cpp"
-#endif
-#ifdef _CRAY
-#define DEFAULT_CPP "/lib/pcpp"
-#endif
-#if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-#define DEFAULT_CPP "/usr/libexec/cpp"
-#endif
-#ifdef	MACH
-#define USE_CC_E
-#endif
-#ifdef __minix_vmd
-#define DEFAULT_CPP "/usr/lib/cpp"
-#endif
-#if defined(__EMX__)
-/* expects cpp in PATH */
-#define DEFAULT_CPP "cpp"
-#endif
-
-/*
- * Step 5:  cpp_argv
- *     The following table contains the flags that should be passed
- *     whenever a Makefile is being generated.  If your preprocessor 
- *     doesn't predefine any unique symbols, choose one and add it to the
- *     end of this table.  Then, do the following:
- * 
- *         a.  Use this symbol in Imake.tmpl when setting MacroFile.
- *         b.  Put this symbol in the definition of BootstrapCFlags in your
- *             <platform>.cf file.
- *         c.  When doing a make World, always add "BOOTSTRAPCFLAGS=-Dsymbol" 
- *             to the end of the command line.
- * 
- *     Note that you may define more than one symbol (useful for platforms 
- *     that support multiple operating systems).
- */
-
-#define	ARGUMENTS 50	/* number of arguments in various arrays */
-char *cpp_argv[ARGUMENTS] = {
-	"cc",		/* replaced by the actual program to exec */
-	"-I.",		/* add current directory to include path */
-#ifdef unix
-	"-Uunix",	/* remove unix symbol so that filename unix.c okay */
-#endif
-#if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(MACH)
-# ifdef __i386__
-	"-D__i386__",
-# endif
-# ifdef __x86_64__
-	"-D__x86_64__",
-# endif
-# ifdef __GNUC__
-	"-traditional",
-# endif
-#endif
-#ifdef M4330
-	"-DM4330",	/* Tektronix */
-#endif
-#ifdef M4310
-	"-DM4310",	/* Tektronix */
-#endif
-#if defined(macII) || defined(_AUX_SOURCE)
-	"-DmacII",	/* Apple A/UX */
-#endif
-#ifdef USL
-	"-DUSL",	/* USL */
-#endif
-#ifdef sony
-	"-Dsony",	/* Sony */
-#if !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV) && NEWSOS < 42
-	"-Dbsd43",
-#endif
-#endif
-#ifdef _IBMR2
-	"-D_IBMR2",	/* IBM RS-6000 (we ensured that aix is defined above */
-#ifndef aix
-#define aix		/* allow BOOTSTRAPCFLAGS="-D_IBMR2" */
-#endif
-#endif /* _IBMR2 */
-#ifdef aix
-	"-Daix",	/* AIX instead of AOS */
-#ifndef ibm
-#define ibm		/* allow BOOTSTRAPCFLAGS="-Daix" */
-#endif
-#endif /* aix */
-#ifdef ibm
-	"-Dibm",	/* IBM PS/2 and RT under both AOS and AIX */
-#endif
-#ifdef luna
-	"-Dluna",	/* OMRON luna 68K and 88K */
-#ifdef luna1
-	"-Dluna1",
-#endif
-#ifdef luna88k		/* need not on UniOS-Mach Vers. 1.13 */
-	"-traditional", /* for some older version            */
-#endif			/* instead of "-DXCOMM=\\#"          */
-#ifdef uniosb
-	"-Duniosb",
-#endif
-#ifdef uniosu
-	"-Duniosu",
-#endif
-#endif /* luna */
-#ifdef _CRAY		/* Cray */
-	"-Ucray",
-#endif
-#ifdef Mips
-	"-DMips",	/* Define and use Mips for Mips Co. OS/mach. */
-# if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43)
-	"-DBSD43",	/* Mips RISCOS supports two environments */
-# else
-	"-DSYSV",	/* System V environment is the default */
-# endif
-#endif /* Mips */
-#ifdef MOTOROLA
-	"-DMOTOROLA",    /* Motorola Delta Systems */
-# ifdef SYSV
-	"-DSYSV", 
-# endif
-# ifdef SVR4
-	"-DSVR4",
-# endif
-#endif /* MOTOROLA */
-#ifdef i386
-	"-Di386",
-# ifdef SVR4
-	"-DSVR4",
-# endif
-# ifdef SYSV
-	"-DSYSV",
-#  ifdef ISC
-	"-DISC",
-#   ifdef ISC40
-	"-DISC40",       /* ISC 4.0 */
-#   else
-#    ifdef ISC202
-	"-DISC202",      /* ISC 2.0.2 */
-#    else
-#     ifdef ISC30
-	"-DISC30",       /* ISC 3.0 */
-#     else
-	"-DISC22",       /* ISC 2.2.1 */
-#     endif
-#    endif
-#   endif
-#  endif
-#  ifdef SCO
-	"-DSCO",
-#   ifdef SCO324
-	"-DSCO324",
-#   endif
-#  endif
-# endif
-# ifdef ESIX
-	"-DESIX",
-# endif
-# ifdef ATT
-	"-DATT",
-# endif
-# ifdef DELL
-	"-DDELL",
-# endif
-#endif
-#ifdef SYSV386           /* System V/386 folks, obsolete */
-	"-Di386",
-# ifdef SVR4
-	"-DSVR4",
-# endif
-# ifdef ISC
-	"-DISC",
-#  ifdef ISC40
-	"-DISC40",       /* ISC 4.0 */
-#  else
-#   ifdef ISC202
-	"-DISC202",      /* ISC 2.0.2 */
-#   else
-#    ifdef ISC30
-	"-DISC30",       /* ISC 3.0 */
-#    else
-	"-DISC22",       /* ISC 2.2.1 */
-#    endif
-#   endif
-#  endif
-# endif
-# ifdef SCO
-	"-DSCO",
-#  ifdef SCO324
-	"-DSCO324",
-#  endif
-# endif
-# ifdef ESIX
-	"-DESIX",
-# endif
-# ifdef ATT
-	"-DATT",
-# endif
-# ifdef DELL
-	"-DDELL",
-# endif
-#endif
-#ifdef __osf__
-	"-D__osf__",
-# ifdef __mips__
-	"-D__mips__",
-# endif
-# ifdef __alpha
-	"-D__alpha",
-# endif
-# ifdef __i386__
-	"-D__i386__",
-# endif
-# ifdef __GNUC__
-	"-traditional",
-# endif
-#endif
-#ifdef Oki
-	"-DOki",
-#endif
-#ifdef sun
-#ifdef SVR4
-	"-DSVR4",
-#endif
-#endif
-#ifdef WIN32
-	"-DWIN32",
-	"-nologo",
-	"-batch",
-	"-D__STDC__",
-#endif
-#ifdef NCR
-	"-DNCR",	/* NCR */
-#endif
-#ifdef linux
-        "-traditional",
-        "-Dlinux",
-#endif
-#ifdef __uxp__
-	"-D__uxp__",
-#endif
-#ifdef __sxg__
-	"-D__sxg__",
-#endif
-#ifdef nec_ews_svr2
-	"-Dnec_ews_svr2",
-#endif
-#ifdef AMOEBA
-	"-DAMOEBA",
-# ifdef CROSS_COMPILE
-	"-DCROSS_COMPILE",
-#  ifdef CROSS_i80386
-	"-Di80386",
-#  endif
-#  ifdef CROSS_sparc
-	"-Dsparc",
-#  endif
-#  ifdef CROSS_mc68000
-	"-Dmc68000",
-#  endif
-# else
-#  ifdef i80386
-	"-Di80386",
-#  endif
-#  ifdef sparc
-	"-Dsparc",
-#  endif
-#  ifdef mc68000
-	"-Dmc68000",
-#  endif
-# endif
-#endif
-#ifdef __minix_vmd
-        "-Dminix",
-#endif
-
-#if defined(__EMX__)
-	"-traditional",
-	"-Demxos2",
-#endif
-
-};
-#else /* else MAKEDEPEND */
-/*
- * Step 6:  predefs
- *     If your compiler and/or preprocessor define any specific symbols, add
- *     them to the the following table.  The definition of struct symtab is
- *     in util/makedepend/def.h.
- */
-struct symtab	predefs[] = {
-#ifdef apollo
-	{"apollo", "1"},
-#endif
-#ifdef ibm032
-	{"ibm032", "1"},
-#endif
-#ifdef ibm
-	{"ibm", "1"},
-#endif
-#ifdef aix
-	{"aix", "1"},
-#endif
-#ifdef sun
-	{"sun", "1"},
-#endif
-#ifdef sun2
-	{"sun2", "1"},
-#endif
-#ifdef sun3
-	{"sun3", "1"},
-#endif
-#ifdef sun4
-	{"sun4", "1"},
-#endif
-#ifdef sparc
-	{"sparc", "1"},
-#endif
-#ifdef __sparc__
-	{"__sparc__", "1"},
-#endif
-#ifdef hpux
-	{"hpux", "1"},
-#endif
-#ifdef __hpux
-	{"__hpux", "1"},
-#endif
-#ifdef __hp9000s800
-	{"__hp9000s800", "1"},
-#endif
-#ifdef __hp9000s700
-	{"__hp9000s700", "1"},
-#endif
-#ifdef vax
-	{"vax", "1"},
-#endif
-#ifdef VMS
-	{"VMS", "1"},
-#endif
-#ifdef cray
-	{"cray", "1"},
-#endif
-#ifdef CRAY
-	{"CRAY", "1"},
-#endif
-#ifdef _CRAY
-	{"_CRAY", "1"},
-#endif
-#ifdef att
-	{"att", "1"},
-#endif
-#ifdef mips
-	{"mips", "1"},
-#endif
-#ifdef __mips__
-	{"__mips__", "1"},
-#endif
-#ifdef ultrix
-	{"ultrix", "1"},
-#endif
-#ifdef stellar
-	{"stellar", "1"},
-#endif
-#ifdef mc68000
-	{"mc68000", "1"},
-#endif
-#ifdef mc68020
-	{"mc68020", "1"},
-#endif
-#ifdef __GNUC__
-	{"__GNUC__", "1"},
-#endif
-#if __STDC__
-	{"__STDC__", "1"},
-#endif
-#ifdef __HIGHC__
-	{"__HIGHC__", "1"},
-#endif
-#ifdef CMU
-	{"CMU", "1"},
-#endif
-#ifdef luna
-	{"luna", "1"},
-#ifdef luna1
-	{"luna1", "1"},
-#endif
-#ifdef luna2
-	{"luna2", "1"},
-#endif
-#ifdef luna88k
-	{"luna88k", "1"},
-#endif
-#ifdef uniosb
-	{"uniosb", "1"},
-#endif
-#ifdef uniosu
-	{"uniosu", "1"},
-#endif
-#endif
-#ifdef ieeep754
-	{"ieeep754", "1"},
-#endif
-#ifdef is68k
-	{"is68k", "1"},
-#endif
-#ifdef m68k
-        {"m68k", "1"},
-#endif
-#ifdef m88k
-        {"m88k", "1"},
-#endif
-#ifdef __m88k__
-	{"__m88k__", "1"},
-#endif
-#ifdef bsd43
-	{"bsd43", "1"},
-#endif
-#ifdef hcx
-	{"hcx", "1"},
-#endif
-#ifdef sony
-	{"sony", "1"},
-#ifdef SYSTYPE_SYSV
-	{"SYSTYPE_SYSV", "1"},
-#endif
-#ifdef _SYSTYPE_SYSV
-	{"_SYSTYPE_SYSV", "1"},
-#endif
-#endif
-#ifdef __OSF__
-	{"__OSF__", "1"},
-#endif
-#ifdef __osf__
-	{"__osf__", "1"},
-#endif
-#ifdef __alpha
-	{"__alpha", "1"},
-#endif
-#ifdef __DECC
-	{"__DECC",  "1"},
-#endif
-#ifdef __decc
-	{"__decc",  "1"},
-#endif
-#ifdef __uxp__
-	{"__uxp__", "1"},
-#endif
-#ifdef __sxg__
-	{"__sxg__", "1"},
-#endif
-#ifdef _SEQUENT_
-	{"_SEQUENT_", "1"},
-	{"__STDC__", "1"},
-#endif
-#ifdef __bsdi__
-	{"__bsdi__", "1"},
-#endif
-#ifdef nec_ews_svr2
-	{"nec_ews_svr2", "1"},
-#endif
-#ifdef nec_ews_svr4
-	{"nec_ews_svr4", "1"},
-#endif
-#ifdef _nec_ews_svr4
-	{"_nec_ews_svr4", "1"},
-#endif
-#ifdef _nec_up
-	{"_nec_up", "1"},
-#endif
-#ifdef SX
-	{"SX", "1"},
-#endif
-#ifdef nec
-	{"nec", "1"},
-#endif
-#ifdef _nec_ft
-	{"_nec_ft", "1"},
-#endif
-#ifdef PC_UX
-	{"PC_UX", "1"},
-#endif
-#ifdef sgi
-	{"sgi", "1"},
-#endif
-#ifdef __sgi
-	{"__sgi", "1"},
-#endif
-#ifdef __FreeBSD__
-	{"__FreeBSD__", "1"},
-#endif
-#ifdef __NetBSD__
-	{"__NetBSD__", "1"},
-#endif
-#ifdef __OpenBSD__
-	{"__OpenBSD__", "1"},
-#endif
-#ifdef __EMX__
-	{"__EMX__", "1"},
-#endif
-	/* add any additional symbols before this line */
-	{NULL, NULL}
-};
-
-#endif /* MAKEDEPEND */
-#endif /* CCIMAKE */
deleted file mode 100644
--- a/config/mkdepend/include.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/* $Xorg: include.c,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
-/*
-
-Copyright (c) 1993, 1994, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/config/makedepend/include.c,v 3.7 2001/12/14 19:53:20 dawes Exp $ */
-
-
-#include "def.h"
-
-#ifdef _MSC_VER
-#include <windows.h>
-static int
-does_file_exist(char *file)
-{
-  WIN32_FILE_ATTRIBUTE_DATA data;
-  BOOL b = GetFileAttributesExA(file, GetFileExInfoStandard, &data);
-  if (!b)
-    return 0;
-  return (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0;
-}
-#else
-static int
-does_file_exist(char *file)
-{
-  struct stat sb;
-  return stat(file, &sb) == 0 && !S_ISDIR(sb.st_mode);
-}
-#endif
-
-extern struct	inclist	inclist[ MAXFILES ],
-			*inclistp, *inclistnext;
-extern char	*includedirs[ ],
-		**includedirsnext;
-extern char	*notdotdot[ ];
-extern boolean show_where_not;
-extern boolean warn_multiple;
-
-static boolean
-isdot(char *p)
-{
-	if(p && *p++ == '.' && *p++ == '\0')
-		return(TRUE);
-	return(FALSE);
-}
-
-static boolean
-isdotdot(char *p)
-{
-	if(p && *p++ == '.' && *p++ == '.' && *p++ == '\0')
-		return(TRUE);
-	return(FALSE);
-}
-
-static boolean
-issymbolic(char *dir, char *component)
-{
-#ifdef S_IFLNK
-	struct stat	st;
-	char	buf[ BUFSIZ ], **pp;
-
-	sprintf(buf, "%s%s%s", dir, *dir ? "/" : "", component);
-	for (pp=notdotdot; *pp; pp++)
-		if (strcmp(*pp, buf) == 0)
-			return (TRUE);
-	if (lstat(buf, &st) == 0
-	&& (st.st_mode & S_IFMT) == S_IFLNK) {
-		*pp++ = copy(buf);
-		if (pp >= &notdotdot[ MAXDIRS ])
-			fatalerr("out of .. dirs, increase MAXDIRS\n");
-		return(TRUE);
-	}
-#endif
-	return(FALSE);
-}
-
-/*
- * Occasionally, pathnames are created that look like .../x/../y
- * Any of the 'x/..' sequences within the name can be eliminated.
- * (but only if 'x' is not a symbolic link!!)
- */
-static void
-remove_dotdot(char *path)
-{
-	register char	*end, *from, *to, **cp;
-	char		*components[ MAXFILES ],
-			newpath[ BUFSIZ ];
-	boolean		component_copied;
-
-	/*
-	 * slice path up into components.
-	 */
-	to = newpath;
-	if (*path == '/')
-		*to++ = '/';
-	*to = '\0';
-	cp = components;
-	for (from=end=path; *end; end++)
-		if (*end == '/') {
-			while (*end == '/')
-				*end++ = '\0';
-			if (*from)
-				*cp++ = from;
-			from = end;
-		}
-	*cp++ = from;
-	*cp = NULL;
-
-	/*
-	 * Recursively remove all 'x/..' component pairs.
-	 */
-	cp = components;
-	while(*cp) {
-		if (!isdot(*cp) && !isdotdot(*cp) && isdotdot(*(cp+1))
-		    && !issymbolic(newpath, *cp))
-		{
-		    char **fp = cp + 2;
-		    char **tp = cp;
-
-		    do 
-			*tp++ = *fp; /* move all the pointers down */
-		    while (*fp++);
-		    if (cp != components)
-			cp--;	/* go back and check for nested ".." */
-		} else {
-		    cp++;
-		}
-	}
-	/*
-	 * Concatenate the remaining path elements.
-	 */
-	cp = components;
-	component_copied = FALSE;
-	while(*cp) {
-		if (component_copied)
-			*to++ = '/';
-		component_copied = TRUE;
-		for (from = *cp; *from; )
-			*to++ = *from++;
-		*to = '\0';
-		cp++;
-	}
-	*to++ = '\0';
-
-	/*
-	 * copy the reconstituted path back to our pointer.
-	 */
-	strcpy(path, newpath);
-}
-
-/*
- * Add an include file to the list of those included by 'file'.
- */
-struct inclist *
-newinclude(char *newfile, char *incstring)
-{
-	register struct inclist	*ip;
-
-	/*
-	 * First, put this file on the global list of include files.
-	 */
-	ip = inclistp++;
-	if (inclistp == inclist + MAXFILES - 1)
-		fatalerr("out of space: increase MAXFILES\n");
-	ip->i_file = copy(newfile);
-
-	if (incstring == NULL)
-		ip->i_incstring = ip->i_file;
-	else
-		ip->i_incstring = copy(incstring);
-
-	inclistnext = inclistp;
-	return(ip);
-}
-
-void
-included_by(struct inclist *ip, struct inclist *newfile)
-{
-	register int i;
-
-	if (ip == NULL)
-		return;
-	/*
-	 * Put this include file (newfile) on the list of files included
-	 * by 'file'.  If 'file' is NULL, then it is not an include
-	 * file itself (i.e. was probably mentioned on the command line).
-	 * If it is already on the list, don't stick it on again.
-	 */
-	if (ip->i_list == NULL) {
-		ip->i_list = (struct inclist **)
-			malloc(sizeof(struct inclist *) * ++ip->i_listlen);
-		ip->i_merged = (boolean *)
-		    malloc(sizeof(boolean) * ip->i_listlen);
-	} else {
-		for (i=0; i<ip->i_listlen; i++)
-			if (ip->i_list[ i ] == newfile) {
-			    i = strlen(newfile->i_file);
-			    if (!(ip->i_flags & INCLUDED_SYM) &&
-				!(i > 2 &&
-				  newfile->i_file[i-1] == 'c' &&
-				  newfile->i_file[i-2] == '.'))
-			    {
-				/* only bitch if ip has */
-				/* no #include SYMBOL lines  */
-				/* and is not a .c file */
-				if (warn_multiple)
-				{
-					warning("%s includes %s more than once!\n",
-						ip->i_file, newfile->i_file);
-					warning1("Already have\n");
-					for (i=0; i<ip->i_listlen; i++)
-						warning1("\t%s\n", ip->i_list[i]->i_file);
-				}
-			    }
-			    return;
-			}
-		ip->i_list = (struct inclist **) realloc(ip->i_list,
-			sizeof(struct inclist *) * ++ip->i_listlen);
-		ip->i_merged = (boolean *)
-		    realloc(ip->i_merged, sizeof(boolean) * ip->i_listlen);
-	}
-	ip->i_list[ ip->i_listlen-1 ] = newfile;
-	ip->i_merged[ ip->i_listlen-1 ] = FALSE;
-}
-
-void
-inc_clean (void)
-{
-	register struct inclist *ip;
-
-	for (ip = inclist; ip < inclistp; ip++) {
-		ip->i_flags &= ~MARKED;
-	}
-}
-
-struct inclist *
-inc_path(char *file, char *include, int type)
-{
-	static char		path[ BUFSIZ ];
-	register char		**pp, *p;
-	register struct inclist	*ip;
-
-	/*
-	 * Check all previously found include files for a path that
-	 * has already been expanded.
-	 */
-	if ((type == INCLUDE) || (type == INCLUDEDOT))
-		inclistnext = inclist;
-	ip = inclistnext;
-
-	for (; ip->i_file; ip++) {
-		if ((strcmp(ip->i_incstring, include) == 0) &&
-		    !(ip->i_flags & INCLUDED_SYM)) {
-			inclistnext = ip + 1;
-			return ip;
-		}
-	}
-
-	if (inclistnext == inclist) {
-		/*
-		 * If the path was surrounded by "" or is an absolute path,
-		 * then check the exact path provided.
-		 */
-		if ((type == INCLUDEDOT) ||
-		    (type == INCLUDENEXTDOT) ||
-		    (*include == '/')) {
-			if (does_file_exist(include))
-				return newinclude(include, include);
-			if (show_where_not)
-				warning1("\tnot in %s\n", include);
-		}
-
-		/*
-		 * If the path was surrounded by "" see if this include file is
-		 * in the directory of the file being parsed.
-		 */
-		if ((type == INCLUDEDOT) || (type == INCLUDENEXTDOT)) {
-			for (p=file+strlen(file); p>file; p--)
-				if (*p == '/')
-					break;
-			if (p == file) {
-				strcpy(path, include);
-			} else {
-				strncpy(path, file, (p-file) + 1);
-				path[ (p-file) + 1 ] = '\0';
-				strcpy(path + (p-file) + 1, include);
-			}
-			remove_dotdot(path);
-			if (does_file_exist(path))
-				return newinclude(path, include);
-			if (show_where_not)
-				warning1("\tnot in %s\n", path);
-		}
-	}
-
-	/*
-	 * Check the include directories specified.  Standard include dirs
-	 * should be at the end.
-	 */
-	if ((type == INCLUDE) || (type == INCLUDEDOT))
-		includedirsnext = includedirs;
-	pp = includedirsnext;
-
-	for (; *pp; pp++) {
-		sprintf(path, "%s/%s", *pp, include);
-		remove_dotdot(path);
-		if (does_file_exist(path)) {
-			includedirsnext = pp + 1;
-			return newinclude(path, include);
-		}
-		if (show_where_not)
-			warning1("\tnot in %s\n", path);
-	}
-
-	return NULL;
-}
deleted file mode 100644
--- a/config/mkdepend/main.c
+++ /dev/null
@@ -1,860 +0,0 @@
-/* $Xorg: main.c,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $ */
-/*
-
-Copyright (c) 1993, 1994, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/config/makedepend/main.c,v 3.32 2003/03/26 20:43:48 tsi Exp $ */
-
-#include "def.h"
-#ifdef hpux
-#define sigvec sigvector
-#endif /* hpux */
-
-#ifdef X_POSIX_C_SOURCE
-#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
-#include <signal.h>
-#undef _POSIX_C_SOURCE
-#else
-#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
-#include <signal.h>
-#else
-#define _POSIX_SOURCE
-#include <signal.h>
-#undef _POSIX_SOURCE
-#endif
-#endif
-
-#include <stdarg.h>
-
-#ifdef MINIX
-#define USE_CHMOD	1
-#endif
-
-#ifdef DEBUG
-int	_debugmask;
-#endif
-
-/* #define DEBUG_DUMP */
-#ifdef DEBUG_DUMP
-#define DBG_PRINT(file, fmt, args)   fprintf(file, fmt, args)
-#else
-#define DBG_PRINT(file, fmt, args)   /* empty */
-#endif
-
-#define DASH_INC_PRE    "#include \""
-#define DASH_INC_POST   "\""
-
-char *ProgramName;
-
-char	*directives[] = {
-	"if",
-	"ifdef",
-	"ifndef",
-	"else",
-	"endif",
-	"define",
-	"undef",
-	"include",
-	"line",
-	"pragma",
-	"error",
-	"ident",
-	"sccs",
-	"elif",
-	"eject",
-	"warning",
-	"include_next",
-	NULL
-};
-
-#define MAKEDEPEND
-#include "imakemdep.h"	/* from config sources */
-#undef MAKEDEPEND
-
-struct	inclist inclist[ MAXFILES ],
-		*inclistp = inclist,
-		*inclistnext = inclist,
-		maininclist;
-
-static char	*filelist[ MAXFILES ];
-char		*includedirs[ MAXDIRS + 1 ],
-		**includedirsnext = includedirs;
-char		*notdotdot[ MAXDIRS ];
-static int	cmdinc_count = 0;
-static char	*cmdinc_list[ 2 * MAXINCFILES ];
-char		*objprefix = "";
-char		*objsuffix = OBJSUFFIX;
-static char	*startat = "# DO NOT DELETE";
-int		width = 78;
-static boolean	append = FALSE;
-boolean		printed = FALSE;
-boolean		verbose = FALSE;
-boolean		show_where_not = FALSE;
-/* Warn on multiple includes of same file */
-boolean 	warn_multiple = FALSE;
-
-static void setfile_cmdinc(struct filepointer *filep, long count, char **list);
-static void redirect(char *line, char *makefile);
-
-static
-#ifdef SIGNALRETURNSINT
-int
-#else
-void
-#endif
-catch (int sig)
-{
-	fflush (stdout);
-	fatalerr ("got signal %d\n", sig);
-}
-
-#if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__UNIXOS2__) || defined(Lynx_22) || defined(__CYGWIN__)
-#define USGISH
-#endif
-
-#ifndef USGISH
-#ifdef X_NOT_POSIX
-#define sigaction sigvec
-#define sa_handler sv_handler
-#define sa_mask sv_mask
-#define sa_flags sv_flags
-#endif
-struct sigaction sig_act;
-#endif /* USGISH */
-
-int
-main(int argc, char *argv[])
-{
-	char	**fp = filelist;
-	char	**incp = includedirs;
-	char	*p;
-	struct inclist	*ip;
-	char	*makefile = NULL;
-	struct filepointer	*filecontent;
-	struct symtab *psymp = predefs;
-	char *endmarker = NULL;
-	char *defincdir = NULL;
-	char **undeflist = NULL;
-	int numundefs = 0, i;
-	register char offset;
-
-	ProgramName = argv[0];
-
-	while (psymp->s_name)
-	{
-	    define2(psymp->s_name, psymp->s_value, &maininclist);
-	    psymp++;
-	}
-	if (argc == 2 && argv[1][0] == '@') {
-	    struct stat ast;
-	    int afd;
-	    char *args;
-	    char **nargv;
-	    int nargc;
-	    char quotechar = '\0';
-
-	    nargc = 1;
-	    if ((afd = open(argv[1]+1, O_RDONLY)) < 0)
-		fatalerr("cannot open \"%s\"\n", argv[1]+1);
-	    fstat(afd, &ast);
-	    args = (char *)malloc(ast.st_size + 1);
-	    if ((ast.st_size = read(afd, args, ast.st_size)) < 0)
-		fatalerr("failed to read %s\n", argv[1]+1);
-	    args[ast.st_size] = '\0';
-	    close(afd);
-	    for (p = args; *p; p++) {
-		if (quotechar) {
-		    if (quotechar == '\\' ||
-			(*p == quotechar && p[-1] != '\\'))
-			quotechar = '\0';
-		    continue;
-		}
-		switch (*p) {
-		case '\\':
-		case '"':
-		case '\'':
-		    quotechar = *p;
-		    break;
-		case ' ':
-		case '\n':
-		    *p = '\0';
-		    if (p > args && p[-1])
-			nargc++;
-		    break;
-		}
-	    }
-	    if (p[-1])
-		nargc++;
-	    nargv = (char **)malloc(nargc * sizeof(char *));
-	    nargv[0] = argv[0];
-	    argc = 1;
-	    for (p = args; argc < nargc; p += strlen(p) + 1)
-		if (*p) nargv[argc++] = p;
-	    argv = nargv;
-	}
-	for(argc--, argv++; argc; argc--, argv++) {
-	    	/* if looking for endmarker then check before parsing */
-		if (endmarker && strcmp (endmarker, *argv) == 0) {
-		    endmarker = NULL;
-		    continue;
-		}
-		if (**argv != '-') {
-			/* treat +thing as an option for C++ */
-			if (endmarker && **argv == '+')
-				continue;
-			*fp++ = argv[0];
-			continue;
-		}
-		switch(argv[0][1]) {
-		case '-':
-			endmarker = &argv[0][2];
-			if (endmarker[0] == '\0') endmarker = "--";
-			break;
-		case 'D':
-			offset = 2;
-			if (argv[0][2] == '\0') {
-				argv++;
-				argc--;
-				offset = 0;
-			}
-			/* offset +1 here since first def letter
-			 * cannot be `=`
-			 */
-			for (p = argv[0] + offset + 1; *p; p++)
-				if (*p == '=') {
-					*p = ' ';
-					break;
-				}
-			define(argv[0] + offset, &maininclist);
-			break;
-		case 'I':
-			if (incp >= includedirs + MAXDIRS)
-			    fatalerr("Too many -I flags.\n");
-			*incp++ = argv[0]+2;
-			if (**(incp-1) == '\0') {
-				*(incp-1) = *(++argv);
-				argc--;
-			}
-			break;
-		case 'U':
-			/* Undef's override all -D's so save them up */
-			numundefs++;
-			if (numundefs == 1)
-			    undeflist = malloc(sizeof(char *));
-			else
-			    undeflist = realloc(undeflist,
-						numundefs * sizeof(char *));
-			offset = 2;
-			if (argv[0][2] == '\0') {
-				argv++;
-				argc--;
-				offset = 0;
-			}
-			undeflist[numundefs - 1] = argv[0] + offset;
-			break;
-		case 'Y':
-			defincdir = argv[0]+2;
-			break;
-		/* do not use if endmarker processing */
-		case 'a':
-			if (endmarker) break;
-			append = TRUE;
-			break;
-		case 'w':
-			if (endmarker) break;
-			if (argv[0][2] == '\0') {
-				argv++;
-				argc--;
-				width = atoi(argv[0]);
-			} else
-				width = atoi(argv[0]+2);
-			break;
-		case 'o':
-			if (endmarker) break;
-			if (argv[0][2] == '\0') {
-				argv++;
-				argc--;
-				objsuffix = argv[0];
-			} else
-				objsuffix = argv[0]+2;
-			break;
-		case 'p':
-			if (endmarker) break;
-			if (argv[0][2] == '\0') {
-				argv++;
-				argc--;
-				objprefix = argv[0];
-			} else
-				objprefix = argv[0]+2;
-			break;
-		case 'v':
-			if (endmarker) break;
-			verbose = TRUE;
-#ifdef DEBUG
-			if (argv[0][2])
-				_debugmask = atoi(argv[0]+2);
-#endif
-			break;
-		case 's':
-			if (endmarker) break;
-			startat = argv[0]+2;
-			if (*startat == '\0') {
-				startat = *(++argv);
-				argc--;
-			}
-			if (*startat != '#')
-				fatalerr("-s flag's value should start %s\n",
-					"with '#'.");
-			break;
-		case 'f':
-			if (endmarker) break;
-			makefile = argv[0]+2;
-			if (*makefile == '\0') {
-				makefile = *(++argv);
-				argc--;
-			}
-			break;
-
-		case 'm':
-			warn_multiple = TRUE;
-			break;
-			
-		/* Ignore -O, -g so we can just pass ${CFLAGS} to
-		   makedepend
-		 */
-		case 'O':
-		case 'g':
-			break;
-		case 'i':
-			if (strcmp(&argv[0][1],"include") == 0) {
-				char *buf;
-				if (argc<2)
-					fatalerr("option -include is a "
-						 "missing its parameter\n");
-				if (cmdinc_count >= MAXINCFILES)
-					fatalerr("Too many -include flags.\n");
-				argc--;
-				argv++;
-				buf = malloc(strlen(DASH_INC_PRE) +
-					     strlen(argv[0]) +
-					     strlen(DASH_INC_POST) + 1);
-                		if(!buf)
-					fatalerr("out of memory at "
-						 "-include string\n");
-				cmdinc_list[2 * cmdinc_count + 0] = argv[0];
-				cmdinc_list[2 * cmdinc_count + 1] = buf;
-				cmdinc_count++;
-				break;
-			}
-			/* intentional fall through */
-		default:
-			if (endmarker) break;
-	/*		fatalerr("unknown opt = %s\n", argv[0]); */
-			warning("ignoring option %s\n", argv[0]);
-		}
-	}
-	/* Now do the undefs from the command line */
-	for (i = 0; i < numundefs; i++)
-	    undefine(undeflist[i], &maininclist);
-	if (numundefs > 0)
-	    free(undeflist);
-
-	if (!defincdir) {
-#ifdef PREINCDIR
-	    if (incp >= includedirs + MAXDIRS)
-		fatalerr("Too many -I flags.\n");
-	    *incp++ = PREINCDIR;
-#endif
-#ifdef __UNIXOS2__
-	    {
-		char *emxinc = getenv("C_INCLUDE_PATH");
-		/* can have more than one component */
-		if (emxinc) {
-		    char *beg, *end;
-		    beg= (char*)strdup(emxinc);
-		    for (;;) {
-			end = (char*)strchr(beg,';');
-			if (end) *end = 0;
-		    	if (incp >= includedirs + MAXDIRS)
-				fatalerr("Too many include dirs\n");
-			*incp++ = beg;
-			if (!end) break;
-			beg = end+1;
-		    }
-		}
-	    }
-#else /* !__UNIXOS2__, does not use INCLUDEDIR at all */
-	    if (incp >= includedirs + MAXDIRS)
-		fatalerr("Too many -I flags.\n");
-	    *incp++ = INCLUDEDIR;
-#endif
-
-#ifdef EXTRAINCDIR
-	    if (incp >= includedirs + MAXDIRS)
-		fatalerr("Too many -I flags.\n");
-	    *incp++ = EXTRAINCDIR;
-#endif
-
-#ifdef POSTINCDIR
-	    if (incp >= includedirs + MAXDIRS)
-		fatalerr("Too many -I flags.\n");
-	    *incp++ = POSTINCDIR;
-#endif
-	} else if (*defincdir) {
-	    if (incp >= includedirs + MAXDIRS)
-		fatalerr("Too many -I flags.\n");
-	    *incp++ = defincdir;
-	}
-
-	redirect(startat, makefile);
-
-	/*
-	 * catch signals.
-	 */
-#ifdef USGISH
-/*  should really reset SIGINT to SIG_IGN if it was.  */
-#ifdef SIGHUP
-	signal (SIGHUP, catch);
-#endif
-	signal (SIGINT, catch);
-#ifdef SIGQUIT
-	signal (SIGQUIT, catch);
-#endif
-	signal (SIGILL, catch);
-#ifdef SIGBUS
-	signal (SIGBUS, catch);
-#endif
-	signal (SIGSEGV, catch);
-#ifdef SIGSYS
-	signal (SIGSYS, catch);
-#endif
-#else
-	sig_act.sa_handler = catch;
-#if defined(_POSIX_SOURCE) || !defined(X_NOT_POSIX)
-	sigemptyset(&sig_act.sa_mask);
-	sigaddset(&sig_act.sa_mask, SIGINT);
-	sigaddset(&sig_act.sa_mask, SIGQUIT);
-#ifdef SIGBUS
-	sigaddset(&sig_act.sa_mask, SIGBUS);
-#endif
-	sigaddset(&sig_act.sa_mask, SIGILL);
-	sigaddset(&sig_act.sa_mask, SIGSEGV);
-	sigaddset(&sig_act.sa_mask, SIGHUP);
-	sigaddset(&sig_act.sa_mask, SIGPIPE);
-#ifdef SIGSYS
-	sigaddset(&sig_act.sa_mask, SIGSYS);
-#endif
-#else
-	sig_act.sa_mask = ((1<<(SIGINT -1))
-			   |(1<<(SIGQUIT-1))
-#ifdef SIGBUS
-			   |(1<<(SIGBUS-1))
-#endif
-			   |(1<<(SIGILL-1))
-			   |(1<<(SIGSEGV-1))
-			   |(1<<(SIGHUP-1))
-			   |(1<<(SIGPIPE-1))
-#ifdef SIGSYS
-			   |(1<<(SIGSYS-1))
-#endif
-			   );
-#endif /* _POSIX_SOURCE */
-	sig_act.sa_flags = 0;
-	sigaction(SIGHUP, &sig_act, (struct sigaction *)0);
-	sigaction(SIGINT, &sig_act, (struct sigaction *)0);
-	sigaction(SIGQUIT, &sig_act, (struct sigaction *)0);
-	sigaction(SIGILL, &sig_act, (struct sigaction *)0);
-#ifdef SIGBUS
-	sigaction(SIGBUS, &sig_act, (struct sigaction *)0);
-#endif
-	sigaction(SIGSEGV, &sig_act, (struct sigaction *)0);
-#ifdef SIGSYS
-	sigaction(SIGSYS, &sig_act, (struct sigaction *)0);
-#endif
-#endif /* USGISH */
-
-	/*
-	 * now peruse through the list of files.
-	 */
-	for(fp=filelist; *fp; fp++) {
-		DBG_PRINT(stderr,"file: %s\n",*fp);
-		filecontent = getfile(*fp);
-		setfile_cmdinc(filecontent, cmdinc_count, cmdinc_list);
-		ip = newinclude(*fp, (char *)NULL);
-
-		find_includes(filecontent, ip, ip, 0, FALSE);
-		freefile(filecontent);
-		recursive_pr_include(ip, ip->i_file, base_name(*fp));
-		inc_clean();
-	}
-	if (printed)
-		printf("\n");
-	return 0;
-}
-
-#ifdef __UNIXOS2__
-/*
- * eliminate \r chars from file
- */
-static int 
-elim_cr(char *buf, int sz)
-{
-	int i,wp;
-	for (i= wp = 0; i<sz; i++) {
-		if (buf[i] != '\r')
-			buf[wp++] = buf[i];
-	}
-	return wp;
-}
-#endif
-
-struct filepointer *
-getfile(char *file)
-{
-	int	fd;
-	struct filepointer	*content;
-	struct stat	st;
-
-	content = (struct filepointer *)malloc(sizeof(struct filepointer));
-	content->f_name = file;
-	if ((fd = open(file, O_RDONLY)) < 0) {
-		warning("cannot open \"%s\"\n", file);
-		content->f_p = content->f_base = content->f_end = (char *)malloc(1);
-		*content->f_p = '\0';
-		return(content);
-	}
-	fstat(fd, &st);
-	content->f_base = (char *)malloc(st.st_size+1);
-	if (content->f_base == NULL)
-		fatalerr("cannot allocate mem\n");
-	if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0)
-		fatalerr("failed to read %s\n", file);
-#ifdef __UNIXOS2__
-	st.st_size = elim_cr(content->f_base,st.st_size);
-#endif
-	close(fd);
-	content->f_len = st.st_size+1;
-	content->f_p = content->f_base;
-	content->f_end = content->f_base + st.st_size;
-	*content->f_end = '\0';
-	content->f_line = 0;
-	content->cmdinc_count = 0;
-	content->cmdinc_list = NULL;
-	content->cmdinc_line = 0;
-	return(content);
-}
-
-void
-setfile_cmdinc(struct filepointer* filep, long count, char** list)
-{
-	filep->cmdinc_count = count;
-	filep->cmdinc_list = list;
-	filep->cmdinc_line = 0;
-}
-
-void
-freefile(struct filepointer *fp)
-{
-	free(fp->f_base);
-	free(fp);
-}
-
-char *copy(char *str)
-{
-	char	*p = (char *)malloc(strlen(str) + 1);
-
-	strcpy(p, str);
-	return(p);
-}
-
-int
-match(char *str, char **list)
-{
-	int	i;
-
-	for (i=0; *list; i++, list++)
-		if (strcmp(str, *list) == 0)
-			return(i);
-	return(-1);
-}
-
-/*
- * Get the next line.  We only return lines beginning with '#' since that
- * is all this program is ever interested in.
- */
-char *getnextline(struct filepointer *filep)
-{
-	char	*p,	/* walking pointer */
-		*eof,	/* end of file pointer */
-		*bol;	/* beginning of line pointer */
-	int	lineno;	/* line number */
-	boolean whitespace = FALSE;
-
-	/*
-	 * Fake the "-include" line files in form of #include to the
-	 * start of each file.
-	 */
-	if (filep->cmdinc_line < filep->cmdinc_count) {
-		char *inc = filep->cmdinc_list[2 * filep->cmdinc_line + 0];
-		char *buf = filep->cmdinc_list[2 * filep->cmdinc_line + 1];
-		filep->cmdinc_line++;
-		sprintf(buf,"%s%s%s",DASH_INC_PRE,inc,DASH_INC_POST);
-		DBG_PRINT(stderr,"%s\n",buf);
-		return(buf);
-	}
-
-	p = filep->f_p;
-	eof = filep->f_end;
-	if (p >= eof)
-		return((char *)NULL);
-	lineno = filep->f_line;
-
-	for (bol = p--; ++p < eof; ) {
-		if ((bol == p) && ((*p == ' ') || (*p == '\t')))
-		{
-			/* Consume leading white-spaces for this line */
-			while (((p+1) < eof) && ((*p == ' ') || (*p == '\t')))
-			{
-				p++;
-				bol++;
-			}
-			whitespace = TRUE;
-		}
-        
-		if (*p == '/' && (p+1) < eof && *(p+1) == '*') {
-			/* Consume C comments */
-			*(p++) = ' ';
-			*(p++) = ' ';
-			while (p < eof && *p) {
-				if (*p == '*' && (p+1) < eof && *(p+1) == '/') {
-					*(p++) = ' ';
-					*(p++) = ' ';
-					break;
-				}
-				if (*p == '\n')
-					lineno++;
-				*(p++) = ' ';
-			}
-			--p;
-		}
-		else if (*p == '/' && (p+1) < eof && *(p+1) == '/') {
-			/* Consume C++ comments */
-			*(p++) = ' ';
-			*(p++) = ' ';
-			while (p < eof && *p) {
-				if (*p == '\\' && (p+1) < eof &&
-				    *(p+1) == '\n') {
-					*(p++) = ' ';
-					lineno++;
-				}
-				else if (*p == '?' && (p+3) < eof &&
-					 *(p+1) == '?' && 
-					 *(p+2) == '/' &&
-					 *(p+3) == '\n') {
-					*(p++) = ' ';
-					*(p++) = ' ';
-					*(p++) = ' ';
-					lineno++;
-				}
-				else if (*p == '\n')
-					break;	/* to process end of line */
-				*(p++) = ' ';
-			}
-			--p;
-		}
-		else if (*p == '\\' && (p+1) < eof && *(p+1) == '\n') {
-			/* Consume backslash line terminations */
-			*(p++) = ' ';
-			*p = ' ';
-			lineno++;
-		}
-		else if (*p == '?' && (p+3) < eof &&
-			 *(p+1) == '?' && *(p+2) == '/' && *(p+3) == '\n') {
-			/* Consume trigraph'ed backslash line terminations */
-			*(p++) = ' ';
-			*(p++) = ' ';
-			*(p++) = ' ';
-			*p = ' ';
-			lineno++;
-		}
-		else if (*p == '\n') {
-			lineno++;
-			if (*bol == '#') {
-				char *cp;
-
-				*(p++) = '\0';
-				/* punt lines with just # (yacc generated) */
-				for (cp = bol+1; 
-				     *cp && (*cp == ' ' || *cp == '\t'); cp++);
-				if (*cp) goto done;
-				--p;
-			}
-			bol = p+1;
-			whitespace = FALSE;
-		}
-	}
-	if (*bol != '#')
-		bol = NULL;
-done:
-	if (bol && whitespace) {
-		warning("%s:  non-portable whitespace encountered at line %d\n",
-			filep->f_name, lineno);
-	}
-	filep->f_p = p;
-	filep->f_line = lineno;
-#ifdef DEBUG_DUMP
-	if (bol)
-		DBG_PRINT(stderr,"%s\n",bol);
-#endif
-	return(bol);
-}
-
-/*
- * Strip the file name down to what we want to see in the Makefile.
- * It will have objprefix and objsuffix around it.
- */
-char *base_name(char *file)
-{
-	char	*p;
-
-	file = copy(file);
-	for(p=file+strlen(file); p>file && *p != '.'; p--) ;
-
-	if (*p == '.')
-		*p = '\0';
-	return(file);
-}
-
-#if defined(USG) && !defined(CRAY) && !defined(SVR4) && !defined(__UNIXOS2__) && !defined(clipper) && !defined(__clipper__)
-int rename (char *from, char *to)
-{
-    (void) unlink (to);
-    if (link (from, to) == 0) {
-	unlink (from);
-	return 0;
-    } else {
-	return -1;
-    }
-}
-#endif /* USGISH */
-
-void
-redirect(char *line, char *makefile)
-{
-	struct stat	st;
-	FILE	*fdin, *fdout;
-	char	backup[ BUFSIZ ],
-		buf[ BUFSIZ ];
-	boolean	found = FALSE;
-	int	len;
-
-	/*
-	 * if makefile is "-" then let it pour onto stdout.
-	 */
-	if (makefile && *makefile == '-' && *(makefile+1) == '\0') {
-		puts(line);
-		return;
-	}
-
-	/*
-	 * use a default makefile is not specified.
-	 */
-	if (!makefile) {
-		if (stat("Makefile", &st) == 0)
-			makefile = "Makefile";
-		else if (stat("makefile", &st) == 0)
-			makefile = "makefile";
-		else
-			fatalerr("[mM]akefile is not present\n");
-	}
-	else
-	    stat(makefile, &st);
-	if ((fdin = fopen(makefile, "r")) == NULL)
-		fatalerr("cannot open \"%s\"\n", makefile);
-	sprintf(backup, "%s.bak", makefile);
-	unlink(backup);
-#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
-	fclose(fdin);
-#endif
-	if (rename(makefile, backup) < 0)
-		fatalerr("cannot rename %s to %s\n", makefile, backup);
-#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
-	if ((fdin = fopen(backup, "r")) == NULL)
-		fatalerr("cannot open \"%s\"\n", backup);
-#endif
-	if ((fdout = freopen(makefile, "w", stdout)) == NULL)
-		fatalerr("cannot open \"%s\"\n", backup);
-	len = strlen(line);
-	while (!found && fgets(buf, BUFSIZ, fdin)) {
-		if (*buf == '#' && strncmp(line, buf, len) == 0)
-			found = TRUE;
-		fputs(buf, fdout);
-	}
-	if (!found) {
-		if (verbose)
-		warning("Adding new delimiting line \"%s\" and dependencies...\n",
-			line);
-		puts(line); /* same as fputs(fdout); but with newline */
-	} else if (append) {
-	    while (fgets(buf, BUFSIZ, fdin)) {
-		fputs(buf, fdout);
-	    }
-	}
-	fflush(fdout);
-#if defined(USGISH) || defined(_SEQUENT_) || defined(USE_CHMOD)
-	chmod(makefile, st.st_mode);
-#else
-        fchmod(fileno(fdout), st.st_mode);
-#endif /* USGISH */
-}
-
-void
-fatalerr(char *msg, ...)
-{
-	va_list args;
-	fprintf(stderr, "%s: error:  ", ProgramName);
-	va_start(args, msg);
-	vfprintf(stderr, msg, args);
-	va_end(args);
-	exit (1);
-}
-
-void
-warning(char *msg, ...)
-{
-	va_list args;
-	fprintf(stderr, "%s: warning:  ", ProgramName);
-	va_start(args, msg);
-	vfprintf(stderr, msg, args);
-	va_end(args);
-}
-
-void
-warning1(char *msg, ...)
-{
-	va_list args;
-	va_start(args, msg);
-	vfprintf(stderr, msg, args);
-	va_end(args);
-}
deleted file mode 100644
--- a/config/mkdepend/mkdepend.man
+++ /dev/null
@@ -1,382 +0,0 @@
-.\" $Xorg: mkdepend.man,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $
-.\" Copyright (c) 1993, 1994, 1998 The Open Group
-.\" 
-.\" Permission to use, copy, modify, distribute, and sell this software and its
-.\" documentation for any purpose is hereby granted without fee, provided that
-.\" the above copyright notice appear in all copies and that both that
-.\" copyright notice and this permission notice appear in supporting
-.\" documentation.
-.\" 
-.\" The above copyright notice and this permission notice shall be included in
-.\" all copies or substantial portions of the Software.
-.\" 
-.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL 
-.\" THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
-.\" WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 
-.\" OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
-.\" SOFTWARE.
-.\" 
-.\" Except as contained in this notice, the name of The Open Group shall not 
-.\" be used in advertising or otherwise to promote the sale, use or other 
-.\" dealing in this Software without prior written authorization from The
-.\" Open Group.
-.\"
-.\" $XFree86: xc/config/makedepend/mkdepend.man,v 1.7 2002/12/14 02:39:45 dawes Exp $
-.\"
-.TH MAKEDEPEND 1 __xorgversion__
-.UC 4
-.SH NAME
-makedepend \- create dependencies in makefiles
-.SH SYNOPSIS
-.B makedepend
-[
-.BI \-D name\fB=\fPdef
-] [
-.BI \-D name
-] [
-.BI \-I includedir
-] [
-.BI \-Y includedir
-] [
-.B \-a
-] [
-.BI \-f makefile
-] [
-.BI \-include \ file
-] [
-.BI \-o objsuffix
-] [
-.BI \-p objprefix
-] [
-.BI \-s string
-] [
-.BI \-w width
-] [
-.B \-v
-] [
-.B \-m
-] [
-\-\^\-
-.I otheroptions
-\-\^\-
-]
-.I sourcefile
-\&.\|.\|.
-.br
-.SH DESCRIPTION
-The
-.B makedepend
-program reads each
-.I sourcefile
-in sequence and parses it like a C-preprocessor,
-processing all
-.I #include,
-.I #define,
-.I #undef,
-.I #ifdef,
-.I #ifndef,
-.I #endif,
-.I #if,
-.I #elif
-and
-.I #else
-directives so that it can correctly tell which
-.I #include,
-directives would be used in a compilation.
-Any
-.I #include,
-directives can reference files having other
-.I #include
-directives, and parsing will occur in these files as well.
-.PP
-Every file that a
-.I sourcefile
-includes,
-directly or indirectly,
-is what
-.B makedepend
-calls a \fIdependency.\fP
-These dependencies are then written to a
-.I makefile
-in such a way that
-.B make(1)
-will know which object files must be recompiled when a dependency has changed.
-.PP
-By default,
-.B makedepend
-places its output in the file named
-.I makefile
-if it exists, otherwise
-.I Makefile.
-An alternate makefile may be specified with the
-.B \-f
-option.
-It first searches the makefile for
-the line
-.sp
-\&    # DO NOT DELETE THIS LINE \-\^\- make depend depends on it.
-.sp
-or one provided with the
-.B \-s
-option,
-as a delimiter for the dependency output.
-If it finds it, it will delete everything
-following this to the end of the makefile
-and put the output after this line.
-If it doesn't find it, the program
-will append the string to the end of the makefile
-and place the output following that.
-For each
-.I sourcefile
-appearing on the command line,
-.B makedepend
-puts lines in the makefile of the form
-.sp
-     sourcefile.o:\0dfile .\|.\|.
-.sp
-Where \fIsourcefile.o\fP is the name from the command
-line with its suffix replaced with ``.o'',
-and \fIdfile\fP is a dependency discovered in a
-.I #include
-directive while parsing
-.I sourcefile
-or one of the files it included.
-.SH EXAMPLE
-Normally,
-.B makedepend
-will be used in a makefile target so that typing ``make depend'' will
-bring the dependencies up to date for the makefile.
-For example,
-.nf
-    SRCS\0=\0file1.c\0file2.c\0.\|.\|.
-    CFLAGS\0=\0\-O\0\-DHACK\0\-I\^.\^.\^/foobar\0\-xyz
-    depend:
-            makedepend\0\-\^\-\0$(CFLAGS)\0\-\^\-\0$(SRCS)
-.fi
-.SH OPTIONS
-The program
-will ignore any option that it does not understand so that you may use
-the same arguments that you would for
-.B cc(1).
-.TP 5
-.B \-D\fIname\fP=\fIdef\fP \fRor\fP \-D\fIname\fP
-Define.
-This places a definition for
-.I name
-in
-.B makedepend's
-symbol table.
-Without 
-.I =def\|
-the symbol becomes defined as ``1''.
-.TP 5
-.B \-I\fIincludedir\fP
-Include directory.
-This option tells
-.B makedepend
-to prepend
-.I includedir
-to its list of directories to search when it encounters
-a
-.I #include
-directive.
-By default,
-.B makedepend
-only searches the standard include directories (usually /usr/include
-and possibly a compiler-dependent directory).
-.TP 5
-.B \-Y\fIincludedir\fP
-Replace all of the standard include directories with the single specified
-include directory; you can omit the
-.I includedir
-to simply prevent searching the standard include directories.
-.TP 5
-.B \-a
-Append the dependencies to the end of the file instead of replacing them. 
-.TP 5
-.B \-f\fImakefile\fP
-Filename.
-This allows you to specify an alternate makefile in which
-.B makedepend
-can place its output.
-Specifying ``\-'' as the file name (i.e., \fB\-f\-\fP) sends the
-output to standard output instead of modifying an existing file.
-.TP 5
-.B \-include \fIfile\fP
-Process file as input, and include all the resulting output
-before processing the regular input file. This has the same
-affect as if the specified file is an include statement that
-appears before the very first line of the regular input file.
-.TP 5
-.B \-o\fIobjsuffix\fP
-Object file suffix.
-Some systems may have object files whose suffix is something other
-than ``.o''.
-This option allows you to specify another suffix, such as
-``.b'' with
-.I \-o.b
-or ``:obj''
-with
-.I \-o:obj
-and so forth.
-.TP 5
-.B \-p\fIobjprefix\fP
-Object file prefix.
-The prefix is prepended to the name of the object file. This is
-usually used to designate a different directory for the object file.
-The default is the empty string.
-.TP 5
-.B \-s\fIstring\fP
-Starting string delimiter.
-This option permits you to specify
-a different string for
-.B makedepend
-to look for in the makefile.
-.TP 5
-.B \-w\fIwidth\fP
-Line width.
-Normally,
-.B makedepend
-will ensure that every output line that it writes will be no wider than
-78 characters for the sake of readability.
-This option enables you to change this width.
-.TP 5
-.B \-v
-Verbose operation.
-This option causes 
-.B makedepend
-to emit the list of files included by each input file.
-.TP 5
-.B \-m
-Warn about multiple inclusion.
-This option causes 
-.B makedepend
-to produce a warning if any input file includes another file more than
-once.  In previous versions of 
-.B makedepend
-this was the default behavior; the default has been changed to better
-match the behavior of the C compiler, which does not consider multiple
-inclusion to be an error.  This option is provided for backward 
-compatibility, and to aid in debugging problems related to multiple
-inclusion.
-.TP 5
-.B "\-\^\- \fIoptions\fP \-\^\-"
-If
-.B makedepend
-encounters a double hyphen (\-\^\-) in the argument list,
-then any unrecognized argument following it
-will be silently ignored; a second double hyphen terminates this
-special treatment.
-In this way,
-.B makedepend
-can be made to safely ignore esoteric compiler arguments that might
-normally be found in a CFLAGS
-.B make
-macro (see the
-.B EXAMPLE
-section above).
-All options that
-.B makedepend
-recognizes and appear between the pair of double hyphens
-are processed normally.
-.SH ALGORITHM
-The approach used in this program enables it to run an order of magnitude
-faster than any other ``dependency generator'' I have ever seen.
-Central to this performance are two assumptions:
-that all files compiled by a single
-makefile will be compiled with roughly the same
-.I \-I
-and
-.I \-D
-options;
-and that most files in a single directory will include largely the
-same files.
-.PP
-Given these assumptions,
-.B makedepend
-expects to be called once for each makefile, with
-all source files that are maintained by the
-makefile appearing on the command line.
-It parses each source and include
-file exactly once, maintaining an internal symbol table
-for each.
-Thus, the first file on the command line will take an amount of time
-proportional to the amount of time that a normal C preprocessor takes.
-But on subsequent files, if it encounters an include file
-that it has already parsed, it does not parse it again.
-.PP
-For example,
-imagine you are compiling two files,
-.I file1.c
-and
-.I file2.c,
-they each include the header file
-.I header.h,
-and the file
-.I header.h
-in turn includes the files
-.I def1.h
-and
-.I def2.h.
-When you run the command
-.sp
-    makedepend\0file1.c\0file2.c
-.sp
-.B makedepend
-will parse
-.I file1.c
-and consequently,
-.I header.h
-and then
-.I def1.h
-and
-.I def2.h.
-It then decides that the dependencies for this file are
-.sp
-    file1.o:\0header.h\0def1.h\0def2.h
-.sp
-But when the program parses
-.I file2.c
-and discovers that it, too, includes
-.I header.h,
-it does not parse the file,
-but simply adds
-.I header.h,
-.I def1.h
-and
-.I def2.h
-to the list of dependencies for
-.I file2.o.
-.SH "SEE ALSO"
-cc(1), make(1)
-.SH BUGS
-.B makedepend
-parses, but does not currently evaluate, the SVR4 #predicate(token-list)
-preprocessor expression; such expressions are simply assumed to be true.
-This may cause the wrong
-.I #include
-directives to be evaluated.
-.PP
-Imagine you are parsing two files,
-say
-.I file1.c
-and
-.I file2.c,
-each includes the file
-.I def.h.
-The list of files that
-.I def.h
-includes might truly be different when
-.I def.h
-is included by
-.I file1.c
-than when it is included by
-.I file2.c.
-But once
-.B makedepend
-arrives at a list of dependencies for a file,
-it is cast in concrete.
-.SH AUTHOR
-Todd Brunhoff, Tektronix, Inc. and MIT Project Athena
deleted file mode 100644
--- a/config/mkdepend/parse.c
+++ /dev/null
@@ -1,686 +0,0 @@
-/* $Xorg: parse.c,v 1.6 2001/02/09 02:03:16 xorgcvs Exp $ */
-/*
-
-Copyright (c) 1993, 1994, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/config/makedepend/parse.c,v 1.12 2002/02/26 05:09:10 tsi Exp $ */
-
-#include "def.h"
-
-extern char	*directives[];
-extern struct inclist	inclist[ MAXFILES ],
-			*inclistnext,
-			maininclist;
-extern char	*includedirs[ ],
-		**includedirsnext;
-
-static int deftype (char *line, struct filepointer *filep,
-		    struct inclist *file_red, struct inclist *file,
-		    int parse_it);
-static int zero_value(char *filename, char *exp, struct filepointer *filep,
-		    struct inclist *file_red);
-static int merge2defines(struct inclist *file1, struct inclist *file2);
-
-static int
-gobble(struct filepointer *filep, struct inclist *file,
-       struct inclist *file_red)
-{
-	char	*line;
-	int	type;
-
-	while ((line = getnextline(filep))) {
-		switch(type = deftype(line, filep, file_red, file, FALSE)) {
-		case IF:
-		case IFFALSE:
-		case IFGUESSFALSE:
-		case IFDEF:
-		case IFNDEF:
-			type = gobble(filep, file, file_red);
-			while ((type == ELIF) || (type == ELIFFALSE) ||
-			       (type == ELIFGUESSFALSE))
-			    type = gobble(filep, file, file_red);
-			if (type == ELSE)
-			        (void)gobble(filep, file, file_red);
-			break;
-		case ELSE:
-		case ENDIF:
-			debug(0,("%s, line %d: #%s\n",
-				file->i_file, filep->f_line,
-				directives[type]));
-			return(type);
-		case DEFINE:
-		case UNDEF:
-		case INCLUDE:
-		case INCLUDEDOT:
-		case PRAGMA:
-		case ERROR:
-		case IDENT:
-		case SCCS:
-		case EJECT:
-		case WARNING:
-		case INCLUDENEXT:
-		case INCLUDENEXTDOT:
-			break;
-		case ELIF:
-		case ELIFFALSE:
-		case ELIFGUESSFALSE:
-			return(type);
-		case -1:
-			warning("%s", file_red->i_file);
-			if (file_red != file)
-				warning1(" (reading %s)", file->i_file);
-			warning1(", line %d: unknown directive == \"%s\"\n",
-				filep->f_line, line);
-			break;
-		}
-	}
-	return(-1);
-}
-
-/*
- * Decide what type of # directive this line is.
- */
-static int 
-deftype (char *line, struct filepointer *filep, 
-	     struct inclist *file_red, struct inclist *file, int parse_it)
-{
-	register char	*p;
-	char	*directive, savechar, *q;
-	register int	ret;
-
-	/*
-	 * Parse the directive...
-	 */
-	directive=line+1;
-	while (*directive == ' ' || *directive == '\t')
-		directive++;
-
-	p = directive;
-	while ((*p == '_') || (*p >= 'a' && *p <= 'z'))
-		p++;
-	savechar = *p;
-	*p = '\0';
-	ret = match(directive, directives);
-	*p = savechar;
-
-	/* If we don't recognize this compiler directive or we happen to just
-	 * be gobbling up text while waiting for an #endif or #elif or #else
-	 * in the case of an #elif we must check the zero_value and return an
-	 * ELIF or an ELIFFALSE.
-	 */
-
-	if (ret == ELIF && !parse_it)
-	{
-	    while (*p == ' ' || *p == '\t')
-		p++;
-	    /*
-	     * parse an expression.
-	     */
-	    debug(0,("%s, line %d: #elif %s ",
-		   file->i_file, filep->f_line, p));
-	    ret = zero_value(file->i_file, p, filep, file_red);
-	    if (ret != IF)
-	    {
-		debug(0,("false...\n"));
-		if (ret == IFFALSE)
-		    return(ELIFFALSE);
-		else
-		    return(ELIFGUESSFALSE);
-	    }
-	    else
-	    {
-		debug(0,("true...\n"));
-		return(ELIF);
-	    }
-	}
-
-	if (ret < 0 || ! parse_it)
-		return(ret);
-
-	/*
-	 * now decide how to parse the directive, and do it.
-	 */
-	while (*p == ' ' || *p == '\t')
-		p++;
-	q = p + strlen(p);
-	do {
-		q--;
-	} while (*q == ' ' || *q == '\t');
-	q[1] = '\0';
-	switch (ret) {
-	case IF:
-		/*
-		 * parse an expression.
-		 */
-		ret = zero_value(file->i_file, p, filep, file_red);
-		debug(0,("%s, line %d: %s #if %s\n",
-			 file->i_file, filep->f_line, ret?"false":"true", p));
-		break;
-	case IFDEF:
-	case IFNDEF:
-		debug(0,("%s, line %d: #%s %s\n",
-			file->i_file, filep->f_line, directives[ret], p));
-	case UNDEF:
-		/*
-		 * separate the name of a single symbol.
-		 */
-		while (isalnum(*p) || *p == '_')
-			*line++ = *p++;
-		*line = '\0';
-		break;
-	case INCLUDE:
-	case INCLUDENEXT:
-		debug(2,("%s, line %d: #include%s %s\n",
-			file->i_file, filep->f_line,
-			(ret == INCLUDE) ? "" : "_next", p));
-
-		/* Support ANSI macro substitution */
-		while (1) {
-			struct symtab **sym;
-
-			if (!*p || *p == '"' || *p == '<')
-				break;
-
-		    	sym = isdefined(p, file_red, NULL);
-			if (!sym)
-				break;
-
-			p = (*sym)->s_value;
-			debug(3,("%s : #includes SYMBOL %s = %s\n",
-			       file->i_incstring,
-			       (*sym) -> s_name,
-			       (*sym) -> s_value));
-			/* mark file as having included a 'soft include' */
-			file->i_flags |= INCLUDED_SYM; 
-		}
-
-		/*
-		 * Separate the name of the include file.
-		 */
-		while (*p && *p != '"' && *p != '<')
-			p++;
-		if (! *p)
-			return(-2);
-		if (*p++ == '"') {
-			if (ret == INCLUDE)
-				ret = INCLUDEDOT;
-			else
-				ret = INCLUDENEXTDOT;
-			while (*p && *p != '"')
-				*line++ = *p++;
-		} else
-			while (*p && *p != '>')
-				*line++ = *p++;
-		*line = '\0';
-		break;
-	case DEFINE:
-		/*
-		 * copy the definition back to the beginning of the line.
-		 */
-		strcpy (line, p);
-		break;
-	case ELSE:
-	case ENDIF:
-	case ELIF:
-	case PRAGMA:
-	case ERROR:
-	case IDENT:
-	case SCCS:
-	case EJECT:
-	case WARNING:
-		debug(0,("%s, line %d: #%s\n",
-			file->i_file, filep->f_line, directives[ret]));
-		/*
-		 * nothing to do.
-		 */
-		break;
-	}
-	return(ret);
-}
-
-struct symtab **
-fdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
-{
-	struct inclist	**ip;
-	struct symtab	**val;
-	int	i;
-	static int	recurse_lvl = 0;
-
-	if (file->i_flags & DEFCHECKED)
-		return(NULL);
-	debug(2,("Looking for %s in %s\n", symbol, file->i_file));
-	file->i_flags |= DEFCHECKED;
-	if ((val = slookup(symbol, file)))
-		debug(1,("%s defined in %s as %s\n",
-			 symbol, file->i_file, (*val)->s_value));
-	if (val == NULL && file->i_list)
-	{
-		for (ip = file->i_list, i=0; i < file->i_listlen; i++, ip++)
-			if (file->i_merged[i]==FALSE) {
-				val = fdefined(symbol, *ip, srcfile);
-				file->i_merged[i]=merge2defines(file,*ip);
-				if (val!=NULL) break;
-			}
-	}
-	else if (val != NULL && srcfile != NULL) *srcfile = file;
-	recurse_lvl--;
-	file->i_flags &= ~DEFCHECKED;
-
-	return(val);
-}
-
-struct symtab **
-isdefined(char *symbol, struct inclist *file, struct inclist **srcfile)
-{
-	struct symtab	**val;
-
-	if ((val = slookup(symbol, &maininclist))) {
-		debug(1,("%s defined on command line\n", symbol));
-		if (srcfile != NULL) *srcfile = &maininclist;
-		return(val);
-	}
-	if ((val = fdefined(symbol, file, srcfile)))
-		return(val);
-	debug(1,("%s not defined in %s\n", symbol, file->i_file));
-	return(NULL);
-}
-
-/*
- * Return type based on if the #if expression evaluates to 0
- */
-static int
-zero_value(char *filename,
-	   char *exp,
-	   struct filepointer *filep,
-	   struct inclist *file_red)
-{
-	if (cppsetup(filename, exp, filep, file_red))
-	    return(IFFALSE);
-	else
-	    return(IF);
-}
-
-void
-define2(char *name, char *val, struct inclist *file)
-{
-    int first, last, below;
-    register struct symtab **sp = NULL, **dest;
-    struct symtab *stab;
-
-    /* Make space if it's needed */
-    if (file->i_defs == NULL)
-    {
-	file->i_defs = (struct symtab **)
-			malloc(sizeof (struct symtab*) * SYMTABINC);
-	file->i_ndefs = 0;
-    }
-    else if (!(file->i_ndefs % SYMTABINC))
-	file->i_defs = (struct symtab **)
-			realloc(file->i_defs,
-			   sizeof(struct symtab*)*(file->i_ndefs+SYMTABINC));
-
-    if (file->i_defs == NULL)
-	fatalerr("malloc()/realloc() failure in insert_defn()\n");
-
-    below = first = 0;
-    last = file->i_ndefs - 1;
-    while (last >= first)
-    {
-	/* Fast inline binary search */
-	register char *s1;
-	register char *s2;
-	register int middle = (first + last) / 2;
-
-	/* Fast inline strchr() */
-	s1 = name;
-	s2 = file->i_defs[middle]->s_name;
-	while (*s1++ == *s2++)
-	    if (s2[-1] == '\0') break;
-
-	/* If exact match, set sp and break */
-	if (*--s1 == *--s2) 
-	{
-	    sp = file->i_defs + middle;
-	    break;
-	}
-
-	/* If name > i_defs[middle] ... */
-	if (*s1 > *s2) 
-	{
-	    below = first;
-	    first = middle + 1;
-	}
-	/* else ... */
-	else
-	{
-	    below = last = middle - 1;
-	}
-    }
-
-    /* Search is done.  If we found an exact match to the symbol name,
-       just replace its s_value */
-    if (sp != NULL)
-    {
-	debug(1,("redefining %s from %s to %s in file %s\n",
-		name, (*sp)->s_value, val, file->i_file));
-	free((*sp)->s_value);
-	(*sp)->s_value = copy(val);
-	return;
-    }
-
-    sp = file->i_defs + file->i_ndefs++;
-    dest = file->i_defs + below + 1;
-    while (sp > dest)
-    {
-	*sp = sp[-1];
-	sp--;
-    }
-    stab = (struct symtab *) malloc(sizeof (struct symtab));
-    if (stab == NULL)
-	fatalerr("malloc()/realloc() failure in insert_defn()\n");
-
-    debug(1,("defining %s to %s in file %s\n", name, val, file->i_file));
-    stab->s_name = copy(name);
-    stab->s_value = copy(val);
-    *sp = stab;
-}
-
-void
-define(char *def, struct inclist *file)
-{
-    char *val;
-
-    /* Separate symbol name and its value */
-    val = def;
-    while (isalnum(*val) || *val == '_')
-	val++;
-    if (*val)
-	*val++ = '\0';
-    while (*val == ' ' || *val == '\t')
-	val++;
-
-    if (!*val)
-	val = "1";
-    define2(def, val, file);
-}
-
-struct symtab **
-slookup(char *symbol, struct inclist *file)
-{
-	register int first = 0;
-	register int last = file->i_ndefs - 1;
-
-	if (file) while (last >= first)
-	{
-	    /* Fast inline binary search */
-	    register char *s1;
-	    register char *s2;
-	    register int middle = (first + last) / 2;
-
-	    /* Fast inline strchr() */
-	    s1 = symbol;
-	    s2 = file->i_defs[middle]->s_name;
-	    while (*s1++ == *s2++)
-	        if (s2[-1] == '\0') break;
-
-	    /* If exact match, we're done */
-	    if (*--s1 == *--s2) 
-	    {
-	        return file->i_defs + middle;
-	    }
-
-	    /* If symbol > i_defs[middle] ... */
-	    if (*s1 > *s2) 
-	    {
-	        first = middle + 1;
-	    }
-	    /* else ... */
-	    else
-	    {
-	        last = middle - 1;
-	    }
-	}
-	return(NULL);
-}
-
-static int 
-merge2defines(struct inclist *file1, struct inclist *file2)
-{
-	int i;
-
-	if ((file1==NULL) || (file2==NULL) ||
-	    !(file2->i_flags & FINISHED))
-		return 0;
-
-	for (i=0; i < file2->i_listlen; i++)
-		if (file2->i_merged[i]==FALSE)
-			return 0;
-
-	{
-		int first1 = 0;
-		int last1 = file1->i_ndefs - 1;
-
-		int first2 = 0;
-		int last2 = file2->i_ndefs - 1;
-
-                int first=0;
-                struct symtab** i_defs = NULL;
-		int deflen=file1->i_ndefs+file2->i_ndefs;
-
-		debug(2,("merging %s into %s\n",
-			file2->i_file, file1->i_file));
-
-                if (deflen>0)
-                { 
-                	/* make sure deflen % SYMTABINC == 0 is still true */
-                	deflen += (SYMTABINC - deflen % SYMTABINC) % SYMTABINC;
-                	i_defs=(struct symtab**)
-			    malloc(deflen*sizeof(struct symtab*));
-                	if (i_defs==NULL) return 0;
-        	}
-
-        	while ((last1 >= first1) && (last2 >= first2))
-        	{
-	    		char *s1=file1->i_defs[first1]->s_name;
-	    		char *s2=file2->i_defs[first2]->s_name;
-
-     			if (strcmp(s1,s2) < 0)
-                        	i_defs[first++]=file1->i_defs[first1++];
-     			else if (strcmp(s1,s2) > 0)
-                        	i_defs[first++]=file2->i_defs[first2++];
-                        else /* equal */
-                        {
-                        	i_defs[first++]=file2->i_defs[first2++];
-                                first1++;
-                        }
-        	}
-        	while (last1 >= first1)
-        	{
-                        i_defs[first++]=file1->i_defs[first1++];
-        	}
-        	while (last2 >= first2)
-        	{
-                        i_defs[first++]=file2->i_defs[first2++];
-        	}
-
-                if (file1->i_defs) free(file1->i_defs);
-                file1->i_defs=i_defs;
-                file1->i_ndefs=first;
-                
-		return 1;
-  	}
-}
-
-void
-undefine(char *symbol, struct inclist *file)
-{
-	register struct symtab **ptr;
-	struct inclist *srcfile;
-	while ((ptr = isdefined(symbol, file, &srcfile)) != NULL)
-	{
-	    srcfile->i_ndefs--;
-	    for (; ptr < srcfile->i_defs + srcfile->i_ndefs; ptr++)
-		*ptr = ptr[1];
-	}
-}
-
-int
-find_includes(struct filepointer *filep, struct inclist *file, 
-	      struct inclist *file_red, int recursion, boolean failOK)
-{
-	struct inclist	*inclistp;
-	char		**includedirsp;
-	register char	*line;
-	register int	type;
-	boolean recfailOK;
-
-	while ((line = getnextline(filep))) {
-		switch(type = deftype(line, filep, file_red, file, TRUE)) {
-		case IF:
-		doif:
-			type = find_includes(filep, file,
-				file_red, recursion+1, failOK);
-			while ((type == ELIF) || (type == ELIFFALSE) ||
-			       (type == ELIFGUESSFALSE))
-				type = gobble(filep, file, file_red);
-			if (type == ELSE)
-				gobble(filep, file, file_red);
-			break;
-		case IFFALSE:
-		case IFGUESSFALSE:
-		    doiffalse:
-			if (type == IFGUESSFALSE || type == ELIFGUESSFALSE)
-			    recfailOK = TRUE;
-			else
-			    recfailOK = failOK;
-			type = gobble(filep, file, file_red);
-			if (type == ELSE)
-			    find_includes(filep, file,
-					  file_red, recursion+1, recfailOK);
-			else
-			if (type == ELIF)
-			    goto doif;
-			else
-			if ((type == ELIFFALSE) || (type == ELIFGUESSFALSE))
-			    goto doiffalse;
-			break;
-		case IFDEF:
-		case IFNDEF:
-			if ((type == IFDEF && isdefined(line, file_red, NULL))
-			 || (type == IFNDEF && !isdefined(line, file_red, NULL))) {
-				debug(1,(type == IFNDEF ?
-				    "line %d: %s !def'd in %s via %s%s\n" : "",
-				    filep->f_line, line,
-				    file->i_file, file_red->i_file, ": doit"));
-				type = find_includes(filep, file,
-					file_red, recursion+1, failOK);
-				while (type == ELIF || type == ELIFFALSE || type == ELIFGUESSFALSE)
-					type = gobble(filep, file, file_red);
-				if (type == ELSE)
-					gobble(filep, file, file_red);
-			}
-			else {
-				debug(1,(type == IFDEF ?
-				    "line %d: %s !def'd in %s via %s%s\n" : "",
-				    filep->f_line, line,
-				    file->i_file, file_red->i_file, ": gobble"));
-				type = gobble(filep, file, file_red);
-				if (type == ELSE)
-					find_includes(filep, file,
-						file_red, recursion+1, failOK);
-				else if (type == ELIF)
-				    	goto doif;
-				else if (type == ELIFFALSE || type == ELIFGUESSFALSE)
-				    	goto doiffalse;
-			}
-			break;
-		case ELSE:
-		case ELIFFALSE:
-		case ELIFGUESSFALSE:
-		case ELIF:
-			if (!recursion)
-				gobble(filep, file, file_red);
-		case ENDIF:
-			if (recursion)
-				return(type);
-		case DEFINE:
-			define(line, file);
-			break;
-		case UNDEF:
-			if (!*line) {
-			    warning("%s", file_red->i_file);
-			    if (file_red != file)
-				warning1(" (reading %s)", file->i_file);
-			    warning1(", line %d: incomplete undef == \"%s\"\n",
-				filep->f_line, line);
-			    break;
-			}
-			undefine(line, file_red);
-			break;
-		case INCLUDE:
-		case INCLUDEDOT:
-		case INCLUDENEXT:
-		case INCLUDENEXTDOT:
-			inclistp = inclistnext;
-			includedirsp = includedirsnext;
-			debug(2,("%s, reading %s, includes %s\n",
-				file_red->i_file, file->i_file, line));
-			add_include(filep, file, file_red, line, type, failOK);
-			inclistnext = inclistp;
-			includedirsnext = includedirsp;
-			break;
-		case ERROR:
-		case WARNING:
-		    	warning("%s", file_red->i_file);
-			if (file_red != file)
-				warning1(" (reading %s)", file->i_file);
-			warning1(", line %d: %s\n",
-				 filep->f_line, line);
-		    	break;
-		    
-		case PRAGMA:
-		case IDENT:
-		case SCCS:
-		case EJECT:
-			break;
-		case -1:
-			warning("%s", file_red->i_file);
-			if (file_red != file)
-			    warning1(" (reading %s)", file->i_file);
-			warning1(", line %d: unknown directive == \"%s\"\n",
-				 filep->f_line, line);
-			break;
-		case -2:
-			warning("%s", file_red->i_file);
-			if (file_red != file)
-			    warning1(" (reading %s)", file->i_file);
-			warning1(", line %d: incomplete include == \"%s\"\n",
-				 filep->f_line, line);
-			break;
-		}
-	}
-	file->i_flags |= FINISHED;
-	debug(2,("finished with %s\n", file->i_file));
-	return(-1);
-}
deleted file mode 100644
--- a/config/mkdepend/pr.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* $Xorg: pr.c,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
-/*
-
-Copyright (c) 1993, 1994, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/config/makedepend/pr.c,v 1.5 2001/12/14 19:53:21 dawes Exp $ */
-
-#include "def.h"
-
-extern struct	inclist	inclist[ MAXFILES ],
-			*inclistp;
-extern char	*objprefix;
-extern char	*objsuffix;
-extern int	width;
-extern boolean	printed;
-extern boolean	verbose;
-extern boolean	show_where_not;
-
-void
-add_include(struct filepointer *filep, struct inclist *file, 
-	    struct inclist *file_red, char *include, int type,
-	    boolean failOK)
-{
-	register struct inclist	*newfile;
-	register struct filepointer	*content;
-
-	/*
-	 * First decide what the pathname of this include file really is.
-	 */
-	newfile = inc_path(file->i_file, include, type);
-	if (newfile == NULL) {
-		if (failOK)
-		    return;
-		if (file != file_red)
-			warning("%s (reading %s, line %d): ",
-				file_red->i_file, file->i_file, filep->f_line);
-		else
-			warning("%s, line %d: ", file->i_file, filep->f_line);
-		warning1("cannot find include file \"%s\"\n", include);
-		show_where_not = TRUE;
-		newfile = inc_path(file->i_file, include, type);
-		show_where_not = FALSE;
-	}
-
-	if (newfile) {
-		included_by(file, newfile);
-		if (!(newfile->i_flags & SEARCHED)) {
-			newfile->i_flags |= SEARCHED;
-			content = getfile(newfile->i_file);
-			find_includes(content, newfile, file_red, 0, failOK);
-			freefile(content);
-		}
-	}
-}
-
-static void
-pr(struct inclist *ip, char *file, char *base)
-{
-	static char	*lastfile;
-	static int	current_len;
-	register int	len, i;
-	char	buf[ BUFSIZ ];
-
-	printed = TRUE;
-	len = strlen(ip->i_file)+1;
-	if (current_len + len > width || file != lastfile) {
-		lastfile = file;
-		sprintf(buf, "\n%s%s%s: %s", objprefix, base, objsuffix,
-			ip->i_file);
-		len = current_len = strlen(buf);
-	}
-	else {
-		buf[0] = ' ';
-		strcpy(buf+1, ip->i_file);
-		current_len += len;
-	}
-	fwrite(buf, len, 1, stdout);
-
-	/*
-	 * If verbose is set, then print out what this file includes.
-	 */
-	if (! verbose || ip->i_list == NULL || ip->i_flags & NOTIFIED)
-		return;
-	ip->i_flags |= NOTIFIED;
-	lastfile = NULL;
-	printf("\n# %s includes:", ip->i_file);
-	for (i=0; i<ip->i_listlen; i++)
-		printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
-}
-
-void
-recursive_pr_include(struct inclist *head, char *file, char *base)
-{
-	int	i;
-
-	if (head->i_flags & MARKED)
-		return;
-	head->i_flags |= MARKED;
-	if (head->i_file != file)
-		pr(head, file, base);
-	for (i=0; i<head->i_listlen; i++)
-		recursive_pr_include(head->i_list[ i ], file, base);
-}
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -289,23 +289,16 @@ HOST_CCOBJS = $(addprefix host_,$(patsub
 HOST_CPPOBJS = $(addprefix host_,$(patsubst %.cpp,%.$(OBJ_SUFFIX),$(filter %.cpp,$(HOST_CPPSRCS))))
 HOST_CMOBJS = $(addprefix host_,$(HOST_CMSRCS:.m=.$(OBJ_SUFFIX)))
 HOST_CMMOBJS = $(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
 ifndef HOST_OBJS
 _HOST_OBJS = $(HOST_COBJS) $(HOST_CCOBJS) $(HOST_CPPOBJS) $(HOST_CMOBJS) $(HOST_CMMOBJS)
 HOST_OBJS = $(strip $(_HOST_OBJS))
 endif
 
-ifndef MOZ_AUTO_DEPS
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
-MDDEPFILES		= $(addprefix $(MDDEPDIR)/,$(OBJS:=.pp))
-MDDEPFILES		+= $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.h.pp) $(XPIDLSRCS:.idl=.xpt.pp))
-endif
-endif
-
 ALL_TRASH = \
 	$(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
 	$(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
 	$(OBJS:.$(OBJ_SUFFIX)=.i) $(OBJS:.$(OBJ_SUFFIX)=.i_o) \
 	$(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) $(DEF_FILE)\
 	$(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
 	$(wildcard *.pdb) $(CODFILE) $(MAPFILE) $(IMPORT_LIBRARY) \
 	$(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
@@ -912,53 +905,32 @@ endif	# WINNT && !GCC
 	chmod +x $@
 ifdef ENABLE_STRIP
 	$(STRIP) $@
 endif
 ifdef MOZ_POST_DSO_LIB_COMMAND
 	$(MOZ_POST_DSO_LIB_COMMAND) $@
 endif
 
-ifdef MOZ_AUTO_DEPS
-ifdef COMPILER_DEPEND
 ifeq ($(SOLARIS_SUNPRO_CC),1)
 _MDDEPFILE = $(MDDEPDIR)/$(@F).pp
 
 define MAKE_DEPS_AUTO_CC
 if test -d $(@D); then \
 	echo "Building deps for $< using Sun Studio cc"; \
 	$(CC) $(COMPILE_CFLAGS) -xM  $< >$(_MDDEPFILE) ; \
 fi
 endef
 define MAKE_DEPS_AUTO_CXX
 if test -d $(@D); then \
 	echo "Building deps for $< using Sun Studio CC"; \
 	$(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
 fi
 endef
 endif # Sun Studio on Solaris
-else # COMPILER_DEPEND
-#
-# Generate dependencies on the fly
-#
-_MDDEPFILE = $(MDDEPDIR)/$(@F).pp
-
-define MAKE_DEPS_AUTO
-if test -d $(@D); then \
-	echo "Building deps for $<"; \
-	$(MKDEPEND) -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $(_MDDEPFILE) ; \
-fi
-endef
-
-MAKE_DEPS_AUTO_CC = $(MAKE_DEPS_AUTO)
-MAKE_DEPS_AUTO_CXX = $(MAKE_DEPS_AUTO)
-
-endif # COMPILER_DEPEND
-
-endif # MOZ_AUTO_DEPS
 
 $(OBJS) $(HOST_OBJS): $(GLOBAL_DEPS)
 
 # Rules for building native targets must come first because of the host_ prefix
 $(HOST_COBJS): host_%.$(OBJ_SUFFIX): %.c
 	$(REPORT_BUILD)
 	$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
 
@@ -1508,75 +1480,16 @@ endif
 libs::
 	$(RM) -r "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
 	$(NSINSTALL) -D "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
 	cd $(FINAL_TARGET) && tar $(TAR_CREATE_FLAGS) - . | (cd "../../bin/extensions/$(INSTALL_EXTENSION_ID)" && tar -xf -)
 
 endif
 
 #############################################################################
-# Dependency system
-#############################################################################
-ifdef COMPILER_DEPEND
-depend::
-	@echo "$(MAKE): No need to run depend target.\
-			Using compiler-based depend." 1>&2
-ifeq ($(GNU_CC)$(GNU_CXX),)
-# Non-GNU compilers
-	@echo "`echo '$(MAKE):'|sed 's/./ /g'`"\
-	'(Compiler-based depend was turned on by "--enable-md".)' 1>&2
-else
-# GNU compilers
-	@space="`echo '$(MAKE): '|sed 's/./ /g'`";\
-	echo "$$space"'Since you are using a GNU compiler,\
-		it is on by default.' 1>&2; \
-	echo "$$space"'To turn it off, pass --disable-md to configure.' 1>&2
-endif
-
-else # ! COMPILER_DEPEND
-
-ifndef MOZ_AUTO_DEPS
-
-define MAKE_DEPS_NOAUTO
-	$(MKDEPEND) -w1024 -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $@
-endef
-
-$(MDDEPDIR)/%.pp: %.c
-	$(REPORT_BUILD)
-	@$(MAKE_DEPS_NOAUTO)
-
-$(MDDEPDIR)/%.pp: %.cpp
-	$(REPORT_BUILD)
-	@$(MAKE_DEPS_NOAUTO)
-
-$(MDDEPDIR)/%.pp: %.s
-	$(REPORT_BUILD)
-	@$(MAKE_DEPS_NOAUTO)
-
-ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
-depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
-else
-depend:: $(SUBMAKEFILES)
-endif
-	$(LOOP_OVER_PARALLEL_DIRS)
-	$(LOOP_OVER_DIRS)
-	$(LOOP_OVER_TOOL_DIRS)
-
-dependclean:: $(SUBMAKEFILES)
-	$(RM) $(MDDEPFILES)
-	$(LOOP_OVER_PARALLEL_DIRS)
-	$(LOOP_OVER_DIRS)
-	$(LOOP_OVER_TOOL_DIRS)
-
-endif # MOZ_AUTO_DEPS
-
-endif # COMPILER_DEPEND
-
-
-#############################################################################
 # MDDEPDIR is the subdirectory where all the dependency files are placed.
 #   This uses a make rule (instead of a macro) to support parallel
 #   builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
 #   processes could simultaneously try to create the same directory.
 #
 #   We use $(CURDIR) in the rule's target to ensure that we don't find
 #   a dependency directory in the source tree via VPATH (perhaps from
 #   a previous build in the source tree) and thus neglect to create a
--- a/configure.in
+++ b/configure.in
@@ -823,17 +823,16 @@ MOZ_PATH_PROG(AUTOCONF, autoconf, :)
 MOZ_PATH_PROGS(UNZIP, unzip)
 if test -z "$UNZIP" -o "$UNZIP" = ":"; then
     AC_MSG_ERROR([unzip not found in \$PATH])
 fi
 MOZ_PATH_PROGS(ZIP, zip)
 if test -z "$ZIP" -o "$ZIP" = ":"; then
     AC_MSG_ERROR([zip not found in \$PATH])
 fi
-MOZ_PATH_PROG(MOZ_NATIVE_MAKEDEPEND, makedepend)
 MOZ_PATH_PROG(XARGS, xargs)
 if test -z "$XARGS" -o "$XARGS" = ":"; then
     AC_MSG_ERROR([xargs not found in \$PATH .])
 fi
 
 MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
 AC_SUBST(RPMBUILD)
 
@@ -1995,17 +1994,16 @@ ia64*-hpux*)
        MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@'
        CXXFLAGS="$CXXFLAGS -Wc,-ansi_for_scope,on"
     else
        DSO_LDOPTS='-b -E'
        MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
        MKCSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
     fi
     MOZ_FIX_LINK_PATHS=
-    MOZ_NATIVE_MAKEDEPEND=
     AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
     AC_DEFINE(_LARGEFILE64_SOURCE)
     ;;
 
 *-hpux*)
     DLL_SUFFIX=".sl"
     if test ! "$GNU_CC"; then
     	DSO_LDOPTS='-b -Wl,+s'
@@ -2084,17 +2082,16 @@ ia64*-hpux*)
 *-mingw*)
     DSO_CFLAGS=
     DSO_PIC_CFLAGS=
     DLL_SUFFIX=.dll
     RC=rc.exe
     MC=mc.exe
     # certain versions of cygwin's makedepend barf on the
     # #include <string> vs -I./dist/include/string issue so don't use it
-    MOZ_NATIVE_MAKEDEPEND=
     if test -n "$GNU_CC"; then
         CC="$CC -mwindows"
         CXX="$CXX -mwindows"
         CPP="$CPP -mwindows"
         CFLAGS="$CFLAGS -mms-bitfields"
         CXXFLAGS="$CXXFLAGS -mms-bitfields"
         DSO_LDOPTS='-shared'
         MKSHLIB='$(CXX) $(DSO_LDOPTS) -o $@'
@@ -2365,17 +2362,16 @@ ia64*-hpux*)
     if test "$ac_os2_declspec" != "yes"; then
         AC_MSG_ERROR([Compiler does not support __declspec(dllexport), install GCC-4.3.2 or newer])
     fi
     ;;
 
 *-solaris*)
     AC_DEFINE(SOLARIS)
     TARGET_NSPR_MDCPUCFG='\"md/_solaris.cfg\"'
-    MOZ_NATIVE_MAKEDEPEND=
     MOZ_FIX_LINK_PATHS=
     # $ORIGIN/.. is for shared libraries under components/ to locate shared
     # libraries one level up (e.g. libnspr4.so)
     if test "$SOLARIS_SUNPRO_CC"; then
        LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN:\$\$ORIGIN/..' -z lazyload -z combreloc -z muldefs"
        LIBS="-lCrun -lCstd -lc $LIBS"
        AC_DEFINE(NSCAP_DISABLE_DEBUG_PTR_TYPES)
        CFLAGS="$CFLAGS -xlibmieee -xstrconst -xbuiltin=%all -D__FUNCTION__=__func__"
@@ -7626,74 +7622,39 @@ fi # COMPILE_ENVIRONMENT
 
 dnl ========================================================
 dnl =
 dnl = Build depencency options
 dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(Build dependencies)
 
-dnl ========================================================
-dnl = Do not auto generate dependency info
-dnl ========================================================
-MOZ_AUTO_DEPS=1
-MOZ_ARG_DISABLE_BOOL(auto-deps,
-[  --disable-auto-deps     Do not automatically generate dependency info],
-    MOZ_AUTO_DEPS=,
-    MOZ_AUTO_DEPS=1)
-
-if test -n "$MOZ_AUTO_DEPS"; then
-dnl ========================================================
-dnl = Use mkdepend instead of $CC -MD for dependency generation
-dnl ========================================================
-_cpp_md_flag=
-MOZ_ARG_DISABLE_BOOL(md,
-[  --disable-md            Do not use compiler-based dependencies ],
-  [_cpp_md_flag=],
-  [_cpp_md_flag=1],
-  [dnl Default is to turn on -MD if using GNU-compatible compilers
-   if test "$GNU_CC" -a "$GNU_CXX"; then
-     _cpp_md_flag=1
-   fi
-  dnl Default is to use -xM if using Sun Studio on Solaris
-   if test "$SOLARIS_SUNPRO_CC"; then
-     _cpp_md_flag=1
-   fi])
-if test "$_cpp_md_flag"; then
-  COMPILER_DEPEND=1
+if test "$GNU_CC" -a "$GNU_CXX"; then
   _DEPEND_CFLAGS='$(filter-out %/.pp,-MD -MF $(MDDEPDIR)/$(@F).pp)'
-  dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
-  if test "$SOLARIS_SUNPRO_CC"; then
-    _DEPEND_CFLAGS=
-  fi
+dnl Sun Studio on Solaris use -xM instead of -MD, see config/rules.mk
+elif test "$SOLARIS_SUNPRO_CC"; then
+  _DEPEND_CFLAGS=
 else
-  COMPILER_DEPEND=
   dnl Don't override this for MSVC
   if test -z "$_WIN32_MSVC"; then
     _USE_CPP_INCLUDE_FLAG=
     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
     _DEFINES_CXXFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
   else
     echo '#include <stdio.h>' > dummy-hello.c
     changequote(,)
     CL_INCLUDES_PREFIX=`${CC} -showIncludes -c -Fonul dummy-hello.c 2>&1 | sed -ne 's/^\([^:]*:[^:]*:\).*stdio.h$/\1/p'`
     changequote([,])
     if test -z "$CL_INCLUDES_PREFIX"; then
         AC_MSG_ERROR([Cannot find cl -showIncludes prefix.])
     fi
     AC_SUBST(CL_INCLUDES_PREFIX)
     rm -f dummy-hello.c
-    COMPILER_DEPEND=1
   fi
 fi
-fi # MOZ_AUTO_DEPS
-MDDEPDIR='.deps'
-AC_SUBST(MOZ_AUTO_DEPS)
-AC_SUBST(COMPILER_DEPEND)
-AC_SUBST(MDDEPDIR)
 
 dnl ========================================================
 dnl =
 dnl = Static Build Options
 dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(Static build options)
 
@@ -8422,17 +8383,16 @@ COMPILE_CFLAGS=`echo \
 	$_DEPEND_CFLAGS \
     $COMPILE_CFLAGS`
 
 COMPILE_CXXFLAGS=`echo \
     $_DEFINES_CXXFLAGS \
 	$_DEPEND_CFLAGS \
     $COMPILE_CXXFLAGS`
 
-AC_SUBST(MOZ_NATIVE_MAKEDEPEND)
 AC_SUBST(SYSTEM_LIBXUL)
 AC_SUBST(MOZ_NATIVE_JPEG)
 AC_SUBST(MOZ_NATIVE_PNG)
 AC_SUBST(MOZ_NATIVE_BZ2)
 
 AC_SUBST(MOZ_FLEXBOX)
 AC_SUBST(MOZ_JPEG_CFLAGS)
 AC_SUBST(MOZ_JPEG_LIBS)
--- a/content/base/src/CSPUtils.jsm
+++ b/content/base/src/CSPUtils.jsm
@@ -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/. */
 
 /**
  * Content Security Policy Utilities
- * 
+ *
  * Overview
  * This contains a set of classes and utilities for CSP.  It is in this
  * separate file for testing purposes.
  */
 
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -40,17 +40,17 @@ const R_GETSCHEME  = new RegExp ("^" + R
 // scheme-source   = scheme ":"
 const R_SCHEMESRC  = new RegExp ("^" + R_SCHEME.source + "\\:$", 'i');
 
 // host-char       = ALPHA / DIGIT / "-"
 const R_HOSTCHAR   = new RegExp ("[a-zA-Z0-9\\-]", 'i');
 
 // host            = "*" / [ "*." ] 1*host-char *( "." 1*host-char )
 const R_HOST       = new RegExp ("\\*|(((\\*\\.)?" + R_HOSTCHAR.source +
-                                      "+)(\\." + R_HOSTCHAR.source +"+)+)",'i');
+                                      "+)(\\." + R_HOSTCHAR.source +"+)*)",'i');
 // port            = ":" ( 1*DIGIT / "*" )
 const R_PORT       = new RegExp ("(\\:([0-9]+|\\*))", 'i');
 
 // host-source     = [ scheme "://" ] host [ port ]
 const R_HOSTSRC    = new RegExp ("^((" + R_SCHEME.source + "\\:\\/\\/)?("
                                        +   R_HOST.source + ")"
                                        +   R_PORT.source + "?)$", 'i');
 
@@ -178,17 +178,17 @@ CSPPolicyURIListener.prototype = {
       this._csp.refinePolicy("allow 'none'", this._docURI, this._docRequest);
       this._csp.refinePolicy("default-src 'none'", this._docURI, this._docRequest);
     }
     // resume the parent document request
     this._docRequest.resume();
   }
 };
 
-//:::::::::::::::::::::::: CLASSES ::::::::::::::::::::::::::// 
+//:::::::::::::::::::::::: CLASSES :::::::::::::::::::::::::://
 
 /**
  * Class that represents a parsed policy structure.
  */
 function CSPRep() {
   // this gets set to true when the policy is done parsing, or when a
   // URI-borne policy has finished loading.
   this._isInitialized = false;
@@ -474,17 +474,17 @@ CSPRep.prototype = {
     }
     return dirs.join("; ");
   },
 
   /**
    * Determines if this policy accepts a URI.
    * @param aContext
    *        one of the SRC_DIRECTIVES defined above
-   * @returns 
+   * @returns
    *        true if the policy permits the URI in given context.
    */
   permits:
   function csp_permits(aURI, aContext) {
     if (!aURI) return false;
 
     // GLOBALLY ALLOW "about:" SCHEME
     if (aURI instanceof String && aURI.substring(0,6) === "about:")
@@ -497,17 +497,17 @@ CSPRep.prototype = {
       if (CSPRep.SRC_DIRECTIVES[i] === aContext) {
         return this._directives[aContext].permits(aURI);
       }
     }
     return false;
   },
 
   /**
-   * Intersects with another CSPRep, deciding the subset policy 
+   * Intersects with another CSPRep, deciding the subset policy
    * that should be enforced, and returning a new instance.
    * @param aCSPRep
    *        a CSPRep instance to use as "other" CSP
    * @returns
    *        a new CSPRep instance of the intersection
    */
   intersectWith:
   function cspsd_intersectWith(aCSPRep) {
@@ -534,17 +534,17 @@ CSPRep.prototype = {
     else if (aCSPRep._directives[reportURIDir]) {
       // blank concat makes a copy of the string.
       newRep._directives[reportURIDir] = aCSPRep._directives[reportURIDir].concat();
     }
 
     newRep._allowEval =          this.allowsEvalInScripts
                            && aCSPRep.allowsEvalInScripts;
 
-    newRep._allowInlineScripts = this.allowsInlineScripts 
+    newRep._allowInlineScripts = this.allowsInlineScripts
                            && aCSPRep.allowsInlineScripts;
 
     return newRep;
   },
 
   /**
    * Copies default source list to each unspecified directive.
    * @returns
@@ -590,17 +590,17 @@ CSPRep.prototype = {
    */
   get allowsInlineScripts () {
     return this._allowInlineScripts;
   },
 };
 
 //////////////////////////////////////////////////////////////////////
 /**
- * Class to represent a list of sources 
+ * Class to represent a list of sources
  */
 function CSPSourceList() {
   this._sources = [];
   this._permitAllSources = false;
 
   // Set to true when this list is created using "makeExplicit()"
   // It's useful to know this when reporting the directive that was violated.
   this._isImplicit = false;
@@ -612,17 +612,17 @@ function CSPSourceList() {
  * @param aStr
  *        string rep of a CSP Source List
  * @param self (optional)
  *        URI or CSPSource representing the "self" source
  * @param enforceSelfChecks (optional)
  *        if present, and "true", will check to be sure "self" has the
  *        appropriate values to inherit when they are omitted from the source.
  * @returns
- *        an instance of CSPSourceList 
+ *        an instance of CSPSourceList
  */
 CSPSourceList.fromString = function(aStr, self, enforceSelfChecks) {
   // source-list = *WSP [ source-expression *( 1*WSP source-expression ) *WSP ]
   //             / *WSP "'none'" *WSP
 
   /* If self parameter is passed, convert to CSPSource,
      unless it is already a CSPSource. */
   if(self && !(self instanceof CSPSource)) {
@@ -663,17 +663,17 @@ CSPSourceList.fromString = function(aStr
 };
 
 CSPSourceList.prototype = {
   /**
    * Compares one CSPSourceList to another.
    *
    * @param that
    *        another CSPSourceList
-   * @returns 
+   * @returns
    *        true if they have the same data
    */
   equals:
   function(that) {
     // special case to default-src * and 'none' to look different
     // (both have a ._sources.length of 0).
     if (that._permitAllSources != this._permitAllSources) {
       return false;
@@ -760,17 +760,17 @@ CSPSourceList.prototype = {
       }
     }
     return false;
   },
 
   /**
    * Intersects with another CSPSourceList, deciding the subset directive
    * that should be enforced, and returning a new instance.
-   * @param that 
+   * @param that
    *        the other CSPSourceList to intersect "this" with
    * @returns
    *        a new instance of a CSPSourceList representing the intersection
    */
   intersectWith:
   function cspsd_intersectWith(that) {
 
     var newCSPSrcList = null;
@@ -836,20 +836,20 @@ function CSPSource() {
 }
 
 /**
  * General factory method to create a new source from one of the following
  * types:
  *  - nsURI
  *  - string
  *  - CSPSource (clone)
- * @param aData 
+ * @param aData
  *        string, nsURI, or CSPSource
  * @param self (optional)
- *	  if present, string, URI, or CSPSource representing the "self" resource 
+ *	  if present, string, URI, or CSPSource representing the "self" resource
  * @param enforceSelfChecks (optional)
  *	  if present, and "true", will check to be sure "self" has the
  *        appropriate values to inherit when they are omitted from the source.
  * @returns
  *        an instance of CSPSource
  */
 CSPSource.create = function(aData, self, enforceSelfChecks) {
   if (typeof aData === 'string')
@@ -875,17 +875,17 @@ CSPSource.create = function(aData, self,
  * @param aURI
  *        nsIURI rep of a URI
  * @param self (optional)
  *        string or CSPSource representing the "self" source
  * @param enforceSelfChecks (optional)
  *        if present, and "true", will check to be sure "self" has the
  *        appropriate values to inherit when they are omitted from aURI.
  * @returns
- *        an instance of CSPSource 
+ *        an instance of CSPSource
  */
 CSPSource.fromURI = function(aURI, self, enforceSelfChecks) {
   if (!(aURI instanceof Components.interfaces.nsIURI)){
     CSPError(CSPLocalizer.getStr("cspSourceNotURI"));
     return null;
   }
 
   if (!self && enforceSelfChecks) {
@@ -918,18 +918,18 @@ CSPSource.fromURI = function(aURI, self,
     // (NS_ERROR_FAILURE)
     sObj._host = CSPHost.fromString(aURI.host);
   } catch(e) {
     sObj._host = undefined;
   }
 
   // grab port (if there is one)
   // creating a source from an nsURI is limited in that one cannot specify "*"
-  // for port.  In fact, there's no way to represent "*" differently than 
-  // a blank port in an nsURI, since "*" turns into -1, and so does an 
+  // for port.  In fact, there's no way to represent "*" differently than
+  // a blank port in an nsURI, since "*" turns into -1, and so does an
   // absence of port declaration.
 
   // port is never inherited from self -- this gets too confusing.
   // Instead, whatever scheme is used (an explicit one or the inherited
   // one) dictates the port if no port is explicitly stated.
   // Set it to undefined here and the default port will be resolved in the
   // getter for .port.
   sObj._port = undefined;
@@ -952,17 +952,17 @@ CSPSource.fromURI = function(aURI, self,
  * @param aStr
  *        string rep of a CSP Source
  * @param self (optional)
  *        string, URI, or CSPSource representing the "self" source
  * @param enforceSelfChecks (optional)
  *        if present, and "true", will check to be sure "self" has the
  *        appropriate values to inherit when they are omitted from aURI.
  * @returns
- *        an instance of CSPSource 
+ *        an instance of CSPSource
  */
 CSPSource.fromString = function(aStr, self, enforceSelfChecks) {
   if (!aStr)
     return null;
 
   if (!(typeof aStr === 'string')) {
     CSPError(CSPLocalizer.getStr("argumentIsNotString"));
     return null;
@@ -991,29 +991,36 @@ CSPSource.fromString = function(aStr, se
     var schemeSrcMatch = R_GETSCHEME.exec(aStr);
     sObj._scheme = schemeSrcMatch[0];
     if (!sObj._host) sObj._host = CSPHost.fromString("*");
     if (!sObj._port) sObj._port = "*";
     return sObj;
   }
 
   // check for host-source or ext-host-source match
-  if (R_HOSTSRC.test(aStr) || R_EXTHOSTSRC.test(aStr)){
+  if (R_HOSTSRC.test(aStr) || R_EXTHOSTSRC.test(aStr)) {
     var schemeMatch = R_GETSCHEME.exec(aStr);
-    if (!schemeMatch)
+    // check that the scheme isn't accidentally matching the host. There should
+    // be '://' if there is a valid scheme in an (EXT)HOSTSRC
+    if (!schemeMatch || aStr.indexOf("://") == -1) {
       sObj._scheme = self.scheme;
-    else {
+      schemeMatch = null;
+    } else {
       sObj._scheme = schemeMatch[0];
     }
 
+    // get array of matches to the R_HOST regular expression
     var hostMatch = R_HOST.exec(aStr);
-    if (!hostMatch) {
+    if (!hostMatch){
       CSPError(CSPLocalizer.getFormatStr("couldntParseInvalidSource", [aStr]));
       return null;
     }
+    // host regex gets scheme, so remove scheme from aStr. Add 3 for '://'
+    if (schemeMatch)
+      hostMatch = R_HOST.exec(aStr.substring(schemeMatch[0].length + 3));
     sObj._host = CSPHost.fromString(hostMatch[0]);
     var portMatch = R_PORT.exec(aStr);
     if (!portMatch) {
       // gets the default port for the given scheme
       defPort = Services.io.getProtocolHandler(sObj._scheme).defaultPort;
       if (!defPort) {
         CSPError(CSPLocalizer.getFormatStr("couldntParseInvalidSource", [aStr]));
         return null;
@@ -1041,17 +1048,17 @@ CSPSource.fromString = function(aStr, se
   return null;
 };
 
 CSPSource.validSchemeName = function(aStr) {
   // <scheme-name>       ::= <alpha><scheme-suffix>
   // <scheme-suffix>     ::= <scheme-chr>
   //                      | <scheme-suffix><scheme-chr>
   // <scheme-chr>        ::= <letter> | <digit> | "+" | "." | "-"
-  
+
   return aStr.match(/^[a-zA-Z][a-zA-Z0-9+.-]*$/);
 };
 
 CSPSource.prototype = {
 
   get scheme () {
     if (this._isSelf && this._self)
       return this._self.scheme;
@@ -1096,17 +1103,17 @@ CSPSource.prototype = {
     return undefined;
   },
 
   /**
    * Generates canonical string representation of the Source.
    */
   toString:
   function() {
-    if (this._isSelf) 
+    if (this._isSelf)
       return this._self.toString();
 
     var s = "";
     if (this.scheme)
       s = s + this.scheme + "://";
     if (this._host)
       s = s + this._host;
     if (this.port)
@@ -1144,49 +1151,49 @@ CSPSource.prototype = {
     if (!(aSource instanceof CSPSource))
       return this.permits(CSPSource.create(aSource));
 
     // verify scheme
     if (this.scheme != aSource.scheme)
       return false;
 
     // port is defined in 'this' (undefined means it may not be relevant
-    // to the scheme) AND this port (implicit or explicit) matches 
+    // to the scheme) AND this port (implicit or explicit) matches
     // aSource's port
     if (this.port && this.port !== "*" && this.port != aSource.port)
       return false;
 
     // host is defined in 'this' (undefined means it may not be relevant
-    // to the scheme) AND this host (implicit or explicit) permits 
+    // to the scheme) AND this host (implicit or explicit) permits
     // aSource's host.
     if (this.host && !this.host.permits(aSource.host))
       return false;
 
     // all scheme, host and port matched!
     return true;
   },
 
   /**
    * Determines the intersection of two sources.
    * Returns a null object if intersection generates no
    * hosts that satisfy it.
-   * @param that 
+   * @param that
    *        the other CSPSource to intersect "this" with
    * @returns
    *        a new instance of a CSPSource representing the intersection
    */
   intersectWith:
   function(that) {
     var newSource = new CSPSource();
 
     // 'self' is not part of the intersection.  Intersect the raw values from
     // the source, self must be set by someone creating this source.
     // When intersecting, we take the more specific of the two: if one scheme,
     // host or port is undefined, the other is taken.  (This is contrary to
-    // when "permits" is called -- there, the value of 'self' is looked at 
+    // when "permits" is called -- there, the value of 'self' is looked at
     // when a scheme, host or port is undefined.)
 
     // port
     if (!this.port)
       newSource._port = that.port;
     else if (!that.port)
       newSource._port = this.port;
     else if (this.port === "*")
@@ -1241,20 +1248,20 @@ CSPSource.prototype = {
     return newSource;
   },
 
   /**
    * Compares one CSPSource to another.
    *
    * @param that
    *        another CSPSource
-   * @param resolveSelf (optional) 
+   * @param resolveSelf (optional)
    *        if present, and 'true', implied values are obtained from 'self'
    *        instead of assumed to be "anything"
-   * @returns 
+   * @returns
    *        true if they have the same data
    */
   equals:
   function(that, resolveSelf) {
     // 1. schemes match
     // 2. ports match
     // 3. either both hosts are undefined, or one equals the other.
     if (resolveSelf)
@@ -1279,17 +1286,17 @@ CSPSource.prototype = {
 function CSPHost() {
   this._segments = [];
 }
 
 /**
  * Factory to create a new CSPHost, parsed from a string.
  *
  * @param aStr
- *        string rep of a CSP Host 
+ *        string rep of a CSP Host
  * @returns
  *        an instance of CSPHost
  */
 CSPHost.fromString = function(aStr) {
   if (!aStr) return null;
 
   // host string must be LDH with dots and stars.
   var invalidChar = aStr.match(/[^a-zA-Z0-9\-\.\*]/);
@@ -1307,17 +1314,17 @@ CSPHost.fromString = function(aStr) {
   for (var i in hObj._segments) {
     var seg = hObj._segments[i];
     if (seg == "*") {
       if (i > 0) {
         // Wildcard must be FIRST
         CSPdebug("Wildcard char located at invalid position in '" + aStr + "'");
         return null;
       }
-    } 
+    }
     else if (seg.match(/[^a-zA-Z0-9\-]/)) {
       // Non-wildcard segment must be LDH string
       CSPdebug("Invalid segment '" + seg + "' in host value");
       return null;
     }
   }
   return hObj;
 };
@@ -1358,58 +1365,58 @@ CSPHost.prototype = {
 
     if (!(aHost instanceof CSPHost)) {
       // -- compare CSPHost to String
       return this.permits(CSPHost.fromString(aHost));
     }
     var thislen = this._segments.length;
     var thatlen = aHost._segments.length;
 
-    // don't accept a less specific host: 
+    // don't accept a less specific host:
     //   \--> *.b.a doesn't accept b.a.
     if (thatlen < thislen) { return false; }
 
     // check for more specific host (and wildcard):
     //   \--> *.b.a accepts d.c.b.a.
     //   \--> c.b.a doesn't accept d.c.b.a.
     if ((thatlen > thislen) && this._segments[0] != "*") {
       return false;
     }
 
-    // Given the wildcard condition (from above), 
+    // Given the wildcard condition (from above),
     // only necessary to compare elements that are present
-    // in this host.  Extra tokens in aHost are ok. 
+    // in this host.  Extra tokens in aHost are ok.
     // * Compare from right to left.
     for (var i=1; i <= thislen; i++) {
-      if (this._segments[thislen-i] != "*" && 
+      if (this._segments[thislen-i] != "*" &&
           (this._segments[thislen-i] != aHost._segments[thatlen-i])) {
         return false;
       }
     }
 
     // at this point, all conditions are met, so the host is allowed
     return true;
   },
 
   /**
    * Determines the intersection of two Hosts.
    * Basically, they must be the same, or one must have a wildcard.
-   * @param that 
+   * @param that
    *        the other CSPHost to intersect "this" with
    * @returns
    *        a new instance of a CSPHost representing the intersection
    *        (or null, if they can't be intersected)
    */
   intersectWith:
   function(that) {
     if (!(this.permits(that) || that.permits(this))) {
       // host definitions cannot co-exist without a more general host
       // ... one must be a subset of the other, or intersection makes no sense.
       return null;
-    } 
+    }
 
     // pick the more specific one, if both are same length.
     if (this._segments.length == that._segments.length) {
       // *.a vs b.a : b.a
       return (this._segments[0] === "*") ? that.clone() : this.clone();
     }
 
     // different lengths...
@@ -1419,17 +1426,17 @@ CSPHost.prototype = {
             this.clone() : that.clone();
   },
 
   /**
    * Compares one CSPHost to another.
    *
    * @param that
    *        another CSPHost
-   * @returns 
+   * @returns
    *        true if they have the same data
    */
   equals:
   function(that) {
     if (this._segments.length != that._segments.length)
       return false;
 
     for (var i=0; i<this._segments.length; i++) {
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -1752,18 +1752,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
 
     const char* nsuri = nsid < ArrayLength(kNSURIs) ? kNSURIs[nsid] : "";
     PR_snprintf(name, sizeof(name), "FragmentOrElement%s %s%s%s %s",
                 nsuri,
                 localName.get(),
                 NS_ConvertUTF16toUTF8(id).get(),
                 NS_ConvertUTF16toUTF8(classes).get(),
                 uri.get());
-    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(FragmentOrElement),
-                              name);
+    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   }
   else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(FragmentOrElement, tmp->mRefCnt.get())
   }
 
   // Always need to traverse script objects, so do that before we check
   // if we're uncollectable.
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -6239,22 +6239,20 @@ class DebugWrapperTraversalCallback : pu
 public:
   DebugWrapperTraversalCallback(void* aWrapper) : mFound(false),
                                                   mWrapper(aWrapper)
   {
     mFlags = WANT_ALL_TRACES;
   }
 
   NS_IMETHOD_(void) DescribeRefCountedNode(nsrefcnt refCount,
-                                           size_t objSz,
                                            const char *objName)
   {
   }
   NS_IMETHOD_(void) DescribeGCedNode(bool isMarked,
-                                     size_t objSz,
                                      const char *objName)
   {
   }
 
   NS_IMETHOD_(void) NoteXPCOMRoot(nsISupports *root)
   {
   }
   NS_IMETHOD_(void) NoteJSRoot(void* root)
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -1814,17 +1814,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
     if (nsid < ArrayLength(kNSURIs)) {
       PR_snprintf(name, sizeof(name), "nsDocument %s %s %s",
                   loadedAsData.get(), kNSURIs[nsid], uri.get());
     }
     else {
       PR_snprintf(name, sizeof(name), "nsDocument %s %s",
                   loadedAsData.get(), uri.get());
     }
-    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(nsDocument), name);
+    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   }
   else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsDocument, tmp->mRefCnt.get())
   }
 
   // Always need to traverse script objects, so do that before we check
   // if we're uncollectable.
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -60,17 +60,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mListeners[i] mListener");
     cb.NoteXPCOMChild(tmp->mListeners[i].mListener.get());
   }
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mChildManagers)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFrameMessageManager)
   tmp->mListeners.Clear();
-  for (PRInt32 i = tmp->mChildManagers.Count(); i > 0; --i) {
+  for (int32_t i = tmp->mChildManagers.Count(); i > 0; --i) {
     static_cast<nsFrameMessageManager*>(tmp->mChildManagers[i - 1])->
       Disconnect(false);
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mChildManagers)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
@@ -168,17 +168,17 @@ nsFrameMessageManager::LoadFrameScript(c
 
   if (mCallbackData) {
 #ifdef DEBUG_smaug
     printf("Will load %s \n", NS_ConvertUTF16toUTF8(aURL).get());
 #endif
     NS_ENSURE_TRUE(mLoadScriptCallback(mCallbackData, aURL), NS_ERROR_FAILURE);
   }
 
-  for (PRInt32 i = 0; i < mChildManagers.Count(); ++i) {
+  for (int32_t i = 0; i < mChildManagers.Count(); ++i) {
     nsRefPtr<nsFrameMessageManager> mm =
       static_cast<nsFrameMessageManager*>(mChildManagers[i]);
     if (mm) {
       // Use false here, so that child managers don't cache the script, which
       // is already cached in the parent.
       mm->LoadFrameScript(aURL, false);
     }
   }
@@ -285,18 +285,18 @@ nsFrameMessageManager::DispatchAsyncMess
                                                     const StructuredCloneData& aData,
                                                     ShouldBroadcast aBroadcast)
 {
   if (mAsyncCallback) {
     NS_ENSURE_TRUE(mCallbackData, NS_ERROR_NOT_INITIALIZED);
     mAsyncCallback(mCallbackData, aMessage, aData);
   }
   if (aBroadcast == BROADCAST) {
-    PRInt32 len = mChildManagers.Count();
-    for (PRInt32 i = 0; i < len; ++i) {
+    int32_t len = mChildManagers.Count();
+    for (int32_t i = 0; i < len; ++i) {
       static_cast<nsFrameMessageManager*>(mChildManagers[i])->
          DispatchAsyncMessageInternal(aMessage, aData, aBroadcast);
     }
   }
   return NS_OK;
 }
 
 nsresult
--- a/content/base/src/nsFrameMessageManager.h
+++ b/content/base/src/nsFrameMessageManager.h
@@ -138,17 +138,17 @@ public:
 
   void Disconnect(bool aRemoveFromParent = true);
   void SetCallbackData(void* aData, bool aLoadScripts = true);
   void* GetCallbackData() { return mCallbackData; }
   enum ShouldBroadcast { BROADCAST, DONT_BROADCAST };
   nsresult DispatchAsyncMessage(const nsAString& aMessageName,
                                 const jsval& aObject,
                                 JSContext* aCx,
-                                PRUint8 aArgc,
+                                uint8_t aArgc,
                                 ShouldBroadcast aBroadcast);
   nsresult DispatchAsyncMessageInternal(const nsAString& aMessage,
                                         const StructuredCloneData& aData,
                                         ShouldBroadcast aBroadcast);
   JSContext* GetJSContext() { return mContext; }
   void SetJSContext(JSContext* aCx) { mContext = aCx; }
   void RemoveFromParent();
   nsFrameMessageManager* GetParentManager() { return mParentManager; }
--- a/content/base/src/nsNodeInfo.cpp
+++ b/content/base/src/nsNodeInfo.cpp
@@ -166,17 +166,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
     if (nsid < ArrayLength(kNSURIs)) {
       PR_snprintf(name, sizeof(name), "nsNodeInfo%s %s", kNSURIs[nsid],
                   localName.get());
     }
     else {
       PR_snprintf(name, sizeof(name), "nsNodeInfo %s", localName.get());
     }
 
-    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(nsNodeInfo), name);
+    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   }
   else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsNodeInfo, tmp->mRefCnt.get())
   }
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mOwnerManager,
                                                   nsNodeInfoManager)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
--- a/content/base/test/file_x-frame-options_main.html
+++ b/content/base/test/file_x-frame-options_main.html
@@ -14,11 +14,13 @@ window.addEventListener('load', parent.t
 <iframe id="deny" src="http://mochi.test:8888/tests/content/base/test/file_x-frame-options_page.sjs?testid=deny&xfo=deny"></iframe><br>
 <iframe id="sameorigin1" src="http://mochi.test:8888/tests/content/base/test/file_x-frame-options_page.sjs?testid=sameorigin1&xfo=sameorigin"></iframe><br>
 <iframe id="sameorigin2" src="http://example.com/tests/content/base/test/file_x-frame-options_page.sjs?testid=sameorigin2&xfo=sameorigin"></iframe><br>
 <iframe id="sameorigin5" src="http://example.com/tests/content/base/test/file_x-frame-options_page.sjs?testid=sameorigin5&xfo=sameorigin2"></iframe><br>
 <iframe id="sameorigin6" src="http://mochi.test:8888/tests/content/base/test/file_x-frame-options_page.sjs?testid=sameorigin6&xfo=sameorigin2"></iframe><br>
 <iframe id="sameorigin7" src="http://mochi.test:8888/tests/content/base/test/file_x-frame-options_page.sjs?testid=sameorigin7&xfo=sameorigin3"></iframe><br>
 <iframe id="sameorigin8" src="http://example.com/tests/content/base/test/file_x-frame-options_page.sjs?testid=sameorigin8&xfo=sameorigin3"></iframe><br>
 <iframe id="mixedpolicy" src="http://mochi.test:8888/tests/content/base/test/file_x-frame-options_page.sjs?testid=mixedpolicy&xfo=mixedpolicy"></iframe><br>
+<iframe id="allow-from-allow" src="http://example.com/tests/content/base/test/file_x-frame-options_page.sjs?testid=allow-from-allow&xfo=afa"></iframe><br>
+<iframe id="allow-from-deny" src="http://example.com/tests/content/base/test/file_x-frame-options_page.sjs?testid=allow-from-deny&xfo=afd"></iframe><br>
 
 </body>
 </html>
--- a/content/base/test/file_x-frame-options_page.sjs
+++ b/content/base/test/file_x-frame-options_page.sjs
@@ -21,13 +21,19 @@ function handleRequest(request, response
     response.setHeader("X-Frame-Options", "SAMEORIGIN, SAMEORIGIN", false);
   }
   else if (query['xfo'] == "sameorigin3") {
     response.setHeader("X-Frame-Options", "SAMEORIGIN,SAMEORIGIN , SAMEORIGIN", false);
   }
   else if (query['xfo'] == "mixedpolicy") {
     response.setHeader("X-Frame-Options", "DENY,SAMEORIGIN", false);
   }
+  else if (query['xfo'] == "afa") {
+    response.setHeader("X-Frame-Options", "ALLOW-FROM http://mochi.test:8888/", false);
+  }
+  else if (query['xfo'] == "afd") {
+    response.setHeader("X-Frame-Options", "ALLOW-FROM http://example.com/", false);
+  }
 
   // from the test harness we'll be checking for the presence of this element
   // to test if the page loaded
   response.write("<h1 id=\"test\">" + query["testid"] + "</h1>");
 }
--- a/content/base/test/test_x-frame-options.html
+++ b/content/base/test/test_x-frame-options.html
@@ -103,16 +103,26 @@ var testFramesLoaded = function() {
   var test9 = frame.contentDocument.getElementById("test");
   is(test9, null, "test sameorigin8");
 
   // iframe from same origin, X-F-O: DENY,SAMEORIGIN - should not load
   frame = harness.contentDocument.getElementById("mixedpolicy");
   var test10 = frame.contentDocument.getElementById("test");
   is(test10, null, "test mixedpolicy");
 
+  // iframe from different origin, allow-from: this origin - should load
+  frame = harness.contentDocument.getElementById("allow-from-allow");
+  var test11 = frame.contentDocument.getElementById("test").textContent;
+  is(test11, "allow-from-allow", "test allow-from-allow");
+
+  // iframe from different origin, with allow-from: other - should not load
+  frame = harness.contentDocument.getElementById("allow-from-deny");
+  var test12 = frame.contentDocument.getElementById("test");
+  is(test12, null, "test allow-from-deny");
+
   // call tests to check principal comparison, e.g. a document can open a window
   // to a data: or javascript: document which frames an
   // X-Frame-Options: SAMEORIGIN document and the frame should load
   testFrameInJSURI();
 }
 
 // test that a document can be framed under a javascript: URL opened by the
 // same site as the frame
--- a/content/base/test/unit/test_csputils.js
+++ b/content/base/test/unit/test_csputils.js
@@ -46,17 +46,17 @@ function do_check_in_array(arr, val, sta
       return;
     }
   }
   do_throw(text, stack);
 }
 
 // helper to assert that an object or array must have a given key
 function do_check_has_key(foo, key, stack) {
-  if (!stack) 
+  if (!stack)
     stack = Components.stack.caller;
 
   var keys = [];
   for (let k in foo) { keys.push(k); }
   var text = key + " in [" + keys.join(",") + "]";
 
   for (var x in foo) {
     if (x == key) {
@@ -67,17 +67,17 @@ function do_check_has_key(foo, key, stac
       return;
     }
   }
   do_throw(text, stack);
 }
 
 // helper to use .equals on stuff
 function do_check_equivalent(foo, bar, stack) {
-  if (!stack) 
+  if (!stack)
     stack = Components.stack.caller;
 
   var text = foo + ".equals(" + bar + ")";
 
   if(foo.equals && foo.equals(bar)) {
     ++_passedChecks;
       dump("TEST-PASS | " + stack.filename + " | [" + stack.name + " : " +
            stack.lineNumber + "] " + text + "\n");
@@ -195,26 +195,26 @@ test(
       var src;
       src = CSPSource.create("a.com", "https://foobar.com:443");
       //"src should inherit port *
       do_check_true(src.permits("https://a.com:443"));
       //"src should inherit and require https scheme
       do_check_false(src.permits("http://a.com"));
       //"src should inherit scheme 'https'"
       do_check_true(src.permits("https://a.com"));
-      
+
       src = CSPSource.create("http://a.com", "https://foobar.com:443");
       //"src should inherit and require http scheme"
       do_check_false(src.permits("https://a.com"));
       //"src should inherit scheme 'http'"
       do_check_true(src.permits("http://a.com"));
       //"src should inherit port and scheme from parent"
       //"src should inherit default port for 'http'"
       do_check_true(src.permits("http://a.com:80"));
-      
+
       src = CSPSource.create("'self'", "https://foobar.com:443");
       //"src should inherit port *
       do_check_true(src.permits("https://foobar.com:443"));
       //"src should inherit and require https scheme
       do_check_false(src.permits("http://foobar.com"));
       //"src should inherit scheme 'https'"
       do_check_true(src.permits("https://foobar.com"));
       //"src should reject other hosts"
@@ -403,17 +403,17 @@ test(
 test(
     function test_CSPRep_fromString_oneDir() {
 
       var cspr;
       var SD = CSPRep.SRC_DIRECTIVES;
       var DEFAULTS = [SD.STYLE_SRC, SD.MEDIA_SRC, SD.IMG_SRC, SD.FRAME_SRC];
 
       // check one-directive policies
-      cspr = CSPRep.fromString("allow bar.com; script-src https://foo.com", 
+      cspr = CSPRep.fromString("allow bar.com; script-src https://foo.com",
                                URI("http://self.com"));
 
       for(var x in DEFAULTS) {
         //DEFAULTS[x] + " does not use default rule."
         do_check_false(cspr.permits("http://bar.com:22", DEFAULTS[x]));
         //DEFAULTS[x] + " does not use default rule."
         do_check_true(cspr.permits("http://bar.com:80", DEFAULTS[x]));
         //DEFAULTS[x] + " does not use default rule."
@@ -503,16 +503,38 @@ test(function test_FrameAncestor_default
       //"frame-ancestors should only allow self"
       do_check_true(cspr.permits("http://self.com:34", SD.FRAME_ANCESTORS));
       do_check_false(cspr.permits("https://foo.com:400", SD.FRAME_ANCESTORS));
       do_check_false(cspr.permits("https://self.com:34", SD.FRAME_ANCESTORS));
       do_check_false(cspr.permits("http://self.com", SD.FRAME_ANCESTORS));
       do_check_false(cspr.permits("http://subd.self.com:34", SD.FRAME_ANCESTORS));
      });
 
+test(function test_FrameAncestor_TLD_defaultPorts() {
+      var cspr;
+      var SD = CSPRep.SRC_DIRECTIVES;
+      var self = "http://self"; //TLD only, no .com or anything.
+
+      cspr = CSPRep.fromString("allow 'self'; frame-ancestors 'self' http://foo:80 bar:80 http://three", URI(self));
+
+      //"frame-ancestors should default to * not 'allow' value"
+      do_check_true(cspr.permits("http://self", SD.FRAME_ANCESTORS));
+      do_check_true(cspr.permits("http://self:80", SD.FRAME_ANCESTORS));
+      do_check_true(cspr.permits("http://foo", SD.FRAME_ANCESTORS));
+      do_check_true(cspr.permits("http://foo:80", SD.FRAME_ANCESTORS));
+      do_check_true(cspr.permits("http://bar", SD.FRAME_ANCESTORS));
+      do_check_true(cspr.permits("http://three:80", SD.FRAME_ANCESTORS));
+
+      do_check_false(cspr.permits("https://foo:400", SD.FRAME_ANCESTORS));
+      do_check_false(cspr.permits("https://self:34", SD.FRAME_ANCESTORS));
+      do_check_false(cspr.permits("https://bar", SD.FRAME_ANCESTORS));
+      do_check_false(cspr.permits("http://three:81", SD.FRAME_ANCESTORS));
+      do_check_false(cspr.permits("https://three:81", SD.FRAME_ANCESTORS));
+     });
+
 test(function test_CSP_ReportURI_parsing() {
       var cspr;
       var SD = CSPRep.SRC_DIRECTIVES;
       var self = "http://self.com:34";
       var parsedURIs = [];
 
       var uri_valid_absolute = self + "/report.py";
       var uri_invalid_host_absolute = "http://foo.org:34/report.py";
@@ -585,27 +607,27 @@ test(
        */
 
       var src;
       src = CSPSource.create("a.com", "https://foobar.com:4443");
       //"src should inherit and require https scheme
       do_check_false(src.permits("http://a.com"));
       //"src should inherit scheme 'https'"
       do_check_true(src.permits("https://a.com"));
-      //"src should get default port 
+      //"src should get default port
       do_check_true(src.permits("https://a.com:443"));
-      
+
       src = CSPSource.create("http://a.com", "https://foobar.com:4443");
       //"src should require http scheme"
       do_check_false(src.permits("https://a.com"));
       //"src should keep scheme 'http'"
       do_check_true(src.permits("http://a.com"));
       //"src should inherit default port for 'http'"
       do_check_true(src.permits("http://a.com:80"));
-      
+
       src = CSPSource.create("'self'", "https://foobar.com:4443");
       //"src should inherit nonstandard port from self
       do_check_true(src.permits("https://foobar.com:4443"));
       do_check_false(src.permits("https://foobar.com"));
       do_check_false(src.permits("https://foobar.com:443"));
 
       //"src should inherit and require https scheme from self
       do_check_false(src.permits("http://foobar.com:4443"));
--- a/content/events/src/nsDOMEventTargetHelper.cpp
+++ b/content/events/src/nsDOMEventTargetHelper.cpp
@@ -45,18 +45,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   if (NS_UNLIKELY(cb.WantDebugInfo())) {
     char name[512];
     nsAutoString uri;
     if (tmp->mOwner && tmp->mOwner->GetExtantDocument()) {
       tmp->mOwner->GetExtantDocument()->GetDocumentURI(uri);
     }
     PR_snprintf(name, sizeof(name), "nsDOMEventTargetHelper %s",
                 NS_ConvertUTF16toUTF8(uri).get());
-    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(nsDOMEventTargetHelper),
-                              name);
+    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   } else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsDOMEventTargetHelper, tmp->mRefCnt.get())
   }
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mListenerManager,
                                                   nsEventListenerManager)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -6,16 +6,17 @@
 #include "nsDocShell.h"
 #include "nsDSURIContentListener.h"
 #include "nsIChannel.h"
 #include "nsServiceManagerUtils.h"
 #include "nsXPIDLString.h"
 #include "nsDocShellCID.h"
 #include "nsIWebNavigationInfo.h"
 #include "nsIDOMWindow.h"
+#include "nsNetUtil.h"
 #include "nsAutoPtr.h"
 #include "nsIHttpChannel.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsError.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
@@ -253,19 +254,25 @@ nsDSURIContentListener::SetParentContent
         mWeakParentContentListener = nullptr;
         mParentContentListener = nullptr;
     }
     return NS_OK;
 }
 
 bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIRequest *request,
                                                         const nsAString& policy) {
-    // return early if header does not have one of the two values with meaning
+    static const char allowFrom[] = "allow-from ";
+    const PRUint32 allowFromLen = ArrayLength(allowFrom) - 1;
+    bool isAllowFrom =
+        StringHead(policy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
+
+    // return early if header does not have one of the values with meaning
     if (!policy.LowerCaseEqualsLiteral("deny") &&
-        !policy.LowerCaseEqualsLiteral("sameorigin"))
+        !policy.LowerCaseEqualsLiteral("sameorigin") &&
+        !isAllowFrom)
         return true;
 
     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(request);
     if (!httpChannel) {
         return true;
     }
 
     if (mDocShell) {
@@ -337,28 +344,42 @@ bool nsDSURIContentListener::CheckOneFra
 
         // If the value of the header is DENY, and the previous condition is
         // not met (current docshell is not the top docshell), prohibit the
         // load.
         if (policy.LowerCaseEqualsLiteral("deny")) {
             return false;
         }
 
+        topDoc = do_GetInterface(curDocShellItem);
+        nsCOMPtr<nsIURI> topUri;
+        topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
+        nsCOMPtr<nsIURI> uri;
+
         // If the X-Frame-Options value is SAMEORIGIN, then the top frame in the
         // parent chain must be from the same origin as this document.
         if (policy.LowerCaseEqualsLiteral("sameorigin")) {
-            nsCOMPtr<nsIURI> uri;
             httpChannel->GetURI(getter_AddRefs(uri));
-            topDoc = do_GetInterface(curDocShellItem);
-            nsCOMPtr<nsIURI> topUri;
-            topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
             rv = ssm->CheckSameOriginURI(uri, topUri, true);
             if (NS_FAILED(rv))
                 return false; /* wasn't same-origin */
         }
+
+        // If the X-Frame-Options value is "allow-from [uri]", then the top
+        // frame in the parent chain must be from that origin
+        if (isAllowFrom) {
+            rv = NS_NewURI(getter_AddRefs(uri),
+                           Substring(policy, allowFromLen));
+            if (NS_FAILED(rv))
+              return false;
+
+            rv = ssm->CheckSameOriginURI(uri, topUri, true);
+            if (NS_FAILED(rv))
+                return false;
+        }
     }
 
     return true;
 }
 
 // Check if X-Frame-Options permits this document to be loaded as a subdocument.
 // This will iterate through and check any number of X-Frame-Options policies
 // in the request (comma-separated in a header, multiple headers, etc).
--- a/dom/base/DOMRequest.cpp
+++ b/dom/base/DOMRequest.cpp
@@ -174,17 +174,20 @@ DOMRequest::FireEvent(const nsAString& a
   bool dummy;
   DispatchEvent(event, &dummy);
 }
 
 void
 DOMRequest::RootResultVal()
 {
   NS_ASSERTION(!mRooted, "Don't call me if already rooted!");
-  NS_HOLD_JS_OBJECTS(this, DOMRequest);
+  nsXPCOMCycleCollectionParticipant *participant;
+  CallQueryInterface(this, &participant);
+  nsContentUtils::HoldJSObjects(NS_CYCLE_COLLECTION_UPCAST(this, DOMRequest),
+                                participant);
   mRooted = true;
 }
 
 void
 DOMRequest::UnrootResultVal()
 {
   NS_ASSERTION(mRooted, "Don't call me if not rooted!");
   NS_DROP_JS_OBJECTS(this, DOMRequest);
--- a/dom/base/DOMRequest.h
+++ b/dom/base/DOMRequest.h
@@ -49,18 +49,18 @@ public:
     if (mRooted) {
       UnrootResultVal();
     }
   }
 
 protected:
   void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable);
 
-  virtual void RootResultVal();
-  virtual void UnrootResultVal();
+  void RootResultVal();
+  void UnrootResultVal();
 
   void Init(nsIDOMWindow* aWindow);
 };
 
 class DOMRequestService MOZ_FINAL : public nsIDOMRequestService
 {
 public:
   NS_DECL_ISUPPORTS
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1142,17 +1142,17 @@ Navigator::GetMozVoicemail(nsIDOMMozVoic
 
     nsCOMPtr<nsIDocument> document = do_QueryInterface(window->GetExtantDocument());
     NS_ENSURE_TRUE(document, NS_OK);
     nsCOMPtr<nsIPrincipal> principal = document->NodePrincipal();
     nsCOMPtr<nsIPermissionManager> permMgr =
       do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
     NS_ENSURE_TRUE(permMgr, NS_OK);
 
-    PRUint32 permission = nsIPermissionManager::DENY_ACTION;
+    uint32_t permission = nsIPermissionManager::DENY_ACTION;
     permMgr->TestPermissionFromPrincipal(principal, "voicemail", &permission);
 
     if (permission != nsIPermissionManager::ALLOW_ACTION) {
       return NS_OK;
     }
 
     nsresult rv = NS_NewVoicemail(window, getter_AddRefs(mVoicemail));
     NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1241,17 +1241,17 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsGlobalWindow)
   return tmp->IsBlackForCC();
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
   if (NS_UNLIKELY(cb.WantDebugInfo())) {
     char name[512];
     PR_snprintf(name, sizeof(name), "nsGlobalWindow #%ld", tmp->mWindowID);
-    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(nsGlobalWindow), name);
+    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name);
   } else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsGlobalWindow, tmp->mRefCnt.get())
   }
 
   if (!cb.WantAllTraces() && tmp->IsBlackForCC()) {
     return NS_SUCCESS_INTERRUPTED_TRAVERSE;
   }
 
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -72,41 +72,40 @@ private:
 // nsJSScriptTimeoutHandler
 // QueryInterface implementation for nsJSScriptTimeoutHandler
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSScriptTimeoutHandler)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSScriptTimeoutHandler)
   tmp->ReleaseJSObjects();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSScriptTimeoutHandler)
   if (NS_UNLIKELY(cb.WantDebugInfo())) {
-    nsCAutoString foo("nsJSScriptTimeoutHandler");
+    nsCAutoString name("nsJSScriptTimeoutHandler");
     if (tmp->mExpr) {
-      foo.AppendLiteral(" [");
-      foo.Append(tmp->mFileName);
-      foo.AppendLiteral(":");
-      foo.AppendInt(tmp->mLineNo);
-      foo.AppendLiteral("]");
+      name.AppendLiteral(" [");
+      name.Append(tmp->mFileName);
+      name.AppendLiteral(":");
+      name.AppendInt(tmp->mLineNo);
+      name.AppendLiteral("]");
     }
     else if (tmp->mFunObj) {
       JSFunction* fun = JS_GetObjectFunction(tmp->mFunObj);
       if (fun && JS_GetFunctionId(fun)) {
         JSFlatString *funId = JS_ASSERT_STRING_IS_FLAT(JS_GetFunctionId(fun));
         size_t size = 1 + JS_PutEscapedFlatString(NULL, 0, funId, 0);
-        char *name = new char[size];
-        if (name) {
-          JS_PutEscapedFlatString(name, size, funId, 0);
-          foo.AppendLiteral(" [");
-          foo.Append(name);
-          delete[] name;
-          foo.AppendLiteral("]");
+        char *funIdName = new char[size];
+        if (funIdName) {
+          JS_PutEscapedFlatString(funIdName, size, funId, 0);
+          name.AppendLiteral(" [");
+          name.Append(funIdName);
+          delete[] funIdName;
+          name.AppendLiteral("]");
         }
       }
     }
-    cb.DescribeRefCountedNode(tmp->mRefCnt.get(),
-                              sizeof(nsJSScriptTimeoutHandler), foo.get());
+    cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name.get());
   }
   else {
     NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsJSScriptTimeoutHandler,
                                       tmp->mRefCnt.get())
   }
 
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContext)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mArgv)
--- a/dom/browser-element/mochitest/Makefile.in
+++ b/dom/browser-element/mochitest/Makefile.in
@@ -58,16 +58,20 @@ MOCHITEST_FILES = \
 		test_browserElement_inproc_XFrameOptions.html \
 		file_browserElement_XFrameOptions.sjs \
 		browserElement_XFrameOptionsDeny.js \
 		test_browserElement_inproc_XFrameOptionsDeny.html \
 		file_browserElement_XFrameOptionsDeny.html \
 		browserElement_XFrameOptionsSameOrigin.js \
 		test_browserElement_inproc_XFrameOptionsSameOrigin.html \
 		file_browserElement_XFrameOptionsSameOrigin.html \
+		browserElement_XFrameOptionsAllowFrom.js \
+		test_browserElement_inproc_XFrameOptionsAllowFrom.html \
+		file_browserElement_XFrameOptionsAllowFrom.html \
+		file_browserElement_XFrameOptionsAllowFrom.sjs \
 		browserElement_Alert.js \
 		test_browserElement_inproc_Alert.html \
 		browserElement_AlertInFrame.js \
 		test_browserElement_inproc_AlertInFrame.html \
 		file_browserElement_AlertInFrame.html \
 		file_browserElement_AlertInFrame_Inner.html \
 		browserElement_TargetTop.js \
 		test_browserElement_inproc_TargetTop.html \
@@ -149,16 +153,17 @@ MOCHITEST_FILES += \
 		test_browserElement_oop_GetScreenshot.html \
 		test_browserElement_oop_SetVisible.html \
 		test_browserElement_oop_SetVisibleFrames.html \
 		test_browserElement_oop_SetVisibleFrames2.html \
 		test_browserElement_oop_KeyEvents.html \
 		test_browserElement_oop_XFrameOptions.html \
 		test_browserElement_oop_XFrameOptionsDeny.html \
 		test_browserElement_oop_XFrameOptionsSameOrigin.html \
+		test_browserElement_oop_XFrameOptionsAllowFrom.html \
 		test_browserElement_oop_Alert.html \
 		test_browserElement_oop_AlertInFrame.html \
 		test_browserElement_oop_TargetTop.html \
 		test_browserElement_oop_ForwardName.html \
 		test_browserElement_oop_TargetBlank.html \
 		test_browserElement_oop_PromptCheck.html \
 		test_browserElement_oop_PromptConfirm.html \
 		test_browserElement_oop_Close.html \
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/browserElement_XFrameOptionsAllowFrom.js
@@ -0,0 +1,53 @@
+/* Any copyright is dedicated to the public domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Bug 690168 - Support Allow-From notation for X-Frame-Options header.
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+
+var initialScreenshot = null;
+
+function runTest() {
+  browserElementTestHelpers.setEnabledPref(true);
+  browserElementTestHelpers.addPermission();
+  var count = 0;
+
+  var iframe = document.createElement('iframe');
+  iframe.mozbrowser = true;
+  iframe.height = '1000px';
+
+  // The innermost page we load will fire an alert when it successfully loads.
+  iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
+    switch (e.detail.message) {
+    case 'step 1':
+      // Make the page wait for us to unblock it (which we do after we finish
+      // taking the screenshot).
+      e.preventDefault();
+
+      iframe.getScreenshot().onsuccess = function(sshot) {
+        if (initialScreenshot == null)
+          initialScreenshot = sshot.target.result;
+        e.detail.unblock();
+      };
+      break;
+    case 'step 2':
+      ok(false, 'cross origin page loaded');
+      break;
+    case 'finish':
+      // The page has now attempted to load the X-Frame-Options page; take
+      // another screenshot.
+      iframe.getScreenshot().onsuccess = function(sshot) {
+        is(sshot.target.result, initialScreenshot, "Screenshots should be identical");
+        SimpleTest.finish();
+      };
+      break;
+    }
+  });
+
+  document.body.appendChild(iframe);
+
+  iframe.src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_XFrameOptionsAllowFrom.html';
+}
+
+runTest();
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/file_browserElement_XFrameOptionsAllowFrom.html
@@ -0,0 +1,43 @@
+<html>
+<body>
+
+  <!-- Try to load in a frame a cross-origin page which sends:
+     "X-Frame-Options: Allow-From http://mochi.test:8888/",
+       and a cross-origin page which sends
+     "X-Frame-Options: Allow-From http://example.com/". -->
+
+<script>
+
+// Make sure these iframes aren't too tall; they both need to fit inside the
+// iframe this page is contained in, without scrolling, in order for the test's
+// screenshots to work properly.
+
+var frame_src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_XFrameOptionsAllowFrom.sjs';
+
+var iframe1 = document.createElement('iframe');
+iframe1.height = '300px';
+var iframe2 = document.createElement('iframe');
+iframe2.height = '300px';
+document.body.appendChild(iframe1);
+document.body.appendChild(iframe2);
+
+iframe1.addEventListener('load', function iframe1Load() {
+  iframe1.removeEventListener('load', iframe1Load);
+  // This causes our embedder to take a screenshot (and blocks until the
+  // screenshot is completed).
+  var iframe2Loaded = false;
+  iframe2.addEventListener('load', function iframe2Load() {
+    iframe2.removeEventListener('load', iframe2Load);
+    iframe2Loaded = true;
+    alert('finish');
+  });
+
+  setTimeout(function() { iframe2.src = frame_src; }, 1000);
+});
+
+
+iframe1.src = frame_src + '?iframe1';
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/file_browserElement_XFrameOptionsAllowFrom.sjs
@@ -0,0 +1,16 @@
+function handleRequest(request, response)
+{
+  var content = 'step 1';
+  if (request.queryString == "iframe1") {
+      response.setHeader("X-Frame-Options", "Allow-From http://mochi.test:8888/")
+      content = 'finish';
+  } else {
+      response.setHeader("X-Frame-Options", "Allow-From http://example.com")
+  }
+
+  response.setHeader("Content-Type", "text/html", false);
+
+  // Tests rely on this page not being entirely blank, because they take
+  // screenshots to determine whether this page was loaded.
+  response.write("<html><body>XFrameOptions test<script>alert('" + content + "')</script></body></html>");
+}
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_inproc_XFrameOptionsAllowFrom.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for Bug 690168</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_XFrameOptionsAllowFrom.js">
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_oop_XFrameOptionsAllowFrom.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for Bug 690168</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_XFrameOptionsAllowFrom.js">
+</script>
+</body>
+</html>
--- a/dom/file/FileRequest.cpp
+++ b/dom/file/FileRequest.cpp
@@ -155,19 +155,8 @@ FileRequest::FireProgressEvent(uint64_t 
   }
 
   bool dummy;
   rv = DispatchEvent(static_cast<nsIDOMProgressEvent*>(event), &dummy);
   if (NS_FAILED(rv)) {
     return;
   }
 }
-
-void
-FileRequest::RootResultVal()
-{
-  NS_ASSERTION(!mRooted, "Don't call me if already rooted!");
-  nsXPCOMCycleCollectionParticipant *participant;
-  CallQueryInterface(this, &participant);
-  nsContentUtils::HoldJSObjects(NS_CYCLE_COLLECTION_UPCAST(this, DOMRequest),
-                                participant);
-  mRooted = true;
-}
--- a/dom/file/FileRequest.h
+++ b/dom/file/FileRequest.h
@@ -46,19 +46,16 @@ public:
 
 private:
   FileRequest(nsIDOMWindow* aWindow);
   ~FileRequest();
 
   void
   FireProgressEvent(uint64_t aLoaded, uint64_t aTotal);
 
-  virtual void
-  RootResultVal();
-
   nsRefPtr<LockedFile> mLockedFile;
   bool mIsFileRequest;
 
   NS_DECL_EVENT_HANDLER(progress)
 };
 
 END_FILE_NAMESPACE
 
--- a/dom/indexedDB/ipc/test_ipc.html
+++ b/dom/indexedDB/ipc/test_ipc.html
@@ -25,71 +25,89 @@
 
       content.wrappedJSObject.RunSet.reloadAndRunAll({
         preventDefault: function() { },
         __exposedProps__: { preventDefault: 'r' }
       });
     }
 
     function iframeScriptSecond() {
+      let isMainProcess = content.wrappedJSObject.SpecialPowers.isMainProcess();
+
+      sendAsyncMessage("test:indexedDB:ipcProcessType",
+                       { isMainProcess: isMainProcess });
+
       let TestRunner = content.wrappedJSObject.TestRunner;
 
       let oldComplete = TestRunner.onComplete;
 
       TestRunner.onComplete = function() {
         TestRunner.onComplete = oldComplete;
 
-        sendAsyncMessage("test:indexedDB:ipcTestComplete", {
-          result: JSON.stringify(TestRunner._failedTests)
-        });
+        sendAsyncMessage("test:indexedDB:ipcTestComplete");
 
         if (oldComplete) {
           oldComplete();
         }
       };
 
-      let oldLog = TestRunner.log;
-      TestRunner.log = function(msg) {
+      function sendTestMessage(msg) {
         sendAsyncMessage("test:indexedDB:ipcTestMessage", { msg: msg });
       }
+
+      TestRunner.log = sendTestMessage;
+      TestRunner.error = sendTestMessage;
     }
 
     let regexString =
       "^(TEST-PASS|TEST-UNEXPECTED-PASS|TEST-KNOWN-FAIL|TEST-UNEXPECTED-FAIL" +
-      "|TEST-DEBUG-INFO) \\| ([^\\|]+) \\|(.*)";
+      "|TEST-DEBUG-INFO|TEST-INFO) \\| ([^\\|]+) \\|(.*)";
 
     let regex = new RegExp(regexString);
 
+    let seenTestMessage = false;
+
     function onTestMessage(data) {
-      let message = SpecialPowers.wrap(data).json.msg;
+      seenTestMessage = true;
+      let message = SpecialPowers.wrap(data).data.msg;
       let match = regex.exec(message);
       if (match) {
         let state = match[1];
         let details = match[2] + " | " + match[3];
 
         switch (state) {
           case "TEST-PASS":
           case "TEST-KNOWN-FAIL":
             ok(true, details);
             break;
 
           case "TEST-UNEXPECTED-FAIL":
           case "TEST-UNEXPECTED-PASS":
             ok(false, details);
             break;
 
+          case "TEST-INFO":
           case "TEST-DEBUG-INFO":
           default:
             info(details);
         }
       }
     }
 
+    let usingChildProcess = false;
+
+    function onProcessType(data) {
+      let isMainProcess = SpecialPowers.wrap(data).data.isMainProcess;
+      usingChildProcess = !isMainProcess;
+    }
+
     function onTestComplete() {
-      ok(true, "Got test complete message");
+      is(usingChildProcess, true, "Expecting to run in child process");
+      is(seenTestMessage, true, "Expecting to receive messages from child");
+      SpecialPowers.removePermission("browser", window.location.href);
       SimpleTest.executeSoon(function () { SimpleTest.finish(); });
     }
 
     function runTests() {
       let iframe = document.createElement("iframe");
       iframe.mozbrowser = true;
       iframe.id = "iframe";
       iframe.style.width = "100%";
@@ -118,16 +136,17 @@
 
         mm.addMessageListener("SPPrefService", spObserver);
         mm.addMessageListener("SPProcessCrashService", spObserver);
         mm.addMessageListener("SPPingService", spObserver);
         mm.addMessageListener("SpecialPowers.Quit", spObserver);
         mm.addMessageListener("SPPermissionManager", spObserver);
 
         mm.addMessageListener("test:indexedDB:ipcTestMessage", onTestMessage);
+        mm.addMessageListener("test:indexedDB:ipcProcessType", onProcessType);
         mm.addMessageListener("test:indexedDB:ipcTestComplete", onTestComplete);
 
         let specialPowersBase = "chrome://specialpowers/content/";
         mm.loadFrameScript(specialPowersBase + "MozillaLogger.js", false);
         mm.loadFrameScript(specialPowersBase + "specialpowersAPI.js", false);
         mm.loadFrameScript(specialPowersBase + "specialpowers.js", false);
 
         mm.loadFrameScript("data:,(" + iframeScriptFirst.toString() + ")();",
@@ -141,30 +160,19 @@
       href = href.substring(0, href.lastIndexOf('/'));
       href = href.substring(0, href.lastIndexOf('/'));
       iframe.src = href + "/test?consoleLevel=INFO";
 
       document.body.appendChild(iframe);
     }
 
     addEventListener("load", function() {
-      let whitelist;
-      try {
-        whitelist =
-          SpecialPowers.getCharPref("dom.mozBrowserFramesWhitelist") + ", ";
-      } catch (e) {
-        whitelist = "";
-      }
-
-      whitelist += window.location.protocol + "//" + window.location.host;
-
+      SpecialPowers.addPermission("browser", true, document);
       SpecialPowers.pushPrefEnv({
         "set": [
           ["dom.ipc.browser_frames.oop_by_default", true],
-          ["dom.mozBrowserFramesEnabled", true],
-          ["dom.mozBrowserFramesWhitelist", whitelist],
-          ["browser.pageThumbs.enabled", false]
+          ["dom.mozBrowserFramesEnabled", true]
         ]
       }, runTests);
     });
   </script>
 </body>
 </html>
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -3772,16 +3772,22 @@ void nsPluginInstanceOwner::SetFrame(nsO
       for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
         nsIScrollableFrame* sf = do_QueryFrame(f);
         if (sf) {
           sf->AddScrollPositionListener(this);
         }
       }
     }
 #endif
+    
+    nsFocusManager* fm = nsFocusManager::GetFocusManager();
+    const nsIContent* content = aFrame->GetContent();
+    if (fm && content) {
+      mContentFocused = (content == fm->GetFocusedContent());
+    }
   }
 }
 
 nsObjectFrame* nsPluginInstanceOwner::GetFrame()
 {
   return mObjectFrame;
 }
 
--- a/dom/plugins/test/mochitest/Makefile.in
+++ b/dom/plugins/test/mochitest/Makefile.in
@@ -59,16 +59,17 @@ MOCHITEST_FILES = \
   crashing_subpage.html \
   test_GCrace.html \
   test_propertyAndMethod.html \
   test_bug539565-1.html \
   test_bug539565-2.html \
   test_bug771202.html \
   file_bug771202.html \
   test_bug777098.html \
+  test_bug751809.html \
   test_enumerate.html \
   test_npruntime_construct.html \
   307-xo-redirect.sjs \
   test_redirect_handling.html \
   test_zero_opacity.html \
   test_NPPVpluginWantsAllNetworkStreams.html \
   test_npruntime_npnsetexception.html \
   test_NPNVdocumentOrigin.html \
new file mode 100644
--- /dev/null
+++ b/dom/plugins/test/mochitest/test_bug751809.html
@@ -0,0 +1,92 @@
+<html>
+<head>
+  <title>Bug 751809</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+
+<body>
+  <script type="application/javascript">
+  
+  SimpleTest.waitForExplicitFinish();
+  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+
+  const Ci = Components.interfaces;
+  const utils = window.QueryInterface(Ci.nsIInterfaceRequestor).
+                                    getInterface(Ci.nsIDOMWindowUtils);
+
+  function waitForCondition(condition, nextTest, errorMsg) {
+    var tries = 0;
+    var interval = setInterval(function() {
+      if (tries >= 30) {
+        ok(false, errorMsg);
+        moveOn();
+      }
+      if (condition()) {
+        moveOn();
+      }
+      tries++;
+    }, 100);
+    var moveOn = function() { clearInterval(interval); nextTest(); };
+  }
+    
+  function startFocusTest() {
+    var plugin = document.getElementById('plugin');
+    ok(plugin, "Got plugin element.");
+    
+    var condition = function() plugin.getBoundingClientRect().width == 400;
+    waitForCondition(condition, afterPluginInsertion, "Waited too long for plugin to show up in page");
+  }
+    
+  function afterPluginInsertion() {
+    var plugin = document.getElementById('plugin');
+    var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
+    ok(!objLoadingContent.activated, "plugin should not be activated");
+    
+    SimpleTest.waitForFocus(afterWindowFocus);
+  }
+    
+  function afterWindowFocus() {
+    var plugin = document.getElementById('plugin');
+    var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
+    
+    synthesizeMouseAtCenter(plugin, {}, window);
+    var condition = function() objLoadingContent.activated;
+    waitForCondition(condition, afterPluginActivation, "Waited too long for plugin to activate");
+  }
+    
+  function afterPluginActivation() { 
+    var plugin = document.getElementById('plugin');
+    var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
+    ok(objLoadingContent.activated, "plugin should be activated now");
+    try {
+      is(plugin.getMouseUpEventCount(), 0, "Plugin should not have received mouse events yet.");
+    } catch(e) {
+      ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
+    }
+
+    synthesizeMouseAtCenter(plugin, {}, window);
+    var condition = function() plugin.getMouseUpEventCount() > 0;
+    waitForCondition(condition, afterFirstClick, "Waited too long for plugin to receive the mouse click");
+  }
+  
+  function afterFirstClick() {
+    var plugin = document.getElementById('plugin');
+    try {
+      is(plugin.getMouseUpEventCount(), 1, "Plugin should have received 1 mouse up event.");
+    } catch(e) {
+      ok(false, "plugin.getMouseUpEventCount() shouldn't throw");
+    }
+
+    SpecialPowers.clearUserPref("plugins.click_to_play");
+    SimpleTest.finish();
+  }
+
+  SpecialPowers.setBoolPref("plugins.click_to_play", true);
+  document.write('<embed id="plugin" type="application/x-test" width="400" height="400" drawmode="solid" color="FF00FFFF"></embed>');
+  SimpleTest.executeSoon(startFocusTest);
+                   
+  </script>
+</body>
+</html>
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -158,16 +158,17 @@ static bool getEventModel(NPObject* npob
 static bool getReflector(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool isVisible(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getWindowPosition(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool constructObject(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool setSitesWithData(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool setSitesWithDataCapabilities(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getLastKeyText(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getNPNVdocumentOrigin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
+static bool getMouseUpEventCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 
 static const NPUTF8* sPluginMethodIdentifierNames[] = {
   "npnEvaluateTest",
   "npnInvokeTest",
   "npnInvokeDefaultTest",
   "setUndefinedValueTest",
   "identifierToStringTest",
   "timerTest",
@@ -217,17 +218,18 @@ static const NPUTF8* sPluginMethodIdenti
   "getEventModel",
   "getReflector",
   "isVisible",
   "getWindowPosition",
   "constructObject",
   "setSitesWithData",
   "setSitesWithDataCapabilities",
   "getLastKeyText",
-  "getNPNVdocumentOrigin"
+  "getNPNVdocumentOrigin",
+  "getMouseUpEventCount"
 };
 static NPIdentifier sPluginMethodIdentifiers[ARRAY_LENGTH(sPluginMethodIdentifierNames)];
 static const ScriptableFunction sPluginMethodFunctions[] = {
   npnEvaluateTest,
   npnInvokeTest,
   npnInvokeDefaultTest,
   setUndefinedValueTest,
   identifierToStringTest,
@@ -278,17 +280,18 @@ static const ScriptableFunction sPluginM
   getEventModel,
   getReflector,
   isVisible,
   getWindowPosition,
   constructObject,
   setSitesWithData,
   setSitesWithDataCapabilities,
   getLastKeyText,
-  getNPNVdocumentOrigin
+  getNPNVdocumentOrigin,
+  getMouseUpEventCount
 };
 
 STATIC_ASSERT(ARRAY_LENGTH(sPluginMethodIdentifierNames) ==
               ARRAY_LENGTH(sPluginMethodFunctions));
 
 static const NPUTF8* sPluginPropertyIdentifierNames[] = {
   "propertyAndMethod"
 };
@@ -772,16 +775,17 @@ NPP_New(NPMIMEType pluginType, NPP insta
   instanceData->focusState = ACTIVATION_STATE_UNKNOWN;
   instanceData->focusEventCount = 0;
   instanceData->eventModel = 0;
   instanceData->closeStream = false;
   instanceData->wantsAllStreams = false;
   instanceData->asyncDrawing = AD_NONE;
   instanceData->frontBuffer = NULL;
   instanceData->backBuffer = NULL;
+  instanceData->mouseUpEventCount = 0;
   instance->pdata = instanceData;
 
   TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
   if (!scriptableObject) {
     printf("NPN_CreateObject failed to create an object, can't create a plugin instance\n");
     free(instanceData);
     return NPERR_GENERIC_ERROR;
   }
@@ -3644,8 +3648,20 @@ bool getNPNVdocumentOrigin(NPObject* npo
   NPError err = NPN_GetValue(npp, NPNVdocumentOrigin, &origin);
   if (err != NPERR_NO_ERROR) {
     return false;
   }
 
   STRINGZ_TO_NPVARIANT(origin, *result);
   return true;
 }
+
+bool getMouseUpEventCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
+  if (argCount != 0) {
+    return false;
+  }
+  
+  NPP npp = static_cast<TestNPObject*>(npobj)->npp;
+  InstanceData* id = static_cast<InstanceData*>(npp->pdata);
+  INT32_TO_NPVARIANT(id->mouseUpEventCount, *result);
+  return true;
+}
--- a/dom/plugins/test/testplugin/nptest.h
+++ b/dom/plugins/test/testplugin/nptest.h
@@ -145,13 +145,14 @@ typedef struct InstanceData {
   int32_t focusEventCount;
   int32_t eventModel;
   bool closeStream;
   std::string lastKeyText;
   bool wantsAllStreams;
   AsyncDrawing asyncDrawing;
   NPAsyncSurface *frontBuffer;
   NPAsyncSurface *backBuffer;
+  int32_t mouseUpEventCount;
 } InstanceData;
 
 void notifyDidPaint(InstanceData* instanceData);
 
 #endif // nptest_h_
--- a/dom/plugins/test/testplugin/nptest_gtk2.cpp
+++ b/dom/plugins/test/testplugin/nptest_gtk2.cpp
@@ -249,16 +249,19 @@ MotionEvent(GtkWidget* widget, GdkEventM
 
 static gboolean
 ButtonEvent(GtkWidget* widget, GdkEventButton* event,
             gpointer user_data)
 {
   InstanceData* instanceData = static_cast<InstanceData*>(user_data);
   instanceData->lastMouseX = event->x;
   instanceData->lastMouseY = event->y;
+  if (event->type == GDK_BUTTON_RELEASE) {
+    instanceData->mouseUpEventCount++;
+  }
   return TRUE;
 }
 
 static gboolean
 DeleteWidget(GtkWidget* widget, GdkEvent* event, gpointer user_data)
 {
   InstanceData* instanceData = static_cast<InstanceData*>(user_data);
   // Some plugins do not expect the plug to be removed from the socket before
@@ -413,16 +416,19 @@ pluginHandleEvent(InstanceData* instance
     instanceData->lastMouseY = motion->y;
     break;
   }
   case ButtonPress:
   case ButtonRelease: {
     XButtonEvent* button = &nsEvent->xbutton;
     instanceData->lastMouseX = button->x;
     instanceData->lastMouseY = button->y;
+    if (nsEvent->type == ButtonRelease) {
+      instanceData->mouseUpEventCount++;
+    }
     break;
   }
   default:
     break;
   }
 #endif
 
   return 0;
--- a/dom/plugins/test/testplugin/nptest_macosx.mm
+++ b/dom/plugins/test/testplugin/nptest_macosx.mm
@@ -271,16 +271,19 @@ pluginHandleEvent(InstanceData* instance
       case osEvt:
       {
         Rect globalBounds = {0};
         WindowRef nativeWindow = static_cast<WindowRef>(static_cast<NP_CGContext*>(w->window)->window);
         if (nativeWindow)
           ::GetWindowBounds(nativeWindow, kWindowStructureRgn, &globalBounds);
         instanceData->lastMouseX = carbonEvent->where.h - w->x - globalBounds.left;
         instanceData->lastMouseY = carbonEvent->where.v - w->y - globalBounds.top;
+        if (carbonEvent->what == mouseUp) {
+          instanceData->mouseUpEventCount++;
+        }
         break;
       }
       default:
         return kNPEventNotHandled;
     }
 
     return kNPEventHandled;
   }
@@ -294,16 +297,19 @@ pluginHandleEvent(InstanceData* instance
     case NPCocoaEventDrawRect:
       pluginDraw(instanceData, cocoaEvent);
       break;
     case NPCocoaEventMouseDown:
     case NPCocoaEventMouseUp:
     case NPCocoaEventMouseMoved:
       instanceData->lastMouseX = (int32_t)cocoaEvent->data.mouse.pluginX;
       instanceData->lastMouseY = (int32_t)cocoaEvent->data.mouse.pluginY;
+      if (cocoaEvent->type == NPCocoaEventMouseUp) {
+        instanceData->mouseUpEventCount++;
+      }
       break;
     case NPCocoaEventWindowFocusChanged:
       instanceData->topLevelWindowActivationState = cocoaEvent->data.focus.hasFocus ?
         ACTIVATION_STATE_ACTIVATED : ACTIVATION_STATE_DEACTIVATED;
       instanceData->topLevelWindowActivationEventCount = instanceData->topLevelWindowActivationEventCount + 1;
       break;
     case NPCocoaEventFocusChanged:
       instanceData->focusState = cocoaEvent->data.focus.hasFocus ?
--- a/dom/plugins/test/testplugin/nptest_qt.cpp
+++ b/dom/plugins/test/testplugin/nptest_qt.cpp
@@ -188,16 +188,17 @@ pluginHandleEvent(InstanceData* instance
     ////printf("ButtonPress\n");
     break;
   }
   case ButtonRelease: {
     //printf("ButtonRelease\n");
     XButtonEvent* button = &nsEvent->xbutton;
     instanceData->lastMouseX = button->x;
     instanceData->lastMouseY = button->y;
+    instanceData->mouseUpEventCount++;
     break;
   }
   default:
     break;
   }
 #endif
 
   return 0;
--- a/dom/plugins/test/testplugin/nptest_windows.cpp
+++ b/dom/plugins/test/testplugin/nptest_windows.cpp
@@ -597,16 +597,19 @@ handleEventInternal(InstanceData* instan
     case WM_MBUTTONDOWN:
     case WM_MBUTTONUP:
     case WM_RBUTTONDOWN:
     case WM_RBUTTONUP: {
       int x = instanceData->hasWidget ? 0 : instanceData->winX;
       int y = instanceData->hasWidget ? 0 : instanceData->winY;
       instanceData->lastMouseX = GET_X_LPARAM(pe->lParam) - x;
       instanceData->lastMouseY = GET_Y_LPARAM(pe->lParam) - y;
+      if ((UINT)pe->event == WM_LBUTTONUP) {
+        instanceData->mouseUpEventCount++;
+      }
       return true;
     }
 
     case WM_KEYDOWN:
       instanceData->lastKeyText.erase();
       *result = 0;
       return true;
 
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -460,17 +460,17 @@ RadioInterfaceLayer.prototype = {
   _sendRequestResults: function _sendRequestResults(requestType, options) {
     let target = this._messageManagerByRequest[options.requestId];
     delete this._messageManagerByRequest[options.requestId];
 
     if (!target) {
       return;
     }
 
-    target.syncAsyncMessage(requestType, options);
+    target.sendAsyncMessage(requestType, options);
   },
 
   updateNetworkInfo: function updateNetworkInfo(message) {
     let voiceMessage = message[RIL.NETWORK_INFO_VOICE_REGISTRATION_STATE];
     let dataMessage = message[RIL.NETWORK_INFO_DATA_REGISTRATION_STATE];
     let operatorMessage = message[RIL.NETWORK_INFO_OPERATOR];
     let selectionMessage = message[RIL.NETWORK_INFO_NETWORK_SELECTION_MODE];
 
--- a/dom/telephony/test/marionette/manifest.ini
+++ b/dom/telephony/test/marionette/manifest.ini
@@ -15,8 +15,19 @@ qemu = true
 #expectedfailure = true
 #[test_outgoing_busy.js]
 #expectedfailure = true
 [test_outgoing_reject.js]
 [test_voicemail_statuschanged.py]
 [test_voicemail_number.js]
 [test_incoming_hold_resume.js]
 [test_outgoing_hold_resume.js]
+[test_incoming_already_connected.js]
+[test_incoming_answer_remote_hangup.js]
+[test_incoming_connecting_hangup.js]
+[test_incoming_connecting_remote_hangup.js]
+[test_incoming_hangup_held.js]
+[test_incoming_remote_cancel.js]
+[test_incoming_remote_hangup_held.js]
+[test_outgoing_already_held.js]
+[test_outgoing_answer_local_hangup.js]
+[test_outgoing_remote_hangup_held.js]
+
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_incoming_already_connected.js
@@ -0,0 +1,206 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let outNumber = "5555551111";
+let inNumber = "5555552222";
+let outgoingCall;
+let incomingCall;
+let gotOriginalConnected = false;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    dial();
+  });
+}
+
+function dial() {
+  log("Make an outgoing call.");
+  outgoingCall = telephony.dial(outNumber);
+  ok(outgoingCall);
+  is(outgoingCall.number, outNumber);
+  is(outgoingCall.state, "dialing");
+
+  is(outgoingCall, telephony.active);
+  is(telephony.calls.length, 1);
+  is(telephony.calls[0], outgoingCall);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Call list is now: " + result);
+    is(result[0], "outbound to  " + outNumber + " : unknown");
+    is(result[1], "OK");
+    answer();
+  });
+}
+
+function answer() {
+  log("Answering the outgoing call.");
+
+  // We get no "connecting" event when the remote party answers the call.
+  outgoingCall.onconnected = function onconnectedOut(event) {
+    log("Received 'connected' call event for the original outgoing call.");
+
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "connected");
+    is(outgoingCall, telephony.active);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : active");
+      is(result[1], "OK");
+
+      if(!gotOriginalConnected){
+        gotOriginalConnected = true;
+        simulateIncoming();
+      } else {
+        // Received connected event for original call multiple times (fail)
+        ok(false,
+           "Received 'connected' event for original call multiple times");
+      }
+    });
+  };
+  runEmulatorCmd("gsm accept " + outNumber);
+}
+
+// With one connected call already, simulate an incoming call
+function simulateIncoming() {
+  log("Simulating an incoming call (with one call already connected).");
+
+  telephony.onincoming = function onincoming(event) {
+    log("Received 'incoming' call event.");
+    incomingCall = event.call;
+    ok(incomingCall);
+    is(incomingCall.number, inNumber);
+    is(incomingCall.state, "incoming");
+
+    // Should be two calls now
+    is(telephony.calls.length, 2);
+    is(telephony.calls[0], outgoingCall);
+    is(telephony.calls[1], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : active");
+      is(result[1], "inbound from " + inNumber + " : incoming");
+      is(result[2], "OK");
+      answerIncoming();
+    });
+  };
+  runEmulatorCmd("gsm call " + inNumber);
+}
+
+// Answer incoming call; original outgoing call should be held
+function answerIncoming() {
+  log("Answering the incoming call.");
+
+  let gotConnecting = false;
+  incomingCall.onconnecting = function onconnectingIn(event) { 
+    log("Received 'connecting' call event for incoming/2nd call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connecting");
+    gotConnecting = true;
+  };
+
+  incomingCall.onconnected = function onconnectedIn(event) {
+    log("Received 'connected' call event for incoming/2nd call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connected");
+    ok(gotConnecting);
+
+    is(incomingCall, telephony.active);
+    is(outgoingCall.state, "held");
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : held");
+      is(result[1], "inbound from " + inNumber + " : active");
+      is(result[2], "OK");
+      hangUpOutgoing();
+    });
+  };
+  incomingCall.answer();
+}
+
+// Hang-up original outgoing (now held) call
+function hangUpOutgoing() {
+  log("Hanging up the original outgoing (now held) call.");
+
+  let gotDisconnecting = false;
+  outgoingCall.ondisconnecting = function ondisconnectingOut(event) {
+    log("Received 'disconnecting' call event for original outgoing call.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "disconnecting");
+    gotDisconnecting = true;
+  };
+
+  outgoingCall.ondisconnected = function ondisconnectedOut(event) {
+    log("Received 'disconnected' call event for original outgoing call.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "disconnected");
+    ok(gotDisconnecting);
+
+    // Back to one call now
+    is(telephony.calls.length, 1);
+    is(incomingCall.state, "connected");
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : active");
+      is(result[1], "OK");
+      hangUpIncoming();
+    });
+  };
+  outgoingCall.hangUp();
+}
+
+// Hang-up remaining (incoming) call
+function hangUpIncoming() {
+  log("Hanging up the remaining (incoming) call.");
+
+  let gotDisconnecting = false;
+  incomingCall.ondisconnecting = function ondisconnectingIn(event) {
+    log("Received 'disconnecting' call event for remaining (incoming) call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnecting");
+    gotDisconnecting = true;
+  };
+
+  incomingCall.ondisconnected = function ondisconnectedIn(event) {
+    log("Received 'disconnected' call event for remaining (incoming) call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnected");
+    ok(gotDisconnecting);
+
+    // Zero calls left
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  incomingCall.hangUp();
+}
+
+function cleanUp() {
+  telephony.onincoming = null;
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_incoming_answer_remote_hangup.js
@@ -0,0 +1,107 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let inNumber = "5555551111";
+let incomingCall;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    simulateIncoming();
+  });
+}
+
+function simulateIncoming() {
+  log("Simulating an incoming call.");
+
+  telephony.onincoming = function onincoming(event) {
+    log("Received 'incoming' call event.");
+    incomingCall = event.call;
+    ok(incomingCall);
+    is(incomingCall.number, inNumber);
+    is(incomingCall.state, "incoming");
+
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : incoming");
+      is(result[1], "OK");
+      answerIncoming();
+    });
+  };
+  runEmulatorCmd("gsm call " + inNumber);
+}
+
+function answerIncoming() {
+  log("Answering the incoming call.");
+
+  let gotConnecting = false;
+  incomingCall.onconnecting = function onconnectingIn(event) { 
+    log("Received 'connecting' call event for incoming call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connecting");
+    gotConnecting = true;
+  };
+
+  incomingCall.onconnected = function onconnectedIn(event) {
+    log("Received 'connected' call event for incoming call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connected");
+    ok(gotConnecting);
+
+    is(incomingCall, telephony.active);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : active");
+      is(result[1], "OK");
+      remoteHangUp();
+    });
+  };
+  incomingCall.answer();
+}
+
+function remoteHangUp() {
+  log("Hanging up the call (remotely)");
+
+  // We get no 'disconnecting' event when remote party hangs-up the call
+
+  incomingCall.ondisconnected = function ondisconnected(event) {
+    log("Received 'disconnected' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnected");
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  runEmulatorCmd("gsm cancel " + inNumber);
+}
+
+function cleanUp() {
+  telephony.onincoming = null;
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_incoming_connecting_hangup.js
@@ -0,0 +1,113 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let inNumber = "5555551111";
+let incomingCall;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    simulateIncoming();
+  });
+}
+
+function simulateIncoming() {
+  log("Simulating an incoming call.");
+
+  telephony.onincoming = function onincoming(event) {
+    log("Received 'incoming' call event.");
+    incomingCall = event.call;
+    ok(incomingCall);
+    is(incomingCall.number, inNumber);
+    is(incomingCall.state, "incoming");
+
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : incoming");
+      is(result[1], "OK");
+      answerIncoming();
+    });
+  };
+  runEmulatorCmd("gsm call " + inNumber);
+}
+
+function answerIncoming() {
+  log("Answering the incoming call.");
+
+  incomingCall.onconnecting = function onconnecting(event) { 
+    log("Received 'connecting' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connecting");
+    // Now hang-up the call before it is fully connected
+
+    // Bug 784429: Hang-up while connecting, call is not terminated
+    // If hang-up between 'connecting' and 'connected' states, receive the
+    // 'disconnecting' event but then a 'connected' event, and the call is
+    // never terminated; this test times out waiting for 'disconnected', and
+    // will leave the emulator in a bad state (with an active incoming call).
+    // For now, hangUp after the 'connected' event so this test doesn't
+    // timeout; once the bug is fixed then update and remove the setTimeout
+
+    //hangUp();
+    log("==> Waiting one second, remove wait once bug 784429 is fixed <==");
+    setTimeout(hangUp, 1000);
+  };
+
+  incomingCall.onconnected = function onconnected(event) {
+    log("Received 'connected' call event.");
+  };
+  incomingCall.answer();
+};
+
+function hangUp() {
+  log("Hanging up the incoming call before fully connected.");
+
+  let gotDisconnecting = false;
+  incomingCall.ondisconnecting = function ondisconnecting(event) {
+    log("Received 'disconnecting' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnecting");
+    gotDisconnecting = true;
+  };
+
+  incomingCall.ondisconnected = function ondisconnected(event) {
+    log("Received 'disconnected' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnected");
+    ok(gotDisconnecting);
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  incomingCall.hangUp();
+}
+
+function cleanUp() {
+  telephony.onincoming = null;
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_incoming_connecting_remote_hangup.js
@@ -0,0 +1,95 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let inNumber = "5555551111";
+let incomingCall;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    simulateIncoming();
+  });
+}
+
+function simulateIncoming() {
+  log("Simulating an incoming call.");
+
+  telephony.onincoming = function onincoming(event) {
+    log("Received 'incoming' call event.");
+    incomingCall = event.call;
+    ok(incomingCall);
+    is(incomingCall.number, inNumber);
+    is(incomingCall.state, "incoming");
+
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : incoming");
+      is(result[1], "OK");
+      answerIncoming();
+    });
+  };
+  runEmulatorCmd("gsm call " + inNumber);
+}
+
+function answerIncoming() {
+  log("Answering the incoming call.");
+
+  incomingCall.onconnecting = function onconnecting(event) { 
+    log("Received 'connecting' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connecting");
+    // Now have the remote party hang-up the call before it is fully connected
+    remoteHangUp();
+  };
+
+  incomingCall.onconnected = function onconnected(event) {
+    log("Received 'connected' call event.");
+  };
+  incomingCall.answer();
+};
+
+function remoteHangUp() {
+  log("Hanging up the incoming call (remotely) before fully connected.");
+
+  // We get no 'disconnecting' event when remote party hangs-up the call
+
+  incomingCall.ondisconnected = function ondisconnected(event) {
+    log("Received 'disconnected' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnected");
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  runEmulatorCmd("gsm cancel " + inNumber);
+}
+
+function cleanUp() {
+  telephony.onincoming = null;
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_incoming_hangup_held.js
@@ -0,0 +1,145 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let inNumber = "5555551111";
+let incomingCall;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    simulateIncoming();
+  });
+}
+
+function simulateIncoming() {
+  log("Simulating an incoming call.");
+
+  telephony.onincoming = function onincoming(event) {
+    log("Received 'incoming' call event.");
+    incomingCall = event.call;
+    ok(incomingCall);
+    is(incomingCall.number, inNumber);
+    is(incomingCall.state, "incoming");
+
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : incoming");
+      is(result[1], "OK");
+      answerIncoming();
+    });
+  };
+  runEmulatorCmd("gsm call " + inNumber);
+}
+
+function answerIncoming() {
+  log("Answering the incoming call.");
+
+  let gotConnecting = false;
+  incomingCall.onconnecting = function onconnectingIn(event) { 
+    log("Received 'connecting' call event for incoming call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connecting");
+    gotConnecting = true;
+  };
+
+  incomingCall.onconnected = function onconnectedIn(event) {
+    log("Received 'connected' call event for incoming call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connected");
+    ok(gotConnecting);
+
+    is(incomingCall, telephony.active);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : active");
+      is(result[1], "OK");
+      hold();
+    });
+  };
+  incomingCall.answer();
+}
+
+function hold() {
+  log("Putting the call on hold.");
+
+  let gotHolding = false;
+  incomingCall.onholding = function onholding(event) {
+    log("Received 'holding' call event");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "holding");
+    gotHolding = true;
+  };
+
+  incomingCall.onheld = function onheld(event) {
+    log("Received 'held' call event");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "held");
+    ok(gotHolding);
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : held");
+      is(result[1], "OK");
+      hangUp();
+    });
+  };
+  incomingCall.hold();
+}
+
+function hangUp() {
+  log("Hanging up the held call (local hang-up).");
+
+  let gotDisconnecting = false;
+  incomingCall.ondisconnecting = function ondisconnecting(event) {
+    log("Received 'disconnecting' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnecting");
+    gotDisconnecting = true;
+  };
+
+  incomingCall.ondisconnected = function ondisconnectedOut(event) {
+    log("Received 'disconnected' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnected");
+    ok(gotDisconnecting);
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  incomingCall.hangUp();
+}
+
+function cleanUp() {
+  telephony.onincoming = null;
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_incoming_remote_cancel.js
@@ -0,0 +1,78 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let inNumber = "5555551111";
+let incomingCall;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    simulateIncoming();
+  });
+}
+
+function simulateIncoming() {
+  log("Simulating an incoming call.");
+
+  telephony.onincoming = function onincoming(event) {
+    log("Received 'incoming' call event.");
+    incomingCall = event.call;
+    ok(incomingCall);
+    is(incomingCall.number, inNumber);
+    is(incomingCall.state, "incoming");
+
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : incoming");
+      is(result[1], "OK");
+      cancelIncoming();
+    });
+  };
+  runEmulatorCmd("gsm call " + inNumber);
+}
+
+function cancelIncoming(){
+  log("Remote party cancelling call before it is answered.");
+
+  // We get no 'disconnecting' event when remote party cancels/hangs-up call
+
+  incomingCall.ondisconnected = function ondisconnected(event) {
+    log("Received 'disconnected' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnected");
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  runEmulatorCmd("gsm cancel " + inNumber);
+}
+
+function cleanUp() {
+  telephony.onincoming = null;
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_incoming_remote_hangup_held.js
@@ -0,0 +1,138 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let inNumber = "5555551111";
+let incomingCall;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    simulateIncoming();
+  });
+}
+
+function simulateIncoming() {
+  log("Simulating an incoming call.");
+
+  telephony.onincoming = function onincoming(event) {
+    log("Received 'incoming' call event.");
+    incomingCall = event.call;
+    ok(incomingCall);
+    is(incomingCall.number, inNumber);
+    is(incomingCall.state, "incoming");
+
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : incoming");
+      is(result[1], "OK");
+      answerIncoming();
+    });
+  };
+  runEmulatorCmd("gsm call " + inNumber);
+}
+
+function answerIncoming() {
+  log("Answering the incoming call.");
+
+  let gotConnecting = false;
+  incomingCall.onconnecting = function onconnectingIn(event) { 
+    log("Received 'connecting' call event for incoming call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connecting");
+    gotConnecting = true;
+  };
+
+  incomingCall.onconnected = function onconnectedIn(event) {
+    log("Received 'connected' call event for incoming call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connected");
+    ok(gotConnecting);
+
+    is(incomingCall, telephony.active);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : active");
+      is(result[1], "OK");
+      hold();
+    });
+  };
+  incomingCall.answer();
+}
+
+function hold() {
+  log("Putting the call on hold.");
+
+  let gotHolding = false;
+  incomingCall.onholding = function onholding(event) {
+    log("Received 'holding' call event");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "holding");
+    gotHolding = true;
+  };
+
+  incomingCall.onheld = function onheld(event) {
+    log("Received 'held' call event");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "held");
+    ok(gotHolding);
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : held");
+      is(result[1], "OK");
+      hangUp();
+    });
+  };
+  incomingCall.hold();
+}
+
+function hangUp() {
+  log("Hanging up the held call (remotely).");
+
+  // We get no 'disconnecting' event when remote party hangs-up the call
+
+  incomingCall.ondisconnected = function ondisconnected(event) {
+    log("Received 'disconnected' call event.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnected");
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  runEmulatorCmd("gsm cancel " + inNumber);
+}
+
+function cleanUp() {
+  telephony.onincoming = null;
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_outgoing_already_held.js
@@ -0,0 +1,229 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let inNumber = "5555551111";
+let outNumber = "5555552222";
+let incomingCall;
+let outgoingCall;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    simulateIncoming();
+  });
+}
+
+function simulateIncoming() {
+  log("Simulating an incoming call.");
+
+  telephony.onincoming = function onincoming(event) {
+    log("Received 'incoming' call event.");
+    incomingCall = event.call;
+    ok(incomingCall);
+    is(incomingCall.number, inNumber);
+    is(incomingCall.state, "incoming");
+
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : incoming");
+      is(result[1], "OK");
+      answerIncoming();
+    });
+  };
+  runEmulatorCmd("gsm call " + inNumber);
+}
+
+function answerIncoming() {
+  log("Answering the incoming call.");
+
+  let gotConnecting = false;
+  incomingCall.onconnecting = function onconnectingIn(event) { 
+    log("Received 'connecting' call event for original (incoming) call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connecting");
+    gotConnecting = true;
+  };
+
+  incomingCall.onconnected = function onconnectedIn(event) {
+    log("Received 'connected' call event for original (incoming) call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "connected");
+    ok(gotConnecting);
+
+    is(incomingCall, telephony.active);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : active");
+      is(result[1], "OK");
+      holdCall();
+    });
+  };
+  incomingCall.answer();
+}
+
+// Put the original (incoming) call on hold
+function holdCall(){
+  log("Putting the original (incoming) call on hold.");
+  
+  let gotHolding = false;
+  incomingCall.onholding = function onholding(event) {
+    log("Received 'holding' call event");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "holding");
+    gotHolding = true;
+  };
+
+  incomingCall.onheld = function onheld(event) {
+    log("Received 'held' call event");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "held");
+    ok(gotHolding);
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], incomingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : held");
+      is(result[1], "OK");   
+      dial();
+    });
+  };
+  incomingCall.hold();
+}
+
+// With one call on hold, make outgoing call
+function dial() {
+  log("Making an outgoing call (while have one call already held).");
+  
+  outgoingCall = telephony.dial(outNumber);
+  ok(outgoingCall);
+  is(outgoingCall.number, outNumber);
+  is(outgoingCall.state, "dialing");
+
+  is(outgoingCall, telephony.active);
+  is(telephony.calls.length, 2);
+  is(telephony.calls[0], incomingCall);
+  is(telephony.calls[1], outgoingCall);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Call list is now: " + result);
+    is(result[0], "inbound from " + inNumber + " : held");
+    is(result[1], "outbound to  " + outNumber + " : unknown");
+    is(result[2], "OK");
+    answerOutgoing();
+  });
+}
+
+// Have the outgoing call answered
+function answerOutgoing() {
+  log("Answering the outgoing/2nd call");
+
+  // We get no "connecting" event when the remote party answers the call.
+  outgoingCall.onconnected = function onconnectedOut(event) {
+    log("Received 'connected' call event for outgoing/2nd call.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "connected");
+
+    is(outgoingCall, telephony.active);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "inbound from " + inNumber + " : held");
+      is(result[1], "outbound to  " + outNumber + " : active");
+      is(result[2], "OK");
+      hangUpIncoming();
+    });
+  };
+  runEmulatorCmd("gsm accept " + outNumber);
+}
+
+// Hang-up the original incoming call, which is now held
+function hangUpIncoming() {
+  log("Hanging up the original incoming (now held) call.");
+
+  let gotDisconnecting = false;
+  incomingCall.ondisconnecting = function ondisconnectingIn(event) {
+    log("Received 'disconnecting' call event for original (incoming) call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnecting");
+    gotDisconnecting = true;
+  };
+
+  incomingCall.ondisconnected = function ondisconnectedIn(event) {
+    log("Received 'disconnected' call event for original (incoming) call.");
+    is(incomingCall, event.call);
+    is(incomingCall.state, "disconnected");
+    ok(gotDisconnecting);
+
+    // Now back to one call
+    is(telephony.active, outgoingCall);
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], outgoingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : active");
+      is(result[1], "OK");
+      hangUpOutgoing();
+    });
+  };
+  incomingCall.hangUp();
+}
+
+// Hang-up the remaining (outgoing) call
+function hangUpOutgoing() {
+  log("Hanging up the remaining (outgoing) call.");
+ 
+  let gotDisconnecting = false;
+  outgoingCall.ondisconnecting = function ondisconnectingOut(event) {
+    log("Received 'disconnecting' call event for remaining (outgoing) call.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "disconnecting");
+    gotDisconnecting = true;
+  };
+
+  outgoingCall.ondisconnected = function ondisconnectedOut(event) {
+    log("Received 'disconnected' call event for remaining (outgoing) call.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "disconnected");
+    ok(gotDisconnecting);
+
+    // Now no calls
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  outgoingCall.hangUp();  
+}
+
+function cleanUp() {
+  telephony.onincoming = null;
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_outgoing_answer_local_hangup.js
@@ -0,0 +1,110 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let outgoingCall;
+let outNumber = "5555551111";
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    dial();
+  });
+}
+
+function dial() {
+  log("Make an outgoing call.");
+
+  outgoingCall = telephony.dial(outNumber);
+  ok(outgoingCall);
+  is(outgoingCall.number, outNumber);
+  is(outgoingCall.state, "dialing");
+
+  is(outgoingCall, telephony.active);
+  is(telephony.calls.length, 1);
+  is(telephony.calls[0], outgoingCall);
+
+  outgoingCall.onalerting = function onalerting(event) {
+    log("Received 'alerting' call event.");
+
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "alerting");
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : ringing");
+      is(result[1], "OK");
+      answer();
+    });
+  };
+}
+
+function answer() {
+  log("Answering the outgoing call.");
+
+  // We get no "connecting" event when the remote party answers the call.
+
+  outgoingCall.onconnected = function onconnected(event) {
+    log("Received 'connected' call event.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "connected");
+
+    is(outgoingCall, telephony.active);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : active");
+      is(result[1], "OK");
+      hangUp();
+    });
+  };
+  runEmulatorCmd("gsm accept " + outNumber);
+};
+
+function hangUp() {
+  log("Hanging up the outgoing call (local hang-up).");
+
+  let gotDisconnecting = false;
+  outgoingCall.ondisconnecting = function ondisconnectingOut(event) {
+    log("Received 'disconnecting' call event.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "disconnecting");
+    gotDisconnecting = true;
+  };
+
+  outgoingCall.ondisconnected = function ondisconnectedOut(event) {
+    log("Received 'disconnected' call event.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "disconnected");
+    ok(gotDisconnecting);
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  outgoingCall.hangUp();
+}
+
+function cleanUp() {
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_outgoing_remote_hangup_held.js
@@ -0,0 +1,133 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 10000;
+
+SpecialPowers.addPermission("telephony", true, document);
+
+let telephony = window.navigator.mozTelephony;
+let outNumber = "5555551111";
+let outgoingCall;
+
+function verifyInitialState() {
+  log("Verifying initial state.");
+  ok(telephony);
+  is(telephony.active, null);
+  ok(telephony.calls);
+  is(telephony.calls.length, 0);
+
+  runEmulatorCmd("gsm list", function(result) {
+    log("Initial call list: " + result);
+    is(result[0], "OK");
+    dial();
+  });
+}
+
+function dial() {
+  log("Make an outgoing call.");
+
+  outgoingCall = telephony.dial(outNumber);
+  ok(outgoingCall);
+  is(outgoingCall.number, outNumber);
+  is(outgoingCall.state, "dialing");
+
+  is(outgoingCall, telephony.active);
+  is(telephony.calls.length, 1);
+  is(telephony.calls[0], outgoingCall);
+
+  outgoingCall.onalerting = function onalerting(event) {
+    log("Received 'alerting' call event.");
+
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "alerting");
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : ringing");
+      is(result[1], "OK");
+      answer();
+    });
+  };
+}
+
+function answer() {
+  log("Answering the outgoing call.");
+
+  // We get no "connecting" event when the remote party answers the call.
+
+  outgoingCall.onconnected = function onconnected(event) {
+    log("Received 'connected' call event.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "connected");
+
+    is(outgoingCall, telephony.active);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : active");
+      is(result[1], "OK");
+      hold();
+    });
+  };
+  runEmulatorCmd("gsm accept " + outNumber);
+};
+
+function hold() {
+  log("Holding the outgoing call.");
+
+  outgoingCall.onholding = function onholding(event) {
+    log("Received 'holding' call event.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "holding");
+
+    is(outgoingCall, telephony.active);
+  };
+
+  outgoingCall.onheld = function onheld(event) {
+    log("Received 'held' call event.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "held");
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 1);
+    is(telephony.calls[0], outgoingCall);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "outbound to  " + outNumber + " : held");
+      is(result[1], "OK");
+      hangUp();
+    });
+  };
+  outgoingCall.hold();
+}
+
+function hangUp() {
+  log("Hanging up the outgoing call (remotely).");
+
+  // We get no 'disconnecting' event when remote party hangs-up the call
+  
+  outgoingCall.ondisconnected = function ondisconnected(event) {
+    log("Received 'disconnected' call event.");
+    is(outgoingCall, event.call);
+    is(outgoingCall.state, "disconnected");
+
+    is(telephony.active, null);
+    is(telephony.calls.length, 0);
+
+    runEmulatorCmd("gsm list", function(result) {
+      log("Call list is now: " + result);
+      is(result[0], "OK");
+      cleanUp();
+    });
+  };
+  runEmulatorCmd("gsm cancel " + outNumber);
+}
+
+function cleanUp() {
+  SpecialPowers.removePermission("telephony", document);
+  finish();
+}
+
+// Start the test
+verifyInitialState();
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -966,17 +966,17 @@ XPCShellEnvironment::XPCShellEnvironment
 
 XPCShellEnvironment::~XPCShellEnvironment()
 {
     if (mCx) {
         JS_BeginRequest(mCx);
 
         JSObject* global = GetGlobalObject();
         if (global) {
-            JS_ClearScope(mCx, global);
+            JS_SetAllNonReservedSlotsToUndefined(mCx, global);
         }
         mGlobalHolder.Release();
 
         JSRuntime *rt = JS_GetRuntime(mCx);
         JS_GC(rt);
 
         mCxStack = nullptr;
 
--- a/js/src/builtin/ParallelArray.cpp
+++ b/js/src/builtin/ParallelArray.cpp
@@ -799,17 +799,16 @@ Class ParallelArrayObject::class_ = {
         setElementAttributes,
         setSpecialAttributes,
         deleteProperty,
         deleteElement,
         deleteSpecial,
         enumerate,
         NULL,                // typeof
         NULL,                // thisObject
-        NULL,                // clear
     }
 };
 
 JSObject *
 ParallelArrayObject::initClass(JSContext *cx, JSObject *obj)
 {
     JS_ASSERT(obj->isNative());
 
--- a/js/src/config/Makefile.in
+++ b/js/src/config/Makefile.in
@@ -26,22 +26,16 @@ TARGETS		= $(HOST_PROGRAM) $(SIMPLE_PROG
 ifdef NSBUILDROOT
 override NSBUILDROOT :=
 endif
 
 ifdef GNU_CC
 MODULE_OPTIMIZE_FLAGS = -O3
 endif
 
-ifndef COMPILER_DEPEND
-ifndef MOZ_NATIVE_MAKEDEPEND
-DIRS		+= mkdepend
-endif
-endif
-
 include $(topsrcdir)/config/config.mk
 
 # Do not install util programs
 NO_INSTALL=1
 
 # Force wrap zlib system header if building js as a shared library.
 ifneq (,$(JS_SHARED_LIBRARY)$(MOZ_NATIVE_ZLIB))
 DEFINES += -DMOZ_NATIVE_ZLIB=1
@@ -65,15 +59,8 @@ export:: \
 	$(INSTALL) system_wrappers_js $(DIST)
 
 GARBAGE_DIRS += system_wrappers_js
 endif
 
 GARBAGE += $(srcdir)/*.pyc *.pyc
 
 FORCE:
-
-ifndef COMPILER_DEPEND
-ifdef MKDEPEND_DIR
-clean clobber realclean clobber_all::
-	cd $(MKDEPEND_DIR); $(MAKE) $@
-endif
-endif
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -574,24 +574,16 @@ endif # MOZ_OPTIMIZE
 endif # OS_ARCH=Darwin
 
 ifdef MOZ_USING_CCACHE
 ifdef CLANG_CXX
 export CCACHE_CPP2=1
 endif
 endif
 
-ifdef MOZ_NATIVE_MAKEDEPEND
-MKDEPEND_DIR =
-MKDEPEND = $(MOZ_NATIVE_MAKEDEPEND)
-else
-MKDEPEND_DIR = $(CONFIG_TOOLS)/mkdepend
-MKDEPEND = $(MKDEPEND_DIR)/mkdepend$(BIN_SUFFIX)
-endif
-
 # Set link flags according to whether we want a console.
 ifdef MOZ_WINCONSOLE
 ifeq ($(MOZ_WINCONSOLE),1)
 ifeq ($(OS_ARCH),OS2)
 BIN_FLAGS	+= -Zlinker -PM:VIO
 endif
 ifeq ($(OS_ARCH),WINNT)
 ifdef GNU_CC
@@ -627,17 +619,17 @@ endif
 #
 # Include any personal overrides the user might think are needed.
 #
 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
 -include $(MY_CONFIG)
 
 ######################################################################
 
-GARBAGE		+= $(DEPENDENCIES) $(MKDEPENDENCIES) $(MKDEPENDENCIES).bak core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
+GARBAGE		+= $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
 
 ifeq ($(OS_ARCH),Darwin)
 ifndef NSDISTMODE
 NSDISTMODE=absolute_symlink
 endif
 PWD := $(CURDIR)
 endif
 
@@ -751,16 +743,19 @@ ifdef TIERS
 DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
 STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
 endif
 
 OPTIMIZE_JARS_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/optimizejars.py)
 
 CREATE_PRECOMPLETE_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/createprecomplete.py)
 
+# MDDEPDIR is the subdirectory where dependency files are stored
+MDDEPDIR := .deps
+
 EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/pythonpath.py -I$(DEPTH)/config $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp --target $@)
 EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/pythonpath.py -I$(DEPTH)/config $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp)
 EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR)
 EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC)
 EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC)
 EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist -- $(LD)
 EXPAND_MKSHLIB_ARGS = --uselist
 ifdef SYMBOL_ORDER
deleted file mode 100644
--- a/js/src/config/mkdepend/Makefile.in
+++ /dev/null
@@ -1,51 +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/.
-
-DEPTH		= @DEPTH@
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-USE_STATIC_LIBS = 1
-
-MODULE		 = mkdepend
-HOST_PROGRAM	 = mkdepend$(BIN_SUFFIX)
-ifdef GNU_CC
-MODULE_OPTIMIZE_FLAGS = -O3
-else
-ifeq ($(OS_ARCH),SunOS)
-MODULE_OPTIMIZE_FLAGS = -fast
-endif
-endif
-
-ifeq ($(OS_ARCH),WINNT)
-ifndef GNU_CC
-MODULE_OPTIMIZE_FLAGS = -Ox
-endif
-endif
-
-HOST_CSRCS	= \
-		cppsetup.c \
-		ifparser.c \
-		include.c \
-		main.c \
-		parse.c \
-		pr.c \
-		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-HOST_CFLAGS	+= -DINCLUDEDIR=\"/usr/include\" -DOBJSUFFIX=\".$(OBJ_SUFFIX)\"
-
-ifdef GNU_CC
-_GCCDIR		= $(shell $(CC) -print-file-name=include)
-HOST_CFLAGS	+= -DPREINCDIR=\"$(_GCCDIR)\"
-endif
-
-export:: $(HOST_PROGRAM)
-
-$(HOST_OBJS): def.h ifparser.h imakemdep.h
deleted file mode 100644
--- a/js/src/config/mkdepend/cppsetup.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* $Xorg: cppsetup.c,v 1.5 2001/02/09 02:03:16 xorgcvs Exp $ */
-/*
-
-Copyright (c) 1993, 1994, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/config/makedepend/cppsetup.c,v 3.11 2001/12/17 20:52:22 dawes Exp $ */
-
-#include "def.h"
-
-#ifdef	CPP
-/*
- * This file is strictly for the sake of cpy.y and yylex.c (if
- * you indeed have the source for cpp).
- */
-#define IB 1
-#define SB 2
-#define NB 4
-#define CB 8
-#define QB 16
-#define WB 32
-#define SALT '#'
-#if defined(pdp11) || defined(vax) || defined(ns16000) || defined(mc68000) || defined(ibm032)
-#define COFF 128
-#else
-#define COFF 0
-#endif
-/*
- * These variables used by cpy.y and yylex.c
- */
-extern char	*outp, *inp, *newp, *pend;
-extern char	*ptrtab;
-extern char	fastab[];
-extern char	slotab[];
-
-/*
- * cppsetup
- */
-struct filepointer	*currentfile;
-struct inclist		*currentinc;
-
-int
-cppsetup(char *line, struct filepointer *filep, struct inclist *inc)
-{
-	char *p, savec;
-	static boolean setupdone = FALSE;
-	boolean	value;
-
-	if (!setupdone) {
-		cpp_varsetup();
-		setupdone = TRUE;
-	}
-
-	currentfile = filep;
-	currentinc = inc;
-	inp = newp = line;
-	for (p=newp; *p; p++)
-		;
-
-	/*
-	 * put a newline back on the end, and set up pend, etc.
-	 */
-	*p++ = '\n';
-	savec = *p;
-	*p = '\0';
-	pend = p;
-
-	ptrtab = slotab+COFF;
-	*--inp = SALT; 
-	outp=inp; 
-	value = yyparse();
-	*p = savec;
-	return(value);
-}
-
-struct symtab **lookup(symbol)
-	char	*symbol;
-{
-	static struct symtab    *undefined;
-	struct symtab   **sp;
-
-	sp = isdefined(symbol, currentinc, NULL);
-	if (sp == NULL) {
-		sp = &undefined;
-		(*sp)->s_value = NULL;
-	}
-	return (sp);
-}
-
-pperror(tag, x0,x1,x2,x3,x4)
-	int	tag,x0,x1,x2,x3,x4;
-{
-	warning("\"%s\", line %d: ", currentinc->i_file, currentfile->f_line);
-	warning(x0,x1,x2,x3,x4);
-}
-
-
-yyerror(s)
-	register char	*s;
-{
-	fatalerr("Fatal error: %s\n", s);
-}
-#else /* not CPP */
-
-#include "ifparser.h"
-struct _parse_data {
-    struct filepointer *filep;
-    struct inclist *inc;
-    char *filename;
-    const char *line;
-};
-
-static const char *
-my_if_errors (IfParser *ip, const char *cp, const char *expecting)
-{
-    struct _parse_data *pd = (struct _parse_data *) ip->data;
-    int lineno = pd->filep->f_line;
-    char *filename = pd->filename;
-    char prefix[300];
-    int prefixlen;
-    int i;
-
-    sprintf (prefix, "\"%s\":%d", filename, lineno);
-    prefixlen = strlen(prefix);
-    fprintf (stderr, "%s:  %s", prefix, pd->line);
-    i = cp - pd->line;
-    if (i > 0 && pd->line[i-1] != '\n') {
-	putc ('\n', stderr);
-    }
-    for (i += prefixlen + 3; i > 0; i--) {
-	putc (' ', stderr);
-    }
-    fprintf (stderr, "^--- expecting %s\n", expecting);
-    return NULL;
-}
-
-
-#define MAXNAMELEN 256
-
-static struct symtab **
-lookup_variable (IfParser *ip, const char *var, int len)
-{
-    char tmpbuf[MAXNAMELEN + 1];
-    struct _parse_data *pd = (struct _parse_data *) ip->data;
-
-    if (len > MAXNAMELEN)
-	return 0;
-
-    strncpy (tmpbuf, var, len);
-    tmpbuf[len] = '\0';
-    return isdefined (tmpbuf, pd->inc, NULL);
-}
-
-
-static int
-my_eval_defined (IfParser *ip, const char *var, int len)
-{
-    if (lookup_variable (ip, var, len))
-	return 1;
-    else
-	return 0;
-}
-
-#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
-
-static long
-my_eval_variable (IfParser *ip, const char *var, int len)
-{
-    long val;
-    struct symtab **s;
-
-    s = lookup_variable (ip, var, len);
-    if (!s)
-	return 0;
-    do {
-	var = (*s)->s_value;
-	if (!isvarfirstletter(*var) || !strcmp((*s)->s_name, var))
-	    break;
-	s = lookup_variable (ip, var, strlen(var));
-    } while (s);
-
-    var = ParseIfExpression(ip, var, &val);
-    if (var && *var) debug(4, ("extraneous: '%s'\n", var));
-    return val;
-}
-
-int
-cppsetup(char *filename,
-	 char *line,
-	 struct filepointer *filep,
-	 struct inclist *inc)
-{
-    IfParser ip;
-    struct _parse_data pd;
-    long val = 0;
-
-    pd.filep = filep;
-    pd.inc = inc;
-    pd.line = line;
-    pd.filename = filename;
-    ip.funcs.handle_error = my_if_errors;
-    ip.funcs.eval_defined = my_eval_defined;
-    ip.funcs.eval_variable = my_eval_variable;
-    ip.data = (char *) &pd;
-
-    (void) ParseIfExpression (&ip, line, &val);
-    if (val)
-	return IF;
-    else
-	return IFFALSE;
-}
-#endif /* CPP */
-
deleted file mode 100644
--- a/js/src/config/mkdepend/def.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/* $Xorg: def.h,v 1.4 2001/02/09 02:03:16 xorgcvs Exp $ */
-/*
-
-Copyright (c) 1993, 1994, 1998 The Open Group.
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-/* $XFree86: xc/config/makedepend/def.h,v 3.14 2003/01/17 17:09:49 tsi Exp $ */
-
-#ifndef NO_X11
-#include <X11/Xos.h>
-#include <X11/Xfuncproto.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#if 0
-#ifndef X_NOT_POSIX
-#ifndef _POSIX_SOURCE
-#define _POSIX_SOURCE
-#endif
-#endif
-#endif
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#define MAXDEFINES	512
-#define MAXFILES	1024
-#define MAXINCFILES	256	/* "-include" files */
-#define MAXDIRS		1024
-#define SYMTABINC	10	/* must be > 1 for define() to work right */
-#define	TRUE		1
-#define	FALSE		0
-
-/* the following must match the directives table in main.c */
-#define	IF		0
-#define	IFDEF		1
-#define	IFNDEF		2
-#define	ELSE		3
-#define	ENDIF		4
-#define	DEFINE		5
-#define	UNDEF		6
-#define	INCLUDE		7
-#define	LINE		8
-#define	PRAGMA		9
-#define ERROR           10
-#define IDENT           11
-#define SCCS            12
-#define ELIF            13
-#define EJECT           14
-#define WARNING         15
-#define INCLUDENEXT     16
-#define IFFALSE         17     /* pseudo value --- never matched */
-#define ELIFFALSE       18     /* pseudo value --- never matched */
-#define INCLUDEDOT      19     /* pseudo value --- never matched */
-#define IFGUESSFALSE    20     /* pseudo value --- never matched */
-#define ELIFGUESSFALSE  21     /* pseudo value --- never matched */
-#define INCLUDENEXTDOT  22     /* pseudo value --- never matched */
-
-#ifdef DEBUG
-extern int	_debugmask;
-/*
- * debug levels are:
- * 
- *     0	show ifn*(def)*,endif
- *     1	trace defined/!defined
- *     2	show #include
- *     3	show #include SYMBOL
- *     4-6	unused
- */
-#define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }
-#else
-#define	debug(level,arg) /**/
-#endif /* DEBUG */
-
-typedef	unsigned char boolean;
-
-struct symtab {
-	char	*s_name;
-	char	*s_value;
-};
-
-/* possible i_flag */
-#define DEFCHECKED	(1<<0)	/* whether defines have been checked */
-#define NOTIFIED	(1<<1)	/* whether we have revealed includes */
-#define MARKED		(1<<2)	/* whether it's in the makefile */
-#define SEARCHED	(1<<3)	/* whether we have read this */
-#define FINISHED	(1<<4)	/* whether we are done reading this */
-#define INCLUDED_SYM	(1<<5)	/* whether #include SYMBOL was found
-				   Can't use i_list if TRUE */
-struct	inclist {
-	char		*i_incstring;	/* string from #include line */
-	char		*i_file;	/* path name of the include file */
-	struct inclist	**i_list;	/* list of files it itself includes */
-	int		i_listlen;	/* length of i_list */
-	struct symtab	**i_defs;	/* symbol table for this file and its
-					   children when merged */
-	int		i_ndefs;	/* current # defines */
-	boolean		*i_merged;      /* whether we have merged child
-					   defines */
-	unsigned char   i_flags;
-};
-
-struct filepointer {
-	char	*f_name;
-	char	*f_p;
-	char	*f_base;
-	char	*f_end;
-	long	f_len;
-	long	f_line;
-	long	cmdinc_count;
-	char	**cmdinc_list;
-	long	cmdinc_line;
-};
-
-#include <stdlib.h>
-#if defined(macII) && !defined(__STDC__)  /* stdlib.h fails to define these */
-char *malloc(), *realloc();
-#endif /* macII */
-
-char			*copy(char *str);
-int                     match(char *str, char **list);
-char			*base_name(char *file);
-char			*getnextline(struct filepointer *fp);
-struct symtab		**slookup(char *symbol, struct inclist *file);
-struct symtab		**isdefined(char *symbol, struct inclist *file,
-				    struct inclist **srcfile);
-struct symtab		**fdefined(char *symbol, struct inclist *file,
-				   struct inclist **srcfile);
-struct filepointer	*getfile(char *file);
-void                    included_by(struct inclist *ip, 
-				    struct inclist *newfile);
-struct inclist		*newinclude(char *newfile, char *incstring);
-void                    inc_clean (void);
-struct inclist		*inc_path(char *file, char *include, int type);
-
-void                    freefile(struct filepointer *fp);
-
-void                    define2(char *name, char *val, struct inclist *file);
-void                    define(char *def, struct inclist *file);
-void                    undefine(char *symbol, struct inclist *file);
-int                     find_includes(struct filepointer *filep, 
-				      struct inclist *file, 
-				      struct inclist *file_red, 
-				      int recursion, boolean failOK);
-
-void                    recursive_pr_include(struct inclist *head, 
-					     char *file, char *base);
-void                    add_include(struct filepointer *filep, 
-				    struct inclist *file, 
-				    struct inclist *file_red, 
-				    char *include, int type,
-				    boolean failOK);
-
-int                     cppsetup(char *filename,
-				 char *line,
-				 struct filepointer *filep,
-				 struct inclist *inc);
-
-
-extern void fatalerr(char *, ...);
-extern void warning(char *, ...);
-extern void warning1(char *, ...);
deleted file mode 100644
--- a/js/src/config/mkdepend/ifparser.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * $Xorg: ifparser.c,v 1.3 2000/08/17 19:41:50 cpqbld Exp $
- *
- * Copyright 1992 Network Computing Devices, Inc.
- * 
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Network Computing Devices may not be
- * used in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Network Computing Devices makes
- * no representations about the suitability of this software for any purpose.
- * It is provided ``as is'' without express or implied warranty.
- * 
- * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- * 
- * Author:  Jim Fulton
- *          Network Computing Devices, Inc.
- * 
- * Simple if statement processor
- *
- * This module can be used to evaluate string representations of C language
- * if constructs.  It accepts the following grammar:
- * 
- *     EXPRESSION	:=	VALUE
- * 			 |	VALUE  BINOP	EXPRESSION
- *			 |	VALUE	'?'	EXPRESSION ':'	EXPRESSION
- * 
- *     VALUE		:=	'('  EXPRESSION  ')'
- * 			 |	'!'  VALUE
- * 			 |	'-'  VALUE
- * 			 |	'+'  VALUE
- *			 |	'~'  VALUE
- * 			 |	'defined'  '('  variable  ')'
- * 			 |	'defined'  variable
- *			 |	# variable '(' variable-list ')'
- * 			 |	variable
- * 			 |	number
- * 
- *     BINOP		:=	'*'	|  '/'	|  '%'
- * 			 |	'+'	|  '-'
- * 			 |	'<<'	|  '>>'
- * 			 |	'<'	|  '>'	|  '<='  |  '>='
- * 			 |	'=='	|  '!='
- * 			 |	'&'	|  '^'  |  '|'
- * 			 |	'&&'	|  '||'
- * 
- * The normal C order of precedence is supported.
- * 
- * 
- * External Entry Points:
- * 
- *     ParseIfExpression		parse a string for #if
- */
-/* $XFree86: xc/config/makedepend/ifparser.c,v 3.11 2002/09/23 01:48:08 tsi Exp $ */
-
-#include "ifparser.h"
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-/****************************************************************************
-		   Internal Macros and Utilities for Parser
- ****************************************************************************/
-
-#define DO(val) if (!(val)) return NULL
-#define CALLFUNC(ggg,fff) (*((ggg)->funcs.fff))
-#define SKIPSPACE(ccc) while (isspace(*ccc)) ccc++
-#define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')
-
-
-static const char *
-parse_variable (IfParser *g, const char *cp, const char **varp)
-{
-    SKIPSPACE (cp);
-
-    if (!isvarfirstletter (*cp))
-	return CALLFUNC(g, handle_error) (g, cp, "variable name");
-
-    *varp = cp;
-    /* EMPTY */
-    for (cp++; isalnum(*cp) || *cp == '_'; cp++) ;
-    return cp;
-}
-
-
-static const char *
-parse_number (IfParser *g, const char *cp, long *valp)
-{
-    long base = 10;
-    SKIPSPACE (cp);
-
-    if (!isdigit(*cp))
-	return CALLFUNC(g, handle_error) (g, cp, "number");
-
-    *valp = 0;
-
-    if (*cp == '0') {
-	cp++;
-	if ((*cp == 'x') || (*cp == 'X')) {
-	    base = 16;
-	    cp++;
-	} else {
-	    base = 8;
-	}
-    }
-
-    /* Ignore overflows and assume ASCII, what source is usually written in */
-    while (1) {
-	int increment = -1;
-	if (base == 8) {
-	    if ((*cp >= '0') && (*cp <= '7'))
-		increment = *cp++ - '0';
-	} else if (base == 16) {
-	    if ((*cp >= '0') && (*cp <= '9'))
-		increment = *cp++ - '0';
-	    else if ((*cp >= 'A') &&  (*cp <= 'F'))
-		increment = *cp++ - ('A' - 10);
-	    else if ((*cp >= 'a') && (*cp <= 'f'))
-		increment = *cp++ - ('a' - 10);
-	} else {	/* Decimal */
-	    if ((*cp >= '0') && (*cp <= '9'))
-		increment = *cp++ - '0';
-	}
-	if (increment < 0)
-	    break;
-	*valp = (*valp * base) + increment;
-    }
-
-    /* Skip trailing qualifiers */
-    while (*cp == 'U' || *cp == 'u' || *cp == 'L' || *cp == 'l') cp++;
-    return cp;
-}
-
-static const char *
-parse_character (IfParser *g, const char *cp, long *valp)
-{
-    char val;
-
-    SKIPSPACE (cp);
-    if (*cp == '\\')
-	switch (cp[1]) {
-	case 'n': val = '\n'; break;
-	case 't': val = '\t'; break;
-	case 'v': val = '\v'; break;
-	case 'b': val = '\b'; break;
-	case 'r': val = '\r'; break;
-	case 'f': val = '\f'; break;
-	case 'a': val = '\a'; break;
-	case '\\': val = '\\'; break;
-	case '?': val = '\?'; break;
-	case '\'': val = '\''; break;
-	case '\"': val = '\"'; break;
-	case 'x': val = (char) strtol (cp + 2, NULL, 16); break;
-	default: val = (char) strtol (cp + 1, NULL, 8); break;
-	}
-    else
-	val = *cp;
-    while (*cp != '\'') cp++;
-    *valp = (long) val;
-    return cp;
-}
-
-static const char *
-parse_value (IfParser *g, const char *cp, long *valp)
-{
-    const char *var, *varend;
-
-    *valp = 0;
-
-    SKIPSPACE (cp);
-    if (!*cp)
-	return cp;
-
-    switch (*cp) {
-      case '(':
-	DO (cp = ParseIfExpression (g, cp + 1, valp));
-	SKIPSPACE (cp);
-	if (*cp != ')') 
-	    return CALLFUNC(g, handle_error) (g, cp, ")");
-
-	return cp + 1;			/* skip the right paren */
-
-      case '!':
-	DO (cp = parse_value (g, cp + 1, valp));
-	*valp = !(*valp);
-	return cp;
-
-      case '-':
-	DO (cp = parse_value (g, cp + 1, valp));
-	*valp = -(*valp);
-	return cp;
-
-      case '+':
-	DO (cp = parse_value (g, cp + 1, valp));
-	return cp;
-
-      case '~':
-	DO (cp = parse_value (g, cp + 1, valp));
-	*valp = ~(*valp);
-	return cp;
-
-      case '#':
-	DO (cp = parse_variable (g, cp + 1, &var));
-	SKIPSPACE (cp);
-	if (*cp != '(')
-	    return CALLFUNC(g, handle_error) (g, cp, "(");
-	do {
-	    DO (cp = parse_variable (g, cp + 1, &var));
-	    SKIPSPACE (cp);
-	} while (*cp && *cp != ')');
-	if (*cp != ')')
-	    return CALLFUNC(g, handle_error) (g, cp, ")");
-	*valp = 1; /* XXX */
-	return cp + 1;
-
-      case '\'':
-	DO (cp = parse_character (g, cp + 1, valp));
-	if (*cp != '\'')
-	    return CALLFUNC(g, handle_error) (g, cp, "'");
-	return cp + 1;
-
-      case 'd':
-	if (strncmp (cp, "defined", 7) == 0 && !isalnum(cp[7])) {
-	    int paren = 0;
-	    int len;
-
-	    cp += 7;
-	    SKIPSPACE (cp);
-	    if (*cp == '(') {
-		paren = 1;
-		cp++;
-	    }
-	    DO (cp = parse_variable (g, cp, &var));
-	    len = cp - var;
-	    SKIPSPACE (cp);
-	    if (paren && *cp != ')')
-		return CALLFUNC(g, handle_error) (g, cp, ")");
-	    *valp = (*(g->funcs.eval_defined)) (g, var, len);
-	    return cp + paren;		/* skip the right paren */
-	}
-	/* fall out */
-    }
-
-    if (isdigit(*cp)) {
-	DO (cp = parse_number (g, cp, valp));
-    } else if (!isvarfirstletter(*cp))
-	return CALLFUNC(g, handle_error) (g, cp, "variable or number");
-    else {
-	DO (cp = parse_variable (g, cp, &var));
-	varend = cp;
-	SKIPSPACE(cp);
-	if (*cp != '(') {
-	    *valp = (*(g->funcs.eval_variable)) (g, var, varend - var);
-	} else {
-	    do {
-		long dummy;
-		DO (cp = ParseIfExpression (g, cp + 1, &dummy));
-		SKIPSPACE(cp);
-		if (*cp == ')')
-		    break;
-		if (*cp != ',')
-		    return CALLFUNC(g, handle_error) (g, cp, ",");
-	    } while (1);
-
-	    *valp = 1;	/* XXX */
-	    cp++;
-	}
-    }
-    
-    return cp;
-}
-
-
-
-static const char *
-parse_product (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_value (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '*':
-	DO (cp = parse_product (g, cp + 1, &rightval));
-	*valp = (*valp * rightval);
-	break;
-
-      case '/':
-	DO (cp = parse_product (g, cp + 1, &rightval));
-	if (rightval == 0)
-	  return CALLFUNC(g, handle_error) (g, cp, "0");
-	*valp = (*valp / rightval);
-	break;
-
-      case '%':
-	DO (cp = parse_product (g, cp + 1, &rightval));
-	*valp = (*valp % rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_sum (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_product (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '+':
-	DO (cp = parse_sum (g, cp + 1, &rightval));
-	*valp = (*valp + rightval);
-	break;
-
-      case '-':
-	DO (cp = parse_sum (g, cp + 1, &rightval));
-	*valp = (*valp - rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_shift (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_sum (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '<':
-	if (cp[1] == '<') {
-	    DO (cp = parse_shift (g, cp + 2, &rightval));
-	    *valp = (*valp << rightval);
-	}
-	break;
-
-      case '>':
-	if (cp[1] == '>') {
-	    DO (cp = parse_shift (g, cp + 2, &rightval));
-	    *valp = (*valp >> rightval);
-	}
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_inequality (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_shift (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '<':
-	if (cp[1] == '=') {
-	    DO (cp = parse_inequality (g, cp + 2, &rightval));
-	    *valp = (*valp <= rightval);
-	} else {
-	    DO (cp = parse_inequality (g, cp + 1, &rightval));
-	    *valp = (*valp < rightval);
-	}
-	break;
-
-      case '>':
-	if (cp[1] == '=') {
-	    DO (cp = parse_inequality (g, cp + 2, &rightval));
-	    *valp = (*valp >= rightval);
-	} else {
-	    DO (cp = parse_inequality (g, cp + 1, &rightval));
-	    *valp = (*valp > rightval);
-	}
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_equality (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_inequality (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '=':
-	if (cp[1] == '=')
-	    cp++;
-	DO (cp = parse_equality (g, cp + 1, &rightval));
-	*valp = (*valp == rightval);
-	break;
-
-      case '!':
-	if (cp[1] != '=')
-	    break;
-	DO (cp = parse_equality (g, cp + 2, &rightval));
-	*valp = (*valp != rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_band (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_equality (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '&':
-	if (cp[1] != '&') {
-	    DO (cp = parse_band (g, cp + 1, &rightval));
-	    *valp = (*valp & rightval);
-	}
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_bxor (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_band (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '^':
-	DO (cp = parse_bxor (g, cp + 1, &rightval));
-	*valp = (*valp ^ rightval);
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-parse_bor (IfParser *g, const char *cp, long *valp)
-{
-    long rightval;
-
-    DO (cp = parse_bxor (g, cp, valp));
-    SKIPSPACE (cp);
-
-    switch (*cp) {
-      case '|':
-	if (cp[1] != '|') {
-	    DO (cp = parse_bor (g, cp + 1, &rightval));
-	    *valp = (*valp | rightval);
-	}
-	break;
-    }
-    return cp;
-}
-
-
-static const char *
-par