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

Diff of /make/read.c

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

revision 1.136 by bosk, Sun Feb 27 21:40:24 2005 UTC revision 1.137 by bosk, Sun Feb 27 22:24:31 2005 UTC
# Line 134  static int conditional_line PARAMS ((cha Line 134  static int conditional_line PARAMS ((cha
134  static void record_files PARAMS ((struct nameseq *filenames, char *pattern, char *pattern_percent,  static void record_files PARAMS ((struct nameseq *filenames, char *pattern, char *pattern_percent,
135                          struct dep *deps, unsigned int cmds_started, char *commands,                          struct dep *deps, unsigned int cmds_started, char *commands,
136                          unsigned int commands_idx, int two_colon,                          unsigned int commands_idx, int two_colon,
137                          const struct floc *flocp, int set_default));                          const struct floc *flocp));
138  static void record_target_var PARAMS ((struct nameseq *filenames, char *defn,  static void record_target_var PARAMS ((struct nameseq *filenames, char *defn,
139                                         enum variable_origin origin,                                         enum variable_origin origin,
140                                         int enabled,                                         int enabled,
# Line 472  eval (struct ebuffer *ebuf, int set_defa Line 472  eval (struct ebuffer *ebuf, int set_defa
472            fi.lineno = tgts_started;                                           \            fi.lineno = tgts_started;                                           \
473            record_files (filenames, pattern, pattern_percent, deps,            \            record_files (filenames, pattern, pattern_percent, deps,            \
474                          cmds_started, commands, commands_idx, two_colon,      \                          cmds_started, commands, commands_idx, two_colon,      \
475                          &fi, set_default);                                    \                          &fi);                                                 \
476          }                                                                     \          }                                                                     \
477        filenames = 0;                                                          \        filenames = 0;                                                          \
478        commands_idx = 0;                                                       \        commands_idx = 0;                                                       \
# Line 1192  eval (struct ebuffer *ebuf, int set_defa Line 1192  eval (struct ebuffer *ebuf, int set_defa
1192              commands[commands_idx++] = '\n';              commands[commands_idx++] = '\n';
1193            }            }
1194    
1195            /* Determine if this target should be made default. We used
1196               to do this in record_files() but because of the delayed
1197               target recording and because preprocessor directives are
1198               legal in target's commands it is too late. Consider this
1199               fragment for example:
1200    
1201               foo:
1202    
1203               ifeq ($(.DEFAULT_TARGET),foo)
1204                  ...
1205               endif
1206    
1207               Because the target is not recorded until after ifeq
1208               directive is evaluated the .DEFAULT_TARGET does not
1209               contain foo yet as one would expect. Because of this
1210               we have to move some of the logic here. */
1211    
1212            if (**default_target_name == '\0' && set_default)
1213              {
1214                char* name;
1215                struct dep *d;
1216                struct nameseq *t = filenames;
1217    
1218                for (; t != 0; t = t->next)
1219                  {
1220                    int reject = 0;
1221                    name = t->name;
1222    
1223                    /* We have nothing to do if this is an implicit rule. */
1224                    if (strchr (name, '%') != 0)
1225                      break;
1226    
1227                    /* See if this target's name does not start with a `.',
1228                       unless it contains a slash.  */
1229                    if (*name == '.' && strchr (name, '/') == 0
1230    #ifdef HAVE_DOS_PATHS
1231                        && strchr (name, '\\') == 0
1232    #endif
1233                    )
1234                      continue;
1235    
1236    
1237                    /* If this file is a suffix, don't let it be
1238                       the default goal file.  */
1239                    for (d = suffix_file->deps; d != 0; d = d->next)
1240                      {
1241                        register struct dep *d2;
1242                        if (*dep_name (d) != '.' && streq (name, dep_name (d)))
1243                          {
1244                            reject = 1;
1245                            break;
1246                          }
1247                        for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
1248                          {
1249                            register unsigned int len = strlen (dep_name (d2));
1250                            if (!strneq (name, dep_name (d2), len))
1251                              continue;
1252                            if (streq (name + len, dep_name (d)))
1253                              {
1254                                reject = 1;
1255                                break;
1256                              }
1257                          }
1258    
1259                        if (reject)
1260                          break;
1261                      }
1262    
1263                    if (!reject)
1264                      {
1265                        (void) define_variable (
1266                          ".DEFAULT_TARGET", 15, t->name, o_file, 0);
1267                        break;
1268                      }
1269                  }
1270              }
1271    
1272          continue;          continue;
1273        }        }
1274    
# Line 1737  static void Line 1814  static void
1814  record_files (struct nameseq *filenames, char *pattern, char *pattern_percent,  record_files (struct nameseq *filenames, char *pattern, char *pattern_percent,
1815                struct dep *deps, unsigned int cmds_started, char *commands,                struct dep *deps, unsigned int cmds_started, char *commands,
1816                unsigned int commands_idx, int two_colon,                unsigned int commands_idx, int two_colon,
1817                const struct floc *flocp, int set_default)                const struct floc *flocp)
1818  {  {
1819    struct nameseq *nextf;    struct nameseq *nextf;
1820    int implicit = 0;    int implicit = 0;
# Line 2013  record_files (struct nameseq *filenames, Line 2090  record_files (struct nameseq *filenames,
2090            name = f->name;            name = f->name;
2091          }          }
2092    
2093        /* See if this is first target seen whose name does        /* See if this target is a default target and update
2094           not start with a `.', unless it contains a slash.  */           DEFAULT_GOAL_FILE if necessary.  */
2095        if (default_goal_file == 0 && set_default        if (strcmp (*default_target_name, name) == 0 &&
2096            && (*name != '.' || strchr (name, '/') != 0            (default_goal_file == 0 ||
2097  #ifdef HAVE_DOS_PATHS             strcmp (default_goal_file->name, name) != 0))
                            || strchr (name, '\\') != 0  
 #endif  
               ))  
2098          {          {
2099            int reject = 0;            default_goal_file = f;
   
           /* If this file is a suffix, don't  
              let it be the default goal file.  */  
   
           for (d = suffix_file->deps; d != 0; d = d->next)  
             {  
               register struct dep *d2;  
               if (*dep_name (d) != '.' && streq (name, dep_name (d)))  
                 {  
                   reject = 1;  
                   break;  
                 }  
               for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)  
                 {  
                   register unsigned int len = strlen (dep_name (d2));  
                   if (!strneq (name, dep_name (d2), len))  
                     continue;  
                   if (streq (name + len, dep_name (d)))  
                     {  
                       reject = 1;  
                       break;  
                     }  
                 }  
               if (reject)  
                 break;  
             }  
   
           if (!reject)  
             default_goal_file = f;  
2100          }          }
2101      }      }
2102    

Legend:
Removed from v.1.136  
changed lines
  Added in v.1.137

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