[BACK]Return to main.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/main.c between version 1.52 and 1.53

version 1.52, 2001/06/03 16:33:48 version 1.53, 2001/06/05 11:59:11
Line 70 
Line 70 
 #include "memory.h"  #include "memory.h"
 #include "make.h"  #include "make.h"
   
   #ifndef PATH_MAX
   # ifdef MAXPATHLEN
   #  define PATH_MAX (MAXPATHLEN+1)
   # else
   #  define PATH_MAX      1024
   # endif
   #endif
   
 #ifndef DEFMAXLOCAL  #ifndef DEFMAXLOCAL
 #define DEFMAXLOCAL DEFMAXJOBS  #define DEFMAXLOCAL DEFMAXJOBS
 #endif  /* DEFMAXLOCAL */  #endif  /* DEFMAXLOCAL */
Line 99 
Line 107 
 bool            checkEnvFirst;  /* -e flag */  bool            checkEnvFirst;  /* -e flag */
   
 static void             MainParseArgs(int, char **);  static void             MainParseArgs(int, char **);
 static char *           chdir_verify_path(char *, char *);  static char *           chdir_verify_path(char *);
 static int              ReadMakefile(void *, void *);  static int              ReadMakefile(void *, void *);
 static void             add_dirpath(Lst, const char *);  static void             add_dirpath(Lst, const char *);
 static void             usage(void);  static void             usage(void);
Line 398 
Line 406 
 }  }
   
 char *  char *
 chdir_verify_path(path, obpath)  chdir_verify_path(path)
     char *path;      char *path;
     char *obpath;  
 {  {
     struct stat sb;      struct stat sb;
   
Line 410 
Line 417 
                   path, strerror(errno));                    path, strerror(errno));
             return NULL;              return NULL;
         } else {          } else {
             if (path[0] != '/') {              if (path[0] != '/')
                 (void)snprintf(obpath, MAXPATHLEN, "%s/%s", curdir, path);                  return Str_concat(curdir, path, '/');
                 return obpath;  
             }  
             else              else
                 return path;                  return estrdup(path);
         }          }
     }      }
   
Line 470 
Line 475 
         bool outOfDate = true;  /* false if all targets up to date */          bool outOfDate = true;  /* false if all targets up to date */
         struct stat sb, sa;          struct stat sb, sa;
         char *p, *path, *pathp, *pwd;          char *p, *path, *pathp, *pwd;
         char mdpath[MAXPATHLEN + 1];          char *mdpath;
         char obpath[MAXPATHLEN + 1];  
         char cdpath[MAXPATHLEN + 1];  
         char *machine = getenv("MACHINE");          char *machine = getenv("MACHINE");
         char *machine_arch = getenv("MACHINE_ARCH");          char *machine_arch = getenv("MACHINE_ARCH");
         const char *syspath = _PATH_DEFSYSPATH;          const char *syspath = _PATH_DEFSYSPATH;
Line 495 
Line 498 
          * All this code is so that we know where we are when we start up           * All this code is so that we know where we are when we start up
          * on a different machine with pmake.           * on a different machine with pmake.
          */           */
         curdir = cdpath;          if ((curdir = dogetcwd()) == NULL) {
         if (getcwd(curdir, MAXPATHLEN) == NULL) {  
                 (void)fprintf(stderr, "make: %s.\n", strerror(errno));                  (void)fprintf(stderr, "make: %s.\n", strerror(errno));
                 exit(2);                  exit(2);
         }          }
Line 509 
Line 511 
   
         if ((pwd = getenv("PWD")) != NULL) {          if ((pwd = getenv("PWD")) != NULL) {
             if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino &&              if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino &&
                 sa.st_dev == sb.st_dev && strlen(pwd) <= MAXPATHLEN)                  sa.st_dev == sb.st_dev) {
                 (void)strcpy(curdir, pwd);                      free(curdir);
                       curdir = estrdup(pwd);
               }
         }          }
   
         /*          /*
Line 556 
Line 560 
          * and modify the paths for the Makefiles apropriately.  The           * and modify the paths for the Makefiles apropriately.  The
          * current directory is also placed as a variable for make scripts.           * current directory is also placed as a variable for make scripts.
          */           */
           mdpath = NULL;
         if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) {          if (!(pathp = getenv("MAKEOBJDIRPREFIX"))) {
                 if (!(path = getenv("MAKEOBJDIR"))) {                  if (!(path = getenv("MAKEOBJDIR"))) {
                         path = _PATH_OBJDIR;                          path = _PATH_OBJDIR;
                         pathp = _PATH_OBJDIRPREFIX;                          pathp = _PATH_OBJDIRPREFIX;
                         (void)snprintf(mdpath, MAXPATHLEN, "%s.%s",                          mdpath = Str_concat(path, machine, '.');
                                         path, machine);                          if (!(objdir = chdir_verify_path(mdpath)))
                         if (!(objdir = chdir_verify_path(mdpath, obpath)))                                  if (!(objdir=chdir_verify_path(path))) {
                                 if (!(objdir=chdir_verify_path(path, obpath))) {                                          free(mdpath);
                                         (void)snprintf(mdpath, MAXPATHLEN,                                          mdpath = Str_concat(pathp, curdir, 0);
                                                         "%s%s", pathp, curdir);                                          if (!(objdir=chdir_verify_path(mdpath)))
                                         if (!(objdir=chdir_verify_path(mdpath,  
                                                                        obpath)))  
                                                 objdir = curdir;                                                  objdir = curdir;
                                 }                                  }
                 }                  }
                 else if (!(objdir = chdir_verify_path(path, obpath)))                  else if (!(objdir = chdir_verify_path(path)))
                         objdir = curdir;                          objdir = curdir;
         }          }
         else {          else {
                 (void)snprintf(mdpath, MAXPATHLEN, "%s%s", pathp, curdir);                  mdpath = Str_concat(pathp, curdir, 0);
                 if (!(objdir = chdir_verify_path(mdpath, obpath)))                  if (!(objdir = chdir_verify_path(mdpath)))
                         objdir = curdir;                          objdir = curdir;
         }          }
           free(mdpath);
   
         esetenv("PWD", objdir);          esetenv("PWD", objdir);
         unsetenv("CDPATH");          unsetenv("CDPATH");
Line 781 
Line 785 
         if (DEBUG(GRAPH2))          if (DEBUG(GRAPH2))
                 Targ_PrintGraph(2);                  Targ_PrintGraph(2);
   
   #ifdef CLEANUP
           if (objdir != curdir)
               free(objdir);
           free(curdir);
   #endif
         if (queryFlag && outOfDate)          if (queryFlag && outOfDate)
                 return 1;                  return 1;
         else          else
Line 804 
Line 813 
 {  {
         char *fname = p;                /* makefile to read */          char *fname = p;                /* makefile to read */
         FILE *stream;          FILE *stream;
         char *name, path[MAXPATHLEN + 1];          char *name;
   
         if (!strcmp(fname, "-")) {          if (!strcmp(fname, "-")) {
                 Var_Set("MAKEFILE", "", VAR_GLOBAL);                  Var_Set("MAKEFILE", "", VAR_GLOBAL);
Line 814 
Line 823 
                         goto found;                          goto found;
                 /* if we've chdir'd, rebuild the path name */                  /* if we've chdir'd, rebuild the path name */
                 if (curdir != objdir && *fname != '/') {                  if (curdir != objdir && *fname != '/') {
                         (void)snprintf(path, sizeof path, "%s/%s", curdir,                          char *path;
                             fname);  
                         if ((stream = fopen(path, "r")) != NULL) {                          path = Str_concat(curdir, fname, '/');
                                 fname = estrdup(path);                          if ((stream = fopen(path, "r")) == NULL)
                                 goto found;                              free(path);
                           else {
                               fname = path;
                               goto found;
                         }                          }
                 }                  }
                 /* look in -I and system include directories. */                  /* look in -I and system include directories. */

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53