📄 am_edit
字号:
$target_adds{"clean"} .= "kde-rpo-clean "; # some strange people like to do a install-exec, and expect that also # all modules are installed. automake doesn't know this, so we need to move # this here from install-data to install-exec. if ($MakefileData =~ m/\nkde_module_LTLIBRARIES\s*=/) { $target_adds{"install-exec-am"} .= "install-kde_moduleLTLIBRARIES"; my $lookup = 'install-data-am:\s*(.*)'; if ($MakefileData =~ /\n$lookup\n/) { my $newdeps = $1; $newdeps =~ s/\s*install-kde_moduleLTLIBRARIES\s*/ /g; substituteLine($lookup, "install-data-am: " . $newdeps); } } my $lines = ""; foreach $add (keys %target_adds) { my $lookup = quotemeta($add) . ':([^\n]*)'; 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; # "vor" means before in German my $nach = $2; # "nach" means after in German 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; } } if($foreign_libtool == 0) { $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=link) (\$\(CXXLD\).*\$\(KCXXFLAGS\))'; if ($MakefileData =~ m/$lookup/ ) { $MakefileData =~ s/$lookup/$1 --tag=CXX $2/; } $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=compile)\s+(\$\(CXX\)\s+)'; 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/\n$lookup\n/) { 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 # stat(FILEIN)[7] might look more elegant, but is slower as it # requires stat'ing the file seek(FILEIN, 0, 2); my $fsize = tell(FILEIN); seek(FILEIN, 0, 0); read FILEIN, $MakefileData, $fsize; close FILEIN; print "DOS CRLF within $makefileDir/$makefile!\n" if($MakefileData =~ y/\r//d); # Remove the line continuations, but keep them marked # Note: we lose the trailing spaces but that's ok. $MakefileData =~ s/\\\s*\n\s*/\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{"noautodist"} = 0; $kdeopts{"foreign-libtool"} = $foreign_libtool; $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); foreach $ext (@list) { if ($ext =~ /^\.$cppExt$/) { $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_/); my $sourceprogram = $program; $sourceprogram =~ s/\@am_/\@/ if($sourceprogram =~ /^.*\@am_.+/); print STDOUT "found program $program\n" if ($verbose); push(@programs, $program); $realObjs{$program} = $objs; if ($MakefileData =~ /\n$sourceprogram\_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/o) { $lookup = '\nbindir\s*=.*'; if ($MakefileData =~ /($lookup)\n/) { substituteLine ($lookup, "DEPDIR = .deps\n$1"); } } 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/o); 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; if($suffix =~ /($cppExt)$/) { $cxxsuffix = $1; $suffix_is_cxx = 1; } 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 =~ /^signals/ || $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"; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -