Ignore:
Timestamp:
May 23, 2007, 7:31:19 AM (18 years ago)
Author:
bird
Message:

Merged with the 2007-05-23 CVS. Added rsort and fixed a couple of windows build issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmakenew/remake.c

    r520 r903  
    4040#endif
    4141
    42 extern int try_implicit_rule PARAMS ((struct file *file, unsigned int depth));
     42extern int try_implicit_rule (struct file *file, unsigned int depth);
    4343
    4444
     
    6161static unsigned int considered;
    6262
    63 static int update_file PARAMS ((struct file *file, unsigned int depth));
    64 static int update_file_1 PARAMS ((struct file *file, unsigned int depth));
    65 static int check_dep PARAMS ((struct file *file, unsigned int depth, FILE_TIMESTAMP this_mtime, int *must_make_ptr));
    66 static int touch_file PARAMS ((struct file *file));
    67 static void remake_file PARAMS ((struct file *file));
    68 static FILE_TIMESTAMP name_mtime PARAMS ((char *name));
    69 static int library_search PARAMS ((char **lib, FILE_TIMESTAMP *mtime_ptr));
     63static int update_file (struct file *file, unsigned int depth);
     64static int update_file_1 (struct file *file, unsigned int depth);
     65static int check_dep (struct file *file, unsigned int depth,
     66                      FILE_TIMESTAMP this_mtime, int *must_make_ptr);
     67static int touch_file (struct file *file);
     68static void remake_file (struct file *file);
     69static FILE_TIMESTAMP name_mtime (const char *name);
     70static const char *library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr);
    7071
    7172
     
    239240
    240241              /* Free the storage.  */
    241               free ((char *) g);
     242              free (g);
    242243
    243244              g = lastgoal == 0 ? goals : lastgoal->next;
     
    538539      if (!running)
    539540        /* The prereq is considered changed if the timestamp has changed while
    540            it was built, OR it doesn't exist.
    541            This causes the Linux kernel build to break.  We'll defer this
    542            fix until GNU make 3.82 to give them time to update.  */
     541           it was built, OR it doesn't exist.  */
    543542        d->changed = ((file_mtime (d->file) != mtime)
    544                       /* || (mtime == NONEXISTENT_MTIME) */);
     543                      || (mtime == NONEXISTENT_MTIME));
    545544
    546545      lastd = d;
     
    823822  if (touch_flag
    824823      /* The update status will be:
    825                 -1      if this target was not remade;
     824                -1      if this target was not remade;
    826825                0       if 0 or more commands (+ or ${MAKE}) were run and won;
    827826                1       if some commands were run and lost.
     
    933932             so that a vpath_search can happen.  Otherwise, it would
    934933             never be done because the target is already updated.  */
    935           (void) f_mtime (d->file, 0);
     934          f_mtime (d->file, 0);
    936935      }
    937936  else if (file->update_status == -1)
     
    942941
    943942
    944 /* Check whether another file (whose mtime is THIS_MTIME)
    945    needs updating on account of a dependency which is file FILE.
    946    If it does, store 1 in *MUST_MAKE_PTR.
    947    In the process, update any non-intermediate files
    948    that FILE depends on (including FILE itself).
    949    Return nonzero if any updating failed.  */
     943/* Check whether another file (whose mtime is THIS_MTIME) needs updating on
     944   account of a dependency which is file FILE.  If it does, store 1 in
     945   *MUST_MAKE_PTR.  In the process, update any non-intermediate files that
     946   FILE depends on (including FILE itself).  Return nonzero if any updating
     947   failed.  */
    950948
    951949static int
     
    961959  if (file->phony || !file->intermediate)
    962960    {
    963       /* If this is a non-intermediate file, update it and record
    964          whether it is newer than THIS_MTIME.  */
     961      /* If this is a non-intermediate file, update it and record whether it
     962         is newer than THIS_MTIME.  */
    965963      FILE_TIMESTAMP mtime;
    966964      dep_status = update_file (file, depth);
     
    991989        }
    992990
    993       /* If the intermediate file actually exists
    994          and is newer, then we should remake from it.  */
    995991      check_renamed (file);
    996992      mtime = file_mtime (file);
    997993      check_renamed (file);
    998994      if (mtime != NONEXISTENT_MTIME && mtime > this_mtime)
     995        /* If the intermediate file actually exists and is newer, then we
     996           should remake from it.  */
    999997        *must_make_ptr = 1;
    1000           /* Otherwise, update all non-intermediate files we depend on,
    1001              if necessary, and see whether any of them is more
    1002              recent than the file on whose behalf we are checking.  */
    1003998      else
    1004999        {
     1000          /* Otherwise, update all non-intermediate files we depend on, if
     1001             necessary, and see whether any of them is more recent than the
     1002             file on whose behalf we are checking.  */
    10051003          struct dep *lastd;
    10061004
     
    10811079        {
    10821080          struct stat statbuf;
    1083           char buf;
     1081          char buf = 'x';
    10841082          int e;
    10851083
     
    11771175      char *arname, *memname;
    11781176      struct file *arfile;
    1179       int arname_used = 0;
    11801177      time_t member_date;
    11811178
     
    11871184      arfile = lookup_file (arname);
    11881185      if (arfile == 0)
    1189         {
    1190           arfile = enter_file (arname);
    1191           arname_used = 1;
    1192         }
     1186        arfile = enter_file (strcache_add (arname));
    11931187      mtime = f_mtime (arfile, search);
    11941188      check_renamed (arfile);
     
    12011195          unsigned int arlen, memlen;
    12021196
    1203           if (!arname_used)
    1204             {
    1205               free (arname);
    1206               arname_used = 1;
    1207             }
    1208 
    1209           arname = arfile->hname;
    1210           arlen = strlen (arname);
     1197          arlen = strlen (arfile->hname);
    12111198          memlen = strlen (memname);
    12121199
    1213           /* free (file->name); */
    1214 
    1215           name = (char *) xmalloc (arlen + 1 + memlen + 2);
    1216           bcopy (arname, name, arlen);
     1200          name = xmalloc (arlen + 1 + memlen + 2);
     1201          memcpy (name, arfile->hname, arlen);
    12171202          name[arlen] = '(';
    1218           bcopy (memname, name + arlen + 1, memlen);
     1203          memcpy (name + arlen + 1, memname, memlen);
    12191204          name[arlen + 1 + memlen] = ')';
    12201205          name[arlen + 1 + memlen + 1] = '\0';
     
    12291214        }
    12301215
    1231       if (!arname_used)
    1232         free (arname);
    1233       free (memname);
     1216      free (arname);
    12341217
    12351218      file->low_resolution_time = 1;
     
    12521235        {
    12531236          /* If name_mtime failed, search VPATH.  */
    1254           char *name = file->name;
    1255           if (vpath_search (&name, &mtime)
     1237          const char *name = vpath_search (file->name, &mtime);
     1238          if (name
    12561239              /* Last resort, is it a library (-lxxx)?  */
    1257               || (name[0] == '-' && name[1] == 'l'
    1258                   && library_search (&name, &mtime)))
     1240              || (file->name[0] == '-' && file->name[1] == 'l'
     1241                  && (name = library_search (file->name, &mtime)) != 0))
    12591242            {
    12601243              if (mtime != UNKNOWN_MTIME)
     
    13751358
    13761359static FILE_TIMESTAMP
    1377 name_mtime (char *name)
     1360name_mtime (const char *name)
    13781361{
    13791362  FILE_TIMESTAMP mtime;
     
    14691452   directories.  */
    14701453
    1471 static int
    1472 library_search (char **lib, FILE_TIMESTAMP *mtime_ptr)
     1454static const char *
     1455library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
    14731456{
    14741457  static char *dirs[] =
     
    14911474  static char *libpatterns = NULL;
    14921475
    1493   char *libname = &(*lib)[2];   /* Name without the `-l'.  */
     1476  const char *libname = lib+2;  /* Name without the '-l'.  */
    14941477  FILE_TIMESTAMP mtime;
    14951478
    14961479  /* Loop variables for the libpatterns value.  */
    1497   char *p, *p2;
     1480  char *p;
     1481  const char *p2;
    14981482  unsigned int len;
    14991483
    1500   char *file, **dp;
     1484  char **dp;
    15011485
    15021486  /* If we don't have libpatterns, get it.  */
     
    15471531      if (mtime != NONEXISTENT_MTIME)
    15481532        {
    1549           *lib = xstrdup (libbuf);
    15501533          if (mtime_ptr != 0)
    15511534            *mtime_ptr = mtime;
    1552           return 1;
     1535          return strcache_add (libbuf);
    15531536        }
    15541537
    15551538      /* Now try VPATH search on that.  */
    15561539
    1557       file = libbuf;
    1558       if (vpath_search (&file, mtime_ptr))
    1559         {
    1560           *lib = file;
    1561           return 1;
    1562         }
     1540      {
     1541        const char *file = vpath_search (libbuf, mtime_ptr);
     1542        if (file)
     1543          return file;
     1544      }
    15631545
    15641546      /* Now try the standard set of directories.  */
     
    15871569          if (mtime != NONEXISTENT_MTIME)
    15881570            {
    1589               *lib = xstrdup (buf);
    15901571              if (mtime_ptr != 0)
    15911572                *mtime_ptr = mtime;
    1592               return 1;
     1573              return strcache_add (buf);
    15931574            }
    15941575        }
Note: See TracChangeset for help on using the changeset viewer.