------------------------------------------------------------------------------
--               GtkAda - Ada95 binding for the Gimp Toolkit                --
--                                                                          --
--                      Copyright (C) 2015, AdaCore                         --
--                                                                          --
-- This library 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 library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
------------------------------------------------------------------------------

with "gtk";

project Shared is

   type Build_Type is ("Debug", "Production");
   Build : Build_Type := external ("BUILD", "@BUILD_TYPE@");

   type Boolean_Type is ("True", "False");
   Build_Opengl : Boolean_Type := "@HAVE_OPENGL@";

   type Yes_No is ("yes", "no");
   Need_Objective_C : Yes_No := "@NEED_OBJECTIVE_C@";

   for Source_Files use ();

   type Library_Kinds is ("relocatable", "static", "static-pic");
   Library_Kind : Library_Kinds := external ("LIBRARY_TYPE", "@DEFAULT_LIBRARY_TYPE@");

   So_Ext      := "@SO_EXT@";
   Version     := "@PACKAGE_VERSION@";
   Gtk_Include := Gtk.Gtk_Default_Include & (@GTK_CFLAGS_GPR@);
   Gtk_Libs    := Gtk.Gtk_Default_Libs    & (@GTK_LIBS_GPR@);
   GL_Include  := Gtk.GL_Default_Include  & (@GL_CFLAGS_GPR@);
   GL_Libs     := Gtk.GL_Default_Libs     & (@GL_LIBS_GPR@);

   package Naming is
      for Body_Suffix ("Objective-C") use ".m";
   end Naming;

   package Compiler is
      for Driver ("Objective-C") use "@OBJC@";
      for Leading_Required_Switches ("Objective-C") use ("-c");
      for PIC_Option ("Objective-C") use ("-fPIC");
      for PIC_Option ("C") use ("-fPIC");

      case Build is
         when "Debug" =>
             for Switches ("Ada") use
                ("-gnatQ", "-gnatwae", "-gnatay", "-g", "-O0",
                 "-Werror=format-security");
             for Switches ("C") use ("-g", "-O0");
         when "Production" =>
             for Switches ("Ada") use
                ("-gnatQ", "-O2", "-gnatn", "-gnatwa", "-gnaty",
                 "-Werror=format-security");
             for Switches ("C") use ("-O2");
      end case;

      Adaflags := External_As_List ("ADAFLAGS", " ");
      for Switches ("Ada") use Compiler'Switches ("Ada") & Adaflags;
      Cppflags := External_As_List ("CPPFLAGS", " ");
      Cflags   := External_As_List ("CFLAGS", " ");
      for Switches ("C") use Compiler'Switches ("C") & Cppflags & Cflags;

      for Switches ("C") use Compiler'Switches ("C") & Gtk_Include;
      for Switches ("Objective-C") use Compiler'Switches ("Objective-C") & Gtk_Include;
   end Compiler;

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

      case Build is
         when "Debug" =>
            for Global_Configuration_Pragmas use Shared'Project_Dir & "src/gnat_debug.adc";
         when "Production" =>
            for Global_Configuration_Pragmas use Shared'Project_Dir & "src/gnat.adc";
      end case;
   end Builder;

   package Binder is
      case Build is
         when "Debug" =>
             for Default_Switches ("Ada") use ("-E");
         when "Production" =>
             null;
      end case;
   end Binder;

   Ldflags := External_As_List ("LDFLAGS", " ");
   package Linker is
      for Leading_Switches ("Ada") use Ldflags;
   end Linker;

   package IDE is
      for VCS_Kind use "auto";
   end IDE;

   package Documentation is
      for Documentation_Dir use "html";
   end Documentation;

end Shared;
