/[make]/make/main.c
ViewVC logotype

Diff of /make/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.205 by psmith, Sun Jun 12 22:22:07 2005 UTC revision 1.206 by psmith, Sat Jun 25 18:57:28 2005 UTC
# Line 271  int warn_undefined_variables_flag; Line 271  int warn_undefined_variables_flag;
271  /* If nonzero, always build all targets, regardless of whether  /* If nonzero, always build all targets, regardless of whether
272     they appear out of date or not.  */     they appear out of date or not.  */
273    
274    static int always_make_set = 0;
275  int always_make_flag = 0;  int always_make_flag = 0;
276    
277  /* If nonzero, we're in the "try to rebuild makefiles" phase.  */  /* If nonzero, we're in the "try to rebuild makefiles" phase.  */
# Line 362  static const char *const usage[] = Line 363  static const char *const usage[] =
363  static const struct command_switch switches[] =  static const struct command_switch switches[] =
364    {    {
365      { 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },      { 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },
366      { 'B', flag, (char *) &always_make_flag, 1, 1, 0, 0, 0, "always-make" },      { 'B', flag, (char *) &always_make_set, 1, 1, 0, 0, 0, "always-make" },
367      { 'C', string, (char *) &directories, 0, 0, 0, 0, 0, "directory" },      { 'C', string, (char *) &directories, 0, 0, 0, 0, 0, "directory" },
368      { 'd', flag, (char *) &debug_flag, 1, 1, 0, 0, 0, 0 },      { 'd', flag, (char *) &debug_flag, 1, 1, 0, 0, 0, 0 },
369      { CHAR_MAX+1, string, (char *) &db_flags, 1, 1, 0, "basic", 0, "debug" },      { CHAR_MAX+1, string, (char *) &db_flags, 1, 1, 0, "basic", 0, "debug" },
# Line 764  find_and_set_default_shell (char *token) Line 765  find_and_set_default_shell (char *token)
765      sh_found = 1;      sh_found = 1;
766    } else {    } else {
767      char *p;      char *p;
768      struct variable *v = lookup_variable ("PATH", 4);      struct variable *v = lookup_variable (STRING_SIZE_TUPLE ("PATH"));
769    
770      /* Search Path for shell */      /* Search Path for shell */
771      if (v && v->value) {      if (v && v->value) {
# Line 889  main (int argc, char **argv, char **envp Line 890  main (int argc, char **argv, char **envp
890    char **p;    char **p;
891    struct dep *read_makefiles;    struct dep *read_makefiles;
892    PATH_VAR (current_directory);    PATH_VAR (current_directory);
893      unsigned int restarts = 0;
894  #ifdef WINDOWS32  #ifdef WINDOWS32
895    char *unix_path = NULL;    char *unix_path = NULL;
896    char *windows32_path = NULL;    char *windows32_path = NULL;
# Line 1149  main (int argc, char **argv, char **envp Line 1151  main (int argc, char **argv, char **envp
1151            v->export = v_export;            v->export = v_export;
1152    
1153            /* Another wrinkle is that POSIX says the value of SHELL set in the            /* Another wrinkle is that POSIX says the value of SHELL set in the
1154               makefile should not change the value of SHELL given to               makefile won't change the value of SHELL given to subprocesses  */
1155               subprocesses, which seems silly to me but...  */            if (streq (v->name, "SHELL"))
           if (strncmp (envp[i], "SHELL=", 6) == 0)  
1156              {              {
1157  #ifndef __MSDOS__  #ifndef __MSDOS__
1158                v->export = v_noexport;                v->export = v_noexport;
# Line 1159  main (int argc, char **argv, char **envp Line 1160  main (int argc, char **argv, char **envp
1160                shell_var.name = "SHELL";                shell_var.name = "SHELL";
1161                shell_var.value = xstrdup (ep + 1);                shell_var.value = xstrdup (ep + 1);
1162              }              }
1163    
1164              /* If MAKE_RESTARTS is set, remember it but don't export it.  */
1165              if (streq (v->name, "MAKE_RESTARTS"))
1166                {
1167                  v->export = v_noexport;
1168                  restarts = (unsigned int) atoi (ep + 1);
1169                }
1170          }          }
1171      }      }
1172  #ifdef WINDOWS32  #ifdef WINDOWS32
# Line 1203  main (int argc, char **argv, char **envp Line 1211  main (int argc, char **argv, char **envp
1211    
1212    /* Decode the switches.  */    /* Decode the switches.  */
1213    
1214    decode_env_switches ("MAKEFLAGS", 9);    decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
1215  #if 0  #if 0
1216    /* People write things like:    /* People write things like:
1217          MFLAGS="CC=gcc -pipe" "CFLAGS=-g"          MFLAGS="CC=gcc -pipe" "CFLAGS=-g"
1218       and we set the -p, -i and -e switches.  Doesn't seem quite right.  */       and we set the -p, -i and -e switches.  Doesn't seem quite right.  */
1219    decode_env_switches ("MFLAGS", 6);    decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
1220  #endif  #endif
1221    decode_switches (argc, argv, 0);    decode_switches (argc, argv, 0);
1222  #ifdef WINDOWS32  #ifdef WINDOWS32
# Line 1222  main (int argc, char **argv, char **envp Line 1230  main (int argc, char **argv, char **envp
1230    
1231    decode_debug_flags ();    decode_debug_flags ();
1232    
1233    /* Print version information.  */    /* Set always_make_flag if -B was given and we've not restarted already.  */
1234      always_make_flag = always_make_set && (restarts == 0);
1235    
1236      /* Print version information.  */
1237    if (print_version_flag || print_data_base_flag || db_level)    if (print_version_flag || print_data_base_flag || db_level)
1238      print_version ();      {
1239          print_version ();
1240    
1241    /* `make --version' is supposed to just print the version and exit.  */        /* `make --version' is supposed to just print the version and exit.  */
1242    if (print_version_flag)        if (print_version_flag)
1243      die (0);          die (0);
1244        }
1245    
1246  #ifndef VMS  #ifndef VMS
1247    /* Set the "MAKE_COMMAND" variable to the name we were invoked with.    /* Set the "MAKE_COMMAND" variable to the name we were invoked with.
# Line 1376  main (int argc, char **argv, char **envp Line 1388  main (int argc, char **argv, char **envp
1388  #endif /* WINDOWS32 */  #endif /* WINDOWS32 */
1389    /* Figure out the level of recursion.  */    /* Figure out the level of recursion.  */
1390    {    {
1391      struct variable *v = lookup_variable (MAKELEVEL_NAME, MAKELEVEL_LENGTH);      struct variable *v = lookup_variable (STRING_SIZE_TUPLE (MAKELEVEL_NAME));
1392      if (v != 0 && v->value[0] != '\0' && v->value[0] != '-')      if (v != 0 && v->value[0] != '\0' && v->value[0] != '-')
1393        makelevel = (unsigned int) atoi (v->value);        makelevel = (unsigned int) atoi (v->value);
1394      else      else
# Line 1588  main (int argc, char **argv, char **envp Line 1600  main (int argc, char **argv, char **envp
1600    /* We need to know what kind of shell we will be using.  */    /* We need to know what kind of shell we will be using.  */
1601    {    {
1602      extern int _is_unixy_shell (const char *_path);      extern int _is_unixy_shell (const char *_path);
1603      struct variable *shv = lookup_variable ("SHELL", 5);      struct variable *shv = lookup_variable (STRING_SIZE_TUPLE ("SHELL"));
1604      extern int unixy_shell;      extern int unixy_shell;
1605      extern char *default_shell;      extern char *default_shell;
1606    
# Line 1607  main (int argc, char **argv, char **envp Line 1619  main (int argc, char **argv, char **envp
1619  #endif /* __MSDOS__ || __EMX__ */  #endif /* __MSDOS__ || __EMX__ */
1620    
1621    /* Decode switches again, in case the variables were set by the makefile.  */    /* Decode switches again, in case the variables were set by the makefile.  */
1622    decode_env_switches ("MAKEFLAGS", 9);    decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));
1623  #if 0  #if 0
1624    decode_env_switches ("MFLAGS", 6);    decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
1625  #endif  #endif
1626    
1627  #if defined (__MSDOS__) || defined (__EMX__)  #if defined (__MSDOS__) || defined (__EMX__)
# Line 1997  main (int argc, char **argv, char **envp Line 2009  main (int argc, char **argv, char **envp
2009                  fatal (NILF, _("Couldn't change back to original directory."));                  fatal (NILF, _("Couldn't change back to original directory."));
2010              }              }
2011    
2012              ++restarts;
2013    
2014              if (ISDB (DB_BASIC))
2015                {
2016                  char **p;
2017                  printf (_("Re-executing[%u]:"), restarts);
2018                  for (p = nargv; *p != 0; ++p)
2019                    printf (" %s", *p);
2020                  putchar ('\n');
2021                }
2022    
2023  #ifndef _AMIGA  #ifndef _AMIGA
2024            for (p = environ; *p != 0; ++p)            for (p = environ; *p != 0; ++p)
2025              if (strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH)              {
2026                  && (*p)[MAKELEVEL_LENGTH] == '=')                if (strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH)
2027                {                    && (*p)[MAKELEVEL_LENGTH] == '=')
2028                  /* The SGI compiler apparently can't understand                  {
2029                     the concept of storing the result of a function                    /* The SGI compiler apparently can't understand
2030                     in something other than a local variable.  */                       the concept of storing the result of a function
2031                  char *sgi_loses;                       in something other than a local variable.  */
2032                  sgi_loses = (char *) alloca (40);                    char *sgi_loses;
2033                  *p = sgi_loses;                    sgi_loses = (char *) alloca (40);
2034                  sprintf (*p, "%s=%u", MAKELEVEL_NAME, makelevel);                    *p = sgi_loses;
2035                  break;                    sprintf (*p, "%s=%u", MAKELEVEL_NAME, makelevel);
2036                }                  }
2037                  if (strneq (*p, "MAKE_RESTARTS=", 14))
2038                    {
2039                      char *sgi_loses;
2040                      sgi_loses = (char *) alloca (40);
2041                      *p = sgi_loses;
2042                      sprintf (*p, "MAKE_RESTARTS=%u", restarts);
2043                      restarts = 0;
2044                    }
2045                }
2046  #else /* AMIGA */  #else /* AMIGA */
2047            {            {
2048              char buffer[256];              char buffer[256];
             int len;  
2049    
2050              len = GetVar (MAKELEVEL_NAME, buffer, sizeof (buffer), GVF_GLOBAL_ONLY);              sprintf (buffer, "%u", makelevel);
2051                SetVar (MAKELEVEL_NAME, buffer, -1, GVF_GLOBAL_ONLY);
2052    
2053              if (len != -1)              sprintf (buffer, "%u", restarts);
2054              {              SetVar ("MAKE_RESTARTS", buffer, -1, GVF_GLOBAL_ONLY);
2055              sprintf (buffer, "%u", makelevel);              restarts = 0;
               SetVar (MAKELEVEL_NAME, buffer, -1, GVF_GLOBAL_ONLY);  
             }  
2056            }            }
2057  #endif  #endif
2058    
2059            if (ISDB (DB_BASIC))            /* If we didn't set the restarts variable yet, add it.  */
2060              {            if (restarts)
2061                char **p;              {
2062                fputs (_("Re-executing:"), stdout);                char *b = alloca (40);
2063                for (p = nargv; *p != 0; ++p)                sprintf (b, "MAKE_RESTARTS=%u", restarts);
2064                  printf (" %s", *p);                putenv (b);
2065                putchar ('\n');              }
             }  
2066    
2067            fflush (stdout);            fflush (stdout);
2068            fflush (stderr);            fflush (stderr);
# Line 2085  main (int argc, char **argv, char **envp Line 2114  main (int argc, char **argv, char **envp
2114    /* Set up `MAKEFLAGS' again for the normal targets.  */    /* Set up `MAKEFLAGS' again for the normal targets.  */
2115    define_makeflags (1, 0);    define_makeflags (1, 0);
2116    
2117      /* Set always_make_flag if -B was given.  */
2118      always_make_flag = always_make_set;
2119    
2120    /* If there is a temp file from reading a makefile from stdin, get rid of    /* If there is a temp file from reading a makefile from stdin, get rid of
2121       it now.  */       it now.  */
2122    if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT)    if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT)
# Line 2304  handle_non_switch_argument (char *arg, i Line 2336  handle_non_switch_argument (char *arg, i
2336          struct variable *v;          struct variable *v;
2337          char *value;          char *value;
2338    
2339          v = lookup_variable ("MAKECMDGOALS", 12);          v = lookup_variable (STRING_SIZE_TUPLE ("MAKECMDGOALS"));
2340          if (v == 0)          if (v == 0)
2341            value = f->name;            value = f->name;
2342          else          else

Legend:
Removed from v.1.205  
changed lines
  Added in v.1.206

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26