1    /* 
     2     *  Copyright (c) 2008 Texas Instruments and others.
     3     *  All rights reserved. This program and the accompanying materials
     4     *  are made available under the terms of the Eclipse Public License v1.0
     5     *  which accompanies this distribution, and is available at
     6     *  http://www.eclipse.org/legal/epl-v10.html
     7     * 
     8     *  Contributors:
     9     *      Texas Instruments - initial implementation
    10     * 
    11     * */
    12    /*!
    13     *  ======== gnu.targets.ITarget ========
    14     *  Interface to GCC compatible compilers
    15     */
    16    @TargetHeader("xdc/bld/stddefs.xdt")
    17    metaonly interface ITarget inherits xdc.bld.ITarget2 {
    18    
    19        override readonly config string stdInclude = "gnu/targets/std.h";
    20        override config string dllExt     = ".so";
    21    
    22        /*!
    23         *  ======== GCCVERS ========
    24         *  Version number of the GCC compiler; e.g., "3.2".
    25         *
    26         *  This string can be supplied by the user, otherwise it is obtained
    27         *  by running "gcc -dumpversion".
    28         */
    29        config string GCCVERS = null;
    30    
    31        /*!
    32         *  ======== version ========
    33         *  The Compatibility Key associated with this target.
    34         *
    35         *  The first two components of this target's Compatibility Key are '1,0'.
    36         *  The rest of the Key represents the compiler version. The third
    37         *  component combines the major and the minor version number in the format
    38         *  Major.Minor. The fourth component is the patch number.
    39         *
    40         *  @a(Example)
    41         *  If this target's `rootDir` points to the compiler version 3.4.6, the 
    42         *  Compatibility Key is [1,0,3.4,6].
    43         *  
    44         */
    45        override metaonly config String version;
    46    
    47        /*!
    48         *  ======== GCCTARG ========
    49         *  The name of the platform executing programs produced by this target
    50         *
    51         *  This string can be supplied by the user, otherwise is is obtained
    52         *  from the compiler and follows the GNU standard format
    53         *  (<cpu>-<manufacturer>-<os> or <cpu>-<manufacturer>-<kernel>-<os>);
    54         *  e.g., "sparc-sun-solaris2.6" or "i586-pc-linux-gnu".
    55         *
    56         *  When building a GCC compiler, there are three different execution
    57         *  platforms to consider: the platform used to "build" the compiler, the
    58         *  "host" platform that runs the compiler, and the "target" platform
    59         *  that runs the executables produced by the compiler. All three
    60         *  platforms are identified using a
    61         *  {@link http://sources.redhat.com/autobook/autobook/autobook_17.html configuration name}
    62         *  defined by GNU Autotools.  `GCCTARG` is the name of the "target"
    63         *  platform.
    64         */
    65        config string GCCTARG = null;
    66    
    67        /*!
    68         *  ======== LONGNAME ========
    69         *  The "long name" of the gcc compiler
    70         *
    71         *  This name is used (in conjunction with rootDir) to find the compiler
    72         *  and linker for this target. The format of `LONGNAME` is always
    73         *  "/bin/<machine>-gcc". For majority of the targets, the default value
    74         *  for `LONGNAME` does not ever need to be changed. But, there are
    75         *  targets where the different but compatible compilers may have
    76         *  different `LONGNAME` parameters. For such targets and compilers,
    77         *  `LONGNAME` can be set in `config.bld`.
    78         *
    79         *  @a(Example)
    80         *  If a version 2007q3 of the CodeSourcery GNU toolchain for Arm is
    81         *  installed in C:/CodeSourcery/arm-2007q3, the following settings in
    82         *  `config.bld` configure `gnu.targets.arm.GCArmv6` target to use that
    83         *  toolchain:
    84         *  @p(code)
    85         *  var GCArmv6 = xdc.module("gnu.targets.arm.GCArmv6");
    86         *  GCArmv6.rootDir = "C:/CodeSourcery/arm-2007q3"; 
    87         *  GCArmv6.LONGNAME = "bin/arm-none-linux-gnueabi-gcc";
    88         *  @p
    89         *
    90         */
    91        config string LONGNAME = "/bin/gcc";
    92        
    93        /*!
    94         *  ======== CYGWIN ========
    95         *  Is the target's compiler a cygwin executable
    96         *
    97         *  Since file names produced by cygwin-based tools differ from the
    98         *  names understood by other Windows executables, it is important
    99         *  to avoid using the names output by cygwin tools as input to
   100         *  non-cygwin programs.  This property tells the target whether
   101         *  or not it's possible to use the output from `gcc -MD -MF`, for
   102         *  example.
   103         */
   104        readonly config Bool CYGWIN = false;
   105        
   106        /*!
   107         *  ======== noStdLinkScript ========
   108         *  Don't use the standard linker script
   109         *
   110         *  If `true`, add a `-T` flag before the generated `package/cfg/*.xdl`
   111         *  file passed to the linker.  This flag suppresses use of the
   112         *  standard linker script implicit in the GCC flow, which effectively
   113         *  says the generated `.xdl` file assumes total control for all
   114         *  `MEMORY` and `SECTION` directives.
   115         *
   116         */
   117        config Bool noStdLinkScript = false;
   118        
   119        /*
   120         *  ======== profiles ========
   121         */
   122        override config xdc.bld.ITarget.OptionSet profiles[string] = [
   123            ["debug", {
   124                compileOpts: {
   125                    copts: "-g",
   126                    defs:  "-D_DEBUG_=1",
   127                },
   128                linkOpts: "-g",
   129            }],
   130    
   131            ["release", {
   132                compileOpts: {
   133                    copts: "-O2 -ffunction-sections -fdata-sections",
   134                },
   135                linkOpts: "",
   136            }],
   137    
   138            ["profile", {
   139                compileOpts: {
   140                    copts: "-g -pg",
   141                },
   142                linkOpts: "-pg"     /* can't use -static here */
   143            }],
   144    
   145            ["coverage", {
   146                compileOpts: {
   147                    copts: "-fprofile-arcs -ftest-coverage",
   148                },
   149                linkOpts: "-fprofile-arcs -ftest-coverage",
   150            }],
   151        ];
   152    
   153        /*!
   154         *  ======== versionMap ========
   155         *  Map of GCC compiler version numbers to compatibility keys.
   156         *
   157         *  This map translates version string information from the compiler
   158         *  into a compatibility key.  The compatibilty key is used to
   159         *  validate consistency among a collection of packages used in
   160         *  a configuration.
   161         *
   162         *  The compiler version string is "gcc<ver>", where <ver> is
   163         *  GCCVERS.
   164         *
   165         *  If a compiler version is not found in this map the default is
   166         *  "1,0,<ver>", where <ver> is the compiler version number.  Thus,
   167         *  the user only needs to extend this table when a significant
   168         *  incompatibility occurs or when two versions of the compiler should
   169         *  be treated as 100% compatible.
   170         */
   171        override config string versionMap[string] = [
   172            ["gcc3.2", "1,0,3.2,0"],
   173        ];
   174    
   175        /*!
   176         *  ======== remoteHost ========
   177         *  Remote host used to run compiler, linker, and archiver tools
   178         *
   179         *  If `remoteHost` is `null` (or `undefined`), the configured compiler
   180         *  is run locally; otherwise, `remoteHost` is taken to be the host name
   181         *  of the machine that that should be used to run the specified compiler.
   182         *
   183         *  All target commands are prefixed with a command that uses `rsh` to run
   184         *  the commands on the specified host.  Thus, in order to use this
   185         *  setting, the remote machine must be support `rsh` and the user must 
   186         *  have permission to run commands from the local machine on the remote 
   187         *  host named `remoteHost`.  This usually involves adding a line to the 
   188         *  user's `~/.rhosts` file on the remote machine of the form:
   189         *  @p(code)
   190         *      local-machine-name user-name
   191         *  @p
   192         *  where `local-machine-name` is the name of the local machine and
   193         * `user-name` is the user's login name on the local machine.
   194         */
   195        config string remoteHost;
   196        
   197        /*!
   198         *  ======== ar ========
   199         *  The command used to create an archive
   200         */
   201        override readonly config xdc.bld.ITarget2.Command ar = {
   202            cmd: "$(rootDir)/$(GCCTARG)/bin/ar",
   203            opts: "cr"
   204        };
   205    
   206        /*!
   207         *  ======== lnk ========
   208         *  The command used to link executables.
   209         */
   210        override readonly config xdc.bld.ITarget2.Command lnk = {
   211            cmd: "$(rootDir)/$(LONGNAME)",
   212            opts: ""
   213        };
   214    
   215        /*!
   216         *  ======== cc ========
   217         *  The command used to compile C/C++ source files into object files
   218         */
   219        override readonly config xdc.bld.ITarget2.Command cc = {
   220            cmd: "$(rootDir)/$(LONGNAME) -c -MD -MF $@.dep",
   221            opts: ""
   222        };
   223    
   224        /*!
   225         *  ======== asm ========
   226         *  The command used to assembles assembly source files into object files
   227         */
   228        override readonly config xdc.bld.ITarget2.Command asm = {
   229            cmd: "$(rootDir)/$(LONGNAME) -c -x assembler",
   230            opts: ""
   231        };
   232    
   233        /*!
   234         *  ======== includeOpts ========
   235         *  Additional user configurable target-specific include path options
   236         */
   237        override config string includeOpts = "";
   238    }
   239    /*
   240     *  @(#) gnu.targets; 1, 0, 1,401; 8-4-2010 16:21:10; /db/ztree/library/trees/xdctargets/xdctargets-c27x/src/
   241     */
   242