OSDN Git Service

More improvements to sparc VIS vec_init code generation.
[pf3gnuchains/gcc-fork.git] / gcc / ada / switch-m.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             S W I T C H - M                              --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 2001-2011, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license.          --
20 --                                                                          --
21 -- GNAT was originally developed  by the GNAT team at  New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
23 --                                                                          --
24 ------------------------------------------------------------------------------
25
26 with Debug;    use Debug;
27 with Makeutl;  use Makeutl;
28 with Osint;    use Osint;
29 with Opt;      use Opt;
30 with Prj;      use Prj;
31 with Prj.Env;  use Prj.Env;
32 with Table;
33
34 with System.Multiprocessors; use System.Multiprocessors;
35
36 package body Switch.M is
37
38    package Normalized_Switches is new Table.Table
39      (Table_Component_Type => String_Access,
40       Table_Index_Type     => Integer,
41       Table_Low_Bound      => 1,
42       Table_Initial        => 20,
43       Table_Increment      => 100,
44       Table_Name           => "Switch.M.Normalized_Switches");
45    --  This table is used to keep the normalized switches, so that they may be
46    --  reused for subsequent invocations of Normalize_Compiler_Switches with
47    --  similar switches.
48
49    Initial_Number_Of_Switches : constant := 10;
50
51    Global_Switches : Argument_List_Access := null;
52    --  Used by function Normalize_Compiler_Switches
53
54    ---------------------------------
55    -- Normalize_Compiler_Switches --
56    ---------------------------------
57
58    procedure Normalize_Compiler_Switches
59      (Switch_Chars : String;
60       Switches     : in out Argument_List_Access;
61       Last         : out Natural)
62    is
63       Switch_Starts_With_Gnat : Boolean;
64
65       Ptr : Integer := Switch_Chars'First;
66       Max : constant Integer := Switch_Chars'Last;
67       C   : Character := ' ';
68
69       Storing      : String := Switch_Chars;
70       First_Stored : Positive := Ptr + 1;
71       Last_Stored  : Positive := First_Stored;
72
73       procedure Add_Switch_Component (S : String);
74       --  Add a new String_Access component in Switches. If a string equal
75       --  to S is already stored in the table Normalized_Switches, use it.
76       --  Otherwise add a new component to the table.
77
78       --------------------------
79       -- Add_Switch_Component --
80       --------------------------
81
82       procedure Add_Switch_Component (S : String) is
83       begin
84          --  If Switches is null, allocate a new array
85
86          if Switches = null then
87             Switches := new Argument_List (1 .. Initial_Number_Of_Switches);
88
89          --  Otherwise, if Switches is full, extend it
90
91          elsif Last = Switches'Last then
92             declare
93                New_Switches : constant Argument_List_Access :=
94                                 new Argument_List
95                                       (1 .. Switches'Length + Switches'Length);
96             begin
97                New_Switches (1 .. Switches'Length) := Switches.all;
98                Last := Switches'Length;
99                Switches := New_Switches;
100             end;
101          end if;
102
103          --  If this is the first switch, Last designates the first component
104
105          if Last = 0 then
106             Last := Switches'First;
107          else
108             Last := Last + 1;
109          end if;
110
111          --  Look into the table Normalized_Switches for a similar string.
112          --  If one is found, put it at the added component, and return.
113
114          for Index in 1 .. Normalized_Switches.Last loop
115             if S = Normalized_Switches.Table (Index).all then
116                Switches (Last) := Normalized_Switches.Table (Index);
117                return;
118             end if;
119          end loop;
120
121          --  No string equal to S was found in the table Normalized_Switches.
122          --  Add a new component in the table.
123
124          Switches (Last) := new String'(S);
125          Normalized_Switches.Append (Switches (Last));
126       end Add_Switch_Component;
127
128    --  Start of processing for Normalize_Compiler_Switches
129
130    begin
131       Last := 0;
132
133       if Ptr = Max or else Switch_Chars (Ptr) /= '-' then
134          return;
135       end if;
136
137       Ptr := Ptr + 1;
138
139       Switch_Starts_With_Gnat :=
140          Ptr + 3 <= Max and then Switch_Chars (Ptr .. Ptr + 3) = "gnat";
141
142       if Switch_Starts_With_Gnat then
143          Ptr := Ptr + 4;
144          First_Stored := Ptr;
145       end if;
146
147       while Ptr <= Max loop
148          C := Switch_Chars (Ptr);
149
150          --  Processing for a switch
151
152          case Switch_Starts_With_Gnat is
153
154             when False =>
155
156                --  All switches that don't start with -gnat stay as is,
157                --  except -pg, -Wall, -k8, -w
158
159                if Switch_Chars = "-pg" or else Switch_Chars = "-p" then
160
161                   --  The gcc driver converts -pg to -p, so that is what
162                   --  is stored in the ALI file.
163
164                   Add_Switch_Component ("-p");
165
166                elsif Switch_Chars = "-Wall" then
167
168                   --  The gcc driver adds -gnatwa when -Wall is used
169
170                   Add_Switch_Component ("-gnatwa");
171                   Add_Switch_Component ("-Wall");
172
173                elsif Switch_Chars = "-k8" then
174
175                   --  The gcc driver transforms -k8 into -gnatk8
176
177                   Add_Switch_Component ("-gnatk8");
178
179                elsif Switch_Chars = "-w" then
180
181                   --  The gcc driver adds -gnatws when -w is used
182
183                   Add_Switch_Component ("-gnatws");
184                   Add_Switch_Component ("-w");
185
186                elsif Switch_Chars'Length > 6
187                  and then
188                    Switch_Chars (Switch_Chars'First .. Switch_Chars'First + 5)
189                                                              = "--RTS="
190                then
191                   Add_Switch_Component (Switch_Chars);
192
193                   --  When --RTS=mtp is used, the gcc driver adds -mrtp
194
195                   if Switch_Chars = "--RTS=mtp" then
196                      Add_Switch_Component ("-mrtp");
197                   end if;
198
199                --  Switch for universal addressing on AAMP target
200
201                elsif Switch_Chars'Length >= 5
202                  and then
203                    Switch_Chars
204                      (Switch_Chars'First .. Switch_Chars'First + 4) = "-univ"
205                then
206                   Add_Switch_Component (Switch_Chars);
207
208                --  Switch for specifying AAMP target library
209
210                elsif Switch_Chars'Length > 13
211                  and then
212                    Switch_Chars (Switch_Chars'First .. Switch_Chars'First + 12)
213                      = "-aamp_target="
214                then
215                   Add_Switch_Component (Switch_Chars);
216
217                --  Take only into account switches that are transmitted to
218                --  gnat1 by the gcc driver and stored by gnat1 in the ALI file.
219
220                else
221                   case C is
222                      when 'O' | 'W' | 'w' | 'f' | 'd' | 'g' | 'm' =>
223                         Add_Switch_Component (Switch_Chars);
224
225                      when others =>
226                         null;
227                   end case;
228                end if;
229
230                return;
231
232             when True =>
233
234                case C is
235
236                   --  One-letter switches
237
238                   when 'a' | 'A' | 'b' | 'B' | 'c' | 'C' | 'E' | 'f' |
239                        'F' | 'g' | 'h' | 'H' | 'I' | 'L' | 'n' | 'N' |
240                        'o' | 'p' | 'P' | 'q' | 'Q' | 'r' | 's' | 'S' |
241                        't' | 'u' | 'U' | 'v' | 'x' | 'X' | 'Z' =>
242                      Storing (First_Stored) := C;
243                      Add_Switch_Component
244                        (Storing (Storing'First .. First_Stored));
245                      Ptr := Ptr + 1;
246
247                   --  One-letter switches followed by a positive number
248
249                   when 'D' | 'G' | 'j' | 'k' | 'm' | 'T' =>
250                      Storing (First_Stored) := C;
251                      Last_Stored := First_Stored;
252
253                      if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
254                         Ptr := Ptr + 1;
255                      end if;
256
257                      loop
258                         Ptr := Ptr + 1;
259                         exit when Ptr > Max
260                           or else Switch_Chars (Ptr) not in '0' .. '9';
261                         Last_Stored := Last_Stored + 1;
262                         Storing (Last_Stored) := Switch_Chars (Ptr);
263                      end loop;
264
265                      Add_Switch_Component
266                        (Storing (Storing'First .. Last_Stored));
267
268                   when 'd' =>
269                      Storing (First_Stored) := 'd';
270
271                      while Ptr < Max loop
272                         Ptr := Ptr + 1;
273                         C := Switch_Chars (Ptr);
274                         exit when C = ASCII.NUL or else C = '/'
275                           or else C = '-';
276
277                         if C in '1' .. '9' or else
278                            C in 'a' .. 'z' or else
279                            C in 'A' .. 'Z'
280                         then
281                            Storing (First_Stored + 1) := C;
282                            Add_Switch_Component
283                              (Storing (Storing'First .. First_Stored + 1));
284
285                         else
286                            Last := 0;
287                            return;
288                         end if;
289                      end loop;
290
291                      return;
292
293                   when 'e' =>
294
295                      --  Some of the gnate... switches are not stored
296
297                      Storing (First_Stored) := 'e';
298                      Ptr := Ptr + 1;
299
300                      if Ptr > Max then
301                         Last := 0;
302                         return;
303
304                      else
305                         case Switch_Chars (Ptr) is
306
307                            when 'D' =>
308                               Storing (First_Stored + 1 ..
309                                          First_Stored + Max - Ptr + 1) :=
310                                   Switch_Chars (Ptr .. Max);
311                               Add_Switch_Component
312                                 (Storing (Storing'First ..
313                                    First_Stored + Max - Ptr + 1));
314                               Ptr := Max + 1;
315
316                            when 'G' =>
317                               Ptr := Ptr + 1;
318                               Add_Switch_Component ("-gnateG");
319
320                            when 'I' =>
321                               Ptr := Ptr + 1;
322
323                               declare
324                                  First : constant Positive := Ptr - 1;
325                               begin
326                                  if Ptr <= Max and then
327                                    Switch_Chars (Ptr) = '='
328                                  then
329                                     Ptr := Ptr + 1;
330                                  end if;
331
332                                  while Ptr <= Max and then
333                                        Switch_Chars (Ptr) in '0' .. '9'
334                                  loop
335                                     Ptr := Ptr + 1;
336                                  end loop;
337
338                                  Storing (First_Stored + 1 ..
339                                             First_Stored + Ptr - First) :=
340                                      Switch_Chars (First .. Ptr - 1);
341                                  Add_Switch_Component
342                                    (Storing (Storing'First ..
343                                       First_Stored + Ptr - First));
344                               end;
345
346                            when 'p' =>
347                               Ptr := Ptr + 1;
348
349                               if Ptr = Max then
350                                  Last := 0;
351                                  return;
352                               end if;
353
354                               if Switch_Chars (Ptr) = '=' then
355                                  Ptr := Ptr + 1;
356                               end if;
357
358                                  --  To normalize, always put a '=' after
359                                  --  -gnatep. Because that could lengthen the
360                                  --  switch string, declare a local variable.
361
362                               declare
363                                  To_Store : String (1 .. Max - Ptr + 9);
364                               begin
365                                  To_Store (1 .. 8) := "-gnatep=";
366                                  To_Store (9 .. Max - Ptr + 9) :=
367                                    Switch_Chars (Ptr .. Max);
368                                  Add_Switch_Component (To_Store);
369                               end;
370
371                               return;
372
373                            when 'S' =>
374                               Ptr := Ptr + 1;
375                               Add_Switch_Component ("-gnateS");
376
377                            when others =>
378                               Last := 0;
379                               return;
380                         end case;
381                      end if;
382
383                   when 'i' =>
384                      Storing (First_Stored) := 'i';
385
386                      Ptr := Ptr + 1;
387
388                      if Ptr > Max then
389                         Last := 0;
390                         return;
391                      end if;
392
393                      C := Switch_Chars (Ptr);
394
395                      if C in '1' .. '5'
396                        or else C = '8'
397                        or else C = 'p'
398                        or else C = 'f'
399                        or else C = 'n'
400                        or else C = 'w'
401                      then
402                         Storing (First_Stored + 1) := C;
403                         Add_Switch_Component
404                           (Storing (Storing'First .. First_Stored + 1));
405                         Ptr := Ptr + 1;
406
407                      else
408                         Last := 0;
409                         return;
410                      end if;
411
412                   --  -gnatl may be -gnatl=<file name>
413
414                   when 'l' =>
415                      Ptr := Ptr + 1;
416
417                      if Ptr > Max or else Switch_Chars (Ptr) /= '=' then
418                         Add_Switch_Component ("-gnatl");
419
420                      else
421                         Add_Switch_Component
422                           ("-gnatl" & Switch_Chars (Ptr .. Max));
423                         return;
424                      end if;
425
426                   --  -gnatR may be followed by '0', '1', '2' or '3',
427                   --  then by 's'
428
429                   when 'R' =>
430                      Last_Stored := First_Stored;
431                      Storing (Last_Stored) := 'R';
432                      Ptr := Ptr + 1;
433
434                      if Ptr <= Max
435                        and then Switch_Chars (Ptr) in '0' .. '9'
436                      then
437                         C := Switch_Chars (Ptr);
438
439                         if C in '4' .. '9' then
440                            Last := 0;
441                            return;
442
443                         else
444                            Last_Stored := Last_Stored + 1;
445                            Storing (Last_Stored) := C;
446                            Ptr := Ptr + 1;
447
448                            if Ptr <= Max
449                              and then Switch_Chars (Ptr) = 's'
450                            then
451                               Last_Stored := Last_Stored + 1;
452                               Storing (Last_Stored) := 's';
453                               Ptr := Ptr + 1;
454                            end if;
455                         end if;
456                      end if;
457
458                      Add_Switch_Component
459                        (Storing (Storing'First .. Last_Stored));
460
461                   --  -gnatWx, x = 'h'. 'u', 's', 'e', '8' or 'b'
462
463                   when 'W' =>
464                      Storing (First_Stored) := 'W';
465                      Ptr := Ptr + 1;
466
467                      if Ptr <= Max then
468                         case Switch_Chars (Ptr) is
469                            when 'h' | 'u' | 's' | 'e' | '8' | 'b' =>
470                               Storing (First_Stored + 1) := Switch_Chars (Ptr);
471                               Add_Switch_Component
472                                 (Storing (Storing'First .. First_Stored + 1));
473                               Ptr := Ptr + 1;
474
475                            when others =>
476                               Last := 0;
477                               return;
478                         end case;
479                      end if;
480
481                   --  Multiple switches
482
483                   when 'V' | 'w' | 'y' =>
484                      Storing (First_Stored) := C;
485                      Ptr := Ptr + 1;
486
487                      if Ptr > Max then
488                         if C = 'y' then
489                            Add_Switch_Component
490                              (Storing (Storing'First .. First_Stored));
491
492                         else
493                            Last := 0;
494                            return;
495                         end if;
496                      end if;
497
498                      --  Loop through remaining switch characters in string
499
500                      while Ptr <= Max loop
501                         C := Switch_Chars (Ptr);
502                         Ptr := Ptr + 1;
503
504                         --  -gnatyMxxx
505
506                         if C = 'M' and then Storing (First_Stored) = 'y' then
507                            Last_Stored := First_Stored + 1;
508                            Storing (Last_Stored) := 'M';
509                            while Ptr <= Max loop
510                               C := Switch_Chars (Ptr);
511                               exit when C not in '0' .. '9';
512                               Last_Stored := Last_Stored + 1;
513                               Storing (Last_Stored) := C;
514                               Ptr := Ptr + 1;
515                            end loop;
516
517                            --  If there is no digit after -gnatyM,
518                            --  the switch is invalid.
519
520                            if Last_Stored = First_Stored + 1 then
521                               Last := 0;
522                               return;
523
524                            else
525                               Add_Switch_Component
526                                 (Storing (Storing'First .. Last_Stored));
527                            end if;
528
529                         --  --gnatx.x
530
531                         elsif C = '.' and then Ptr <= Max then
532                            Storing (First_Stored + 1) := '.';
533                            Storing (First_Stored + 2) := Switch_Chars (Ptr);
534                            Ptr := Ptr + 1;
535                            Add_Switch_Component
536                              (Storing (Storing'First .. First_Stored + 2));
537
538                         --  All other switches are -gnatxx
539
540                         else
541                            Storing (First_Stored + 1) := C;
542                            Add_Switch_Component
543                              (Storing (Storing'First .. First_Stored + 1));
544                         end if;
545                      end loop;
546
547                   --  -gnat95 -gnat05
548
549                   when '0' | '9' =>
550                      Last_Stored := First_Stored;
551                      Storing (Last_Stored) := C;
552                      Ptr := Ptr + 1;
553
554                      if Ptr /= Max or else Switch_Chars (Ptr) /= '5' then
555
556                         --  Invalid switch
557
558                         Last := 0;
559                         return;
560
561                      else
562                         Last_Stored := Last_Stored + 1;
563                         Storing (Last_Stored) := '5';
564                         Add_Switch_Component
565                           (Storing (Storing'First .. Last_Stored));
566                         Ptr := Ptr + 1;
567                      end if;
568
569                      --  -gnat12
570
571                   when '1' =>
572                      Last_Stored := First_Stored;
573                      Storing (Last_Stored) := C;
574                      Ptr := Ptr + 1;
575
576                      if Ptr /= Max or else Switch_Chars (Ptr) /= '2' then
577
578                         --  Invalid switch
579
580                         Last := 0;
581                         return;
582
583                      else
584                         Last_Stored := Last_Stored + 1;
585                         Storing (Last_Stored) := '2';
586                         Add_Switch_Component
587                           (Storing (Storing'First .. Last_Stored));
588                         Ptr := Ptr + 1;
589                      end if;
590
591                      --  -gnat2005 -gnat2012
592
593                   when '2' =>
594                      if Ptr + 3 /= Max then
595                         Last := 0;
596                         return;
597
598                      elsif Switch_Chars (Ptr + 1 .. Ptr + 3) = "005" then
599                         Last_Stored := First_Stored + 3;
600                         Storing (First_Stored .. Last_Stored) := "2005";
601                         Add_Switch_Component
602                           (Storing (Storing'First .. Last_Stored));
603                         Ptr := Max + 1;
604
605                      elsif Switch_Chars (Ptr + 1 .. Ptr + 3) = "012" then
606                         Last_Stored := First_Stored + 3;
607                         Storing (First_Stored .. Last_Stored) := "2012";
608                         Add_Switch_Component
609                           (Storing (Storing'First .. Last_Stored));
610                         Ptr := Max + 1;
611
612                      else
613
614                         --  Invalid switch
615
616                         Last := 0;
617                         return;
618
619                      end if;
620
621                   --  -gnat83
622
623                   when '8' =>
624                      Last_Stored := First_Stored;
625                      Storing (Last_Stored) := '8';
626                      Ptr := Ptr + 1;
627
628                      if Ptr /= Max or else Switch_Chars (Ptr) /= '3' then
629
630                         --  Invalid switch
631
632                         Last := 0;
633                         return;
634
635                      else
636                         Last_Stored := Last_Stored + 1;
637                         Storing (Last_Stored) := '3';
638                         Add_Switch_Component
639                           (Storing (Storing'First .. Last_Stored));
640                         Ptr := Ptr + 1;
641                      end if;
642
643                   --  Not a valid switch
644
645                   when others =>
646                      Last := 0;
647                      return;
648
649                end case;
650
651          end case;
652       end loop;
653    end Normalize_Compiler_Switches;
654
655    function Normalize_Compiler_Switches
656      (Switch_Chars : String) return Argument_List
657    is
658       Last : Natural;
659
660    begin
661       Normalize_Compiler_Switches (Switch_Chars, Global_Switches, Last);
662
663       if Last = 0 then
664          return (1 .. 0 => null);
665       else
666          return Global_Switches (Global_Switches'First .. Last);
667       end if;
668    end Normalize_Compiler_Switches;
669
670    ------------------------
671    -- Scan_Make_Switches --
672    ------------------------
673
674    procedure Scan_Make_Switches
675      (Env               : in out Prj.Tree.Environment;
676       Switch_Chars      : String;
677       Success           : out Boolean)
678    is
679       Ptr : Integer          := Switch_Chars'First;
680       Max : constant Integer := Switch_Chars'Last;
681       C   : Character        := ' ';
682
683    begin
684       --  Assume a good switch
685
686       Success := True;
687
688       --  Skip past the initial character (must be the switch character)
689
690       if Ptr = Max then
691          Bad_Switch (Switch_Chars);
692
693       else
694          Ptr := Ptr + 1;
695       end if;
696
697       --  A little check, "gnat" at the start of a switch is for the compiler
698
699       if Switch_Chars'Length >= Ptr + 3
700         and then Switch_Chars (Ptr .. Ptr + 3) = "gnat"
701       then
702          Success := False;
703          return;
704       end if;
705
706       C := Switch_Chars (Ptr);
707
708       --  Multiple character switches
709
710       if Switch_Chars'Length > 2 then
711          if Switch_Chars = "--create-missing-dirs" then
712             Setup_Projects := True;
713
714          elsif Switch_Chars'Length > Subdirs_Option'Length
715            and then
716              Switch_Chars
717                (Switch_Chars'First ..
718                 Switch_Chars'First + Subdirs_Option'Length - 1) =
719                                                             Subdirs_Option
720          then
721             Subdirs :=
722               new String'
723                 (Switch_Chars
724                   (Switch_Chars'First + Subdirs_Option'Length ..
725                    Switch_Chars'Last));
726
727          elsif Switch_Chars = Makeutl.Unchecked_Shared_Lib_Imports then
728             Opt.Unchecked_Shared_Lib_Imports := True;
729
730          elsif Switch_Chars = Makeutl.Single_Compile_Per_Obj_Dir_Switch then
731             Opt.One_Compilation_Per_Obj_Dir := True;
732
733          elsif Switch_Chars (Ptr) = '-' then
734             Bad_Switch (Switch_Chars);
735
736          elsif Switch_Chars'Length > 3
737            and then Switch_Chars (Ptr .. Ptr + 1) = "aP"
738          then
739             Add_Directories
740               (Env.Project_Path,
741                Switch_Chars (Ptr + 2 .. Switch_Chars'Last));
742
743          elsif C = 'v' and then Switch_Chars'Length = 3 then
744             Ptr := Ptr + 1;
745             Verbose_Mode := True;
746
747             case Switch_Chars (Ptr) is
748                when 'l' =>
749                   Verbosity_Level := Opt.Low;
750
751                when 'm' =>
752                   Verbosity_Level := Opt.Medium;
753
754                when 'h' =>
755                   Verbosity_Level := Opt.High;
756
757                when others =>
758                   Success := False;
759             end case;
760
761          elsif C = 'd' then
762
763             --  Note: for the debug switch, the remaining characters in this
764             --  switch field must all be debug flags, since all valid switch
765             --  characters are also valid debug characters. This switch is not
766             --  documented on purpose because it is only used by the
767             --  implementors.
768
769             --  Loop to scan out debug flags
770
771             while Ptr < Max loop
772                Ptr := Ptr + 1;
773                C := Switch_Chars (Ptr);
774
775                if C in 'a' .. 'z' or else C in 'A' .. 'Z' then
776                   Set_Debug_Flag (C);
777                else
778                   Bad_Switch (Switch_Chars);
779                end if;
780             end loop;
781
782          elsif C = 'e' then
783             Ptr := Ptr + 1;
784
785             case Switch_Chars (Ptr) is
786
787                --  Processing for eI switch
788
789                when 'I' =>
790                   Ptr := Ptr + 1;
791                   Scan_Pos (Switch_Chars, Max, Ptr, Main_Index, C);
792
793                   if Ptr <= Max then
794                      Bad_Switch (Switch_Chars);
795                   end if;
796
797                --  Processing for eL switch
798
799                when 'L' =>
800                   if Ptr /= Max then
801                      Bad_Switch (Switch_Chars);
802
803                   else
804                      Follow_Links_For_Files := True;
805                      Follow_Links_For_Dirs  := True;
806                   end if;
807
808                --  Processing for eS switch
809
810                when 'S' =>
811                   if Ptr /= Max then
812                      Bad_Switch (Switch_Chars);
813
814                   else
815                      Commands_To_Stdout := True;
816                   end if;
817
818                when others =>
819                   Bad_Switch (Switch_Chars);
820             end case;
821
822          elsif C = 'j' then
823             Ptr := Ptr + 1;
824
825             declare
826                Max_Proc : Nat;
827
828             begin
829                Scan_Nat (Switch_Chars, Max, Ptr, Max_Proc, C);
830
831                if Ptr <= Max then
832                   Bad_Switch (Switch_Chars);
833
834                else
835                   if Max_Proc = 0 then
836                      Max_Proc := Nat (Number_Of_CPUs);
837
838                      if Max_Proc = 0 then
839                         Max_Proc := 1;
840                      end if;
841                   end if;
842
843                   Maximum_Processes := Positive (Max_Proc);
844                end if;
845             end;
846
847          elsif C = 'w' and then Switch_Chars'Length = 3 then
848             Ptr := Ptr + 1;
849
850             if Switch_Chars = "-we" then
851                Warning_Mode := Treat_As_Error;
852
853             elsif Switch_Chars = "-wn" then
854                Warning_Mode := Normal;
855
856             elsif Switch_Chars = "-ws" then
857                Warning_Mode  := Suppress;
858
859             else
860                Success := False;
861             end if;
862
863          else
864             Success := False;
865          end if;
866
867       --  Single-character switches
868
869       else
870          Check_Switch : begin
871
872             case C is
873
874                when 'a' =>
875                   Check_Readonly_Files := True;
876
877                --  Processing for b switch
878
879                when 'b' =>
880                   Bind_Only  := True;
881                   Make_Steps := True;
882
883                --  Processing for B switch
884
885                when 'B' =>
886                   Build_Bind_And_Link_Full_Project := True;
887
888                --  Processing for c switch
889
890                when 'c' =>
891                   Compile_Only := True;
892                   Make_Steps   := True;
893
894                --  Processing for C switch
895
896                when 'C' =>
897                   Opt.Create_Mapping_File := True;
898
899                --  Processing for D switch
900
901                when 'D' =>
902                   if Object_Directory_Present then
903                      Osint.Fail ("duplicate -D switch");
904
905                   else
906                      Object_Directory_Present := True;
907                   end if;
908
909                --  Processing for f switch
910
911                when 'f' =>
912                   Force_Compilations := True;
913
914                --  Processing for F switch
915
916                when 'F' =>
917                   Full_Path_Name_For_Brief_Errors := True;
918
919                --  Processing for h switch
920
921                when 'h' =>
922                   Usage_Requested := True;
923
924                --  Processing for i switch
925
926                when 'i' =>
927                   In_Place_Mode := True;
928
929                --  Processing for j switch
930
931                when 'j' =>
932                   --  -j not followed by a number is an error
933
934                   Bad_Switch (Switch_Chars);
935
936                --  Processing for k switch
937
938                when 'k' =>
939                   Keep_Going := True;
940
941                --  Processing for l switch
942
943                when 'l' =>
944                   Link_Only  := True;
945                   Make_Steps := True;
946
947                --  Processing for M switch
948
949                when 'M' =>
950                   List_Dependencies := True;
951
952                --  Processing for n switch
953
954                when 'n' =>
955                   Do_Not_Execute := True;
956
957                --  Processing for o switch
958
959                when 'o' =>
960                   if Output_File_Name_Present then
961                      Osint.Fail ("duplicate -o switch");
962                   else
963                      Output_File_Name_Present := True;
964                   end if;
965
966                --  Processing for p switch
967
968                when 'p' =>
969                   Setup_Projects := True;
970
971                --  Processing for q switch
972
973                when 'q' =>
974                   Quiet_Output := True;
975
976                --  Processing for R switch
977
978                when 'R' =>
979                   Run_Path_Option := False;
980
981                --  Processing for s switch
982
983                when 's' =>
984                   Ptr := Ptr + 1;
985                   Check_Switches := True;
986
987                --  Processing for v switch
988
989                when 'v' =>
990                   Verbose_Mode := True;
991                   Verbosity_Level := Opt.High;
992
993                   --  Processing for x switch
994
995                when 'x' =>
996                   External_Unit_Compilation_Allowed := True;
997                   Use_Include_Path_File := True;
998
999                   --  Processing for z switch
1000
1001                when 'z' =>
1002                   No_Main_Subprogram := True;
1003
1004                   --  Any other small letter is an illegal switch
1005
1006                when others =>
1007                   if C in 'a' .. 'z' then
1008                      Bad_Switch (Switch_Chars);
1009
1010                   else
1011                      Success := False;
1012                   end if;
1013
1014             end case;
1015          end Check_Switch;
1016       end if;
1017    end Scan_Make_Switches;
1018
1019 end Switch.M;