VirtualBox

source: kBuild/vendor/gnumake/2007-05-23/read.c@ 1989

Last change on this file since 1989 was 900, checked in by bird, 18 years ago

Load /home/bird/src/Gnu/make/2007-05-23 into vendor/gnumake/current.

  • Property svn:eol-style set to native
File size: 89.2 KB
Line 
1/* Reading and parsing of makefiles for GNU Make.
2Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
4Foundation, Inc.
5This file is part of GNU Make.
6
7GNU Make is free software; you can redistribute it and/or modify it under the
8terms of the GNU General Public License as published by the Free Software
9Foundation; either version 2, or (at your option) any later version.
10
11GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License along with
16GNU Make; see the file COPYING. If not, write to the Free Software
17Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */
18
19#include "make.h"
20
21#include <assert.h>
22
23#include <glob.h>
24
25#include "dep.h"
26#include "filedef.h"
27#include "job.h"
28#include "commands.h"
29#include "variable.h"
30#include "rule.h"
31#include "debug.h"
32#include "hash.h"
33
34
35#ifndef WINDOWS32
36#ifndef _AMIGA
37#ifndef VMS
38#include <pwd.h>
39#else
40struct passwd *getpwnam (char *name);
41#endif
42#endif
43#endif /* !WINDOWS32 */
44
45/* A 'struct ebuffer' controls the origin of the makefile we are currently
46 eval'ing.
47*/
48
49struct ebuffer
50 {
51 char *buffer; /* Start of the current line in the buffer. */
52 char *bufnext; /* Start of the next line in the buffer. */
53 char *bufstart; /* Start of the entire buffer. */
54 unsigned int size; /* Malloc'd size of buffer. */
55 FILE *fp; /* File, or NULL if this is an internal buffer. */
56 struct floc floc; /* Info on the file in fp (if any). */
57 };
58
59/* Types of "words" that can be read in a makefile. */
60enum make_word_type
61 {
62 w_bogus, w_eol, w_static, w_variable, w_colon, w_dcolon, w_semicolon,
63 w_varassign
64 };
65
66
67/* A `struct conditionals' contains the information describing
68 all the active conditionals in a makefile.
69
70 The global variable `conditionals' contains the conditionals
71 information for the current makefile. It is initialized from
72 the static structure `toplevel_conditionals' and is later changed
73 to new structures for included makefiles. */
74
75struct conditionals
76 {
77 unsigned int if_cmds; /* Depth of conditional nesting. */
78 unsigned int allocated; /* Elts allocated in following arrays. */
79 char *ignoring; /* Are we ignoring or interpreting?
80 0=interpreting, 1=not yet interpreted,
81 2=already interpreted */
82 char *seen_else; /* Have we already seen an `else'? */
83 };
84
85static struct conditionals toplevel_conditionals;
86static struct conditionals *conditionals = &toplevel_conditionals;
87
88
89/* Default directories to search for include files in */
90
91static const char *default_include_directories[] =
92 {
93#if defined(WINDOWS32) && !defined(INCLUDEDIR)
94/* This completely up to the user when they install MSVC or other packages.
95 This is defined as a placeholder. */
96# define INCLUDEDIR "."
97#endif
98 INCLUDEDIR,
99#ifndef _AMIGA
100 "/usr/gnu/include",
101 "/usr/local/include",
102 "/usr/include",
103#endif
104 0
105 };
106
107/* List of directories to search for include files in */
108
109static const char **include_directories;
110
111/* Maximum length of an element of the above. */
112
113static unsigned int max_incl_len;
114
115/* The filename and pointer to line number of the
116 makefile currently being read in. */
117
118const struct floc *reading_file = 0;
119
120/* The chain of makefiles read by read_makefile. */
121
122static struct dep *read_makefiles = 0;
123
124static int eval_makefile (const char *filename, int flags);
125static int eval (struct ebuffer *buffer, int flags);
126
127static long readline (struct ebuffer *ebuf);
128static void do_define (char *name, unsigned int namelen,
129 enum variable_origin origin, struct ebuffer *ebuf);
130static int conditional_line (char *line, int len, const struct floc *flocp);
131static void record_files (struct nameseq *filenames, const char *pattern,
132 const char *pattern_percent, struct dep *deps,
133 unsigned int cmds_started, char *commands,
134 unsigned int commands_idx, int two_colon,
135 const struct floc *flocp);
136static void record_target_var (struct nameseq *filenames, char *defn,
137 enum variable_origin origin, int enabled,
138 const struct floc *flocp);
139static enum make_word_type get_next_mword (char *buffer, char *delim,
140 char **startp, unsigned int *length);
141static void remove_comments (char *line);
142static char *find_char_unquote (char *string, int stop1, int stop2,
143 int blank, int ignorevars);
144
145
146/* Read in all the makefiles and return the chain of their names. */
147
148struct dep *
149read_all_makefiles (const char **makefiles)
150{
151 unsigned int num_makefiles = 0;
152
153 /* Create *_LIST variables, to hold the makefiles, targets, and variables
154 we will be reading. */
155
156 define_variable ("MAKEFILE_LIST", sizeof ("MAKEFILE_LIST")-1, "", o_file, 0);
157
158 DB (DB_BASIC, (_("Reading makefiles...\n")));
159
160 /* If there's a non-null variable MAKEFILES, its value is a list of
161 files to read first thing. But don't let it prevent reading the
162 default makefiles and don't let the default goal come from there. */
163
164 {
165 char *value;
166 char *name, *p;
167 unsigned int length;
168
169 {
170 /* Turn off --warn-undefined-variables while we expand MAKEFILES. */
171 int save = warn_undefined_variables_flag;
172 warn_undefined_variables_flag = 0;
173
174 value = allocated_variable_expand ("$(MAKEFILES)");
175
176 warn_undefined_variables_flag = save;
177 }
178
179 /* Set NAME to the start of next token and LENGTH to its length.
180 MAKEFILES is updated for finding remaining tokens. */
181 p = value;
182
183 while ((name = find_next_token ((const char **)&p, &length)) != 0)
184 {
185 if (*p != '\0')
186 *p++ = '\0';
187 eval_makefile (name, RM_NO_DEFAULT_GOAL|RM_INCLUDED|RM_DONTCARE);
188 }
189
190 free (value);
191 }
192
193 /* Read makefiles specified with -f switches. */
194
195 if (makefiles != 0)
196 while (*makefiles != 0)
197 {
198 struct dep *tail = read_makefiles;
199 register struct dep *d;
200
201 if (! eval_makefile (*makefiles, 0))
202 perror_with_name ("", *makefiles);
203
204 /* Find the right element of read_makefiles. */
205 d = read_makefiles;
206 while (d->next != tail)
207 d = d->next;
208
209 /* Use the storage read_makefile allocates. */
210 *makefiles = dep_name (d);
211 ++num_makefiles;
212 ++makefiles;
213 }
214
215 /* If there were no -f switches, try the default names. */
216
217 if (num_makefiles == 0)
218 {
219 static char *default_makefiles[] =
220#ifdef VMS
221 /* all lower case since readdir() (the vms version) 'lowercasifies' */
222 { "makefile.vms", "gnumakefile.", "makefile.", 0 };
223#else
224#ifdef _AMIGA
225 { "GNUmakefile", "Makefile", "SMakefile", 0 };
226#else /* !Amiga && !VMS */
227 { "GNUmakefile", "makefile", "Makefile", 0 };
228#endif /* AMIGA */
229#endif /* VMS */
230 register char **p = default_makefiles;
231 while (*p != 0 && !file_exists_p (*p))
232 ++p;
233
234 if (*p != 0)
235 {
236 if (! eval_makefile (*p, 0))
237 perror_with_name ("", *p);
238 }
239 else
240 {
241 /* No default makefile was found. Add the default makefiles to the
242 `read_makefiles' chain so they will be updated if possible. */
243 struct dep *tail = read_makefiles;
244 /* Add them to the tail, after any MAKEFILES variable makefiles. */
245 while (tail != 0 && tail->next != 0)
246 tail = tail->next;
247 for (p = default_makefiles; *p != 0; ++p)
248 {
249 struct dep *d = alloc_dep ();
250 d->file = enter_file (strcache_add (*p));
251 d->file->dontcare = 1;
252 /* Tell update_goal_chain to bail out as soon as this file is
253 made, and main not to die if we can't make this file. */
254 d->changed = RM_DONTCARE;
255 if (tail == 0)
256 read_makefiles = d;
257 else
258 tail->next = d;
259 tail = d;
260 }
261 if (tail != 0)
262 tail->next = 0;
263 }
264 }
265
266 return read_makefiles;
267}
268
269
270/* Install a new conditional and return the previous one. */
271
272static struct conditionals *
273install_conditionals (struct conditionals *new)
274{
275 struct conditionals *save = conditionals;
276
277 memset (new, '\0', sizeof (*new));
278 conditionals = new;
279
280 return save;
281}
282
283/* Free the current conditionals and reinstate a saved one. */
284
285static void
286restore_conditionals (struct conditionals *saved)
287{
288 /* Free any space allocated by conditional_line. */
289 if (conditionals->ignoring)
290 free (conditionals->ignoring);
291 if (conditionals->seen_else)
292 free (conditionals->seen_else);
293
294 /* Restore state. */
295 conditionals = saved;
296}
297
298
299static int
300eval_makefile (const char *filename, int flags)
301{
302 struct dep *deps;
303 struct ebuffer ebuf;
304 const struct floc *curfile;
305 char *expanded = 0;
306 int makefile_errno;
307 int r;
308
309 filename = strcache_add (filename);
310 ebuf.floc.filenm = filename;
311 ebuf.floc.lineno = 1;
312
313 if (ISDB (DB_VERBOSE))
314 {
315 printf (_("Reading makefile `%s'"), filename);
316 if (flags & RM_NO_DEFAULT_GOAL)
317 printf (_(" (no default goal)"));
318 if (flags & RM_INCLUDED)
319 printf (_(" (search path)"));
320 if (flags & RM_DONTCARE)
321 printf (_(" (don't care)"));
322 if (flags & RM_NO_TILDE)
323 printf (_(" (no ~ expansion)"));
324 puts ("...");
325 }
326
327 /* First, get a stream to read. */
328
329 /* Expand ~ in FILENAME unless it came from `include',
330 in which case it was already done. */
331 if (!(flags & RM_NO_TILDE) && filename[0] == '~')
332 {
333 expanded = tilde_expand (filename);
334 if (expanded != 0)
335 filename = expanded;
336 }
337
338 ebuf.fp = fopen (filename, "r");
339 /* Save the error code so we print the right message later. */
340 makefile_errno = errno;
341
342 /* If the makefile wasn't found and it's either a makefile from
343 the `MAKEFILES' variable or an included makefile,
344 search the included makefile search path for this makefile. */
345 if (ebuf.fp == 0 && (flags & RM_INCLUDED) && *filename != '/')
346 {
347 unsigned int i;
348 for (i = 0; include_directories[i] != 0; ++i)
349 {
350 const char *included = concat (include_directories[i], "/", filename);
351 ebuf.fp = fopen (included, "r");
352 if (ebuf.fp)
353 {
354 filename = strcache_add (included);
355 break;
356 }
357 }
358 }
359
360 /* Add FILENAME to the chain of read makefiles. */
361 deps = alloc_dep ();
362 deps->next = read_makefiles;
363 read_makefiles = deps;
364 deps->file = lookup_file (filename);
365 if (deps->file == 0)
366 deps->file = enter_file (filename);
367 filename = deps->file->name;
368 deps->changed = flags;
369 if (flags & RM_DONTCARE)
370 deps->file->dontcare = 1;
371
372 if (expanded)
373 free (expanded);
374
375 /* If the makefile can't be found at all, give up entirely. */
376
377 if (ebuf.fp == 0)
378 {
379 /* If we did some searching, errno has the error from the last
380 attempt, rather from FILENAME itself. Restore it in case the
381 caller wants to use it in a message. */
382 errno = makefile_errno;
383 return 0;
384 }
385
386 /* Add this makefile to the list. */
387 do_variable_definition (&ebuf.floc, "MAKEFILE_LIST", filename, o_file,
388 f_append, 0);
389
390 /* Evaluate the makefile */
391
392 ebuf.size = 200;
393 ebuf.buffer = ebuf.bufnext = ebuf.bufstart = xmalloc (ebuf.size);
394
395 curfile = reading_file;
396 reading_file = &ebuf.floc;
397
398 r = eval (&ebuf, !(flags & RM_NO_DEFAULT_GOAL));
399
400 reading_file = curfile;
401
402 fclose (ebuf.fp);
403
404 free (ebuf.bufstart);
405 alloca (0);
406 return r;
407}
408
409int
410eval_buffer (char *buffer)
411{
412 struct ebuffer ebuf;
413 struct conditionals *saved;
414 struct conditionals new;
415 const struct floc *curfile;
416 int r;
417
418 /* Evaluate the buffer */
419
420 ebuf.size = strlen (buffer);
421 ebuf.buffer = ebuf.bufnext = ebuf.bufstart = buffer;
422 ebuf.fp = NULL;
423
424 ebuf.floc = *reading_file;
425
426 curfile = reading_file;
427 reading_file = &ebuf.floc;
428
429 saved = install_conditionals (&new);
430
431 r = eval (&ebuf, 1);
432
433 restore_conditionals (saved);
434
435 reading_file = curfile;
436
437 alloca (0);
438 return r;
439}
440
441
442
443/* Read file FILENAME as a makefile and add its contents to the data base.
444
445 SET_DEFAULT is true if we are allowed to set the default goal. */
446
447
448static int
449eval (struct ebuffer *ebuf, int set_default)
450{
451 char *collapsed = 0;
452 unsigned int collapsed_length = 0;
453 unsigned int commands_len = 200;
454 char *commands;
455 unsigned int commands_idx = 0;
456 unsigned int cmds_started, tgts_started;
457 int ignoring = 0, in_ignored_define = 0;
458 int no_targets = 0; /* Set when reading a rule without targets. */
459 struct nameseq *filenames = 0;
460 struct dep *deps = 0;
461 long nlines = 0;
462 int two_colon = 0;
463 const char *pattern = 0;
464 const char *pattern_percent;
465 struct floc *fstart;
466 struct floc fi;
467
468#define record_waiting_files() \
469 do \
470 { \
471 if (filenames != 0) \
472 { \
473 fi.lineno = tgts_started; \
474 record_files (filenames, pattern, pattern_percent, deps, \
475 cmds_started, commands, commands_idx, two_colon, \
476 &fi); \
477 } \
478 filenames = 0; \
479 commands_idx = 0; \
480 no_targets = 0; \
481 pattern = 0; \
482 } while (0)
483
484 pattern_percent = 0;
485 cmds_started = tgts_started = 1;
486
487 fstart = &ebuf->floc;
488 fi.filenm = ebuf->floc.filenm;
489
490 /* Loop over lines in the file.
491 The strategy is to accumulate target names in FILENAMES, dependencies
492 in DEPS and commands in COMMANDS. These are used to define a rule
493 when the start of the next rule (or eof) is encountered.
494
495 When you see a "continue" in the loop below, that means we are moving on
496 to the next line _without_ ending any rule that we happen to be working
497 with at the moment. If you see a "goto rule_complete", then the
498 statement we just parsed also finishes the previous rule. */
499
500 commands = xmalloc (200);
501
502 while (1)
503 {
504 unsigned int linelen;
505 char *line;
506 unsigned int wlen;
507 char *p;
508 char *p2;
509
510 /* Grab the next line to be evaluated */
511 ebuf->floc.lineno += nlines;
512 nlines = readline (ebuf);
513
514 /* If there is nothing left to eval, we're done. */
515 if (nlines < 0)
516 break;
517
518 /* If this line is empty, skip it. */
519 line = ebuf->buffer;
520 if (line[0] == '\0')
521 continue;
522
523 linelen = strlen (line);
524
525 /* Check for a shell command line first.
526 If it is not one, we can stop treating tab specially. */
527 if (line[0] == cmd_prefix)
528 {
529 if (no_targets)
530 /* Ignore the commands in a rule with no targets. */
531 continue;
532
533 /* If there is no preceding rule line, don't treat this line
534 as a command, even though it begins with a tab character.
535 SunOS 4 make appears to behave this way. */
536
537 if (filenames != 0)
538 {
539 if (ignoring)
540 /* Yep, this is a shell command, and we don't care. */
541 continue;
542
543 /* Append this command line to the line being accumulated. */
544 if (commands_idx == 0)
545 cmds_started = ebuf->floc.lineno;
546
547 if (linelen + 1 + commands_idx > commands_len)
548 {
549 commands_len = (linelen + 1 + commands_idx) * 2;
550 commands = xrealloc (commands, commands_len);
551 }
552 memcpy (&commands[commands_idx], line, linelen);
553 commands_idx += linelen;
554 commands[commands_idx++] = '\n';
555
556 continue;
557 }
558 }
559
560 /* This line is not a shell command line. Don't worry about tabs.
561 Get more space if we need it; we don't need to preserve the current
562 contents of the buffer. */
563
564 if (collapsed_length < linelen+1)
565 {
566 collapsed_length = linelen+1;
567 if (collapsed)
568 free (collapsed);
569 collapsed = xmalloc (collapsed_length);
570 }
571 strcpy (collapsed, line);
572 /* Collapse continuation lines. */
573 collapse_continuations (collapsed);
574 remove_comments (collapsed);
575
576 /* Compare a word, both length and contents. */
577#define word1eq(s) (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
578 p = collapsed;
579 while (isspace ((unsigned char)*p))
580 ++p;
581
582 if (*p == '\0')
583 /* This line is completely empty--ignore it. */
584 continue;
585
586 /* Find the end of the first token. Note we don't need to worry about
587 * ":" here since we compare tokens by length (so "export" will never
588 * be equal to "export:").
589 */
590 for (p2 = p+1; *p2 != '\0' && !isspace ((unsigned char)*p2); ++p2)
591 ;
592 wlen = p2 - p;
593
594 /* Find the start of the second token. If it looks like a target or
595 variable definition it can't be a preprocessor token so skip
596 them--this allows variables/targets named `ifdef', `export', etc. */
597 while (isspace ((unsigned char)*p2))
598 ++p2;
599
600 if ((p2[0] == ':' || p2[0] == '+' || p2[0] == '=') && p2[1] == '\0')
601 {
602 /* It can't be a preprocessor token so skip it if we're ignoring */
603 if (ignoring)
604 continue;
605
606 goto skip_conditionals;
607 }
608
609 /* We must first check for conditional and `define' directives before
610 ignoring anything, since they control what we will do with
611 following lines. */
612
613 if (!in_ignored_define)
614 {
615 int i = conditional_line (p, wlen, fstart);
616 if (i != -2)
617 {
618 if (i == -1)
619 fatal (fstart, _("invalid syntax in conditional"));
620
621 ignoring = i;
622 continue;
623 }
624 }
625
626 if (word1eq ("endef"))
627 {
628 if (!in_ignored_define)
629 fatal (fstart, _("extraneous `endef'"));
630 in_ignored_define = 0;
631 continue;
632 }
633
634 if (word1eq ("define"))
635 {
636 if (ignoring)
637 in_ignored_define = 1;
638 else
639 {
640 if (*p2 == '\0')
641 fatal (fstart, _("empty variable name"));
642
643 /* Let the variable name be the whole rest of the line,
644 with trailing blanks stripped (comments have already been
645 removed), so it could be a complex variable/function
646 reference that might contain blanks. */
647 p = strchr (p2, '\0');
648 while (isblank ((unsigned char)p[-1]))
649 --p;
650 do_define (p2, p - p2, o_file, ebuf);
651 }
652 continue;
653 }
654
655 if (word1eq ("override"))
656 {
657 if (*p2 == '\0')
658 error (fstart, _("empty `override' directive"));
659
660 if (strneq (p2, "define", 6)
661 && (isblank ((unsigned char)p2[6]) || p2[6] == '\0'))
662 {
663 if (ignoring)
664 in_ignored_define = 1;
665 else
666 {
667 p2 = next_token (p2 + 6);
668 if (*p2 == '\0')
669 fatal (fstart, _("empty variable name"));
670
671 /* Let the variable name be the whole rest of the line,
672 with trailing blanks stripped (comments have already been
673 removed), so it could be a complex variable/function
674 reference that might contain blanks. */
675 p = strchr (p2, '\0');
676 while (isblank ((unsigned char)p[-1]))
677 --p;
678 do_define (p2, p - p2, o_override, ebuf);
679 }
680 }
681 else if (!ignoring
682 && !try_variable_definition (fstart, p2, o_override, 0))
683 error (fstart, _("invalid `override' directive"));
684
685 continue;
686 }
687
688 if (ignoring)
689 /* Ignore the line. We continue here so conditionals
690 can appear in the middle of a rule. */
691 continue;
692
693 if (word1eq ("export"))
694 {
695 /* 'export' by itself causes everything to be exported. */
696 if (*p2 == '\0')
697 export_all_variables = 1;
698 else
699 {
700 struct variable *v;
701
702 v = try_variable_definition (fstart, p2, o_file, 0);
703 if (v != 0)
704 v->export = v_export;
705 else
706 {
707 unsigned int l;
708 const char *cp;
709 char *ap;
710
711 /* Expand the line so we can use indirect and constructed
712 variable names in an export command. */
713 cp = ap = allocated_variable_expand (p2);
714
715 for (p = find_next_token (&cp, &l); p != 0;
716 p = find_next_token (&cp, &l))
717 {
718 v = lookup_variable (p, l);
719 if (v == 0)
720 v = define_variable_loc (p, l, "", o_file, 0, fstart);
721 v->export = v_export;
722 }
723
724 free (ap);
725 }
726 }
727 goto rule_complete;
728 }
729
730 if (word1eq ("unexport"))
731 {
732 if (*p2 == '\0')
733 export_all_variables = 0;
734 else
735 {
736 unsigned int l;
737 struct variable *v;
738 const char *cp;
739 char *ap;
740
741 /* Expand the line so we can use indirect and constructed
742 variable names in an unexport command. */
743 cp = ap = allocated_variable_expand (p2);
744
745 for (p = find_next_token (&cp, &l); p != 0;
746 p = find_next_token (&cp, &l))
747 {
748 v = lookup_variable (p, l);
749 if (v == 0)
750 v = define_variable_loc (p, l, "", o_file, 0, fstart);
751
752 v->export = v_noexport;
753 }
754
755 free (ap);
756 }
757 goto rule_complete;
758 }
759
760 skip_conditionals:
761 if (word1eq ("vpath"))
762 {
763 const char *cp;
764 char *vpat;
765 unsigned int l;
766 cp = variable_expand (p2);
767 p = find_next_token (&cp, &l);
768 if (p != 0)
769 {
770 vpat = savestring (p, l);
771 p = find_next_token (&cp, &l);
772 /* No searchpath means remove all previous
773 selective VPATH's with the same pattern. */
774 }
775 else
776 /* No pattern means remove all previous selective VPATH's. */
777 vpat = 0;
778 construct_vpath_list (vpat, p);
779 if (vpat != 0)
780 free (vpat);
781
782 goto rule_complete;
783 }
784
785 if (word1eq ("include") || word1eq ("-include") || word1eq ("sinclude"))
786 {
787 /* We have found an `include' line specifying a nested
788 makefile to be read at this point. */
789 struct conditionals *save;
790 struct conditionals new_conditionals;
791 struct nameseq *files;
792 /* "-include" (vs "include") says no error if the file does not
793 exist. "sinclude" is an alias for this from SGI. */
794 int noerror = (p[0] != 'i');
795
796 p = allocated_variable_expand (p2);
797
798 /* If no filenames, it's a no-op. */
799 if (*p == '\0')
800 {
801 free (p);
802 continue;
803 }
804
805 /* Parse the list of file names. */
806 p2 = p;
807 files = multi_glob (parse_file_seq (&p2, '\0',
808 sizeof (struct nameseq),
809 1),
810 sizeof (struct nameseq));
811 free (p);
812
813 /* Save the state of conditionals and start
814 the included makefile with a clean slate. */
815 save = install_conditionals (&new_conditionals);
816
817 /* Record the rules that are waiting so they will determine
818 the default goal before those in the included makefile. */
819 record_waiting_files ();
820
821 /* Read each included makefile. */
822 while (files != 0)
823 {
824 struct nameseq *next = files->next;
825 const char *name = files->name;
826 int r;
827
828 free (files);
829 files = next;
830
831 r = eval_makefile (name, (RM_INCLUDED | RM_NO_TILDE
832 | (noerror ? RM_DONTCARE : 0)));
833 if (!r && !noerror)
834 error (fstart, "%s: %s", name, strerror (errno));
835 }
836
837 /* Restore conditional state. */
838 restore_conditionals (save);
839
840 goto rule_complete;
841 }
842
843 if (try_variable_definition (fstart, p, o_file, 0))
844 /* This line has been dealt with. */
845 goto rule_complete;
846
847 /* This line starts with a tab but was not caught above because there
848 was no preceding target, and the line might have been usable as a
849 variable definition. But now we know it is definitely lossage. */
850 if (line[0] == cmd_prefix)
851 fatal(fstart, _("commands commence before first target"));
852
853 /* This line describes some target files. This is complicated by
854 the existence of target-specific variables, because we can't
855 expand the entire line until we know if we have one or not. So
856 we expand the line word by word until we find the first `:',
857 then check to see if it's a target-specific variable.
858
859 In this algorithm, `lb_next' will point to the beginning of the
860 unexpanded parts of the input buffer, while `p2' points to the
861 parts of the expanded buffer we haven't searched yet. */
862
863 {
864 enum make_word_type wtype;
865 enum variable_origin v_origin;
866 int exported;
867 char *cmdleft, *semip, *lb_next;
868 unsigned int plen = 0;
869 char *colonp;
870 const char *end, *beg; /* Helpers for whitespace stripping. */
871
872 /* Record the previous rule. */
873
874 record_waiting_files ();
875 tgts_started = fstart->lineno;
876
877 /* Search the line for an unquoted ; that is not after an
878 unquoted #. */
879 cmdleft = find_char_unquote (line, ';', '#', 0, 1);
880 if (cmdleft != 0 && *cmdleft == '#')
881 {
882 /* We found a comment before a semicolon. */
883 *cmdleft = '\0';
884 cmdleft = 0;
885 }
886 else if (cmdleft != 0)
887 /* Found one. Cut the line short there before expanding it. */
888 *(cmdleft++) = '\0';
889 semip = cmdleft;
890
891 collapse_continuations (line);
892
893 /* We can't expand the entire line, since if it's a per-target
894 variable we don't want to expand it. So, walk from the
895 beginning, expanding as we go, and looking for "interesting"
896 chars. The first word is always expandable. */
897 wtype = get_next_mword(line, NULL, &lb_next, &wlen);
898 switch (wtype)
899 {
900 case w_eol:
901 if (cmdleft != 0)
902 fatal(fstart, _("missing rule before commands"));
903 /* This line contained something but turned out to be nothing
904 but whitespace (a comment?). */
905 continue;
906
907 case w_colon:
908 case w_dcolon:
909 /* We accept and ignore rules without targets for
910 compatibility with SunOS 4 make. */
911 no_targets = 1;
912 continue;
913
914 default:
915 break;
916 }
917
918 p2 = variable_expand_string(NULL, lb_next, wlen);
919
920 while (1)
921 {
922 lb_next += wlen;
923 if (cmdleft == 0)
924 {
925 /* Look for a semicolon in the expanded line. */
926 cmdleft = find_char_unquote (p2, ';', 0, 0, 0);
927
928 if (cmdleft != 0)
929 {
930 unsigned long p2_off = p2 - variable_buffer;
931 unsigned long cmd_off = cmdleft - variable_buffer;
932 char *pend = p2 + strlen(p2);
933
934 /* Append any remnants of lb, then cut the line short
935 at the semicolon. */
936 *cmdleft = '\0';
937
938 /* One school of thought says that you shouldn't expand
939 here, but merely copy, since now you're beyond a ";"
940 and into a command script. However, the old parser
941 expanded the whole line, so we continue that for
942 backwards-compatiblity. Also, it wouldn't be
943 entirely consistent, since we do an unconditional
944 expand below once we know we don't have a
945 target-specific variable. */
946 (void)variable_expand_string(pend, lb_next, (long)-1);
947 lb_next += strlen(lb_next);
948 p2 = variable_buffer + p2_off;
949 cmdleft = variable_buffer + cmd_off + 1;
950 }
951 }
952
953 colonp = find_char_unquote(p2, ':', 0, 0, 0);
954#ifdef HAVE_DOS_PATHS
955 /* The drive spec brain-damage strikes again... */
956 /* Note that the only separators of targets in this context
957 are whitespace and a left paren. If others are possible,
958 they should be added to the string in the call to index. */
959 while (colonp && (colonp[1] == '/' || colonp[1] == '\\') &&
960 colonp > p2 && isalpha ((unsigned char)colonp[-1]) &&
961 (colonp == p2 + 1 || strchr (" \t(", colonp[-2]) != 0))
962 colonp = find_char_unquote(colonp + 1, ':', 0, 0, 0);
963#endif
964 if (colonp != 0)
965 break;
966
967 wtype = get_next_mword(lb_next, NULL, &lb_next, &wlen);
968 if (wtype == w_eol)
969 break;
970
971 p2 += strlen(p2);
972 *(p2++) = ' ';
973 p2 = variable_expand_string(p2, lb_next, wlen);
974 /* We don't need to worry about cmdleft here, because if it was
975 found in the variable_buffer the entire buffer has already
976 been expanded... we'll never get here. */
977 }
978
979 p2 = next_token (variable_buffer);
980
981 /* If the word we're looking at is EOL, see if there's _anything_
982 on the line. If not, a variable expanded to nothing, so ignore
983 it. If so, we can't parse this line so punt. */
984 if (wtype == w_eol)
985 {
986 if (*p2 != '\0')
987 /* There's no need to be ivory-tower about this: check for
988 one of the most common bugs found in makefiles... */
989 fatal (fstart, _("missing separator%s"),
990 !strneq(line, " ", 8) ? ""
991 : _(" (did you mean TAB instead of 8 spaces?)"));
992 continue;
993 }
994
995 /* Make the colon the end-of-string so we know where to stop
996 looking for targets. */
997 *colonp = '\0';
998 filenames = multi_glob (parse_file_seq (&p2, '\0',
999 sizeof (struct nameseq),
1000 1),
1001 sizeof (struct nameseq));
1002 *p2 = ':';
1003
1004 if (!filenames)
1005 {
1006 /* We accept and ignore rules without targets for
1007 compatibility with SunOS 4 make. */
1008 no_targets = 1;
1009 continue;
1010 }
1011 /* This should never be possible; we handled it above. */
1012 assert (*p2 != '\0');
1013 ++p2;
1014
1015 /* Is this a one-colon or two-colon entry? */
1016 two_colon = *p2 == ':';
1017 if (two_colon)
1018 p2++;
1019
1020 /* Test to see if it's a target-specific variable. Copy the rest
1021 of the buffer over, possibly temporarily (we'll expand it later
1022 if it's not a target-specific variable). PLEN saves the length
1023 of the unparsed section of p2, for later. */
1024 if (*lb_next != '\0')
1025 {
1026 unsigned int l = p2 - variable_buffer;
1027 plen = strlen (p2);
1028 variable_buffer_output (p2+plen, lb_next, strlen (lb_next)+1);
1029 p2 = variable_buffer + l;
1030 }
1031
1032 /* See if it's an "override" or "export" keyword; if so see if what
1033 comes after it looks like a variable definition. */
1034
1035 wtype = get_next_mword (p2, NULL, &p, &wlen);
1036
1037 v_origin = o_file;
1038 exported = 0;
1039 if (wtype == w_static)
1040 {
1041 if (word1eq ("override"))
1042 {
1043 v_origin = o_override;
1044 wtype = get_next_mword (p+wlen, NULL, &p, &wlen);
1045 }
1046 else if (word1eq ("export"))
1047 {
1048 exported = 1;
1049 wtype = get_next_mword (p+wlen, NULL, &p, &wlen);
1050 }
1051 }
1052
1053 if (wtype != w_eol)
1054 wtype = get_next_mword (p+wlen, NULL, NULL, NULL);
1055
1056 if (wtype == w_varassign)
1057 {
1058 /* If there was a semicolon found, add it back, plus anything
1059 after it. */
1060 if (semip)
1061 {
1062 unsigned int l = p - variable_buffer;
1063 *(--semip) = ';';
1064 variable_buffer_output (p2 + strlen (p2),
1065 semip, strlen (semip)+1);
1066 p = variable_buffer + l;
1067 }
1068 record_target_var (filenames, p, v_origin, exported, fstart);
1069 filenames = 0;
1070 continue;
1071 }
1072
1073 /* This is a normal target, _not_ a target-specific variable.
1074 Unquote any = in the dependency list. */
1075 find_char_unquote (lb_next, '=', 0, 0, 0);
1076
1077 /* We have some targets, so don't ignore the following commands. */
1078 no_targets = 0;
1079
1080 /* Expand the dependencies, etc. */
1081 if (*lb_next != '\0')
1082 {
1083 unsigned int l = p2 - variable_buffer;
1084 (void) variable_expand_string (p2 + plen, lb_next, (long)-1);
1085 p2 = variable_buffer + l;
1086
1087 /* Look for a semicolon in the expanded line. */
1088 if (cmdleft == 0)
1089 {
1090 cmdleft = find_char_unquote (p2, ';', 0, 0, 0);
1091 if (cmdleft != 0)
1092 *(cmdleft++) = '\0';
1093 }
1094 }
1095
1096 /* Is this a static pattern rule: `target: %targ: %dep; ...'? */
1097 p = strchr (p2, ':');
1098 while (p != 0 && p[-1] == '\\')
1099 {
1100 register char *q = &p[-1];
1101 register int backslash = 0;
1102 while (*q-- == '\\')
1103 backslash = !backslash;
1104 if (backslash)
1105 p = strchr (p + 1, ':');
1106 else
1107 break;
1108 }
1109#ifdef _AMIGA
1110 /* Here, the situation is quite complicated. Let's have a look
1111 at a couple of targets:
1112
1113 install: dev:make
1114
1115 dev:make: make
1116
1117 dev:make:: xyz
1118
1119 The rule is that it's only a target, if there are TWO :'s
1120 OR a space around the :.
1121 */
1122 if (p && !(isspace ((unsigned char)p[1]) || !p[1]
1123 || isspace ((unsigned char)p[-1])))
1124 p = 0;
1125#endif
1126#ifdef HAVE_DOS_PATHS
1127 {
1128 int check_again;
1129 do {
1130 check_again = 0;
1131 /* For DOS-style paths, skip a "C:\..." or a "C:/..." */
1132 if (p != 0 && (p[1] == '\\' || p[1] == '/') &&
1133 isalpha ((unsigned char)p[-1]) &&
1134 (p == p2 + 1 || strchr (" \t:(", p[-2]) != 0)) {
1135 p = strchr (p + 1, ':');
1136 check_again = 1;
1137 }
1138 } while (check_again);
1139 }
1140#endif
1141 if (p != 0)
1142 {
1143 struct nameseq *target;
1144 target = parse_file_seq (&p2, ':', sizeof (struct nameseq), 1);
1145 ++p2;
1146 if (target == 0)
1147 fatal (fstart, _("missing target pattern"));
1148 else if (target->next != 0)
1149 fatal (fstart, _("multiple target patterns"));
1150 pattern_percent = find_percent_cached (&target->name);
1151 pattern = target->name;
1152 if (pattern_percent == 0)
1153 fatal (fstart, _("target pattern contains no `%%'"));
1154 free (target);
1155 }
1156 else
1157 pattern = 0;
1158
1159 /* Strip leading and trailing whitespaces. */
1160 beg = p2;
1161 end = beg + strlen (beg) - 1;
1162 strip_whitespace (&beg, &end);
1163
1164 if (beg <= end && *beg != '\0')
1165 {
1166 /* Put all the prerequisites here; they'll be parsed later. */
1167 deps = alloc_dep ();
1168 deps->name = strcache_add_len (beg, end - beg + 1);
1169 }
1170 else
1171 deps = 0;
1172
1173 commands_idx = 0;
1174 if (cmdleft != 0)
1175 {
1176 /* Semicolon means rest of line is a command. */
1177 unsigned int l = strlen (cmdleft);
1178
1179 cmds_started = fstart->lineno;
1180
1181 /* Add this command line to the buffer. */
1182 if (l + 2 > commands_len)
1183 {
1184 commands_len = (l + 2) * 2;
1185 commands = xrealloc (commands, commands_len);
1186 }
1187 memcpy (commands, cmdleft, l);
1188 commands_idx += l;
1189 commands[commands_idx++] = '\n';
1190 }
1191
1192 /* Determine if this target should be made default. We used to do
1193 this in record_files() but because of the delayed target recording
1194 and because preprocessor directives are legal in target's commands
1195 it is too late. Consider this fragment for example:
1196
1197 foo:
1198
1199 ifeq ($(.DEFAULT_GOAL),foo)
1200 ...
1201 endif
1202
1203 Because the target is not recorded until after ifeq directive is
1204 evaluated the .DEFAULT_GOAL does not contain foo yet as one
1205 would expect. Because of this we have to move some of the logic
1206 here. */
1207
1208 if (**default_goal_name == '\0' && set_default)
1209 {
1210 const char *name;
1211 struct dep *d;
1212 struct nameseq *t = filenames;
1213
1214 for (; t != 0; t = t->next)
1215 {
1216 int reject = 0;
1217 name = t->name;
1218
1219 /* We have nothing to do if this is an implicit rule. */
1220 if (strchr (name, '%') != 0)
1221 break;
1222
1223 /* See if this target's name does not start with a `.',
1224 unless it contains a slash. */
1225 if (*name == '.' && strchr (name, '/') == 0
1226#ifdef HAVE_DOS_PATHS
1227 && strchr (name, '\\') == 0
1228#endif
1229 )
1230 continue;
1231
1232
1233 /* If this file is a suffix, don't let it be
1234 the default goal file. */
1235 for (d = suffix_file->deps; d != 0; d = d->next)
1236 {
1237 register struct dep *d2;
1238 if (*dep_name (d) != '.' && streq (name, dep_name (d)))
1239 {
1240 reject = 1;
1241 break;
1242 }
1243 for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
1244 {
1245 unsigned int l = strlen (dep_name (d2));
1246 if (!strneq (name, dep_name (d2), l))
1247 continue;
1248 if (streq (name + l, dep_name (d)))
1249 {
1250 reject = 1;
1251 break;
1252 }
1253 }
1254
1255 if (reject)
1256 break;
1257 }
1258
1259 if (!reject)
1260 {
1261 define_variable_global (".DEFAULT_GOAL", 13, t->name,
1262 o_file, 0, NILF);
1263 break;
1264 }
1265 }
1266 }
1267
1268 continue;
1269 }
1270
1271 /* We get here except in the case that we just read a rule line.
1272 Record now the last rule we read, so following spurious
1273 commands are properly diagnosed. */
1274 rule_complete:
1275 record_waiting_files ();
1276 }
1277
1278#undef word1eq
1279
1280 if (conditionals->if_cmds)
1281 fatal (fstart, _("missing `endif'"));
1282
1283 /* At eof, record the last rule. */
1284 record_waiting_files ();
1285
1286 if (collapsed)
1287 free (collapsed);
1288 free (commands);
1289
1290 return 1;
1291}
1292
1293
1294
1295/* Remove comments from LINE.
1296 This is done by copying the text at LINE onto itself. */
1297
1298static void
1299remove_comments (char *line)
1300{
1301 char *comment;
1302
1303 comment = find_char_unquote (line, '#', 0, 0, 0);
1304
1305 if (comment != 0)
1306 /* Cut off the line at the #. */
1307 *comment = '\0';
1308}
1309
1310/* Execute a `define' directive.
1311 The first line has already been read, and NAME is the name of
1312 the variable to be defined. The following lines remain to be read. */
1313
1314static void
1315do_define (char *name, unsigned int namelen,
1316 enum variable_origin origin, struct ebuffer *ebuf)
1317{
1318 struct floc defstart;
1319 long nlines = 0;
1320 int nlevels = 1;
1321 unsigned int length = 100;
1322 char *definition = xmalloc (length);
1323 unsigned int idx = 0;
1324 char *p;
1325
1326 /* Expand the variable name. */
1327 char *var = alloca (namelen + 1);
1328 memcpy (var, name, namelen);
1329 var[namelen] = '\0';
1330 var = variable_expand (var);
1331
1332 defstart = ebuf->floc;
1333
1334 while (1)
1335 {
1336 unsigned int len;
1337 char *line;
1338
1339 nlines = readline (ebuf);
1340 ebuf->floc.lineno += nlines;
1341
1342 /* If there is nothing left to eval, we're done. */
1343 if (nlines < 0)
1344 break;
1345
1346 line = ebuf->buffer;
1347
1348 collapse_continuations (line);
1349
1350 /* If the line doesn't begin with a tab, test to see if it introduces
1351 another define, or ends one. */
1352
1353 /* Stop if we find an 'endef' */
1354 if (line[0] != cmd_prefix)
1355 {
1356 p = next_token (line);
1357 len = strlen (p);
1358
1359 /* If this is another 'define', increment the level count. */
1360 if ((len == 6 || (len > 6 && isblank ((unsigned char)p[6])))
1361 && strneq (p, "define", 6))
1362 ++nlevels;
1363
1364 /* If this is an 'endef', decrement the count. If it's now 0,
1365 we've found the last one. */
1366 else if ((len == 5 || (len > 5 && isblank ((unsigned char)p[5])))
1367 && strneq (p, "endef", 5))
1368 {
1369 p += 5;
1370 remove_comments (p);
1371 if (*next_token (p) != '\0')
1372 error (&ebuf->floc,
1373 _("Extraneous text after `endef' directive"));
1374
1375 if (--nlevels == 0)
1376 {
1377 /* Define the variable. */
1378 if (idx == 0)
1379 definition[0] = '\0';
1380 else
1381 definition[idx - 1] = '\0';
1382
1383 /* Always define these variables in the global set. */
1384 define_variable_global (var, strlen (var), definition,
1385 origin, 1, &defstart);
1386 free (definition);
1387 return;
1388 }
1389 }
1390 }
1391
1392 /* Otherwise add this line to the variable definition. */
1393 len = strlen (line);
1394 if (idx + len + 1 > length)
1395 {
1396 length = (idx + len) * 2;
1397 definition = xrealloc (definition, length + 1);
1398 }
1399
1400 memcpy (&definition[idx], line, len);
1401 idx += len;
1402 /* Separate lines with a newline. */
1403 definition[idx++] = '\n';
1404 }
1405
1406 /* No `endef'!! */
1407 fatal (&defstart, _("missing `endef', unterminated `define'"));
1408
1409 /* NOTREACHED */
1410 return;
1411}
1412
1413
1414/* Interpret conditional commands "ifdef", "ifndef", "ifeq",
1415 "ifneq", "else" and "endif".
1416 LINE is the input line, with the command as its first word.
1417
1418 FILENAME and LINENO are the filename and line number in the
1419 current makefile. They are used for error messages.
1420
1421 Value is -2 if the line is not a conditional at all,
1422 -1 if the line is an invalid conditional,
1423 0 if following text should be interpreted,
1424 1 if following text should be ignored. */
1425
1426static int
1427conditional_line (char *line, int len, const struct floc *flocp)
1428{
1429 char *cmdname;
1430 enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype;
1431 unsigned int i;
1432 unsigned int o;
1433
1434 /* Compare a word, both length and contents. */
1435#define word1eq(s) (len == sizeof(s)-1 && strneq (s, line, sizeof(s)-1))
1436#define chkword(s, t) if (word1eq (s)) { cmdtype = (t); cmdname = (s); }
1437
1438 /* Make sure this line is a conditional. */
1439 chkword ("ifdef", c_ifdef)
1440 else chkword ("ifndef", c_ifndef)
1441 else chkword ("ifeq", c_ifeq)
1442 else chkword ("ifneq", c_ifneq)
1443 else chkword ("else", c_else)
1444 else chkword ("endif", c_endif)
1445 else
1446 return -2;
1447
1448 /* Found one: skip past it and any whitespace after it. */
1449 line = next_token (line + len);
1450
1451#define EXTRANEOUS() error (flocp, _("Extraneous text after `%s' directive"), cmdname)
1452
1453 /* An 'endif' cannot contain extra text, and reduces the if-depth by 1 */
1454 if (cmdtype == c_endif)
1455 {
1456 if (*line != '\0')
1457 EXTRANEOUS ();
1458
1459 if (!conditionals->if_cmds)
1460 fatal (flocp, _("extraneous `%s'"), cmdname);
1461
1462 --conditionals->if_cmds;
1463
1464 goto DONE;
1465 }
1466
1467 /* An 'else' statement can either be simple, or it can have another
1468 conditional after it. */
1469 if (cmdtype == c_else)
1470 {
1471 const char *p;
1472
1473 if (!conditionals->if_cmds)
1474 fatal (flocp, _("extraneous `%s'"), cmdname);
1475
1476 o = conditionals->if_cmds - 1;
1477
1478 if (conditionals->seen_else[o])
1479 fatal (flocp, _("only one `else' per conditional"));
1480
1481 /* Change the state of ignorance. */
1482 switch (conditionals->ignoring[o])
1483 {
1484 case 0:
1485 /* We've just been interpreting. Never do it again. */
1486 conditionals->ignoring[o] = 2;
1487 break;
1488 case 1:
1489 /* We've never interpreted yet. Maybe this time! */
1490 conditionals->ignoring[o] = 0;
1491 break;
1492 }
1493
1494 /* It's a simple 'else'. */
1495 if (*line == '\0')
1496 {
1497 conditionals->seen_else[o] = 1;
1498 goto DONE;
1499 }
1500
1501 /* The 'else' has extra text. That text must be another conditional
1502 and cannot be an 'else' or 'endif'. */
1503
1504 /* Find the length of the next word. */
1505 for (p = line+1; *p != '\0' && !isspace ((unsigned char)*p); ++p)
1506 ;
1507 len = p - line;
1508
1509 /* If it's 'else' or 'endif' or an illegal conditional, fail. */
1510 if (word1eq("else") || word1eq("endif")
1511 || conditional_line (line, len, flocp) < 0)
1512 EXTRANEOUS ();
1513 else
1514 {
1515 /* conditional_line() created a new level of conditional.
1516 Raise it back to this level. */
1517 if (conditionals->ignoring[o] < 2)
1518 conditionals->ignoring[o] = conditionals->ignoring[o+1];
1519 --conditionals->if_cmds;
1520 }
1521
1522 goto DONE;
1523 }
1524
1525 if (conditionals->allocated == 0)
1526 {
1527 conditionals->allocated = 5;
1528 conditionals->ignoring = xmalloc (conditionals->allocated);
1529 conditionals->seen_else = xmalloc (conditionals->allocated);
1530 }
1531
1532 o = conditionals->if_cmds++;
1533 if (conditionals->if_cmds > conditionals->allocated)
1534 {
1535 conditionals->allocated += 5;
1536 conditionals->ignoring = xrealloc (conditionals->ignoring,
1537 conditionals->allocated);
1538 conditionals->seen_else = xrealloc (conditionals->seen_else,
1539 conditionals->allocated);
1540 }
1541
1542 /* Record that we have seen an `if...' but no `else' so far. */
1543 conditionals->seen_else[o] = 0;
1544
1545 /* Search through the stack to see if we're already ignoring. */
1546 for (i = 0; i < o; ++i)
1547 if (conditionals->ignoring[i])
1548 {
1549 /* We are already ignoring, so just push a level to match the next
1550 "else" or "endif", and keep ignoring. We don't want to expand
1551 variables in the condition. */
1552 conditionals->ignoring[o] = 1;
1553 return 1;
1554 }
1555
1556 if (cmdtype == c_ifdef || cmdtype == c_ifndef)
1557 {
1558 char *var;
1559 struct variable *v;
1560 char *p;
1561
1562 /* Expand the thing we're looking up, so we can use indirect and
1563 constructed variable names. */
1564 var = allocated_variable_expand (line);
1565
1566 /* Make sure there's only one variable name to test. */
1567 p = end_of_token (var);
1568 i = p - var;
1569 p = next_token (p);
1570 if (*p != '\0')
1571 return -1;
1572
1573 var[i] = '\0';
1574 v = lookup_variable (var, i);
1575
1576 conditionals->ignoring[o] =
1577 ((v != 0 && *v->value != '\0') == (cmdtype == c_ifndef));
1578
1579 free (var);
1580 }
1581 else
1582 {
1583 /* "ifeq" or "ifneq". */
1584 char *s1, *s2;
1585 unsigned int l;
1586 char termin = *line == '(' ? ',' : *line;
1587
1588 if (termin != ',' && termin != '"' && termin != '\'')
1589 return -1;
1590
1591 s1 = ++line;
1592 /* Find the end of the first string. */
1593 if (termin == ',')
1594 {
1595 int count = 0;
1596 for (; *line != '\0'; ++line)
1597 if (*line == '(')
1598 ++count;
1599 else if (*line == ')')
1600 --count;
1601 else if (*line == ',' && count <= 0)
1602 break;
1603 }
1604 else
1605 while (*line != '\0' && *line != termin)
1606 ++line;
1607
1608 if (*line == '\0')
1609 return -1;
1610
1611 if (termin == ',')
1612 {
1613 /* Strip blanks after the first string. */
1614 char *p = line++;
1615 while (isblank ((unsigned char)p[-1]))
1616 --p;
1617 *p = '\0';
1618 }
1619 else
1620 *line++ = '\0';
1621
1622 s2 = variable_expand (s1);
1623 /* We must allocate a new copy of the expanded string because
1624 variable_expand re-uses the same buffer. */
1625 l = strlen (s2);
1626 s1 = alloca (l + 1);
1627 memcpy (s1, s2, l + 1);
1628
1629 if (termin != ',')
1630 /* Find the start of the second string. */
1631 line = next_token (line);
1632
1633 termin = termin == ',' ? ')' : *line;
1634 if (termin != ')' && termin != '"' && termin != '\'')
1635 return -1;
1636
1637 /* Find the end of the second string. */
1638 if (termin == ')')
1639 {
1640 int count = 0;
1641 s2 = next_token (line);
1642 for (line = s2; *line != '\0'; ++line)
1643 {
1644 if (*line == '(')
1645 ++count;
1646 else if (*line == ')')
1647 {
1648 if (count <= 0)
1649 break;
1650 else
1651 --count;
1652 }
1653 }
1654 }
1655 else
1656 {
1657 ++line;
1658 s2 = line;
1659 while (*line != '\0' && *line != termin)
1660 ++line;
1661 }
1662
1663 if (*line == '\0')
1664 return -1;
1665
1666 *line = '\0';
1667 line = next_token (++line);
1668 if (*line != '\0')
1669 EXTRANEOUS ();
1670
1671 s2 = variable_expand (s2);
1672 conditionals->ignoring[o] = (streq (s1, s2) == (cmdtype == c_ifneq));
1673 }
1674
1675 DONE:
1676 /* Search through the stack to see if we're ignoring. */
1677 for (i = 0; i < conditionals->if_cmds; ++i)
1678 if (conditionals->ignoring[i])
1679 return 1;
1680 return 0;
1681}
1682
1683
1684/* Remove duplicate dependencies in CHAIN. */
1685
1686static unsigned long
1687dep_hash_1 (const void *key)
1688{
1689 return_STRING_HASH_1 (dep_name ((struct dep const *) key));
1690}
1691
1692static unsigned long
1693dep_hash_2 (const void *key)
1694{
1695 return_STRING_HASH_2 (dep_name ((struct dep const *) key));
1696}
1697
1698static int
1699dep_hash_cmp (const void *x, const void *y)
1700{
1701 struct dep *dx = (struct dep *) x;
1702 struct dep *dy = (struct dep *) y;
1703 int cmp = strcmp (dep_name (dx), dep_name (dy));
1704
1705 /* If the names are the same but ignore_mtimes are not equal, one of these
1706 is an order-only prerequisite and one isn't. That means that we should
1707 remove the one that isn't and keep the one that is. */
1708
1709 if (!cmp && dx->ignore_mtime != dy->ignore_mtime)
1710 dx->ignore_mtime = dy->ignore_mtime = 0;
1711
1712 return cmp;
1713}
1714
1715
1716void
1717uniquize_deps (struct dep *chain)
1718{
1719 struct hash_table deps;
1720 register struct dep **depp;
1721
1722 hash_init (&deps, 500, dep_hash_1, dep_hash_2, dep_hash_cmp);
1723
1724 /* Make sure that no dependencies are repeated. This does not
1725 really matter for the purpose of updating targets, but it
1726 might make some names be listed twice for $^ and $?. */
1727
1728 depp = &chain;
1729 while (*depp)
1730 {
1731 struct dep *dep = *depp;
1732 struct dep **dep_slot = (struct dep **) hash_find_slot (&deps, dep);
1733 if (HASH_VACANT (*dep_slot))
1734 {
1735 hash_insert_at (&deps, dep, dep_slot);
1736 depp = &dep->next;
1737 }
1738 else
1739 {
1740 /* Don't bother freeing duplicates.
1741 It's dangerous and little benefit accrues. */
1742 *depp = dep->next;
1743 }
1744 }
1745
1746 hash_free (&deps, 0);
1747}
1748
1749
1750/* Record target-specific variable values for files FILENAMES.
1751 TWO_COLON is nonzero if a double colon was used.
1752
1753 The links of FILENAMES are freed, and so are any names in it
1754 that are not incorporated into other data structures.
1755
1756 If the target is a pattern, add the variable to the pattern-specific
1757 variable value list. */
1758
1759static void
1760record_target_var (struct nameseq *filenames, char *defn,
1761 enum variable_origin origin, int exported,
1762 const struct floc *flocp)
1763{
1764 struct nameseq *nextf;
1765 struct variable_set_list *global;
1766
1767 global = current_variable_set_list;
1768
1769 /* If the variable is an append version, store that but treat it as a
1770 normal recursive variable. */
1771
1772 for (; filenames != 0; filenames = nextf)
1773 {
1774 struct variable *v;
1775 const char *name = filenames->name;
1776 const char *fname;
1777 const char *percent;
1778 struct pattern_var *p;
1779
1780 nextf = filenames->next;
1781 free (filenames);
1782
1783 /* If it's a pattern target, then add it to the pattern-specific
1784 variable list. */
1785 percent = find_percent_cached (&name);
1786 if (percent)
1787 {
1788 /* Get a reference for this pattern-specific variable struct. */
1789 p = create_pattern_var (name, percent);
1790 p->variable.fileinfo = *flocp;
1791 /* I don't think this can fail since we already determined it was a
1792 variable definition. */
1793 v = parse_variable_definition (&p->variable, defn);
1794 assert (v != 0);
1795
1796 if (v->flavor == f_simple)
1797 v->value = allocated_variable_expand (v->value);
1798 else
1799 v->value = xstrdup (v->value);
1800
1801 fname = p->target;
1802 }
1803 else
1804 {
1805 struct file *f;
1806
1807 /* Get a file reference for this file, and initialize it.
1808 We don't want to just call enter_file() because that allocates a
1809 new entry if the file is a double-colon, which we don't want in
1810 this situation. */
1811 f = lookup_file (name);
1812 if (!f)
1813 f = enter_file (strcache_add (name));
1814 else if (f->double_colon)
1815 f = f->double_colon;
1816
1817 initialize_file_variables (f, 1);
1818 fname = f->name;
1819
1820 current_variable_set_list = f->variables;
1821 v = try_variable_definition (flocp, defn, origin, 1);
1822 if (!v)
1823 error (flocp, _("Malformed target-specific variable definition"));
1824 current_variable_set_list = global;
1825 }
1826
1827 /* Set up the variable to be *-specific. */
1828 v->origin = origin;
1829 v->per_target = 1;
1830 v->export = exported ? v_export : v_default;
1831
1832 /* If it's not an override, check to see if there was a command-line
1833 setting. If so, reset the value. */
1834 if (origin != o_override)
1835 {
1836 struct variable *gv;
1837 int len = strlen(v->name);
1838
1839 gv = lookup_variable (v->name, len);
1840 if (gv && (gv->origin == o_env_override || gv->origin == o_command))
1841 {
1842 if (v->value != 0)
1843 free (v->value);
1844 v->value = xstrdup (gv->value);
1845 v->origin = gv->origin;
1846 v->recursive = gv->recursive;
1847 v->append = 0;
1848 }
1849 }
1850 }
1851}
1852
1853
1854/* Record a description line for files FILENAMES,
1855 with dependencies DEPS, commands to execute described
1856 by COMMANDS and COMMANDS_IDX, coming from FILENAME:COMMANDS_STARTED.
1857 TWO_COLON is nonzero if a double colon was used.
1858 If not nil, PATTERN is the `%' pattern to make this
1859 a static pattern rule, and PATTERN_PERCENT is a pointer
1860 to the `%' within it.
1861
1862 The links of FILENAMES are freed, and so are any names in it
1863 that are not incorporated into other data structures. */
1864
1865static void
1866record_files (struct nameseq *filenames, const char *pattern,
1867 const char *pattern_percent, struct dep *deps,
1868 unsigned int cmds_started, char *commands,
1869 unsigned int commands_idx, int two_colon,
1870 const struct floc *flocp)
1871{
1872 struct nameseq *nextf;
1873 int implicit = 0;
1874 unsigned int max_targets = 0, target_idx = 0;
1875 const char **targets = 0, **target_percents = 0;
1876 struct commands *cmds;
1877
1878 /* If we've already snapped deps, that means we're in an eval being
1879 resolved after the makefiles have been read in. We can't add more rules
1880 at this time, since they won't get snapped and we'll get core dumps.
1881 See Savannah bug # 12124. */
1882 if (snapped_deps)
1883 fatal (flocp, _("prerequisites cannot be defined in command scripts"));
1884
1885 if (commands_idx > 0)
1886 {
1887 cmds = xmalloc (sizeof (struct commands));
1888 cmds->fileinfo.filenm = flocp->filenm;
1889 cmds->fileinfo.lineno = cmds_started;
1890 cmds->commands = savestring (commands, commands_idx);
1891 cmds->command_lines = 0;
1892 }
1893 else
1894 cmds = 0;
1895
1896 for (; filenames != 0; filenames = nextf)
1897 {
1898 const char *name = filenames->name;
1899 struct file *f;
1900 struct dep *this = 0;
1901 const char *implicit_percent;
1902
1903 nextf = filenames->next;
1904 free (filenames);
1905
1906 /* Check for special targets. Do it here instead of, say, snap_deps()
1907 so that we can immediately use the value. */
1908
1909 if (streq (name, ".POSIX"))
1910 posix_pedantic = 1;
1911 else if (streq (name, ".SECONDEXPANSION"))
1912 second_expansion = 1;
1913
1914 implicit_percent = find_percent_cached (&name);
1915 implicit |= implicit_percent != 0;
1916
1917 if (implicit)
1918 {
1919 if (pattern != 0)
1920 fatal (flocp, _("mixed implicit and static pattern rules"));
1921
1922 if (implicit_percent == 0)
1923 fatal (flocp, _("mixed implicit and normal rules"));
1924
1925 if (targets == 0)
1926 {
1927 max_targets = 5;
1928 targets = xmalloc (5 * sizeof (char *));
1929 target_percents = xmalloc (5 * sizeof (char *));
1930 target_idx = 0;
1931 }
1932 else if (target_idx == max_targets - 1)
1933 {
1934 max_targets += 5;
1935 targets = xrealloc (targets, max_targets * sizeof (char *));
1936 target_percents = xrealloc (target_percents,
1937 max_targets * sizeof (char *));
1938 }
1939 targets[target_idx] = name;
1940 target_percents[target_idx] = implicit_percent;
1941 ++target_idx;
1942 continue;
1943 }
1944
1945 /* If this is a static pattern rule:
1946 `targets: target%pattern: dep%pattern; cmds',
1947 make sure the pattern matches this target name. */
1948 if (pattern && !pattern_matches (pattern, pattern_percent, name))
1949 error (flocp, _("target `%s' doesn't match the target pattern"), name);
1950 else if (deps)
1951 {
1952 /* If there are multiple filenames, copy the chain DEPS for all but
1953 the last one. It is not safe for the same deps to go in more
1954 than one place in the database. */
1955 this = nextf != 0 ? copy_dep_chain (deps) : deps;
1956 this->need_2nd_expansion = (second_expansion
1957 && strchr (this->name, '$'));
1958 }
1959
1960 if (!two_colon)
1961 {
1962 /* Single-colon. Combine these dependencies
1963 with others in file's existing record, if any. */
1964 f = enter_file (strcache_add (name));
1965
1966 if (f->double_colon)
1967 fatal (flocp,
1968 _("target file `%s' has both : and :: entries"), f->name);
1969
1970 /* If CMDS == F->CMDS, this target was listed in this rule
1971 more than once. Just give a warning since this is harmless. */
1972 if (cmds != 0 && cmds == f->cmds)
1973 error (flocp,
1974 _("target `%s' given more than once in the same rule."),
1975 f->name);
1976
1977 /* Check for two single-colon entries both with commands.
1978 Check is_target so that we don't lose on files such as .c.o
1979 whose commands were preinitialized. */
1980 else if (cmds != 0 && f->cmds != 0 && f->is_target)
1981 {
1982 error (&cmds->fileinfo,
1983 _("warning: overriding commands for target `%s'"),
1984 f->name);
1985 error (&f->cmds->fileinfo,
1986 _("warning: ignoring old commands for target `%s'"),
1987 f->name);
1988 }
1989
1990 f->is_target = 1;
1991
1992 /* Defining .DEFAULT with no deps or cmds clears it. */
1993 if (f == default_file && this == 0 && cmds == 0)
1994 f->cmds = 0;
1995 if (cmds != 0)
1996 f->cmds = cmds;
1997
1998 /* Defining .SUFFIXES with no dependencies clears out the list of
1999 suffixes. */
2000 if (f == suffix_file && this == 0)
2001 {
2002 free_dep_chain (f->deps);
2003 f->deps = 0;
2004 }
2005 else if (this != 0)
2006 {
2007 /* Add the file's old deps and the new ones in THIS together. */
2008
2009 if (f->deps != 0)
2010 {
2011 struct dep **d_ptr = &f->deps;
2012
2013 while ((*d_ptr)->next != 0)
2014 d_ptr = &(*d_ptr)->next;
2015
2016 if (cmds != 0)
2017 /* This is the rule with commands, so put its deps
2018 last. The rationale behind this is that $< expands to
2019 the first dep in the chain, and commands use $<
2020 expecting to get the dep that rule specifies. However
2021 the second expansion algorithm reverses the order thus
2022 we need to make it last here. */
2023 (*d_ptr)->next = this;
2024 else
2025 {
2026 /* This is the rule without commands. Put its
2027 dependencies at the end but before dependencies from
2028 the rule with commands (if any). This way everything
2029 appears in makefile order. */
2030
2031 if (f->cmds != 0)
2032 {
2033 this->next = *d_ptr;
2034 *d_ptr = this;
2035 }
2036 else
2037 (*d_ptr)->next = this;
2038 }
2039 }
2040 else
2041 f->deps = this;
2042
2043 /* This is a hack. I need a way to communicate to snap_deps()
2044 that the last dependency line in this file came with commands
2045 (so that logic in snap_deps() can put it in front and all
2046 this $< -logic works). I cannot simply rely on file->cmds
2047 being not 0 because of the cases like the following:
2048
2049 foo: bar
2050 foo:
2051 ...
2052
2053 I am going to temporarily "borrow" UPDATING member in
2054 `struct file' for this. */
2055
2056 if (cmds != 0)
2057 f->updating = 1;
2058 }
2059 }
2060 else
2061 {
2062 /* Double-colon. Make a new record even if there already is one. */
2063 f = lookup_file (name);
2064
2065 /* Check for both : and :: rules. Check is_target so
2066 we don't lose on default suffix rules or makefiles. */
2067 if (f != 0 && f->is_target && !f->double_colon)
2068 fatal (flocp,
2069 _("target file `%s' has both : and :: entries"), f->name);
2070 f = enter_file (strcache_add (name));
2071 /* If there was an existing entry and it was a double-colon entry,
2072 enter_file will have returned a new one, making it the prev
2073 pointer of the old one, and setting its double_colon pointer to
2074 the first one. */
2075 if (f->double_colon == 0)
2076 /* This is the first entry for this name, so we must set its
2077 double_colon pointer to itself. */
2078 f->double_colon = f;
2079 f->is_target = 1;
2080 f->deps = this;
2081 f->cmds = cmds;
2082 }
2083
2084 /* If this is a static pattern rule, set the stem to the part of its
2085 name that matched the `%' in the pattern, so you can use $* in the
2086 commands. */
2087 if (pattern)
2088 {
2089 static const char *percent = "%";
2090 char *buffer = variable_expand ("");
2091 char *o = patsubst_expand_pat (buffer, name, pattern, percent,
2092 pattern_percent+1, percent+1);
2093 f->stem = strcache_add_len (buffer, o - buffer);
2094 if (this)
2095 {
2096 this->staticpattern = 1;
2097 this->stem = f->stem;
2098 }
2099 }
2100
2101 name = f->name;
2102
2103 /* If this target is a default target, update DEFAULT_GOAL_FILE. */
2104 if (streq (*default_goal_name, name)
2105 && (default_goal_file == 0
2106 || ! streq (default_goal_file->name, name)))
2107 default_goal_file = f;
2108 }
2109
2110 if (implicit)
2111 {
2112 if (deps)
2113 deps->need_2nd_expansion = second_expansion;
2114 create_pattern_rule (targets, target_percents, target_idx,
2115 two_colon, deps, cmds, 1);
2116 }
2117}
2118
2119
2120/* Search STRING for an unquoted STOPCHAR or blank (if BLANK is nonzero).
2121 Backslashes quote STOPCHAR, blanks if BLANK is nonzero, and backslash.
2122 Quoting backslashes are removed from STRING by compacting it into
2123 itself. Returns a pointer to the first unquoted STOPCHAR if there is
2124 one, or nil if there are none. STOPCHARs inside variable references are
2125 ignored if IGNOREVARS is true.
2126
2127 STOPCHAR _cannot_ be '$' if IGNOREVARS is true. */
2128
2129static char *
2130find_char_unquote (char *string, int stop1, int stop2, int blank,
2131 int ignorevars)
2132{
2133 unsigned int string_len = 0;
2134 char *p = string;
2135
2136 if (ignorevars)
2137 ignorevars = '$';
2138
2139 while (1)
2140 {
2141 if (stop2 && blank)
2142 while (*p != '\0' && *p != ignorevars && *p != stop1 && *p != stop2
2143 && ! isblank ((unsigned char) *p))
2144 ++p;
2145 else if (stop2)
2146 while (*p != '\0' && *p != ignorevars && *p != stop1 && *p != stop2)
2147 ++p;
2148 else if (blank)
2149 while (*p != '\0' && *p != ignorevars && *p != stop1
2150 && ! isblank ((unsigned char) *p))
2151 ++p;
2152 else
2153 while (*p != '\0' && *p != ignorevars && *p != stop1)
2154 ++p;
2155
2156 if (*p == '\0')
2157 break;
2158
2159 /* If we stopped due to a variable reference, skip over its contents. */
2160 if (*p == ignorevars)
2161 {
2162 char openparen = p[1];
2163
2164 p += 2;
2165
2166 /* Skip the contents of a non-quoted, multi-char variable ref. */
2167 if (openparen == '(' || openparen == '{')
2168 {
2169 unsigned int pcount = 1;
2170 char closeparen = (openparen == '(' ? ')' : '}');
2171
2172 while (*p)
2173 {
2174 if (*p == openparen)
2175 ++pcount;
2176 else if (*p == closeparen)
2177 if (--pcount == 0)
2178 {
2179 ++p;
2180 break;
2181 }
2182 ++p;
2183 }
2184 }
2185
2186 /* Skipped the variable reference: look for STOPCHARS again. */
2187 continue;
2188 }
2189
2190 if (p > string && p[-1] == '\\')
2191 {
2192 /* Search for more backslashes. */
2193 int i = -2;
2194 while (&p[i] >= string && p[i] == '\\')
2195 --i;
2196 ++i;
2197 /* Only compute the length if really needed. */
2198 if (string_len == 0)
2199 string_len = strlen (string);
2200 /* The number of backslashes is now -I.
2201 Copy P over itself to swallow half of them. */
2202 memmove (&p[i], &p[i/2], (string_len - (p - string)) - (i/2) + 1);
2203 p += i/2;
2204 if (i % 2 == 0)
2205 /* All the backslashes quoted each other; the STOPCHAR was
2206 unquoted. */
2207 return p;
2208
2209 /* The STOPCHAR was quoted by a backslash. Look for another. */
2210 }
2211 else
2212 /* No backslash in sight. */
2213 return p;
2214 }
2215
2216 /* Never hit a STOPCHAR or blank (with BLANK nonzero). */
2217 return 0;
2218}
2219
2220/* Search PATTERN for an unquoted % and handle quoting. */
2221
2222char *
2223find_percent (char *pattern)
2224{
2225 return find_char_unquote (pattern, '%', 0, 0, 0);
2226}
2227
2228/* Search STRING for an unquoted % and handle quoting. Returns a pointer to
2229 the % or NULL if no % was found.
2230 This version is used with strings in the string cache: if there's a need to
2231 modify the string a new version will be added to the string cache and
2232 *STRING will be set to that. */
2233
2234const char *
2235find_percent_cached (const char **string)
2236{
2237 const char *p = *string;
2238 char *new = 0;
2239 int slen;
2240
2241 /* If the first char is a % return now. This lets us avoid extra tests
2242 inside the loop. */
2243 if (*p == '%')
2244 return p;
2245
2246 while (1)
2247 {
2248 while (*p != '\0' && *p != '%')
2249 ++p;
2250
2251 if (*p == '\0')
2252 break;
2253
2254 /* See if this % is escaped with a backslash; if not we're done. */
2255 if (p[-1] != '\\')
2256 break;
2257
2258 {
2259 /* Search for more backslashes. */
2260 char *pv;
2261 int i = -2;
2262
2263 while (&p[i] >= *string && p[i] == '\\')
2264 --i;
2265 ++i;
2266
2267 /* At this point we know we'll need to allocate a new string.
2268 Make a copy if we haven't yet done so. */
2269 if (! new)
2270 {
2271 slen = strlen (*string);
2272 new = alloca (slen + 1);
2273 memcpy (new, *string, slen + 1);
2274 p = new + (p - *string);
2275 *string = new;
2276 }
2277
2278 /* At this point *string, p, and new all point into the same string.
2279 Get a non-const version of p so we can modify new. */
2280 pv = new + (p - *string);
2281
2282 /* The number of backslashes is now -I.
2283 Copy P over itself to swallow half of them. */
2284 memmove (&pv[i], &pv[i/2], (slen - (pv - new)) - (i/2) + 1);
2285 p += i/2;
2286
2287 /* If the backslashes quoted each other; the % was unquoted. */
2288 if (i % 2 == 0)
2289 break;
2290 }
2291 }
2292
2293 /* If we had to change STRING, add it to the strcache. */
2294 if (new)
2295 {
2296 *string = strcache_add (*string);
2297 p = *string + (p - new);
2298 }
2299
2300 /* If we didn't find a %, return NULL. Otherwise return a ptr to it. */
2301 return (*p == '\0') ? NULL : p;
2302}
2303
2304
2305/* Parse a string into a sequence of filenames represented as a
2306 chain of struct nameseq's in reverse order and return that chain.
2307
2308 The string is passed as STRINGP, the address of a string pointer.
2309 The string pointer is updated to point at the first character
2310 not parsed, which either is a null char or equals STOPCHAR.
2311
2312 SIZE is how big to construct chain elements.
2313 This is useful if we want them actually to be other structures
2314 that have room for additional info.
2315
2316 If STRIP is nonzero, strip `./'s off the beginning. */
2317
2318struct nameseq *
2319parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip)
2320{
2321 struct nameseq *new = 0;
2322 struct nameseq *new1, *lastnew1;
2323 char *p = *stringp;
2324
2325#ifdef VMS
2326# define VMS_COMMA ','
2327#else
2328# define VMS_COMMA 0
2329#endif
2330
2331 while (1)
2332 {
2333 const char *name;
2334 char *q;
2335
2336 /* Skip whitespace; see if any more names are left. */
2337 p = next_token (p);
2338 if (*p == '\0')
2339 break;
2340 if (*p == stopchar)
2341 break;
2342
2343 /* There are, so find the end of the next name. */
2344 q = p;
2345 p = find_char_unquote (q, stopchar, VMS_COMMA, 1, 0);
2346#ifdef VMS
2347 /* convert comma separated list to space separated */
2348 if (p && *p == ',')
2349 *p =' ';
2350#endif
2351#ifdef _AMIGA
2352 if (stopchar == ':' && p && *p == ':'
2353 && !(isspace ((unsigned char)p[1]) || !p[1]
2354 || isspace ((unsigned char)p[-1])))
2355 p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0);
2356#endif
2357#ifdef HAVE_DOS_PATHS
2358 /* For DOS paths, skip a "C:\..." or a "C:/..." until we find the
2359 first colon which isn't followed by a slash or a backslash.
2360 Note that tokens separated by spaces should be treated as separate
2361 tokens since make doesn't allow path names with spaces */
2362 if (stopchar == ':')
2363 while (p != 0 && !isspace ((unsigned char)*p) &&
2364 (p[1] == '\\' || p[1] == '/') && isalpha ((unsigned char)p[-1]))
2365 p = find_char_unquote (p + 1, stopchar, VMS_COMMA, 1, 0);
2366#endif
2367 if (p == 0)
2368 p = q + strlen (q);
2369
2370 if (strip)
2371#ifdef VMS
2372 /* Skip leading `[]'s. */
2373 while (p - q > 2 && q[0] == '[' && q[1] == ']')
2374#else
2375 /* Skip leading `./'s. */
2376 while (p - q > 2 && q[0] == '.' && q[1] == '/')
2377#endif
2378 {
2379 q += 2; /* Skip "./". */
2380 while (q < p && *q == '/')
2381 /* Skip following slashes: ".//foo" is "foo", not "/foo". */
2382 ++q;
2383 }
2384
2385 /* Extract the filename just found, and skip it. */
2386
2387 if (q == p)
2388 /* ".///" was stripped to "". */
2389#if defined(VMS)
2390 continue;
2391#elif defined(_AMIGA)
2392 name = "";
2393#else
2394 name = "./";
2395#endif
2396 else
2397#ifdef VMS
2398/* VMS filenames can have a ':' in them but they have to be '\'ed but we need
2399 * to remove this '\' before we can use the filename.
2400 * Savestring called because q may be read-only string constant.
2401 */
2402 {
2403 char *qbase = xstrdup (q);
2404 char *pbase = qbase + (p-q);
2405 char *q1 = qbase;
2406 char *q2 = q1;
2407 char *p1 = pbase;
2408
2409 while (q1 != pbase)
2410 {
2411 if (*q1 == '\\' && *(q1+1) == ':')
2412 {
2413 q1++;
2414 p1--;
2415 }
2416 *q2++ = *q1++;
2417 }
2418 name = strcache_add_len (qbase, p1 - qbase);
2419 free (qbase);
2420 }
2421#else
2422 name = strcache_add_len (q, p - q);
2423#endif
2424
2425 /* Add it to the front of the chain. */
2426 new1 = xmalloc (size);
2427 new1->name = name;
2428 new1->next = new;
2429 new = new1;
2430 }
2431
2432#ifndef NO_ARCHIVES
2433
2434 /* Look for multi-word archive references.
2435 They are indicated by a elt ending with an unmatched `)' and
2436 an elt further down the chain (i.e., previous in the file list)
2437 with an unmatched `(' (e.g., "lib(mem"). */
2438
2439 new1 = new;
2440 lastnew1 = 0;
2441 while (new1 != 0)
2442 if (new1->name[0] != '(' /* Don't catch "(%)" and suchlike. */
2443 && new1->name[strlen (new1->name) - 1] == ')'
2444 && strchr (new1->name, '(') == 0)
2445 {
2446 /* NEW1 ends with a `)' but does not contain a `('.
2447 Look back for an elt with an opening `(' but no closing `)'. */
2448
2449 struct nameseq *n = new1->next, *lastn = new1;
2450 char *paren = 0;
2451 while (n != 0 && (paren = strchr (n->name, '(')) == 0)
2452 {
2453 lastn = n;
2454 n = n->next;
2455 }
2456 if (n != 0
2457 /* Ignore something starting with `(', as that cannot actually
2458 be an archive-member reference (and treating it as such
2459 results in an empty file name, which causes much lossage). */
2460 && n->name[0] != '(')
2461 {
2462 /* N is the first element in the archive group.
2463 Its name looks like "lib(mem" (with no closing `)'). */
2464
2465 char *libname;
2466
2467 /* Copy "lib(" into LIBNAME. */
2468 ++paren;
2469 libname = alloca (paren - n->name + 1);
2470 memcpy (libname, n->name, paren - n->name);
2471 libname[paren - n->name] = '\0';
2472
2473 if (*paren == '\0')
2474 {
2475 /* N was just "lib(", part of something like "lib( a b)".
2476 Edit it out of the chain and free its storage. */
2477 lastn->next = n->next;
2478 free (n);
2479 /* LASTN->next is the new stopping elt for the loop below. */
2480 n = lastn->next;
2481 }
2482 else
2483 {
2484 /* Replace N's name with the full archive reference. */
2485 n->name = strcache_add (concat (libname, paren, ")"));
2486 }
2487
2488 if (new1->name[1] == '\0')
2489 {
2490 /* NEW1 is just ")", part of something like "lib(a b )".
2491 Omit it from the chain and free its storage. */
2492 if (lastnew1 == 0)
2493 new = new1->next;
2494 else
2495 lastnew1->next = new1->next;
2496 lastn = new1;
2497 new1 = new1->next;
2498 free (lastn);
2499 }
2500 else
2501 {
2502 /* Replace also NEW1->name, which already has closing `)'. */
2503 new1->name = strcache_add (concat (libname, new1->name, ""));
2504 new1 = new1->next;
2505 }
2506
2507 /* Trace back from NEW1 (the end of the list) until N
2508 (the beginning of the list), rewriting each name
2509 with the full archive reference. */
2510
2511 while (new1 != n)
2512 {
2513 new1->name = strcache_add (concat (libname, new1->name, ")"));
2514 lastnew1 = new1;
2515 new1 = new1->next;
2516 }
2517 }
2518 else
2519 {
2520 /* No frobnication happening. Just step down the list. */
2521 lastnew1 = new1;
2522 new1 = new1->next;
2523 }
2524 }
2525 else
2526 {
2527 lastnew1 = new1;
2528 new1 = new1->next;
2529 }
2530
2531#endif
2532
2533 *stringp = p;
2534 return new;
2535}
2536
2537
2538/* Find the next line of text in an eval buffer, combining continuation lines
2539 into one line.
2540 Return the number of actual lines read (> 1 if continuation lines).
2541 Returns -1 if there's nothing left in the buffer.
2542
2543 After this function, ebuf->buffer points to the first character of the
2544 line we just found.
2545 */
2546
2547/* Read a line of text from a STRING.
2548 Since we aren't really reading from a file, don't bother with linenumbers.
2549 */
2550
2551static unsigned long
2552readstring (struct ebuffer *ebuf)
2553{
2554 char *eol;
2555
2556 /* If there is nothing left in this buffer, return 0. */
2557 if (ebuf->bufnext >= ebuf->bufstart + ebuf->size)
2558 return -1;
2559
2560 /* Set up a new starting point for the buffer, and find the end of the
2561 next logical line (taking into account backslash/newline pairs). */
2562
2563 eol = ebuf->buffer = ebuf->bufnext;
2564
2565 while (1)
2566 {
2567 int backslash = 0;
2568 char *bol = eol;
2569 char *p;
2570
2571 /* Find the next newline. At EOS, stop. */
2572 eol = p = strchr (eol , '\n');
2573 if (!eol)
2574 {
2575 ebuf->bufnext = ebuf->bufstart + ebuf->size + 1;
2576 return 0;
2577 }
2578
2579 /* Found a newline; if it's escaped continue; else we're done. */
2580 while (p > bol && *(--p) == '\\')
2581 backslash = !backslash;
2582 if (!backslash)
2583 break;
2584 ++eol;
2585 }
2586
2587 /* Overwrite the newline char. */
2588 *eol = '\0';
2589 ebuf->bufnext = eol+1;
2590
2591 return 0;
2592}
2593
2594static long
2595readline (struct ebuffer *ebuf)
2596{
2597 char *p;
2598 char *end;
2599 char *start;
2600 long nlines = 0;
2601
2602 /* The behaviors between string and stream buffers are different enough to
2603 warrant different functions. Do the Right Thing. */
2604
2605 if (!ebuf->fp)
2606 return readstring (ebuf);
2607
2608 /* When reading from a file, we always start over at the beginning of the
2609 buffer for each new line. */
2610
2611 p = start = ebuf->bufstart;
2612 end = p + ebuf->size;
2613 *p = '\0';
2614
2615 while (fgets (p, end - p, ebuf->fp) != 0)
2616 {
2617 char *p2;
2618 unsigned long len;
2619 int backslash;
2620
2621 len = strlen (p);
2622 if (len == 0)
2623 {
2624 /* This only happens when the first thing on the line is a '\0'.
2625 It is a pretty hopeless case, but (wonder of wonders) Athena
2626 lossage strikes again! (xmkmf puts NULs in its makefiles.)
2627 There is nothing really to be done; we synthesize a newline so
2628 the following line doesn't appear to be part of this line. */
2629 error (&ebuf->floc,
2630 _("warning: NUL character seen; rest of line ignored"));
2631 p[0] = '\n';
2632 len = 1;
2633 }
2634
2635 /* Jump past the text we just read. */
2636 p += len;
2637
2638 /* If the last char isn't a newline, the whole line didn't fit into the
2639 buffer. Get some more buffer and try again. */
2640 if (p[-1] != '\n')
2641 goto more_buffer;
2642
2643 /* We got a newline, so add one to the count of lines. */
2644 ++nlines;
2645
2646#if !defined(WINDOWS32) && !defined(__MSDOS__) && !defined(__EMX__)
2647 /* Check to see if the line was really ended with CRLF; if so ignore
2648 the CR. */
2649 if ((p - start) > 1 && p[-2] == '\r')
2650 {
2651 --p;
2652 p[-1] = '\n';
2653 }
2654#endif
2655
2656 backslash = 0;
2657 for (p2 = p - 2; p2 >= start; --p2)
2658 {
2659 if (*p2 != '\\')
2660 break;
2661 backslash = !backslash;
2662 }
2663
2664 if (!backslash)
2665 {
2666 p[-1] = '\0';
2667 break;
2668 }
2669
2670 /* It was a backslash/newline combo. If we have more space, read
2671 another line. */
2672 if (end - p >= 80)
2673 continue;
2674
2675 /* We need more space at the end of our buffer, so realloc it.
2676 Make sure to preserve the current offset of p. */
2677 more_buffer:
2678 {
2679 unsigned long off = p - start;
2680 ebuf->size *= 2;
2681 start = ebuf->buffer = ebuf->bufstart = xrealloc (start, ebuf->size);
2682 p = start + off;
2683 end = start + ebuf->size;
2684 *p = '\0';
2685 }
2686 }
2687
2688 if (ferror (ebuf->fp))
2689 pfatal_with_name (ebuf->floc.filenm);
2690
2691 /* If we found some lines, return how many.
2692 If we didn't, but we did find _something_, that indicates we read the last
2693 line of a file with no final newline; return 1.
2694 If we read nothing, we're at EOF; return -1. */
2695
2696 return nlines ? nlines : p == ebuf->bufstart ? -1 : 1;
2697}
2698
2699
2700/* Parse the next "makefile word" from the input buffer, and return info
2701 about it.
2702
2703 A "makefile word" is one of:
2704
2705 w_bogus Should never happen
2706 w_eol End of input
2707 w_static A static word; cannot be expanded
2708 w_variable A word containing one or more variables/functions
2709 w_colon A colon
2710 w_dcolon A double-colon
2711 w_semicolon A semicolon
2712 w_varassign A variable assignment operator (=, :=, +=, or ?=)
2713
2714 Note that this function is only used when reading certain parts of the
2715 makefile. Don't use it where special rules hold sway (RHS of a variable,
2716 in a command list, etc.) */
2717
2718static enum make_word_type
2719get_next_mword (char *buffer, char *delim, char **startp, unsigned int *length)
2720{
2721 enum make_word_type wtype = w_bogus;
2722 char *p = buffer, *beg;
2723 char c;
2724
2725 /* Skip any leading whitespace. */
2726 while (isblank ((unsigned char)*p))
2727 ++p;
2728
2729 beg = p;
2730 c = *(p++);
2731 switch (c)
2732 {
2733 case '\0':
2734 wtype = w_eol;
2735 break;
2736
2737 case ';':
2738 wtype = w_semicolon;
2739 break;
2740
2741 case '=':
2742 wtype = w_varassign;
2743 break;
2744
2745 case ':':
2746 wtype = w_colon;
2747 switch (*p)
2748 {
2749 case ':':
2750 ++p;
2751 wtype = w_dcolon;
2752 break;
2753
2754 case '=':
2755 ++p;
2756 wtype = w_varassign;
2757 break;
2758 }
2759 break;
2760
2761 case '+':
2762 case '?':
2763 if (*p == '=')
2764 {
2765 ++p;
2766 wtype = w_varassign;
2767 break;
2768 }
2769
2770 default:
2771 if (delim && strchr (delim, c))
2772 wtype = w_static;
2773 break;
2774 }
2775
2776 /* Did we find something? If so, return now. */
2777 if (wtype != w_bogus)
2778 goto done;
2779
2780 /* This is some non-operator word. A word consists of the longest
2781 string of characters that doesn't contain whitespace, one of [:=#],
2782 or [?+]=, or one of the chars in the DELIM string. */
2783
2784 /* We start out assuming a static word; if we see a variable we'll
2785 adjust our assumptions then. */
2786 wtype = w_static;
2787
2788 /* We already found the first value of "c", above. */
2789 while (1)
2790 {
2791 char closeparen;
2792 int count;
2793
2794 switch (c)
2795 {
2796 case '\0':
2797 case ' ':
2798 case '\t':
2799 case '=':
2800 goto done_word;
2801
2802 case ':':
2803#ifdef HAVE_DOS_PATHS
2804 /* A word CAN include a colon in its drive spec. The drive
2805 spec is allowed either at the beginning of a word, or as part
2806 of the archive member name, like in "libfoo.a(d:/foo/bar.o)". */
2807 if (!(p - beg >= 2
2808 && (*p == '/' || *p == '\\') && isalpha ((unsigned char)p[-2])
2809 && (p - beg == 2 || p[-3] == '(')))
2810#endif
2811 goto done_word;
2812
2813 case '$':
2814 c = *(p++);
2815 if (c == '$')
2816 break;
2817
2818 /* This is a variable reference, so note that it's expandable.
2819 Then read it to the matching close paren. */
2820 wtype = w_variable;
2821
2822 if (c == '(')
2823 closeparen = ')';
2824 else if (c == '{')
2825 closeparen = '}';
2826 else
2827 /* This is a single-letter variable reference. */
2828 break;
2829
2830 for (count=0; *p != '\0'; ++p)
2831 {
2832 if (*p == c)
2833 ++count;
2834 else if (*p == closeparen && --count < 0)
2835 {
2836 ++p;
2837 break;
2838 }
2839 }
2840 break;
2841
2842 case '?':
2843 case '+':
2844 if (*p == '=')
2845 goto done_word;
2846 break;
2847
2848 case '\\':
2849 switch (*p)
2850 {
2851 case ':':
2852 case ';':
2853 case '=':
2854 case '\\':
2855 ++p;
2856 break;
2857 }
2858 break;
2859
2860 default:
2861 if (delim && strchr (delim, c))
2862 goto done_word;
2863 break;
2864 }
2865
2866 c = *(p++);
2867 }
2868 done_word:
2869 --p;
2870
2871 done:
2872 if (startp)
2873 *startp = beg;
2874 if (length)
2875 *length = p - beg;
2876 return wtype;
2877}
2878
2879
2880/* Construct the list of include directories
2881 from the arguments and the default list. */
2882
2883void
2884construct_include_path (const char **arg_dirs)
2885{
2886#ifdef VAXC /* just don't ask ... */
2887 stat_t stbuf;
2888#else
2889 struct stat stbuf;
2890#endif
2891 const char **dirs;
2892 const char **cpp;
2893 unsigned int idx;
2894
2895 /* Compute the number of pointers we need in the table. */
2896 idx = sizeof (default_include_directories) / sizeof (const char *);
2897 if (arg_dirs)
2898 for (cpp = arg_dirs; *cpp != 0; ++cpp)
2899 ++idx;
2900
2901#ifdef __MSDOS__
2902 /* Add one for $DJDIR. */
2903 ++idx;
2904#endif
2905
2906 dirs = xmalloc (idx * sizeof (const char *));
2907
2908 idx = 0;
2909 max_incl_len = 0;
2910
2911 /* First consider any dirs specified with -I switches.
2912 Ignore any that don't exist. Remember the maximum string length. */
2913
2914 if (arg_dirs)
2915 while (*arg_dirs != 0)
2916 {
2917 const char *dir = *(arg_dirs++);
2918 char *expanded = 0;
2919 int e;
2920
2921 if (dir[0] == '~')
2922 {
2923 expanded = tilde_expand (dir);
2924 if (expanded != 0)
2925 dir = expanded;
2926 }
2927
2928 EINTRLOOP (e, stat (dir, &stbuf));
2929 if (e == 0 && S_ISDIR (stbuf.st_mode))
2930 {
2931 unsigned int len = strlen (dir);
2932 /* If dir name is written with trailing slashes, discard them. */
2933 while (len > 1 && dir[len - 1] == '/')
2934 --len;
2935 if (len > max_incl_len)
2936 max_incl_len = len;
2937 dirs[idx++] = strcache_add_len (dir, len);
2938 }
2939
2940 if (expanded)
2941 free (expanded);
2942 }
2943
2944 /* Now add the standard default dirs at the end. */
2945
2946#ifdef __MSDOS__
2947 {
2948 /* The environment variable $DJDIR holds the root of the DJGPP directory
2949 tree; add ${DJDIR}/include. */
2950 struct variable *djdir = lookup_variable ("DJDIR", 5);
2951
2952 if (djdir)
2953 {
2954 unsigned int len = strlen (djdir->value) + 8;
2955 char *defdir = alloca (len + 1);
2956
2957 strcat (strcpy (defdir, djdir->value), "/include");
2958 dirs[idx++] = strcache_add (defdir);
2959
2960 if (len > max_incl_len)
2961 max_incl_len = len;
2962 }
2963 }
2964#endif
2965
2966 for (cpp = default_include_directories; *cpp != 0; ++cpp)
2967 {
2968 int e;
2969
2970 EINTRLOOP (e, stat (*cpp, &stbuf));
2971 if (e == 0 && S_ISDIR (stbuf.st_mode))
2972 {
2973 unsigned int len = strlen (*cpp);
2974 /* If dir name is written with trailing slashes, discard them. */
2975 while (len > 1 && (*cpp)[len - 1] == '/')
2976 --len;
2977 if (len > max_incl_len)
2978 max_incl_len = len;
2979 dirs[idx++] = strcache_add_len (*cpp, len - 1);
2980 }
2981 }
2982
2983 dirs[idx] = 0;
2984
2985 /* Now add each dir to the .INCLUDE_DIRS variable. */
2986
2987 for (cpp = dirs; *cpp != 0; ++cpp)
2988 do_variable_definition (NILF, ".INCLUDE_DIRS", *cpp,
2989 o_default, f_append, 0);
2990
2991 include_directories = dirs;
2992}
2993
2994
2995/* Expand ~ or ~USER at the beginning of NAME.
2996 Return a newly malloc'd string or 0. */
2997
2998char *
2999tilde_expand (const char *name)
3000{
3001#ifndef VMS
3002 if (name[1] == '/' || name[1] == '\0')
3003 {
3004 extern char *getenv ();
3005 char *home_dir;
3006 int is_variable;
3007
3008 {
3009 /* Turn off --warn-undefined-variables while we expand HOME. */
3010 int save = warn_undefined_variables_flag;
3011 warn_undefined_variables_flag = 0;
3012
3013 home_dir = allocated_variable_expand ("$(HOME)");
3014
3015 warn_undefined_variables_flag = save;
3016 }
3017
3018 is_variable = home_dir[0] != '\0';
3019 if (!is_variable)
3020 {
3021 free (home_dir);
3022 home_dir = getenv ("HOME");
3023 }
3024# if !defined(_AMIGA) && !defined(WINDOWS32)
3025 if (home_dir == 0 || home_dir[0] == '\0')
3026 {
3027 extern char *getlogin ();
3028 char *logname = getlogin ();
3029 home_dir = 0;
3030 if (logname != 0)
3031 {
3032 struct passwd *p = getpwnam (logname);
3033 if (p != 0)
3034 home_dir = p->pw_dir;
3035 }
3036 }
3037# endif /* !AMIGA && !WINDOWS32 */
3038 if (home_dir != 0)
3039 {
3040 char *new = xstrdup (concat (home_dir, "", name + 1));
3041 if (is_variable)
3042 free (home_dir);
3043 return new;
3044 }
3045 }
3046# if !defined(_AMIGA) && !defined(WINDOWS32)
3047 else
3048 {
3049 struct passwd *pwent;
3050 char *userend = strchr (name + 1, '/');
3051 if (userend != 0)
3052 *userend = '\0';
3053 pwent = getpwnam (name + 1);
3054 if (pwent != 0)
3055 {
3056 if (userend == 0)
3057 return xstrdup (pwent->pw_dir);
3058 else
3059 return xstrdup (concat (pwent->pw_dir, "/", userend + 1));
3060 }
3061 else if (userend != 0)
3062 *userend = '/';
3063 }
3064# endif /* !AMIGA && !WINDOWS32 */
3065#endif /* !VMS */
3066 return 0;
3067}
3068
3069/* Given a chain of struct nameseq's describing a sequence of filenames,
3070 in reverse of the intended order, return a new chain describing the
3071 result of globbing the filenames. The new chain is in forward order.
3072 The links of the old chain are freed or used in the new chain.
3073 Likewise for the names in the old chain.
3074
3075 SIZE is how big to construct chain elements.
3076 This is useful if we want them actually to be other structures
3077 that have room for additional info. */
3078
3079struct nameseq *
3080multi_glob (struct nameseq *chain, unsigned int size)
3081{
3082 void dir_setup_glob (glob_t *);
3083 struct nameseq *new = 0;
3084 struct nameseq *old;
3085 struct nameseq *nexto;
3086 glob_t gl;
3087
3088 dir_setup_glob (&gl);
3089
3090 for (old = chain; old != 0; old = nexto)
3091 {
3092 const char *gname;
3093#ifndef NO_ARCHIVES
3094 char *arname = 0;
3095 char *memname = 0;
3096#endif
3097 nexto = old->next;
3098 gname = old->name;
3099
3100 if (gname[0] == '~')
3101 {
3102 char *newname = tilde_expand (old->name);
3103 if (newname != 0)
3104 gname = newname;
3105 }
3106
3107#ifndef NO_ARCHIVES
3108 if (ar_name (gname))
3109 {
3110 /* OLD->name is an archive member reference. Replace it with the
3111 archive file name, and save the member name in MEMNAME. We will
3112 glob on the archive name and then reattach MEMNAME later. */
3113 ar_parse_name (gname, &arname, &memname);
3114 gname = arname;
3115 }
3116#endif /* !NO_ARCHIVES */
3117
3118 switch (glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl))
3119 {
3120 case 0: /* Success. */
3121 {
3122 int i = gl.gl_pathc;
3123 while (i-- > 0)
3124 {
3125#ifndef NO_ARCHIVES
3126 if (memname != 0)
3127 {
3128 /* Try to glob on MEMNAME within the archive. */
3129 struct nameseq *found
3130 = ar_glob (gl.gl_pathv[i], memname, size);
3131 if (! found)
3132 {
3133 /* No matches. Use MEMNAME as-is. */
3134 unsigned int alen = strlen (gl.gl_pathv[i]);
3135 unsigned int mlen = strlen (memname);
3136 char *name;
3137 struct nameseq *elt = xmalloc (size);
3138 memset (elt, '\0', size);
3139
3140 name = alloca (alen + 1 + mlen + 2);
3141 memcpy (name, gl.gl_pathv[i], alen);
3142 name[alen] = '(';
3143 memcpy (name+alen+1, memname, mlen);
3144 name[alen + 1 + mlen] = ')';
3145 name[alen + 1 + mlen + 1] = '\0';
3146 elt->name = strcache_add (name);
3147 elt->next = new;
3148 new = elt;
3149 }
3150 else
3151 {
3152 /* Find the end of the FOUND chain. */
3153 struct nameseq *f = found;
3154 while (f->next != 0)
3155 f = f->next;
3156
3157 /* Attach the chain being built to the end of the FOUND
3158 chain, and make FOUND the new NEW chain. */
3159 f->next = new;
3160 new = found;
3161 }
3162 }
3163 else
3164#endif /* !NO_ARCHIVES */
3165 {
3166 struct nameseq *elt = xmalloc (size);
3167 memset (elt, '\0', size);
3168 elt->name = strcache_add (gl.gl_pathv[i]);
3169 elt->next = new;
3170 new = elt;
3171 }
3172 }
3173 globfree (&gl);
3174 free (old);
3175 break;
3176 }
3177
3178 case GLOB_NOSPACE:
3179 fatal (NILF, _("virtual memory exhausted"));
3180 break;
3181
3182 default:
3183 old->next = new;
3184 new = old;
3185 break;
3186 }
3187
3188#ifndef NO_ARCHIVES
3189 if (arname)
3190 free (arname);
3191#endif
3192 }
3193
3194 return new;
3195}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette