4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 * This file contains the makefile reader.
35 #include <alloca.h> /* alloca() */
36 #include <errno.h> /* errno */
37 #include <fcntl.h> /* fcntl() */
39 #include <mksh/macro.h> /* expand_value(), expand_macro() */
40 #include <mksh/misc.h> /* getmem() */
41 #include <mksh/read.h> /* get_next_block_fn() */
42 #include <sys/uio.h> /* read() */
43 #include <unistd.h> /* read(), unlink() */
55 static int line_started_with_space
=0; // Used to diagnose spaces instead of tabs
58 * File table of contents
60 static void parse_makefile(register Name true_makefile_name
, register Source source
);
61 static Source
push_macro_value(register Source bp
, register wchar_t *buffer
, int size
, register Source source
);
62 extern void enter_target_groups_and_dependencies(Name_vector target
, Name_vector depes
, Cmd_line command
, Separator separator
, Boolean target_group_seen
);
63 extern Name
normalize_name(register wchar_t *name_string
, register int length
);
66 * read_simple_file(makefile_name, chase_path, doname_it,
67 * complain, must_exist, report_file, lock_makefile)
69 * Make the makefile and setup to read it. Actually read it if it is stdio
72 * false if the read failed
75 * makefile_name Name of the file to read
76 * chase_path Use the makefile path when opening file
77 * doname_it Call doname() to build the file first
78 * complain Print message if doname/open fails
79 * must_exist Generate fatal if file is missing
80 * report_file Report file when running -P
81 * lock_makefile Lock the makefile when reading
83 * Static variables used:
85 * Global variables used:
86 * do_not_exec_rule Is -n on?
87 * file_being_read Set to the name of the new file
88 * line_number The number of the current makefile line
89 * makefiles_used A list of all makefiles used, appended to
94 read_simple_file(register Name makefile_name
, register Boolean chase_path
, register Boolean doname_it
, Boolean complain
, Boolean must_exist
, Boolean report_file
, Boolean lock_makefile
)
96 static short max_include_depth
;
97 register Property makefile
= maybe_append_prop(makefile_name
,
99 Boolean forget_after_parse
= false;
100 static pathpt makefile_path
;
103 register Source source
= ALLOC(Source
);
104 Property orig_makefile
= makefile
;
108 wchar_t *previous_file_being_read
= file_being_read
;
109 int previous_line_number
= line_number
;
110 wchar_t previous_current_makefile
[MAXPATHLEN
];
111 Makefile_type save_makefile_type
;
112 Name normalized_makefile_name
;
113 register wchar_t *string_start
;
114 register wchar_t *string_end
;
118 wchar_t * wcb
= get_wstring(makefile_name
->string_mb
);
120 if (max_include_depth
++ >= 40) {
121 fatal(gettext("Too many nested include statements"));
123 if (makefile
->body
.makefile
.contents
!= NULL
) {
124 retmem(makefile
->body
.makefile
.contents
);
127 source
->inp_buf_ptr
=
128 source
->inp_buf_end
= NULL
;
129 source
->error_converting
= false;
130 makefile
->body
.makefile
.contents
= NULL
;
131 makefile
->body
.makefile
.size
= 0;
132 if ((makefile_name
->hash
.length
!= 1) ||
133 (wcb
[0] != (int) hyphen_char
)) {
134 if ((makefile
->body
.makefile
.contents
== NULL
) &&
136 if (makefile_path
== NULL
) {
137 char *pfx
= make_install_prefix();
144 // As regularly installed
145 asprintf(&path
, "%s/../share/lib/make", pfx
);
146 add_dir_to_path(path
, &makefile_path
, -1);
150 asprintf(&path
, "%s/../../share/", pfx
);
151 add_dir_to_path(path
, &makefile_path
, -1);
154 add_dir_to_path("/usr/share/lib/make",
157 add_dir_to_path("/etc/default",
163 save_makefile_type
= makefile_type
;
164 makefile_type
= reading_nothing
;
165 if (doname(makefile_name
, true, false) == build_dont_know
) {
166 /* Try normalized filename */
167 string_start
=get_wstring(makefile_name
->string_mb
);
168 for (string_end
=string_start
+1; *string_end
!= L
'\0'; string_end
++);
169 normalized_makefile_name
=normalize_name(string_start
, string_end
- string_start
);
170 if ((strcmp(makefile_name
->string_mb
, normalized_makefile_name
->string_mb
) == 0) ||
171 (doname(normalized_makefile_name
, true, false) == build_dont_know
)) {
172 n
= access_vroot(makefile_name
->string_mb
,
175 makefile_path
: NULL
,
178 get_vroot_path((char **) NULL
,
181 if ((path
[0] == (int) period_char
) &&
182 (path
[1] == (int) slash_char
)) {
185 MBSTOWCS(wcs_buffer
, path
);
186 makefile_name
= GETNAME(wcs_buffer
,
190 retmem(string_start
);
192 * Commented out: retmem_mb(normalized_makefile_name->string_mb);
193 * We have to return this memory, but it seems to trigger a bug
194 * in dmake or in Sun C++ 5.7 compiler (it works ok if this code
195 * is compiled using Sun C++ 5.6).
197 // retmem_mb(normalized_makefile_name->string_mb);
199 makefile_type
= save_makefile_type
;
201 source
->string
.free_after_use
= false;
202 source
->previous
= NULL
;
203 source
->already_expanded
= false;
204 /* Lock the file for read, but not when -n. */
208 make_state_lockfile
= getmem(strlen(make_state
->string_mb
) + strlen(".lock") + 1);
209 (void) sprintf(make_state_lockfile
,
211 make_state
->string_mb
);
212 (void) file_lock(make_state
->string_mb
,
214 (int *) &make_state_locked
,
216 if(!make_state_locked
) {
217 printf("-- NO LOCKING for read\n");
218 retmem_mb(make_state_lockfile
);
219 make_state_lockfile
= 0;
223 if (makefile
->body
.makefile
.contents
== NULL
) {
224 save_makefile_type
= makefile_type
;
225 makefile_type
= reading_nothing
;
227 (doname(makefile_name
, true, false) == build_failed
)) {
229 (void) fprintf(stderr
,
230 gettext("%s: Couldn't make `%s'\n"),
232 makefile_name
->string_mb
);
235 makefile_type
= save_makefile_type
;
238 makefile_type
= save_makefile_type
;
240 // Before calling exists() make sure that we have the right timestamp
242 makefile_name
->stat
.time
= file_no_time
;
244 if (exists(makefile_name
) == file_doesnt_exist
) {
246 (makefile_name
->stat
.stat_errno
!= ENOENT
)) {
248 fatal(gettext("Can't find `%s': %s"),
249 makefile_name
->string_mb
,
250 errmsg(makefile_name
->
253 warning(gettext("Can't find `%s': %s"),
254 makefile_name
->string_mb
,
255 errmsg(makefile_name
->
260 if(make_state_locked
&& (make_state_lockfile
!= NULL
)) {
261 (void) unlink(make_state_lockfile
);
262 retmem_mb(make_state_lockfile
);
263 make_state_lockfile
= NULL
;
264 make_state_locked
= false;
267 retmem_mb((char *)source
);
271 * These values are the size and bytes of
272 * the MULTI-BYTE makefile.
274 orig_makefile
->body
.makefile
.size
=
275 makefile
->body
.makefile
.size
=
276 source
->bytes_left_in_file
=
277 makefile_name
->stat
.size
;
279 for (dpp
= &makefiles_used
;
281 dpp
= &(*dpp
)->next
);
282 dp
= ALLOC(Dependency
);
284 dp
->name
= makefile_name
;
285 dp
->automatic
= false;
290 source
->fd
= open_vroot(makefile_name
->string_mb
,
295 if (source
->fd
< 0) {
296 if (complain
|| (errno
!= ENOENT
)) {
298 fatal(gettext("Can't open `%s': %s"),
299 makefile_name
->string_mb
,
302 warning(gettext("Can't open `%s': %s"),
303 makefile_name
->string_mb
,
310 (void) fcntl(source
->fd
, F_SETFD
, 1);
311 orig_makefile
->body
.makefile
.contents
=
312 makefile
->body
.makefile
.contents
=
313 source
->string
.text
.p
=
314 source
->string
.buffer
.start
=
315 ALLOC_WC((int) (makefile_name
->stat
.size
+ 2));
316 if (makefile_type
== reading_cpp_file
) {
317 forget_after_parse
= true;
319 source
->string
.text
.end
= source
->string
.text
.p
;
320 source
->string
.buffer
.end
=
321 source
->string
.text
.p
+ makefile_name
->stat
.size
;
323 /* Do we ever reach here? */
325 source
->string
.text
.p
=
326 source
->string
.buffer
.start
=
327 makefile
->body
.makefile
.contents
;
328 source
->string
.text
.end
=
329 source
->string
.buffer
.end
=
330 source
->string
.text
.p
+ makefile
->body
.makefile
.size
;
331 source
->bytes_left_in_file
=
332 makefile
->body
.makefile
.size
;
334 file_being_read
= wcb
;
337 char *stdin_text_end
;
338 char *stdin_buffer_start
;
339 char *stdin_buffer_end
;
344 MBSTOWCS(wcs_buffer
, "Standard in");
345 makefile_name
= GETNAME(wcs_buffer
, FIND_LENGTH
);
347 * Memory to read standard in, then convert it
348 * to wide char strings.
351 stdin_text_p
= getmem(length
= 1024);
352 stdin_buffer_end
= stdin_text_p
+ length
;
353 MBSTOWCS(wcs_buffer
, "standard input");
354 file_being_read
= (wchar_t *) wcsdup(wcs_buffer
);
356 while ((n
= read(fileno(stdin
),
362 p_mb
= getmem(length
= 1024 +
364 stdin_buffer_start
));
368 stdin_buffer_start
));
369 retmem_mb(stdin_buffer_start
);
370 stdin_text_p
= p_mb
+
371 (stdin_buffer_end
- stdin_buffer_start
);
372 stdin_buffer_start
= p_mb
;
374 stdin_buffer_start
+ length
;
379 fatal(gettext("Error reading standard input: %s"),
382 stdin_text_p
= stdin_buffer_start
;
383 stdin_text_end
= stdin_buffer_end
- length
;
384 num_mb_chars
= stdin_text_end
- stdin_text_p
;
387 * Now, convert the sequence of multibyte chars into
388 * a sequence of corresponding wide character codes.
390 source
->string
.free_after_use
= false;
391 source
->previous
= NULL
;
392 source
->bytes_left_in_file
= 0;
394 source
->already_expanded
= false;
395 source
->string
.buffer
.start
=
396 source
->string
.text
.p
= ALLOC_WC(num_mb_chars
+ 1);
397 source
->string
.buffer
.end
=
398 source
->string
.text
.p
+ num_mb_chars
;
399 num_wc_chars
= mbstowcs(source
->string
.text
.p
,
402 if ((int) num_wc_chars
>= 0) {
403 source
->string
.text
.end
=
404 source
->string
.text
.p
+ num_wc_chars
;
406 (void) retmem_mb(stdin_text_p
);
410 (void) printf(gettext(">>>>>>>>>>>>>>>> Reading makefile %s\n"),
411 makefile_name
->string_mb
);
413 parse_makefile(makefile_name
, source
);
415 (void) printf(gettext(">>>>>>>>>>>>>>>> End of makefile %s\n"),
416 makefile_name
->string_mb
);
418 if(file_being_read
) {
419 retmem(file_being_read
);
421 file_being_read
= previous_file_being_read
;
422 line_number
= previous_line_number
;
423 makefile_type
= reading_nothing
;
425 if (make_state_locked
) {
426 /* Unlock .make.state. */
427 unlink(make_state_lockfile
);
428 make_state_locked
= false;
429 retmem_mb(make_state_lockfile
);
431 if (forget_after_parse
) {
432 retmem(makefile
->body
.makefile
.contents
);
433 makefile
->body
.makefile
.contents
= NULL
;
435 retmem_mb((char *)source
);
440 * parse_makefile(true_makefile_name, source)
442 * Strings are read from Sources.
443 * When macros are found, their values are represented by a
444 * Source that is pushed on a stack. At end of string
445 * (that is returned from GET_CHAR() as 0), the block is popped.
448 * true_makefile_name The name of makefile we are parsing
449 * source The source block to read from
451 * Global variables used:
452 * do_not_exec_rule Is -n on?
453 * line_number The number of the current makefile line
454 * makefile_type What kind of makefile are we reading?
455 * empty_name The Name ""
458 parse_makefile(register Name true_makefile_name
, register Source source
)
461 char mb_buffer[MB_LEN_MAX];
463 register wchar_t *source_p
;
464 register wchar_t *source_end
;
465 register wchar_t *string_start
;
467 register Boolean macro_seen_in_string
;
469 String_rec name_string
;
470 wchar_t name_buffer
[STRING_BUFFER_LENGTH
];
471 register int distance
;
472 register int paren_count
;
476 Cmd_line command_tail
;
479 Name_vector_rec target
;
480 Name_vector_rec depes
;
481 Name_vector_rec extra_name_vector
;
482 Name_vector current_names
;
483 Name_vector extra_names
= &extra_name_vector
;
485 Boolean target_group_seen
;
487 register Reader_state state
;
488 register Reader_state on_eoln_state
;
489 register Separator separator
;
491 wchar_t buffer
[4 * STRING_BUFFER_LENGTH
];
494 Boolean save_do_not_exec_rule
= do_not_exec_rule
;
498 static Name shell_name
;
501 static wchar_t include_space
[10];
502 static wchar_t include_tab
[10];
503 int tmp_bytes_left_in_string
;
504 Boolean tmp_maybe_include
= false;
506 Boolean first_target
;
508 String_rec include_name
;
509 wchar_t include_buffer
[STRING_BUFFER_LENGTH
];
511 target
.next
= depes
.next
= NULL
;
512 /* Move some values from their struct to register declared locals */
517 * Read whitespace on old line. Leave pointer on first char on
521 on_eoln_state
= exit_state
;
523 for (WCTOMB(mb_buffer, GET_CHAR());
525 source_p++, WCTOMB(mb_buffer, GET_CHAR()))
526 switch (mb_buffer[0]) {
528 for (char_number
=0; 1; source_p
++,char_number
++) switch (GET_CHAR()) {
530 /* End of this string. Pop it and return to the previous one */
531 GET_NEXT_BLOCK(source
);
533 if (source
== NULL
) {
534 GOTO_STATE(on_eoln_state
);
540 if (source
->fd
>= 0) {
543 switch (GET_CHAR()) {
545 GET_NEXT_BLOCK(source
);
546 if (source
== NULL
) {
547 GOTO_STATE(on_eoln_state
);
549 /* Go back to the top of this loop */
552 case numbersign_char
:
557 * Go back to the top of this loop since the
558 * new line does not start with a regular char.
562 /* We found the first proper char on the new line */
563 goto start_new_line_no_skip
;
566 if (char_number
== 0)
567 line_started_with_space
=line_number
;
569 /* Whitespace. Just keep going in this loop */
571 case numbersign_char
:
572 /* Comment. Skip over it */
573 for (; 1; source_p
++) {
574 switch (GET_CHAR()) {
576 GET_NEXT_BLOCK_NOCHK(source
);
577 if (source
== NULL
) {
578 GOTO_STATE(on_eoln_state
);
580 if (source
->error_converting
) {
581 // Illegal byte sequence - skip its first byte
582 source
->inp_buf_ptr
++;
587 /* Comments can be continued */
588 if (*++source_p
== (int) nul_char
) {
589 GET_NEXT_BLOCK_NOCHK(source
);
590 if (source
== NULL
) {
591 GOTO_STATE(on_eoln_state
);
593 if (source
->error_converting
) {
594 // Illegal byte sequence - skip its first byte
595 source
->inp_buf_ptr
++;
600 if(*source_p
== (int) newline_char
) {
601 if (source
->fd
>= 0) {
608 * After we skip the comment we go to
609 * the end of line handler since end of
610 * line terminates comments.
616 /* Macro reference */
617 if (source
->already_expanded
) {
619 * If we are reading from the expansion of a
620 * macro we already expanded everything enough.
622 goto start_new_line_no_skip
;
625 * Expand the value and push the Source on the stack of
631 Source t
= (Source
) alloca((int) sizeof (Source_rec
));
632 source
= push_macro_value(t
,
640 /* We found the first proper char on the new line */
641 goto start_new_line_no_skip
;
645 * We found the first normal char (one that starts an identifier)
648 start_new_line_no_skip
:
649 /* Inspect that first char to see if it maybe is special anyway */
650 switch (GET_CHAR()) {
652 GET_NEXT_BLOCK(source
);
653 if (source
== NULL
) {
654 GOTO_STATE(on_eoln_state
);
656 goto start_new_line_no_skip
;
661 /* Evaluate the line before it is read */
662 string_start
= source_p
+ 1;
663 macro_seen_in_string
= false;
664 /* Stuff the line in a string so we can eval it. */
665 for (; 1; source_p
++) {
666 switch (GET_CHAR()) {
670 if (source
->fd
> 0) {
671 if (!macro_seen_in_string
) {
672 macro_seen_in_string
= true;
673 INIT_STRING_FROM_STACK(
674 name_string
, name_buffer
);
676 append_string(string_start
,
678 source_p
- string_start
);
679 GET_NEXT_BLOCK(source
);
680 string_start
= source_p
;
685 if (!macro_seen_in_string
) {
686 INIT_STRING_FROM_STACK(name_string
,
689 append_string(string_start
,
691 source_p
- string_start
);
693 alloca((int) sizeof (Source_rec
));
694 extrap
->string
.buffer
.start
= NULL
;
696 extrap
->inp_buf_ptr
=
697 extrap
->inp_buf_end
= NULL
;
698 extrap
->error_converting
= false;
699 if (*source_p
== (int) nul_char
) {
703 expand_value(GETNAME(name_string
.buffer
.start
,
707 if (name_string
.free_after_use
) {
708 retmem(name_string
.buffer
.start
);
711 extrap
->string
.text
.p
=
712 extrap
->string
.buffer
.start
;
714 /* And push the value */
715 extrap
->previous
= source
;
725 /* We now have a line we can start reading */
727 if (source
== NULL
) {
728 GOTO_STATE(exit_state
);
730 /* Check if this is an include command */
731 if ((makefile_type
== reading_makefile
) &&
732 !source
->already_expanded
) {
733 if (include_space
[0] == (int) nul_char
) {
734 MBSTOWCS(include_space
, "include ");
735 MBSTOWCS(include_tab
, "include\t");
737 if ((IS_WEQUALN(source_p
, include_space
, 8)) ||
738 (IS_WEQUALN(source_p
, include_tab
, 8))) {
740 if (iswspace(*source_p
)) {
741 Makefile_type save_makefile_type
;
746 * Yes, this is an include.
747 * Skip spaces to get to the filename.
749 while (iswspace(*source_p
) ||
750 (*source_p
== (int) nul_char
)) {
751 switch (GET_CHAR()) {
753 GET_NEXT_BLOCK(source
);
754 if (source
== NULL
) {
755 GOTO_STATE(on_eoln_state
);
765 string_start
= source_p
;
766 /* Find the end of the filename */
767 macro_seen_in_string
= false;
768 while (!iswspace(*source_p
) ||
769 (*source_p
== (int) nul_char
)) {
770 switch (GET_CHAR()) {
772 if (!macro_seen_in_string
) {
773 INIT_STRING_FROM_STACK(name_string
,
776 append_string(string_start
,
778 source_p
- string_start
);
779 macro_seen_in_string
= true;
780 GET_NEXT_BLOCK(source
);
781 string_start
= source_p
;
782 if (source
== NULL
) {
783 GOTO_STATE(on_eoln_state
);
793 source
->string
.text
.p
= source_p
;
794 if (macro_seen_in_string
) {
795 append_string(string_start
,
797 source_p
- string_start
);
798 name_start
= name_string
.buffer
.start
;
799 name_length
= name_string
.text
.p
- name_start
;
801 name_start
= string_start
;
802 name_length
= source_p
- string_start
;
805 /* Strip "./" from the head of the name */
806 if ((name_start
[0] == (int) period_char
) &&
807 (name_start
[1] == (int) slash_char
)) {
811 /* if include file name is surrounded by double quotes */
812 if ((name_start
[0] == (int) doublequote_char
) &&
813 (name_start
[name_length
- 1] == (int) doublequote_char
)) {
817 /* if name does not begin with a slash char */
818 if (name_start
[0] != (int) slash_char
) {
819 if ((name_start
[0] == (int) period_char
) &&
820 (name_start
[1] == (int) slash_char
)) {
825 INIT_STRING_FROM_STACK(include_name
, include_buffer
);
826 APPEND_NAME(true_makefile_name
,
828 true_makefile_name
->hash
.length
);
830 wchar_t *slash
= wcsrchr(include_name
.buffer
.start
, (int) slash_char
);
832 include_name
.text
.p
= slash
+ 1;
833 append_string(name_start
,
837 name_start
= include_name
.buffer
.start
;
838 name_length
= include_name
.text
.p
- name_start
;
843 /* Even when we run -n we want to create makefiles */
844 do_not_exec_rule
= false;
845 makefile_name
= GETNAME(name_start
, name_length
);
846 if (makefile_name
->dollar
) {
847 String_rec destination
;
848 wchar_t buffer
[STRING_BUFFER_LENGTH
];
852 INIT_STRING_FROM_STACK(destination
, buffer
);
853 expand_value(makefile_name
,
856 for (p
= destination
.buffer
.start
;
857 (*p
!= (int) nul_char
) && iswspace(*p
);
860 (*q
!= (int) nul_char
) && !iswspace(*q
);
862 makefile_name
= GETNAME(p
, q
-p
);
863 if (destination
.free_after_use
) {
864 retmem(destination
.buffer
.start
);
870 save_makefile_type
= makefile_type
;
871 if (read_simple_file(makefile_name
,
878 fatal_reader(gettext("Read of include file `%s' failed"),
879 makefile_name
->string_mb
);
881 makefile_type
= save_makefile_type
;
882 do_not_exec_rule
= save_do_not_exec_rule
;
889 /* Check if the word include was split across 8K boundary. */
891 tmp_bytes_left_in_string
= source
->string
.text
.end
- source_p
;
892 if (tmp_bytes_left_in_string
< 8) {
893 tmp_maybe_include
= false;
894 if (IS_WEQUALN(source_p
,
896 tmp_bytes_left_in_string
)) {
897 tmp_maybe_include
= true;
899 if (tmp_maybe_include
) {
900 GET_NEXT_BLOCK(source
);
901 tmp_maybe_include
= false;
908 /* Reset the status in preparation for the new line */
909 for (nvp
= &target
; nvp
!= NULL
; nvp
= nvp
->next
) {
912 for (nvp
= &depes
; nvp
!= NULL
; nvp
= nvp
->next
) {
915 target_group_seen
= false;
916 command
= command_tail
= NULL
;
919 current_names
= &target
;
920 SET_STATE(scan_name_state
);
921 on_eoln_state
= illegal_eoln_state
;
922 separator
= none_seen
;
924 /* The state machine starts here */
926 while (1) switch (state
) {
928 /****************************************************************
931 case scan_name_state
:
932 /* Scan an identifier. We skip over chars until we find a break char */
933 /* First skip white space. */
934 for (; 1; source_p
++) switch (GET_CHAR()) {
936 GET_NEXT_BLOCK(source
);
938 if (source
== NULL
) {
939 GOTO_STATE(on_eoln_state
);
943 /* We found the end of the line. */
944 /* Do postprocessing or return error */
946 if (source
->fd
>= 0) {
949 GOTO_STATE(on_eoln_state
);
952 if (*++source_p
== (int) nul_char
) {
953 GET_NEXT_BLOCK(source
);
954 if (source
== NULL
) {
955 GOTO_STATE(on_eoln_state
);
958 if (*source_p
== (int) newline_char
) {
959 if (source
->fd
>= 0) {
968 /* Whitespace is skipped */
970 case numbersign_char
:
971 /* Comment. Skip over it */
972 for (; 1; source_p
++) {
973 switch (GET_CHAR()) {
975 GET_NEXT_BLOCK_NOCHK(source
);
976 if (source
== NULL
) {
977 GOTO_STATE(on_eoln_state
);
979 if (source
->error_converting
) {
980 // Illegal byte sequence - skip its first byte
981 source
->inp_buf_ptr
++;
986 if (*++source_p
== (int) nul_char
) {
987 GET_NEXT_BLOCK_NOCHK(source
);
988 if (source
== NULL
) {
989 GOTO_STATE(on_eoln_state
);
991 if (source
->error_converting
) {
992 // Illegal byte sequence - skip its first byte
993 source
->inp_buf_ptr
++;
998 if(*source_p
== (int) newline_char
) {
999 if (source
->fd
>= 0) {
1006 if (source
->fd
>= 0) {
1009 GOTO_STATE(on_eoln_state
);
1013 /* Macro reference. Expand and push value */
1014 if (source
->already_expanded
) {
1020 Source t
= (Source
) alloca((int) sizeof (Source_rec
));
1021 source
= push_macro_value(t
,
1029 /* End of white space */
1033 /* First proper identifier character */
1036 string_start
= source_p
;
1037 paren_count
= brace_count
= 0;
1038 macro_seen_in_string
= false;
1040 for (; 1; source_p
++) {
1041 switch (GET_CHAR()) {
1043 /* Save what we have seen so far of the identifier */
1044 if (source_p
!= string_start
) {
1045 if (!macro_seen_in_string
) {
1046 INIT_STRING_FROM_STACK(name_string
,
1049 append_string(string_start
,
1051 source_p
- string_start
);
1052 macro_seen_in_string
= true;
1054 /* Get more text to read */
1055 GET_NEXT_BLOCK(source
);
1056 string_start
= source_p
;
1058 if (source
== NULL
) {
1059 GOTO_STATE(on_eoln_state
);
1063 if (paren_count
> 0) {
1064 fatal_reader(gettext("Unmatched `(' on line"));
1066 if (brace_count
> 0) {
1067 fatal_reader(gettext("Unmatched `{' on line"));
1071 current_names
= enter_name(&name_string
,
1072 macro_seen_in_string
,
1077 &target_group_seen
);
1078 first_target
= false;
1079 if (extra_names
== NULL
) {
1080 extra_names
= (Name_vector
)
1081 alloca((int) sizeof (Name_vector_rec
));
1083 /* Do postprocessing or return error */
1084 if (source
->fd
>= 0) {
1087 GOTO_STATE(on_eoln_state
);
1088 case backslash_char
:
1089 /* Check if this is a quoting backslash */
1090 if (!macro_seen_in_string
) {
1091 INIT_STRING_FROM_STACK(name_string
,
1093 macro_seen_in_string
= true;
1095 append_string(string_start
,
1097 source_p
- string_start
);
1098 if (*++source_p
== (int) nul_char
) {
1099 GET_NEXT_BLOCK(source
);
1100 if (source
== NULL
) {
1101 GOTO_STATE(on_eoln_state
);
1104 if (*source_p
== (int) newline_char
) {
1105 if (source
->fd
>= 0) {
1108 *source_p
= (int) space_char
;
1109 string_start
= source_p
;
1110 goto resume_name_scan
;
1112 string_start
= source_p
;
1116 case numbersign_char
:
1117 if (paren_count
+ brace_count
> 0) {
1120 fatal_reader(gettext("Unexpected comment seen"));
1122 if (source
->already_expanded
) {
1125 /* Save the identifier so far */
1126 if (source_p
!= string_start
) {
1127 if (!macro_seen_in_string
) {
1128 INIT_STRING_FROM_STACK(name_string
,
1131 append_string(string_start
,
1133 source_p
- string_start
);
1134 macro_seen_in_string
= true;
1136 /* Eval and push the macro */
1141 (Source
) alloca((int) sizeof (Source_rec
));
1142 source
= push_macro_value(t
,
1148 string_start
= source_p
+ 1;
1150 case parenleft_char
:
1153 case parenright_char
:
1154 if (--paren_count
< 0) {
1155 fatal_reader(gettext("Unmatched `)' on line"));
1158 case braceleft_char
:
1161 case braceright_char
:
1162 if (--brace_count
< 0) {
1163 fatal_reader(gettext("Unmatched `}' on line"));
1166 case ampersand_char
:
1169 if (paren_count
+ brace_count
== 0) {
1175 if (paren_count
+ brace_count
> 0) {
1178 current_names
= enter_name(&name_string
,
1179 macro_seen_in_string
,
1184 &target_group_seen
);
1185 first_target
= false;
1186 if (extra_names
== NULL
) {
1187 extra_names
= (Name_vector
)
1188 alloca((int) sizeof (Name_vector_rec
));
1192 if (paren_count
+ brace_count
> 0) {
1195 if (separator
== conditional_seen
) {
1205 /* End of the target list. We now start reading */
1206 /* dependencies or a conditional assignment */
1207 if (separator
!= none_seen
) {
1208 fatal_reader(gettext("Extra `:', `::', or `:=' on dependency line"));
1210 /* Enter the last target */
1211 if ((string_start
!= source_p
) ||
1212 macro_seen_in_string
) {
1214 enter_name(&name_string
,
1215 macro_seen_in_string
,
1220 &target_group_seen
);
1221 first_target
= false;
1222 if (extra_names
== NULL
) {
1223 extra_names
= (Name_vector
)
1225 sizeof (Name_vector_rec
));
1228 /* Check if it is ":" "::" or ":=" */
1230 switch (*++source_p
) {
1232 GET_NEXT_BLOCK(source
);
1234 if (source
== NULL
) {
1235 GOTO_STATE(enter_dependencies_state
);
1237 goto scan_colon_label
;
1240 fatal_reader(gettext("syntax error"));
1242 separator
= conditional_seen
;
1244 current_names
= &depes
;
1245 GOTO_STATE(scan_name_state
);
1247 separator
= two_colon
;
1251 separator
= one_colon
;
1253 current_names
= &depes
;
1254 on_eoln_state
= enter_dependencies_state
;
1255 GOTO_STATE(scan_name_state
);
1256 case semicolon_char
:
1257 if (paren_count
+ brace_count
> 0) {
1260 /* End of reading names. Start reading the rule */
1261 if ((separator
!= one_colon
) &&
1262 (separator
!= two_colon
)) {
1263 fatal_reader(gettext("Unexpected command seen"));
1265 /* Enter the last dependency */
1266 if ((string_start
!= source_p
) ||
1267 macro_seen_in_string
) {
1269 enter_name(&name_string
,
1270 macro_seen_in_string
,
1275 &target_group_seen
);
1276 first_target
= false;
1277 if (extra_names
== NULL
) {
1278 extra_names
= (Name_vector
)
1280 sizeof (Name_vector_rec
));
1284 /* Make sure to enter a rule even if the is */
1286 command
= command_tail
= ALLOC(Cmd_line
);
1287 command
->next
= NULL
;
1288 command
->command_line
= empty_name
;
1289 command
->make_refd
= false;
1290 command
->ignore_command_dependency
= false;
1291 command
->assign
= false;
1292 command
->ignore_error
= false;
1293 command
->silent
= false;
1295 GOTO_STATE(scan_command_state
);
1298 ** following code drops the target separator plus char if it starts
1301 if(first_target
&& !macro_seen_in_string
&&
1302 source_p
== string_start
) {
1303 for (; 1; source_p
++)
1304 switch (GET_CHAR()) {
1306 if (source_p
!= string_start
) {
1307 if (!macro_seen_in_string
) {
1308 INIT_STRING_FROM_STACK(name_string
,
1311 append_string(string_start
,
1313 source_p
- string_start
);
1314 macro_seen_in_string
= true;
1316 GET_NEXT_BLOCK(source
);
1317 string_start
= source_p
;
1319 if (source
== NULL
) {
1320 GOTO_STATE(on_eoln_state
);
1325 while (*source_p
== (int) nul_char
) {
1326 if (source_p
!= string_start
) {
1327 if (!macro_seen_in_string
) {
1328 INIT_STRING_FROM_STACK(name_string
,
1331 append_string(string_start
,
1333 source_p
- string_start
);
1334 macro_seen_in_string
= true;
1336 GET_NEXT_BLOCK(source
);
1337 string_start
= source_p
;
1338 if (source
== NULL
) {
1339 GOTO_STATE(on_eoln_state
);
1342 if (*source_p
== (int) tab_char
||
1343 *source_p
== (int) space_char
) {
1344 macro_seen_in_string
= false;
1345 string_start
= source_p
+ 1;
1347 goto resume_name_scan
;
1352 string_start
= source_p
+ 1;
1355 goto resume_name_scan
;
1358 if (paren_count
+ brace_count
> 0) {
1361 /* We found "+=" construct */
1362 if (source_p
!= string_start
) {
1363 /* "+" is not a break char. */
1364 /* Ignore it if it is part of an identifier */
1366 goto resume_name_scan
;
1368 /* Make sure the "+" is followed by a "=" */
1370 switch (*++source_p
) {
1372 if (!macro_seen_in_string
) {
1373 INIT_STRING_FROM_STACK(name_string
,
1376 append_string(string_start
,
1378 source_p
- string_start
);
1379 GET_NEXT_BLOCK(source
);
1381 string_start
= source_p
;
1382 if (source
== NULL
) {
1383 GOTO_STATE(illegal_eoln_state
);
1390 fatal_reader(gettext("Must be a separator on rules"));
1394 /* The "+" just starts a regular name. */
1395 /* Start reading that name */
1396 goto resume_name_scan
;
1400 if (paren_count
+ brace_count
> 0) {
1403 /* We found macro assignment. */
1404 /* Check if it is legal and if it is appending */
1405 switch (separator
) {
1407 separator
= equal_seen
;
1408 on_eoln_state
= enter_equal_state
;
1410 case conditional_seen
:
1411 on_eoln_state
= enter_conditional_state
;
1414 /* Reader must special check for "MACRO:sh=" */
1416 if (sh_name
== NULL
) {
1417 MBSTOWCS(wcs_buffer
, "sh");
1418 sh_name
= GETNAME(wcs_buffer
, FIND_LENGTH
);
1419 MBSTOWCS(wcs_buffer
, "shell");
1420 shell_name
= GETNAME(wcs_buffer
, FIND_LENGTH
);
1423 if (!macro_seen_in_string
) {
1424 INIT_STRING_FROM_STACK(name_string
,
1427 append_string(string_start
,
1429 source_p
- string_start
1432 if ( (((target
.used
== 1) &&
1433 (depes
.used
== 1) &&
1434 (depes
.names
[0] == sh_name
)) ||
1435 ((target
.used
== 1) &&
1436 (depes
.used
== 0) &&
1437 (separator
== one_colon
) &&
1438 (GETNAME(name_string
.buffer
.start
,FIND_LENGTH
) == sh_name
))) &&
1440 String_rec macro_name
;
1441 wchar_t buffer
[100];
1443 INIT_STRING_FROM_STACK(macro_name
,
1445 APPEND_NAME(target
.names
[0],
1448 append_char((int) colon_char
,
1450 APPEND_NAME(sh_name
,
1454 GETNAME(macro_name
.buffer
.start
,
1456 separator
= equal_seen
;
1457 on_eoln_state
= enter_equal_state
;
1459 } else if ( (((target
.used
== 1) &&
1460 (depes
.used
== 1) &&
1461 (depes
.names
[0] == shell_name
)) ||
1462 ((target
.used
== 1) &&
1463 (depes
.used
== 0) &&
1464 (separator
== one_colon
) &&
1465 (GETNAME(name_string
.buffer
.start
,FIND_LENGTH
) == shell_name
))) &&
1467 String_rec macro_name
;
1468 wchar_t buffer
[100];
1470 INIT_STRING_FROM_STACK(macro_name
,
1472 APPEND_NAME(target
.names
[0],
1475 append_char((int) colon_char
,
1477 APPEND_NAME(shell_name
,
1481 GETNAME(macro_name
.buffer
.start
,
1483 separator
= equal_seen
;
1484 on_eoln_state
= enter_equal_state
;
1488 fatal_reader(gettext("syntax error"));
1491 fatal_reader(gettext("Macro assignment on dependency line"));
1497 /* Enter the macro name */
1498 if ((string_start
!= source_p
) ||
1499 macro_seen_in_string
) {
1501 enter_name(&name_string
,
1502 macro_seen_in_string
,
1507 &target_group_seen
);
1508 first_target
= false;
1509 if (extra_names
== NULL
) {
1510 extra_names
= (Name_vector
)
1512 sizeof (Name_vector_rec
));
1521 /* Skip whitespace to the start of the value */
1522 macro_seen_in_string
= false;
1523 for (; 1; source_p
++) {
1524 switch (GET_CHAR()) {
1526 GET_NEXT_BLOCK(source
);
1528 if (source
== NULL
) {
1529 GOTO_STATE(on_eoln_state
);
1532 case backslash_char
:
1533 if (*++source_p
== (int) nul_char
) {
1534 GET_NEXT_BLOCK(source
);
1535 if (source
== NULL
) {
1536 GOTO_STATE(on_eoln_state
);
1539 if (*source_p
!= (int) newline_char
) {
1540 if (!macro_seen_in_string
) {
1541 macro_seen_in_string
=
1543 INIT_STRING_FROM_STACK(name_string
,
1549 append_char(*source_p
,
1551 string_start
= source_p
+1;
1552 goto macro_value_start
;
1554 if (source
->fd
>= 0) {
1560 case numbersign_char
:
1561 string_start
= source_p
;
1562 goto macro_value_end
;
1567 string_start
= source_p
;
1568 goto macro_value_start
;
1572 /* Find the end of the value */
1573 for (; 1; source_p
++) {
1574 if (distance
!= 0) {
1575 *source_p
= *(source_p
+ distance
);
1577 switch (GET_CHAR()) {
1579 if (!macro_seen_in_string
) {
1580 macro_seen_in_string
= true;
1581 INIT_STRING_FROM_STACK(name_string
,
1584 append_string(string_start
,
1586 source_p
- string_start
);
1587 GET_NEXT_BLOCK(source
);
1588 string_start
= source_p
;
1590 if (source
== NULL
) {
1591 GOTO_STATE(on_eoln_state
);
1594 case backslash_char
:
1596 if (distance
!= 0) {
1598 *(source_p
+ distance
);
1600 if (*source_p
== (int) nul_char
) {
1601 if (!macro_seen_in_string
) {
1602 macro_seen_in_string
=
1604 INIT_STRING_FROM_STACK(name_string
,
1609 *(source_p
- 1) = (int) space_char
;
1610 append_string(string_start
,
1614 GET_NEXT_BLOCK(source
);
1615 string_start
= source_p
;
1616 if (source
== NULL
) {
1617 GOTO_STATE(on_eoln_state
);
1619 if (distance
!= 0) {
1624 if (*source_p
== (int) newline_char
) {
1625 append_char((int) space_char
, &name_string
);
1627 append_char((int) backslash_char
, &name_string
);
1631 if (*source_p
== (int) newline_char
) {
1635 *source_p
= (int) space_char
;
1636 while ((*(source_p
+
1641 (int) space_char
)) {
1647 case numbersign_char
:
1648 goto macro_value_end
;
1652 /* Complete the value in the string */
1653 if (!macro_seen_in_string
) {
1654 macro_seen_in_string
= true;
1655 INIT_STRING_FROM_STACK(name_string
,
1658 append_string(string_start
,
1660 source_p
- string_start
);
1661 if (name_string
.buffer
.start
!= name_string
.text
.p
) {
1663 GETNAME(name_string
.buffer
.start
,
1666 if (name_string
.free_after_use
) {
1667 retmem(name_string
.buffer
.start
);
1669 for (; distance
> 0; distance
--) {
1670 *source_p
++ = (int) space_char
;
1672 GOTO_STATE(on_eoln_state
);
1676 /****************************************************************
1677 * enter dependencies state
1679 case enter_dependencies_state
:
1680 enter_dependencies_label
:
1681 /* Expects pointer on first non whitespace char after last dependency. (On */
1682 /* next line.) We end up here after having read a "targets : dependencies" */
1683 /* line. The state checks if there is a rule to read and if so dispatches */
1684 /* to scan_command_state scan_command_state reads one rule line and the */
1687 /* First check if the first char on the next line is special */
1688 switch (GET_CHAR()) {
1690 GET_NEXT_BLOCK(source
);
1691 if (source
== NULL
) {
1694 goto enter_dependencies_label
;
1696 /* The line should be evaluate before it is read */
1697 macro_seen_in_string
= false;
1698 string_start
= source_p
+ 1;
1699 for (; 1; source_p
++) {
1700 switch (GET_CHAR()) {
1704 if (source
->fd
> 0) {
1705 if (!macro_seen_in_string
) {
1706 macro_seen_in_string
= true;
1707 INIT_STRING_FROM_STACK(name_string
,
1710 append_string(string_start
,
1712 source_p
- string_start
);
1713 GET_NEXT_BLOCK(source
);
1714 string_start
= source_p
;
1719 if (!macro_seen_in_string
) {
1720 INIT_STRING_FROM_STACK(name_string
,
1723 append_string(string_start
,
1725 source_p
- string_start
);
1727 alloca((int) sizeof (Source_rec
));
1728 extrap
->string
.buffer
.start
= NULL
;
1730 extrap
->inp_buf_ptr
=
1731 extrap
->inp_buf_end
= NULL
;
1732 extrap
->error_converting
= false;
1733 expand_value(GETNAME(name_string
.buffer
.start
,
1737 if (name_string
.free_after_use
) {
1738 retmem(name_string
.buffer
.start
);
1741 extrap
->string
.text
.p
=
1742 extrap
->string
.buffer
.start
;
1744 extrap
->previous
= source
;
1747 goto enter_dependencies_label
;
1751 if (source
->already_expanded
) {
1757 Source t
= (Source
) alloca((int) sizeof (Source_rec
));
1758 source
= push_macro_value(t
,
1764 goto enter_dependencies_label
;
1765 case numbersign_char
:
1766 if (makefile_type
!= reading_makefile
) {
1768 GOTO_STATE(scan_command_state
);
1770 for (; 1; source_p
++) {
1771 switch (GET_CHAR()) {
1773 GET_NEXT_BLOCK_NOCHK(source
);
1774 if (source
== NULL
) {
1775 GOTO_STATE(on_eoln_state
);
1777 if (source
->error_converting
) {
1778 // Illegal byte sequence - skip its first byte
1779 source
->inp_buf_ptr
++;
1783 case backslash_char
:
1784 if (*++source_p
== (int) nul_char
) {
1785 GET_NEXT_BLOCK_NOCHK(source
);
1786 if (source
== NULL
) {
1787 GOTO_STATE(on_eoln_state
);
1789 if (source
->error_converting
) {
1790 // Illegal byte sequence - skip its first byte
1791 source
->inp_buf_ptr
++;
1796 if(*source_p
== (int) newline_char
) {
1797 if (source
->fd
>= 0) {
1804 if (source
->fd
>= 0) {
1807 goto enter_dependencies_label
;
1812 GOTO_STATE(scan_command_state
);
1815 /* We read all the command lines for the target/dependency line. */
1816 /* Enter the stuff */
1817 enter_target_groups_and_dependencies( &target
, &depes
, command
,
1818 separator
, target_group_seen
);
1820 goto start_new_line
;
1822 /****************************************************************
1823 * scan command state
1825 case scan_command_state
:
1826 /* We need to read one rule line. Do that and return to */
1827 /* the enter dependencies state */
1828 string_start
= source_p
;
1829 macro_seen_in_string
= false;
1830 for (; 1; source_p
++) {
1831 switch (GET_CHAR()) {
1832 case backslash_char
:
1833 if (!macro_seen_in_string
) {
1834 INIT_STRING_FROM_STACK(name_string
,
1837 append_string(string_start
,
1839 source_p
- string_start
);
1840 macro_seen_in_string
= true;
1841 if (*++source_p
== (int) nul_char
) {
1842 GET_NEXT_BLOCK(source
);
1843 if (source
== NULL
) {
1844 string_start
= source_p
;
1845 goto command_newline
;
1848 append_char((int) backslash_char
, &name_string
);
1849 append_char(*source_p
, &name_string
);
1850 if (*source_p
== (int) newline_char
) {
1851 if (source
->fd
>= 0) {
1854 if (*++source_p
== (int) nul_char
) {
1855 GET_NEXT_BLOCK(source
);
1856 if (source
== NULL
) {
1857 string_start
= source_p
;
1858 goto command_newline
;
1861 if (*source_p
== (int) tab_char
) {
1865 if (*++source_p
== (int) nul_char
) {
1866 GET_NEXT_BLOCK(source
);
1867 if (source
== NULL
) {
1868 string_start
= source_p
;
1869 goto command_newline
;
1873 string_start
= source_p
;
1874 if ((*source_p
== (int) newline_char
) ||
1875 (*source_p
== (int) backslash_char
) ||
1876 (*source_p
== (int) nul_char
)) {
1882 if ((string_start
!= source_p
) ||
1883 macro_seen_in_string
) {
1884 if (macro_seen_in_string
) {
1885 append_string(string_start
,
1887 source_p
- string_start
);
1889 name_string
.buffer
.start
;
1890 string_end
= name_string
.text
.p
;
1892 string_end
= source_p
;
1894 while ((*string_start
!= (int) newline_char
) &&
1895 iswspace(*string_start
)){
1898 if ((string_end
> string_start
) ||
1899 (makefile_type
== reading_statefile
)) {
1900 if (command_tail
== NULL
) {
1905 command_tail
->next
=
1910 command_tail
->next
= NULL
;
1911 command_tail
->make_refd
= false;
1912 command_tail
->ignore_command_dependency
= false;
1913 command_tail
->assign
= false;
1914 command_tail
->ignore_error
= false;
1915 command_tail
->silent
= false;
1916 command_tail
->command_line
=
1917 GETNAME(string_start
,
1918 string_end
- string_start
);
1919 if (macro_seen_in_string
&&
1920 name_string
.free_after_use
) {
1927 if ((source
!= NULL
) && (source
->fd
>= 0)) {
1930 if ((source
!= NULL
) &&
1931 (*++source_p
== (int) nul_char
)) {
1932 GET_NEXT_BLOCK(source
);
1933 if (source
== NULL
) {
1934 GOTO_STATE(on_eoln_state
);
1937 } while (*source_p
== (int) newline_char
);
1939 GOTO_STATE(enter_dependencies_state
);
1941 if (!macro_seen_in_string
) {
1942 INIT_STRING_FROM_STACK(name_string
,
1945 append_string(string_start
,
1947 source_p
- string_start
);
1948 macro_seen_in_string
= true;
1949 GET_NEXT_BLOCK(source
);
1950 string_start
= source_p
;
1952 if (source
== NULL
) {
1953 GOTO_STATE(enter_dependencies_state
);
1959 /****************************************************************
1962 case enter_equal_state
:
1963 if (target
.used
!= 1) {
1964 GOTO_STATE(poorly_formed_macro_state
);
1966 enter_equal(target
.names
[0], macro_value
, append
);
1967 goto start_new_line
;
1969 /****************************************************************
1970 * enter conditional state
1972 case enter_conditional_state
:
1973 if (depes
.used
!= 1) {
1974 GOTO_STATE(poorly_formed_macro_state
);
1976 for (nvp
= &target
; nvp
!= NULL
; nvp
= nvp
->next
) {
1977 for (i
= 0; i
< nvp
->used
; i
++) {
1978 enter_conditional(nvp
->names
[i
],
1984 goto start_new_line
;
1986 /****************************************************************
1989 case illegal_bytes_state
:
1990 fatal_reader(gettext("Invalid byte sequence"));
1991 case illegal_eoln_state
:
1992 if (line_number
> 1) {
1993 if (line_started_with_space
== (line_number
- 1)) {
1995 fatal_reader(gettext("Unexpected end of line seen\n\t*** missing separator (did you mean TAB instead of 8 spaces?)"));
1998 fatal_reader(gettext("Unexpected end of line seen"));
1999 case poorly_formed_macro_state
:
2000 fatal_reader(gettext("Badly formed macro assignment"));
2004 fatal_reader(gettext("Internal error. Unknown reader state"));
2009 * push_macro_value(bp, buffer, size, source)
2011 * Macro and function that evaluates one macro
2012 * and makes the reader read from the value of it
2015 * The source block to read the macro from
2018 * bp The new source block to fill in
2019 * buffer Buffer to read from
2020 * size size of the buffer
2021 * source The old source block
2023 * Global variables used:
2026 push_macro_value(register Source bp
, register wchar_t *buffer
, int size
, register Source source
)
2028 bp
->string
.buffer
.start
= bp
->string
.text
.p
= buffer
;
2029 bp
->string
.text
.end
= NULL
;
2030 bp
->string
.buffer
.end
= buffer
+ (size
/SIZEOFWCHAR_T
);
2031 bp
->string
.free_after_use
= false;
2034 bp
->inp_buf_end
= NULL
;
2035 bp
->error_converting
= false;
2036 expand_macro(source
, &bp
->string
, (wchar_t *) NULL
, false);
2037 bp
->string
.text
.p
= bp
->string
.buffer
.start
;
2039 /* 4209588: 'make' doesn't understand a macro with whitespaces in the head as target.
2040 * strip whitespace from the begining of the macro value
2042 while (iswspace(*bp
->string
.text
.p
)) {
2043 bp
->string
.text
.p
++;
2047 bp
->already_expanded
= true;
2048 bp
->previous
= source
;
2053 * enter_target_groups_and_dependencies(target, depes, command, separator,
2054 * target_group_seen)
2057 * target Structure that shows the target(s) on the line
2058 * we are currently parsing. This can looks like
2059 * target1 .. targetN : dependencies
2062 * target1 + .. + targetN : dependencies
2064 * depes Dependencies
2065 * command Points to the command(s) to be executed for
2067 * separator : or :: or :=
2068 * target_group_seen Set if we have target1 + .. + targetN
2071 * After reading the command lines for a target, this routine
2072 * is called to setup the dependencies and the commands for it.
2073 * If the target is a % pattern or part of a target group, then
2074 * the appropriate routines are called.
2078 enter_target_groups_and_dependencies(Name_vector target
, Name_vector depes
, Cmd_line command
, Separator separator
, Boolean target_group_seen
)
2081 Boolean reset
= true;
2082 Chain target_group_member
;
2083 Percent percent_ptr
;
2085 for (; target
!= NULL
; target
= target
->next
) {
2086 for (i
= 0; i
< target
->used
; i
++) {
2087 if (target
->names
[i
] != NULL
) {
2088 if (target_group_seen
) {
2089 target_group_member
=
2090 find_target_groups(target
, i
, reset
);
2091 if(target_group_member
== NULL
) {
2092 fatal_reader(gettext("Unexpected '+' on dependency line"));
2097 /* If we saw it in the makefile it must be
2099 target
->names
[i
]->stat
.is_file
= true;
2100 /* Make sure that we use dependencies
2101 * entered for makefiles */
2102 target
->names
[i
]->state
= build_dont_know
;
2104 /* If the target is special we delegate
2106 if (target
->names
[i
]->special_reader
2108 special_reader(target
->names
[i
],
2112 /* Check if this is a "a%b : x%y" type rule */
2113 else if (target
->names
[i
]->percent
) {
2115 enter_percent(target
->names
[i
],
2116 target
->target_group
[i
],
2118 if (target_group_seen
) {
2119 target_group_member
->percent_member
=
2122 } else if (target
->names
[i
]->dollar
) {
2123 enter_dyntarget(target
->names
[i
]);
2126 target
->target_group
[i
],
2131 if (target_group_seen
) {
2132 target_group_member
->percent_member
=
2138 target
->target_group
[i
],