am_edit

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

TXT
1,913
字号
        my $lookup = quotemeta($add) . ":\s*(.*)";        if ($MakefileData =~ /\n$lookup\n/) {            substituteLine($lookup, "$add: " . $target_adds{$add} . $1);        } else {            $lines .= "$add: " . $target_adds{$add} . "\n";        }    }    if ($lines) {        appendLines($lines);    }    my $found = 1;        while ($found) {        if ($MakefileData =~ m/\n(.*)\$\(CXXFLAGS\)(.*)\n/) {            my $vor = $1;            my $nach = $2;            my $lookup = quotemeta("$1\$(CXXFLAGS)$2");            my $replacement = "$1\$(KCXXFLAGS)$2";            $MakefileData =~ s/$lookup/$replacement/;            $lookup =~ s/\\\$\\\(CXXFLAGS\\\)/\\\$\\\(KCXXFLAGS\\\)/;            $replacement = "$vor\$(KCXXFLAGS) \$(KDE_CXXFLAGS)$nach";            substituteLine($lookup, $replacement);        } else {            $found = 0;        }    }    $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=link) (\$\(CXXLD\).*\$\(KCXXFLAGS\))';        if ($MakefileData =~ m/$lookup/ ) {        $MakefileData =~ s/$lookup/$1 --tag=CXX $2/;    }    $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=compile) (\$\(CXX\).*\$\(KCXXFLAGS\))';    if ($MakefileData =~ m/$lookup/ ) {        $MakefileData =~ s/$lookup/$1 --tag=CXX $2/;    }    $MakefileData =~ s/\$\(KCXXFLAGS\)/\$\(CXXFLAGS\)/g;    $lookup = '(.*)cp -pr \$\$/\$\$file \$\(distdir\)/\$\$file(.*)';    if ($MakefileData =~ m/$lookup/) {        substituteLine($lookup, "$1cp -pr \$\$d/\$\$file \$(distdir)/\$\$file$2");    }    # Always update the Makefile.in    updateMakefile ();    return;}#-----------------------------------------------------------------------------# Check to see whether we should process this make file.# This is where we look for tags that we need to process.# A small amount of initialising on the tags is also done here.# And of course we open and/or create the needed make files.sub initialise (){    if (! -r "Makefile.am") {	print STDOUT "found Makefile.in without Makefile.am\n" if ($verbose);	return 0;    }    # Checking for files to process...    open (FILEIN, $makefile)      || die "Could not open $makefileDir/$makefile: $!\n";    # Read the file    while ( <FILEIN> )    {        $MakefileData .= $_;    }    close FILEIN;    # Remove the line continuations, but keep them marked    # Note: we lose the trailing spaces but that's ok.    $MakefileData =~ s/\\\s*\n/\034/g;    # If we've processed the file before...    restoreMakefile ()      if ($MakefileData =~ /$progId/);    foreach $dir (@foreignfiles) {      if (substr($makefileDir,0,length($dir)) eq $dir) {	return 0;      }    }    %kdeopts = ();    $kdeopts{"foreign"} = 0;    $kdeopts{"qtonly"} = 0;    $kdeopts{"nofinal"} = !$use_final; # default    if ($MakefileData =~ /\nKDE_OPTIONS\s*=\s*([^\n]*)\n/) {        local @kde_options = split(/[\s\034]/, $1);        if (grep(/^foreign$/, @kde_options)) {            push(@foreignfiles, $makefileDir . "/");            return 0; # don't touch me        }        for $opt (@kde_options) {            if (!defined $kdeopts{$opt}) {                print STDERR "Warning: unknown option $opt in $printname\n";            } else {                $kdeopts{$opt} = 1;            }        }    }    # Look for the tags that mean we should process this file.    $metasourceTags = 0;    $metasourceTags++    while ($MakefileData =~ /\n[^=\#]*METASOURCES\s*=/g);    my $pofileTag = 0;    $pofileTag++    while ($MakefileData =~ /\nPOFILES\s*=/g);    if ($pofileTag > 1)      {          print STDERR "Error: Only one POFILES tag allowed\n";          $errorflag = 1;      }    while ($MakefileData =~ /\n\.SUFFIXES:([^\n]+)\n/g) {	my @list=split(' ', $1);	my $extions = " " . $cppExt . " ";	foreach $ext (@list) {	    if ($extions =~ / \*\Q$ext\E /) {		$cxxsuffix = $ext;		$cxxsuffix =~ s/\.//g;		print STDOUT "will use suffix $cxxsuffix\n" if ($verbose);		last;	    }	}    }                                                         while ($MakefileData =~ /\n(\S*)_OBJECTS\s*=[ \t\034]*([^\n]*)\n/g) {                my $program = $1;        my $objs = $2; # safe them                my $ocv = 0;                my @objlist = split(/[\s\034]+/, $objs);        foreach $obj (@objlist) {            if ($obj =~ /\$\((\S+)\)/ ) {                my $variable = $1;                if ($variable !~ 'OBJEXT') {                    $ocv = 1;                }            }        }                next if ($ocv);                $program =~ s/^am_// if ($program =~ /^am_/);                print STDOUT "found program $program\n" if ($verbose);        push(@programs, $program);                $realObjs{$program} = $objs;                if ($MakefileData =~ /\n$program\_SOURCES\s*=\s*(.*)\n/) {            $sources{$program} = $1;        } else {            $sources{$program} = "";            print STDERR "found program with no _SOURCES: $program\n";        }                my $realprogram = $program;        $realprogram =~ s/_/./g; # unmask to regexp        if ($MakefileData =~ /\n($realprogram)(\$\(EXEEXT\)?)?:.*\$\($program\_OBJECTS\)/) {            $realname{$program} = $1;        } else {            # not standard Makefile - nothing to worry about            $realname{$program} = "";        }    }        my $lookup = '\nDEPDIR\s*=.*';    if ($MakefileData !~ /($lookup)\n/) {        $lookup = '\nbindir\s*=.*';        if ($MakefileData =~ /($lookup)\n/) {            substituteLine ($lookup, "DEPDIR = .deps\n$1");        }    } else {        print STDERR "$printname defines DEPDIR. This means you're using automake > 1.4 - this is not supported!\n";    }    my @marks = ('MAINTAINERCLEANFILES', 'CLEANFILES', 'DISTCLEANFILES');    foreach $mark (@marks) {        while ($MakefileData =~ /\n($mark)\s*=\s*([^\n]*)/g) {            foreach $file (split('[\034\s]', $2)) {                $file =~ s/\.\///;                push(@cleanfiles, $file);            }        }    }    my $localTag = 0;    $localTag++ if ($MakefileData =~ /\ninstall-\S+-local:/);        return (!$errorflag);}#-----------------------------------------------------------------------------# Gets the list of user defined directories - relative to $srcdir - where# header files could be located.sub tag_META_INCLUDES (){    my $lookup = '[^=\n]*META_INCLUDES\s*=\s*(.*)';    return 1    if ($MakefileData !~ /($lookup)\n/);    print STDOUT "META_INCLUDE processing <$1>\n"       if ($verbose);    my $headerStr = $2;    removeLine ($lookup, $1);    $headerStr =~ tr/\034/ /;    my @headerlist = split(' ', $headerStr);    foreach $dir (@headerlist)    {        $dir =~ s#\$\(srcdir\)#.#;        if (! -d $dir)        {            print STDERR "Warning: $dir can't be found. ",                            "Must be a relative path to \$(srcdir)\n";        }        else        {            push (@headerdirs, $dir);        }    }    return 0;}#-----------------------------------------------------------------------------sub tag_FINAL(){    my @final_names = ();        foreach $program (@programs) {                if ($sources{$program} =~ /\(/) {            print STDOUT "found ( in $program\_SOURCES. skipping\n" if ($verbose);            next;        }                my $mocsources = "";                my @progsources = split(/[\s\034]+/, $sources{$program});        my %sourcelist = ();                foreach $source (@progsources) {            my $suffix = $source;            $suffix =~ s/^.*\.([^\.]+)$/$1/;                        if (defined($sourcelist{$suffix})) {                $sourcelist{$suffix} .= " " . $source;            } else {                $sourcelist{$suffix} .= $source;            }        }                foreach $suffix (keys %sourcelist) {                        # See if this file contains c++ code. (ie Just check the files suffix against            my $suffix_is_cxx = 0;            foreach $cxx_suffix (split(' ', $cppExt)) {                $cxx_suffix =~ s/^\*\.//;                $cxx_suffix = quotemeta($cxx_suffix);                if ($suffix =~ $cxx_suffix) {                    $suffix_is_cxx = 1;                    last; # $cxx_suffix                }            }                        my $mocfiles_in = ($suffix eq $cxxsuffix) &&              defined($depedmocs{$program});                        my @sourcelist = split(/[\s\034]+/, $sourcelist{$suffix});                        if ((@sourcelist == 1 && !$mocfiles_in) || $suffix_is_cxx != 1 ) {                                # we support IDL on our own                if ($suffix =~ /^skel$/ || $suffix =~ /^stub/ || $suffix =~ /^h$/                    || $suffix =~ /^ui$/ ) {                    next;                }                                foreach $file (@sourcelist) {                                        $file =~ s/\Q$suffix\E$//;                                        $finalObjs{$program} .= $file;                    if ($program =~ /_la$/) {                        $finalObjs{$program} .= "lo ";                    } else {                        $finalObjs{$program} .= "o ";                    }                }                next; # suffix            }                        my $source_deps = "";            foreach $source (@sourcelist) {                if (-f $source) {                    $source_deps .= "\$(srcdir)/$source ";                } else {                    $source_deps .= "$source ";                }            }                        $handling = "$program.all_$suffix.$suffix: \$(srcdir)/Makefile.in " . $source_deps . " ";                        if ($mocfiles_in) {                $handling .= $depedmocs{$program};                foreach $mocfile (split(' ', $depedmocs{$program})) {                    if ($mocfile =~ m/\.$suffix$/) {                        $mocsources .= " " . $mocfile;                    }                }            }                        $handling .= "\n";            $handling .= "\t\@echo 'creating $program.all_$suffix.$suffix ...'; \\\n";            $handling .= "\trm -f $program.all_$suffix.files $program.all_$suffix.final; \\\n";            $handling .= "\techo \"#define KDE_USE_FINAL 1\" >> $program.all_$suffix.final; \\\n";            $handling .= "\tfor file in " . $sourcelist{$suffix} . " $mocsources; do \\\n";            $handling .= "\t  echo \"#include \\\"\$\$file\\\"\" >> $program.all_$suffix.files; \\\n";            $handling .= "\t  test ! -f \$\(srcdir\)/\$\$file || egrep '^#pragma +implementation' \$\(srcdir\)/\$\$file >> $program.all_$suffix.final; \\\n";            $handling .= "\tdone; \\\n";            $handling .= "\tcat $program.all_$suffix.final $program.all_$suffix.files  > $program.all_$suffix.$suffix; \\\n";            $handling .= "\trm -f $program.all_$suffix.final $program.all_$suffix.files\n";                        appendLines($handling);                        push(@final_names, "$program.all_$suffix.$suffix");            $finalObjs{$program} .= "$program.all_$suffix.";            if ($program =~ /_la$/) {                $finalObjs{$program} .= "lo ";            } else {                $finalObjs{$program} .= "o ";            }        }    }        if (!$kdeopts{"nofinal"} && @final_names >= 1) {        # add clean-final target        my $lines = "$cleantarget-final:\n";        $lines .= "\t-rm -f " . join(' ', @final_names) . "\n" if (@final_names);        appendLines($lines);        $target_adds{"$cleantarget-am"} .= "$cleantarget-final ";                foreach $finalfile (@final_names) {            $finalfile =~ s/\.[^.]*$/.P/;            $dep_finals .= " \$(DEPDIR)/$finalfile";        }    }}# Organises the list of headers that we'll use to produce moc files# from.sub tag_METASOURCES (){    local @newObs           = ();  # here we add to create object files    local @deped            = ();  # here we add to create moc files    local $mocExt           = ".moc";    local %mocFiles         = ();    my $line = "";    my $postEqual = "";    my $lookup;    my $found = "";    if ($metasourceTags > 1) {	$lookup = $program . '_METASOURCES\s*=\s*(.*)';	return 1    if ($MakefileData !~ /\n($lookup)\n/);	$found = $1;    } else {	$lookup = $program . '_METASOURCES\s*=\s*(.*)';	if ($MakefileData !~ /\n($lookup)\n/) {	    $lookup = 'METASOURCES\s*=\s*(.*)';

⌨️ 快捷键说明

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