+ my $mtime=mtime(srcfile($file));
+ if (! exists $pagemtime{$page} ||
+ $mtime > $pagemtime{$page} ||
+ $forcerebuild{$page}) {
+ $pagemtime{$page}=$mtime;
+ if (isinternal($page)) {
+ push @internal, $file;
+ # Preprocess internal page in scan-only mode.
+ my $content=readfile(srcfile($file));
+ preprocess($page, $page, $content, 1);
+ }
+ else {
+ push @needsbuild, $file;
+ }
+ }
+ }
+ run_hooks(needsbuild => sub { shift->(\@needsbuild) });
+
+ # scan and render files
+ foreach my $file (@needsbuild) {
+ debug(sprintf(gettext("scanning %s"), $file));
+ scan($file);
+ }
+ calculate_backlinks();
+ foreach my $file (@needsbuild) {
+ debug(sprintf(gettext("rendering %s"), $file));
+ render($file);
+ $rendered{$file}=1;
+ }
+ foreach my $file (@internal) {
+ # internal pages are not rendered
+ my $page=pagename($file);
+ delete $depends{$page};
+ foreach my $old (@{$renderedfiles{$page}}) {
+ delete $destsources{$old};