project aflex is

   type Build_Type is ("distrib", "debug", "optimize", "profile", "coverage");

   Mode : Build_Type := external ("AFLEX_BUILD", "distrib");

   Processors := External ("PROCESSORS", "1");

   Mains := ("aflex");

   for Main use Mains;
   for Source_Dirs use ("src");
   for Object_Dir use "./obj";
   for Exec_Dir use "./bin";

   for Create_Missing_Dirs use "True";  --  Flips by default the "-p" switch

   package Builder is
       for Default_Switches ("Ada") use ("-j" & Processors);
   end Builder;

   package Compiler is
      warnings := ("-gnatwua");
      defaults := ("-gnat2012", "-gnaty-");
      case Mode is
         when "distrib" =>
            for Default_Switches ("Ada") use defaults & ("-O2", "-gnatafno", "-gnatVa", "-gnatwa");

         when "debug" =>
            for Default_Switches ("Ada") use defaults & warnings
               & ("-g", "-gnata", "-gnatVaMI");

         when "coverage" =>
            for Default_Switches ("Ada") use defaults & warnings
               & ("-g", "-O2", "-gnata", "-gnatVaMI",
                  "-fprofile-arcs", "-ftest-coverage");

         when "optimize" =>
            for Default_Switches ("Ada") use defaults & warnings
               & ("-O2", "-gnatn", "-gnatp", "-fdata-sections", "-ffunction-sections");

         when "profile" =>
            for Default_Switches ("Ada") use defaults & warnings & ("-pg");

      end case;
   end Compiler;

   package Binder is
      case Mode is
         when "debug" =>
            for Default_Switches ("Ada") use ("-E");

	 when others =>
            for Default_Switches ("Ada") use ("-E");

      end case;
   end Binder;

   package Linker is
      case Mode is
         when "profile" =>
            for Default_Switches ("Ada") use ("-pg");

         when "distrib" =>
            for Default_Switches ("Ada") use ("-s");

         when "optimize" =>
            for Default_Switches ("Ada") use ("-Wl,--gc-sections");

         when "coverage" =>
            for Default_Switches ("ada") use ("-fprofile-arcs");
	 
	 when others =>
	    null;
      end case;

   end Linker;
 
   package Ide is
      for VCS_Kind use "git";
   end Ide;

end aflex;
