Print this page
make: translate using gettext, rather than the unmaintainable catgets


  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 
  27 /*
  28  *      mksh.cc
  29  *
  30  *      Execute the command(s) of one Make or DMake rule
  31  */
  32 
  33 /*
  34  * Included files
  35  */
  36 #include <mksh/dosys.h>           /* redirect_io() */
  37 #include <mksh/misc.h>            /* retmem() */
  38 #include <mksh/mksh.h>
  39 #include <mksdmsi18n/mksdmsi18n.h>
  40 #include <errno.h>
  41 #include <signal.h>
  42 
  43 
  44 /*
  45  * Workaround for NFS bug. Sometimes, when running 'chdir' on a remote
  46  * dmake server, it fails with "Stale NFS file handle" error.
  47  * The second attempt seems to work.
  48  */
  49 int
  50 my_chdir(char * dir) {
  51         int res = chdir(dir);
  52         if (res != 0 && (errno == ESTALE || errno == EAGAIN)) {
  53                 /* Stale NFS file handle. Try again */
  54                 res = chdir(dir);
  55         }
  56         return res;
  57 }
  58 
  59 


  64 static void     init_mksh_globals(char *shell);
  65 static void     set_env_vars(char *env_list[]);
  66 
  67 
  68 static void
  69 set_env_vars(char *env_list[])
  70 {
  71         char                    **env_list_p;
  72 
  73         for (env_list_p = env_list;
  74              *env_list_p != (char *) NULL;
  75              env_list_p++) {
  76                 putenv(*env_list_p);
  77         }
  78 }
  79 
  80 static void
  81 init_mksh_globals(char *shell)
  82 {
  83 /*
  84         MBSTOWCS(wcs_buffer, NOCATGETS("SHELL"));
  85         shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
  86         MBSTOWCS(wcs_buffer, shell);
  87         (void) SETVAR(shell_name, GETNAME(wcs_buffer, FIND_LENGTH), false);
  88  */
  89         char * dmake_shell;
  90         if ((dmake_shell = getenv(NOCATGETS("DMAKE_SHELL"))) == NULL) {
  91                 dmake_shell = shell;
  92         } 
  93         MBSTOWCS(wcs_buffer, dmake_shell);
  94         shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
  95 }
  96 
  97 /*
  98  * Change the pathname in the value of the SUNPRO_DEPENDENCIES env variable
  99  * from oldpath to newpath.
 100  */
 101 static void
 102 change_sunpro_dependencies_value(char *oldpath, char *newpath)
 103 {
 104         char            buf[MAXPATHLEN];
 105         static char     *env;
 106         int             length;
 107         int             oldpathlen;
 108         char            *sp_dep_value;
 109 
 110         /* check if SUNPRO_DEPENDENCIES is set in the environment */
 111         if ((sp_dep_value = getenv(NOCATGETS("SUNPRO_DEPENDENCIES"))) != NULL) {
 112                 oldpathlen = strlen(oldpath);
 113                 /* check if oldpath is indeed in the value of SUNPRO_DEPENDENCIES */
 114                 if (strncmp(oldpath, sp_dep_value, oldpathlen) == 0) {
 115                         (void) sprintf(buf,
 116                                        "%s%s",
 117                                        newpath,
 118                                        sp_dep_value + oldpathlen);
 119                         length = 2 +
 120                                 strlen(NOCATGETS("SUNPRO_DEPENDENCIES")) +
 121                                 strlen(buf);
 122                         env = getmem(length);
 123                         (void) sprintf(env,
 124                                        "%s=%s",
 125                                        NOCATGETS("SUNPRO_DEPENDENCIES"),
 126                                        buf);
 127                         (void) putenv(env);
 128                 }
 129         }
 130 }
 131 
 132 


  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 
  27 /*
  28  *      mksh.cc
  29  *
  30  *      Execute the command(s) of one Make or DMake rule
  31  */
  32 
  33 /*
  34  * Included files
  35  */
  36 #include <mksh/dosys.h>           /* redirect_io() */
  37 #include <mksh/misc.h>            /* retmem() */
  38 #include <mksh/mksh.h>

  39 #include <errno.h>
  40 #include <signal.h>
  41 
  42 
  43 /*
  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.
  47  */
  48 int
  49 my_chdir(char * dir) {
  50         int res = chdir(dir);
  51         if (res != 0 && (errno == ESTALE || errno == EAGAIN)) {
  52                 /* Stale NFS file handle. Try again */
  53                 res = chdir(dir);
  54         }
  55         return res;
  56 }
  57 
  58 


  63 static void     init_mksh_globals(char *shell);
  64 static void     set_env_vars(char *env_list[]);
  65 
  66 
  67 static void
  68 set_env_vars(char *env_list[])
  69 {
  70         char                    **env_list_p;
  71 
  72         for (env_list_p = env_list;
  73              *env_list_p != (char *) NULL;
  74              env_list_p++) {
  75                 putenv(*env_list_p);
  76         }
  77 }
  78 
  79 static void
  80 init_mksh_globals(char *shell)
  81 {
  82 /*
  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);
  87  */
  88         char * dmake_shell;
  89         if ((dmake_shell = getenv("DMAKE_SHELL")) == NULL) {
  90                 dmake_shell = shell;
  91         } 
  92         MBSTOWCS(wcs_buffer, dmake_shell);
  93         shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
  94 }
  95 
  96 /*
  97  * Change the pathname in the value of the SUNPRO_DEPENDENCIES env variable
  98  * from oldpath to newpath.
  99  */
 100 static void
 101 change_sunpro_dependencies_value(char *oldpath, char *newpath)
 102 {
 103         char            buf[MAXPATHLEN];
 104         static char     *env;
 105         int             length;
 106         int             oldpathlen;
 107         char            *sp_dep_value;
 108 
 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) {
 114                         (void) sprintf(buf,
 115                                        "%s%s",
 116                                        newpath,
 117                                        sp_dep_value + oldpathlen);
 118                         length = 2 +
 119                                 strlen("SUNPRO_DEPENDENCIES") +
 120                                 strlen(buf);
 121                         env = getmem(length);
 122                         (void) sprintf(env,
 123                                        "%s=%s",
 124                                        "SUNPRO_DEPENDENCIES",
 125                                        buf);
 126                         (void) putenv(env);
 127                 }
 128         }
 129 }
 130 
 131