<?xml version="1.0" ?>
<!DOCTYPE gprconfig [
  <!ENTITY filter_gnat '<compilers><compiler name="^GNAT$" /><compiler name="^GNAT_DOTNET$" /><compiler name="^JGNAT$" /><compiler name="^GNAT_CODEPEER$" /><compiler name="^GNAT_C$" /><compiler name="^GNAT_CCG$" /><compiler name="^GNAT_CUDA$" /><compiler name="^GNAT_LLVM$" /><compiler name="^GNAT_LLVM_VXWORKS$" /><compiler name="^GNAT_LLVM-.*$" /><compiler name="^GNAT_LLVM_NATIVE$" /></compilers>'>
] >

<gprconfig>

  <!-- GNAT -->
  <configuration>
   &filter_gnat;
   <config>
   package Compiler is
      for Driver                   ("Ada") use "${PATH(ada)}${PREFIX(ada)}gcc";
      for Language_Kind            ("Ada") use "unit_based";
      for Dependency_Kind          ("Ada") use "ALI_File";
      for Leading_Required_Switches        ("Ada") use
	  ("-c", "-x", "ada", "-gnatA")
             &amp; Compiler'Leading_Required_Switches ("Ada");
      for Mapping_File_Switches    ("Ada") use ("-gnatem=");
      for Mapping_Spec_Suffix      ("Ada") use "%s";
      for Mapping_Body_Suffix      ("Ada") use "%b";
      for Config_File_Switches     ("Ada") use ("-gnatec=");
      for Include_Path_File     ("Ada") use "ADA_PRJ_INCLUDE_FILE";
   end Compiler;

   package Binder is
      for Objects_Path_File     ("Ada") use "ADA_PRJ_OBJECTS_FILE";
      for Driver         ("Ada") use
          "${GPRCONFIG_PREFIX}lib/gprbuild/gprbind";
   end Binder;

   for Toolchain_Version ("Ada") use "GNAT ${VERSION(ada)}";
   for Runtime_Dir       ("Ada") use "${RUNTIME_DIR(ada)}";
   </config>
  </configuration>

  <!-- CUDA -->
  <configuration>
   <compilers>
    <compiler name="^GNAT_CUDA$"/>
   </compilers>
   <config>
   package Compiler is
      for Object_File_Suffix       ("Ada") use ".cubin";
      for Driver                   ("Ada") use "${PATH(ada)}cuda-gcc";
   end Compiler;
   </config>
  </configuration>

  <!-- DOTNET -->
  <configuration>
   <compilers>
    <compiler name="^GNAT_DOTNET$"/>
   </compilers>
   <config>
   package Compiler is
      for Object_File_Suffix       ("Ada") use ".il";
      for Driver                   ("Ada") use "${PATH(ada)}${PREFIX(ada)}gnatcompile";
   end Compiler;
   </config>
  </configuration>

  <!-- JGNAT -->
  <configuration>
   <compilers>
    <compiler name="^JGNAT$"/>
   </compilers>
   <config>
   package Compiler is
      for Object_File_Suffix       ("Ada") use ".class";
   end Compiler;
   </config>
  </configuration>

  <!-- C Target common settings -->
  <configuration>
   <compilers>
     <compiler name="^GNAT_C$"/>
     <compiler name="^GNAT_CCG$"/>
   </compilers>
   <config>
   package Compiler is
      for Object_File_Suffix        ("Ada") use ".c";
   end Compiler;
   package Clean is
      for Object_Artifact_Extensions ("Ada") use (".h");
   end Clean;
   </config>
  </configuration>

  <!-- Old C Target using -gnatceg -->
  <configuration>
   <compilers>
     <compiler name="^GNAT_C$"/>
   </compilers>
   <config>
   package Compiler is
      for Leading_Required_Switches ("Ada") use
        Compiler'Leading_Required_Switches ("Ada") &amp; ("-gnatceg");
   end Compiler;
   </config>
  </configuration>

  <!-- Add -G to binder switches for C/CCG targets starting with version 20 -->
  <configuration>
   <compilers>
     <compiler name="^GNAT_C$"/>
     <compiler name="^GNAT_CCG$"/>
   </compilers>
   <compilers negate="true">
     <compiler version="18" />
     <compiler version="19" />
   </compilers>
   <config>
   package Binder is
      for Required_Switches ("Ada") use
        Binder'Required_Switches ("Ada") &amp; ("-G");
   end Binder;
   </config>
  </configuration>

  <!-- Add -m32 on linux and windows 64bits hosts for C target -->
  <configuration>
   <compilers>
     <compiler name="^GNAT_C$"/>
   </compilers>
   <hosts>
     <host name="^x86_64-.*linux.*$" />
     <host name="^x86_64-.*mingw.*$" />
   </hosts>
   <config>
   package Compiler is
      for Leading_Required_Switches ("Ada") use
        Compiler'Leading_Required_Switches ("Ada") &amp; ("-m32");
   end Compiler;
   </config>
  </configuration>

  <configuration>
   &filter_gnat;
   <compilers negate="true">
     <compiler version="3.16" />
     <compiler version="5.00" />
     <compiler version="5.01" />
     <compiler version="5.02" />
   </compilers>
   <config>
   package Compiler is
      for Multi_Unit_Switches ("Ada") use ("-gnateI");
      for Multi_Unit_Object_Separator ("Ada") use "~";
      for Config_Body_File_Name ("Ada") use
           "pragma Source_File_Name_Project (%u, Body_File_Name => ""%f"");";
      for Config_Spec_File_Name ("Ada") use
           "pragma Source_File_Name_Project (%u, Spec_File_Name => ""%f"");";
      for Config_Body_File_Name_Index ("Ada") use
           "pragma Source_File_Name_Project (%u, Body_File_Name => ""%f"", Index => %i);";
      for Config_Spec_File_Name_Index ("Ada") use
           "pragma Source_File_Name_Project (%u, Spec_File_Name => ""%f"", Index => %i);";
      for Config_Body_File_Name_Pattern ("Ada") use
           "pragma Source_File_Name_Project " &amp;
           "  (Body_File_Name  => ""*%b""," &amp;
           "   Casing          => %c," &amp;
           "   Dot_Replacement => ""%d"");";
      for Config_Spec_File_Name_Pattern ("Ada") use
           "pragma Source_File_Name_Project " &amp;
           "  (Spec_File_Name  => ""*%s""," &amp;
           "   Casing          => %c," &amp;
           "   Dot_Replacement => ""%d"");";
      for Config_File_Unique    ("Ada") use "False";
   end Compiler;
   </config>
  </configuration>

  <configuration>
   &filter_gnat;
   <compilers>
     <compiler version="3.16" />
     <compiler version="5.00" />
   </compilers>
   <config>
   package Compiler is
      for Config_Body_File_Name    ("Ada") use
           "pragma Source_File_Name (%u, Body_File_Name => ""%f"");";
      for Config_Spec_File_Name    ("Ada") use
           "pragma Source_File_Name (%u, Spec_File_Name => ""%f"");";
      for Config_Body_File_Name_Pattern ("Ada") use
           "pragma Source_File_Name " &amp;
           "  (Body_File_Name  => ""*%b""," &amp;
           "   Casing          => %c," &amp;
           "   Dot_Replacement => ""%d"");";
      for Config_Spec_File_Name_Pattern ("Ada") use
           "pragma Source_File_Name " &amp;
           "  (Spec_File_Name  => ""*%s""," &amp;
           "   Casing          => %c," &amp;
           "   Dot_Replacement => ""%d"");";
      for Config_File_Unique    ("Ada") use "True";
   end Compiler;
   </config>
  </configuration>

  <configuration>
   &filter_gnat;
   <compilers>
     <compiler version="5.01" />
     <compiler version="5.02" />
   </compilers>
   <config>
   package Compiler is
      for Config_Body_File_Name    ("Ada") use
           "pragma Source_File_Name_Project (%u, Body_File_Name => ""%f"");";
      for Config_Spec_File_Name    ("Ada") use
           "pragma Source_File_Name_Project (%u, Spec_File_Name => ""%f"");";
      for Config_Body_File_Name_Pattern ("Ada") use
           "pragma Source_File_Name_Project " &amp;
           "  (Body_File_Name  => ""*%b""," &amp;
           "   Casing          => %c," &amp;
           "   Dot_Replacement => ""%d"");";
      for Config_Spec_File_Name_Pattern ("Ada") use
           "pragma Source_File_Name_Project " &amp;
           "  (Spec_File_Name  => ""*%s""," &amp;
           "   Casing          => %c," &amp;
           "   Dot_Replacement => ""%d"");";
      for Config_File_Unique    ("Ada") use "False";
   end Compiler;
   </config>
  </configuration>

  <!--  Whether -fPIC is needed -->
  <configuration>
   &filter_gnat;
   <targets negate="true">
      <target name="^.*lynxos.*$" />
      <target name="^.*mingw.*$" />
      <target name="^.*dec-osf.*$" />
      <target name="^.*vms.*$" />
      <target name="^.*dotnet.*$" />
      <target name="^.*jvm.*$" />
   </targets>
   <config>
   package Compiler is
      for PIC_Option      ("Ada") use ("-fPIC");
   end Compiler;
   </config>
  </configuration>

  <!--  Whether encapsulated library is supported -->
  <configuration>
   &filter_gnat;
   <targets>
      <target name="^.*mingw.*$" />
      <target name="^.*linux.*$" />
      <target name="^.*sunos.*$" />
      <target name="^sparc-.*solaris.*$"/>
      <target name="^i.86-.*-solaris.*$"/>
      <target name="^i.86-.*darwin.*$" />
      <target name="^powerpc-.*darwin.*$" />
      <target name="^x86_64-.*darwin.*$" />
      <target name="^.*android.*$" />
      <target name="^.*-fastos.*$" />
      <target name="^.*-qnx[0-9]*$" />
      <target name="^.*freebsd.*$" />
      <target name="^.*netbsd.*$" />
      <target name="^.*dragonfly.*$" />
      <target name="^.*cuda.*$" />
   </targets>
   <config>
      for Library_Encapsulated_Supported use "true";
   </config>
  </configuration>

  <!-- add switch __RTS= to the compiler and binder for GNAT, if not default -->
  <configuration>
   <compilers>
     <compiler name="^GNAT$" />
     <compiler name="^GNAT_CODEPEER$" />
     <compiler name="^GNAT_LLVM$" />
     <compiler name="^GNAT_LLVM_VXWORKS*$" />
     <compiler name="^GNAT_LLVM-.*$" />
     <compiler name="^GNAT_LLVM_NATIVE$" />
   </compilers>
   <compilers negate="true">
     <compiler runtime="default" />
   </compilers>
   <config>
   package Compiler is
      for Leading_Required_Switches ("Ada") use
        Compiler'Leading_Required_Switches ("Ada") &amp; ("--RTS=${RUNTIME_DIR(ada)}");
   end Compiler;

   package Binder is
      for Required_Switches ("Ada") use
        Binder'Required_Switches ("Ada") &amp; ("--RTS=${RUNTIME_DIR(ada)}");
   end Binder;
   </config>
  </configuration>

  <!-- Always add switch __RTS= to the compiler and binder for GNAT CCG and CUDA -->
  <configuration>
   <compilers>
     <compiler name="^GNAT_CCG$" />
     <compiler name="^GNAT_CUDA$" />
   </compilers>
   <config>
   package Compiler is
      for Leading_Required_Switches ("Ada") use
        Compiler'Leading_Required_Switches ("Ada") &amp; ("--RTS=${RUNTIME_DIR(ada)}");
   end Compiler;

   package Binder is
      for Required_Switches ("Ada") use
        Binder'Required_Switches ("Ada") &amp; ("--RTS=${RUNTIME_DIR(ada)}");
   end Binder;
   </config>
  </configuration>

  <configuration>
   <compilers>
     <compiler name="^GNAT_DOTNET$" runtime="compact" />
     <compiler name="^GNAT_DOTNET$" runtime="silverlight" />
   </compilers>
   <config>
   package Compiler is
      for Leading_Required_Switches ("Ada") use
        Compiler'Leading_Required_Switches ("Ada") &amp; ("--RTS=${RUNTIME(ada)}/..");
   end Compiler;

   package Binder is
      for Required_Switches ("Ada") use
        Binder'Required_Switches ("Ada") &amp; ("--RTS=${RUNTIME(ada)}/..");
   end Binder;
   </config>
  </configuration>

  <!-- add compiler option -msoft-float when the runtime is soft-float -->
  <configuration>
   <compilers>
     <compiler name="^GNAT$" runtime="soft-float" />
   </compilers>
   <config>
   package Compiler is
      for Leading_Required_Switches ("Ada") use
        Compiler'Leading_Required_Switches ("Ada") &amp; ("-msoft-float");
   end Compiler;
   </config>
  </configuration>

  <!-- When using the (Ada) ios-simulator runtime, always compile all files
       with -mios-simulator-version-min (including non-Ada files).  -->

   <configuration>
     <compilers>
       <compiler language="Ada" runtime="ios-simulator" />
     </compilers>
     <config>
   package Compiler is
      for Leading_Required_Switches ("Ada") use
        Compiler'Leading_Required_Switches ("Ada")
        &amp; ("-mios-simulator-version-min=8.0");
      for Leading_Required_Switches ("C") use
        Compiler'Leading_Required_Switches ("C")
        &amp; ("-mios-simulator-version-min=8.0");
      for Leading_Required_Switches ("C++") use
        Compiler'Leading_Required_Switches ("C++")
        &amp; ("-mios-simulator-version-min=8.0");
      for Leading_Required_Switches ("Asm") use
        Compiler'Leading_Required_Switches ("Asm")
        &amp; ("-mios-simulator-version-min=8.0");
      for Leading_Required_Switches ("Asm2") use
        Compiler'Leading_Required_Switches ("Asm2")
        &amp; ("-mios-simulator-version-min=8.0");
      for Leading_Required_Switches ("Asm_Cpp") use
        Compiler'Leading_Required_Switches ("Asm_Cpp")
        &amp; ("-mios-simulator-version-min=8.0");
   end Compiler;
     </config>
   </configuration>

   <!-- GNAT including 7.2.2 and older does not support dependence on
        configuration pragma files -->

   <configuration>
   &filter_gnat;
   <compilers>
     <compiler language="Ada" version="^7\.[012]\.*" />
     <compiler language="Ada" version="^[3456]\.*" />
   </compilers>
   <config>
     package Compiler is
        for Config_File_Dependency_Support ("Ada") use "False";
     end Compiler;
   </config>
  </configuration>

  <!-- GNAT LLVM needs to emit the .debug_aranges section on most targets
       because the runtime relies on it to produce symbolic backtraces;
       don't emit it on VxWorks because wrdbg doesn't like it. -->

  <configuration>
   <compilers>
     <compiler name="^GNAT_LLVM.*$" />
   </compilers>
   <targets negate="true">
     <target name="^.*vxworks7r2.*$" />
   </targets>
   <config>
   package Compiler is
      for Leading_Required_Switches ("Ada") use
        Compiler'Leading_Required_Switches ("Ada") &amp; ("-gdwarf-aranges");
   end Compiler;
   </config>
  </configuration>

</gprconfig>
