Home | History | Annotate | Download | only in make-3.81

Lines Matching full:file

5 This file is part of GNU Make.
16 GNU Make; see the file COPYING. If not, write to the Free Software
32 #include <sys/file.h>
42 extern int try_implicit_rule PARAMS ((struct file *file, unsigned int depth));
46 `struct file'. However, double colon targets have seperate `struct
47 file's; make sure we always use the base of the double colon chain. */
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));
88 #define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \
89 : file_mtime (file))
127 /* Iterate over all double-colon entries for this file. */
128 struct file *file;
131 for (file = g->file->double_colon ? g->file->double_colon : g->file;
132 file != NULL;
133 file = file->prev)
137 check_renamed (file);
140 if (file->cmd_target)
155 x = update_file (file, rebuilding_makefiles ? 1 : 0);
156 check_renamed (file);
164 /* If we updated a file and STATUS was not already 1, set it to
169 if ((x != 0 || file->updated) && status < 1)
171 if (file->update_status != 0)
175 status = file->update_status;
184 FILE_TIMESTAMP mtime = MTIME (file);
185 check_renamed (file);
187 if (file->updated && g->changed &&
188 mtime != file->mtime_before_update)
192 -n or -q was given and this file was specified
199 if (rebuilding_makefiles && file->dontcare)
208 any_not_updated |= !file->updated;
214 /* Reset FILE since it is null at the end of the loop. */
215 file = g->file;
226 && file->update_status == 0 && !g->changed
229 message (1, ((file->phony || file->cmds == 0)
232 file->name);
273 /* If FILE is not up to date, execute the commands for it.
279 then decrement it again after finding out whether this file
282 If there are multiple double-colon entries for FILE,
286 update_file (struct file *file, unsigned int depth)
289 register struct file *f;
291 f = file->double_colon ? file->double_colon : file;
299 DBF (DB_VERBOSE, _("Pruning file `%s'.\n"));
323 file until this rule is finished. */
331 if (file->double_colon)
339 status |= update_file (d->file, depth + 1);
349 complain (const struct file *file)
358 if (file->parent == 0)
359 fatal (NILF, msg_noparent, "", file->name, "");
361 fatal (NILF, msg_parent, "", file->name, file->parent->name, "");
364 if (file->parent == 0)
365 error (NILF, msg_noparent, "*** ", file->name, ".");
367 error (NILF, msg_parent, "*** ", file->name, file->parent->name, ".");
370 /* Consider a single `struct file' and update it as appropriate. */
373 update_file_1 (struct file *file, unsigned int depth)
381 DBF (DB_VERBOSE, _("Considering target file `%s'.\n"));
383 if (file->updated)
385 if (file->update_status > 0)
388 _("Recently tried and failed to update file `%s'.\n"));
390 /* If the file we tried to make is marked dontcare then no message
394 if (file->dontcare && !rebuilding_makefiles)
396 file->dontcare = 0;
397 complain (file);
400 return file->update_status;
403 DBF (DB_VERBOSE, _("File `%s' was considered already.\n"));
407 switch (file->command_state)
413 DBF (DB_VERBOSE, _("Still updating file `%s'.\n"));
416 DBF (DB_VERBOSE, _("Finished updating file `%s'.\n"));
417 return file->update_status;
424 /* Notice recursive update of the same file. */
425 start_updating (file);
427 /* Looking at the file's modtime beforehand allows the possibility
429 not need an implicit rule. If this were not done, the file
433 this_mtime = file_mtime (file);
434 check_renamed (file);
437 DBF (DB_BASIC, _("File `%s' does not exist.\n"));
439 && file->low_resolution_time)
444 error (NILF, _("*** Warning: .LOW_RESOLUTION_TIME file `%s' has a high resolution time stamp"),
445 file->name);
451 /* If file was specified as a target with no commands,
454 if (!file->phony && file->cmds == 0 && !file->tried_implicit)
456 if (try_implicit_rule (file, depth))
460 file->tried_implicit = 1;
462 if (file->cmds == 0 && !file->is_target
466 file->cmds = default_file->cmds;
470 and see whether any of them is more recent than this file. */
473 d = file->deps;
480 check_renamed (d->file);
482 mtime = file_mtime (d->file);
483 check_renamed (d->file);
485 if (is_updating (d->file))
488 file->name, d->file->name);
493 file->deps = d->next;
500 d->file->parent = file;
506 dontcare = d->file->dontcare;
507 d->file->dontcare = file->dontcare;
511 dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
515 d->file->dontcare = dontcare;
520 check_renamed (d->file);
523 register struct file *f = d->file;
543 d->changed = ((file_mtime (d->file) != mtime)
555 for (d = file->deps; d != 0; d = d->next)
556 if (d->file->intermediate)
560 FILE_TIMESTAMP mtime = file_mtime (d->file);
561 check_renamed (d->file);
562 d->file->parent = file;
567 dontcare = d->file->dontcare;
568 d->file->dontcare = file->dontcare;
572 dep_status |= update_file (d->file, depth);
576 d->file->dontcare = dontcare;
578 check_renamed (d->file);
581 register struct file *f = d->file;
597 d->changed = ((file->phony && file->cmds != 0)
598 || file_mtime (d->file) != mtime);
602 finish_updating (file);
604 DBF (DB_VERBOSE, _("Finished prerequisites of target file `%s'.\n"));
608 set_command_state (file, cs_deps_running);
618 file->update_status = dep_status;
619 notice_finished_file (file);
623 DBF (DB_VERBOSE, _("Giving up on target file `%s'.\n"));
628 _("Target `%s' not remade because of errors."), file->name);
633 if (file->command_state == cs_deps_running)
638 was definitely propagated to FILE's also_make's by set_command_state
641 file's bookkeeping (updated, but not_started is bogus state). */
642 set_command_state (file, cs_not_started);
645 recent than this file, so we can define $?. */
648 for (d = file->deps; d != 0; d = d->next)
650 FILE_TIMESTAMP d_mtime = file_mtime (d->file);
651 check_renamed (d->file);
659 if (d_mtime == NONEXISTENT_MTIME && !d->file->intermediate)
670 or its dependent, FILE, is older or does not exist. */
698 printf (fmt, dep_name (d), file->name);
707 if (file->double_colon && file->deps == 0)
713 else if (!noexist && file->is_target && !deps_changed && file->cmds == 0
720 else if (!must_make && file->cmds != 0 && always_make_flag)
731 printf (_("No need to remake target `%s'"), file->name);
732 if (!streq (file->name, file->hname))
733 printf (_("; using VPATH name `%s'"), file->hname);
738 notice_finished_file (file);
740 /* Since we don't need to remake the file, convert it to use the
744 while (file)
746 file->name = file->hname;
747 file = file->prev;
757 if (!streq(file->name, file->hname))
759 DB (DB_BASIC, (_(" Ignoring VPATH name `%s'.\n"), file->hname));
760 file->ignore_vpath = 1;
763 /* Now, take appropriate actions to remake the file. */
764 remake_file (file);
766 if (file->command_state != cs_finished)
772 switch (file->update_status)
775 DBF (DB_BASIC, _("Failed to remake target file `%s'.\n"));
778 DBF (DB_BASIC, _("Successfully remade target file `%s'.\n"));
781 DBF (DB_BASIC, _("Target file `%s' needs remade under -q.\n"));
784 assert (file->update_status >= 0 && file->update_status <= 2);
788 file->updated = 1;
789 return file->update_status;
793 /* Set FILE's `updated' flag and re-check its mtime and the mtime's of all
795 touches FILE.
797 On return, FILE->update_status will no longer be -1 if it was. */
800 notice_finished_file (struct file *file)
803 int ran = file->command_state == cs_running;
806 file->command_state = cs_finished;
807 file->updated = 1;
816 && file->update_status == 0)
818 if (file->cmds != 0 && file->cmds->any_recurse)
823 for (i = 0; i < file->cmds->ncommand_lines; ++i)
824 if (!(file->cmds->lines_flags[i] & COMMANDS_RECURSE))
830 if (file->phony)
831 file->update_status = 0;
833 else if (file->cmds != 0)
835 /* Should set file's modification date and do nothing else. */
836 file->update_status = touch_file (file);
851 if (file->mtime_before_update == UNKNOWN_MTIME)
852 file->mtime_before_update = file->last_mtime;
854 if ((ran && !file->phony) || touched)
864 for (i = file->cmds->ncommand_lines; i > 0; --i)
865 if (! (file->cmds->lines_flags[i-1] & COMMANDS_RECURSE))
871 else if (file->is_target && file->cmds == 0)
874 file->last_mtime = i == 0 ? UNKNOWN_MTIME : NEW_MTIME;
877 if (file->double_colon)
881 double-colon entries for this file.
889 struct file *f;
890 FILE_TIMESTAMP max_mtime = file->last_mtime;
895 for (f = file->double_colon; f != 0 && f->updated; f = f->prev)
901 for (f = file->double_colon; f != 0; f = f->prev)
905 if (ran && file->update_status != -1)
906 /* We actually tried to update FILE, which has
910 for (d = file->also_make; d != 0; d = d->next)
912 d->file->command_state = cs_finished;
913 d->file->updated = 1;
914 d->file->update_status = file->update_status;
916 if (ran && !d->file->phony)
921 (void) f_mtime (d->file, 0);
923 else if (file->update_status == -1)
924 /* Nothing was done for FILE, but it needed nothing done.
926 file->update_status = 0;
930 /* Check whether another file (whose mtime is THIS_MTIME)
931 needs updating on account of a dependency which is file FILE.
934 that FILE depends on (including FILE itself).
938 check_dep (struct file *file, unsigned int depth,
945 start_updating (file);
947 if (file->phony || !file->intermediate)
949 /* If this is a non-intermediate file, update it and record
952 dep_status = update_file (file, depth);
953 check_renamed (file);
954 mtime = file_mtime (file);
955 check_renamed (file);
961 /* FILE is an intermediate file. */
964 if (!file->phony && file->cmds == 0 && !file->tried_implicit)
966 if (try_implicit_rule (file, depth))
970 file->tried_implicit = 1;
972 if (file->cmds == 0 && !file->is_target
976 file->cmds = default_file->cmds;
979 /* If the intermediate file actually exists
981 check_renamed (file);
982 mtime = file_mtime (file);
983 check_renamed (file);
988 recent than the file on whose behalf we are checking. */
994 d = file->deps;
999 if (is_updating (d->file))
1002 file->name, d->file->name);
1005 file->deps = d->next;
1007 d = file->deps;
1018 d->file->parent = file;
1020 dep_status |= check_dep (d->file, depth, this_mtime,
1024 check_renamed (d->file);
1028 if (d->file->command_state == cs_running
1029 || d->file->command_state == cs_deps_running)
1030 /* Record that some of FILE's deps are still being made.
1033 set_command_state (file, cs_deps_running);
1041 finish_updating (file);
1046 /* Touch FILE. Return zero if successful, one if not. */
1048 #define TOUCH_ERROR(call) return (perror_with_name (call, file->name), 1)
1051 touch_file (struct file *file)
1054 message (0, "touch %s", file->name);
1057 if (ar_name (file->name))
1058 return ar_touch (file->name);
1062 int fd = open (file->name, O_RDWR | O_CREAT, 0666);
1082 /* If file length was 0, we just
1087 fd = open (file
1099 /* Having checked and updated the dependencies of FILE,
1100 do whatever is appropriate to remake FILE itself.
1101 Return the status from executing FILE's commands. */
1104 remake_file (struct file *file)
1106 if (file->cmds == 0)
1108 if (file->phony)
1110 file->update_status = 0;
1111 else if (file->is_target)
1112 /* This is a nonexistent target file we cannot make.
1114 file->update_status = 0;
1117 /* This is a dependency file we cannot remake. Fail. */
1118 if (!rebuilding_makefiles || !file->dontcare)
1119 complain (file);
1120 file->update_status = 2;
1125 chop_commands (file->cmds);
1128 if (!touch_flag || file->cmds->any_recurse)
1130 execute_file_commands (file);
1134 /* This tells notice_finished_file it is ok to touch the file. */
1135 file->update_status = 0;
1139 notice_finished_file (file);
1143 /* Return the mtime of a file, given a `struct file'.
1144 Caches the time in the struct file to avoid excess stat calls.
1146 If the file is not found, and SEARCH is nonzero, VPATH searching and
1149 FILE. */
1152 f_mtime (struct file *file, int search)
1156 /* File's mtime is not known; must get it from the system. */
1159 if (ar_name (file->name))
1161 /* This file is an archive-member reference. */
1164 struct file *arfile;
1169 ar_parse_name (file->name, &arname, &memname);
1199 /* free (file->name); */
1211 rename_file (file, name);
1213 rehash_file (file, name);
1214 check_renamed (file);
1221 file->low_resolution_time = 1;
1227 member_date = ar_member_date (file->hname);
1230 : file_timestamp_cons (file->hname, member_date, 0));
1235 mtime = name_mtime (file->name);
1237 if (mtime == NONEXISTENT_MTIME && search && !file->ignore_vpath)
1240 char *name = file->name;
1249 file->last_mtime = mtime;
1254 if (gpath_search (name, strlen(name) - strlen(file->name) - 1))
1256 rename_file (file, name);
1257 check_renamed (file);
1258 return file_mtime (file);
1261 rehash_file (file, name);
1262 check_renamed (file);
1264 Otherwise, find the mtime of the resulting file. */
1279 && !file->updated)
1286 /* Experimentation has shown that FAT filesystems can set file times
1296 Allow for any file (NTFS or FAT) to perhaps suffer from this
1304 /* If the file's time appears to be in the future, update our
1314 error (NILF, _("Warning: File `%s' has modification time in the future"),
1315 file->name);
1321 error (NILF, _("Warning: File `%s' has modification time %.2g s in the future"),
1322 file->name, from_now);
1329 /* Store the mtime into all the entries for this file. */
1330 if (file->double_colon)
1331 file = file->double_colon;
1335 /* If this file is not implicit but it is intermediate then it was
1336 made so by the .INTERMEDIATE target. If this file has never
1340 if (mtime != NONEXISTENT_MTIME && file->command_state == cs_not_started
1341 && file->command_state == cs_not_started
1342 && !file->tried_implicit && file->intermediate)
1343 file->intermediate = 0;
1345 file->last_mtime = mtime;
1346 file = file->prev;
1348 while (file != 0);
1354 /* Return the mtime of the file or archive-member reference NAME. */
1356 /* First, we check with stat(). If the file does not exist, then we return
1392 amongst all of them (and the target file of course).
1415 file's mtime so we don't need to test it again). */
1424 /* Set up to check the file pointed to by this link. */
1453 /* Search for a library file specified as -lLIBNAME, searching for a
1454 suitable library file in the system library directories and the VPATH
1486 char *file, **dp;
1543 file = libbuf;
1544 if (vpath_search (&file, mtime_ptr))
1546 *lib = file;