26 */
27
28 /*
29 * This is not "#ifdef TEAMWARE_MAKE_CMN" because we're currently
30 * using the TW fake i18n headers and libraries to build both
31 * SMake and PMake on SPARC/S1 and x86/S2.
32 */
33
34 #include <avo/intl.h>
35 #include <limits.h> /* MB_LEN_MAX */
36 #include <stdio.h>
37 #include <stdlib.h> /* wchar_t */
38 #include <string.h> /* strcmp() */
39 #include <nl_types.h> /* catgets() */
40 #include <sys/param.h> /* MAXPATHLEN */
41 #include <sys/types.h> /* time_t, caddr_t */
42 #include <vroot/vroot.h> /* pathpt */
43 #include <sys/time.h> /* timestruc_t */
44 #include <errno.h> /* errno */
45
46 #if defined (HP_UX) || defined (linux)
47 #define MAXNAMELEN 256
48 #define RW_NO_OVERLOAD_WCHAR 1 /* Rogue Wave, belongs in <rw/compiler.h> */
49 #else
50 #include <wctype.h>
51 #include <widec.h>
52 #endif
53
54 #if defined (linux)
55 /*
56 * Definition of wchar functions.
57 */
58 # include <wctype.h>
59 # include <wchar.h>
60 # define wsdup(x) wcsdup(x)
61 # define wschr(x,y) wcschr(x,y)
62 # define wscat(x,y) wcscat(x,y)
63 # define wsrchr(x,y) wcsrchr(x,y)
64 # define wslen(x) wcslen(x)
65 # define wscpy(x,y) wcscpy(x,y)
66 # define wsncpy(x,y,z) wcsncpy(x,y,z)
67 # define wscmp(x,y) wcscmp(x,y)
68 # define wsncmp(x,y,z) wcsncmp(x,y,z)
69 #endif
70
71 /*
72 * A type and some utilities for boolean values
73 */
74
75 #define false BOOLEAN_false
76 #define true BOOLEAN_true
77
78 typedef enum {
79 false = 0,
80 true = 1,
81 failed = 0,
82 succeeded = 1
83 } Boolean;
84 #define BOOLEAN(expr) ((expr) ? true : false)
85
86 /*
87 * Some random constants (in an enum so dbx knows their values)
88 */
89 enum {
90 update_delay = 30, /* time between rstat checks */
91 #ifdef sun386
92 ar_member_name_len = 14,
93 #else
94 ar_member_name_len = 1024,
95 #endif
96
97 hashsize = 2048 /* size of hash table */
98 };
99
100
101 /*
102 * Symbols that defines all the different char constants make uses
103 */
104 enum {
105 ampersand_char = '&',
106 asterisk_char = '*',
107 at_char = '@',
108 backquote_char = '`',
109 backslash_char = '\\',
110 bar_char = '|',
111 braceleft_char = '{',
112 braceright_char = '}',
113 bracketleft_char = '[',
114 bracketright_char = ']',
115 colon_char = ':',
116 comma_char = ',',
377 sccs_get_special,
378 silent_special,
379 suffixes_special,
380 svr4_special,
381 localhost_special
382 } Special;
383
384 typedef enum {
385 no_colon,
386 one_colon,
387 two_colon,
388 equal_seen,
389 conditional_seen,
390 none_seen
391 } Separator;
392
393 /*
394 * Magic values for the timestamp stored with each name object
395 */
396
397 #if defined (linux)
398 typedef struct timespec timestruc_t;
399 #endif
400
401 extern const timestruc_t file_no_time;
402 extern const timestruc_t file_doesnt_exist;
403 extern const timestruc_t file_is_dir;
404 extern const timestruc_t file_min_time;
405 extern const timestruc_t file_max_time;
406
407 /*
408 * Each Name has a list of properties
409 * The properties are used to store information that only
410 * a subset of the Names need
411 */
412 typedef enum {
413 no_prop,
414 conditional_prop,
415 line_prop,
416 macro_prop,
417 makefile_prop,
418 member_prop,
419 recursive_prop,
444 struct _Macro {
445 /*
446 * For "ABC = xyz" constructs
447 * Name "ABC" get one macro prop
448 */
449 struct _Name *value;
450 #ifdef NSE
451 Boolean imported:1;
452 #endif
453 Boolean exported:1;
454 Boolean read_only:1;
455 /*
456 * This macro is defined conditionally
457 */
458 Boolean is_conditional:1;
459 /*
460 * The list for $? is stored as a structured list that
461 * is translated into a string iff it is referenced.
462 * This is why some macro values need a daemon.
463 */
464 #if defined(HP_UX) || defined(linux)
465 Daemon daemon;
466 #else
467 Daemon daemon:2;
468 #endif
469 };
470
471 struct _Macro_list {
472 struct _Macro_list *next;
473 char *macro_name;
474 char *value;
475 };
476
477 enum sccs_stat {
478 DONT_KNOW_SCCS = 0,
479 NO_SCCS,
480 HAS_SCCS
481 };
482
483 struct _Name {
484 struct _Property *prop; /* List of properties */
485 char *string_mb; /* Multi-byte name string */
486 struct {
487 unsigned int length;
488 } hash;
489 struct {
490 timestruc_t time; /* Modification */
491 int stat_errno; /* error from "stat" */
492 off_t size; /* Of file */
493 mode_t mode; /* Of file */
494 #if defined(HP_UX) || defined(linux)
495 Boolean is_file;
496 Boolean is_dir;
497 Boolean is_sym_link;
498 Boolean is_precious;
499 enum sccs_stat has_sccs;
500 #else
501 Boolean is_file:1;
502 Boolean is_dir:1;
503 Boolean is_sym_link:1;
504 Boolean is_precious:1;
505 #ifdef NSE
506 Boolean is_derived_src:1;
507 #endif
508 enum sccs_stat has_sccs:2;
509 #endif
510 } stat;
511 /*
512 * Count instances of :: definitions for this target
513 */
514 short colon_splits;
515 /*
516 * We only clear the automatic depes once per target per report
517 */
518 short temp_file_number;
519 /*
520 * Count how many conditional macros this target has defined
521 */
522 short conditional_cnt;
523 /*
524 * A conditional macro was used when building this target
525 */
526 Boolean depends_on_conditional:1;
527 /*
528 * Pointer to list of conditional macros which were used to build
529 * this target
530 */
531 struct _Macro_list *conditional_macro_list;
532 Boolean has_member_depe:1;
533 Boolean is_member:1;
534 /*
535 * This target is a directory that has been read
536 */
537 Boolean has_read_dir:1;
538 /*
539 * This name is a macro that is now being expanded
540 */
541 Boolean being_expanded:1;
542 /*
543 * This name is a magic name that the reader must know about
544 */
545 #if defined(HP_UX) || defined(linux)
546 Special special_reader;
547 Doname state;
548 Separator colons;
549 #else
550 Special special_reader:5;
551 Doname state:3;
552 Separator colons:3;
553 #endif
554 Boolean has_depe_list_expanded:1;
555 Boolean suffix_scan_done:1;
556 Boolean has_complained:1; /* For sccs */
557 /*
558 * This target has been built during this make run
559 */
560 Boolean ran_command:1;
561 Boolean with_squiggle:1; /* for .SUFFIXES */
562 Boolean without_squiggle:1; /* for .SUFFIXES */
563 Boolean has_read_suffixes:1; /* Suffix list cached*/
564 Boolean has_suffixes:1;
565 Boolean has_target_prop:1;
566 Boolean has_vpath_alias_prop:1;
567 Boolean dependency_printed:1; /* For dump_make_state() */
568 Boolean dollar:1; /* In namestring */
569 Boolean meta:1; /* In namestring */
570 Boolean percent:1; /* In namestring */
571 Boolean wildcard:1; /* In namestring */
572 Boolean has_parent:1;
573 Boolean is_target:1;
748 union Body {
749 struct _Macro macro;
750 struct Conditional conditional;
751 struct Line line;
752 struct Makefile makefile;
753 struct Member member;
754 struct Recursive recursive;
755 struct Sccs sccs;
756 struct Suffix suffix;
757 struct Target target;
758 struct STime time;
759 struct Vpath_alias vpath_alias;
760 struct Long_member_name long_member_name;
761 struct _Macro_appendix macro_appendix;
762 struct _Env_mem env_mem;
763 };
764
765 #define PROPERTY_HEAD_SIZE (sizeof (struct _Property)-sizeof (union Body))
766 struct _Property {
767 struct _Property *next;
768 #if defined(HP_UX) || defined(linux)
769 Property_id type;
770 #else
771 Property_id type:4;
772 #endif
773 union Body body;
774 };
775
776 /* Structure for dynamic "ascii" arrays */
777 struct ASCII_Dyn_Array {
778 char *start;
779 size_t size;
780 };
781
782 struct _Envvar {
783 struct _Name *name;
784 struct _Name *value;
785 struct _Envvar *next;
786 char *env_string;
787 Boolean already_put:1;
788 };
789
790 /*
791 * Macros for the reader
792 */
|
26 */
27
28 /*
29 * This is not "#ifdef TEAMWARE_MAKE_CMN" because we're currently
30 * using the TW fake i18n headers and libraries to build both
31 * SMake and PMake on SPARC/S1 and x86/S2.
32 */
33
34 #include <avo/intl.h>
35 #include <limits.h> /* MB_LEN_MAX */
36 #include <stdio.h>
37 #include <stdlib.h> /* wchar_t */
38 #include <string.h> /* strcmp() */
39 #include <nl_types.h> /* catgets() */
40 #include <sys/param.h> /* MAXPATHLEN */
41 #include <sys/types.h> /* time_t, caddr_t */
42 #include <vroot/vroot.h> /* pathpt */
43 #include <sys/time.h> /* timestruc_t */
44 #include <errno.h> /* errno */
45
46 #include <wctype.h>
47 #include <widec.h>
48
49
50 /*
51 * A type and some utilities for boolean values
52 */
53
54 #define false BOOLEAN_false
55 #define true BOOLEAN_true
56
57 typedef enum {
58 false = 0,
59 true = 1,
60 failed = 0,
61 succeeded = 1
62 } Boolean;
63 #define BOOLEAN(expr) ((expr) ? true : false)
64
65 /*
66 * Some random constants (in an enum so dbx knows their values)
67 */
68 enum {
69 update_delay = 30, /* time between rstat checks */
70 ar_member_name_len = 1024,
71 hashsize = 2048 /* size of hash table */
72 };
73
74
75 /*
76 * Symbols that defines all the different char constants make uses
77 */
78 enum {
79 ampersand_char = '&',
80 asterisk_char = '*',
81 at_char = '@',
82 backquote_char = '`',
83 backslash_char = '\\',
84 bar_char = '|',
85 braceleft_char = '{',
86 braceright_char = '}',
87 bracketleft_char = '[',
88 bracketright_char = ']',
89 colon_char = ':',
90 comma_char = ',',
351 sccs_get_special,
352 silent_special,
353 suffixes_special,
354 svr4_special,
355 localhost_special
356 } Special;
357
358 typedef enum {
359 no_colon,
360 one_colon,
361 two_colon,
362 equal_seen,
363 conditional_seen,
364 none_seen
365 } Separator;
366
367 /*
368 * Magic values for the timestamp stored with each name object
369 */
370
371
372 extern const timestruc_t file_no_time;
373 extern const timestruc_t file_doesnt_exist;
374 extern const timestruc_t file_is_dir;
375 extern const timestruc_t file_min_time;
376 extern const timestruc_t file_max_time;
377
378 /*
379 * Each Name has a list of properties
380 * The properties are used to store information that only
381 * a subset of the Names need
382 */
383 typedef enum {
384 no_prop,
385 conditional_prop,
386 line_prop,
387 macro_prop,
388 makefile_prop,
389 member_prop,
390 recursive_prop,
415 struct _Macro {
416 /*
417 * For "ABC = xyz" constructs
418 * Name "ABC" get one macro prop
419 */
420 struct _Name *value;
421 #ifdef NSE
422 Boolean imported:1;
423 #endif
424 Boolean exported:1;
425 Boolean read_only:1;
426 /*
427 * This macro is defined conditionally
428 */
429 Boolean is_conditional:1;
430 /*
431 * The list for $? is stored as a structured list that
432 * is translated into a string iff it is referenced.
433 * This is why some macro values need a daemon.
434 */
435 Daemon daemon:2;
436 };
437
438 struct _Macro_list {
439 struct _Macro_list *next;
440 char *macro_name;
441 char *value;
442 };
443
444 enum sccs_stat {
445 DONT_KNOW_SCCS = 0,
446 NO_SCCS,
447 HAS_SCCS
448 };
449
450 struct _Name {
451 struct _Property *prop; /* List of properties */
452 char *string_mb; /* Multi-byte name string */
453 struct {
454 unsigned int length;
455 } hash;
456 struct {
457 timestruc_t time; /* Modification */
458 int stat_errno; /* error from "stat" */
459 off_t size; /* Of file */
460 mode_t mode; /* Of file */
461 Boolean is_file:1;
462 Boolean is_dir:1;
463 Boolean is_sym_link:1;
464 Boolean is_precious:1;
465 #ifdef NSE
466 Boolean is_derived_src:1;
467 #endif
468 enum sccs_stat has_sccs:2;
469 } stat;
470 /*
471 * Count instances of :: definitions for this target
472 */
473 short colon_splits;
474 /*
475 * We only clear the automatic depes once per target per report
476 */
477 short temp_file_number;
478 /*
479 * Count how many conditional macros this target has defined
480 */
481 short conditional_cnt;
482 /*
483 * A conditional macro was used when building this target
484 */
485 Boolean depends_on_conditional:1;
486 /*
487 * Pointer to list of conditional macros which were used to build
488 * this target
489 */
490 struct _Macro_list *conditional_macro_list;
491 Boolean has_member_depe:1;
492 Boolean is_member:1;
493 /*
494 * This target is a directory that has been read
495 */
496 Boolean has_read_dir:1;
497 /*
498 * This name is a macro that is now being expanded
499 */
500 Boolean being_expanded:1;
501 /*
502 * This name is a magic name that the reader must know about
503 */
504 Special special_reader:5;
505 Doname state:3;
506 Separator colons:3;
507 Boolean has_depe_list_expanded:1;
508 Boolean suffix_scan_done:1;
509 Boolean has_complained:1; /* For sccs */
510 /*
511 * This target has been built during this make run
512 */
513 Boolean ran_command:1;
514 Boolean with_squiggle:1; /* for .SUFFIXES */
515 Boolean without_squiggle:1; /* for .SUFFIXES */
516 Boolean has_read_suffixes:1; /* Suffix list cached*/
517 Boolean has_suffixes:1;
518 Boolean has_target_prop:1;
519 Boolean has_vpath_alias_prop:1;
520 Boolean dependency_printed:1; /* For dump_make_state() */
521 Boolean dollar:1; /* In namestring */
522 Boolean meta:1; /* In namestring */
523 Boolean percent:1; /* In namestring */
524 Boolean wildcard:1; /* In namestring */
525 Boolean has_parent:1;
526 Boolean is_target:1;
701 union Body {
702 struct _Macro macro;
703 struct Conditional conditional;
704 struct Line line;
705 struct Makefile makefile;
706 struct Member member;
707 struct Recursive recursive;
708 struct Sccs sccs;
709 struct Suffix suffix;
710 struct Target target;
711 struct STime time;
712 struct Vpath_alias vpath_alias;
713 struct Long_member_name long_member_name;
714 struct _Macro_appendix macro_appendix;
715 struct _Env_mem env_mem;
716 };
717
718 #define PROPERTY_HEAD_SIZE (sizeof (struct _Property)-sizeof (union Body))
719 struct _Property {
720 struct _Property *next;
721 Property_id type:4;
722 union Body body;
723 };
724
725 /* Structure for dynamic "ascii" arrays */
726 struct ASCII_Dyn_Array {
727 char *start;
728 size_t size;
729 };
730
731 struct _Envvar {
732 struct _Name *name;
733 struct _Name *value;
734 struct _Envvar *next;
735 char *env_string;
736 Boolean already_put:1;
737 };
738
739 /*
740 * Macros for the reader
741 */
|