⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 am_edit

📁 《Linux程序设计权威指南》源代码
💻
📖 第 1 页 / 共 4 页
字号:
      || $line =~ /^\s*(-?rm.*) \S*$/)  {    $line =~ s/^(.*) ([^\s]*)\s*$/$1 \$(DESTDIR)$2/ if ($line !~ /\$\(DESTDIR\)/);  }  if ($line ne $_[0]) {    $_[0] = quotemeta $_[0];    substituteLine($_[0], $line);  }}#---------------------------------------------------------------------------sub tag_CLOSURE () {  return if ($program !~ /_la$/);  my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n";  $MakefileData =~ m/$lookup/;  return if ($1 !~ /CXXLINK/);  if ($MakefileData !~ /\n$program\_LDFLAGS\s*=.*-no-undefined/) {    print STDERR "Report: $program contains undefined in $printname\n" if ($program =~ /^lib/ || $dryrun);    return;  }  my $closure = $realname{$program} . ".closure";  my $lines = "$closure: \$($program\_OBJECTS) \$($program\_DEPENDENCIES)\n";  $lines .= "\t\@echo \"int main() {}\" > $program\_closure.$cxxsuffix\n";  $lines .= "\t\@\$\(LTCXXCOMPILE\) -c $program\_closure.$cxxsuffix\n";  $lines .= "\t\@\$\(CXXLINK\) $program\_closure.lo \$($program\_LDFLAGS) \$($program\_OBJECTS) \$($program\_LIBADD) \$(LIBS)\n";  $lines .= "\t\@rm -f $program\_closure.* $closure\n";  $lines .= "\t\@echo \"timestamp\" > $closure\n";  $lines .= "\n";  appendLines($lines);  $lookup = $realname{$program} . ": (.*)";  if ($MakefileData =~ /\n$lookup\n/) {    $lines  = "\@KDE_USE_CLOSURE_TRUE@". $realname{$program} . ": $closure $1";    $lines .= "\n\@KDE_USE_CLOSURE_FALSE@" . $realname{$program} . ": $1";    substituteLine($lookup, $lines);  }}#-----------------------------------------------------------------------------# Returns 0 if the line was processed - 1 otherwise.# Errors are logged in the global $errorflagssub tag_DOCFILES (){    if ($MakefileData =~ /\nSUBDIRS\s*=/) { # subdirs      $MakefileData =~ /\n(.*-recursive:\s*)\n/;      my $orig_rules = $1;      my $rules = $orig_rules;      $rules =~ s/:\s*$//;      substituteLine($orig_rules, "$rules docs-recursive:");      appendLines("docs: docs-recursive docs-am\n");    } else {      appendLines("docs: docs-am\n");    }    my $lookup = 'KDE_DOCS\s*=\s*([^\n]*)';    goto nodocs    if ($MakefileData !~ /\n$lookup/);    print STDOUT "KDE_DOCS processing <$1>\n"   if ($verbose);    tag_SUBDIRS();    my $tmp = $1;    # Either find the files in the directory (AUTO) or use    # only the specified po files.    my $files = "";    my $appname = $tmp;    $appname =~ s/^(\S*)\s*.*$/$1/;    if ($appname =~ /AUTO/) {      $appname = basename($makefileDir);    }    if ($tmp !~ / - /)    {        opendir (THISDIR, ".");	foreach $entry (readdir(THISDIR)) {	  next if ($entry eq "CVS" || $entry =~ /^\./  || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/);	  next if (! -f $entry);	  $files .= "$entry ";	}        closedir (THISDIR);        print STDOUT "docfiles found = $files\n"   if ($verbose);    }    else    {        $tmp =~ s/\034/ /g;	$tmp =~ s/^\S*\s*-\s*//;        $files = $tmp;    }    goto nodocs if (!$files);        # Nothing to do    if ($files =~ /(^| )index\.docbook($| )/) {      my $lines = "";      $lines .= "docs-am: HTML HTML/index.html\n";      $lines .= "\n";      $lines .= "HTML:\n";      $lines .= "\ttest -d HTML || mkdir HTML\n";      $lines .= "\n";      $lines .= "HTML/index.html: index.docbook\n";      $lines .= "\t\@test -d HTML && rm -r HTML\n";      $lines .= "\tkdb2html \$(srcdir)/index.docbook\n";      $lines .= "\n";      $lines .= "install-docs:\n";      $lines .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n";      $lines .= "\t\@if test -d HTML; then \\\n";      $lines .= "\t(cd HTML && for file in * .anchors; do if test -f \$\$file; then \\\n";      $lines .= "\techo \$(INSTALL_DATA) \$\$file \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$file ;\\\n";      $lines .= "\t\$(INSTALL_DATA) \$\$file \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$file; \\\n";      $lines .= "\tfi; done); fi\n";      $lines .= "\t-rm -f \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n";      $lines .= "\t\$(LN_S) ../../$kdelang/common \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n";      $lines .= "\n";      $lines .= "uninstall-docs:\n";      $lines .= "\t-rm -rf \$(kde_htmldir)/$kdelang/$appname\n";      $lines .= "\n";      $target_adds{"install-data-am"} .= "install-docs ";      $target_adds{"uninstall"} .= "uninstall-docs ";      appendLines ($lines);      $docsadded = 1;    } else {      appendLines("docs-am:\n");    }    $target_adds{"install-data-am"} .= "install-nls";    $target_adds{"uninstall"} .= "uninstall-nls ";    $tmp = "install-nls:\n";    $tmp .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n";    $tmp .= "\t\@for base in $files; do \\\n";    $tmp .= "\t  echo \$(INSTALL_DATA) \$\$base \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n";    $tmp .= "\t  \$(INSTALL_DATA) \$(srcdir)/\$\$base \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n";    $tmp .= "\tdone\n";    $tmp .= "\n";    $tmp .= "uninstall-nls:\n";    $tmp .= "\tfor base in $files; do \\\n";    $tmp .= "\t  rm -f \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n";    $tmp .= "\tdone\n\n";    appendLines ($tmp);    $target_adds{"distdir"} .= "distdir-nls ";    $tmp = "distdir-nls:\n";    $tmp .= "\tfor file in $files; do \\\n";    $tmp .= "\t  cp \$(srcdir)/\$\$file \$(distdir); \\\n";    $tmp .= "\tdone\n";    appendLines ($tmp);    return 0;  nodocs:    appendLines("docs-am:\n");    return 1;}#-----------------------------------------------------------------------------# Find headers in any of the source directories specified previously, that# are candidates for "moc-ing".sub findMocCandidates (){    my @list = ();    foreach $dir (@headerdirs)    {        chdir ($dir);        @list = `grep -l '^.*Q_OBJECT' $hExt 2> /dev/null`;        chdir ($makefileDir);        # The assoc array of root of headerfile and header filename        foreach $hFile (@list)        {            chomp ($hFile);            $hFile =~ /(.*)\.[^\.]*$/;          # Find name minus extension            if ($mocFiles{$1})            {                print STDERR "Warning: Multiple header files found for $1\n";                next;                           # Use the first one            }            $mocFiles{$1} = "$dir\035$hFile";   # Add relative dir        }    }    return 0;}#-----------------------------------------------------------------------------# The programmer has specified a moc list. Prune out the moc candidates# list that we found based on looking at the header files. This generates# a warning if the programmer gets the list wrong, but this doesn't have# to be fatal here.sub pruneMocCandidates ($){    my %prunedMoc = ();    local @mocList = split(' ', $_[0]);    foreach $mocname (@mocList)    {        $mocname =~ s/\.moc$//;        if ($mocFiles{$mocname})        {            $prunedMoc{$mocname} = $mocFiles{$mocname};        }        else        {            my $print = $makefileDir;            $print =~ s/^\Q$topdir\E\\//;            # They specified a moc file but we can't find a header that            # will generate this moc file. That's possible fatal!            print STDERR "Warning: No moc-able header file for $print/$mocname\n";        }    }    undef %mocFiles;    %mocFiles = %prunedMoc;}#-----------------------------------------------------------------------------# Finds the cpp files (If they exist).# The cpp files get appended to the header file separated by \035sub checkMocCandidates (){    my @cppFiles = ();    foreach $mocFile (keys (%mocFiles))    {        # Find corresponding c++ files that includes the moc file        @cppFiles =            `grep -l "^#include[ ]*.$mocFile\.moc." $cppExt 2> /dev/null`;        if (@cppFiles == 1)        {            chomp $cppFiles[0];            $mocFiles{$mocFile} .= "\035" . $cppFiles[0];	    push(@deped, $mocFile);            next;        }        if (@cppFiles == 0)        {            push (@newObs, $mocFile);           # Produce new object file            next    if ($haveAutomocTag);       # This is expected...            # But this is an error we can deal with - let them know            print STDERR                "Warning: No c++ file that includes $mocFile.moc\n";            next;        }        else        {            # We can't decide which file to use, so it's fatal. Although as a            # guess we could use the mocFile.cpp file if it's in the list???            print STDERR                "Error: Multiple c++ files that include $mocFile.moc\n";            print STDERR "\t",join ("\t", @cppFiles),"\n";            $errorflag = 1;            delete $mocFiles{$mocFile};            # Let's continue and see what happens - They have been told!        }    }}#-----------------------------------------------------------------------------# Add the rules for generating moc source from header files# For Automoc output *.moc.cpp but normally we'll output *.moc# (We must compile *.moc.cpp separately. *.moc files are included# in the appropriate *.cpp file by the programmer)sub addMocRules (){    my $cppFile;    my $hFile;    my $cleanMoc = "";    foreach $mocFile (keys (%mocFiles))    {        undef $cppFile;        ($dir, $hFile, $cppFile) =  split ("\035", $mocFiles{$mocFile}, 3);        $dir =~ s#^\.#\$(srcdir)#;        if (defined ($cppFile))        {            appendLines ("\$(srcdir)/$cppFile: $mocFile.moc\n$mocFile.moc: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile.moc\n");            $cleanMoc .= " $mocFile.moc";        }        else        {            appendLines ("$mocFile$mocExt: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile$mocExt\n");            $cleanMoc .= " $mocFile$mocExt";        }    }	    if ($cleanMoc) {      # Always add dist clean tag      # Add extra *.moc.cpp files created for USE_AUTOMOC because they      # aren't included in the normal *.moc clean rules.      appendLines ("$cleantarget-metasources:\n\t-rm -f $cleanMoc\n");      $target_adds{"$cleantarget-am"} .= "$cleantarget-metasources ";    }  }#-----------------------------------------------------------------------------sub updateMakefile (){    return if ($dryrun);    open (FILEOUT, "> $makefile")                        || die "Could not create $makefile: $!\n";    print FILEOUT "\# $progId - " . '$Revision: 1.154 $ '  . "\n";    $MakefileData =~ s/\034/\\\n/g;    # Restore continuation lines    print FILEOUT $MakefileData;    close FILEOUT;}#-----------------------------------------------------------------------------# The given line needs to be removed from the makefile# Do this by adding the special "removed line" comment at the line start.sub removeLine ($$){    my ($lookup, $old) = @_;    $old =~ s/\034/\\\n#>- /g;          # Fix continuation lines    $MakefileData =~ s/\n$lookup/\n#>\- $old/;}#-----------------------------------------------------------------------------# Replaces the old line with the new line# old line(s) are retained but tagged as removed. The new line(s) have the# "added" tag placed before it.sub substituteLine ($$){    my ($lookup, $new) = @_;    if ($MakefileData =~ /\n($lookup)/) {      $old = $1;      $old =~ s/\034/\\\n#>\- /g;         # Fix continuation lines      $new =~ s/\034/\\\n/g;      my $newCount = 1;      $newCount++  while ($new =~ /\n/g);      $MakefileData =~ s/\n$lookup/\n#>- $old\n#>\+ $newCount\n$new/;    } else {      print STDERR "Warning: substitution of \"$lookup\" in $printname failed\n";    }}#-----------------------------------------------------------------------------# Slap new lines on the back of the file.sub appendLines ($){    my ($new) = @_;    $new =~ s/\034/\\\n/g;        # Fix continuation lines    my $newCount = 1;    $newCount++  while ($new =~ /\n/g);    $MakefileData .= "\n#>\+ $newCount\n$new";}#-----------------------------------------------------------------------------# Restore the Makefile.in to the state it was before we fiddled with itsub restoreMakefile (){    $MakefileData =~ s/# $progId[^\n\034]*[\n\034]*//g;    # Restore removed lines    $MakefileData =~ s/([\n\034])#>\- /$1/g;    # Remove added lines    while ($MakefileData =~ /[\n\034]#>\+ ([^\n\034]*)/)    {        my $newCount = $1;        my $removeLines = "";        while ($newCount--) {            $removeLines .= "[^\n\034]*([\n\034]|)";        }        $MakefileData =~ s/[\n\034]#>\+.*[\n\034]$removeLines/\n/;    }}#-----------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -