* config/darwin.c (darwin_assemble_visibility): Treat
[official-gcc.git] / gcc / ada / switch-m.adb
blob0d769dc09f15ff18d7fb675ee52da89b19b05504
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-2012, 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 ------------------------------------------------------------------------------
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;
34 with System.Multiprocessors; use System.Multiprocessors;
36 package body Switch.M is
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.
49 Initial_Number_Of_Switches : constant := 10;
51 Global_Switches : Argument_List_Access := null;
52 -- Used by function Normalize_Compiler_Switches
54 ---------------------------------
55 -- Normalize_Compiler_Switches --
56 ---------------------------------
58 procedure Normalize_Compiler_Switches
59 (Switch_Chars : String;
60 Switches : in out Argument_List_Access;
61 Last : out Natural)
63 Switch_Starts_With_Gnat : Boolean;
65 Ptr : Integer := Switch_Chars'First;
66 Max : constant Integer := Switch_Chars'Last;
67 C : Character := ' ';
69 Storing : String := Switch_Chars;
70 First_Stored : Positive := Ptr + 1;
71 Last_Stored : Positive := First_Stored;
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.
78 --------------------------
79 -- Add_Switch_Component --
80 --------------------------
82 procedure Add_Switch_Component (S : String) is
83 begin
84 -- If Switches is null, allocate a new array
86 if Switches = null then
87 Switches := new Argument_List (1 .. Initial_Number_Of_Switches);
89 -- Otherwise, if Switches is full, extend it
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;
103 -- If this is the first switch, Last designates the first component
105 if Last = 0 then
106 Last := Switches'First;
107 else
108 Last := Last + 1;
109 end if;
111 -- Look into the table Normalized_Switches for a similar string.
112 -- If one is found, put it at the added component, and return.
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;
121 -- No string equal to S was found in the table Normalized_Switches.
122 -- Add a new component in the table.
124 Switches (Last) := new String'(S);
125 Normalized_Switches.Append (Switches (Last));
126 end Add_Switch_Component;
128 -- Start of processing for Normalize_Compiler_Switches
130 begin
131 Last := 0;
133 if Ptr = Max or else Switch_Chars (Ptr) /= '-' then
134 return;
135 end if;
137 Ptr := Ptr + 1;
139 Switch_Starts_With_Gnat :=
140 Ptr + 3 <= Max and then Switch_Chars (Ptr .. Ptr + 3) = "gnat";
142 if Switch_Starts_With_Gnat then
143 Ptr := Ptr + 4;
144 First_Stored := Ptr;
145 end if;
147 while Ptr <= Max loop
148 C := Switch_Chars (Ptr);
150 -- Processing for a switch
152 case Switch_Starts_With_Gnat is
154 when False =>
156 -- All switches that don't start with -gnat stay as is,
157 -- except -pg, -Wall, -k8, -w
159 if Switch_Chars = "-pg" or else Switch_Chars = "-p" then
161 -- The gcc driver converts -pg to -p, so that is what
162 -- is stored in the ALI file.
164 Add_Switch_Component ("-p");
166 elsif Switch_Chars = "-Wall" then
168 -- The gcc driver adds -gnatwa when -Wall is used
170 Add_Switch_Component ("-gnatwa");
171 Add_Switch_Component ("-Wall");
173 elsif Switch_Chars = "-k8" then
175 -- The gcc driver transforms -k8 into -gnatk8
177 Add_Switch_Component ("-gnatk8");
179 elsif Switch_Chars = "-w" then
181 -- The gcc driver adds -gnatws when -w is used
183 Add_Switch_Component ("-gnatws");
184 Add_Switch_Component ("-w");
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);
193 -- When --RTS=mtp is used, the gcc driver adds -mrtp
195 if Switch_Chars = "--RTS=mtp" then
196 Add_Switch_Component ("-mrtp");
197 end if;
199 -- Switch for universal addressing on AAMP target
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);
208 -- Switch for specifying AAMP target library
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);
217 -- Take only into account switches that are transmitted to
218 -- gnat1 by the gcc driver and stored by gnat1 in the ALI file.
220 else
221 case C is
222 when 'O' | 'W' | 'w' | 'f' | 'd' | 'g' | 'm' =>
223 Add_Switch_Component (Switch_Chars);
225 when others =>
226 null;
227 end case;
228 end if;
230 return;
232 when True =>
234 case C is
236 -- One-letter switches
238 when 'a' | 'A' | 'b' | 'B' | 'c' | 'C' | 'E' | 'f' |
239 'F' | 'g' | 'h' | 'H' | 'I' | 'L' | 'N' | 'p' |
240 'P' | 'q' | 'Q' | 'r' | 's' | 'S' | 't' | 'u' |
241 'U' | 'v' | 'x' | 'X' | 'Z' =>
242 Storing (First_Stored) := C;
243 Add_Switch_Component
244 (Storing (Storing'First .. First_Stored));
245 Ptr := Ptr + 1;
247 -- One-letter switches followed by a positive number
249 when 'D' | 'G' | 'j' | 'k' | 'm' | 'T' =>
250 Storing (First_Stored) := C;
251 Last_Stored := First_Stored;
253 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
254 Ptr := Ptr + 1;
255 end if;
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;
265 Add_Switch_Component
266 (Storing (Storing'First .. Last_Stored));
268 when 'd' =>
269 Storing (First_Stored) := 'd';
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 = '-';
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));
285 else
286 Last := 0;
287 return;
288 end if;
289 end loop;
291 return;
293 when 'e' =>
295 -- Some of the gnate... switches are not stored
297 Storing (First_Stored) := 'e';
298 Ptr := Ptr + 1;
300 if Ptr > Max then
301 Last := 0;
302 return;
304 else
305 case Switch_Chars (Ptr) is
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;
316 when 'G' =>
317 Ptr := Ptr + 1;
318 Add_Switch_Component ("-gnateG");
320 when 'I' =>
321 Ptr := Ptr + 1;
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;
332 while Ptr <= Max and then
333 Switch_Chars (Ptr) in '0' .. '9'
334 loop
335 Ptr := Ptr + 1;
336 end loop;
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;
346 when 'p' =>
347 Ptr := Ptr + 1;
349 if Ptr = Max then
350 Last := 0;
351 return;
352 end if;
354 if Switch_Chars (Ptr) = '=' then
355 Ptr := Ptr + 1;
356 end if;
358 -- To normalize, always put a '=' after
359 -- -gnatep. Because that could lengthen the
360 -- switch string, declare a local variable.
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;
371 return;
373 when 'S' =>
374 Ptr := Ptr + 1;
375 Add_Switch_Component ("-gnateS");
377 when others =>
378 Last := 0;
379 return;
380 end case;
381 end if;
383 when 'i' =>
384 Storing (First_Stored) := 'i';
386 Ptr := Ptr + 1;
388 if Ptr > Max then
389 Last := 0;
390 return;
391 end if;
393 C := Switch_Chars (Ptr);
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;
407 else
408 Last := 0;
409 return;
410 end if;
412 -- -gnatl may be -gnatl=<file name>
414 when 'l' =>
415 Ptr := Ptr + 1;
417 if Ptr > Max or else Switch_Chars (Ptr) /= '=' then
418 Add_Switch_Component ("-gnatl");
420 else
421 Add_Switch_Component
422 ("-gnatl" & Switch_Chars (Ptr .. Max));
423 return;
424 end if;
426 -- -gnatn may be -gnatn, -gnatn1, or -gnatn2
428 when 'n' =>
429 Last_Stored := First_Stored;
430 Storing (Last_Stored) := 'n';
431 Ptr := Ptr + 1;
433 if Ptr <= Max
434 and then Switch_Chars (Ptr) in '1' .. '2'
435 then
436 Last_Stored := Last_Stored + 1;
437 Storing (Last_Stored) := Switch_Chars (Ptr);
438 Ptr := Ptr + 1;
439 end if;
441 Add_Switch_Component
442 (Storing (Storing'First .. Last_Stored));
444 -- -gnato may be -gnatox or -gnatoxx, with x=0/1/2/3
446 when 'o' =>
447 Last_Stored := First_Stored;
448 Storing (Last_Stored) := 'o';
449 Ptr := Ptr + 1;
451 if Ptr <= Max
452 and then Switch_Chars (Ptr) in '0' .. '3'
453 then
454 Last_Stored := Last_Stored + 1;
455 Storing (Last_Stored) := Switch_Chars (Ptr);
456 Ptr := Ptr + 1;
458 if Ptr <= Max
459 and then Switch_Chars (Ptr) in '0' .. '3'
460 then
461 Last_Stored := Last_Stored + 1;
462 Storing (Last_Stored) := Switch_Chars (Ptr);
463 Ptr := Ptr + 1;
464 end if;
465 end if;
467 Add_Switch_Component
468 (Storing (Storing'First .. Last_Stored));
470 -- -gnatR may be followed by '0', '1', '2' or '3',
471 -- then by 's'
473 when 'R' =>
474 Last_Stored := First_Stored;
475 Storing (Last_Stored) := 'R';
476 Ptr := Ptr + 1;
478 if Ptr <= Max
479 and then Switch_Chars (Ptr) in '0' .. '9'
480 then
481 C := Switch_Chars (Ptr);
483 if C in '4' .. '9' then
484 Last := 0;
485 return;
487 else
488 Last_Stored := Last_Stored + 1;
489 Storing (Last_Stored) := C;
490 Ptr := Ptr + 1;
492 if Ptr <= Max
493 and then Switch_Chars (Ptr) = 's'
494 then
495 Last_Stored := Last_Stored + 1;
496 Storing (Last_Stored) := 's';
497 Ptr := Ptr + 1;
498 end if;
499 end if;
500 end if;
502 Add_Switch_Component
503 (Storing (Storing'First .. Last_Stored));
505 -- -gnatWx, x = 'h'. 'u', 's', 'e', '8' or 'b'
507 when 'W' =>
508 Storing (First_Stored) := 'W';
509 Ptr := Ptr + 1;
511 if Ptr <= Max then
512 case Switch_Chars (Ptr) is
513 when 'h' | 'u' | 's' | 'e' | '8' | 'b' =>
514 Storing (First_Stored + 1) := Switch_Chars (Ptr);
515 Add_Switch_Component
516 (Storing (Storing'First .. First_Stored + 1));
517 Ptr := Ptr + 1;
519 when others =>
520 Last := 0;
521 return;
522 end case;
523 end if;
525 -- Multiple switches
527 when 'V' | 'w' | 'y' =>
528 Storing (First_Stored) := C;
529 Ptr := Ptr + 1;
531 if Ptr > Max then
532 if C = 'y' then
533 Add_Switch_Component
534 (Storing (Storing'First .. First_Stored));
536 else
537 Last := 0;
538 return;
539 end if;
540 end if;
542 -- Loop through remaining switch characters in string
544 while Ptr <= Max loop
545 C := Switch_Chars (Ptr);
546 Ptr := Ptr + 1;
548 -- -gnatyMxxx
550 if C = 'M' and then Storing (First_Stored) = 'y' then
551 Last_Stored := First_Stored + 1;
552 Storing (Last_Stored) := 'M';
553 while Ptr <= Max loop
554 C := Switch_Chars (Ptr);
555 exit when C not in '0' .. '9';
556 Last_Stored := Last_Stored + 1;
557 Storing (Last_Stored) := C;
558 Ptr := Ptr + 1;
559 end loop;
561 -- If there is no digit after -gnatyM,
562 -- the switch is invalid.
564 if Last_Stored = First_Stored + 1 then
565 Last := 0;
566 return;
568 else
569 Add_Switch_Component
570 (Storing (Storing'First .. Last_Stored));
571 end if;
573 -- --gnatx.x
575 elsif C = '.' and then Ptr <= Max then
576 Storing (First_Stored + 1) := '.';
577 Storing (First_Stored + 2) := Switch_Chars (Ptr);
578 Ptr := Ptr + 1;
579 Add_Switch_Component
580 (Storing (Storing'First .. First_Stored + 2));
582 -- All other switches are -gnatxx
584 else
585 Storing (First_Stored + 1) := C;
586 Add_Switch_Component
587 (Storing (Storing'First .. First_Stored + 1));
588 end if;
589 end loop;
591 -- -gnat95 -gnat05
593 when '0' | '9' =>
594 Last_Stored := First_Stored;
595 Storing (Last_Stored) := C;
596 Ptr := Ptr + 1;
598 if Ptr /= Max or else Switch_Chars (Ptr) /= '5' then
600 -- Invalid switch
602 Last := 0;
603 return;
605 else
606 Last_Stored := Last_Stored + 1;
607 Storing (Last_Stored) := '5';
608 Add_Switch_Component
609 (Storing (Storing'First .. Last_Stored));
610 Ptr := Ptr + 1;
611 end if;
613 -- -gnat12
615 when '1' =>
616 Last_Stored := First_Stored;
617 Storing (Last_Stored) := C;
618 Ptr := Ptr + 1;
620 if Ptr /= Max or else Switch_Chars (Ptr) /= '2' then
622 -- Invalid switch
624 Last := 0;
625 return;
627 else
628 Last_Stored := Last_Stored + 1;
629 Storing (Last_Stored) := '2';
630 Add_Switch_Component
631 (Storing (Storing'First .. Last_Stored));
632 Ptr := Ptr + 1;
633 end if;
635 -- -gnat2005 -gnat2012
637 when '2' =>
638 if Ptr + 3 /= Max then
639 Last := 0;
640 return;
642 elsif Switch_Chars (Ptr + 1 .. Ptr + 3) = "005" then
643 Last_Stored := First_Stored + 3;
644 Storing (First_Stored .. Last_Stored) := "2005";
645 Add_Switch_Component
646 (Storing (Storing'First .. Last_Stored));
647 Ptr := Max + 1;
649 elsif Switch_Chars (Ptr + 1 .. Ptr + 3) = "012" then
650 Last_Stored := First_Stored + 3;
651 Storing (First_Stored .. Last_Stored) := "2012";
652 Add_Switch_Component
653 (Storing (Storing'First .. Last_Stored));
654 Ptr := Max + 1;
656 else
658 -- Invalid switch
660 Last := 0;
661 return;
663 end if;
665 -- -gnat83
667 when '8' =>
668 Last_Stored := First_Stored;
669 Storing (Last_Stored) := '8';
670 Ptr := Ptr + 1;
672 if Ptr /= Max or else Switch_Chars (Ptr) /= '3' then
674 -- Invalid switch
676 Last := 0;
677 return;
679 else
680 Last_Stored := Last_Stored + 1;
681 Storing (Last_Stored) := '3';
682 Add_Switch_Component
683 (Storing (Storing'First .. Last_Stored));
684 Ptr := Ptr + 1;
685 end if;
687 -- Not a valid switch
689 when others =>
690 Last := 0;
691 return;
693 end case;
695 end case;
696 end loop;
697 end Normalize_Compiler_Switches;
699 function Normalize_Compiler_Switches
700 (Switch_Chars : String) return Argument_List
702 Last : Natural;
704 begin
705 Normalize_Compiler_Switches (Switch_Chars, Global_Switches, Last);
707 if Last = 0 then
708 return (1 .. 0 => null);
709 else
710 return Global_Switches (Global_Switches'First .. Last);
711 end if;
712 end Normalize_Compiler_Switches;
714 ------------------------
715 -- Scan_Make_Switches --
716 ------------------------
718 procedure Scan_Make_Switches
719 (Env : in out Prj.Tree.Environment;
720 Switch_Chars : String;
721 Success : out Boolean)
723 Ptr : Integer := Switch_Chars'First;
724 Max : constant Integer := Switch_Chars'Last;
725 C : Character := ' ';
727 begin
728 -- Assume a good switch
730 Success := True;
732 -- Skip past the initial character (must be the switch character)
734 if Ptr = Max then
735 Bad_Switch (Switch_Chars);
737 else
738 Ptr := Ptr + 1;
739 end if;
741 -- A little check, "gnat" at the start of a switch is for the compiler
743 if Switch_Chars'Length >= Ptr + 3
744 and then Switch_Chars (Ptr .. Ptr + 3) = "gnat"
745 then
746 Success := False;
747 return;
748 end if;
750 C := Switch_Chars (Ptr);
752 -- Multiple character switches
754 if Switch_Chars'Length > 2 then
755 if Switch_Chars = "--create-missing-dirs" then
756 Setup_Projects := True;
758 elsif Switch_Chars'Length > Subdirs_Option'Length
759 and then
760 Switch_Chars
761 (Switch_Chars'First ..
762 Switch_Chars'First + Subdirs_Option'Length - 1) =
763 Subdirs_Option
764 then
765 Subdirs :=
766 new String'
767 (Switch_Chars
768 (Switch_Chars'First + Subdirs_Option'Length ..
769 Switch_Chars'Last));
771 elsif Switch_Chars = Makeutl.Unchecked_Shared_Lib_Imports then
772 Opt.Unchecked_Shared_Lib_Imports := True;
774 elsif Switch_Chars = Makeutl.Single_Compile_Per_Obj_Dir_Switch then
775 Opt.One_Compilation_Per_Obj_Dir := True;
777 elsif Switch_Chars (Ptr) = '-' then
778 Bad_Switch (Switch_Chars);
780 elsif Switch_Chars'Length > 3
781 and then Switch_Chars (Ptr .. Ptr + 1) = "aP"
782 then
783 Add_Directories
784 (Env.Project_Path,
785 Switch_Chars (Ptr + 2 .. Switch_Chars'Last));
787 elsif C = 'v' and then Switch_Chars'Length = 3 then
788 Ptr := Ptr + 1;
789 Verbose_Mode := True;
791 case Switch_Chars (Ptr) is
792 when 'l' =>
793 Verbosity_Level := Opt.Low;
795 when 'm' =>
796 Verbosity_Level := Opt.Medium;
798 when 'h' =>
799 Verbosity_Level := Opt.High;
801 when others =>
802 Success := False;
803 end case;
805 elsif C = 'd' then
807 -- Note: for the debug switch, the remaining characters in this
808 -- switch field must all be debug flags, since all valid switch
809 -- characters are also valid debug characters. This switch is not
810 -- documented on purpose because it is only used by the
811 -- implementors.
813 -- Loop to scan out debug flags
815 while Ptr < Max loop
816 Ptr := Ptr + 1;
817 C := Switch_Chars (Ptr);
819 if C in 'a' .. 'z' or else C in 'A' .. 'Z' then
820 Set_Debug_Flag (C);
821 else
822 Bad_Switch (Switch_Chars);
823 end if;
824 end loop;
826 elsif C = 'e' then
827 Ptr := Ptr + 1;
829 case Switch_Chars (Ptr) is
831 -- Processing for eI switch
833 when 'I' =>
834 Ptr := Ptr + 1;
835 Scan_Pos (Switch_Chars, Max, Ptr, Main_Index, C);
837 if Ptr <= Max then
838 Bad_Switch (Switch_Chars);
839 end if;
841 -- Processing for eL switch
843 when 'L' =>
844 if Ptr /= Max then
845 Bad_Switch (Switch_Chars);
847 else
848 Follow_Links_For_Files := True;
849 Follow_Links_For_Dirs := True;
850 end if;
852 -- Processing for eS switch
854 when 'S' =>
855 if Ptr /= Max then
856 Bad_Switch (Switch_Chars);
858 else
859 Commands_To_Stdout := True;
860 end if;
862 when others =>
863 Bad_Switch (Switch_Chars);
864 end case;
866 elsif C = 'j' then
867 Ptr := Ptr + 1;
869 declare
870 Max_Proc : Nat;
872 begin
873 Scan_Nat (Switch_Chars, Max, Ptr, Max_Proc, C);
875 if Ptr <= Max then
876 Bad_Switch (Switch_Chars);
878 else
879 if Max_Proc = 0 then
880 Max_Proc := Nat (Number_Of_CPUs);
882 if Max_Proc = 0 then
883 Max_Proc := 1;
884 end if;
885 end if;
887 Maximum_Processes := Positive (Max_Proc);
888 end if;
889 end;
891 elsif C = 'w' and then Switch_Chars'Length = 3 then
892 Ptr := Ptr + 1;
894 if Switch_Chars = "-we" then
895 Warning_Mode := Treat_As_Error;
897 elsif Switch_Chars = "-wn" then
898 Warning_Mode := Normal;
900 elsif Switch_Chars = "-ws" then
901 Warning_Mode := Suppress;
903 else
904 Success := False;
905 end if;
907 else
908 Success := False;
909 end if;
911 -- Single-character switches
913 else
914 Check_Switch : begin
916 case C is
918 when 'a' =>
919 Check_Readonly_Files := True;
921 -- Processing for b switch
923 when 'b' =>
924 Bind_Only := True;
925 Make_Steps := True;
927 -- Processing for B switch
929 when 'B' =>
930 Build_Bind_And_Link_Full_Project := True;
932 -- Processing for c switch
934 when 'c' =>
935 Compile_Only := True;
936 Make_Steps := True;
938 -- Processing for C switch
940 when 'C' =>
941 Opt.Create_Mapping_File := True;
943 -- Processing for D switch
945 when 'D' =>
946 if Object_Directory_Present then
947 Osint.Fail ("duplicate -D switch");
949 else
950 Object_Directory_Present := True;
951 end if;
953 -- Processing for f switch
955 when 'f' =>
956 Force_Compilations := True;
958 -- Processing for F switch
960 when 'F' =>
961 Full_Path_Name_For_Brief_Errors := True;
963 -- Processing for h switch
965 when 'h' =>
966 Usage_Requested := True;
968 -- Processing for i switch
970 when 'i' =>
971 In_Place_Mode := True;
973 -- Processing for j switch
975 when 'j' =>
976 -- -j not followed by a number is an error
978 Bad_Switch (Switch_Chars);
980 -- Processing for k switch
982 when 'k' =>
983 Keep_Going := True;
985 -- Processing for l switch
987 when 'l' =>
988 Link_Only := True;
989 Make_Steps := True;
991 -- Processing for M switch
993 when 'M' =>
994 List_Dependencies := True;
996 -- Processing for n switch
998 when 'n' =>
999 Do_Not_Execute := True;
1001 -- Processing for o switch
1003 when 'o' =>
1004 if Output_File_Name_Present then
1005 Osint.Fail ("duplicate -o switch");
1006 else
1007 Output_File_Name_Present := True;
1008 end if;
1010 -- Processing for p switch
1012 when 'p' =>
1013 Setup_Projects := True;
1015 -- Processing for q switch
1017 when 'q' =>
1018 Quiet_Output := True;
1020 -- Processing for R switch
1022 when 'R' =>
1023 Run_Path_Option := False;
1025 -- Processing for s switch
1027 when 's' =>
1028 Ptr := Ptr + 1;
1029 Check_Switches := True;
1031 -- Processing for v switch
1033 when 'v' =>
1034 Verbose_Mode := True;
1035 Verbosity_Level := Opt.High;
1037 -- Processing for x switch
1039 when 'x' =>
1040 External_Unit_Compilation_Allowed := True;
1041 Use_Include_Path_File := True;
1043 -- Processing for z switch
1045 when 'z' =>
1046 No_Main_Subprogram := True;
1048 -- Any other small letter is an illegal switch
1050 when others =>
1051 if C in 'a' .. 'z' then
1052 Bad_Switch (Switch_Chars);
1054 else
1055 Success := False;
1056 end if;
1058 end case;
1059 end Check_Switch;
1060 end if;
1061 end Scan_Make_Switches;
1063 end Switch.M;