am_edit

来自「KDE下的西门子手机管理程序」· 代码 · 共 1,913 行 · 第 1/5 页

TXT
1,913
字号
      $lines .= "\n";      $lines .= "HTML/index.html: HTML index.docbook\n";      $lines .= "\t\@test -d HTML && rm -r HTML\n";      $lines .= "\t\$(KDB2HTML) \$(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 .= "\tfilelist=`(cd HTML && ls -1 * .anchors 2> /dev/null)`; for file in \$\$filelist; do if test -f HTML/\$\$file; then \\\n";      $lines .= "\techo \$(INSTALL_DATA) HTML/\$\$file \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$file ;\\\n";      $lines .= "\t\$(INSTALL_DATA) HTML/\$\$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) /\$(kde_htmldir)/$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);    } 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";    if ($appname eq 'common') {      $tmp .= "\t\@echo \"merging common and language specific dir\" ;\\\n";	  $tmp .= "\tif test ! -e \$(kde_htmldir)/en/common/kde-common.css; then echo 'no english docs found in \$(kde_htmldir)/en/common/'; exit 1; fi \n";      $tmp .= "\t\@com_files=`cd \$(kde_htmldir)/en/common && echo *` ;\\\n";      $tmp .= "\tcd \$(DESTDIR)\$(kde_htmldir)/$kdelang/common ;\\\n";      $tmp .= "\tif test -n \"\$\$com_files\"; then for p in \$\$com_files ; do \\\n";      $tmp .= "\t  case \" $files \" in \\\n";      $tmp .= "\t    *\" \$\$p \"*) ;; \\\n";      $tmp .= "\t    *) test ! -e \$\$p && echo \$(LN_S) ../../en/common/\$\$p \$(DESTDIR)\$(kde_htmldir)/$kdelang/common/\$\$p && \$(LN_S) ../../en/common/\$\$p \$\$p ;; \\\n";      $tmp .= "\t  esac ; \\\n";      $tmp .= "\tdone ; fi ; true\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 =            `egrep -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;    foreach $mocFile (keys (%mocFiles))    {        undef $cppFile;        ($dir, $hFile, $cppFile) =  split ("\035", $mocFiles{$mocFile}, 3);        $dir =~ s#^\.#\$(srcdir)#;        if (defined ($cppFile))        {            $target_adds{"\$(srcdir)/$cppFile"} .= "$mocFile.moc ";            appendLines ("$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";        }    }}sub make_meta_classes (){    return if ($kdeopts{"qtonly"});    my $cppFile;    my $hFile;    my $moc_class_headers = "";    my @cppFiles =	`grep -l "setMocClasses[ 	]*(.*)[ 	]*;" $cppExt 2> /dev/null`;    chomp(@cppFiles);    print STDOUT "C++ files with setMocClasses() = [".join(' ', @cppFiles)."]\n"        if $verbose;    foreach $program (@programs) {	my $mocs = "";	my @progsources = split(/[\s\034]+/, $sources{$program});	my @depmocs = split(' ', $depedmocs{$program});	my %shash = (), %mhash = ();	@shash{@progsources} = 1;  # we are only interested in the existence	@mhash{@depmocs} = 1;	print STDOUT "program=$program\n" if ($verbose);	print STDOUT "psources=[".join(' ', keys %shash)."]\n" if ($verbose);	print STDOUT "depmocs=[".join(' ', keys %mhash)."]\n" if ($verbose);	print STDOUT "globalmocs=[".join(' ', keys(%globalmocs))."]\n" if ($verbose);	foreach my $mocFile (keys (%globalmocs))	{	    undef $cppFile;	    ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3);	    $dir =~ s#^\.#\$(srcdir)#;	    if (defined ($cppFile))	    {		#print STDOUT "cpp=$cppFile\n";		$mocs .= " $mocFile.moc" if exists $shash{$cppFile};	    }	    else	    {		# Bah. This is the case, if no C++ file includes the .moc		# file. We make a .moc.cpp file for that. Unfortunately this		# is not included in the %sources hash, but rather is mentioned		# in %depedmocs. If the user wants to use AUTO he can't just		# use an unspecific METAINCLUDES. Instead he must use		# program_METAINCLUDES. Anyway, it's not working real nicely.		# E.g. Its not clear what happens if user specifies two		# METAINCLUDES=AUTO in the same Makefile.am.		$mocs .= " $mocFile.moc.$cxxsuffix"		    if exists $mhash{$mocFile.".moc.$cxxsuffix"};	    }	}  	$mocs .= $ui_mocs;	if ($mocs) {	    print STDOUT "==> mocs=[".$mocs."]\n" if ($verbose);	    my $sourcename = $program."_meta_unload";	    my $ext = ($program =~ /_la$/) ? ".lo" : ".o";	    my $srcfile = $sourcename.".$cxxsuffix";	    my $objfile = $sourcename.$ext;	    $moc_class_headers .= " $srcfile";	    my $appl;	    $appl  = "$srcfile: $mocs\n";	    $appl .= "\t\@echo 'creating $srcfile'\n";	    $appl .= "\t-rm -f $srcfile\n";	    $appl .= "\t\@echo 'static const char * _metalist_$program\[\] = {' > $srcfile\n";	    $appl .= "\tcat $mocs | grep 'char.*className' | ";	    $appl .=  "sed -e 's/.*[^A-Za-z0-9_:]\\([A-Za-z0-9_:]*\\)::className.*\$\$/\\\"\\1\\\",/' | sort | uniq >> $srcfile\n";	    $appl .= "\t\@echo '0};' >> $srcfile\n";	    $appl .= "\t\@echo '#include <kunload.h>' >> $srcfile\n";	    $appl .= "\t\@echo '_UNLOAD($program)' >> $srcfile\n";		$appl .= "\n";	    	    $realObjs{$program} .= " \034" . $objfile . " ";	    $sources{$program} .= " $srcfile";            $sources_changed{$program} = 1;            $dep_files .= " \$(DEPDIR)/$sourcename.P";	    # now also add a dependency for the C++ file which includes a	    # setMocClasses() call, and is part of this program (if any)	    #foreach $cppFile (@cppFiles) {		#print STDOUT "testing $cppFile\n" if $verbose;	        #if (exists $shash{$cppFile}) {		#    $appl .= "\$(srcdir)/$cppFile: $header\n";		#}	    #}	    appendLines ($appl);	}	print STDOUT "\n" if $verbose;    }    if ($moc_class_headers) {        appendLines ("$cleantarget-moc-classes:\n\t-rm -f $moc_class_headers\n");        $target_adds{"$cleantarget-am"} .= "$cleantarget-moc-classes ";    }}#-----------------------------------------------------------------------------sub updateMakefile (){    return if ($dryrun);    open (FILEOUT, "> $makefile")                        || die "Could not create $makefile: $!\n";    print FILEOUT "\# $progId - " . '$Revision: 1.1.1.1 $ '  . "\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 + =
减小字号Ctrl + -
显示快捷键?