Mercurial > hg > easyhg-kdiff3
diff kdiff3/admin/am_edit @ 14:415083d043f3
KDiff3 version 0.9.70
author | joachim99 |
---|---|
date | Mon, 06 Oct 2003 19:19:11 +0000 |
parents | 53b8ecbce0cb |
children | efe33e938730 |
line wrap: on
line diff
--- a/kdiff3/admin/am_edit Mon Oct 06 19:12:57 2003 +0000 +++ b/kdiff3/admin/am_edit Mon Oct 06 19:19:11 2003 +0000 @@ -18,7 +18,7 @@ # KDE_ICON = AUTO # # For documentation : -# ... +# http://developer.kde.org/documentation/other/developer-faq.html # # and more new tags TBD! # @@ -31,6 +31,7 @@ # Alex Zepeda <jazepeda@pacbell.net> # David Faure <faure@kde.org> # Stephan Kulow <coolo@kde.org> +# Dirk Mueller <mueller@kde.org> use Cwd; use File::Find; @@ -62,7 +63,10 @@ sub tag_SUBDIRS(); sub tag_ICON(); sub tag_CLOSURE(); +sub tag_NO_UNDEFINED(); +sub tag_NMCHECK(); sub tag_DIST(); +sub tag_KDEINIT(); # Some global globals... $verbose = 0; # a debug flag @@ -99,6 +103,7 @@ "Making it useful by Stephan Kulow <coolo\@kde.org> and\n", "Harri Porten <porten\@kde.org>\n", "Updated (Feb-1999), John Birch <jb.nz\@writeme.com>\n", + "Fixes and Improvements by Dirk Mueller <mueller\@kde.org>\n", "Current Maintainer Stephan Kulow\n\n"; exit 0; } @@ -117,15 +122,15 @@ { print STDOUT "Usage $thisProg [OPTION] ... [dir/Makefile.in]...\n", "\n", - "Patches dir/Makefile.in generated from automake\n", - "(where dir can be a full or relative directory name)", + "Patches dir/Makefile.in generated by automake\n", + "(where dir can be an absolute or relative directory name)\n", "\n", " -v, --verbose verbosely list files processed\n", " -h, --help print this help, then exit\n", " --version print version number, then exit\n", " -p, --path= use the path to am_edit if the path\n", - " --no-final don't patch for --enable-final\n", - " called from is not the one to be used\n"; + " called from is not the one to be used\n", + " --no-final don't patch for --enable-final\n"; exit 0; } @@ -168,7 +173,7 @@ find (\&add_makefile, cwd()); #chdir('$topdir'); } else { - print STDOUT "Using user enter input files\n" if ($verbose); + print STDOUT "Using input files specified by user\n" if ($verbose); } foreach $makefile (sort(@makefiles)) @@ -207,6 +212,8 @@ local @programs = (); # lists the names of programs and libraries local $program = ""; + local @kdeinits = (); # lists the kdeinit targets + local %realObjs = (); # lists the objects compiled into $program local %sources = (); # lists the sources used for $program local %finalObjs = (); # lists the objects compiled when final @@ -220,17 +227,20 @@ local $idl_output = "";# lists all idl generated files for cleantarget local $ui_output = "";# lists all uic generated files for cleantarget - local %depedmocs = (); + local %dependmocs = (); local $metasourceTags = 0; local $dep_files = ""; local $dep_finals = ""; local %target_adds = (); # the targets to add + local %rule_adds = (); local $kdelang = ""; local @cleanfiles = (); local $cleanMoc = ""; local $closure_output = ""; + local %varcontent = (); + $makefileDir = dirname($makefile); chdir ($makefileDir); $printname = $makefile; @@ -238,24 +248,36 @@ $makefile = basename($makefile); print STDOUT "Processing makefile $printname\n" if ($verbose); - + # Setup and see if we need to do this. return if (!initialise()); - + tag_AUTOMAKE (); # Allows a "make" to redo the Makefile.in tag_META_INCLUDES (); # Supplies directories for src locations - + foreach $program (@programs) { $sources_changed{$program} = 0; - $depedmocs{$program} = ""; + $dependmocs{$program} = ""; $important{$program} = ""; tag_IDLFILES(); # Sorts out idl rules + tag_NO_UNDEFINED(); tag_CLOSURE(); + tag_NMCHECK(); tag_UIFILES(); # Sorts out ui rules tag_METASOURCES (); # Sorts out the moc rules if ($sources_changed{$program}) { - my $lookup = "$program" . '_SOURCES\s*=\s*(.*)'; - substituteLine($lookup, "$program\_SOURCES=" . $sources{$program}); + my $lookup = $program . '_SOURCES\s*=[ \t]*(.*)'; + + if($program =~ /libkdeinit_(.*)/) { + my $prog = $1; + substituteLine($prog . '_SOURCES\s*=[ \t]*.*', + "${prog}_SOURCES = ${prog}_dummy.$cxxsuffix\n" . + "libkdeinit_${prog}_SOURCES = " . $sources{$program}); + $sources{$prog} = "${prog}_dummy.$cxxsuffix"; + } + else { + substituteLine($lookup, "$program\_SOURCES=" . $sources{$program}); + } } if ($important{$program}) { local %source_dict = (); @@ -285,7 +307,8 @@ appendLines ("$cleantarget-metasources:\n\t-rm -f $cleanMoc\n"); $target_adds{"$cleantarget-am"} .= "$cleantarget-metasources "; } - tag_DIST(); + + tag_DIST() unless ($kdeopts{"noautodist"}); if ($idl_output) { appendLines ("$cleantarget-idl:\n\t-rm -f $idl_output\n"); @@ -318,6 +341,7 @@ $tmp .= "\t$automkCall\n\tcd \$(top_srcdir) && perl $thisProg $printname\n\n"; appendLines($tmp); + make_bcheck_target(); make_meta_classes(); tag_COMPILE_FIRST(); tag_FINAL() if (!$kdeopts{"nofinal"}); @@ -328,20 +352,15 @@ my $nofinal_install_lines = "no-final-install:\n\t\$(MAKE) "; foreach $program (@programs) { - - my $lookup = "$program\_OBJECTS.*=[^\n]*"; - + my $lookup = $program . '_OBJECTS\s*=[ \t]*.*'; my $new = ""; - my @list = split(/[\034\s]+/, $realObjs{$program}); - if (!$kdeopts{"nofinal"} && @list > 1 && $finalObjs{$program}) { - $new .= "$program\_final\_OBJECTS = " . $finalObjs{$program}; $new .= "\n$program\_nofinal\_OBJECTS = " . $realObjs{$program}; $new .= "\n\@KDE_USE_FINAL_FALSE\@$program\_OBJECTS = \$($program\_nofinal\_OBJECTS)"; $new .= "\n\@KDE_USE_FINAL_TRUE\@$program\_OBJECTS = \$($program\_final\_OBJECTS)"; - + $final_lines .= "$program\_OBJECTS=\"\$($program\_final_OBJECTS)\" "; $final_install_lines .= "$program\_OBJECTS=\"\$($program\_final_OBJECTS)\" "; $nofinal_lines .= "$program\_OBJECTS=\"\$($program\_nofinal\_OBJECTS)\" "; @@ -349,74 +368,110 @@ } else { $new = "$program\_OBJECTS = " . $realObjs{$program}; } - substituteLine ($lookup, $new); + if($MakefileData =~ m/\n$lookup/) { + substituteLine ($lookup, $new); + } + else { + appendLines("$new\n"); + } } - appendLines($final_lines . "all-am"); - appendLines($final_install_lines . "install-am"); - appendLines($nofinal_lines . "all-am"); - appendLines($nofinal_install_lines . "install-am"); - - my $lookup = 'DEP_FILES\s*=([^\n]*)'; - if ($MakefileData =~ /\n$lookup\n/o) { - $depfiles = $1; - + appendLines($final_lines . "all-am\n"); + appendLines($final_install_lines . "install-am\n"); + appendLines($nofinal_lines . "all-am\n"); + appendLines($nofinal_install_lines . "install-am\n"); + + my $lookup = '(\@\S+\@)?DEP_FILES\s*=[ \t]*(.*)'; + if ($MakefileData =~ /\n$lookup/) { + my $condition = $1; + my $depfiles = $2; + my $workfiles; + if ($dep_finals) { - $lines = "\@KDE_USE_FINAL_TRUE\@DEP_FILES = $dep_files $dep_finals \034\t$depfiles\n"; - $lines .= "\@KDE_USE_FINAL_FALSE\@DEP_FILES = $dep_files $depfiles\n"; + # Add the conditions on every line, since + # there may be line continuations in the list. + $workfiles = "$dep_files $dep_finals $depfiles"; + $workfiles =~ s/\034/\034$condition\@KDE_USE_FINAL_TRUE\@\t/g; + $lines = "$condition\@KDE_USE_FINAL_TRUE\@DEP_FILES = $workfiles\n"; + $workfiles = "$dep_files $depfiles"; + $workfiles =~ s/\034/\034$condition\@KDE_USE_FINAL_FALSE\@\t/g; + $lines .= "$condition\@KDE_USE_FINAL_FALSE\@DEP_FILES = $workfiles"; } else { - $lines = "DEP_FILES = $dep_files $depfiles\n"; + $workfiles = "$dep_files $depfiles"; + $workfiles =~ s/\034/\034$condition\t/g; + $lines = $condition . "DEP_FILES = $workfiles"; } - substituteLine($lookup, $lines); } - + + # new recursive targets + $target_adds{ "nmcheck" } .= ""; # always create nmcheck target + $target_adds{ "nmcheck-am" } .= "nmcheck"; + $lookup = 'RECURSIVE_TARGETS\s*=[ \t]*(.*)'; + if ($MakefileData =~ /\n$lookup/) { + substituteLine($lookup, "RECURSIVE_TARGETS = $1 nmcheck-recursive bcheck-recursive"); + } + my $cvs_lines = "cvs-clean:\n"; - $cvs_lines .= "\t\$(MAKE) -f \$(top_srcdir)/admin/Makefile.common cvs-clean\n"; + $cvs_lines .= "\t\$(MAKE) admindir=\$(top_srcdir)/admin -f \$(top_srcdir)/admin/Makefile.common cvs-clean\n"; appendLines($cvs_lines); - + $cvs_lines = "kde-rpo-clean:\n"; $cvs_lines .= "\t-rm -f *.rpo\n"; appendLines($cvs_lines); $target_adds{"clean"} .= "kde-rpo-clean "; + my %target_dels = ("install-data-am" => ""); + # 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); +# $target_adds{"install-exec-am"} .= "install-kde_moduleLTLIBRARIES "; +# don't use $target_adds here because we need to append the dependency, not +# prepend it. Fixes #44342 , when a module depends on a lib in the same dir +# and libtool needs it during relinking upon install (Simon) + my $lookup = "install-exec-am:([^\n]*)"; + if($MakefileData =~ /\n$lookup\n/) { + substituteLine("$lookup", "install-exec-am: $1 install-kde_moduleLTLIBRARIES"); } + $target_dels{"install-data-am"} .= "install-kde_moduleLTLIBRARIES "; + $target_adds{"install-data-am"} .= " "; } - + my $lines = ""; foreach $add (keys %target_adds) { my $lookup = quotemeta($add) . ':([^\n]*)'; if ($MakefileData =~ /\n$lookup\n/) { - substituteLine($lookup, "$add: " . $target_adds{$add} . $1); + my $newlines = $1; + my $oldlines = $lookup; + if (defined $target_dels{$add}) { + foreach $del (split(' ', $target_dels{$add})) { + $newlines =~ s/\s*$del\s*/ /g; + } + } + substituteLine($oldlines, "$add: " . $target_adds{$add} . $newlines); } else { - $lines .= "$add: " . $target_adds{$add} . "\n"; + $lines .= "$add: " . $target_adds{$add} . "\n"; } } - if ($lines) { - appendLines($lines); - } + + appendLines($lines) if ($lines); + + $lines = join("\n", values %rule_adds); + appendLines($lines) if ($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 $stuff_before = $1; + my $stuff_after = $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"; + $replacement = "$stuff_before\$(KCXXFLAGS) \$(KDE_CXXFLAGS)$stuff_after"; substituteLine($lookup, $replacement); } else { $found = 0; @@ -425,12 +480,12 @@ 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) (\$\(CXX\).*\$\(KCXXFLAGS\))'; + $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=compile)\s+(\$\(CXX\)\s+)'; if ($MakefileData =~ m/$lookup/ ) { $MakefileData =~ s/$lookup/$1 --tag=CXX $2/; } @@ -450,6 +505,16 @@ #----------------------------------------------------------------------------- +# Beware: This procedure is not complete. E.g. it also parses lines +# containing a '=' in rules (for instance setting shell vars). For our +# usage this us enough, though. +sub read_variables () +{ + while ($MakefileData =~ /\n\s*(\S+)\s*=([^\n]*)/g) { + $varcontent{$1} = $2; + } +} + # 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. @@ -476,7 +541,9 @@ # 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; + # Don't mangle line-leading spaces (usually tabs) + # since they're important. + $MakefileData =~ s/\\\s*\n/\034/g; # If we've processed the file before... restoreMakefile () if ($MakefileData =~ /$progId/); @@ -490,11 +557,15 @@ %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); + read_variables(); + + if ($MakefileData =~ /\nKDE_OPTIONS\s*=[ \t]*([^\n]*)\n/) { + my $kde_options_str = $1; + local @kde_options = split(/[\034\s]+/, $kde_options_str); if (grep(/^foreign$/, @kde_options)) { push(@foreignfiles, $makefileDir . "/"); return 0; # don't touch me @@ -521,7 +592,8 @@ } while ($MakefileData =~ /\n\.SUFFIXES:([^\n]+)\n/g) { - my @list=split(' ', $1); + my $suffixes_str = $1; + my @list=split(' ', $suffixes_str); foreach $ext (@list) { if ($ext =~ /^\.$cppExt$/) { $cxxsuffix = $ext; @@ -531,37 +603,44 @@ } } } - - while ($MakefileData =~ /\n(\S*)_OBJECTS\s*=[ \t\034]*([^\n]*)\n/g) { - + + tag_KDEINIT(); + + while ($MakefileData =~ /\n(\S*)_OBJECTS\s*=[\034 \t]*([^\n]*)\n/g) { + my $program = $1; my $objs = $2; # safe them - + my $ocv = 0; - - my @objlist = split(/[\s\034]+/, $objs); + + my @objlist = split(/[\034\s]+/, $objs); foreach $obj (@objlist) { - if ($obj =~ /\$\((\S+)\)/ ) { - my $variable = $1; - if ($variable !~ 'OBJEXT') { + if ($obj =~ /(\S*)\$\((\S+)\)/ ) { + my $pre = $1; + my $variable = $2; + if ($pre eq '' && exists($varcontent{$variable})) { + my @addlist = split(/[\034\s]+/, $varcontent{$variable}); + push(@objlist, @addlist); + } elsif ($variable !~ 'OBJEXT') { $ocv = 1; - } + } } } - + next if ($ocv); + next if ($program =~ /^am_libkdeinit_/); $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/) { + + if ($MakefileData =~ /\n$sourceprogram\_SOURCES\s*=[ \t]*(.*)\n/) { $sources{$program} = $1; } else { @@ -578,19 +657,18 @@ $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 $lookup = 'DEPDIR\s*=.*'; + if ($MakefileData !~ /\n$lookup/) { + $lookup = 'bindir\s*=[ \t]*.*'; + substituteLine($lookup, "DEPDIR = .deps\n$1") if ($MakefileData =~ /\n($lookup)/); + } my @marks = ('MAINTAINERCLEANFILES', 'CLEANFILES', 'DISTCLEANFILES'); foreach $mark (@marks) { - while ($MakefileData =~ /\n($mark)\s*=\s*([^\n]*)/g) { - foreach $file (split('[\034\s]', $2)) { + while ($MakefileData =~ /\n($mark)\s*=[ \t]*([^\n]*)/g) { + my $clean_str = $2; + foreach $file (split('[\034\s]+', $clean_str)) { $file =~ s/\.\///; push(@cleanfiles, $file); } @@ -609,15 +687,14 @@ # header files could be located. sub tag_META_INCLUDES () { - my $lookup = '[^=\n]*META_INCLUDES\s*=\s*(.*)'; - return 1 if ($MakefileData !~ /($lookup)\n/o); + my $lookup = '[^=\n]*META_INCLUDES\s*=[ \t]*(.*)'; + 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); + my @headerlist = split(/[\034\s]+/, $headerStr); foreach $dir (@headerlist) { @@ -648,47 +725,55 @@ print STDOUT "found ( in $program\_SOURCES. skipping\n" if ($verbose); next; } + + my $mocs = ""; # Moc files (in this program) + my $moc_cpp_added = 0; # If we added some .moc.cpp files, due to + # no other .cpp file including the .moc one. - my $mocsources = ""; - - my @progsources = split(/[\s\034]+/, $sources{$program}); + my @progsources = split(/[\034\s]+/, $sources{$program}); + my %shash = (); + @shash{@progsources} = 1; # we are only interested in the existence my %sourcelist = (); foreach $source (@progsources) { my $suffix = $source; $suffix =~ s/^.*\.([^\.]+)$/$1/; - if (defined($sourcelist{$suffix})) { - $sourcelist{$suffix} .= " " . $source; + $sourcelist{$suffix} .= "$source "; + } + foreach my $mocFile (keys (%globalmocs)) + { + my ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3); + if (defined ($cppFile)) { + $mocs .= " $mocFile.moc" if exists $shash{$cppFile}; } else { - $sourcelist{$suffix} .= $source; - } + $sourcelist{$cxxsuffix} .= "$mocFile.moc.$cxxsuffix "; + $moc_cpp_added = 1; + } } - foreach $suffix (keys %sourcelist) { - # See if this file contains c++ code. (ie Just check the files suffix against + # See if this file contains c++ code. (i.e., just check the file's suffix against c++ extensions) my $suffix_is_cxx = 0; if($suffix =~ /($cppExt)$/) { $cxxsuffix = $1; $suffix_is_cxx = 1; } - my $mocfiles_in = ($suffix eq $cxxsuffix) && - defined($depedmocs{$program}); + my $mocfiles_in = ($suffix eq $cxxsuffix) && $moc_cpp_added; - my @sourcelist = split(/[\s\034]+/, $sourcelist{$suffix}); + my @sourcelist = split(/[\034\s]+/, $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$/ ) { + if ($suffix eq "skel" || $suffix =~ /^stub/ + || $suffix =~ /^signals/ # obsolete, remove in KDE-4 + || $suffix eq "h" || $suffix eq "ui" ) { next; } foreach $file (@sourcelist) { - $file =~ s/\Q$suffix\E$//; $finalObjs{$program} .= $file; @@ -704,44 +789,33 @@ my $source_deps = ""; foreach $source (@sourcelist) { if (-f $source) { - $source_deps .= "\$(srcdir)/$source "; + $source_deps .= " \$(srcdir)/$source"; } else { - $source_deps .= "$source "; + $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 = "$program.all_$suffix.$suffix: \$(srcdir)/Makefile.in" . $source_deps . " " . join(' ', $mocs) . "\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 .= "\tfor file in " . $sourcelist{$suffix} . "; 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 .= "\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."; + my $finalObj = "$program.all_$suffix."; if ($program =~ /_la$/) { - $finalObjs{$program} .= "lo "; + $finalObj .= "lo"; } else { - $finalObjs{$program} .= "o "; + $finalObj .= "o"; } + $finalObjs{$program} .= $finalObj . " "; } } @@ -759,17 +833,185 @@ } } +sub tag_KDEINIT() +{ + my @progs = (); + my $ltlibs = ""; + my $lookup = 'kdeinit_LTLIBRARIES\s*=[ \t]*(.*)'; + + if ($MakefileData =~ m/\n$lookup/) { + @kdeinits = split(/[\034\s]+/, $1); + my $lines = ""; + foreach my $kdeinit (@kdeinits) { + if ($kdeinit =~ m/\.la$/) { + $kdeinit =~ s/\.la$//; + push(@progs, $kdeinit); + + $lines .= "\n${kdeinit}.la.$cxxsuffix:\n"; + $lines .= "\techo 'extern \"C\" int kdemain(int argc, char* argv[]);' > ${kdeinit}.la.$cxxsuffix; \\\n"; + $lines .= "\techo 'int main(int argc, char* argv[]) { return kdemain(argc,argv); }' >> ${kdeinit}.la.$cxxsuffix\n"; + + $lines .= "\n${kdeinit}_dummy.$cxxsuffix:\n"; + $lines .= "\t echo > ${kdeinit}_dummy.$cxxsuffix\n"; + + push(@cleanfiles, "${kdeinit}.la.$cxxsuffix"); + push(@cleanfiles, "${kdeinit}_dummy.$cxxsuffix"); + + # add dependency + $dep_files .= " \$(DEPDIR)/${kdeinit}.la.Po" if($dep_files !~/${kdeinit}.la.Po/ ); + $dep_files .= " \$(DEPDIR)/${kdeinit}_dummy.Plo" if($dep_files !~/${kdeinit}_dummy.Plo/ ); + + # make library + $lookup = $kdeinit . '_la_LIBADD\s*=[ \t]*(.*)'; + if($MakefileData =~ m/\n$lookup/) { + my $libadd = $1; + substituteLine($lookup, "${kdeinit}_la_LIBADD = libkdeinit_${kdeinit}.la"); + appendLines("libkdeinit_${kdeinit}_la_LIBADD = $libadd\n"); + } + appendLines("libkdeinit_${kdeinit}_la_LDFLAGS = \$(all_libraries)\n"); + + # add library dependencies + $lookup = $kdeinit . '_la_DEPENDENCIES\s*=[ \t]*(.*)'; + if($MakefileData =~ m/\n$lookup/) { + my $libdeps = $1; + substituteLine($lookup, "${kdeinit}_la_DEPENDENCIES = libkdeinit_${kdeinit}.la"); + appendLines("libkdeinit_${kdeinit}_la_DEPENDENCIES = $libdeps\n"); + } + + # make library objects + $lookup = "am_${kdeinit}_la_OBJECTS" . '\s*=[ \t]*(.*)'; + if($MakefileData =~ m/\n$lookup/) { + my $libobjects = $1; + substituteLine($lookup, "am_${kdeinit}_la_OBJECTS = ${kdeinit}_dummy.lo"); + appendLines("am_libkdeinit_${kdeinit}_la_OBJECTS = $libobjects\n"); + my $prog = "libkdeinit_${kdeinit}_la"; + push(@programs, $prog); + $realObjs{$prog} = $libobjects; + $realname{$prog} = "libkdeinit_${kdeinit}.la"; + } + $target_adds{"libkdeinit_${kdeinit}.la"} = "\$(libkdeinit_${kdeinit}_la_OBJECTS) \$(libkdeinit_${kdeinit}_la_DEPENDENCIES)\n" . + "\t\$(CXXLINK) -rpath \$(libdir) \$(libkdeinit_${kdeinit}_la_LDFLAGS) ". + "\$(libkdeinit_${kdeinit}_la_OBJECTS) " . + "\$(libkdeinit_${kdeinit}_la_LIBADD) " . + "\$(LIBS)\n"; + + # make libkdeinit sources + $lookup = $kdeinit . '_la_SOURCES\s*=[ \t]*(.*)'; + if($MakefileData =~ m/\n$lookup/) { + my $srces = $1; + $sources_changed{"libkdeinit_${kdeinit}_la"} = 1; + $sources{"libkdeinit_${kdeinit}_la"} = $srces; + } + + # make libkdeinit metasources + $lookup = $kdeinit . '_la_METASOURCES\s*=[ \t]*(.*)'; + substituteLine($lookup, "libkdeinit_${kdeinit}_la_METASOURCES = $1") + if($MakefileData =~ m/\n$lookup/); + +=cut + # make binary sources + $lookup = $kdeinit. '_SOURCES\s*=[ \t]*(.*)'; + if($MakefileData =~ m/\n$lookup/) { + substituteLine($lookup, "${kdeinit}_SOURCES = ${kdeinit}.la.$cxxsuffix"); + $lookup = 'SOURCES\s*=[ \t]*(.*)'; + if($MakefileData =~ m/\n$lookup/) { + my $srces = $1; + $srces =~ s/\b$kdeinit\.c\b/\$(${kdeinit}_SOURCES)/; + $srces =~ s/\$\(${kdeinit}_la_SOURCES\)/\$(libkdeinit_${kdeinit}_la_SOURCES)/; + substituteLine($lookup, "SOURCES = $srces"); + } + $lookup = 'DIST_SOURCES\s*=[ \t](.*)'; + if($MakefileData =~ m/\n$lookup/) { + my $srces = $1; + $srces =~ s/\b$kdeinit\.c\b/\$(${kdeinit}_SOURCES)/; + $srces =~ s/\$\(${kdeinit}_la_SOURCES\)/\$(libkdeinit_${kdeinit}_la_SOURCES)/; + substituteLine($lookup, "DIST_SOURCES = $srces"); + } + } + + # make binary objects / libs + $lookup = $kdeinit . '_OBJECTS\s*=[ \t]*.*'; + if($MakefileData =~ m/\n$lookup/) { + $realObjs{$kdeinit} = "${kdeinit}.la.\$(OBJEXT)"; + substituteLine("${kdeinit}_LDFLAGS\\s*=.*", "${kdeinit}_LDFLAGS = \$(all_libraries)"); + substituteLine("${kdeinit}_LDADD\\s*=.*", "${kdeinit}_LDADD = libkdeinit_${kdeinit}.la"); + substituteLine("${kdeinit}_DEPENDENCIES\\s*=.*", "${kdeinit}_DEPENDENCIES = libkdeinit_${kdeinit}.la"); + } +=cut + # add binary + push(@programs, $kdeinit); + $realObjs{$kdeinit} = "${kdeinit}.la.\$(OBJEXT)"; + $realname{$kdeinit} = $kdeinit; + $sources{$kdeinit} = "${kdeinit}.la.$cxxsuffix"; + + $lines .= "${kdeinit}_LDFLAGS = \$(all_libraries)\n"; + $lines .= "${kdeinit}_LDADD = libkdeinit_${kdeinit}.la\n"; + $lines .= "${kdeinit}_DEPENDENCIES = libkdeinit_${kdeinit}.la\n"; + + $target_adds{"${kdeinit}\$(EXEEXT)"} = + "\$(${kdeinit}_OBJECTS) \$(${kdeinit}_DEPENDENCIES)\n" . + "\t\@rm -f ${kdeinit}\$(EXEEXT)\n" . + "\t\$(CXXLINK) \$(${kdeinit}_LDFLAGS) \$(${kdeinit}_OBJECTS) \$(${kdeinit}_LDADD) \$(LIBS)\n"; + + $ltlibs .= " libkdeinit_${kdeinit}.la"; + } + } + appendLines($lines); + + # add libkdeinit target + $lookup = 'lib_LTLIBRARIES\s*=[ \t]*(.*)'; + if($MakefileData =~ m/\n$lookup/) { + substituteLine($lookup, "lib_LTLIBRARIES = $1 $ltlibs"); + } + else { + print STDERR + "Error: lib_LTLIBRARIES missing in $printname (required for kdeinit_LTLIBRARIES).\n"; + $errorflag = 1; + } + } + + if($#progs >= 0) { + if($MakefileData !~ m/\nbin_PROGRAMS\s*=/) { + print STDERR "Error: bin_PROGRAMS missing in $printname (required for bin_PROGRAMS).\n"; + $errorflag = 1; + } + else { + # add our new progs to SOURCES, DIST_SOURCES and bin_PROGRAMS + my $progsources = ""; + my $progexes = ""; + foreach my $p (@progs) { + $progsources .= "\$(${p}_SOURCES) "; + $progexes .= "${p}\$(EXEEXT) "; + } + $lookup = 'SOURCES\s*=[ \t]*(.*)'; + if($MakefileData =~ /\n$lookup/) { + substituteLine($lookup, "SOURCES = $1 $progsources"); + } + $lookup = 'DIST_SOURCES\s*=[ \t]*(.*)'; + if($MakefileData =~ /\n$lookup/) { + substituteLine($lookup, "DIST_SOURCES = $1 $progsources"); + } + # bin_PROGRAMS is complicated, as it exists twice, so we do a little + # magic trick here + $lookup = 'PROGRAMS\s*=[ \t]*(.*)'; + if ($MakefileData =~ /\n$lookup/) { + substituteLine($lookup, "bin_PROGRAMS += $progexes\nPROGRAMS = $1"); + } + } + } +} + #----------------------------------------------------------------------------- sub tag_COMPILE_FIRST() { foreach $program (@programs) { - my $lookup = "$program" . '_COMPILE_FIRST\s*=\s*(.*)'; + my $lookup = "$program" . '_COMPILE_FIRST\s*=[ \t]*(.*)'; if ($MakefileData =~ m/\n$lookup\n/) { - my @compilefirst = split(/[\s\034]+/, $1); - my @progsources = split(/[\s\034]+/, $sources{$program}); + my $compilefirst_str = $1; + my @compilefirst = split(/[\034\s]+/, $compilefirst_str); + my @progsources = split(/[\034\s]+/, $sources{$program}); my %donesources = (); - $handling = ""; foreach $source (@progsources) { my @deps = (); my $sdeps = ""; @@ -784,10 +1026,9 @@ next if defined($donesources{$depend}); push @deps, $depend; } - $handling .= "$sdeps: " . join(' ', @deps) . "\n" if (@deps); + $target_adds{$sdeps} = join(' ', @deps) if (@deps); $donesources{$source} = 1; } - appendLines($handling) if (length($handling)); } } } @@ -800,7 +1041,7 @@ sub tag_METASOURCES () { local @newObs = (); # here we add to create object files - local @deped = (); # here we add to create moc files + local @depend = (); # here we add to create moc files local $mocExt = ".moc"; local %mocFiles = (); @@ -809,7 +1050,6 @@ my $lookup; my $found = ""; - if ($metasourceTags > 1) { $lookup = $program . '_METASOURCES\s*=\s*(.*)'; return 1 if ($MakefileData !~ /\n($lookup)\n/); @@ -818,7 +1058,7 @@ $lookup = $program . '_METASOURCES\s*=\s*(.*)'; if ($MakefileData !~ /\n($lookup)\n/) { $lookup = 'METASOURCES\s*=\s*(.*)'; - return 1 if ($MakefileData !~ /\n($lookup)\n/o); + return 1 if ($MakefileData !~ /\n($lookup)\n/); $found = $1; $metasourceTags = 0; # we can use the general target only once } else { @@ -858,15 +1098,15 @@ if (@newObs) { my $ext = ($program =~ /_la$/) ? ".moc.lo " : ".moc.o "; $realObjs{$program} .= "\034" . join ($ext, @newObs) . $ext; - $depedmocs{$program} = join (".moc.$cxxsuffix " , @newObs) . ".moc.$cxxsuffix"; + $dependmocs{$program} = join (".moc.$cxxsuffix " , @newObs) . ".moc.$cxxsuffix"; foreach $file (@newObs) { $dep_files .= " \$(DEPDIR)/$file.moc.P" if($dep_files !~/$file.moc.P/); } } - if (@deped) { - $depedmocs{$program} .= " "; - $depedmocs{$program} .= join('.moc ', @deped) . ".moc"; - $depedmocs{$program} .= " "; + if (@depend) { + $dependmocs{$program} .= " "; + $dependmocs{$program} .= join('.moc ', @depend) . ".moc"; + $dependmocs{$program} .= " "; } addMocRules (); @globalmocs{keys %mocFiles}=values %mocFiles; @@ -878,13 +1118,20 @@ # Errors are logged in the global $errorflags sub tag_AUTOMAKE () { - my $lookup = '.*cd \$\(top_srcdir\)\s+&&[\s\034]+\$\(AUTOMAKE\)(.*)'; + my $lookup = '.*cd \$\(top_srcdir\)\s+&&[\034\s]+\$\(AUTOMAKE\)(.*)'; return 1 if ($MakefileData !~ /\n($lookup)\n/); print STDOUT "AUTOMAKE processing <$1>\n" if ($verbose); my $newLine = $1."\n\tcd \$(top_srcdir) && perl $thisProg $printname"; substituteLine ($lookup, $newLine); $automkCall = $1; + + $lookup = '.*cd \$\(srcdir\)\s+&&[\034\s]+\$\(AUTOCONF\)(.*)'; + if ($MakefileData =~ /\n($lookup)\n/) { + $newLine = "\tcd \$(srcdir) && rm -f configure && \$(MAKE) -f admin/Makefile.common configure"; + substituteLine ($lookup, $newLine); + } + return 0; } @@ -945,8 +1192,7 @@ } closedir (THISDIR); - my $lines = "SUBDIRS =$subdirs\n"; - substituteLine('SUBDIRS\s*=.*', $lines); + substituteLine('SUBDIRS\s*=.*', "SUBDIRS =$subdirs"); return 0; } @@ -957,23 +1203,19 @@ my @cppFiles = (); foreach $source (@psources) { - my $skel = ($source =~ m/\.skel$/); my $stub = ($source =~ m/\.stub$/); - my $signals = ($source =~ m/\.signals$/); + my $signals = ($source =~ m/\.signals$/); # obsolete, remove in KDE-4 if ($stub || $skel || $signals) { - + my $qs = quotemeta($source); $sources{$program} =~ s/$qs//; $sources_changed{$program} = 1; - - print STDOUT "adding IDL file $source\n" if ($verbose); - + $source =~ s/\.(stub|skel|signals)$//; - my $sourcename; - + if ($skel) { $sourcename = "$source\_skel"; } elsif ($stub) { @@ -994,8 +1236,8 @@ if ($allidls !~ /$source\_kidl/) { - $dep_lines .= "$source.kidl: $sourcedir$source.h \$(DCOPIDL_DEPENDENCIES)\n"; - $dep_lines .= "\t\$(DCOPIDL) $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; /bin/false )\n"; + $dep_lines .= "$source.kidl: $sourcedir$source.h \$(DCOP_DEPENDENCIES)\n"; + $dep_lines .= "\t\$(DCOPIDL) $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; false )\n"; $allidls .= $source . "_kidl "; } @@ -1009,7 +1251,7 @@ $dep_lines .= "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-signals --no-stub $source.kidl\n"; } elsif ($stub) { $dep_lines_tmp = "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-signals --no-skel $source.kidl\n"; - } else { # signals + } else { # signals - obsolete, remove in KDE 4 $dep_lines_tmp = "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-stub --no-skel $source.kidl\n"; } @@ -1066,7 +1308,6 @@ sub tag_UIFILES () { my @psources = split(/[\034\s]+/, $sources{$program}); - my $dep_lines = ""; my @depFiles = (); foreach $source (@psources) { @@ -1088,22 +1329,28 @@ if (!$uiFiles{$source}) { - $dep_lines .= "$source.$cxxsuffix: $sourcedir$source.ui $source.h $source.moc\n"; + my $dep_lines = "$source.$cxxsuffix: $sourcedir$source.ui $source.h $source.moc\n"; $dep_lines .= "\trm -f $source.$cxxsuffix\n"; if (!$kdeopts{"qtonly"}) { $dep_lines .= "\techo '#include <klocale.h>' > $source.$cxxsuffix\n"; - $dep_lines .= "\t\$(UIC) -tr \${UIC_TR} -i $source.h $sourcedir$source.ui | sed -e \"s,\${UIC_TR}( \\\"\\\" ),QString::null,g\" | sed -e \"s,\${UIC_TR}( \\\"\\\"\\, \\\"\\\" ),QString::null,g\" >> $source.$cxxsuffix || rm -f $source.$cxxsuffix\n"; + my ($mangled_source) = $source; + $mangled_source =~ s/[^A-Za-z0-9]/_/g; # get rid of garbage + $dep_lines .= "\t\$(UIC) -tr \${UIC_TR} -i $source.h $sourcedir$source.ui > $source.$cxxsuffix.temp ; ret=\$\$?; \\\n"; + $dep_lines .= "\tsed -e \"s,\${UIC_TR}( \\\"\\\" ),QString::null,g\" $source.$cxxsuffix.temp | sed -e \"s,\${UIC_TR}( \\\"\\\"\\, \\\"\\\" ),QString::null,g\" | sed -e \"s,image\\([0-9][0-9]*\\)_data,img\\1_" . $mangled_source . ",g\" >> $source.$cxxsuffix ;\\\n"; + $dep_lines .= "\trm -f $source.$cxxsuffix.temp ;\\\n"; } else { - $dep_lines .= "\t\$(UIC) -i $source.h $sourcedir$source.ui > $source.$cxxsuffix || rm -f $source.$cxxsuffix\n"; + $dep_lines .= "\t\$(UIC) -i $source.h $sourcedir$source.ui > $source.$cxxsuffix; ret=\$\$?; \\\n"; } - $dep_lines .= "\techo '#include \"$source.moc\"' >> $source.$cxxsuffix\n\n"; + $dep_lines .= "\tif test \"\$\$ret\" = 0; then echo '#include \"$source.moc\"' >> $source.$cxxsuffix; else rm -f $source.$cxxsuffix ; exit \$\$ret ; fi\n\n"; $dep_lines .= "$source.h: $sourcedir$source.ui\n"; $dep_lines .= "\t\$(UIC) -o $source.h $sourcedir$source.ui\n\n"; $dep_lines .= "$source.moc: $source.h\n"; $dep_lines .= "\t\$(MOC) $source.h -o $source.moc\n"; + $rule_adds{"$source.$cxxsuffix"} = $dep_lines; + $uiFiles{$source} = 1; - $depedmocs{$program} .= " $source.moc"; + $dependmocs{$program} .= " $source.moc"; $globalmocs{$source} = "\035$source.h\035$source.cpp"; } @@ -1122,18 +1369,15 @@ $dep_files .= " \$(DEPDIR)/$source.P" if($dep_files !~/$source.P/ ); } } - if ($dep_lines) { - appendLines($dep_lines); - } } sub tag_ICON() { - my $lookup = '([^\s]*)_ICON\s*=\s*([^\n]*)'; + my $lookup = '([^\s]*)_ICON\s*=[ \t]*(.*)'; my $install = ""; my $uninstall = ""; - while ($MakefileData =~ /\n$lookup/og) { + while ($MakefileData =~ /\n$lookup/g) { my $destdir; if ($1 eq "KDE") { $destdir = "kde_icondir"; @@ -1143,7 +1387,8 @@ my $iconauto = ($2 =~ /AUTO\s*$/); my @appnames = (); if ( ! $iconauto ) { - my @_appnames = split(" ", $2); + my $appicon_str = $2; + my @_appnames = split(" ", $appicon_str); print STDOUT "KDE_ICON processing <@_appnames>\n" if ($verbose); foreach $appname (@_appnames) { push(@appnames, quotemeta($appname)); @@ -1160,11 +1405,11 @@ if ( $iconauto ) { push(@files, $entry) - if ($entry =~ /\.xpm/ || $entry =~ /\.png/ || $entry =~ /\.mng/); + if ($entry =~ /\.xpm/ || $entry =~ /\.png/ || $entry =~ /\.mng/ || $entry =~ /\.svg/); } else { foreach $appname (@appnames) { push(@files, $entry) - if ($entry =~ /-$appname\.xpm/ || $entry =~ /-$appname\.png/ || $entry =~ /-$appname\.mng/); + if ($entry =~ /-$appname\.xpm/ || $entry =~ /-$appname\.png/ || $entry =~ /-$appname\.mng/ || $entry =~ /-$appname\.svg/); } } } @@ -1175,7 +1420,7 @@ foreach $file (@files) { my $newfile = $file; my $prefix = $file; - $prefix =~ s/\.(png|xpm|mng)$//; + $prefix =~ s/\.(png|xpm|mng|svg|svgz)$//; my $appname = $prefix; $appname =~ s/^[^-]+-// if ($appname =~ /-/) ; $appname =~ s/^[^-]+-// if ($appname =~ /-/) ; @@ -1200,12 +1445,12 @@ 'filesys' => 'filesystems', 'mime' => 'mimetypes' ); - + if (! defined $type_hash{$type} ) { print STDERR "unknown icon type $type in $printname ($file)\n"; next; } - + my %dir_hash = ( 'los' => 'locolor/16x16', @@ -1220,10 +1465,18 @@ 'hi32' => 'hicolor/32x32', 'hi48' => 'hicolor/48x48', 'hi64' => 'hicolor/64x64', - 'hisc' => 'hicolor/scalable' + 'hi128' => 'hicolor/128x128', + 'hisc' => 'hicolor/scalable', + 'cr16' => 'crystalsvg/16x16', + 'cr22' => 'crystalsvg/22x22', + 'cr32' => 'crystalsvg/32x32', + 'cr48' => 'crystalsvg/48x48', + 'cr64' => 'crystalsvg/64x64', + 'cr128' => 'crystalsvg/128x128', + 'crsc' => 'crystalsvg/scalable' ); - $newfile =~ s@.*-($appname\.(png|xpm|mng?))@$1@; + $newfile =~ s@.*-($appname\.(png|xpm|mng|svgz|svg?))@$1@; if (! defined $dir_hash{$prefix}) { print STDERR "unknown icon prefix $prefix in $printname\n"; @@ -1276,7 +1529,7 @@ } appendLines ($tmp); my $lookup = 'POFILES\s*=([^\n]*)'; - if ($MakefileData !~ /\n$lookup/o) { + if ($MakefileData !~ /\n$lookup/) { appendLines("$pofileLine\nGMOFILES =$allgmofiles"); } else { substituteLine ($lookup, "$pofileLine\nGMOFILES =$allgmofiles"); @@ -1289,8 +1542,8 @@ $target_adds{"maintainer-clean"} .= "clean-nls "; - $lookup = 'DISTFILES\s*=\s*(.*)'; - if ($MakefileData =~ /\n$lookup\n/o) { + $lookup = 'DISTFILES\s*=[ \t]*(.*)'; + if ($MakefileData =~ /\n$lookup/) { $tmp = "DISTFILES = \$(GMOFILES) \$(POFILES) $1"; substituteLine ($lookup, $tmp); } @@ -1312,11 +1565,15 @@ $tmp .= "; do \\\n"; if ($lang) { $tmp .= "\t echo \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n"; - $tmp .= "\t test ! -f \$\$base.gmo || \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n" + $tmp .= "\t if test -f \$\$base.gmo; then \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n"; + $tmp .= "\t elif test -f \$(srcdir)/\$\$base.gmo; then \$(INSTALL_DATA) \$(srcdir)/\$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n"; + $tmp .= "\t fi ;\\\n"; } else { $tmp .= "\t echo \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n"; $tmp .= "\t \$(mkinstalldirs) \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES ; \\\n"; - $tmp .= "\t test ! -f \$\$base.gmo || \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n"; + $tmp .= "\t if test -f \$\$base.gmo; then \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n"; + $tmp .= "\t elif test -f \$(srcdir)/\$\$base.gmo; then \$(INSTALL_DATA) \$(srcdir)/\$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n"; + $tmp .= "\t fi ;\\\n"; } $tmp .= "\tdone\n\n"; appendLines ($tmp); @@ -1366,7 +1623,7 @@ sub tag_POFILES () { my $lookup = 'POFILES\s*=([^\n]*)'; - return 1 if ($MakefileData !~ /\n$lookup/o); + return 1 if ($MakefileData !~ /\n$lookup/); print STDOUT "POFILES processing <$1>\n" if ($verbose); my $tmp = $1; @@ -1405,14 +1662,15 @@ sub helper_LOCALINSTALL($) { - my $lookup = "\n" . $_[0] . ":"; - if ($MakefileData =~ /($lookup)/) { + my $lookup = "\035" . $_[0] . " *:[^\035]*\035\t"; + my $copy = $MakefileData; + $copy =~ s/\n/\035/g; + if ($copy =~ /($lookup.*)$/) { - my $install = $MakefileData; - $install =~ s/\n/\035/g; - $install =~ s/.*\035$_[0]:[^\035]*\035//; + $install = $1; + $install =~ s/\035$_[0] *:[^\035]*\035//; my $emptyline = 0; - while (! $emptyline) { + while (! $emptyline ) { if ($install =~ /([^\035]*)\035(.*)/) { local $line = $1; $install = $2; @@ -1455,11 +1713,35 @@ } #--------------------------------------------------------------------------- +# libtool is very hard to persuade it could use -Wl,--no-undefined for making +# -no-undefined actually work +# append $(KDE_NO_UNFINED) after every -no-undefined in LDFLAGS +# this may go away if libtool ever does this on its own +sub tag_NO_UNDEFINED () { + return if ($program !~ /_la$/); + + my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n"; + $MakefileData =~ m/$lookup/; + return if (!defined($1)); + return if ($1 !~ /CXXLINK/); + + if ($MakefileData !~ /\n$program\_LDFLAGS\s*=.*-no-undefined/ ) { + return; + } + + $lookup = $program . '\_LDFLAGS(\s*)=(.*)-no-undefined(.*)'; + if ($MakefileData =~ /\n$lookup\n/) { + my $replace = $program . "\_LDFLAGS$1=$2-no-undefined \$(KDE_NO_UNDEFINED)$3"; + substituteLine($lookup, $replace); + } +} + sub tag_CLOSURE () { return if ($program !~ /_la$/); - + my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n"; $MakefileData =~ m/$lookup/; + return if (!defined($1)); return if ($1 !~ /CXXLINK/); if ($MakefileData !~ /\n$program\_LDFLAGS\s*=.*-no-undefined/ && @@ -1467,6 +1749,7 @@ 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() {return 0;}\" > $program\_closure.$cxxsuffix\n"; @@ -1485,14 +1768,57 @@ $closure_output .= " $closure"; } +sub tag_NMCHECK () { + return if ($program !~ /_la$/); + my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n"; + $MakefileData =~ m/$lookup/; + my $linkcmd = $1; + return if (!defined($1)); + return if ($linkcmd !~ /CXXLINK/ && $linkcmd !~ /LINK/); + + $lookup = $program . '_NMCHECK\s*=([^\n]*)'; + if( $MakefileData !~ m/\n$lookup\n/ ) { + return; + } + my $allowed = $1; + $allowed =~ s/^ *//; + $lookup = $program . '_NMCHECKWEAK\s*=([^\n]*)'; + my $weak = ""; + my $is_weak = 0; + if( $MakefileData =~ m/\n$lookup\n/ ) { + $weak = $1; + $is_weak = 1; + } + $weak =~ s/^ *//; + + if( $is_weak ) + { + $weak = '--allowweak=\'' . $weak . '\' '; + } + my $nmline = "\@KDE_USE_NMCHECK_TRUE@\t\@\$(MAKE) \$(AM_MAKEFLAGS) nmcheck_$realname{$program} || ( rm -f $realname{$program}; exit 1 )"; + $lookup = '(\t\$\(CXXLINK\)[^\n]*' . $program . '_OBJECTS[^\n]*)'; + if( $MakefileData =~ /\n$lookup\n/ ) { + my $oldstuff = $1; + substituteLine( $lookup, $oldstuff . "\n" . $nmline ); + } + $lookup = '(\t\$\(LINK\)[^\n]*' . $program . '_OBJECTS[^\n]*)'; + if( $MakefileData =~ /\n$lookup\n/ ) { + my $oldstuff = $1; + substituteLine( $lookup, $oldstuff . "\n" . $nmline ); + } + $nmline = "\@\$(top_srcdir)/admin/nmcheck $realname{$program} \'$allowed\' $weak"; + appendLines( "\nnmcheck_$realname{$program}: $realname{$program} \n\t$nmline\n" ); + $target_adds{ "nmcheck" } .= "nmcheck_$realname{$program} "; +} + sub tag_DIST () { my %foundfiles = (); opendir (THISDIR, "."); foreach $entry (readdir(THISDIR)) { - next if ($entry eq "CVS" || $entry =~ /^\./ || $entry =~ /^Makefile$$/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/); + next if ($entry eq "CVS" || $entry =~ /^\./ || $entry eq "Makefile" || $entry =~ /~$/ || $entry =~ /^\#.*\#$/); next if (! -f $entry); - next if ($entry =~ /\.moc/ || $entry =~ /\.lo$/ || $entry =~ /\.la$/ || $entry =~ /\.o/); - next if ($entry =~ /.+meta_unload.$cppExt$/ || $entry =~ /\.all_$cppExt\.$cppExt$/); + next if ($entry =~ /\.moc/ || $entry =~ /\.moc.$cppExt$/ || $entry =~ /\.lo$/ || $entry =~ /\.la$/ || $entry =~ /\.o/); + next if ($entry =~ /\.all_$cppExt\.$cppExt$/); $foundfiles{$entry} = 1; } closedir (THISDIR); @@ -1500,15 +1826,17 @@ # doing this for MAINTAINERCLEANFILES would be wrong my @marks = ("EXTRA_DIST", "DIST_COMMON", '\S*_SOURCES', '\S*_HEADERS', 'CLEANFILES', 'DISTCLEANFILES', '\S*_OBJECTS'); foreach $mark (@marks) { - while ($MakefileData =~ /\n($mark)\s*=\s*([^\n]*)/g) { - foreach $file (split('[\034\s]', $2)) { + while ($MakefileData =~ /\n($mark)\s*=[ \t]*([^\n]*)/g) { + my $cleanfiles_str = $2; + foreach $file (split('[\034\s]+', $cleanfiles_str)) { $file =~ s/\.\///; $foundfiles{$file} = 0 if (defined $foundfiles{$file}); } } } my @files = ("Makefile", "config.cache", "config.log", "stamp-h", - "stamp-h1", "stamp-h1", "config.h", "Makefile", "config.status", "config.h", "libtool"); + "stamp-h1", "stamp-h1", "config.h", "Makefile", + "config.status", "config.h", "libtool", "core" ); foreach $file (@files) { $foundfiles{$file} = 0 if (defined $foundfiles{$file}); } @@ -1521,10 +1849,11 @@ } if ($KDE_DIST) { print "KDE_DIST $printname $KDE_DIST\n" if ($verbose); - - my $lookup = "DISTFILES *=(.*)"; - if ($MakefileData =~ /\n$lookup\n/o) { - substituteLine($lookup, "KDE_DIST=$KDE_DIST\n\nDISTFILES=$1 \$(KDE_DIST)\n"); + + my $lookup = 'DISTFILES\s*=[ \t]*(.*)'; + if ($MakefileData =~ /\n$lookup/) { + substituteLine($lookup, "DISTFILES = $1 \$(KDE_DIST)"); + appendLines("KDE_DIST=$KDE_DIST\n"); } } } @@ -1534,20 +1863,10 @@ # Errors are logged in the global $errorflags sub 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"); -# } $target_adds{"all"} .= "docs-am "; - my $lookup = 'KDE_DOCS\s*=\s*([^\n]*)'; - goto nodocs if ($MakefileData !~ /\n$lookup/o); + my $lookup = 'KDE_DOCS\s*=[ \t]*([^\n]*)'; + goto nodocs if ($MakefileData !~ /\n$lookup/); print STDOUT "KDE_DOCS processing <$1>\n" if ($verbose); my $tmp = $1; @@ -1569,7 +1888,7 @@ { opendir (THISDIR, "."); foreach $entry (readdir(THISDIR)) { - next if ($entry eq "CVS" || $entry =~ /^\./ || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/); + next if ($entry eq "CVS" || $entry =~ /^\./ || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/ || $entry eq "core" || $entry eq "index.cache.bz2"); next if (! -f $entry); $files .= "$entry "; } @@ -1585,7 +1904,7 @@ goto nodocs if (!$files); # Nothing to do if ($files =~ /(^| )index\.docbook($| )/) { - + my $lines = ""; my $lookup = 'MEINPROC\s*='; if ($MakefileData !~ /\n($lookup)/) { @@ -1598,17 +1917,20 @@ $lookup = '\nindex.cache.bz2:'; if ($MakefileData !~ /\n($lookup)/) { $lines .= "index.cache.bz2: \$(srcdir)/index.docbook \$(KDE_XSL_STYLESHEET) $files\n"; - $lines .= "\t-\@if test -n \"\$(MEINPROC)\"; then echo \$(MEINPROC) --check --cache index.cache.bz2 \$(srcdir)/index.docbook; \$(MEINPROC) --check --cache index.cache.bz2 \$(srcdir)/index.docbook; fi\n"; + $lines .= "\t\@if test -n \"\$(MEINPROC)\"; then echo \$(MEINPROC) --check --cache index.cache.bz2 \$(srcdir)/index.docbook; \$(MEINPROC) --check --cache index.cache.bz2 \$(srcdir)/index.docbook; fi\n"; $lines .= "\n"; } - - $lines .= "docs-am: index.cache.bz2\n"; + + $lines .= "docs-am: index.cache.bz2\n"; $lines .= "\n"; $lines .= "install-docs: docs-am install-nls\n"; $lines .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n"; $lines .= "\t\@if test -f index.cache.bz2; then \\\n"; $lines .= "\techo \$(INSTALL_DATA) index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n"; $lines .= "\t\$(INSTALL_DATA) index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n"; + $lines .= "\telif test -f \$(srcdir)/index.cache.bz2; then \\\n"; + $lines .= "\techo \$(INSTALL_DATA) \$(srcdir)/index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n"; + $lines .= "\t\$(INSTALL_DATA) \$(srcdir)/index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n"; $lines .= "\tfi\n"; $lines .= "\t-rm -f \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n"; $lines .= "\t\$(LN_S) \$(kde_libs_htmldir)/$kdelang/common \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n"; @@ -1628,7 +1950,7 @@ appendLines("docs-am: $files\n"); } - $target_adds{"install-data-am"} .= "install-nls"; + $target_adds{"install-data-am"} .= "install-nls "; $target_adds{"uninstall"} .= "uninstall-nls "; $tmp = "install-nls:\n"; @@ -1639,13 +1961,13 @@ $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 .= "\tif test ! -f \$(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 *) test ! -f \$\$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"; } @@ -1696,8 +2018,9 @@ read HFIN, $hfData, $hfsize; close HFIN; # push (@list, $hf) if(index($hfData, "Q_OBJECT") >= 0); ### fast but doesn't handle //Q_OBJECT - if ( $hfData =~ /{([^}]*)Q_OBJECT/s ) { ## handle " { friend class blah; Q_OBJECT " - push (@list, $hf) unless $1 =~ m://[^\n]*Q_OBJECT[^\n]*$:s; ## handle "// Q_OBJECT" + # handle " { friend class blah; Q_OBJECT ", but don't match antlarr_Q_OBJECT (\b). + if ( $hfData =~ /{([^}]*)\bQ_OBJECT/s ) { + push (@list, $hf) unless $1 =~ m://[^\n]*Q_OBJECT[^\n]*$:s; ## reject "// Q_OBJECT" } } # The assoc array of root of headerfile and header filename @@ -1786,7 +2109,7 @@ @cppFiles = keys %{$moc2cpp->{"$mocFile.moc"}}; if (@cppFiles == 1) { $mocFiles{$mocFile} .= "\035" . $cppFiles[0]; - push(@deped, $mocFile); + push(@depend, $mocFile); } elsif (@cppFiles == 0) { push (@newObs, $mocFile); # Produce new object file next if ($haveAutomocTag); # This is expected... @@ -1824,18 +2147,58 @@ $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"; + $cppFile =~ s,\.[^.]*$,,; + $target_adds{"$cppFile.o"} .= "$mocFile.moc "; + $target_adds{"$cppFile.lo"} .= "$mocFile.moc "; + appendLines ("$mocFile.moc: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile.moc\n"); + $cleanMoc .= " $mocFile.moc"; + appendLines ("mocs: $mocFile.moc\n"); } else { appendLines ("$mocFile$mocExt: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile$mocExt\n"); $cleanMoc .= " $mocFile$mocExt"; + appendLines ("mocs: $mocFile$mocExt\n"); } } } +sub make_bcheck_target() +{ + my $lookup = 'RECURSIVE_TARGETS\s*=[ \t]*(.*)'; + my $bcheckdep = "bcheck-am"; + $bcheckdep = "bcheck-recursive" if ($MakefileData =~ /\n$lookup/); + + my $headers= ""; + $headers = $1 if($MakefileData =~ /\nHEADERS\s*=[ \t]*(.+)/); + $headers =~ s/\$\((?:noinst|EXTRA)_HEADERS\)//g; + + $target_adds{"clean-am"} .= "clean-bcheck "; + + my $t = "clean-bcheck: \n" . + "\trm -f *.bchecktest.cc *.bchecktest.cc.class a.out\n\n" . + "bcheck: $bcheckdep\n\n" . + "bcheck-am:\n" . + "\t\@for i in $headers; do \\\n" . + "\t if test \$(srcdir)/\$\$i -nt \$\$i.bchecktest.cc; then \\\n" . + "\t echo \"int main() {return 0;}\" > \$\$i.bchecktest.cc ; \\\n" . + "\t echo \"#include \\\"\$\$i\\\"\" >> \$\$i.bchecktest.cc ; \\\n" . + "\t echo \"\$\$i\"; \\\n" . + "\t if ! "; + $t .= $cxxsuffix eq "KKK" ? + "\$(CXX) \$(DEFS) -I. -I\$(srcdir) -I\$(top_builddir) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(KDE_CXXFLAGS) " : + "\$(CXXCOMPILE) "; + $t .= " --dump-class-hierarchy \$\$i.bchecktest.cc; then \\\n" . + "\t rm -f \$\$i.bchecktest.cc; exit 1; \\\n" . + "\t fi ; \\\n" . + "\t echo \"\" >> \$\$i.bchecktest.cc.class; \\\n" . + "\t perl \$(top_srcdir)/admin/bcheck.pl \$\$i.bchecktest.cc.class || { rm -f \$\$i.bchecktest.cc; exit 1; }; \\\n" . + "\t rm -f a.out; \\\n" . + "\t fi ; \\\n" . + "\tdone\n"; + appendLines("$t\n"); +} + sub make_meta_classes () { return if ($kdeopts{"qtonly"}); @@ -1845,8 +2208,8 @@ my $moc_class_headers = ""; foreach $program (@programs) { my $mocs = ""; - my @progsources = split(/[\s\034]+/, $sources{$program}); - my @depmocs = split(' ', $depedmocs{$program}); + my @progsources = split(/[\034\s]+/, $sources{$program}); + my @depmocs = split(' ', $dependmocs{$program}); my %shash = (), %mhash = (); @shash{@progsources} = 1; # we are only interested in the existence @mhash{@depmocs} = 1; @@ -1857,9 +2220,7 @@ 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)#; + my ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3); if (defined ($cppFile)) { $mocs .= " $mocFile.moc" if exists $shash{$cppFile}; @@ -1869,7 +2230,7 @@ # 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 + # in %dependmocs. 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 @@ -1880,30 +2241,6 @@ } 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\@if test \${kde_qtver} = 2; then \\\n"; - $appl .= "\t\techo 'static const char * _metalist_$program\[\] = {' > $srcfile ;\\\n"; - $appl .= "\t\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\techo '0};' >> $srcfile ;\\\n"; - $appl .= "\t\techo '#include <kunload.h>' >> $srcfile ;\\\n"; - $appl .= "\t\techo '_UNLOAD($program)' >> $srcfile ;\\\n"; - $appl .= "\telse echo > $srcfile; fi\n"; - $appl .= "\n"; - - $realObjs{$program} .= " \034" . $objfile . " "; - $sources{$program} .= " $srcfile"; - $sources_changed{$program} = 1; - $dep_files .= " \$(DEPDIR)/$sourcename.P" if($dep_files !~/$sourcename.P/); - appendLines ($appl); } print STDOUT "\n" if $verbose; } @@ -1922,8 +2259,15 @@ open (FILEOUT, "> $makefile") || die "Could not create $makefile: $!\n"; - print FILEOUT "\# $progId - " . '$Revision$ ' . "\n"; - $MakefileData =~ s/\034/\\\n\t/g; # Restore continuation lines + $MakefileData =~ s/\034/\\\n/g; # Restore continuation lines + # Append our $progId line, _below_ the "generated by automake" line + # because automake-1.6 relies on the first line to be his own. + my $progIdLine = "\# $progId - " . '$Revision$ '."\n"; + if ( !( $MakefileData =~ s/^(.*generated .*by automake.*\n)/$1$progIdLine/ ) ) { + warn "automake line not found in $makefile\n"; + # Fallback: first line + print FILEOUT $progIdLine; + }; print FILEOUT $MakefileData; close FILEOUT; } @@ -1952,11 +2296,11 @@ if ($MakefileData =~ /\n($lookup)/) { $old = $1; $old =~ s/\034/\\\n#>\- /g; # Fix continuation lines - $new =~ s/\034/\\\n\t/g; - my $newCount = ($new =~ tr/\n//) + 1; + my $newCount = ($new =~ tr/\034//) + ($new =~ tr/\n//) + 1; + $new =~ s/\\\n/\034/g; $MakefileData =~ s/\n$lookup/\n#>- $old\n#>\+ $newCount\n$new/; } else { - print STDERR "Warning: substitution of \"$lookup\" in $printname failed\n"; + warn "Warning: substitution of \"$lookup\" in $printname failed\n"; } } @@ -1966,8 +2310,9 @@ sub appendLines ($) { my ($new) = @_; - $new =~ s/\034/\\\n\t/g; # Fix continuation lines - my $newCount = ($new =~ tr/\n//) + 1; + my $copynew = $new; + my $newCount = ($new =~ tr/\034//) + ($new =~ tr/\n//) + 1; + $new =~ s/\\\n/\034/g; # Fix continuation lines $MakefileData .= "\n#>\+ $newCount\n$new"; }