------------------------------------------------------------------------------
--                              Ada Web Server                              --
--                                                                          --
--                     Copyright (C) 2003-2022, AdaCore                     --
--                                                                          --
--  This is free software;  you can redistribute it  and/or modify it       --
--  under terms of the  GNU General Public License as published  by the     --
--  Free Software  Foundation;  either version 3,  or (at your option) any  --
--  later version.  This software 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   --
--  distributed  with  this  software;   see  file COPYING3.  If not, go    --
--  to http://www.gnu.org/licenses for a complete copy of the license.      --
------------------------------------------------------------------------------

with "../shared";

with "crypto_lib";
with "ssl_lib";

with "gnatcoll";

library project SSL is

   case Shared.Socket is
      when "std" =>
         for Languages use ("Ada", "Project file");
         for Source_Dirs use (".", "../config/ssl");
         for Excluded_Source_Files use ("ssl-loader.ads");

      when "gnutls" =>
         for Languages use ("Ada", "Project file", "C");
         for Source_Dirs use (".", "../config/ssl", "../config/ssl/gnutls");

      when others =>
         for Languages use ("Ada", "Project file", "C");
         for Source_Dirs use (".", "../config/ssl", "../config/ssl/openssl");
   end case;

   case Shared.SSL_Dynamic is
      when "false" =>
         for Excluded_Source_Files use ("ssl-loader.ads");

      when "true" =>
         case Shared.Socket is
            when "ssl" | "openssl" =>
               for Excluded_Source_Files use ("wrappers.c");
            when others =>
               null;
         end case;
   end case;

   for Object_Dir use "../" & Shared'Object_Dir & "/ssl";
   for Library_Dir use "../" & Shared'Library_Dir & "/ssl";

   for Library_Name use "aws_ssl";
   for Library_Kind use Shared.Library_Type;
   for Leading_Library_Options use Shared.Leading_Library_Options;

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

   package Ide renames Shared.Ide;

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

   package Compiler renames Shared.Compiler;

   ------------
   -- Naming --
   ------------

   package Naming is

      --  SSL Lib

      case Shared.Socket is
         when "std" =>
            for Specification ("SSL.Thin") use "ssl-thin__dummy.ads";

         when "ssl" | "openssl" =>
            case Shared.SSL_Dynamic is
               when "false" =>
                  for Spec ("SSL.Thin") use "ssl-thin__openssl.ads";
               when "true" =>
                  for Body ("SSL.Loader") use "ssl-loader__openssl.adb";
            end case;

          when "gnutls" =>
            case Shared.SSL_Dynamic is
               when "false" =>
                  for Spec ("SSL.Thin") use "ssl-thin__gnutls.ads";
               when "true" =>
                  for Body ("SSL.Loader") use "ssl-loader__gnutls.adb";
            end case;
      end case;

   end Naming;

end SSL;
