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 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
30 * Execute the command(s) of one Make or DMake rule
36 #include <mksh/dosys.h> /* redirect_io() */
37 #include <mksh/misc.h> /* retmem() */
38 #include <mksh/mksh.h>
44 * Workaround for NFS bug. Sometimes, when running 'chdir' on a remote
45 * dmake server, it fails with "Stale NFS file handle" error.
46 * The second attempt seems to work.
49 my_chdir(char * dir
) {
51 if (res
!= 0 && (errno
== ESTALE
|| errno
== EAGAIN
)) {
52 /* Stale NFS file handle. Try again */
60 * File table of contents
62 static void change_sunpro_dependencies_value(char *oldpath
, char *newpath
);
63 static void init_mksh_globals(char *shell
);
64 static void set_env_vars(char *env_list
[]);
68 set_env_vars(char *env_list
[])
72 for (env_list_p
= env_list
;
73 *env_list_p
!= (char *) NULL
;
80 init_mksh_globals(char *shell
)
83 MBSTOWCS(wcs_buffer, "SHELL");
84 shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
85 MBSTOWCS(wcs_buffer, shell);
86 (void) SETVAR(shell_name, GETNAME(wcs_buffer, FIND_LENGTH), false);
89 if ((dmake_shell
= getenv("DMAKE_SHELL")) == NULL
) {
92 MBSTOWCS(wcs_buffer
, dmake_shell
);
93 shell_name
= GETNAME(wcs_buffer
, FIND_LENGTH
);
97 * Change the pathname in the value of the SUNPRO_DEPENDENCIES env variable
98 * from oldpath to newpath.
101 change_sunpro_dependencies_value(char *oldpath
, char *newpath
)
103 char buf
[MAXPATHLEN
];
109 /* check if SUNPRO_DEPENDENCIES is set in the environment */
110 if ((sp_dep_value
= getenv("SUNPRO_DEPENDENCIES")) != NULL
) {
111 oldpathlen
= strlen(oldpath
);
112 /* check if oldpath is indeed in the value of SUNPRO_DEPENDENCIES */
113 if (strncmp(oldpath
, sp_dep_value
, oldpathlen
) == 0) {
117 sp_dep_value
+ oldpathlen
);
119 strlen("SUNPRO_DEPENDENCIES") +
121 env
= getmem(length
);
124 "SUNPRO_DEPENDENCIES",