Print this page
make: remove SCCS ident stuff
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/lib/mksh/src/mksh.cc
+++ new/usr/src/cmd/make/lib/mksh/src/mksh.cc
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 -/*
26 - * @(#)mksh.cc 1.22 06/12/12
27 - */
28 25
29 -#pragma ident "@(#)mksh.cc 1.22 06/12/12"
30 26
31 27 /*
32 28 * mksh.cc
33 29 *
34 30 * Execute the command(s) of one Make or DMake rule
35 31 */
36 32
37 33 /*
38 34 * Included files
39 35 */
40 36 #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL) /* tolik */
41 37 # include <avo/util.h>
42 38 #endif
43 39
44 40 #include <mksh/dosys.h> /* redirect_io() */
45 41 #include <mksh/misc.h> /* retmem() */
46 42 #include <mksh/mksh.h>
47 43 #include <mksdmsi18n/mksdmsi18n.h>
48 44 #include <errno.h>
49 45 #include <signal.h>
50 46
51 47 #ifdef HP_UX
52 48 extern void (*sigset(int, void (*)(__harg)))(__harg);
53 49 #endif
54 50
55 51 /*
56 52 * Workaround for NFS bug. Sometimes, when running 'chdir' on a remote
57 53 * dmake server, it fails with "Stale NFS file handle" error.
58 54 * The second attempt seems to work.
59 55 */
60 56 int
61 57 my_chdir(char * dir) {
62 58 int res = chdir(dir);
63 59 if (res != 0 && (errno == ESTALE || errno == EAGAIN)) {
64 60 /* Stale NFS file handle. Try again */
65 61 res = chdir(dir);
66 62 }
67 63 return res;
68 64 }
69 65
70 66
71 67 /*
72 68 * File table of contents
73 69 */
74 70 static void change_sunpro_dependencies_value(char *oldpath, char *newpath);
75 71 static void init_mksh_globals(char *shell);
76 72 static void set_env_vars(char *env_list[]);
77 73
78 74 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
79 75 /*
80 76 * Execute the command(s) of one Make or DMake rule
81 77 */
82 78 int
83 79 do_job(Avo_DmakeCommand *cmd_list[], char *env_list[], char *stdout_file, char *stderr_file, char *cwd, char *cnwd, int ignore, int silent, pathpt vroot_path, char *shell, int nice_prio)
84 80 {
85 81 Boolean always_exec_flag;
86 82 char *cmd;
87 83 Avo_DmakeCommand **cmd_list_p;
88 84 Name command;
89 85 Boolean do_not_exec_flag;
90 86 Boolean ignore_flag;
91 87 int length;
92 88 Boolean make_refd_flag;
93 89 Boolean meta_flag;
94 90 char pathname[MAXPATHLEN];
95 91 Doname result;
96 92 Boolean silent_flag;
97 93 wchar_t *tmp_wcs_buffer;
98 94
99 95 if ((childPid = fork()) < 0) { /* error */
100 96 ;
101 97 } else if (childPid > 0) { /* parent */
102 98 ;
103 99 } else { /* child, mksh */
104 100 (void) sigset(SIGCHLD, SIG_DFL);
105 101 enable_interrupt(handle_interrupt_mksh);
106 102 /* set environment variables */
107 103 set_env_vars(env_list);
108 104 /* redirect stdout and stderr to temp files */
109 105 dup2(1, 2); // Because fatal_mksh() prints error messages into
110 106 // stderr but dmake uses stderr for XDR communications
111 107 // and stdout for errors messages.
112 108 redirect_io(stdout_file, stderr_file);
113 109 /* try cd'ing to cwd */
114 110 if (my_chdir(cwd) != 0) {
115 111 /* try the netpath machine:pathname */
116 112 if (!avo_netpath_to_path(cnwd, pathname)) {
117 113 fatal_mksh(catgets(libmksdmsi18n_catd, 1, 137, "`cd %s' failed, and conversion of %s to automounter pathname also failed: %s"), cwd, cnwd, strerror(errno));
118 114 } else if (my_chdir(pathname) != 0) {
119 115 fatal_mksh(catgets(libmksdmsi18n_catd, 1, 138, "`cd %s' and `cd %s' both failed: %s"), cwd, pathname, strerror(errno));
120 116 }
121 117 /*
122 118 * change the value of SUNPRO_DEPENDENCIES
123 119 * to the new path.
124 120 */
125 121 change_sunpro_dependencies_value(cwd, pathname);
126 122 }
127 123 init_mksh_globals(shell);
128 124 for (cmd_list_p = cmd_list;
129 125 *cmd_list_p != (Avo_DmakeCommand *) NULL;
130 126 cmd_list_p++) {
131 127 if ((*cmd_list_p)->ignore()) {
132 128 ignore_flag = true;
133 129 } else {
134 130 ignore_flag = false;
135 131 }
136 132 if ((*cmd_list_p)->silent()) {
137 133 silent_flag = true;
138 134 } else {
139 135 silent_flag = false;
140 136 }
141 137 /*
142 138 if ((*cmd_list_p)->always_exec()) {
143 139 always_exec_flag = true;
144 140 } else {
145 141 always_exec_flag = false;
146 142 }
147 143 */
148 144 always_exec_flag = false;
149 145 if ((*cmd_list_p)->meta()) {
150 146 meta_flag = true;
151 147 } else {
152 148 meta_flag = false;
153 149 }
154 150 if ((*cmd_list_p)->make_refd()) {
155 151 make_refd_flag = true;
156 152 } else {
157 153 make_refd_flag = false;
158 154 }
159 155 if ((*cmd_list_p)->do_not_exec()) {
160 156 do_not_exec_flag = true;
161 157 } else {
162 158 do_not_exec_flag = false;
163 159 }
164 160 do_not_exec_rule = do_not_exec_flag;
165 161 cmd = (*cmd_list_p)->getCmd();
166 162 if ((length = strlen(cmd)) >= MAXPATHLEN) {
167 163 tmp_wcs_buffer = ALLOC_WC(length + 1);
168 164 (void) mbstowcs(tmp_wcs_buffer, cmd, length + 1);
169 165 command = GETNAME(tmp_wcs_buffer, FIND_LENGTH);
170 166 retmem(tmp_wcs_buffer);
171 167 } else {
172 168 MBSTOWCS(wcs_buffer, cmd);
173 169 command = GETNAME(wcs_buffer, FIND_LENGTH);
174 170 }
175 171 if ((command->hash.length > 0) &&
176 172 (!silent_flag || do_not_exec_flag)) {
177 173 (void) printf("%s\n", command->string_mb);
178 174 }
179 175 result = dosys_mksh(command,
180 176 ignore_flag,
181 177 make_refd_flag,
182 178 false, /* bugs #4085164 & #4990057 */
183 179 /* BOOLEAN(silent_flag && ignore_flag), */
184 180 always_exec_flag,
185 181 (Name) NULL,
186 182 false,
187 183 NULL,
188 184 NULL,
189 185 vroot_path,
190 186 nice_prio);
191 187 if (result == build_failed) {
192 188
193 189 #ifdef PRINT_EXIT_STATUS
194 190 warning_mksh(NOCATGETS("I'm in do_job(), and dosys_mksh() returned result of build_failed."));
195 191 #endif
196 192
197 193 if (silent_flag) {
198 194 (void) printf(catgets(libmksdmsi18n_catd, 1, 139, "The following command caused the error:\n%s\n"),
199 195 command->string_mb);
200 196 }
201 197 if (!ignore_flag && !ignore) {
202 198
203 199 #ifdef PRINT_EXIT_STATUS
204 200 warning_mksh(NOCATGETS("I'm in do_job(), and dosys_mksh() returned result of build_failed, exiting 1."));
205 201 #endif
206 202
207 203 exit(1);
208 204 }
209 205 }
210 206 }
211 207
212 208 #ifdef PRINT_EXIT_STATUS
213 209 warning_mksh(NOCATGETS("I'm in do_job(), exiting 0."));
214 210 #endif
215 211
216 212 exit(0);
217 213 }
218 214 return childPid;
219 215 }
220 216 #endif /* TEAMWARE_MAKE_CMN */
221 217
222 218 static void
223 219 set_env_vars(char *env_list[])
224 220 {
225 221 char **env_list_p;
226 222
227 223 for (env_list_p = env_list;
228 224 *env_list_p != (char *) NULL;
229 225 env_list_p++) {
230 226 putenv(*env_list_p);
231 227 }
232 228 }
233 229
234 230 static void
235 231 init_mksh_globals(char *shell)
236 232 {
237 233 /*
238 234 MBSTOWCS(wcs_buffer, NOCATGETS("SHELL"));
239 235 shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
240 236 MBSTOWCS(wcs_buffer, shell);
241 237 (void) SETVAR(shell_name, GETNAME(wcs_buffer, FIND_LENGTH), false);
242 238 */
243 239 char * dmake_shell;
244 240 if ((dmake_shell = getenv(NOCATGETS("DMAKE_SHELL"))) == NULL) {
245 241 dmake_shell = shell;
246 242 }
247 243 MBSTOWCS(wcs_buffer, dmake_shell);
248 244 shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
249 245 }
250 246
251 247 /*
252 248 * Change the pathname in the value of the SUNPRO_DEPENDENCIES env variable
253 249 * from oldpath to newpath.
254 250 */
255 251 static void
256 252 change_sunpro_dependencies_value(char *oldpath, char *newpath)
257 253 {
258 254 char buf[MAXPATHLEN];
259 255 static char *env;
260 256 int length;
261 257 int oldpathlen;
262 258 char *sp_dep_value;
263 259
264 260 /* check if SUNPRO_DEPENDENCIES is set in the environment */
265 261 if ((sp_dep_value = getenv(NOCATGETS("SUNPRO_DEPENDENCIES"))) != NULL) {
266 262 oldpathlen = strlen(oldpath);
267 263 /* check if oldpath is indeed in the value of SUNPRO_DEPENDENCIES */
268 264 if (strncmp(oldpath, sp_dep_value, oldpathlen) == 0) {
269 265 (void) sprintf(buf,
270 266 "%s%s",
271 267 newpath,
272 268 sp_dep_value + oldpathlen);
273 269 length = 2 +
274 270 strlen(NOCATGETS("SUNPRO_DEPENDENCIES")) +
275 271 strlen(buf);
276 272 env = getmem(length);
277 273 (void) sprintf(env,
278 274 "%s=%s",
279 275 NOCATGETS("SUNPRO_DEPENDENCIES"),
280 276 buf);
281 277 (void) putenv(env);
282 278 }
283 279 }
284 280 }
285 281
286 282
↓ open down ↓ |
247 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX