Print this page
make: unifdef for MAKETOOL and DISTRIBUTED (undefined)


  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]
  18  *
  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  *      macro.cc
  28  *
  29  *      Handle expansion of make macros
  30  */
  31 
  32 /*
  33  * Included files
  34  */
  35 #ifdef DISTRIBUTED
  36 #include <avo/strings.h>  /* AVO_STRDUP() */
  37 #include <dm/Avo_DoJobMsg.h>
  38 #endif
  39 #include <mk/defs.h>
  40 #include <mksh/macro.h>           /* getvar(), expand_value() */
  41 #include <mksh/misc.h>            /* getmem() */
  42 
  43 /*
  44  * Defined macros
  45  */
  46 
  47 /*
  48  * typedefs & structs
  49  */
  50 
  51 /*
  52  * Static variables
  53  */
  54 
  55 /*
  56  * File table of contents
  57  */
  58 


  96         if (destination.free_after_use) {
  97                 retmem(destination.buffer.start);
  98         }
  99         macro_apx->body.macro_appendix.value_to_append = value;
 100 
 101         SETVAR(name, empty_name, true);
 102 }
 103 
 104 /*
 105  *      setvar_envvar()
 106  *
 107  *      This function scans the list of environment variables that have
 108  *      dynamic values and sets them.
 109  *
 110  *      Parameters:
 111  *
 112  *      Global variables used:
 113  *              envvar          A list of environment vars with $ in value
 114  */
 115 void
 116 #ifdef DISTRIBUTED
 117 setvar_envvar(Avo_DoJobMsg *dmake_job_msg)
 118 #else
 119 setvar_envvar(void)
 120 #endif
 121 {
 122         wchar_t                 buffer[STRING_BUFFER_LENGTH];
 123         int                     length;
 124 #ifdef DISTRIBUTED
 125         Property                macro;
 126 #endif
 127         register        char    *mbs, *tmp_mbs_buffer = NULL;
 128         register        char    *env, *tmp_mbs_buffer2 = NULL;
 129         Envvar                  p;
 130         String_rec              value;
 131 
 132         for (p = envvar; p != NULL; p = p->next) {
 133                 if (p->already_put
 134 #ifdef DISTRIBUTED
 135                     && !dmake_job_msg
 136 #endif
 137                     ) {
 138                         continue;
 139                 }
 140                 INIT_STRING_FROM_STACK(value, buffer);          
 141                 expand_value(p->value, &value, false);
 142                 if ((length = wslen(value.buffer.start)) >= MAXPATHLEN) {
 143                         mbs = tmp_mbs_buffer = getmem((length + 1) * MB_LEN_MAX);
 144                         (void) wcstombs(mbs,
 145                                         value.buffer.start,
 146                                         (length + 1) * MB_LEN_MAX);
 147                 } else {
 148                         mbs = mbs_buffer;
 149                         WCSTOMBS(mbs, value.buffer.start);
 150                 }
 151                 length = 2 + strlen(p->name->string_mb) + strlen(mbs);
 152                 if (!p->already_put || length > (MAXPATHLEN * MB_LEN_MAX)) {
 153                         env = tmp_mbs_buffer2 = getmem(length);
 154                 } else {
 155                         env = mbs_buffer2;
 156                 }
 157                 (void) sprintf(env,
 158                                "%s=%s",
 159                                p->name->string_mb,
 160                                mbs);
 161                 if (!p->already_put) {
 162                         (void) putenv(env);
 163                         p->already_put = true;
 164                         if (p->env_string) {
 165                                 retmem_mb(p->env_string);
 166                         }
 167                         p->env_string = env;
 168                         tmp_mbs_buffer2 = NULL; // We should not return this memory now
 169                 }
 170 #ifdef DISTRIBUTED
 171                 if (dmake_job_msg) {
 172                         dmake_job_msg->appendVar(env);
 173                 }
 174 #endif
 175                 if (tmp_mbs_buffer2) {
 176                         retmem_mb(tmp_mbs_buffer2);
 177                         tmp_mbs_buffer2 = NULL;
 178                 }
 179                 if (tmp_mbs_buffer) {
 180                         retmem_mb(tmp_mbs_buffer);
 181                         tmp_mbs_buffer = NULL;
 182                 }
 183         }
 184 #ifdef DISTRIBUTED
 185         /* Append SUNPRO_DEPENDENCIES to the dmake_job_msg. */
 186         if (keep_state && dmake_job_msg) {
 187                 macro = get_prop(sunpro_dependencies->prop, macro_prop);
 188                 length = 2 +
 189                          strlen(sunpro_dependencies->string_mb) +
 190                          strlen(macro->body.macro.value->string_mb);
 191                 if (length > (MAXPATHLEN * MB_LEN_MAX)) {
 192                         env = tmp_mbs_buffer2 = getmem(length);
 193                 } else {
 194                         env = mbs_buffer2;
 195                 }
 196                 (void) sprintf(env,
 197                                "%s=%s",
 198                                sunpro_dependencies->string_mb,
 199                                macro->body.macro.value->string_mb);
 200                 dmake_job_msg->appendVar(env);
 201                 if (tmp_mbs_buffer2) {
 202                         retmem_mb(tmp_mbs_buffer2);
 203                         tmp_mbs_buffer2 = NULL;
 204                 }
 205         }
 206 #endif
 207 }
 208 
 209 


  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]
  18  *
  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  *      macro.cc
  28  *
  29  *      Handle expansion of make macros
  30  */
  31 
  32 /*
  33  * Included files
  34  */




  35 #include <mk/defs.h>
  36 #include <mksh/macro.h>           /* getvar(), expand_value() */
  37 #include <mksh/misc.h>            /* getmem() */
  38 
  39 /*
  40  * Defined macros
  41  */
  42 
  43 /*
  44  * typedefs & structs
  45  */
  46 
  47 /*
  48  * Static variables
  49  */
  50 
  51 /*
  52  * File table of contents
  53  */
  54 


  92         if (destination.free_after_use) {
  93                 retmem(destination.buffer.start);
  94         }
  95         macro_apx->body.macro_appendix.value_to_append = value;
  96 
  97         SETVAR(name, empty_name, true);
  98 }
  99 
 100 /*
 101  *      setvar_envvar()
 102  *
 103  *      This function scans the list of environment variables that have
 104  *      dynamic values and sets them.
 105  *
 106  *      Parameters:
 107  *
 108  *      Global variables used:
 109  *              envvar          A list of environment vars with $ in value
 110  */
 111 void



 112 setvar_envvar(void)

 113 {
 114         wchar_t                 buffer[STRING_BUFFER_LENGTH];
 115         int                     length;



 116         register        char    *mbs, *tmp_mbs_buffer = NULL;
 117         register        char    *env, *tmp_mbs_buffer2 = NULL;
 118         Envvar                  p;
 119         String_rec              value;
 120 
 121         for (p = envvar; p != NULL; p = p->next) {
 122                 if (p->already_put



 123                     ) {
 124                         continue;
 125                 }
 126                 INIT_STRING_FROM_STACK(value, buffer);          
 127                 expand_value(p->value, &value, false);
 128                 if ((length = wslen(value.buffer.start)) >= MAXPATHLEN) {
 129                         mbs = tmp_mbs_buffer = getmem((length + 1) * MB_LEN_MAX);
 130                         (void) wcstombs(mbs,
 131                                         value.buffer.start,
 132                                         (length + 1) * MB_LEN_MAX);
 133                 } else {
 134                         mbs = mbs_buffer;
 135                         WCSTOMBS(mbs, value.buffer.start);
 136                 }
 137                 length = 2 + strlen(p->name->string_mb) + strlen(mbs);
 138                 if (!p->already_put || length > (MAXPATHLEN * MB_LEN_MAX)) {
 139                         env = tmp_mbs_buffer2 = getmem(length);
 140                 } else {
 141                         env = mbs_buffer2;
 142                 }
 143                 (void) sprintf(env,
 144                                "%s=%s",
 145                                p->name->string_mb,
 146                                mbs);
 147                 if (!p->already_put) {
 148                         (void) putenv(env);
 149                         p->already_put = true;
 150                         if (p->env_string) {
 151                                 retmem_mb(p->env_string);
 152                         }
 153                         p->env_string = env;
 154                         tmp_mbs_buffer2 = NULL; // We should not return this memory now
 155                 }





 156                 if (tmp_mbs_buffer2) {
 157                         retmem_mb(tmp_mbs_buffer2);
 158                         tmp_mbs_buffer2 = NULL;
 159                 }
 160                 if (tmp_mbs_buffer) {
 161                         retmem_mb(tmp_mbs_buffer);
 162                         tmp_mbs_buffer = NULL;
 163                 }
 164         }























 165 }
 166 
 167