66 #include <locale.h> /* setlocale() */
67 #include <mk/defs.h>
68 #include <mksdmsi18n/mksdmsi18n.h> /* libmksdmsi18n_init() */
69 #include <mksh/macro.h> /* getvar() */
70 #include <mksh/misc.h> /* getmem(), setup_char_semantics() */
71
72 #if defined(TEAMWARE_MAKE_CMN)
73 #ifdef USE_DMS_CCR
74 # include <pubdmsi18n/pubdmsi18n.h> /* libpubdmsi18n_init() */
75 #endif
76 #endif
77
78 #include <pwd.h> /* getpwnam() */
79 #include <setjmp.h>
80 #include <signal.h>
81 #include <stdlib.h>
82 #include <sys/errno.h> /* ENOENT */
83 #include <sys/stat.h> /* fstat() */
84 #include <fcntl.h> /* open() */
85
86 #ifdef SUN5_0
87 # include <sys/systeminfo.h> /* sysinfo() */
88 #endif
89
90 #include <sys/types.h> /* stat() */
91 #include <sys/wait.h> /* wait() */
92 #include <unistd.h> /* execv(), unlink(), access() */
93 #include <vroot/report.h> /* report_dependency(), get_report_file() */
94
95 // From read2.cc
96 extern Name normalize_name(register wchar_t *name_string, register int length);
97
98 // From parallel.cc
99 #if defined(TEAMWARE_MAKE_CMN)
100 #define MAXJOBS_ADJUST_RFE4694000
101
102 #ifdef MAXJOBS_ADJUST_RFE4694000
103 extern void job_adjust_fini();
104 #endif /* MAXJOBS_ADJUST_RFE4694000 */
105 #endif /* TEAMWARE_MAKE_CMN */
106
107 #if defined(linux)
108 #include <ctype.h>
145 static Boolean trace_status; /* `-p' */
146
147 #ifdef DMAKE_STATISTICS
148 static Boolean getname_stat = false;
149 #endif
150
151 #if defined(TEAMWARE_MAKE_CMN)
152 static time_t start_time;
153 static int g_argc;
154 static char **g_argv;
155 #ifdef USE_DMS_CCR
156 static Avo_usage_tracking *usageTracking = NULL;
157 #else
158 static Avo_cleanup *cleanup = NULL;
159 #endif
160 #endif
161
162 /*
163 * File table of contents
164 */
165 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
166 extern "C" void cleanup_after_exit(void);
167 #else
168 extern void cleanup_after_exit(int, ...);
169 #endif
170
171 #ifdef TEAMWARE_MAKE_CMN
172 extern "C" {
173 extern void dmake_exit_callback(void);
174 extern void dmake_message_callback(char *);
175 }
176 #endif
177
178 extern Name normalize_name(register wchar_t *name_string, register int length);
179
180 extern int main(int, char * []);
181
182 static void append_makeflags_string(Name, String);
183 static void doalarm(int);
184 static void enter_argv_values(int , char **, ASCII_Dyn_Array *);
185 static void make_targets(int, char **, Boolean);
186 static int parse_command_option(char);
187 static void read_command_options(int, char **);
188 static void read_environment(Boolean);
189 static void read_files_and_state(int, char **);
472 if ((out_stat.st_dev == err_stat.st_dev) &&
473 (out_stat.st_ino == err_stat.st_ino)) {
474 stdout_stderr_same = true;
475 } else {
476 stdout_stderr_same = false;
477 }
478 #else
479 stdout_stderr_same = false;
480 #endif
481 /* Make the vroot package scan the path using shell semantics */
482 set_path_style(0);
483
484 setup_char_semantics();
485
486 setup_for_projectdir();
487
488 /*
489 * If running with .KEEP_STATE, curdir will be set with
490 * the connected directory.
491 */
492 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
493 (void) atexit(cleanup_after_exit);
494 #else
495 (void) on_exit(cleanup_after_exit, (char *) NULL);
496 #endif
497
498 load_cached_names();
499
500 /*
501 * Set command line flags
502 */
503 setup_makeflags_argv();
504 read_command_options(mf_argc, mf_argv);
505 read_command_options(argc, argv);
506 if (debug_level > 0) {
507 cp = getenv(makeflags->string_mb);
508 (void) printf(catgets(catd, 1, 167, "MAKEFLAGS value: %s\n"), cp == NULL ? "" : cp);
509 }
510
511 setup_interrupt(handle_interrupt);
512
513 read_files_and_state(argc, argv);
514
515 #ifdef TEAMWARE_MAKE_CMN
516 /*
725 }
726
727 /*
728 * Make sure SUNPRO_DEPENDENCIES is exported (or not) properly
729 * and NSE_DEP.
730 */
731 if (keep_state) {
732 maybe_append_prop(sunpro_dependencies, macro_prop)->
733 body.macro.exported = true;
734 #ifdef NSE
735 (void) setenv(NOCATGETS("NSE_DEP"), get_current_path());
736 #endif
737 } else {
738 maybe_append_prop(sunpro_dependencies, macro_prop)->
739 body.macro.exported = false;
740 }
741
742 working_on_targets = true;
743 if (trace_status) {
744 dump_make_state();
745 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
746 fclose(stdout);
747 fclose(stderr);
748 exit_status = 0;
749 #endif
750 exit(0);
751 }
752 if (list_all_targets) {
753 dump_target_list();
754 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
755 fclose(stdout);
756 fclose(stderr);
757 exit_status = 0;
758 #endif
759 exit(0);
760 }
761 trace_reader = false;
762
763 /*
764 * Set temp_file_directory to the directory the .make.state
765 * file is written to.
766 */
767 if ((slash_ptr = strrchr(make_state->string_mb, (int) slash_char)) == NULL) {
768 temp_file_directory = strdup(get_current_path());
769 } else {
770 *slash_ptr = (int) nul_char;
771 (void) strcpy(make_state_dir, make_state->string_mb);
772 *slash_ptr = (int) slash_char;
773 /* when there is only one slash and it's the first
774 ** character, make_state_dir should point to '/'.
775 */
776 if(make_state_dir[0] == '\0') {
777 make_state_dir[0] = '/';
778 make_state_dir[1] = '\0';
787 get_current_path(),
788 make_state_dir);
789 temp_file_directory = strdup(tmp_current_path2);
790 }
791 }
792
793 #ifdef DISTRIBUTED
794 building_serial = false;
795 #endif
796
797 report_dir_enter_leave(true);
798
799 make_targets(argc, argv, parallel_flag);
800
801 report_dir_enter_leave(false);
802
803 #ifdef NSE
804 exit(nse_exit_status());
805 #else
806 if (build_failed_ever_seen) {
807 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
808 if (posix) {
809 exit_status = 1;
810 }
811 #endif
812 exit(1);
813 }
814 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
815 exit_status = 0;
816 #endif
817 exit(0);
818 #endif
819 /* NOTREACHED */
820 }
821
822 /*
823 * cleanup_after_exit()
824 *
825 * Called from exit(), performs cleanup actions.
826 *
827 * Parameters:
828 * status The argument exit() was called with
829 * arg Address of an argument vector to
830 * cleanup_after_exit()
831 *
832 * Global variables used:
833 * command_changed Set if we think .make.state should be rewritten
834 * current_line Is set we set commands_changed
835 * do_not_exec_rule
836 * True if -n flag on
837 * done The Name ".DONE", rule we run
838 * keep_state Set if .KEEP_STATE seen
839 * parallel True if building in parallel
840 * quest If -q is on we do not run .DONE
841 * report_dependencies
842 * True if -P flag on
843 * running_list List of parallel running processes
844 * temp_file_name The temp file is removed, if any
845 * catd the message catalog file
846 * usage_tracking Should have been constructed in main()
847 * should destroyed just before exiting
848 */
849 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
850 extern "C" void
851 cleanup_after_exit(void)
852 #else
853 void cleanup_after_exit(int status, ...)
854 #endif
855 {
856 Running rp;
857 #ifdef NSE
858 char push_cmd[NSE_TFS_PUSH_LEN + 3 +
859 (MAXPATHLEN * MB_LEN_MAX) + 12];
860 char *active;
861 #endif
862
863 extern long getname_bytes_count;
864 extern long getname_names_count;
865 extern long getname_struct_count;
866 extern long freename_bytes_count;
867 extern long freename_names_count;
868 extern long freename_struct_count;
869 extern long other_alloc;
870
871 extern long env_alloc_num;
872 extern long env_alloc_bytes;
873
874
890 printf(NOCATGETS("\n Total used: %ld Kb (%ld bytes)\n"), (getname_struct_count/1000 + getname_bytes_count/1000) - (freename_struct_count/1000 + freename_bytes_count/1000), (getname_struct_count + getname_bytes_count) - (freename_struct_count + freename_bytes_count));
891
892 printf(NOCATGETS("\n>>> Other:\n"));
893 printf(
894 NOCATGETS(" Env (%ld): %ld Kb (%ld bytes)\n"),
895 env_alloc_num,
896 env_alloc_bytes/1000,
897 env_alloc_bytes
898 );
899
900 }
901 #endif
902
903 /*
904 #ifdef DISTRIBUTED
905 if (get_parent() == TRUE) {
906 #endif
907 */
908
909 parallel = false;
910 #ifdef SUN5_0
911 /* If we used the SVR4_MAKE, don't build .DONE or .FAILED */
912 if (!getenv(USE_SVR4_MAKE)){
913 #endif
914 /* Build the target .DONE or .FAILED if we caught an error */
915 if (!quest && !list_all_targets) {
916 Name failed_name;
917
918 MBSTOWCS(wcs_buffer, NOCATGETS(".FAILED"));
919 failed_name = GETNAME(wcs_buffer, FIND_LENGTH);
920 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
921 if ((exit_status != 0) && (failed_name->prop != NULL)) {
922 #else
923 if ((status != 0) && (failed_name->prop != NULL)) {
924 #endif
925 #ifdef TEAMWARE_MAKE_CMN
926 /*
927 * [tolik] switch DMake to serial mode
928 */
929 dmake_mode_type = serial_mode;
930 no_parallel = true;
931 #endif
932 (void) doname(failed_name, false, true);
933 } else {
934 if (!trace_status) {
935 #ifdef TEAMWARE_MAKE_CMN
936 /*
937 * Switch DMake to serial mode
938 */
939 dmake_mode_type = serial_mode;
940 no_parallel = true;
941 #endif
942 (void) doname(done, false, true);
943 }
944 }
945 }
946 #ifdef SUN5_0
947 }
948 #endif
949 /*
950 * Remove the temp file utilities report dependencies thru if it
951 * is still around
952 */
953 if (temp_file_name != NULL) {
954 (void) unlink(temp_file_name->string_mb);
955 }
956 /*
957 * Do not save the current command in .make.state if make
958 * was interrupted.
959 */
960 if (current_line != NULL) {
961 command_changed = true;
962 current_line->body.line.command_used = NULL;
963 }
964 /*
965 * For each parallel build process running, remove the temp files
966 * and zap the command line so it won't be put in .make.state
967 */
968 for (rp = running_list; rp != NULL; rp = rp->next) {
1105 for (rp = running_list; rp != NULL; rp = rp->next) {
1106 if (rp->state != build_running) {
1107 continue;
1108 }
1109 if (rp->pid > 0) {
1110 kill(rp->pid, SIGTERM);
1111 rp->pid = -1;
1112 }
1113 }
1114 if (getpid() == getpgrp()) {
1115 bsd_signal(SIGTERM, SIG_IGN);
1116 kill (-getpid(), SIGTERM);
1117 }
1118 #ifdef TEAMWARE_MAKE_CMN
1119 /* Clean up all parallel/distributed children already finished */
1120 finish_children(false);
1121 #endif
1122
1123 /* Make sure the processes running under us terminate first */
1124
1125 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
1126 while (wait((int *) NULL) != -1);
1127 #else
1128 while (wait((union wait*) NULL) != -1);
1129 #endif
1130 /* Delete the current targets unless they are precious */
1131 if ((current_target != NULL) &&
1132 current_target->is_member &&
1133 ((member = get_prop(current_target->prop, member_prop)) != NULL)) {
1134 current_target = member->body.member.library;
1135 }
1136 if (!do_not_exec_rule &&
1137 !touch &&
1138 !quest &&
1139 (current_target != NULL) &&
1140 !(current_target->stat.is_precious || all_precious)) {
1141
1142 /* BID_1030811 */
1143 /* azv 16 Oct 95 */
1144 current_target->stat.time = file_no_time;
1145
1146 if (exists(current_target) != file_doesnt_exist) {
1147 (void) fprintf(stderr,
1148 "\n*** %s ",
1149 current_target->string_mb);
1210 /* Have we locked .make.state or .nse_depinfo? */
1211 if ((make_state_lockfile != NULL) && (make_state_locked)) {
1212 unlink(make_state_lockfile);
1213 make_state_lockfile = NULL;
1214 make_state_locked = false;
1215 }
1216 #ifdef NSE
1217 if ((nse_depinfo_lockfile[0] != '\0') && (nse_depinfo_locked)) {
1218 unlink(nse_depinfo_lockfile);
1219 nse_depinfo_lockfile[0] = '\0';
1220 nse_depinfo_locked = false;
1221 }
1222 #endif
1223 /*
1224 * Re-read .make.state file (it might be changed by recursive make)
1225 */
1226 check_state(NULL);
1227
1228 report_dir_enter_leave(false);
1229
1230 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
1231 exit_status = 2;
1232 #endif
1233 exit(2);
1234 }
1235
1236 /*
1237 * doalarm(sig, ...)
1238 *
1239 * Handle the alarm interrupt but do nothing. Side effect is to
1240 * cause return from wait3.
1241 *
1242 * Parameters:
1243 * sig
1244 *
1245 * Global variables used:
1246 */
1247 /*ARGSUSED*/
1248 static void
1249 doalarm(int)
1250 {
1251 return;
1252 }
1947 touch = false;
1948 } else {
1949 touch = true;
1950 }
1951 return 0;
1952 case 'u': /* Unconditional flag */
1953 if (invert_this) {
1954 build_unconditional = false;
1955 } else {
1956 build_unconditional = true;
1957 }
1958 return 0;
1959 case 'V': /* SVR4 mode */
1960 svr4 = true;
1961 return 0;
1962 case 'v': /* Version flag */
1963 if (invert_this) {
1964 } else {
1965 #ifdef TEAMWARE_MAKE_CMN
1966 fprintf(stdout, NOCATGETS("dmake: %s\n"), verstring);
1967 #ifdef SUN5_0
1968 exit_status = 0;
1969 #endif
1970 exit(0);
1971 #else
1972 warning(catgets(catd, 1, 324, "Ignoring DistributedMake -v option"));
1973 #endif
1974 }
1975 return 0;
1976 case 'w': /* Unconditional flag */
1977 if (invert_this) {
1978 report_cwd = false;
1979 } else {
1980 report_cwd = true;
1981 }
1982 return 0;
1983 #if 0
1984 case 'X': /* Filter stdout */
1985 if (invert_this) {
1986 filter_stderr = false;
1987 } else {
1988 filter_stderr = true;
1989 }
2201 #ifdef NSE
2202 if (getenv(NOCATGETS("NSE_ENV")) != NULL) {
2203 nse = true;
2204 }
2205 #endif
2206
2207 /*
2208 * initialize global dependency entry for .NOT_AUTO
2209 */
2210 not_auto_depen->next = NULL;
2211 not_auto_depen->name = not_auto;
2212 not_auto_depen->automatic = not_auto_depen->stale = false;
2213
2214 /*
2215 * Read internal definitions and rules.
2216 */
2217 if (read_trace_level > 1) {
2218 trace_reader = true;
2219 }
2220 if (!ignore_default_mk) {
2221 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
2222 if (svr4) {
2223 MBSTOWCS(wcs_buffer, NOCATGETS("svr4.make.rules"));
2224 default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2225 } else {
2226 MBSTOWCS(wcs_buffer, NOCATGETS("make.rules"));
2227 default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2228 }
2229 #else
2230 MBSTOWCS(wcs_buffer, NOCATGETS("default.mk"));
2231 default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2232 #endif
2233 default_makefile->stat.is_file = true;
2234
2235 (void) read_makefile(default_makefile,
2236 true,
2237 false,
2238 true);
2239 }
2240
2241 /*
2242 * If the user did not redefine the MAKE macro in the
2243 * default makefile (make.rules), then we'd like to
2244 * change the macro value of MAKE to be some form
2245 * of argv[0] for recursive MAKE builds.
2246 */
2247 MBSTOWCS(wcs_buffer, NOCATGETS("MAKE"));
2248 def_make_name = GETNAME(wcs_buffer, wslen(wcs_buffer));
2249 def_make_macro = get_prop(def_make_name->prop, macro_prop);
2250 if ((def_make_macro != NULL) &&
2251 (IS_EQUAL(def_make_macro->body.macro.value->string_mb,
2252 NOCATGETS("make")))) {
|
66 #include <locale.h> /* setlocale() */
67 #include <mk/defs.h>
68 #include <mksdmsi18n/mksdmsi18n.h> /* libmksdmsi18n_init() */
69 #include <mksh/macro.h> /* getvar() */
70 #include <mksh/misc.h> /* getmem(), setup_char_semantics() */
71
72 #if defined(TEAMWARE_MAKE_CMN)
73 #ifdef USE_DMS_CCR
74 # include <pubdmsi18n/pubdmsi18n.h> /* libpubdmsi18n_init() */
75 #endif
76 #endif
77
78 #include <pwd.h> /* getpwnam() */
79 #include <setjmp.h>
80 #include <signal.h>
81 #include <stdlib.h>
82 #include <sys/errno.h> /* ENOENT */
83 #include <sys/stat.h> /* fstat() */
84 #include <fcntl.h> /* open() */
85
86 # include <sys/systeminfo.h> /* sysinfo() */
87
88 #include <sys/types.h> /* stat() */
89 #include <sys/wait.h> /* wait() */
90 #include <unistd.h> /* execv(), unlink(), access() */
91 #include <vroot/report.h> /* report_dependency(), get_report_file() */
92
93 // From read2.cc
94 extern Name normalize_name(register wchar_t *name_string, register int length);
95
96 // From parallel.cc
97 #if defined(TEAMWARE_MAKE_CMN)
98 #define MAXJOBS_ADJUST_RFE4694000
99
100 #ifdef MAXJOBS_ADJUST_RFE4694000
101 extern void job_adjust_fini();
102 #endif /* MAXJOBS_ADJUST_RFE4694000 */
103 #endif /* TEAMWARE_MAKE_CMN */
104
105 #if defined(linux)
106 #include <ctype.h>
143 static Boolean trace_status; /* `-p' */
144
145 #ifdef DMAKE_STATISTICS
146 static Boolean getname_stat = false;
147 #endif
148
149 #if defined(TEAMWARE_MAKE_CMN)
150 static time_t start_time;
151 static int g_argc;
152 static char **g_argv;
153 #ifdef USE_DMS_CCR
154 static Avo_usage_tracking *usageTracking = NULL;
155 #else
156 static Avo_cleanup *cleanup = NULL;
157 #endif
158 #endif
159
160 /*
161 * File table of contents
162 */
163 extern "C" void cleanup_after_exit(void);
164
165 #ifdef TEAMWARE_MAKE_CMN
166 extern "C" {
167 extern void dmake_exit_callback(void);
168 extern void dmake_message_callback(char *);
169 }
170 #endif
171
172 extern Name normalize_name(register wchar_t *name_string, register int length);
173
174 extern int main(int, char * []);
175
176 static void append_makeflags_string(Name, String);
177 static void doalarm(int);
178 static void enter_argv_values(int , char **, ASCII_Dyn_Array *);
179 static void make_targets(int, char **, Boolean);
180 static int parse_command_option(char);
181 static void read_command_options(int, char **);
182 static void read_environment(Boolean);
183 static void read_files_and_state(int, char **);
466 if ((out_stat.st_dev == err_stat.st_dev) &&
467 (out_stat.st_ino == err_stat.st_ino)) {
468 stdout_stderr_same = true;
469 } else {
470 stdout_stderr_same = false;
471 }
472 #else
473 stdout_stderr_same = false;
474 #endif
475 /* Make the vroot package scan the path using shell semantics */
476 set_path_style(0);
477
478 setup_char_semantics();
479
480 setup_for_projectdir();
481
482 /*
483 * If running with .KEEP_STATE, curdir will be set with
484 * the connected directory.
485 */
486 (void) atexit(cleanup_after_exit);
487
488 load_cached_names();
489
490 /*
491 * Set command line flags
492 */
493 setup_makeflags_argv();
494 read_command_options(mf_argc, mf_argv);
495 read_command_options(argc, argv);
496 if (debug_level > 0) {
497 cp = getenv(makeflags->string_mb);
498 (void) printf(catgets(catd, 1, 167, "MAKEFLAGS value: %s\n"), cp == NULL ? "" : cp);
499 }
500
501 setup_interrupt(handle_interrupt);
502
503 read_files_and_state(argc, argv);
504
505 #ifdef TEAMWARE_MAKE_CMN
506 /*
715 }
716
717 /*
718 * Make sure SUNPRO_DEPENDENCIES is exported (or not) properly
719 * and NSE_DEP.
720 */
721 if (keep_state) {
722 maybe_append_prop(sunpro_dependencies, macro_prop)->
723 body.macro.exported = true;
724 #ifdef NSE
725 (void) setenv(NOCATGETS("NSE_DEP"), get_current_path());
726 #endif
727 } else {
728 maybe_append_prop(sunpro_dependencies, macro_prop)->
729 body.macro.exported = false;
730 }
731
732 working_on_targets = true;
733 if (trace_status) {
734 dump_make_state();
735 fclose(stdout);
736 fclose(stderr);
737 exit_status = 0;
738 exit(0);
739 }
740 if (list_all_targets) {
741 dump_target_list();
742 fclose(stdout);
743 fclose(stderr);
744 exit_status = 0;
745 exit(0);
746 }
747 trace_reader = false;
748
749 /*
750 * Set temp_file_directory to the directory the .make.state
751 * file is written to.
752 */
753 if ((slash_ptr = strrchr(make_state->string_mb, (int) slash_char)) == NULL) {
754 temp_file_directory = strdup(get_current_path());
755 } else {
756 *slash_ptr = (int) nul_char;
757 (void) strcpy(make_state_dir, make_state->string_mb);
758 *slash_ptr = (int) slash_char;
759 /* when there is only one slash and it's the first
760 ** character, make_state_dir should point to '/'.
761 */
762 if(make_state_dir[0] == '\0') {
763 make_state_dir[0] = '/';
764 make_state_dir[1] = '\0';
773 get_current_path(),
774 make_state_dir);
775 temp_file_directory = strdup(tmp_current_path2);
776 }
777 }
778
779 #ifdef DISTRIBUTED
780 building_serial = false;
781 #endif
782
783 report_dir_enter_leave(true);
784
785 make_targets(argc, argv, parallel_flag);
786
787 report_dir_enter_leave(false);
788
789 #ifdef NSE
790 exit(nse_exit_status());
791 #else
792 if (build_failed_ever_seen) {
793 if (posix) {
794 exit_status = 1;
795 }
796 exit(1);
797 }
798 exit_status = 0;
799 exit(0);
800 #endif
801 /* NOTREACHED */
802 }
803
804 /*
805 * cleanup_after_exit()
806 *
807 * Called from exit(), performs cleanup actions.
808 *
809 * Parameters:
810 * status The argument exit() was called with
811 * arg Address of an argument vector to
812 * cleanup_after_exit()
813 *
814 * Global variables used:
815 * command_changed Set if we think .make.state should be rewritten
816 * current_line Is set we set commands_changed
817 * do_not_exec_rule
818 * True if -n flag on
819 * done The Name ".DONE", rule we run
820 * keep_state Set if .KEEP_STATE seen
821 * parallel True if building in parallel
822 * quest If -q is on we do not run .DONE
823 * report_dependencies
824 * True if -P flag on
825 * running_list List of parallel running processes
826 * temp_file_name The temp file is removed, if any
827 * catd the message catalog file
828 * usage_tracking Should have been constructed in main()
829 * should destroyed just before exiting
830 */
831 extern "C" void
832 cleanup_after_exit(void)
833 {
834 Running rp;
835 #ifdef NSE
836 char push_cmd[NSE_TFS_PUSH_LEN + 3 +
837 (MAXPATHLEN * MB_LEN_MAX) + 12];
838 char *active;
839 #endif
840
841 extern long getname_bytes_count;
842 extern long getname_names_count;
843 extern long getname_struct_count;
844 extern long freename_bytes_count;
845 extern long freename_names_count;
846 extern long freename_struct_count;
847 extern long other_alloc;
848
849 extern long env_alloc_num;
850 extern long env_alloc_bytes;
851
852
868 printf(NOCATGETS("\n Total used: %ld Kb (%ld bytes)\n"), (getname_struct_count/1000 + getname_bytes_count/1000) - (freename_struct_count/1000 + freename_bytes_count/1000), (getname_struct_count + getname_bytes_count) - (freename_struct_count + freename_bytes_count));
869
870 printf(NOCATGETS("\n>>> Other:\n"));
871 printf(
872 NOCATGETS(" Env (%ld): %ld Kb (%ld bytes)\n"),
873 env_alloc_num,
874 env_alloc_bytes/1000,
875 env_alloc_bytes
876 );
877
878 }
879 #endif
880
881 /*
882 #ifdef DISTRIBUTED
883 if (get_parent() == TRUE) {
884 #endif
885 */
886
887 parallel = false;
888 /* If we used the SVR4_MAKE, don't build .DONE or .FAILED */
889 if (!getenv(USE_SVR4_MAKE)){
890 /* Build the target .DONE or .FAILED if we caught an error */
891 if (!quest && !list_all_targets) {
892 Name failed_name;
893
894 MBSTOWCS(wcs_buffer, NOCATGETS(".FAILED"));
895 failed_name = GETNAME(wcs_buffer, FIND_LENGTH);
896 if ((exit_status != 0) && (failed_name->prop != NULL)) {
897 #ifdef TEAMWARE_MAKE_CMN
898 /*
899 * [tolik] switch DMake to serial mode
900 */
901 dmake_mode_type = serial_mode;
902 no_parallel = true;
903 #endif
904 (void) doname(failed_name, false, true);
905 } else {
906 if (!trace_status) {
907 #ifdef TEAMWARE_MAKE_CMN
908 /*
909 * Switch DMake to serial mode
910 */
911 dmake_mode_type = serial_mode;
912 no_parallel = true;
913 #endif
914 (void) doname(done, false, true);
915 }
916 }
917 }
918 }
919 /*
920 * Remove the temp file utilities report dependencies thru if it
921 * is still around
922 */
923 if (temp_file_name != NULL) {
924 (void) unlink(temp_file_name->string_mb);
925 }
926 /*
927 * Do not save the current command in .make.state if make
928 * was interrupted.
929 */
930 if (current_line != NULL) {
931 command_changed = true;
932 current_line->body.line.command_used = NULL;
933 }
934 /*
935 * For each parallel build process running, remove the temp files
936 * and zap the command line so it won't be put in .make.state
937 */
938 for (rp = running_list; rp != NULL; rp = rp->next) {
1075 for (rp = running_list; rp != NULL; rp = rp->next) {
1076 if (rp->state != build_running) {
1077 continue;
1078 }
1079 if (rp->pid > 0) {
1080 kill(rp->pid, SIGTERM);
1081 rp->pid = -1;
1082 }
1083 }
1084 if (getpid() == getpgrp()) {
1085 bsd_signal(SIGTERM, SIG_IGN);
1086 kill (-getpid(), SIGTERM);
1087 }
1088 #ifdef TEAMWARE_MAKE_CMN
1089 /* Clean up all parallel/distributed children already finished */
1090 finish_children(false);
1091 #endif
1092
1093 /* Make sure the processes running under us terminate first */
1094
1095 while (wait((int *) NULL) != -1);
1096 /* Delete the current targets unless they are precious */
1097 if ((current_target != NULL) &&
1098 current_target->is_member &&
1099 ((member = get_prop(current_target->prop, member_prop)) != NULL)) {
1100 current_target = member->body.member.library;
1101 }
1102 if (!do_not_exec_rule &&
1103 !touch &&
1104 !quest &&
1105 (current_target != NULL) &&
1106 !(current_target->stat.is_precious || all_precious)) {
1107
1108 /* BID_1030811 */
1109 /* azv 16 Oct 95 */
1110 current_target->stat.time = file_no_time;
1111
1112 if (exists(current_target) != file_doesnt_exist) {
1113 (void) fprintf(stderr,
1114 "\n*** %s ",
1115 current_target->string_mb);
1176 /* Have we locked .make.state or .nse_depinfo? */
1177 if ((make_state_lockfile != NULL) && (make_state_locked)) {
1178 unlink(make_state_lockfile);
1179 make_state_lockfile = NULL;
1180 make_state_locked = false;
1181 }
1182 #ifdef NSE
1183 if ((nse_depinfo_lockfile[0] != '\0') && (nse_depinfo_locked)) {
1184 unlink(nse_depinfo_lockfile);
1185 nse_depinfo_lockfile[0] = '\0';
1186 nse_depinfo_locked = false;
1187 }
1188 #endif
1189 /*
1190 * Re-read .make.state file (it might be changed by recursive make)
1191 */
1192 check_state(NULL);
1193
1194 report_dir_enter_leave(false);
1195
1196 exit_status = 2;
1197 exit(2);
1198 }
1199
1200 /*
1201 * doalarm(sig, ...)
1202 *
1203 * Handle the alarm interrupt but do nothing. Side effect is to
1204 * cause return from wait3.
1205 *
1206 * Parameters:
1207 * sig
1208 *
1209 * Global variables used:
1210 */
1211 /*ARGSUSED*/
1212 static void
1213 doalarm(int)
1214 {
1215 return;
1216 }
1911 touch = false;
1912 } else {
1913 touch = true;
1914 }
1915 return 0;
1916 case 'u': /* Unconditional flag */
1917 if (invert_this) {
1918 build_unconditional = false;
1919 } else {
1920 build_unconditional = true;
1921 }
1922 return 0;
1923 case 'V': /* SVR4 mode */
1924 svr4 = true;
1925 return 0;
1926 case 'v': /* Version flag */
1927 if (invert_this) {
1928 } else {
1929 #ifdef TEAMWARE_MAKE_CMN
1930 fprintf(stdout, NOCATGETS("dmake: %s\n"), verstring);
1931 exit_status = 0;
1932 exit(0);
1933 #else
1934 warning(catgets(catd, 1, 324, "Ignoring DistributedMake -v option"));
1935 #endif
1936 }
1937 return 0;
1938 case 'w': /* Unconditional flag */
1939 if (invert_this) {
1940 report_cwd = false;
1941 } else {
1942 report_cwd = true;
1943 }
1944 return 0;
1945 #if 0
1946 case 'X': /* Filter stdout */
1947 if (invert_this) {
1948 filter_stderr = false;
1949 } else {
1950 filter_stderr = true;
1951 }
2163 #ifdef NSE
2164 if (getenv(NOCATGETS("NSE_ENV")) != NULL) {
2165 nse = true;
2166 }
2167 #endif
2168
2169 /*
2170 * initialize global dependency entry for .NOT_AUTO
2171 */
2172 not_auto_depen->next = NULL;
2173 not_auto_depen->name = not_auto;
2174 not_auto_depen->automatic = not_auto_depen->stale = false;
2175
2176 /*
2177 * Read internal definitions and rules.
2178 */
2179 if (read_trace_level > 1) {
2180 trace_reader = true;
2181 }
2182 if (!ignore_default_mk) {
2183 if (svr4) {
2184 MBSTOWCS(wcs_buffer, NOCATGETS("svr4.make.rules"));
2185 default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2186 } else {
2187 MBSTOWCS(wcs_buffer, NOCATGETS("make.rules"));
2188 default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2189 }
2190 default_makefile->stat.is_file = true;
2191
2192 (void) read_makefile(default_makefile,
2193 true,
2194 false,
2195 true);
2196 }
2197
2198 /*
2199 * If the user did not redefine the MAKE macro in the
2200 * default makefile (make.rules), then we'd like to
2201 * change the macro value of MAKE to be some form
2202 * of argv[0] for recursive MAKE builds.
2203 */
2204 MBSTOWCS(wcs_buffer, NOCATGETS("MAKE"));
2205 def_make_name = GETNAME(wcs_buffer, wslen(wcs_buffer));
2206 def_make_macro = get_prop(def_make_name->prop, macro_prop);
2207 if ((def_make_macro != NULL) &&
2208 (IS_EQUAL(def_make_macro->body.macro.value->string_mb,
2209 NOCATGETS("make")))) {
|