------------------------------------------------------------------------------
--                              Ada Web Server                              --
--                                                                          --
--                          Copyright (C) 2004-2008                         --
--                                  AdaCore                                 --
--                                                                          --
--  This library is free software; you can redistribute it and/or modify    --
--  it under the terms of the GNU General Public License as published by    --
--  the Free Software Foundation; either version 2 of the License, or (at   --
--  your option) any later version.                                         --
--                                                                          --
--  This library is distributed in the hope that it will be useful, but     --
--  WITHOUT ANY WARRANTY; without even the implied warranty of              --
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       --
--  General Public License for more details.                                --
--                                                                          --
--  You should have received a copy of the GNU General Public License       --
--  along with this library; if not, write to the Free Software Foundation, --
--  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.          --
--                                                                          --
------------------------------------------------------------------------------

with "../shared";
with "../win32/win32";
with "../src/src";

with "regtests_lst";

project Regtests is

   for Languages use ("Ada", "Project file");

   type Build_Mode is ("Separated", "Generator", "Grouped");
   Mode : Build_Mode := external ("Test_Mode", "Separated");

   for Source_Dirs use (".", "generated");
   for Object_Dir use "../" & Shared'Object_Dir & "/regtests";
   for Exec_Dir use ".";

   --  Common tests for Separated and Grouped section

   Common :=
     ("dispatch1.adb", "dispatch_method.adb", "dispatch_vh.adb", "tres.adb",
      "upload2.adb", "upload3.adb", "server_config.adb", "tlog.adb");

   --  Common tests using XMLADA support

   Common_XMLADA := ("check_mem.adb", "test_speed.adb");

   case Mode is
      when "Generator" =>
         for Main use ("generate.adb");

      when "Separated" =>

         for Main use Regtests_Lst.T_STD & Common;

         case Shared.XMLAda is
            when "Installed" =>
               for Main use project'Main & Common_XMLADA & Regtests_Lst.T_XMLADA;

               case Shared.SOCKET is
                  when "ssl" | "openssl" | "gnutls" =>
                     for Main use project'Main & Regtests_Lst.T_SEC_XMLADA;
                  when "std" =>
                     for Main use project'Main;
               end case;

            when "Disabled" =>
               case Shared.SOCKET is
                  when "ssl" | "openssl" | "gnutls" =>
                     for Main use project'Main & Regtests_Lst.T_SEC;
                  when "std" =>
                     for Main use project'Main;
               end case;
         end case;

      when "Grouped" =>
         for Main use ("test_all.adb") & Common;

         case Shared.XMLAda is
            when "Installed" =>
               for Main use project'Main & Common_XMLADA;
            when "Disabled" =>
               for Main use project'Main;
         end case;
   end case;

   --------------
   -- Compiler --
   --------------

   package Compiler is
      for Default_Switches ("Ada")
        use ("-gnat05", "-g") & Shared.Global_Options;
   end Compiler;

   -------------
   -- Builder --
   -------------

   package Builder renames Shared.Builder;

   ------------
   -- Binder --
   ------------

   package Binder renames Shared.Binder;

   ------------
   -- Linker --
   ------------

   package Linker is
      for Default_Switches ("Ada") use ("-g", "-L../lib");
      for Switches ("check_mem.adb") use ("-L../lib", "-lgmem");
   end Linker;

   ---------
   -- Ide --
   ---------

   package Ide renames Shared.Ide;

end Regtests;
