------------------------------------------------------------------------------
--                              Ada Web Server                              --
--                                                                          --
--                         Copyright (C) 2003-2007                          --
--                                 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.          --
--                                                                          --
------------------------------------------------------------------------------

project Shared is

   for Source_Dirs use ();

   type Build_Type is ("Debug", "Release");
   Build : Build_Type := external ("PRJ_BUILD", "Debug");

   type OS_Type is ("UNIX", "Windows_NT", "Darwin");
   OS : OS_Type := external ("OS", "UNIX");

   type Install_Status is ("Installed", "Disabled");

   -------------
   -- SOCKLIB --
   -------------

   type SOCKLIB_Type is ("GNAT", "IPv6");
   SOCKLIB : SOCKLIB_Type := external ("PRJ_SOCKLIB", "GNAT");

   ------------
   -- SOCKET --
   ------------

   type Socket_Type is ("std", "ssl", "openssl", "gnutls");
   Socket : Socket_Type := external ("SOCKET", "std");

   --------------------------
   -- Static / Relocatable --
   --------------------------

   type Library_Kind is ("relocatable", "static");
   Library_Type : Library_Kind := external ("LIBRARY_TYPE", "relocatable");

   -----------------------
   -- Build directories --
   -----------------------

   for Exec_Dir use ".build";

   case Build is
      when "Debug" =>
         for Exec_Dir use Project'Exec_Dir & "/debug";
      when "Release" =>
         for Exec_Dir use Project'Exec_Dir & "/release";
   end case;

   case Library_Type is
      when "static" =>
         for Exec_Dir use Project'Exec_Dir & "/static";
      when "relocatable" =>
         for Exec_Dir use Project'Exec_Dir & "/relocatable";
   end case;

   for Object_Dir use Project'Exec_Dir & "/obj";
   for Library_Dir use Project'Exec_Dir & "/lib";

   ------------------------
   -- External Libraries --
   ------------------------

   XMLAda : Install_Status := external ("PRJ_XMLADA", "Installed");
   ASIS   : Install_Status := external ("PRJ_ASIS", "Installed");
   XMLAda : Install_Status := external ("PRJ_XMLADA", "Installed");
   LDAP   : Install_Status := external ("PRJ_LDAP", "Installed");

   -------------------------
   -- Compression library --
   -------------------------

   ZLib := ("-L../lib", "-lz");

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

   package Ide is
      for VCS_Kind use "Subversion";
      for VCS_Log_Check
        use "style_checker -l70 -H";
      for VCS_File_Check
        use "style_checker -ign out -ign tmplt -ign sed -ign txt"
         & " -lang Ada -cp -cy -sp -gnat05"
         & " -lang XML -l256";
   end Ide;

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

   Global_Options := ("");
   --  Options used for all Ada units in both Debug and Release modes

   Common_Options :=
     ("-gnat05", "-gnatwcfijkmruv", "-gnaty3abcefhiklmnoprstx", "-Wall")
     & Global_Options;
   --  Common options used for the Debug and Release modes

   Debug_Options :=
     ("-g", "-gnata", "-gnatVa", "-gnatQ", "-gnato", "-gnatwe");

   Release_Options :=
     ("-O2", "-gnatn");

   package Compiler is

      case Build is
         when "Debug" =>
            for Default_Switches ("Ada") use Common_Options & Debug_Options;

         when "Release" =>
            for Default_Switches ("Ada") use Common_Options & Release_Options;
      end case;

      case OS is
         when "Darwin" =>
            for Default_Switches ("Ada")
              use Compiler'Default_Switches ("Ada") & ("-fno-common");
         when others =>
            null;
      end case;

   end Compiler;

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

   package Binder is
      for Default_Switches ("Ada") use ("-E");
   end Binder;

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

   package Builder is
      for Default_Switches ("Ada") use ("-m");
   end Builder;

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

   package Linker is
      for Default_Switches ("Ada") use ZLib;
   end Linker;

end Shared;
