Index: linkers/main.cpp
===================================================================
--- linkers/main.cpp	(revision aef6d9018087bd74d9796307b62d5ebb0e37ac90)
+++ linkers/main.cpp	(revision 746192499f21a467b00d3c9c10ffd818d59e44e1)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2011, Chris Johns <chrisj@rtems.org>
+ * Copyright (c) 2011-2012, Chris Johns <chrisj@rtems.org>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
@@ -38,5 +38,5 @@
 
 #include <rld.h>
-#include <rld-gcc.h>
+#include <rld-cc.h>
 #include <rld-outputter.h>
 #include <rld-process.h>
@@ -48,5 +48,5 @@
 
 /**
- * RTEMS Linker options. This needs to be rewritten to be like gcc where only a
+ * RTEMS Linker options. This needs to be rewritten to be like cc where only a
  * single '-' and long options is present.
  */
@@ -58,15 +58,16 @@
   { "map",         no_argument,            NULL,           'M' },
   { "output",      required_argument,      NULL,           'o' },
+  { "script",      no_argument,            NULL,           'S' },
   { "lib-path",    required_argument,      NULL,           'L' },
   { "lib",         required_argument,      NULL,           'l' },
   { "no-stdlibs",  no_argument,            NULL,           'n' },
-  { "exec-prefix", required_argument,      NULL,           'E' },
-  { "march",       required_argument,      NULL,           'a' },
-  { "mcpu",        required_argument,      NULL,           'c' },
   { "entry",       required_argument,      NULL,           'e' },
   { "define",      required_argument,      NULL,           'd' },
   { "undefined",   required_argument,      NULL,           'u' },
   { "base",        required_argument,      NULL,           'b' },
-  { "script",      no_argument,            NULL,           'S' },
+  { "cc",          required_argument,      NULL,           'C' },
+  { "exec-prefix", required_argument,      NULL,           'E' },
+  { "march",       required_argument,      NULL,           'a' },
+  { "mcpu",        required_argument,      NULL,           'c' },
   { NULL,          0,                      NULL,            0 }
 };
@@ -92,4 +93,5 @@
             << " -M        : generate map output (also --map)" << std::endl
             << " -o file   : linker output is written to file (also --output)" << std::endl
+            << " -S script : linker output is a script file (also --script)" << std::endl
             << " -L path   : path to a library, add multiple for more than" << std::endl
             << "             one path (also --lib-path)" << std::endl
@@ -97,7 +99,4 @@
             << "             for more than one library (also --lib)" << std::endl
             << " -n        : do not search standard libraries (also --no-stdlibs)" << std::endl
-            << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl
-            << " -a march  : machine architecture (also --march)" << std::endl
-            << " -c cpu    : machine architecture's CPU (also --mcpu)" << std::endl
             << " -e entry  : entry point symbol (also --entry)" << std::endl
             << " -d sym    : add the symbol definition, add multiple with" << std::endl
@@ -107,5 +106,8 @@
             << " -b elf    : read the ELF file symbols as the base RTEMS kernel" << std::endl
             << "             image (also --base)" << std::endl
-            << " -S script : linker output is a script file (also --script)" << std::endl;
+            << " -C file   : execute file as the target C compiler (also --cc)" << std::endl
+            << " -E prefix : the RTEMS tool prefix (also --exec-prefix)" << std::endl
+            << " -a march  : machine architecture (also --march)" << std::endl
+            << " -c cpu    : machine architecture's CPU (also --mcpu)" << std::endl;
   ::exit (exit_code);
 }
@@ -166,4 +168,5 @@
     std::string         output = "a.out";
     std::string         base_name;
+    std::string         cc_name;
     bool                script = false;
     bool                standard_libs = true;
@@ -176,5 +179,5 @@
     while (true)
     {
-      int opt = ::getopt_long (argc, argv, "hvwVMnSb:E:o:L:l:a:c:e:d:u:", rld_opts, NULL);
+      int opt = ::getopt_long (argc, argv, "hvwVMnSb:E:o:L:l:a:c:e:d:u:C:", rld_opts, NULL);
       if (opt < 0)
         break;
@@ -228,15 +231,21 @@
           break;
 
+        case 'C':
+          if (exec_prefix_set == true)
+            std::cerr << "warning: exec-prefix ignored when CC provided" << std::endl;
+          rld::cc::cc = optarg;
+          break;
+
         case 'E':
           exec_prefix_set = true;
-          rld::gcc::exec_prefix = optarg;
+          rld::cc::exec_prefix = optarg;
           break;
 
         case 'a':
-          rld::gcc::march = optarg;
+          rld::cc::march = optarg;
           break;
 
         case 'c':
-          rld::gcc::mcpu = optarg;
+          rld::cc::mcpu = optarg;
           break;
 
@@ -297,10 +306,11 @@
 
     /*
-     * If the exec-prefix is not set by the command line see if it can be
-     * detected from the object file types. This must be after we have added
-     * the object files.
-     */
-    if (!exec_prefix_set)
-      rld::gcc::exec_prefix = rld::elf::machine_type ();
+     * If the full path to CC is not provided and the exec-prefix is not set by
+     * the command line see if it can be detected from the object file
+     * types. This must be after we have added the object files because they
+     * are used when detecting.
+     */
+    if (rld::cc::cc.empty () && !exec_prefix_set)
+      rld::cc::exec_prefix = rld::elf::machine_type ();
 
     /*
@@ -317,5 +327,5 @@
      * Get the standard library paths
      */
-    rld::gcc::get_standard_libpaths (libpaths);
+    rld::cc::get_standard_libpaths (libpaths);
 
     /*
@@ -328,5 +338,5 @@
      */
     if (standard_libs)
-      rld::gcc::get_standard_libs (libraries, libpaths);
+      rld::cc::get_standard_libs (libraries, libpaths);
 
     /*
Index: linkers/rld-cc.cpp
===================================================================
--- linkers/rld-cc.cpp	(revision 746192499f21a467b00d3c9c10ffd818d59e44e1)
+++ linkers/rld-cc.cpp	(revision 746192499f21a467b00d3c9c10ffd818d59e44e1)
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2011-2012, Chris Johns <chrisj@rtems.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, 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.
+ */
+
+#include <string.h>
+
+#include <fstream>
+
+#include <rld.h>
+#include <rld-cc.h>
+#include <rld-process.h>
+
+namespace rld
+{
+  namespace cc
+  {
+    std::string cc;
+    std::string exec_prefix;
+    std::string march;
+    std::string mcpu;
+    std::string install_path;
+    std::string programs_path;
+    std::string libraries_path;
+
+    /**
+     * The list of standard libraries.
+     */
+    #define RPS RLD_PATHSTR_SEPARATOR_STR
+    static const char* std_lib_c         = "libgcc.a" RPS "libssp.a" RPS "libc.a";
+    static const char* std_lib_cplusplus = "libstdc++.a";
+
+    static void
+    make_cc_command (rld::process::arg_container& args)
+    {
+      /*
+       * Use the absolute path to CC is provided.
+       */
+      if (!cc.empty ())
+        args.push_back (cc);
+      else
+      {
+        std::string cmd = "gcc";
+        if (!exec_prefix.empty ())
+          cmd = exec_prefix + "-rtems" + rld::rtems_version () + '-' + cmd;
+        args.push_back (cmd);
+      }
+      if (!march.empty ())
+        args.push_back ("-march=" + march);
+      if (!mcpu.empty ())
+        args.push_back ("-mcpu=" + mcpu);
+    }
+
+    static bool
+    match_and_trim (const char* prefix, std::string& line, std::string& result)
+    {
+      std::string::size_type pos = ::strlen (prefix);
+      if (line.substr (0, pos) == prefix)
+      {
+        if (line[pos] == '=')
+          ++pos;
+        result = line.substr (pos, line.size () - pos - 1);
+        return true;
+      }
+      return false;
+    }
+
+    static void
+    search_dirs ()
+    {
+      rld::process::arg_container args;
+
+      make_cc_command (args);
+      args.push_back ("-print-search-dirs");
+
+      rld::process::tempfile out;
+      rld::process::tempfile err;
+      rld::process::status   status;
+
+      status = rld::process::execute ("gcc", args, out.name (), err.name ());
+
+      if ((status.type == rld::process::status::normal) &&
+          (status.code == 0))
+      {
+        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
+          out.output ("gcc", std::cout, true);
+        out.open ();
+        while (true)
+        {
+          std::string line;
+          out.getline (line);
+          if (line.size () == 0)
+            break;
+          if (match_and_trim ("install: ", line, install_path))
+            continue;
+          if (match_and_trim ("programs: ", line, programs_path))
+            continue;
+          if (match_and_trim ("libraries: ", line, libraries_path))
+            continue;
+        }
+        out.close ();
+        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
+        {
+          std::cout << "cc::install: " << install_path << std::endl
+                    << "cc::programs: " << programs_path << std::endl
+                    << "cc::libraries: " << libraries_path << std::endl;
+        }
+      }
+      else
+      {
+        err.output ("gcc", std::cout);
+      }
+    }
+
+    void
+    get_library_path (std::string& name, std::string& path)
+    {
+      rld::process::arg_container args;
+
+      make_cc_command (args);
+      args.push_back ("-print-file-name=" + name);
+
+      rld::process::tempfile out;
+      rld::process::tempfile err;
+      rld::process::status   status;
+
+      status = rld::process::execute ("gcc", args, out.name (), err.name ());
+
+      if ((status.type == rld::process::status::normal) &&
+          (status.code == 0))
+      {
+        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
+          out.output ("cc", std::cout, true);
+        out.open ();
+        out.get (path);
+        out.close ();
+        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
+          std::cout << "cc::libpath: " << name << " -> " << path << std::endl;
+      }
+      else
+      {
+        err.output ("cc", std::cout);
+      }
+    }
+
+    void
+    get_standard_libpaths (rld::files::paths& libpaths)
+    {
+      search_dirs ();
+      rld::split (libraries_path, libpaths, RLD_PATHSTR_SEPARATOR);
+    }
+
+    void
+    get_standard_libs (rld::files::paths& libs,
+                       rld::files::paths& libpaths,
+                       bool               cplusplus)
+    {
+      strings libnames;
+
+      rld::split (std_lib_c, libnames, RLD_PATHSTR_SEPARATOR);
+      if (cplusplus)
+        rld::files::path_split (std_lib_cplusplus, libnames);
+
+      for (strings::iterator lni = libnames.begin ();
+           lni != libnames.end ();
+           ++lni)
+      {
+        if (rld::verbose () >= RLD_VERBOSE_INFO)
+          std::cout << "cc::stdlib: " << *lni << std::endl;
+
+        std::string path;
+
+        rld::files::find_file (path, *lni, libpaths);
+        if (path.empty ())
+          throw rld::error ("Library not found: " + *lni, "getting standard libs");
+
+        libs.push_back (path);
+      }
+    }
+  }
+}
Index: linkers/rld-cc.h
===================================================================
--- linkers/rld-cc.h	(revision 746192499f21a467b00d3c9c10ffd818d59e44e1)
+++ linkers/rld-cc.h	(revision 746192499f21a467b00d3c9c10ffd818d59e44e1)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011-2012, Chris Johns <chrisj@rtems.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, 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.
+ */
+/**
+ * @file
+ *
+ * @ingroup rtems-ld
+ *
+ * @brief Various calls to CC.
+ *
+ */
+
+#if !defined (_RLD_CC_H_)
+#define _RLD_CC_H_
+
+#include <string>
+
+#include <rld-files.h>
+
+namespace rld
+{
+  namespace cc
+  {
+    extern std::string cc;             //< The CC executable.
+    extern std::string exec_prefix;    //< The CC executable prefix.
+    extern std::string march;          //< The CC machine architecture.
+    extern std::string mcpu;           //< The CC machine CPU.
+
+    extern std::string install_path;   //< The CC reported install path.
+    extern std::string programs_path;  //< The CC reported programs path.
+    extern std::string libraries_path; //< The CC reported libraries path.
+
+    /**
+     * Get the standard libraries paths from the compiler.
+     */
+    void get_standard_libpaths (rld::files::paths& libpaths);
+
+    /**
+     * Get the standard libraries. Optionally add the C++ library.
+     */
+    void get_standard_libs (rld::files::paths& libs,
+                            rld::files::paths& libpaths,
+                            bool               cpp = false);
+
+  }
+}
+
+#endif
Index: nkers/rld-gcc.cpp
===================================================================
--- linkers/rld-gcc.cpp	(revision aef6d9018087bd74d9796307b62d5ebb0e37ac90)
+++ 	(revision )
@@ -1,183 +1,0 @@
-/*
- * Copyright (c) 2011, Chris Johns <chrisj@rtems.org> 
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, 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.
- */
-
-#include <string.h>
-
-#include <fstream>
-
-#include <rld.h>
-#include <rld-gcc.h>
-#include <rld-process.h>
-
-namespace rld
-{
-  namespace gcc
-  {
-    std::string exec_prefix;
-    std::string march;
-    std::string mcpu;
-    std::string install_path;
-    std::string programs_path;
-    std::string libraries_path;
-
-    /**
-     * The list of standard libraries.
-     */
-    #define RPS RLD_PATHSTR_SEPARATOR_STR
-    static const char* std_lib_c         = "libgcc.a" RPS "libssp.a" RPS "libc.a";
-    static const char* std_lib_cplusplus = "libstdc++.a";
-
-    static void
-    make_cc_command (rld::process::arg_container& args)
-    {
-      std::string cmd = "gcc";
-      if (!exec_prefix.empty ())
-        cmd = exec_prefix + "-rtems" + rld::rtems_version () + '-' + cmd;
-      args.push_back (cmd);
-      if (!march.empty ())
-        args.push_back ("-march=" + march);
-      if (!mcpu.empty ())
-        args.push_back ("-mcpu=" + mcpu);
-    }
-
-    static bool
-    match_and_trim (const char* prefix, std::string& line, std::string& result)
-    {
-      std::string::size_type pos = ::strlen (prefix);
-      if (line.substr (0, pos) == prefix)
-      {
-        if (line[pos] == '=')
-          ++pos;
-        result = line.substr (pos, line.size () - pos - 1);
-        return true;
-      }
-      return false;
-    }
-
-    static void
-    search_dirs ()
-    {
-      rld::process::arg_container args;
-
-      make_cc_command (args);
-      args.push_back ("-print-search-dirs");
-      
-      rld::process::tempfile out;
-      rld::process::tempfile err;
-      rld::process::status   status;
-
-      status = rld::process::execute ("gcc", args, out.name (), err.name ());
-
-      if ((status.type == rld::process::status::normal) &&
-          (status.code == 0))
-      {
-        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
-          out.output ("gcc", std::cout, true);
-        out.open ();
-        while (true)
-        {
-          std::string line;
-          out.getline (line);
-          if (line.size () == 0)
-            break;
-          if (match_and_trim ("install: ", line, install_path))
-            continue;
-          if (match_and_trim ("programs: ", line, programs_path))
-            continue;
-          if (match_and_trim ("libraries: ", line, libraries_path))
-            continue;
-        }
-        out.close ();
-        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
-        {
-          std::cout << "gcc::install: " << install_path << std::endl
-                    << "gcc::programs: " << programs_path << std::endl
-                    << "gcc::libraries: " << libraries_path << std::endl;
-        }
-      }
-      else
-      {
-        err.output ("gcc", std::cout);
-      }
-    }
-
-    void
-    get_library_path (std::string& name, std::string& path)
-    {
-      rld::process::arg_container args;
-
-      make_cc_command (args);
-      args.push_back ("-print-file-name=" + name);
-      
-      rld::process::tempfile out;
-      rld::process::tempfile err;
-      rld::process::status   status;
-
-      status = rld::process::execute ("gcc", args, out.name (), err.name ());
-
-      if ((status.type == rld::process::status::normal) &&
-          (status.code == 0))
-      {
-        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
-          out.output ("gcc", std::cout, true);
-        out.open ();
-        out.get (path);
-        out.close ();
-        if (rld::verbose () >= RLD_VERBOSE_DETAILS)
-          std::cout << "gcc::libpath: " << name << " -> " << path << std::endl;
-      }
-      else
-      {
-        err.output ("gcc", std::cout);
-      }
-    }
-
-    void
-    get_standard_libpaths (rld::files::paths& libpaths)
-    {
-      search_dirs ();
-      rld::split (libraries_path, libpaths, RLD_PATHSTR_SEPARATOR);
-    }
-
-    void
-    get_standard_libs (rld::files::paths& libs, 
-                       rld::files::paths& libpaths,
-                       bool               cplusplus)
-    {
-      strings libnames;
-
-      rld::split (std_lib_c, libnames, RLD_PATHSTR_SEPARATOR);
-      if (cplusplus)
-        rld::files::path_split (std_lib_cplusplus, libnames);
-
-      for (strings::iterator lni = libnames.begin ();
-           lni != libnames.end ();
-           ++lni)
-      {
-        if (rld::verbose () >= RLD_VERBOSE_INFO)
-          std::cout << "gcc::stdlib: " << *lni << std::endl;
-
-        std::string path;
-
-        rld::files::find_file (path, *lni, libpaths);
-        if (path.empty ())
-          throw rld::error ("Library not found: " + *lni, "getting standard libs");
-
-        libs.push_back (path);
-      }
-    }
-  }
-}
Index: nkers/rld-gcc.h
===================================================================
--- linkers/rld-gcc.h	(revision aef6d9018087bd74d9796307b62d5ebb0e37ac90)
+++ 	(revision )
@@ -1,59 +1,0 @@
-/*
- * Copyright (c) 2011, Chris Johns <chrisj@rtems.org> 
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, 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.
- */
-/**
- * @file
- *
- * @ingroup rtems-ld
- *
- * @brief Various calls to GCC.
- *
- */
-
-#if !defined (_RLD_GCC_H_)
-#define _RLD_GCC_H_
-
-#include <string>
-
-#include <rld-files.h>
-
-namespace rld
-{
-  namespace gcc
-  {
-    extern std::string exec_prefix;    //< The GCC executable prefix.
-    extern std::string march;          //< The GCC machine architecture.
-    extern std::string mcpu;           //< The GCC machine CPU.
-
-    extern std::string install_path;   //< The GCC reported install path.
-    extern std::string programs_path;  //< The GCC reported programs path.
-    extern std::string libraries_path; //< The GCC reported libraries path.
-    
-    /**
-     * Get the standard libraries paths from the compiler.
-     */
-    void get_standard_libpaths (rld::files::paths& libpaths);
-    
-    /**
-     * Get the standard libraries. Optionally add the C++ library.
-     */
-    void get_standard_libs (rld::files::paths& libs, 
-                            rld::files::paths& libpaths,
-                            bool               cpp = false);
-    
-  }
-}
-
-#endif
Index: linkers/wscript
===================================================================
--- linkers/wscript	(revision aef6d9018087bd74d9796307b62d5ebb0e37ac90)
+++ linkers/wscript	(revision 746192499f21a467b00d3c9c10ffd818d59e44e1)
@@ -86,5 +86,5 @@
                           'rld-elf.cpp',
                           'rld-files.cpp',
-                          'rld-gcc.cpp',
+                          'rld-cc.cpp',
                           'rld-outputter.cpp',
                           'rld-process.cpp',
