annotate kdiff3/admin/am_edit @ 66:efe33e938730

0.9.86
author joachim99
date Thu, 16 Sep 2004 02:40:08 +0000
parents 415083d043f3
children 8febbfb1148c
rev   line source
joachim99@2 1 #!/usr/bin/perl -w
joachim99@2 2
joachim99@2 3 # Expands the specialised KDE tags in Makefile.in to (hopefully) valid
joachim99@2 4 # make syntax.
joachim99@2 5 # When called without file parameters, we work recursively on all Makefile.in
joachim99@2 6 # in and below the current subdirectory. When called with file parameters,
joachim99@2 7 # only those Makefile.in are changed.
joachim99@2 8 # The currently supported tags are
joachim99@2 9 #
joachim99@2 10 # {program}_METASOURCES
joachim99@2 11 # where you have a choice of two styles
joachim99@2 12 # {program}_METASOURCES = name1.moc name2.moc ... [\]
joachim99@2 13 # {program}_METASOURCES = AUTO
joachim99@2 14 # The second style requires other tags as well.
joachim99@2 15 #
joachim99@2 16 # To install icons :
joachim99@2 17 # KDE_ICON = iconname iconname2 ...
joachim99@2 18 # KDE_ICON = AUTO
joachim99@2 19 #
joachim99@2 20 # For documentation :
joachim99@14 21 # http://developer.kde.org/documentation/other/developer-faq.html
joachim99@2 22 #
joachim99@2 23 # and more new tags TBD!
joachim99@2 24 #
joachim99@2 25 # The concept (and base code) for this program came from automoc,
joachim99@2 26 # supplied by the following
joachim99@2 27 #
joachim99@2 28 # Matthias Ettrich <ettrich@kde.org> (The originator)
joachim99@2 29 # Kalle Dalheimer <kalle@kde.org> (The original implementator)
joachim99@2 30 # Harri Porten <porten@tu-harburg.de>
joachim99@2 31 # Alex Zepeda <jazepeda@pacbell.net>
joachim99@2 32 # David Faure <faure@kde.org>
joachim99@2 33 # Stephan Kulow <coolo@kde.org>
joachim99@14 34 # Dirk Mueller <mueller@kde.org>
joachim99@2 35
joachim99@2 36 use Cwd;
joachim99@2 37 use File::Find;
joachim99@2 38 use File::Basename;
joachim99@2 39
joachim99@2 40 # Prototype the functions
joachim99@2 41 sub initialise ();
joachim99@2 42 sub processMakefile ($);
joachim99@2 43 sub updateMakefile ();
joachim99@2 44 sub restoreMakefile ();
joachim99@2 45
joachim99@2 46 sub removeLine ($$);
joachim99@2 47 sub appendLines ($);
joachim99@2 48 sub substituteLine ($$);
joachim99@2 49
joachim99@2 50 sub findMocCandidates ();
joachim99@2 51 sub pruneMocCandidates ($);
joachim99@2 52 sub checkMocCandidates ();
joachim99@2 53 sub addMocRules ();
joachim99@66 54 sub findKcfgFile($);
joachim99@2 55
joachim99@2 56 sub tag_AUTOMAKE ();
joachim99@2 57 sub tag_META_INCLUDES ();
joachim99@2 58 sub tag_METASOURCES ();
joachim99@2 59 sub tag_POFILES ();
joachim99@2 60 sub tag_DOCFILES ();
joachim99@2 61 sub tag_LOCALINSTALL();
joachim99@2 62 sub tag_IDLFILES();
joachim99@2 63 sub tag_UIFILES();
joachim99@66 64 sub tag_KCFGFILES();
joachim99@2 65 sub tag_SUBDIRS();
joachim99@2 66 sub tag_ICON();
joachim99@2 67 sub tag_CLOSURE();
joachim99@14 68 sub tag_NO_UNDEFINED();
joachim99@14 69 sub tag_NMCHECK();
joachim99@2 70 sub tag_DIST();
joachim99@14 71 sub tag_KDEINIT();
joachim99@2 72
joachim99@2 73 # Some global globals...
joachim99@2 74 $verbose = 0; # a debug flag
joachim99@2 75 $thisProg = "$0"; # This programs name
joachim99@2 76 $topdir = cwd(); # The current directory
joachim99@2 77 @makefiles = (); # Contains all the files we'll process
joachim99@2 78 @foreignfiles = ();
joachim99@2 79 $start = (times)[0]; # some stats for testing - comment out for release
joachim99@2 80 $version = "v0.2";
joachim99@2 81 $errorflag = 0;
joachim99@2 82 $cppExt = "(cpp|cc|cxx|C|c\\+\\+)";
joachim99@2 83 $hExt = "(h|H|hh|hxx|hpp|h\\+\\+)";
joachim99@2 84 $progId = "KDE tags expanded automatically by " . basename($thisProg);
joachim99@2 85 $automkCall = "\n";
joachim99@2 86 $printname = ""; # used to display the directory the Makefile is in
joachim99@2 87 $use_final = 1; # create code for --enable-final
joachim99@2 88 $cleantarget = "clean";
joachim99@2 89 $dryrun = 0;
joachim99@2 90 $pathoption = 0;
joachim99@2 91 $foreign_libtool = 0;
joachim99@2 92
joachim99@2 93 while (defined ($ARGV[0]))
joachim99@2 94 {
joachim99@2 95 $_ = shift;
joachim99@2 96 if (/^--version$/)
joachim99@2 97 {
joachim99@2 98 print STDOUT "\n";
joachim99@2 99 print STDOUT basename($thisProg), " $version\n",
joachim99@2 100 "This is really free software, unencumbered by the GPL.\n",
joachim99@2 101 "You can do anything you like with it except sueing me.\n",
joachim99@2 102 "Copyright 1998 Kalle Dalheimer <kalle\@kde.org>\n",
joachim99@2 103 "Concept, design and unnecessary questions about perl\n",
joachim99@2 104 " by Matthias Ettrich <ettrich\@kde.org>\n\n",
joachim99@2 105 "Making it useful by Stephan Kulow <coolo\@kde.org> and\n",
joachim99@2 106 "Harri Porten <porten\@kde.org>\n",
joachim99@2 107 "Updated (Feb-1999), John Birch <jb.nz\@writeme.com>\n",
joachim99@14 108 "Fixes and Improvements by Dirk Mueller <mueller\@kde.org>\n",
joachim99@2 109 "Current Maintainer Stephan Kulow\n\n";
joachim99@2 110 exit 0;
joachim99@2 111 }
joachim99@2 112 elsif (/^--verbose$|^-v$/)
joachim99@2 113 {
joachim99@2 114 $verbose = 1; # Oh is there a problem...?
joachim99@2 115 }
joachim99@66 116 elsif (/^(?:-p|--path=)(.+)$/)
joachim99@2 117 {
joachim99@66 118 my $p = $1;
joachim99@66 119 $thisProg = $p . "/". basename($thisProg);
joachim99@2 120 warn ("$thisProg doesn't exist\n") if (!(-f $thisProg));
joachim99@66 121 $thisProg .= " -p".$p;
joachim99@2 122 $pathoption=1;
joachim99@2 123 }
joachim99@2 124 elsif (/^--help$|^-h$/)
joachim99@2 125 {
joachim99@2 126 print STDOUT "Usage $thisProg [OPTION] ... [dir/Makefile.in]...\n",
joachim99@2 127 "\n",
joachim99@14 128 "Patches dir/Makefile.in generated by automake\n",
joachim99@14 129 "(where dir can be an absolute or relative directory name)\n",
joachim99@2 130 "\n",
joachim99@2 131 " -v, --verbose verbosely list files processed\n",
joachim99@2 132 " -h, --help print this help, then exit\n",
joachim99@2 133 " --version print version number, then exit\n",
joachim99@2 134 " -p, --path= use the path to am_edit if the path\n",
joachim99@14 135 " called from is not the one to be used\n",
joachim99@14 136 " --no-final don't patch for --enable-final\n";
joachim99@2 137
joachim99@2 138 exit 0;
joachim99@2 139 }
joachim99@2 140 elsif (/^--no-final$/)
joachim99@2 141 {
joachim99@2 142 $use_final = 0;
joachim99@2 143 $thisProg .= " --no-final";
joachim99@2 144 }
joachim99@2 145 elsif (/^--foreign-libtool$/)
joachim99@2 146 {
joachim99@2 147 $foreign_libtool = 1;
joachim99@2 148 $thisProg .= " --foreign-libtool";
joachim99@2 149 }
joachim99@2 150 elsif (/^-n$/)
joachim99@2 151 {
joachim99@2 152 $dryrun = 1;
joachim99@2 153 }
joachim99@2 154 else
joachim99@2 155 {
joachim99@2 156 # user selects what input files to check
joachim99@2 157 # add full path if relative path is given
joachim99@2 158 $_ = cwd()."/".$_ if (! /^\//);
joachim99@2 159 print "User wants $_\n" if ($verbose);
joachim99@2 160 push (@makefiles, $_);
joachim99@2 161 }
joachim99@2 162 }
joachim99@2 163
joachim99@2 164 if ($thisProg =~ /^\// && !$pathoption )
joachim99@2 165 {
joachim99@2 166 print STDERR "Illegal full pathname call performed...\n",
joachim99@2 167 "The call to \"$thisProg\"\nwould be inserted in some Makefile.in.\n",
joachim99@2 168 "Please use option --path.\n";
joachim99@2 169 exit 1;
joachim99@2 170 }
joachim99@2 171
joachim99@2 172 # Only scan for files when the user hasn't entered data
joachim99@2 173 if (!@makefiles)
joachim99@2 174 {
joachim99@2 175 print STDOUT "Scanning for Makefile.in\n" if ($verbose);
joachim99@2 176 find (\&add_makefile, cwd());
joachim99@2 177 #chdir('$topdir');
joachim99@2 178 } else {
joachim99@14 179 print STDOUT "Using input files specified by user\n" if ($verbose);
joachim99@2 180 }
joachim99@2 181
joachim99@2 182 foreach $makefile (sort(@makefiles))
joachim99@2 183 {
joachim99@2 184 processMakefile ($makefile);
joachim99@2 185 last if ($errorflag);
joachim99@2 186 }
joachim99@2 187
joachim99@2 188 # Just some debug statistics - comment out for release as it uses printf.
joachim99@2 189 printf STDOUT "Time %.2f CPU sec\n", (times)[0] - $start if ($verbose);
joachim99@2 190
joachim99@2 191 exit $errorflag; # causes make to fail if erroflag is set
joachim99@2 192
joachim99@2 193 #-----------------------------------------------------------------------------
joachim99@2 194
joachim99@2 195 # In conjunction with the "find" call, this builds the list of input files
joachim99@2 196 sub add_makefile ()
joachim99@2 197 {
joachim99@2 198 push (@makefiles, $File::Find::name) if (/Makefile.in$/);
joachim99@2 199 }
joachim99@2 200
joachim99@2 201 #-----------------------------------------------------------------------------
joachim99@2 202
joachim99@2 203 # Processes a single make file
joachim99@2 204 # The parameter contains the full path name of the Makefile.in to use
joachim99@2 205 sub processMakefile ($)
joachim99@2 206 {
joachim99@2 207 # some useful globals for the subroutines called here
joachim99@2 208 local ($makefile) = @_;
joachim99@2 209 local @headerdirs = ('.');
joachim99@2 210 local $haveAutomocTag = 0;
joachim99@2 211 local $MakefileData = "";
joachim99@2 212
joachim99@2 213 local $cxxsuffix = "KKK";
joachim99@2 214
joachim99@2 215 local @programs = (); # lists the names of programs and libraries
joachim99@2 216 local $program = "";
joachim99@2 217
joachim99@14 218 local @kdeinits = (); # lists the kdeinit targets
joachim99@14 219
joachim99@2 220 local %realObjs = (); # lists the objects compiled into $program
joachim99@2 221 local %sources = (); # lists the sources used for $program
joachim99@2 222 local %finalObjs = (); # lists the objects compiled when final
joachim99@2 223 local %realname = (); # the binary name of program variable
joachim99@2 224 local %idlfiles = (); # lists the idl files used for $program
joachim99@2 225 local %globalmocs = ();# list of all mocfiles (in %mocFiles format)
joachim99@2 226 local %important = (); # list of files to be generated asap
joachim99@2 227 local %uiFiles = ();
joachim99@66 228 local %kcfgFiles = ();
joachim99@2 229
joachim99@2 230 local $allidls = "";
joachim99@2 231 local $idl_output = "";# lists all idl generated files for cleantarget
joachim99@2 232 local $ui_output = "";# lists all uic generated files for cleantarget
joachim99@66 233 local $kcfg_output = "";# lists all kcfg generated files for cleantarget
joachim99@2 234
joachim99@14 235 local %dependmocs = ();
joachim99@2 236
joachim99@2 237 local $metasourceTags = 0;
joachim99@2 238 local $dep_files = "";
joachim99@2 239 local $dep_finals = "";
joachim99@2 240 local %target_adds = (); # the targets to add
joachim99@14 241 local %rule_adds = ();
joachim99@2 242 local $kdelang = "";
joachim99@2 243 local @cleanfiles = ();
joachim99@2 244 local $cleanMoc = "";
joachim99@2 245 local $closure_output = "";
joachim99@2 246
joachim99@14 247 local %varcontent = ();
joachim99@14 248
joachim99@2 249 $makefileDir = dirname($makefile);
joachim99@2 250 chdir ($makefileDir);
joachim99@2 251 $printname = $makefile;
joachim99@2 252 $printname =~ s/^\Q$topdir\E\///;
joachim99@2 253 $makefile = basename($makefile);
joachim99@2 254
joachim99@2 255 print STDOUT "Processing makefile $printname\n" if ($verbose);
joachim99@14 256
joachim99@2 257 # Setup and see if we need to do this.
joachim99@2 258 return if (!initialise());
joachim99@14 259
joachim99@2 260 tag_AUTOMAKE (); # Allows a "make" to redo the Makefile.in
joachim99@2 261 tag_META_INCLUDES (); # Supplies directories for src locations
joachim99@14 262
joachim99@2 263 foreach $program (@programs) {
joachim99@2 264 $sources_changed{$program} = 0;
joachim99@14 265 $dependmocs{$program} = "";
joachim99@2 266 $important{$program} = "";
joachim99@2 267 tag_IDLFILES(); # Sorts out idl rules
joachim99@14 268 tag_NO_UNDEFINED();
joachim99@2 269 tag_CLOSURE();
joachim99@14 270 tag_NMCHECK();
joachim99@66 271 tag_UIFILES(); # Sorts out ui rules
joachim99@66 272 tag_KCFGFILES(); # Sorts out kcfg rules
joachim99@2 273 tag_METASOURCES (); # Sorts out the moc rules
joachim99@2 274 if ($sources_changed{$program}) {
joachim99@14 275 my $lookup = $program . '_SOURCES\s*=[ \t]*(.*)';
joachim99@14 276
joachim99@14 277 if($program =~ /libkdeinit_(.*)/) {
joachim99@14 278 my $prog = $1;
joachim99@66 279 substituteLine($prog . '_SOURCES\s*=[ \t]*(.*)',
joachim99@14 280 "${prog}_SOURCES = ${prog}_dummy.$cxxsuffix\n" .
joachim99@14 281 "libkdeinit_${prog}_SOURCES = " . $sources{$program});
joachim99@14 282 $sources{$prog} = "${prog}_dummy.$cxxsuffix";
joachim99@14 283 }
joachim99@14 284 else {
joachim99@14 285 substituteLine($lookup, "$program\_SOURCES=" . $sources{$program});
joachim99@14 286 }
joachim99@2 287 }
joachim99@2 288 if ($important{$program}) {
joachim99@2 289 local %source_dict = ();
joachim99@2 290 for $source (split(/[\034\s]+/, $sources{$program})) {
joachim99@2 291 $source_dict{$source} = 1;
joachim99@2 292 }
joachim99@2 293 for $source (@cleanfiles) {
joachim99@2 294 $source_dict{$source} = 0;
joachim99@2 295 }
joachim99@2 296 for $source (keys %source_dict) {
joachim99@2 297 next if (!$source);
joachim99@2 298 if ($source_dict{$source}) {
joachim99@2 299 # sanity check
joachim99@2 300 if (! -f $source) {
joachim99@2 301 print STDERR "Error: $source is listed in a _SOURCE line in $printname, but doesn't exist yet. Put it in DISTCLEANFILES!\n";
joachim99@2 302 } else {
joachim99@2 303 $target_adds{"\$(srcdir)/$source"} .= $important{$program};
joachim99@2 304 }
joachim99@2 305 }
joachim99@2 306 }
joachim99@2 307 }
joachim99@2 308 }
joachim99@2 309 if ($cleanMoc) {
joachim99@2 310 # Always add dist clean tag
joachim99@2 311 # Add extra *.moc.cpp files created for USE_AUTOMOC because they
joachim99@2 312 # aren't included in the normal *.moc clean rules.
joachim99@2 313 appendLines ("$cleantarget-metasources:\n\t-rm -f $cleanMoc\n");
joachim99@2 314 $target_adds{"$cleantarget-am"} .= "$cleantarget-metasources ";
joachim99@2 315 }
joachim99@14 316
joachim99@14 317 tag_DIST() unless ($kdeopts{"noautodist"});
joachim99@2 318
joachim99@2 319 if ($idl_output) {
joachim99@2 320 appendLines ("$cleantarget-idl:\n\t-rm -f $idl_output\n");
joachim99@2 321 $target_adds{"$cleantarget-am"} .= "$cleantarget-idl ";
joachim99@2 322 }
joachim99@2 323
joachim99@2 324 if ($ui_output) {
joachim99@2 325 appendLines ("$cleantarget-ui:\n\t-rm -f $ui_output\n");
joachim99@2 326 $target_adds{"$cleantarget-am"} .= "$cleantarget-ui ";
joachim99@2 327 }
joachim99@2 328
joachim99@66 329 if ($kcfg_output) {
joachim99@66 330 appendLines ("$cleantarget-kcfg:\n\t-rm -f $kcfg_output\n");
joachim99@66 331 $target_adds{"$cleantarget-am"} .= "$cleantarget-kcfg ";
joachim99@66 332 }
joachim99@66 333
joachim99@2 334 if ($closure_output) {
joachim99@2 335 appendLines ("$cleantarget-closures:\n\t-rm -f $closure_output\n");
joachim99@2 336 $target_adds{"$cleantarget-am"} .= "$cleantarget-closures ";
joachim99@2 337 }
joachim99@2 338
joachim99@2 339 if ($MakefileData =~ /\nKDE_LANG\s*=\s*(\S*)\s*\n/) {
joachim99@2 340 $kdelang = '$(KDE_LANG)'
joachim99@2 341 } else {
joachim99@2 342 $kdelang = '';
joachim99@2 343 }
joachim99@2 344
joachim99@2 345 tag_POFILES (); # language rules for po directory
joachim99@2 346 tag_DOCFILES (); # language rules for doc directories
joachim99@2 347 tag_LOCALINSTALL(); # add $(DESTDIR) before all kde_ dirs
joachim99@2 348 tag_ICON();
joachim99@2 349 tag_SUBDIRS();
joachim99@2 350
joachim99@2 351 my $tmp = "force-reedit:\n";
joachim99@2 352 $tmp .= "\t$automkCall\n\tcd \$(top_srcdir) && perl $thisProg $printname\n\n";
joachim99@2 353 appendLines($tmp);
joachim99@2 354
joachim99@14 355 make_bcheck_target();
joachim99@2 356 make_meta_classes();
joachim99@2 357 tag_COMPILE_FIRST();
joachim99@2 358 tag_FINAL() if (!$kdeopts{"nofinal"});
joachim99@2 359
joachim99@2 360 my $final_lines = "final:\n\t\$(MAKE) ";
joachim99@2 361 my $final_install_lines = "final-install:\n\t\$(MAKE) ";
joachim99@2 362 my $nofinal_lines = "no-final:\n\t\$(MAKE) ";
joachim99@2 363 my $nofinal_install_lines = "no-final-install:\n\t\$(MAKE) ";
joachim99@2 364
joachim99@2 365 foreach $program (@programs) {
joachim99@14 366 my $lookup = $program . '_OBJECTS\s*=[ \t]*.*';
joachim99@2 367 my $new = "";
joachim99@2 368 my @list = split(/[\034\s]+/, $realObjs{$program});
joachim99@2 369 if (!$kdeopts{"nofinal"} && @list > 1 && $finalObjs{$program}) {
joachim99@2 370 $new .= "$program\_final\_OBJECTS = " . $finalObjs{$program};
joachim99@2 371 $new .= "\n$program\_nofinal\_OBJECTS = " . $realObjs{$program};
joachim99@2 372 $new .= "\n\@KDE_USE_FINAL_FALSE\@$program\_OBJECTS = \$($program\_nofinal\_OBJECTS)";
joachim99@2 373 $new .= "\n\@KDE_USE_FINAL_TRUE\@$program\_OBJECTS = \$($program\_final\_OBJECTS)";
joachim99@14 374
joachim99@2 375 $final_lines .= "$program\_OBJECTS=\"\$($program\_final_OBJECTS)\" ";
joachim99@2 376 $final_install_lines .= "$program\_OBJECTS=\"\$($program\_final_OBJECTS)\" ";
joachim99@2 377 $nofinal_lines .= "$program\_OBJECTS=\"\$($program\_nofinal\_OBJECTS)\" ";
joachim99@2 378 $nofinal_install_lines .= "$program\_OBJECTS=\"\$($program\_nofinal_OBJECTS)\" ";
joachim99@2 379 } else {
joachim99@2 380 $new = "$program\_OBJECTS = " . $realObjs{$program};
joachim99@2 381 }
joachim99@14 382 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 383 substituteLine ($lookup, $new);
joachim99@14 384 }
joachim99@14 385 else {
joachim99@14 386 appendLines("$new\n");
joachim99@14 387 }
joachim99@2 388 }
joachim99@14 389 appendLines($final_lines . "all-am\n");
joachim99@14 390 appendLines($final_install_lines . "install-am\n");
joachim99@14 391 appendLines($nofinal_lines . "all-am\n");
joachim99@14 392 appendLines($nofinal_install_lines . "install-am\n");
joachim99@14 393
joachim99@14 394 my $lookup = '(\@\S+\@)?DEP_FILES\s*=[ \t]*(.*)';
joachim99@14 395 if ($MakefileData =~ /\n$lookup/) {
joachim99@14 396 my $condition = $1;
joachim99@14 397 my $depfiles = $2;
joachim99@14 398 my $workfiles;
joachim99@14 399
joachim99@2 400 if ($dep_finals) {
joachim99@14 401 # Add the conditions on every line, since
joachim99@14 402 # there may be line continuations in the list.
joachim99@14 403 $workfiles = "$dep_files $dep_finals $depfiles";
joachim99@14 404 $workfiles =~ s/\034/\034$condition\@KDE_USE_FINAL_TRUE\@\t/g;
joachim99@14 405 $lines = "$condition\@KDE_USE_FINAL_TRUE\@DEP_FILES = $workfiles\n";
joachim99@14 406 $workfiles = "$dep_files $depfiles";
joachim99@14 407 $workfiles =~ s/\034/\034$condition\@KDE_USE_FINAL_FALSE\@\t/g;
joachim99@14 408 $lines .= "$condition\@KDE_USE_FINAL_FALSE\@DEP_FILES = $workfiles";
joachim99@2 409 } else {
joachim99@14 410 $workfiles = "$dep_files $depfiles";
joachim99@14 411 $workfiles =~ s/\034/\034$condition\t/g;
joachim99@14 412 $lines = $condition . "DEP_FILES = $workfiles";
joachim99@2 413 }
joachim99@2 414 substituteLine($lookup, $lines);
joachim99@2 415 }
joachim99@14 416
joachim99@14 417 # new recursive targets
joachim99@14 418 $target_adds{ "nmcheck" } .= ""; # always create nmcheck target
joachim99@14 419 $target_adds{ "nmcheck-am" } .= "nmcheck";
joachim99@14 420 $lookup = 'RECURSIVE_TARGETS\s*=[ \t]*(.*)';
joachim99@14 421 if ($MakefileData =~ /\n$lookup/) {
joachim99@14 422 substituteLine($lookup, "RECURSIVE_TARGETS = $1 nmcheck-recursive bcheck-recursive");
joachim99@14 423 }
joachim99@14 424
joachim99@2 425 my $cvs_lines = "cvs-clean:\n";
joachim99@14 426 $cvs_lines .= "\t\$(MAKE) admindir=\$(top_srcdir)/admin -f \$(top_srcdir)/admin/Makefile.common cvs-clean\n";
joachim99@2 427 appendLines($cvs_lines);
joachim99@14 428
joachim99@2 429 $cvs_lines = "kde-rpo-clean:\n";
joachim99@2 430 $cvs_lines .= "\t-rm -f *.rpo\n";
joachim99@2 431 appendLines($cvs_lines);
joachim99@2 432 $target_adds{"clean"} .= "kde-rpo-clean ";
joachim99@2 433
joachim99@14 434 my %target_dels = ("install-data-am" => "");
joachim99@14 435
joachim99@2 436 # some strange people like to do a install-exec, and expect that also
joachim99@2 437 # all modules are installed. automake doesn't know this, so we need to move
joachim99@2 438 # this here from install-data to install-exec.
joachim99@2 439 if ($MakefileData =~ m/\nkde_module_LTLIBRARIES\s*=/) {
joachim99@14 440 # $target_adds{"install-exec-am"} .= "install-kde_moduleLTLIBRARIES ";
joachim99@14 441 # don't use $target_adds here because we need to append the dependency, not
joachim99@14 442 # prepend it. Fixes #44342 , when a module depends on a lib in the same dir
joachim99@14 443 # and libtool needs it during relinking upon install (Simon)
joachim99@14 444 my $lookup = "install-exec-am:([^\n]*)";
joachim99@14 445 if($MakefileData =~ /\n$lookup\n/) {
joachim99@14 446 substituteLine("$lookup", "install-exec-am: $1 install-kde_moduleLTLIBRARIES");
joachim99@2 447 }
joachim99@14 448 $target_dels{"install-data-am"} .= "install-kde_moduleLTLIBRARIES ";
joachim99@14 449 $target_adds{"install-data-am"} .= " ";
joachim99@2 450 }
joachim99@14 451
joachim99@2 452 my $lines = "";
joachim99@2 453
joachim99@2 454 foreach $add (keys %target_adds) {
joachim99@2 455 my $lookup = quotemeta($add) . ':([^\n]*)';
joachim99@2 456 if ($MakefileData =~ /\n$lookup\n/) {
joachim99@14 457 my $newlines = $1;
joachim99@14 458 my $oldlines = $lookup;
joachim99@14 459 if (defined $target_dels{$add}) {
joachim99@14 460 foreach $del (split(' ', $target_dels{$add})) {
joachim99@14 461 $newlines =~ s/\s*$del\s*/ /g;
joachim99@14 462 }
joachim99@14 463 }
joachim99@14 464 substituteLine($oldlines, "$add: " . $target_adds{$add} . $newlines);
joachim99@2 465 } else {
joachim99@14 466 $lines .= "$add: " . $target_adds{$add} . "\n";
joachim99@2 467 }
joachim99@2 468 }
joachim99@14 469
joachim99@14 470 appendLines($lines) if ($lines);
joachim99@14 471
joachim99@14 472 $lines = join("\n", values %rule_adds);
joachim99@14 473 appendLines($lines) if ($lines);
joachim99@2 474
joachim99@2 475 my $found = 1;
joachim99@14 476
joachim99@2 477 while ($found) {
joachim99@2 478 if ($MakefileData =~ m/\n(.*)\$\(CXXFLAGS\)(.*)\n/) {
joachim99@14 479 my $stuff_before = $1;
joachim99@14 480 my $stuff_after = $2;
joachim99@2 481 my $lookup = quotemeta("$1\$(CXXFLAGS)$2");
joachim99@2 482 my $replacement = "$1\$(KCXXFLAGS)$2";
joachim99@2 483 $MakefileData =~ s/$lookup/$replacement/;
joachim99@2 484 $lookup =~ s/\\\$\\\(CXXFLAGS\\\)/\\\$\\\(KCXXFLAGS\\\)/;
joachim99@14 485 $replacement = "$stuff_before\$(KCXXFLAGS) \$(KDE_CXXFLAGS)$stuff_after";
joachim99@2 486 substituteLine($lookup, $replacement);
joachim99@2 487 } else {
joachim99@2 488 $found = 0;
joachim99@2 489 }
joachim99@2 490 }
joachim99@2 491
joachim99@2 492 if($foreign_libtool == 0) {
joachim99@2 493 $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=link) (\$\(CXXLD\).*\$\(KCXXFLAGS\))';
joachim99@14 494
joachim99@2 495 if ($MakefileData =~ m/$lookup/ ) {
joachim99@2 496 $MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
joachim99@2 497 }
joachim99@2 498
joachim99@14 499 $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=compile)\s+(\$\(CXX\)\s+)';
joachim99@2 500 if ($MakefileData =~ m/$lookup/ ) {
joachim99@2 501 $MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
joachim99@2 502 }
joachim99@2 503 }
joachim99@2 504
joachim99@2 505 $MakefileData =~ s/\$\(KCXXFLAGS\)/\$\(CXXFLAGS\)/g;
joachim99@2 506
joachim99@2 507 $lookup = '(.*)cp -pr \$\$/\$\$file \$\(distdir\)/\$\$file(.*)';
joachim99@2 508 if ($MakefileData =~ m/\n$lookup\n/) {
joachim99@2 509 substituteLine($lookup, "$1cp -pr \$\$d/\$\$file \$(distdir)/\$\$file$2");
joachim99@2 510 }
joachim99@2 511
joachim99@2 512 # Always update the Makefile.in
joachim99@2 513 updateMakefile ();
joachim99@2 514 return;
joachim99@2 515 }
joachim99@2 516
joachim99@2 517 #-----------------------------------------------------------------------------
joachim99@2 518
joachim99@14 519 # Beware: This procedure is not complete. E.g. it also parses lines
joachim99@14 520 # containing a '=' in rules (for instance setting shell vars). For our
joachim99@14 521 # usage this us enough, though.
joachim99@14 522 sub read_variables ()
joachim99@14 523 {
joachim99@14 524 while ($MakefileData =~ /\n\s*(\S+)\s*=([^\n]*)/g) {
joachim99@14 525 $varcontent{$1} = $2;
joachim99@14 526 }
joachim99@14 527 }
joachim99@14 528
joachim99@2 529 # Check to see whether we should process this make file.
joachim99@2 530 # This is where we look for tags that we need to process.
joachim99@2 531 # A small amount of initialising on the tags is also done here.
joachim99@2 532 # And of course we open and/or create the needed make files.
joachim99@2 533 sub initialise ()
joachim99@2 534 {
joachim99@2 535 if (! -r "Makefile.am") {
joachim99@2 536 print STDOUT "found Makefile.in without Makefile.am\n" if ($verbose);
joachim99@2 537 return 0;
joachim99@2 538 }
joachim99@2 539
joachim99@2 540 # Checking for files to process...
joachim99@66 541
joachim99@66 542 open (FILEIN, $makefile) || die "Can't open $makefileDir/$makefile: $!\n";
joachim99@66 543 # perl bug in 5.8.0: in utf8 mode it badly screws up
joachim99@66 544 binmode(FILEIN, ":bytes") if ($] >= 5.008);
joachim99@2 545 # Read the file
joachim99@2 546 # stat(FILEIN)[7] might look more elegant, but is slower as it
joachim99@2 547 # requires stat'ing the file
joachim99@2 548 seek(FILEIN, 0, 2);
joachim99@2 549 my $fsize = tell(FILEIN);
joachim99@2 550 seek(FILEIN, 0, 0);
joachim99@2 551 read FILEIN, $MakefileData, $fsize;
joachim99@2 552 close FILEIN;
joachim99@2 553 print "DOS CRLF within $makefileDir/$makefile!\n" if($MakefileData =~ y/\r//d);
joachim99@2 554
joachim99@2 555 # Remove the line continuations, but keep them marked
joachim99@2 556 # Note: we lose the trailing spaces but that's ok.
joachim99@14 557 # Don't mangle line-leading spaces (usually tabs)
joachim99@14 558 # since they're important.
joachim99@14 559 $MakefileData =~ s/\\\s*\n/\034/g;
joachim99@2 560
joachim99@2 561 # If we've processed the file before...
joachim99@2 562 restoreMakefile () if ($MakefileData =~ /$progId/);
joachim99@2 563
joachim99@2 564 foreach $dir (@foreignfiles) {
joachim99@2 565 if (substr($makefileDir,0,length($dir)) eq $dir) {
joachim99@2 566 return 0;
joachim99@2 567 }
joachim99@2 568 }
joachim99@2 569
joachim99@2 570 %kdeopts = ();
joachim99@2 571 $kdeopts{"foreign"} = 0;
joachim99@2 572 $kdeopts{"qtonly"} = 0;
joachim99@14 573 $kdeopts{"noautodist"} = 0;
joachim99@2 574 $kdeopts{"foreign-libtool"} = $foreign_libtool;
joachim99@2 575 $kdeopts{"nofinal"} = !$use_final; # default
joachim99@2 576
joachim99@14 577 read_variables();
joachim99@14 578
joachim99@14 579 if ($MakefileData =~ /\nKDE_OPTIONS\s*=[ \t]*([^\n]*)\n/) {
joachim99@14 580 my $kde_options_str = $1;
joachim99@14 581 local @kde_options = split(/[\034\s]+/, $kde_options_str);
joachim99@2 582 if (grep(/^foreign$/, @kde_options)) {
joachim99@2 583 push(@foreignfiles, $makefileDir . "/");
joachim99@2 584 return 0; # don't touch me
joachim99@2 585 }
joachim99@2 586 for $opt (@kde_options) {
joachim99@2 587 if (!defined $kdeopts{$opt}) {
joachim99@2 588 print STDERR "Warning: unknown option $opt in $printname\n";
joachim99@2 589 } else {
joachim99@2 590 $kdeopts{$opt} = 1;
joachim99@2 591 }
joachim99@2 592 }
joachim99@2 593 }
joachim99@2 594
joachim99@2 595 # Look for the tags that mean we should process this file.
joachim99@2 596 $metasourceTags = 0;
joachim99@2 597 $metasourceTags++ while ($MakefileData =~ /\n[^=\#]*METASOURCES\s*=/g);
joachim99@2 598
joachim99@2 599 my $pofileTag = 0;
joachim99@2 600 $pofileTag++ while ($MakefileData =~ /\nPOFILES\s*=/g);
joachim99@2 601 if ($pofileTag > 1)
joachim99@2 602 {
joachim99@2 603 print STDERR "Error: Only one POFILES tag allowed\n";
joachim99@2 604 $errorflag = 1;
joachim99@2 605 }
joachim99@2 606
joachim99@2 607 while ($MakefileData =~ /\n\.SUFFIXES:([^\n]+)\n/g) {
joachim99@14 608 my $suffixes_str = $1;
joachim99@14 609 my @list=split(' ', $suffixes_str);
joachim99@2 610 foreach $ext (@list) {
joachim99@2 611 if ($ext =~ /^\.$cppExt$/) {
joachim99@2 612 $cxxsuffix = $ext;
joachim99@2 613 $cxxsuffix =~ s/\.//g;
joachim99@2 614 print STDOUT "will use suffix $cxxsuffix\n" if ($verbose);
joachim99@2 615 last;
joachim99@2 616 }
joachim99@2 617 }
joachim99@2 618 }
joachim99@14 619
joachim99@14 620 tag_KDEINIT();
joachim99@14 621
joachim99@14 622 while ($MakefileData =~ /\n(\S*)_OBJECTS\s*=[\034 \t]*([^\n]*)\n/g) {
joachim99@14 623
joachim99@2 624 my $program = $1;
joachim99@2 625 my $objs = $2; # safe them
joachim99@14 626
joachim99@2 627 my $ocv = 0;
joachim99@14 628
joachim99@14 629 my @objlist = split(/[\034\s]+/, $objs);
joachim99@2 630 foreach $obj (@objlist) {
joachim99@14 631 if ($obj =~ /(\S*)\$\((\S+)\)/ ) {
joachim99@14 632 my $pre = $1;
joachim99@14 633 my $variable = $2;
joachim99@14 634 if ($pre eq '' && exists($varcontent{$variable})) {
joachim99@14 635 my @addlist = split(/[\034\s]+/, $varcontent{$variable});
joachim99@14 636 push(@objlist, @addlist);
joachim99@14 637 } elsif ($variable !~ 'OBJEXT') {
joachim99@2 638 $ocv = 1;
joachim99@14 639 }
joachim99@2 640 }
joachim99@2 641 }
joachim99@14 642
joachim99@2 643 next if ($ocv);
joachim99@14 644 next if ($program =~ /^am_libkdeinit_/);
joachim99@2 645
joachim99@2 646 $program =~ s/^am_// if ($program =~ /^am_/);
joachim99@14 647
joachim99@2 648 my $sourceprogram = $program;
joachim99@2 649 $sourceprogram =~ s/\@am_/\@/ if($sourceprogram =~ /^.*\@am_.+/);
joachim99@14 650
joachim99@2 651 print STDOUT "found program $program\n" if ($verbose);
joachim99@2 652 push(@programs, $program);
joachim99@14 653
joachim99@2 654 $realObjs{$program} = $objs;
joachim99@14 655
joachim99@14 656 if ($MakefileData =~ /\n$sourceprogram\_SOURCES\s*=[ \t]*(.*)\n/) {
joachim99@2 657 $sources{$program} = $1;
joachim99@2 658 }
joachim99@2 659 else {
joachim99@2 660 $sources{$program} = "";
joachim99@2 661 print STDERR "found program with no _SOURCES: $program\n";
joachim99@2 662 }
joachim99@2 663
joachim99@2 664 my $realprogram = $program;
joachim99@2 665 $realprogram =~ s/_/./g; # unmask to regexp
joachim99@2 666 if ($MakefileData =~ /\n($realprogram)(\$\(EXEEXT\)?)?:.*\$\($program\_OBJECTS\)/) {
joachim99@2 667 $realname{$program} = $1;
joachim99@2 668 } else {
joachim99@2 669 # not standard Makefile - nothing to worry about
joachim99@2 670 $realname{$program} = "";
joachim99@2 671 }
joachim99@2 672 }
joachim99@14 673
joachim99@14 674 my $lookup = 'DEPDIR\s*=.*';
joachim99@14 675 if ($MakefileData !~ /\n$lookup/) {
joachim99@14 676 $lookup = 'bindir\s*=[ \t]*.*';
joachim99@14 677 substituteLine($lookup, "DEPDIR = .deps\n$1") if ($MakefileData =~ /\n($lookup)/);
joachim99@14 678 }
joachim99@2 679
joachim99@2 680 my @marks = ('MAINTAINERCLEANFILES', 'CLEANFILES', 'DISTCLEANFILES');
joachim99@2 681 foreach $mark (@marks) {
joachim99@14 682 while ($MakefileData =~ /\n($mark)\s*=[ \t]*([^\n]*)/g) {
joachim99@14 683 my $clean_str = $2;
joachim99@14 684 foreach $file (split('[\034\s]+', $clean_str)) {
joachim99@2 685 $file =~ s/\.\///;
joachim99@2 686 push(@cleanfiles, $file);
joachim99@2 687 }
joachim99@2 688 }
joachim99@2 689 }
joachim99@2 690
joachim99@2 691 my $localTag = 0;
joachim99@2 692 $localTag++ if ($MakefileData =~ /\ninstall-\S+-local:/);
joachim99@2 693
joachim99@2 694 return (!$errorflag);
joachim99@2 695 }
joachim99@2 696
joachim99@2 697 #-----------------------------------------------------------------------------
joachim99@2 698
joachim99@2 699 # Gets the list of user defined directories - relative to $srcdir - where
joachim99@2 700 # header files could be located.
joachim99@2 701 sub tag_META_INCLUDES ()
joachim99@2 702 {
joachim99@14 703 my $lookup = '[^=\n]*META_INCLUDES\s*=[ \t]*(.*)';
joachim99@14 704 return 1 if ($MakefileData !~ /($lookup)\n/);
joachim99@2 705 print STDOUT "META_INCLUDE processing <$1>\n" if ($verbose);
joachim99@2 706
joachim99@2 707 my $headerStr = $2;
joachim99@2 708 removeLine ($lookup, $1);
joachim99@2 709
joachim99@14 710 my @headerlist = split(/[\034\s]+/, $headerStr);
joachim99@2 711
joachim99@2 712 foreach $dir (@headerlist)
joachim99@2 713 {
joachim99@2 714 $dir =~ s#\$\(srcdir\)#.#;
joachim99@2 715 if (! -d $dir)
joachim99@2 716 {
joachim99@2 717 print STDERR "Warning: $dir can't be found. ",
joachim99@2 718 "Must be a relative path to \$(srcdir)\n";
joachim99@2 719 }
joachim99@2 720 else
joachim99@2 721 {
joachim99@2 722 push (@headerdirs, $dir);
joachim99@2 723 }
joachim99@2 724 }
joachim99@2 725
joachim99@2 726 return 0;
joachim99@2 727 }
joachim99@2 728
joachim99@2 729 #-----------------------------------------------------------------------------
joachim99@2 730
joachim99@2 731 sub tag_FINAL()
joachim99@2 732 {
joachim99@2 733 my @final_names = ();
joachim99@2 734
joachim99@2 735 foreach $program (@programs) {
joachim99@2 736
joachim99@2 737 if ($sources{$program} =~ /\(/) {
joachim99@2 738 print STDOUT "found ( in $program\_SOURCES. skipping\n" if ($verbose);
joachim99@2 739 next;
joachim99@2 740 }
joachim99@14 741
joachim99@14 742 my $mocs = ""; # Moc files (in this program)
joachim99@14 743 my $moc_cpp_added = 0; # If we added some .moc.cpp files, due to
joachim99@14 744 # no other .cpp file including the .moc one.
joachim99@2 745
joachim99@14 746 my @progsources = split(/[\034\s]+/, $sources{$program});
joachim99@14 747 my %shash = ();
joachim99@14 748 @shash{@progsources} = 1; # we are only interested in the existence
joachim99@2 749 my %sourcelist = ();
joachim99@66 750 my %extradeps = ();
joachim99@2 751
joachim99@2 752 foreach $source (@progsources) {
joachim99@2 753 my $suffix = $source;
joachim99@2 754 $suffix =~ s/^.*\.([^\.]+)$/$1/;
joachim99@2 755
joachim99@14 756 $sourcelist{$suffix} .= "$source ";
joachim99@14 757 }
joachim99@14 758 foreach my $mocFile (keys (%globalmocs))
joachim99@14 759 {
joachim99@14 760 my ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3);
joachim99@14 761 if (defined ($cppFile)) {
joachim99@14 762 $mocs .= " $mocFile.moc" if exists $shash{$cppFile};
joachim99@2 763 } else {
joachim99@14 764 $sourcelist{$cxxsuffix} .= "$mocFile.moc.$cxxsuffix ";
joachim99@14 765 $moc_cpp_added = 1;
joachim99@14 766 }
joachim99@2 767 }
joachim99@66 768
joachim99@66 769 # scan for extra given dependencies and add them to our target
joachim99@66 770 while ($MakefileData =~ /\n\s*(\S+)\.(?:lo|o)\s*:([^\n]*)/g) {
joachim99@66 771 $extradeps{$1} = $2;
joachim99@66 772 }
joachim99@66 773
joachim99@2 774 foreach $suffix (keys %sourcelist) {
joachim99@14 775 # See if this file contains c++ code. (i.e., just check the file's suffix against c++ extensions)
joachim99@2 776 my $suffix_is_cxx = 0;
joachim99@2 777 if($suffix =~ /($cppExt)$/) {
joachim99@2 778 $cxxsuffix = $1;
joachim99@2 779 $suffix_is_cxx = 1;
joachim99@2 780 }
joachim99@2 781
joachim99@14 782 my $mocfiles_in = ($suffix eq $cxxsuffix) && $moc_cpp_added;
joachim99@2 783
joachim99@14 784 my @sourcelist = split(/[\034\s]+/, $sourcelist{$suffix});
joachim99@2 785
joachim99@2 786 if ((@sourcelist == 1 && !$mocfiles_in) || $suffix_is_cxx != 1 ) {
joachim99@2 787
joachim99@2 788 # we support IDL on our own
joachim99@14 789 if ($suffix eq "skel" || $suffix =~ /^stub/
joachim99@14 790 || $suffix =~ /^signals/ # obsolete, remove in KDE-4
joachim99@66 791 || $suffix eq "h" || $suffix eq "ui"
joachim99@66 792 || $suffix eq "kcfgc" ) {
joachim99@2 793 next;
joachim99@2 794 }
joachim99@2 795
joachim99@2 796 foreach $file (@sourcelist) {
joachim99@2 797 $file =~ s/\Q$suffix\E$//;
joachim99@2 798
joachim99@2 799 $finalObjs{$program} .= $file;
joachim99@2 800 if ($program =~ /_la$/) {
joachim99@2 801 $finalObjs{$program} .= "lo ";
joachim99@2 802 } else {
joachim99@2 803 $finalObjs{$program} .= "o ";
joachim99@2 804 }
joachim99@2 805 }
joachim99@2 806 next; # suffix
joachim99@2 807 }
joachim99@2 808
joachim99@2 809 my $source_deps = "";
joachim99@2 810 foreach $source (@sourcelist) {
joachim99@2 811 if (-f $source) {
joachim99@14 812 $source_deps .= " \$(srcdir)/$source";
joachim99@2 813 } else {
joachim99@14 814 $source_deps .= " $source";
joachim99@2 815 }
joachim99@66 816 my $plainsource = $source;
joachim99@66 817 $plainsource =~ s/\.$cppExt$//;
joachim99@66 818 $source_deps .= " " . $extradeps{$plainsource} if (exists($extradeps{$plainsource}));
joachim99@2 819 }
joachim99@14 820
joachim99@14 821 $handling = "$program.all_$suffix.$suffix: \$(srcdir)/Makefile.in" . $source_deps . " " . join(' ', $mocs) . "\n";
joachim99@2 822 $handling .= "\t\@echo 'creating $program.all_$suffix.$suffix ...'; \\\n";
joachim99@2 823 $handling .= "\trm -f $program.all_$suffix.files $program.all_$suffix.final; \\\n";
joachim99@2 824 $handling .= "\techo \"#define KDE_USE_FINAL 1\" >> $program.all_$suffix.final; \\\n";
joachim99@14 825 $handling .= "\tfor file in " . $sourcelist{$suffix} . "; do \\\n";
joachim99@2 826 $handling .= "\t echo \"#include \\\"\$\$file\\\"\" >> $program.all_$suffix.files; \\\n";
joachim99@2 827 $handling .= "\t test ! -f \$\(srcdir\)/\$\$file || egrep '^#pragma +implementation' \$\(srcdir\)/\$\$file >> $program.all_$suffix.final; \\\n";
joachim99@2 828 $handling .= "\tdone; \\\n";
joachim99@14 829 $handling .= "\tcat $program.all_$suffix.final $program.all_$suffix.files > $program.all_$suffix.$suffix; \\\n";
joachim99@2 830 $handling .= "\trm -f $program.all_$suffix.final $program.all_$suffix.files\n";
joachim99@14 831
joachim99@2 832 appendLines($handling);
joachim99@14 833
joachim99@2 834 push(@final_names, "$program.all_$suffix.$suffix");
joachim99@14 835 my $finalObj = "$program.all_$suffix.";
joachim99@2 836 if ($program =~ /_la$/) {
joachim99@14 837 $finalObj .= "lo";
joachim99@2 838 } else {
joachim99@14 839 $finalObj .= "o";
joachim99@2 840 }
joachim99@14 841 $finalObjs{$program} .= $finalObj . " ";
joachim99@2 842 }
joachim99@2 843 }
joachim99@2 844
joachim99@2 845 if (!$kdeopts{"nofinal"} && @final_names >= 1) {
joachim99@2 846 # add clean-final target
joachim99@2 847 my $lines = "$cleantarget-final:\n";
joachim99@2 848 $lines .= "\t-rm -f " . join(' ', @final_names) . "\n" if (@final_names);
joachim99@2 849 appendLines($lines);
joachim99@2 850 $target_adds{"$cleantarget-am"} .= "$cleantarget-final ";
joachim99@2 851
joachim99@2 852 foreach $finalfile (@final_names) {
joachim99@2 853 $finalfile =~ s/\.[^.]*$/.P/;
joachim99@2 854 $dep_finals .= " \$(DEPDIR)/$finalfile";
joachim99@2 855 }
joachim99@2 856 }
joachim99@2 857 }
joachim99@2 858
joachim99@14 859 sub tag_KDEINIT()
joachim99@14 860 {
joachim99@14 861 my @progs = ();
joachim99@14 862 my $ltlibs = "";
joachim99@14 863 my $lookup = 'kdeinit_LTLIBRARIES\s*=[ \t]*(.*)';
joachim99@14 864
joachim99@14 865 if ($MakefileData =~ m/\n$lookup/) {
joachim99@14 866 @kdeinits = split(/[\034\s]+/, $1);
joachim99@14 867 my $lines = "";
joachim99@14 868 foreach my $kdeinit (@kdeinits) {
joachim99@14 869 if ($kdeinit =~ m/\.la$/) {
joachim99@14 870 $kdeinit =~ s/\.la$//;
joachim99@14 871 push(@progs, $kdeinit);
joachim99@14 872
joachim99@14 873 $lines .= "\n${kdeinit}.la.$cxxsuffix:\n";
joachim99@14 874 $lines .= "\techo 'extern \"C\" int kdemain(int argc, char* argv[]);' > ${kdeinit}.la.$cxxsuffix; \\\n";
joachim99@14 875 $lines .= "\techo 'int main(int argc, char* argv[]) { return kdemain(argc,argv); }' >> ${kdeinit}.la.$cxxsuffix\n";
joachim99@14 876
joachim99@14 877 $lines .= "\n${kdeinit}_dummy.$cxxsuffix:\n";
joachim99@66 878 $lines .= "\techo 'extern \"C\" int kdemain(int argc, char* argv[]);' > ${kdeinit}_dummy.$cxxsuffix; \\\n";
joachim99@66 879 $lines .= "\techo 'extern \"C\" int kdeinitmain(int argc, char* argv[]) { return kdemain(argc,argv); }' >> ${kdeinit}_dummy.$cxxsuffix\n";
joachim99@14 880
joachim99@14 881 push(@cleanfiles, "${kdeinit}.la.$cxxsuffix");
joachim99@14 882 push(@cleanfiles, "${kdeinit}_dummy.$cxxsuffix");
joachim99@14 883
joachim99@14 884 # add dependency
joachim99@14 885 $dep_files .= " \$(DEPDIR)/${kdeinit}.la.Po" if($dep_files !~/${kdeinit}.la.Po/ );
joachim99@14 886 $dep_files .= " \$(DEPDIR)/${kdeinit}_dummy.Plo" if($dep_files !~/${kdeinit}_dummy.Plo/ );
joachim99@14 887
joachim99@14 888 # make library
joachim99@14 889 $lookup = $kdeinit . '_la_LIBADD\s*=[ \t]*(.*)';
joachim99@14 890 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 891 my $libadd = $1;
joachim99@14 892 substituteLine($lookup, "${kdeinit}_la_LIBADD = libkdeinit_${kdeinit}.la");
joachim99@14 893 appendLines("libkdeinit_${kdeinit}_la_LIBADD = $libadd\n");
joachim99@14 894 }
joachim99@66 895 appendLines("libkdeinit_${kdeinit}_la_LDFLAGS = -no-undefined -avoid-version \$(all_libraries)\n");
joachim99@14 896
joachim99@14 897 # add library dependencies
joachim99@14 898 $lookup = $kdeinit . '_la_DEPENDENCIES\s*=[ \t]*(.*)';
joachim99@14 899 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 900 my $libdeps = $1;
joachim99@14 901 substituteLine($lookup, "${kdeinit}_la_DEPENDENCIES = libkdeinit_${kdeinit}.la");
joachim99@14 902 appendLines("libkdeinit_${kdeinit}_la_DEPENDENCIES = $libdeps\n");
joachim99@14 903 }
joachim99@14 904
joachim99@14 905 # make library objects
joachim99@14 906 $lookup = "am_${kdeinit}_la_OBJECTS" . '\s*=[ \t]*(.*)';
joachim99@14 907 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 908 my $libobjects = $1;
joachim99@14 909 substituteLine($lookup, "am_${kdeinit}_la_OBJECTS = ${kdeinit}_dummy.lo");
joachim99@14 910 appendLines("am_libkdeinit_${kdeinit}_la_OBJECTS = $libobjects\n");
joachim99@14 911 my $prog = "libkdeinit_${kdeinit}_la";
joachim99@14 912 push(@programs, $prog);
joachim99@14 913 $realObjs{$prog} = $libobjects;
joachim99@14 914 $realname{$prog} = "libkdeinit_${kdeinit}.la";
joachim99@14 915 }
joachim99@14 916 $target_adds{"libkdeinit_${kdeinit}.la"} = "\$(libkdeinit_${kdeinit}_la_OBJECTS) \$(libkdeinit_${kdeinit}_la_DEPENDENCIES)\n" .
joachim99@14 917 "\t\$(CXXLINK) -rpath \$(libdir) \$(libkdeinit_${kdeinit}_la_LDFLAGS) ".
joachim99@14 918 "\$(libkdeinit_${kdeinit}_la_OBJECTS) " .
joachim99@14 919 "\$(libkdeinit_${kdeinit}_la_LIBADD) " .
joachim99@14 920 "\$(LIBS)\n";
joachim99@14 921
joachim99@14 922 # make libkdeinit sources
joachim99@14 923 $lookup = $kdeinit . '_la_SOURCES\s*=[ \t]*(.*)';
joachim99@14 924 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 925 my $srces = $1;
joachim99@14 926 $sources_changed{"libkdeinit_${kdeinit}_la"} = 1;
joachim99@14 927 $sources{"libkdeinit_${kdeinit}_la"} = $srces;
joachim99@14 928 }
joachim99@14 929
joachim99@14 930 # make libkdeinit metasources
joachim99@14 931 $lookup = $kdeinit . '_la_METASOURCES\s*=[ \t]*(.*)';
joachim99@14 932 substituteLine($lookup, "libkdeinit_${kdeinit}_la_METASOURCES = $1")
joachim99@14 933 if($MakefileData =~ m/\n$lookup/);
joachim99@14 934
joachim99@14 935 =cut
joachim99@14 936 # make binary sources
joachim99@14 937 $lookup = $kdeinit. '_SOURCES\s*=[ \t]*(.*)';
joachim99@14 938 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 939 substituteLine($lookup, "${kdeinit}_SOURCES = ${kdeinit}.la.$cxxsuffix");
joachim99@14 940 $lookup = 'SOURCES\s*=[ \t]*(.*)';
joachim99@14 941 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 942 my $srces = $1;
joachim99@14 943 $srces =~ s/\b$kdeinit\.c\b/\$(${kdeinit}_SOURCES)/;
joachim99@14 944 $srces =~ s/\$\(${kdeinit}_la_SOURCES\)/\$(libkdeinit_${kdeinit}_la_SOURCES)/;
joachim99@14 945 substituteLine($lookup, "SOURCES = $srces");
joachim99@14 946 }
joachim99@14 947 $lookup = 'DIST_SOURCES\s*=[ \t](.*)';
joachim99@14 948 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 949 my $srces = $1;
joachim99@14 950 $srces =~ s/\b$kdeinit\.c\b/\$(${kdeinit}_SOURCES)/;
joachim99@14 951 $srces =~ s/\$\(${kdeinit}_la_SOURCES\)/\$(libkdeinit_${kdeinit}_la_SOURCES)/;
joachim99@14 952 substituteLine($lookup, "DIST_SOURCES = $srces");
joachim99@14 953 }
joachim99@14 954 }
joachim99@14 955
joachim99@14 956 # make binary objects / libs
joachim99@14 957 $lookup = $kdeinit . '_OBJECTS\s*=[ \t]*.*';
joachim99@14 958 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 959 $realObjs{$kdeinit} = "${kdeinit}.la.\$(OBJEXT)";
joachim99@14 960 substituteLine("${kdeinit}_LDFLAGS\\s*=.*", "${kdeinit}_LDFLAGS = \$(all_libraries)");
joachim99@14 961 substituteLine("${kdeinit}_LDADD\\s*=.*", "${kdeinit}_LDADD = libkdeinit_${kdeinit}.la");
joachim99@14 962 substituteLine("${kdeinit}_DEPENDENCIES\\s*=.*", "${kdeinit}_DEPENDENCIES = libkdeinit_${kdeinit}.la");
joachim99@14 963 }
joachim99@14 964 =cut
joachim99@14 965 # add binary
joachim99@14 966 push(@programs, $kdeinit);
joachim99@14 967 $realObjs{$kdeinit} = "${kdeinit}.la.\$(OBJEXT)";
joachim99@14 968 $realname{$kdeinit} = $kdeinit;
joachim99@14 969 $sources{$kdeinit} = "${kdeinit}.la.$cxxsuffix";
joachim99@14 970
joachim99@66 971 $lines .= "${kdeinit}_LDFLAGS = \$(KDE_RPATH) -no-undefined \$(all_libraries)\n";
joachim99@14 972 $lines .= "${kdeinit}_LDADD = libkdeinit_${kdeinit}.la\n";
joachim99@14 973 $lines .= "${kdeinit}_DEPENDENCIES = libkdeinit_${kdeinit}.la\n";
joachim99@14 974
joachim99@14 975 $target_adds{"${kdeinit}\$(EXEEXT)"} =
joachim99@14 976 "\$(${kdeinit}_OBJECTS) \$(${kdeinit}_DEPENDENCIES)\n" .
joachim99@14 977 "\t\@rm -f ${kdeinit}\$(EXEEXT)\n" .
joachim99@14 978 "\t\$(CXXLINK) \$(${kdeinit}_LDFLAGS) \$(${kdeinit}_OBJECTS) \$(${kdeinit}_LDADD) \$(LIBS)\n";
joachim99@14 979
joachim99@14 980 $ltlibs .= " libkdeinit_${kdeinit}.la";
joachim99@14 981 }
joachim99@14 982 }
joachim99@14 983 appendLines($lines);
joachim99@14 984
joachim99@14 985 # add libkdeinit target
joachim99@14 986 $lookup = 'lib_LTLIBRARIES\s*=[ \t]*(.*)';
joachim99@14 987 if($MakefileData =~ m/\n$lookup/) {
joachim99@14 988 substituteLine($lookup, "lib_LTLIBRARIES = $1 $ltlibs");
joachim99@14 989 }
joachim99@14 990 else {
joachim99@14 991 print STDERR
joachim99@14 992 "Error: lib_LTLIBRARIES missing in $printname (required for kdeinit_LTLIBRARIES).\n";
joachim99@14 993 $errorflag = 1;
joachim99@14 994 }
joachim99@14 995 }
joachim99@14 996
joachim99@14 997 if($#progs >= 0) {
joachim99@14 998 if($MakefileData !~ m/\nbin_PROGRAMS\s*=/) {
joachim99@66 999 print STDERR "Error: bin_PROGRAMS missing in $printname (required for kdeinit_LTLIBRARIES).\n";
joachim99@14 1000 $errorflag = 1;
joachim99@14 1001 }
joachim99@14 1002 else {
joachim99@14 1003 # add our new progs to SOURCES, DIST_SOURCES and bin_PROGRAMS
joachim99@14 1004 my $progsources = "";
joachim99@14 1005 my $progexes = "";
joachim99@14 1006 foreach my $p (@progs) {
joachim99@14 1007 $progsources .= "\$(${p}_SOURCES) ";
joachim99@14 1008 $progexes .= "${p}\$(EXEEXT) ";
joachim99@14 1009 }
joachim99@14 1010 $lookup = 'SOURCES\s*=[ \t]*(.*)';
joachim99@14 1011 if($MakefileData =~ /\n$lookup/) {
joachim99@14 1012 substituteLine($lookup, "SOURCES = $1 $progsources");
joachim99@14 1013 }
joachim99@14 1014 $lookup = 'DIST_SOURCES\s*=[ \t]*(.*)';
joachim99@14 1015 if($MakefileData =~ /\n$lookup/) {
joachim99@14 1016 substituteLine($lookup, "DIST_SOURCES = $1 $progsources");
joachim99@14 1017 }
joachim99@14 1018 # bin_PROGRAMS is complicated, as it exists twice, so we do a little
joachim99@14 1019 # magic trick here
joachim99@14 1020 $lookup = 'PROGRAMS\s*=[ \t]*(.*)';
joachim99@14 1021 if ($MakefileData =~ /\n$lookup/) {
joachim99@14 1022 substituteLine($lookup, "bin_PROGRAMS += $progexes\nPROGRAMS = $1");
joachim99@14 1023 }
joachim99@14 1024 }
joachim99@14 1025 }
joachim99@14 1026 }
joachim99@14 1027
joachim99@2 1028 #-----------------------------------------------------------------------------
joachim99@2 1029
joachim99@2 1030 sub tag_COMPILE_FIRST()
joachim99@2 1031 {
joachim99@2 1032 foreach $program (@programs) {
joachim99@14 1033 my $lookup = "$program" . '_COMPILE_FIRST\s*=[ \t]*(.*)';
joachim99@2 1034 if ($MakefileData =~ m/\n$lookup\n/) {
joachim99@14 1035 my $compilefirst_str = $1;
joachim99@14 1036 my @compilefirst = split(/[\034\s]+/, $compilefirst_str);
joachim99@14 1037 my @progsources = split(/[\034\s]+/, $sources{$program});
joachim99@2 1038 my %donesources = ();
joachim99@2 1039 foreach $source (@progsources) {
joachim99@2 1040 my @deps = ();
joachim99@2 1041 my $sdeps = "";
joachim99@2 1042 if (-f $source) {
joachim99@2 1043 $sdeps = "\$(srcdir)/$source";
joachim99@2 1044 } else {
joachim99@2 1045 $sdeps = "$source";
joachim99@2 1046 }
joachim99@2 1047 foreach $depend (@compilefirst) {
joachim99@2 1048 next if ($source eq $depend);
joachim99@2 1049 # avoid cyclic dependencies
joachim99@2 1050 next if defined($donesources{$depend});
joachim99@2 1051 push @deps, $depend;
joachim99@2 1052 }
joachim99@66 1053 $target_adds{$sdeps} .= join(' ', @deps) . ' ' if (@deps);
joachim99@2 1054 $donesources{$source} = 1;
joachim99@2 1055 }
joachim99@2 1056 }
joachim99@2 1057 }
joachim99@2 1058 }
joachim99@2 1059
joachim99@2 1060 #-----------------------------------------------------------------------------
joachim99@2 1061
joachim99@2 1062
joachim99@2 1063 # Organises the list of headers that we'll use to produce moc files
joachim99@2 1064 # from.
joachim99@2 1065 sub tag_METASOURCES ()
joachim99@2 1066 {
joachim99@2 1067 local @newObs = (); # here we add to create object files
joachim99@14 1068 local @depend = (); # here we add to create moc files
joachim99@2 1069 local $mocExt = ".moc";
joachim99@2 1070 local %mocFiles = ();
joachim99@2 1071
joachim99@2 1072 my $line = "";
joachim99@2 1073 my $postEqual = "";
joachim99@2 1074
joachim99@2 1075 my $lookup;
joachim99@2 1076 my $found = "";
joachim99@2 1077 if ($metasourceTags > 1) {
joachim99@2 1078 $lookup = $program . '_METASOURCES\s*=\s*(.*)';
joachim99@2 1079 return 1 if ($MakefileData !~ /\n($lookup)\n/);
joachim99@2 1080 $found = $1;
joachim99@2 1081 } else {
joachim99@2 1082 $lookup = $program . '_METASOURCES\s*=\s*(.*)';
joachim99@2 1083 if ($MakefileData !~ /\n($lookup)\n/) {
joachim99@2 1084 $lookup = 'METASOURCES\s*=\s*(.*)';
joachim99@14 1085 return 1 if ($MakefileData !~ /\n($lookup)\n/);
joachim99@2 1086 $found = $1;
joachim99@2 1087 $metasourceTags = 0; # we can use the general target only once
joachim99@2 1088 } else {
joachim99@2 1089 $found = $1;
joachim99@2 1090 }
joachim99@2 1091 }
joachim99@2 1092 print STDOUT "METASOURCE processing <$found>)\n" if ($verbose);
joachim99@2 1093
joachim99@2 1094 $postEqual = $found;
joachim99@2 1095 $postEqual =~ s/[^=]*=//;
joachim99@2 1096
joachim99@2 1097 removeLine ($lookup, $found);
joachim99@2 1098
joachim99@2 1099 # Always find the header files that could be used to "moc"
joachim99@2 1100 return 1 if (findMocCandidates ());
joachim99@2 1101
joachim99@2 1102 if ($postEqual =~ /AUTO\s*(\S*)|USE_AUTOMOC\s*(\S*)/)
joachim99@2 1103 {
joachim99@2 1104 print STDERR "$printname: the argument for AUTO|USE_AUTOMOC is obsolete" if ($+);
joachim99@2 1105 $mocExt = ".moc.$cxxsuffix";
joachim99@2 1106 $haveAutomocTag = 1;
joachim99@2 1107 }
joachim99@2 1108 else
joachim99@2 1109 {
joachim99@2 1110 # Not automoc so read the list of files supplied which
joachim99@2 1111 # should be .moc files.
joachim99@2 1112
joachim99@2 1113 $postEqual =~ tr/\034/ /;
joachim99@2 1114
joachim99@2 1115 # prune out extra headers - This also checks to make sure that
joachim99@2 1116 # the list is valid.
joachim99@2 1117 pruneMocCandidates ($postEqual);
joachim99@2 1118 }
joachim99@2 1119
joachim99@2 1120 checkMocCandidates ();
joachim99@2 1121
joachim99@2 1122 if (@newObs) {
joachim99@2 1123 my $ext = ($program =~ /_la$/) ? ".moc.lo " : ".moc.o ";
joachim99@2 1124 $realObjs{$program} .= "\034" . join ($ext, @newObs) . $ext;
joachim99@14 1125 $dependmocs{$program} = join (".moc.$cxxsuffix " , @newObs) . ".moc.$cxxsuffix";
joachim99@2 1126 foreach $file (@newObs) {
joachim99@2 1127 $dep_files .= " \$(DEPDIR)/$file.moc.P" if($dep_files !~/$file.moc.P/);
joachim99@2 1128 }
joachim99@2 1129 }
joachim99@14 1130 if (@depend) {
joachim99@14 1131 $dependmocs{$program} .= " ";
joachim99@14 1132 $dependmocs{$program} .= join('.moc ', @depend) . ".moc";
joachim99@14 1133 $dependmocs{$program} .= " ";
joachim99@2 1134 }
joachim99@2 1135 addMocRules ();
joachim99@2 1136 @globalmocs{keys %mocFiles}=values %mocFiles;
joachim99@2 1137 }
joachim99@2 1138
joachim99@2 1139 #-----------------------------------------------------------------------------
joachim99@2 1140
joachim99@2 1141 # Returns 0 if the line was processed - 1 otherwise.
joachim99@2 1142 # Errors are logged in the global $errorflags
joachim99@2 1143 sub tag_AUTOMAKE ()
joachim99@2 1144 {
joachim99@14 1145 my $lookup = '.*cd \$\(top_srcdir\)\s+&&[\034\s]+\$\(AUTOMAKE\)(.*)';
joachim99@2 1146 return 1 if ($MakefileData !~ /\n($lookup)\n/);
joachim99@2 1147 print STDOUT "AUTOMAKE processing <$1>\n" if ($verbose);
joachim99@2 1148
joachim99@2 1149 my $newLine = $1."\n\tcd \$(top_srcdir) && perl $thisProg $printname";
joachim99@2 1150 substituteLine ($lookup, $newLine);
joachim99@2 1151 $automkCall = $1;
joachim99@14 1152
joachim99@14 1153 $lookup = '.*cd \$\(srcdir\)\s+&&[\034\s]+\$\(AUTOCONF\)(.*)';
joachim99@14 1154 if ($MakefileData =~ /\n($lookup)\n/) {
joachim99@66 1155 $newLine = "\tcd \$(srcdir) && rm -f configure\n";
joachim99@66 1156 $newLine .= "\tcd \$(top_srcdir) && \$(MAKE) -f admin/Makefile.common configure";
joachim99@14 1157 substituteLine ($lookup, $newLine);
joachim99@14 1158 }
joachim99@14 1159
joachim99@2 1160 return 0;
joachim99@2 1161 }
joachim99@2 1162
joachim99@2 1163 #-----------------------------------------------------------------------------
joachim99@2 1164
joachim99@2 1165 sub handle_TOPLEVEL()
joachim99@2 1166 {
joachim99@2 1167 my $pofiles = "";
joachim99@2 1168 my @restfiles = ();
joachim99@2 1169 opendir (THISDIR, ".");
joachim99@2 1170 foreach $entry (readdir(THISDIR)) {
joachim99@2 1171 next if (-d $entry);
joachim99@2 1172
joachim99@2 1173 next if ($entry eq "CVS" || $entry =~ /^\./ || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/ || $entry =~ /.gmo$/);
joachim99@2 1174
joachim99@2 1175 if ($entry =~ /\.po$/) {
joachim99@2 1176 next;
joachim99@2 1177 }
joachim99@2 1178 push(@restfiles, $entry);
joachim99@2 1179 }
joachim99@2 1180 closedir (THISDIR);
joachim99@2 1181
joachim99@2 1182 if (@restfiles) {
joachim99@2 1183 $target_adds{"install-data-am"} .= "install-nls-files ";
joachim99@2 1184 $lines = "install-nls-files:\n";
joachim99@2 1185 $lines .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_locale)/$kdelang\n";
joachim99@2 1186 for $file (@restfiles) {
joachim99@2 1187 $lines .= "\t\$(INSTALL_DATA) \$\(srcdir\)/$file \$(DESTDIR)\$(kde_locale)/$kdelang/$file\n";
joachim99@2 1188 }
joachim99@2 1189 $target_adds{"uninstall"} .= "uninstall-nls-files ";
joachim99@2 1190 $lines .= "uninstall-nls-files:\n";
joachim99@2 1191 for $file (@restfiles) {
joachim99@2 1192 $lines .= "\t-rm -f \$(DESTDIR)\$(kde_locale)/$kdelang/$file\n";
joachim99@2 1193 }
joachim99@2 1194 appendLines($lines);
joachim99@2 1195 }
joachim99@2 1196
joachim99@2 1197 return 0;
joachim99@2 1198 }
joachim99@2 1199
joachim99@2 1200 #-----------------------------------------------------------------------------
joachim99@2 1201
joachim99@2 1202 sub tag_SUBDIRS ()
joachim99@2 1203 {
joachim99@2 1204 if ($MakefileData !~ /\nSUBDIRS\s*=\s*\$\(AUTODIRS\)\s*\n/) {
joachim99@2 1205 return 1;
joachim99@2 1206 }
joachim99@2 1207
joachim99@2 1208 my $subdirs = ".";
joachim99@2 1209
joachim99@2 1210 opendir (THISDIR, ".");
joachim99@2 1211 foreach $entry (readdir(THISDIR)) {
joachim99@2 1212 next if ($entry eq "CVS" || $entry =~ /^\./);
joachim99@2 1213 if (-d $entry && -f $entry . "/Makefile.am") {
joachim99@2 1214 $subdirs .= " $entry";
joachim99@2 1215 next;
joachim99@2 1216 }
joachim99@2 1217 }
joachim99@2 1218 closedir (THISDIR);
joachim99@2 1219
joachim99@14 1220 substituteLine('SUBDIRS\s*=.*', "SUBDIRS =$subdirs");
joachim99@2 1221 return 0;
joachim99@2 1222 }
joachim99@2 1223
joachim99@2 1224 sub tag_IDLFILES ()
joachim99@2 1225 {
joachim99@2 1226 my @psources = split(/[\034\s]+/, $sources{$program});
joachim99@2 1227 my $dep_lines = "";
joachim99@2 1228 my @cppFiles = ();
joachim99@2 1229
joachim99@2 1230 foreach $source (@psources) {
joachim99@2 1231 my $skel = ($source =~ m/\.skel$/);
joachim99@2 1232 my $stub = ($source =~ m/\.stub$/);
joachim99@14 1233 my $signals = ($source =~ m/\.signals$/); # obsolete, remove in KDE-4
joachim99@2 1234
joachim99@2 1235 if ($stub || $skel || $signals) {
joachim99@14 1236
joachim99@2 1237 my $qs = quotemeta($source);
joachim99@2 1238 $sources{$program} =~ s/$qs//;
joachim99@2 1239 $sources_changed{$program} = 1;
joachim99@14 1240
joachim99@2 1241 $source =~ s/\.(stub|skel|signals)$//;
joachim99@2 1242 my $sourcename;
joachim99@14 1243
joachim99@2 1244 if ($skel) {
joachim99@2 1245 $sourcename = "$source\_skel";
joachim99@2 1246 } elsif ($stub) {
joachim99@2 1247 $sourcename = "$source\_stub";
joachim99@2 1248 } else {
joachim99@2 1249 $sourcename = "$source\_signals";
joachim99@2 1250 }
joachim99@2 1251
joachim99@2 1252 my $sourcedir = '';
joachim99@2 1253 if (-f "$makefileDir/$source.h") {
joachim99@2 1254 $sourcedir = '$(srcdir)/';
joachim99@2 1255 } else {
joachim99@2 1256 if ($MakefileData =~ /\n$source\_DIR\s*=\s*(\S+)\n/) {
joachim99@2 1257 $sourcedir = $1;
joachim99@2 1258 $sourcedir .= "/" if ($sourcedir !~ /\/$/);
joachim99@2 1259 }
joachim99@2 1260 }
joachim99@2 1261
joachim99@2 1262 if ($allidls !~ /$source\_kidl/) {
joachim99@2 1263
joachim99@66 1264 $use_ng = ($MakefileData =~ /\n$source\_DCOPIDLNG\s*=\s*(\S+)\n/);
joachim99@66 1265 $dcopidl = $use_ng ? "\$(DCOPIDLNG)" : "\$(DCOPIDL)";
joachim99@66 1266
joachim99@14 1267 $dep_lines .= "$source.kidl: $sourcedir$source.h \$(DCOP_DEPENDENCIES)\n";
joachim99@66 1268 $dep_lines .= "\t$dcopidl $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; false )\n";
joachim99@2 1269
joachim99@2 1270 $allidls .= $source . "_kidl ";
joachim99@2 1271 }
joachim99@2 1272
joachim99@2 1273 if ($allidls !~ /$sourcename/) {
joachim99@2 1274
joachim99@2 1275 $dep_lines_tmp = "";
joachim99@2 1276
joachim99@2 1277 if ($skel) {
joachim99@2 1278 $dep_lines .= "$sourcename.$cxxsuffix: $source.kidl\n";
joachim99@2 1279 $dep_lines .= "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-signals --no-stub $source.kidl\n";
joachim99@2 1280 } elsif ($stub) {
joachim99@2 1281 $dep_lines_tmp = "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-signals --no-skel $source.kidl\n";
joachim99@14 1282 } else { # signals - obsolete, remove in KDE 4
joachim99@2 1283 $dep_lines_tmp = "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-stub --no-skel $source.kidl\n";
joachim99@2 1284 }
joachim99@2 1285
joachim99@2 1286 if ($stub || $signals) {
joachim99@2 1287 $target_adds{"$sourcename.$cxxsuffix"} .= "$sourcename.h ";
joachim99@2 1288 $dep_lines .= "$sourcename.h: $source.kidl\n";
joachim99@2 1289 $dep_lines .= $dep_lines_tmp;
joachim99@2 1290 }
joachim99@2 1291
joachim99@2 1292 $allidls .= $sourcename . " ";
joachim99@2 1293 }
joachim99@2 1294
joachim99@2 1295 $idlfiles{$program} .= $sourcename . " ";
joachim99@2 1296
joachim99@2 1297 if ($program =~ /_la$/) {
joachim99@2 1298 $realObjs{$program} .= " $sourcename.lo";
joachim99@2 1299 } else {
joachim99@2 1300 $realObjs{$program} .= " $sourcename.\$(OBJEXT)";
joachim99@2 1301 }
joachim99@2 1302 $sources{$program} .= " $sourcename.$cxxsuffix";
joachim99@2 1303 $sources_changed{$program} = 1;
joachim99@2 1304 $important{$program} .= "$sourcename.h " if (!$skel);
joachim99@2 1305 $idl_output .= "\\\n\t$sourcename.$cxxsuffix $sourcename.h $source.kidl ";
joachim99@2 1306 push(@cleanfiles, "$sourcename.$cxxsuffix");
joachim99@2 1307 push(@cleanfiles, "$sourcename.h");
joachim99@2 1308 push(@cleanfiles, "$sourcename.kidl");
joachim99@2 1309 $dep_files .= " \$(DEPDIR)/$sourcename.P" if ($dep_files !~/$sourcename.P/);
joachim99@2 1310 }
joachim99@2 1311 }
joachim99@2 1312 if ($dep_lines) {
joachim99@2 1313 appendLines($dep_lines);
joachim99@2 1314 }
joachim99@2 1315
joachim99@2 1316 if (0) {
joachim99@2 1317 my $lookup = "($program)";
joachim99@2 1318 $lookup .= '(|\$\(EXEEXT\))';
joachim99@2 1319 $lookup =~ s/\_/./g;
joachim99@2 1320 $lookup .= ":(.*..$program\_OBJECTS..*)";
joachim99@2 1321 # $lookup = quotemeta($lookup);
joachim99@2 1322 if ($MakefileData =~ /\n$lookup\n/) {
joachim99@2 1323
joachim99@2 1324 my $line = "$1$2: ";
joachim99@2 1325 foreach $file (split(' ', $idlfiles{$program})) {
joachim99@2 1326 $line .= "$file.$cxxsuffix ";
joachim99@2 1327 }
joachim99@2 1328 $line .= $3;
joachim99@2 1329 substituteLine($lookup, $line);
joachim99@2 1330 } else {
joachim99@2 1331 print STDERR "no built dependency found $lookup\n";
joachim99@2 1332 }
joachim99@2 1333 }
joachim99@2 1334 }
joachim99@2 1335
joachim99@2 1336 sub tag_UIFILES ()
joachim99@2 1337 {
joachim99@2 1338 my @psources = split(/[\034\s]+/, $sources{$program});
joachim99@2 1339 my @depFiles = ();
joachim99@2 1340
joachim99@2 1341 foreach $source (@psources) {
joachim99@2 1342
joachim99@2 1343 if ($source =~ m/\.ui$/) {
joachim99@2 1344
joachim99@2 1345 print STDERR "adding UI file $source\n" if ($verbose);
joachim99@2 1346
joachim99@2 1347 my $qs = quotemeta($source);
joachim99@2 1348 $sources{$program} =~ s/$qs//;
joachim99@2 1349 $sources_changed{$program} = 1;
joachim99@2 1350
joachim99@2 1351 $source =~ s/\.ui$//;
joachim99@2 1352
joachim99@2 1353 my $sourcedir = '';
joachim99@2 1354 if (-f "$makefileDir/$source.ui") {
joachim99@2 1355 $sourcedir = '$(srcdir)/';
joachim99@2 1356 }
joachim99@2 1357
joachim99@2 1358 if (!$uiFiles{$source}) {
joachim99@2 1359
joachim99@14 1360 my $dep_lines = "$source.$cxxsuffix: $sourcedir$source.ui $source.h $source.moc\n";
joachim99@2 1361 $dep_lines .= "\trm -f $source.$cxxsuffix\n";
joachim99@2 1362 if (!$kdeopts{"qtonly"}) {
joachim99@66 1363 $dep_lines .= "\techo '#include <kdialog.h>' > $source.$cxxsuffix\n";
joachim99@66 1364 $dep_lines .= "\techo '#include <klocale.h>' >> $source.$cxxsuffix\n";
joachim99@14 1365 my ($mangled_source) = $source;
joachim99@14 1366 $mangled_source =~ s/[^A-Za-z0-9]/_/g; # get rid of garbage
joachim99@14 1367 $dep_lines .= "\t\$(UIC) -tr \${UIC_TR} -i $source.h $sourcedir$source.ui > $source.$cxxsuffix.temp ; ret=\$\$?; \\\n";
joachim99@66 1368 $dep_lines .= "\t\$(PERL) -pe \"s,\${UIC_TR}( \\\"\\\" ),QString::null,g\" $source.$cxxsuffix.temp | \$(PERL) -pe \"s,\${UIC_TR}( \\\"\\\"\\, \\\"\\\" ),QString::null,g\" | \$(PERL) -pe \"s,image([0-9][0-9]*)_data,img\\\$\$1_" . $mangled_source . ",g\" >> $source.$cxxsuffix ;\\\n";
joachim99@14 1369 $dep_lines .= "\trm -f $source.$cxxsuffix.temp ;\\\n";
joachim99@2 1370 } else {
joachim99@14 1371 $dep_lines .= "\t\$(UIC) -i $source.h $sourcedir$source.ui > $source.$cxxsuffix; ret=\$\$?; \\\n";
joachim99@2 1372 }
joachim99@14 1373 $dep_lines .= "\tif test \"\$\$ret\" = 0; then echo '#include \"$source.moc\"' >> $source.$cxxsuffix; else rm -f $source.$cxxsuffix ; exit \$\$ret ; fi\n\n";
joachim99@2 1374 $dep_lines .= "$source.h: $sourcedir$source.ui\n";
joachim99@2 1375 $dep_lines .= "\t\$(UIC) -o $source.h $sourcedir$source.ui\n\n";
joachim99@2 1376 $dep_lines .= "$source.moc: $source.h\n";
joachim99@2 1377 $dep_lines .= "\t\$(MOC) $source.h -o $source.moc\n";
joachim99@2 1378
joachim99@14 1379 $rule_adds{"$source.$cxxsuffix"} = $dep_lines;
joachim99@14 1380
joachim99@2 1381 $uiFiles{$source} = 1;
joachim99@14 1382 $dependmocs{$program} .= " $source.moc";
joachim99@2 1383 $globalmocs{$source} = "\035$source.h\035$source.cpp";
joachim99@2 1384 }
joachim99@2 1385
joachim99@2 1386 if ($program =~ /_la$/) {
joachim99@2 1387 $realObjs{$program} .= " $source.lo";
joachim99@2 1388 } else {
joachim99@2 1389 $realObjs{$program} .= " $source.\$(OBJEXT)";
joachim99@2 1390 }
joachim99@2 1391 $sources{$program} .= " $source.$cxxsuffix";
joachim99@2 1392 $sources_changed{$program} = 1;
joachim99@2 1393 $important{$program} .= "$source.h ";
joachim99@2 1394 $ui_output .= "\\\n\t$source.$cxxsuffix $source.h $source.moc ";
joachim99@2 1395 push(@cleanfiles, "$source.$cxxsuffix");
joachim99@66 1396 push(@cleanfiles, "$source.h");
joachim99@2 1397 push(@cleanfiles, "$source.moc");
joachim99@2 1398 $dep_files .= " \$(DEPDIR)/$source.P" if($dep_files !~/$source.P/ );
joachim99@2 1399 }
joachim99@2 1400 }
joachim99@2 1401 }
joachim99@2 1402
joachim99@66 1403 sub tag_KCFGFILES ()
joachim99@66 1404 {
joachim99@66 1405 my @psources = split(/[\034\s]+/, $sources{$program});
joachim99@66 1406 my @depFiles = ();
joachim99@66 1407
joachim99@66 1408 foreach $source (@psources) {
joachim99@66 1409
joachim99@66 1410 if ($source =~ m/\.kcfgc$/) {
joachim99@66 1411
joachim99@66 1412 print STDERR "adding KCFG file $source\n" if ($verbose);
joachim99@66 1413
joachim99@66 1414 my $qs = quotemeta($source);
joachim99@66 1415 $sources{$program} =~ s/$qs//;
joachim99@66 1416 $sources_changed{$program} = 1;
joachim99@66 1417
joachim99@66 1418 $source =~ s/\.kcfgc$//;
joachim99@66 1419
joachim99@66 1420 my $sourcedir = '';
joachim99@66 1421 if (-f "$makefileDir/$source.kcfgc") {
joachim99@66 1422 $sourcedir = '$(srcdir)/';
joachim99@66 1423 }
joachim99@66 1424
joachim99@66 1425 if (!$kcfgFiles{$source}) {
joachim99@66 1426 $kcfg = "$program.kcfg";
joachim99@66 1427 findKcfgFile("$source.kcfgc");
joachim99@66 1428
joachim99@66 1429 my $fixsuffix = "";
joachim99@66 1430 $fixsuffix = "else mv $source.cpp $source.$cxxsuffix ; "
joachim99@66 1431 unless "cpp" eq $cxxsuffix;
joachim99@66 1432
joachim99@66 1433 my $dep_lines = "$source.$cxxsuffix: $source.h\n";
joachim99@66 1434 $dep_lines .= "$source.h: $sourcedir$kcfg $sourcedir$source.kcfgc \$(KCFG_DEPENDENCIES)\n";
joachim99@66 1435 $dep_lines .= "\t\$(KCONFIG_COMPILER) $sourcedir$kcfg $sourcedir$source.kcfgc; ret=\$\$?; \\\n";
joachim99@66 1436 $dep_lines .= "\tif test \"\$\$ret\" != 0; then rm -f $source.h ; exit \$\$ret ; $fixsuffix fi\n\n";
joachim99@66 1437
joachim99@66 1438 $rule_adds{"$source.$cxxsuffix"} = $dep_lines;
joachim99@66 1439
joachim99@66 1440 $kcfgFiles{$source} = 1;
joachim99@66 1441 }
joachim99@66 1442
joachim99@66 1443 if ($program =~ /_la$/) {
joachim99@66 1444 $realObjs{$program} .= " $source.lo";
joachim99@66 1445 } else {
joachim99@66 1446 $realObjs{$program} .= " $source.\$(OBJEXT)";
joachim99@66 1447 }
joachim99@66 1448 $sources{$program} .= " $source.$cxxsuffix";
joachim99@66 1449 $sources_changed{$program} = 1;
joachim99@66 1450 $important{$program} .= "$source.h ";
joachim99@66 1451 $kcfg_output .= "\\\n\t$source.$cxxsuffix $source.h ";
joachim99@66 1452 push(@cleanfiles, "$source.$cxxsuffix");
joachim99@66 1453 push(@cleanfiles, "$source.h");
joachim99@66 1454 $dep_files .= " \$(DEPDIR)/$source.P" if($dep_files !~/$source.P/ );
joachim99@66 1455 }
joachim99@66 1456 }
joachim99@66 1457 }
joachim99@66 1458
joachim99@2 1459 sub tag_ICON()
joachim99@2 1460 {
joachim99@14 1461 my $lookup = '([^\s]*)_ICON\s*=[ \t]*(.*)';
joachim99@2 1462 my $install = "";
joachim99@2 1463 my $uninstall = "";
joachim99@2 1464
joachim99@14 1465 while ($MakefileData =~ /\n$lookup/g) {
joachim99@2 1466 my $destdir;
joachim99@2 1467 if ($1 eq "KDE") {
joachim99@2 1468 $destdir = "kde_icondir";
joachim99@2 1469 } else {
joachim99@2 1470 $destdir = $1 . "dir";
joachim99@2 1471 }
joachim99@2 1472 my $iconauto = ($2 =~ /AUTO\s*$/);
joachim99@2 1473 my @appnames = ();
joachim99@2 1474 if ( ! $iconauto ) {
joachim99@14 1475 my $appicon_str = $2;
joachim99@14 1476 my @_appnames = split(" ", $appicon_str);
joachim99@2 1477 print STDOUT "KDE_ICON processing <@_appnames>\n" if ($verbose);
joachim99@2 1478 foreach $appname (@_appnames) {
joachim99@2 1479 push(@appnames, quotemeta($appname));
joachim99@2 1480 }
joachim99@2 1481 } else {
joachim99@2 1482 print STDOUT "KDE_ICON processing <AUTO>\n" if ($verbose);
joachim99@2 1483 }
joachim99@2 1484
joachim99@2 1485 my @files = ();
joachim99@2 1486 opendir (THISDIR, ".");
joachim99@2 1487 foreach $entry (readdir(THISDIR)) {
joachim99@2 1488 next if ($entry eq "CVS" || $entry =~ /^\./ || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/);
joachim99@2 1489 next if (! -f $entry);
joachim99@2 1490 if ( $iconauto )
joachim99@2 1491 {
joachim99@2 1492 push(@files, $entry)
joachim99@14 1493 if ($entry =~ /\.xpm/ || $entry =~ /\.png/ || $entry =~ /\.mng/ || $entry =~ /\.svg/);
joachim99@2 1494 } else {
joachim99@2 1495 foreach $appname (@appnames) {
joachim99@2 1496 push(@files, $entry)
joachim99@14 1497 if ($entry =~ /-$appname\.xpm/ || $entry =~ /-$appname\.png/ || $entry =~ /-$appname\.mng/ || $entry =~ /-$appname\.svg/);
joachim99@2 1498 }
joachim99@2 1499 }
joachim99@2 1500 }
joachim99@2 1501 closedir (THISDIR);
joachim99@2 1502
joachim99@2 1503 my %directories = ();
joachim99@2 1504
joachim99@2 1505 foreach $file (@files) {
joachim99@2 1506 my $newfile = $file;
joachim99@2 1507 my $prefix = $file;
joachim99@14 1508 $prefix =~ s/\.(png|xpm|mng|svg|svgz)$//;
joachim99@2 1509 my $appname = $prefix;
joachim99@2 1510 $appname =~ s/^[^-]+-// if ($appname =~ /-/) ;
joachim99@2 1511 $appname =~ s/^[^-]+-// if ($appname =~ /-/) ;
joachim99@2 1512 $appname = quotemeta($appname);
joachim99@2 1513 $prefix =~ s/$appname$//;
joachim99@2 1514 $prefix =~ s/-$//;
joachim99@2 1515
joachim99@2 1516 $prefix = 'lo16-app' if ($prefix eq 'mini');
joachim99@2 1517 $prefix = 'lo32-app' if ($prefix eq 'lo');
joachim99@2 1518 $prefix = 'hi48-app' if ($prefix eq 'large');
joachim99@2 1519 $prefix .= '-app' if ($prefix =~ m/^...$/);
joachim99@2 1520
joachim99@2 1521 my $type = $prefix;
joachim99@2 1522 $type =~ s/^.*-([^-]+)$/$1/;
joachim99@2 1523 $prefix =~ s/^(.*)-[^-]+$/$1/;
joachim99@2 1524
joachim99@2 1525 my %type_hash =
joachim99@2 1526 (
joachim99@2 1527 'action' => 'actions',
joachim99@2 1528 'app' => 'apps',
joachim99@2 1529 'device' => 'devices',
joachim99@2 1530 'filesys' => 'filesystems',
joachim99@2 1531 'mime' => 'mimetypes'
joachim99@2 1532 );
joachim99@14 1533
joachim99@2 1534 if (! defined $type_hash{$type} ) {
joachim99@2 1535 print STDERR "unknown icon type $type in $printname ($file)\n";
joachim99@2 1536 next;
joachim99@2 1537 }
joachim99@14 1538
joachim99@2 1539 my %dir_hash =
joachim99@2 1540 (
joachim99@2 1541 'los' => 'locolor/16x16',
joachim99@2 1542 'lom' => 'locolor/32x32',
joachim99@2 1543 'him' => 'hicolor/32x32',
joachim99@2 1544 'hil' => 'hicolor/48x48',
joachim99@2 1545 'lo16' => 'locolor/16x16',
joachim99@2 1546 'lo22' => 'locolor/22x22',
joachim99@2 1547 'lo32' => 'locolor/32x32',
joachim99@2 1548 'hi16' => 'hicolor/16x16',
joachim99@2 1549 'hi22' => 'hicolor/22x22',
joachim99@2 1550 'hi32' => 'hicolor/32x32',
joachim99@2 1551 'hi48' => 'hicolor/48x48',
joachim99@2 1552 'hi64' => 'hicolor/64x64',
joachim99@14 1553 'hi128' => 'hicolor/128x128',
joachim99@14 1554 'hisc' => 'hicolor/scalable',
joachim99@14 1555 'cr16' => 'crystalsvg/16x16',
joachim99@14 1556 'cr22' => 'crystalsvg/22x22',
joachim99@14 1557 'cr32' => 'crystalsvg/32x32',
joachim99@14 1558 'cr48' => 'crystalsvg/48x48',
joachim99@14 1559 'cr64' => 'crystalsvg/64x64',
joachim99@14 1560 'cr128' => 'crystalsvg/128x128',
joachim99@14 1561 'crsc' => 'crystalsvg/scalable'
joachim99@2 1562 );
joachim99@2 1563
joachim99@14 1564 $newfile =~ s@.*-($appname\.(png|xpm|mng|svgz|svg?))@$1@;
joachim99@2 1565
joachim99@2 1566 if (! defined $dir_hash{$prefix}) {
joachim99@2 1567 print STDERR "unknown icon prefix $prefix in $printname\n";
joachim99@2 1568 next;
joachim99@2 1569 }
joachim99@2 1570
joachim99@2 1571 my $dir = $dir_hash{$prefix} . "/" . $type_hash{$type};
joachim99@2 1572 if ($newfile =~ /-[^\.]/) {
joachim99@2 1573 my $tmp = $newfile;
joachim99@2 1574 $tmp =~ s/^([^-]+)-.*$/$1/;
joachim99@2 1575 $dir = $dir . "/" . $tmp;
joachim99@2 1576 $newfile =~ s/^[^-]+-//;
joachim99@2 1577 }
joachim99@2 1578
joachim99@2 1579 if (!defined $directories{$dir}) {
joachim99@2 1580 $install .= "\t\$(mkinstalldirs) \$(DESTDIR)\$($destdir)/$dir\n";
joachim99@2 1581 $directories{$dir} = 1;
joachim99@2 1582 }
joachim99@2 1583
joachim99@2 1584 $install .= "\t\$(INSTALL_DATA) \$(srcdir)/$file \$(DESTDIR)\$($destdir)/$dir/$newfile\n";
joachim99@2 1585 $uninstall .= "\t-rm -f \$(DESTDIR)\$($destdir)/$dir/$newfile\n";
joachim99@2 1586
joachim99@2 1587 }
joachim99@2 1588 }
joachim99@2 1589
joachim99@2 1590 if (length($install)) {
joachim99@2 1591 $target_adds{"install-data-am"} .= "install-kde-icons ";
joachim99@2 1592 $target_adds{"uninstall-am"} .= "uninstall-kde-icons ";
joachim99@2 1593 appendLines("install-kde-icons:\n" . $install . "\nuninstall-kde-icons:\n" . $uninstall);
joachim99@2 1594 }
joachim99@2 1595 }
joachim99@2 1596
joachim99@2 1597 sub handle_POFILES($$)
joachim99@2 1598 {
joachim99@2 1599 my @pofiles = split(" ", $_[0]);
joachim99@2 1600 my $lang = $_[1];
joachim99@2 1601
joachim99@2 1602 # Build rules for creating the gmo files
joachim99@2 1603 my $tmp = "";
joachim99@2 1604 my $allgmofiles = "";
joachim99@2 1605 my $pofileLine = "POFILES =";
joachim99@2 1606 foreach $pofile (@pofiles)
joachim99@2 1607 {
joachim99@2 1608 $pofile =~ /(.*)\.[^\.]*$/; # Find name minus extension
joachim99@2 1609 $tmp .= "$1.gmo: $pofile\n";
joachim99@2 1610 $tmp .= "\trm -f $1.gmo; \$(GMSGFMT) -o $1.gmo \$(srcdir)/$pofile\n";
joachim99@2 1611 $tmp .= "\ttest ! -f $1.gmo || touch $1.gmo\n";
joachim99@2 1612 $allgmofiles .= " $1.gmo";
joachim99@2 1613 $pofileLine .= " $1.po";
joachim99@2 1614 }
joachim99@2 1615 appendLines ($tmp);
joachim99@2 1616 my $lookup = 'POFILES\s*=([^\n]*)';
joachim99@14 1617 if ($MakefileData !~ /\n$lookup/) {
joachim99@2 1618 appendLines("$pofileLine\nGMOFILES =$allgmofiles");
joachim99@2 1619 } else {
joachim99@2 1620 substituteLine ($lookup, "$pofileLine\nGMOFILES =$allgmofiles");
joachim99@2 1621 }
joachim99@2 1622
joachim99@2 1623 if ($allgmofiles) {
joachim99@2 1624
joachim99@2 1625 # Add the "clean" rule so that the maintainer-clean does something
joachim99@2 1626 appendLines ("clean-nls:\n\t-rm -f $allgmofiles\n");
joachim99@2 1627
joachim99@2 1628 $target_adds{"maintainer-clean"} .= "clean-nls ";
joachim99@2 1629
joachim99@14 1630 $lookup = 'DISTFILES\s*=[ \t]*(.*)';
joachim99@14 1631 if ($MakefileData =~ /\n$lookup/) {
joachim99@2 1632 $tmp = "DISTFILES = \$(GMOFILES) \$(POFILES) $1";
joachim99@2 1633 substituteLine ($lookup, $tmp);
joachim99@2 1634 }
joachim99@2 1635 }
joachim99@2 1636
joachim99@2 1637 $target_adds{"install-data-am"} .= "install-nls ";
joachim99@2 1638
joachim99@2 1639 $tmp = "install-nls:\n";
joachim99@2 1640 if ($lang) {
joachim99@2 1641 $tmp .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES\n";
joachim99@2 1642 }
joachim99@2 1643 $tmp .= "\t\@for base in ";
joachim99@2 1644 foreach $pofile (@pofiles)
joachim99@2 1645 {
joachim99@2 1646 $pofile =~ /(.*)\.[^\.]*$/; # Find name minus extension
joachim99@2 1647 $tmp .= "$1 ";
joachim99@2 1648 }
joachim99@2 1649
joachim99@2 1650 $tmp .= "; do \\\n";
joachim99@2 1651 if ($lang) {
joachim99@2 1652 $tmp .= "\t echo \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n";
joachim99@14 1653 $tmp .= "\t if test -f \$\$base.gmo; then \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n";
joachim99@14 1654 $tmp .= "\t elif test -f \$(srcdir)/\$\$base.gmo; then \$(INSTALL_DATA) \$(srcdir)/\$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n";
joachim99@14 1655 $tmp .= "\t fi ;\\\n";
joachim99@2 1656 } else {
joachim99@2 1657 $tmp .= "\t echo \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n";
joachim99@2 1658 $tmp .= "\t \$(mkinstalldirs) \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES ; \\\n";
joachim99@14 1659 $tmp .= "\t if test -f \$\$base.gmo; then \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n";
joachim99@14 1660 $tmp .= "\t elif test -f \$(srcdir)/\$\$base.gmo; then \$(INSTALL_DATA) \$(srcdir)/\$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n";
joachim99@14 1661 $tmp .= "\t fi ;\\\n";
joachim99@2 1662 }
joachim99@2 1663 $tmp .= "\tdone\n\n";
joachim99@2 1664 appendLines ($tmp);
joachim99@2 1665
joachim99@2 1666 $target_adds{"uninstall"} .= "uninstall-nls ";
joachim99@2 1667
joachim99@2 1668 $tmp = "uninstall-nls:\n";
joachim99@2 1669 foreach $pofile (@pofiles)
joachim99@2 1670 {
joachim99@2 1671 $pofile =~ /(.*)\.[^\.]*$/; # Find name minus extension
joachim99@2 1672 if ($lang) {
joachim99@2 1673 $tmp .= "\trm -f \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/$1.mo\n";
joachim99@2 1674 } else {
joachim99@2 1675 $tmp .= "\trm -f \$(DESTDIR)\$(kde_locale)/$1/LC_MESSAGES/\$(PACKAGE).mo\n";
joachim99@2 1676 }
joachim99@2 1677 }
joachim99@2 1678 appendLines($tmp);
joachim99@2 1679
joachim99@2 1680 $target_adds{"all"} .= "all-nls ";
joachim99@2 1681
joachim99@2 1682 $tmp = "all-nls: \$(GMOFILES)\n";
joachim99@2 1683
joachim99@2 1684 appendLines($tmp);
joachim99@2 1685
joachim99@2 1686 $target_adds{"distdir"} .= "distdir-nls ";
joachim99@2 1687
joachim99@2 1688 $tmp = "distdir-nls:\$(GMOFILES)\n";
joachim99@2 1689 $tmp .= "\tfor file in \$(POFILES); do \\\n";
joachim99@2 1690 $tmp .= "\t cp \$(srcdir)/\$\$file \$(distdir); \\\n";
joachim99@2 1691 $tmp .= "\tdone\n";
joachim99@2 1692 $tmp .= "\tfor file in \$(GMOFILES); do \\\n";
joachim99@2 1693 $tmp .= "\t cp \$(srcdir)/\$\$file \$(distdir); \\\n";
joachim99@2 1694 $tmp .= "\tdone\n";
joachim99@2 1695
joachim99@2 1696 appendLines ($tmp);
joachim99@2 1697
joachim99@2 1698 if (!$lang) {
joachim99@2 1699 appendLines("merge:\n\t\$(MAKE) -f \$(top_srcdir)/admin/Makefile.common package-merge POFILES=\"\${POFILES}\" PACKAGE=\${PACKAGE}\n\n");
joachim99@2 1700 }
joachim99@2 1701
joachim99@2 1702 }
joachim99@2 1703
joachim99@2 1704 #-----------------------------------------------------------------------------
joachim99@2 1705
joachim99@2 1706 # Returns 0 if the line was processed - 1 otherwise.
joachim99@2 1707 # Errors are logged in the global $errorflags
joachim99@2 1708 sub tag_POFILES ()
joachim99@2 1709 {
joachim99@2 1710 my $lookup = 'POFILES\s*=([^\n]*)';
joachim99@14 1711 return 1 if ($MakefileData !~ /\n$lookup/);
joachim99@2 1712 print STDOUT "POFILES processing <$1>\n" if ($verbose);
joachim99@2 1713
joachim99@2 1714 my $tmp = $1;
joachim99@2 1715
joachim99@2 1716 # make sure these are all gone.
joachim99@2 1717 if ($MakefileData =~ /\n\.po\.gmo:\n/)
joachim99@2 1718 {
joachim99@2 1719 print STDERR "Warning: Found old .po.gmo rules in $printname. New po rules not added\n";
joachim99@2 1720 return 1;
joachim99@2 1721 }
joachim99@2 1722
joachim99@2 1723 # Either find the pofiles in the directory (AUTO) or use
joachim99@2 1724 # only the specified po files.
joachim99@2 1725 my $pofiles = "";
joachim99@2 1726 if ($tmp =~ /^\s*AUTO\s*$/)
joachim99@2 1727 {
joachim99@2 1728 opendir (THISDIR, ".");
joachim99@2 1729 $pofiles = join(" ", grep(/\.po$/, readdir(THISDIR)));
joachim99@2 1730 closedir (THISDIR);
joachim99@2 1731 print STDOUT "pofiles found = $pofiles\n" if ($verbose);
joachim99@66 1732 if (-f "charset" && -f "kdelibs/kdelibs.po") {
joachim99@2 1733 handle_TOPLEVEL();
joachim99@2 1734 }
joachim99@2 1735 }
joachim99@2 1736 else
joachim99@2 1737 {
joachim99@2 1738 $tmp =~ s/\034/ /g;
joachim99@2 1739 $pofiles = $tmp;
joachim99@2 1740 }
joachim99@2 1741 return 1 if (!$pofiles); # Nothing to do
joachim99@2 1742
joachim99@2 1743 handle_POFILES($pofiles, $kdelang);
joachim99@2 1744
joachim99@2 1745 return 0;
joachim99@2 1746 }
joachim99@2 1747
joachim99@2 1748 sub helper_LOCALINSTALL($)
joachim99@2 1749 {
joachim99@14 1750 my $lookup = "\035" . $_[0] . " *:[^\035]*\035\t";
joachim99@14 1751 my $copy = $MakefileData;
joachim99@14 1752 $copy =~ s/\n/\035/g;
joachim99@14 1753 if ($copy =~ /($lookup.*)$/) {
joachim99@2 1754
joachim99@14 1755 $install = $1;
joachim99@14 1756 $install =~ s/\035$_[0] *:[^\035]*\035//;
joachim99@2 1757 my $emptyline = 0;
joachim99@14 1758 while (! $emptyline ) {
joachim99@2 1759 if ($install =~ /([^\035]*)\035(.*)/) {
joachim99@2 1760 local $line = $1;
joachim99@2 1761 $install = $2;
joachim99@2 1762 if ($line !~ /^\s*$/ && $line !~ /^(\@.*\@)*\t/) {
joachim99@2 1763 $emptyline = 1;
joachim99@2 1764 } else {
joachim99@2 1765 replaceDestDir($line);
joachim99@2 1766 }
joachim99@2 1767 } else {
joachim99@2 1768 $emptyline = 1;
joachim99@2 1769 }
joachim99@2 1770 }
joachim99@2 1771 }
joachim99@2 1772
joachim99@2 1773 }
joachim99@2 1774
joachim99@2 1775 sub tag_LOCALINSTALL ()
joachim99@2 1776 {
joachim99@2 1777 helper_LOCALINSTALL('install-exec-local');
joachim99@2 1778 helper_LOCALINSTALL('install-data-local');
joachim99@2 1779 helper_LOCALINSTALL('uninstall-local');
joachim99@2 1780
joachim99@2 1781 return 0;
joachim99@2 1782 }
joachim99@2 1783
joachim99@2 1784 sub replaceDestDir($) {
joachim99@2 1785 local $line = $_[0];
joachim99@2 1786
joachim99@2 1787 if ( $line =~ /^\s*(\@.*\@)*\s*\$\(mkinstalldirs\)/
joachim99@2 1788 || $line =~ /^\s*(\@.*\@)*\s*\$\(INSTALL\S*\)/
joachim99@2 1789 || $line =~ /^\s*(\@.*\@)*\s*(-?rm.*) \S*$/)
joachim99@2 1790 {
joachim99@2 1791 $line =~ s/^(.*) ([^\s]+)\s*$/$1 \$(DESTDIR)$2/ if ($line !~ /\$\(DESTDIR\)/);
joachim99@2 1792 }
joachim99@2 1793
joachim99@2 1794 if ($line ne $_[0]) {
joachim99@2 1795 $_[0] = quotemeta $_[0];
joachim99@2 1796 substituteLine($_[0], $line);
joachim99@2 1797 }
joachim99@2 1798 }
joachim99@2 1799
joachim99@2 1800 #---------------------------------------------------------------------------
joachim99@14 1801 # libtool is very hard to persuade it could use -Wl,--no-undefined for making
joachim99@14 1802 # -no-undefined actually work
joachim99@14 1803 # append $(KDE_NO_UNFINED) after every -no-undefined in LDFLAGS
joachim99@14 1804 # this may go away if libtool ever does this on its own
joachim99@14 1805 sub tag_NO_UNDEFINED () {
joachim99@14 1806 return if ($program !~ /_la$/);
joachim99@14 1807
joachim99@14 1808 my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n";
joachim99@14 1809 $MakefileData =~ m/$lookup/;
joachim99@14 1810 return if (!defined($1));
joachim99@14 1811 return if ($1 !~ /CXXLINK/);
joachim99@14 1812
joachim99@14 1813 if ($MakefileData !~ /\n$program\_LDFLAGS\s*=.*-no-undefined/ ) {
joachim99@14 1814 return;
joachim99@14 1815 }
joachim99@14 1816
joachim99@14 1817 $lookup = $program . '\_LDFLAGS(\s*)=(.*)-no-undefined(.*)';
joachim99@14 1818 if ($MakefileData =~ /\n$lookup\n/) {
joachim99@14 1819 my $replace = $program . "\_LDFLAGS$1=$2-no-undefined \$(KDE_NO_UNDEFINED)$3";
joachim99@14 1820 substituteLine($lookup, $replace);
joachim99@14 1821 }
joachim99@14 1822 }
joachim99@14 1823
joachim99@2 1824 sub tag_CLOSURE () {
joachim99@2 1825 return if ($program !~ /_la$/);
joachim99@14 1826
joachim99@2 1827 my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n";
joachim99@2 1828 $MakefileData =~ m/$lookup/;
joachim99@14 1829 return if (!defined($1));
joachim99@2 1830 return if ($1 !~ /CXXLINK/);
joachim99@2 1831
joachim99@2 1832 if ($MakefileData !~ /\n$program\_LDFLAGS\s*=.*-no-undefined/ &&
joachim99@2 1833 $MakefileData !~ /\n$program\_LDFLAGS\s*=.*KDE_PLUGIN/ ) {
joachim99@2 1834 print STDERR "Report: $program contains undefined in $printname\n" if ($program =~ /^lib/ && $dryrun);
joachim99@2 1835 return;
joachim99@2 1836 }
joachim99@14 1837
joachim99@2 1838 my $closure = $realname{$program} . ".closure";
joachim99@2 1839 my $lines = "$closure: \$($program\_OBJECTS) \$($program\_DEPENDENCIES)\n";
joachim99@2 1840 $lines .= "\t\@echo \"int main() {return 0;}\" > $program\_closure.$cxxsuffix\n";
joachim99@2 1841 $lines .= "\t\@\$\(LTCXXCOMPILE\) -c $program\_closure.$cxxsuffix\n";
joachim99@2 1842 $lines .= "\t\$\(CXXLINK\) $program\_closure.lo \$($program\_LDFLAGS) \$($program\_OBJECTS) \$($program\_LIBADD) \$(LIBS)\n";
joachim99@2 1843 $lines .= "\t\@rm -f $program\_closure.* $closure\n";
joachim99@2 1844 $lines .= "\t\@echo \"timestamp\" > $closure\n";
joachim99@2 1845 $lines .= "\n";
joachim99@2 1846 appendLines($lines);
joachim99@2 1847 $lookup = $realname{$program} . ": (.*)";
joachim99@2 1848 if ($MakefileData =~ /\n$lookup\n/) {
joachim99@2 1849 $lines = "\@KDE_USE_CLOSURE_TRUE@". $realname{$program} . ": $closure $1";
joachim99@2 1850 $lines .= "\n\@KDE_USE_CLOSURE_FALSE@" . $realname{$program} . ": $1";
joachim99@2 1851 substituteLine($lookup, $lines);
joachim99@2 1852 }
joachim99@2 1853 $closure_output .= " $closure";
joachim99@2 1854 }
joachim99@2 1855
joachim99@14 1856 sub tag_NMCHECK () {
joachim99@14 1857 return if ($program !~ /_la$/);
joachim99@14 1858 my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n";
joachim99@14 1859 $MakefileData =~ m/$lookup/;
joachim99@14 1860 my $linkcmd = $1;
joachim99@14 1861 return if (!defined($1));
joachim99@14 1862 return if ($linkcmd !~ /CXXLINK/ && $linkcmd !~ /LINK/);
joachim99@14 1863
joachim99@14 1864 $lookup = $program . '_NMCHECK\s*=([^\n]*)';
joachim99@14 1865 if( $MakefileData !~ m/\n$lookup\n/ ) {
joachim99@14 1866 return;
joachim99@14 1867 }
joachim99@14 1868 my $allowed = $1;
joachim99@14 1869 $allowed =~ s/^ *//;
joachim99@14 1870 $lookup = $program . '_NMCHECKWEAK\s*=([^\n]*)';
joachim99@14 1871 my $weak = "";
joachim99@14 1872 my $is_weak = 0;
joachim99@14 1873 if( $MakefileData =~ m/\n$lookup\n/ ) {
joachim99@14 1874 $weak = $1;
joachim99@14 1875 $is_weak = 1;
joachim99@14 1876 }
joachim99@14 1877 $weak =~ s/^ *//;
joachim99@14 1878
joachim99@14 1879 if( $is_weak )
joachim99@14 1880 {
joachim99@14 1881 $weak = '--allowweak=\'' . $weak . '\' ';
joachim99@14 1882 }
joachim99@14 1883 my $nmline = "\@KDE_USE_NMCHECK_TRUE@\t\@\$(MAKE) \$(AM_MAKEFLAGS) nmcheck_$realname{$program} || ( rm -f $realname{$program}; exit 1 )";
joachim99@14 1884 $lookup = '(\t\$\(CXXLINK\)[^\n]*' . $program . '_OBJECTS[^\n]*)';
joachim99@14 1885 if( $MakefileData =~ /\n$lookup\n/ ) {
joachim99@14 1886 my $oldstuff = $1;
joachim99@14 1887 substituteLine( $lookup, $oldstuff . "\n" . $nmline );
joachim99@14 1888 }
joachim99@14 1889 $lookup = '(\t\$\(LINK\)[^\n]*' . $program . '_OBJECTS[^\n]*)';
joachim99@14 1890 if( $MakefileData =~ /\n$lookup\n/ ) {
joachim99@14 1891 my $oldstuff = $1;
joachim99@14 1892 substituteLine( $lookup, $oldstuff . "\n" . $nmline );
joachim99@14 1893 }
joachim99@14 1894 $nmline = "\@\$(top_srcdir)/admin/nmcheck $realname{$program} \'$allowed\' $weak";
joachim99@14 1895 appendLines( "\nnmcheck_$realname{$program}: $realname{$program} \n\t$nmline\n" );
joachim99@14 1896 $target_adds{ "nmcheck" } .= "nmcheck_$realname{$program} ";
joachim99@14 1897 }
joachim99@14 1898
joachim99@2 1899 sub tag_DIST () {
joachim99@2 1900 my %foundfiles = ();
joachim99@2 1901 opendir (THISDIR, ".");
joachim99@2 1902 foreach $entry (readdir(THISDIR)) {
joachim99@14 1903 next if ($entry eq "CVS" || $entry =~ /^\./ || $entry eq "Makefile" || $entry =~ /~$/ || $entry =~ /^\#.*\#$/);
joachim99@2 1904 next if (! -f $entry);
joachim99@14 1905 next if ($entry =~ /\.moc/ || $entry =~ /\.moc.$cppExt$/ || $entry =~ /\.lo$/ || $entry =~ /\.la$/ || $entry =~ /\.o/);
joachim99@14 1906 next if ($entry =~ /\.all_$cppExt\.$cppExt$/);
joachim99@2 1907 $foundfiles{$entry} = 1;
joachim99@2 1908 }
joachim99@2 1909 closedir (THISDIR);
joachim99@2 1910
joachim99@2 1911 # doing this for MAINTAINERCLEANFILES would be wrong
joachim99@2 1912 my @marks = ("EXTRA_DIST", "DIST_COMMON", '\S*_SOURCES', '\S*_HEADERS', 'CLEANFILES', 'DISTCLEANFILES', '\S*_OBJECTS');
joachim99@2 1913 foreach $mark (@marks) {
joachim99@14 1914 while ($MakefileData =~ /\n($mark)\s*=[ \t]*([^\n]*)/g) {
joachim99@14 1915 my $cleanfiles_str = $2;
joachim99@14 1916 foreach $file (split('[\034\s]+', $cleanfiles_str)) {
joachim99@2 1917 $file =~ s/\.\///;
joachim99@2 1918 $foundfiles{$file} = 0 if (defined $foundfiles{$file});
joachim99@2 1919 }
joachim99@2 1920 }
joachim99@2 1921 }
joachim99@2 1922 my @files = ("Makefile", "config.cache", "config.log", "stamp-h",
joachim99@14 1923 "stamp-h1", "stamp-h1", "config.h", "Makefile",
joachim99@14 1924 "config.status", "config.h", "libtool", "core" );
joachim99@2 1925 foreach $file (@files) {
joachim99@2 1926 $foundfiles{$file} = 0 if (defined $foundfiles{$file});
joachim99@2 1927 }
joachim99@2 1928
joachim99@2 1929 my $KDE_DIST = "";
joachim99@2 1930 foreach $file (keys %foundfiles) {
joachim99@2 1931 if ($foundfiles{$file} == 1) {
joachim99@2 1932 $KDE_DIST .= "$file ";
joachim99@2 1933 }
joachim99@2 1934 }
joachim99@2 1935 if ($KDE_DIST) {
joachim99@2 1936 print "KDE_DIST $printname $KDE_DIST\n" if ($verbose);
joachim99@14 1937
joachim99@14 1938 my $lookup = 'DISTFILES\s*=[ \t]*(.*)';
joachim99@14 1939 if ($MakefileData =~ /\n$lookup/) {
joachim99@14 1940 substituteLine($lookup, "DISTFILES = $1 \$(KDE_DIST)");
joachim99@14 1941 appendLines("KDE_DIST=$KDE_DIST\n");
joachim99@2 1942 }
joachim99@2 1943 }
joachim99@2 1944 }
joachim99@2 1945
joachim99@2 1946 #-----------------------------------------------------------------------------
joachim99@2 1947 # Returns 0 if the line was processed - 1 otherwise.
joachim99@2 1948 # Errors are logged in the global $errorflags
joachim99@2 1949 sub tag_DOCFILES ()
joachim99@2 1950 {
joachim99@2 1951 $target_adds{"all"} .= "docs-am ";
joachim99@2 1952
joachim99@14 1953 my $lookup = 'KDE_DOCS\s*=[ \t]*([^\n]*)';
joachim99@14 1954 goto nodocs if ($MakefileData !~ /\n$lookup/);
joachim99@2 1955 print STDOUT "KDE_DOCS processing <$1>\n" if ($verbose);
joachim99@2 1956
joachim99@2 1957 my $tmp = $1;
joachim99@2 1958
joachim99@2 1959 # Either find the files in the directory (AUTO) or use
joachim99@2 1960 # only the specified po files.
joachim99@2 1961 my $files = "";
joachim99@2 1962 my $appname = $tmp;
joachim99@2 1963 $appname =~ s/^(\S*)\s*.*$/$1/;
joachim99@2 1964 if ($appname =~ /AUTO/) {
joachim99@2 1965 $appname = basename($makefileDir);
joachim99@2 1966 if ("$appname" eq "en") {
joachim99@2 1967 print STDERR "Error: KDE_DOCS = AUTO relies on the directory name. Yours is 'en' - you most likely want something else, e.g. KDE_DOCS = myapp\n";
joachim99@2 1968 exit(1);
joachim99@2 1969 }
joachim99@2 1970 }
joachim99@2 1971
joachim99@2 1972 if ($tmp !~ / - /)
joachim99@2 1973 {
joachim99@2 1974 opendir (THISDIR, ".");
joachim99@2 1975 foreach $entry (readdir(THISDIR)) {
joachim99@14 1976 next if ($entry eq "CVS" || $entry =~ /^\./ || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/ || $entry eq "core" || $entry eq "index.cache.bz2");
joachim99@2 1977 next if (! -f $entry);
joachim99@2 1978 $files .= "$entry ";
joachim99@2 1979 }
joachim99@2 1980 closedir (THISDIR);
joachim99@2 1981 print STDOUT "docfiles found = $files\n" if ($verbose);
joachim99@2 1982 }
joachim99@2 1983 else
joachim99@2 1984 {
joachim99@2 1985 $tmp =~ s/\034/ /g;
joachim99@2 1986 $tmp =~ s/^\S*\s*-\s*//;
joachim99@2 1987 $files = $tmp;
joachim99@2 1988 }
joachim99@2 1989 goto nodocs if (!$files); # Nothing to do
joachim99@2 1990
joachim99@2 1991 if ($files =~ /(^| )index\.docbook($| )/) {
joachim99@14 1992
joachim99@2 1993 my $lines = "";
joachim99@2 1994 my $lookup = 'MEINPROC\s*=';
joachim99@2 1995 if ($MakefileData !~ /\n($lookup)/) {
joachim99@2 1996 $lines = "MEINPROC=/\$(kde_bindir)/meinproc\n";
joachim99@2 1997 }
joachim99@2 1998 $lookup = 'KDE_XSL_STYLESHEET\s*=';
joachim99@2 1999 if ($MakefileData !~ /\n($lookup)/) {
joachim99@2 2000 $lines .= "KDE_XSL_STYLESHEET=/\$(kde_datadir)/ksgmltools2/customization/kde-chunk.xsl\n";
joachim99@2 2001 }
joachim99@2 2002 $lookup = '\nindex.cache.bz2:';
joachim99@2 2003 if ($MakefileData !~ /\n($lookup)/) {
joachim99@2 2004 $lines .= "index.cache.bz2: \$(srcdir)/index.docbook \$(KDE_XSL_STYLESHEET) $files\n";
joachim99@14 2005 $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";
joachim99@2 2006 $lines .= "\n";
joachim99@2 2007 }
joachim99@14 2008
joachim99@14 2009 $lines .= "docs-am: index.cache.bz2\n";
joachim99@2 2010 $lines .= "\n";
joachim99@2 2011 $lines .= "install-docs: docs-am install-nls\n";
joachim99@2 2012 $lines .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n";
joachim99@2 2013 $lines .= "\t\@if test -f index.cache.bz2; then \\\n";
joachim99@2 2014 $lines .= "\techo \$(INSTALL_DATA) index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n";
joachim99@2 2015 $lines .= "\t\$(INSTALL_DATA) index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n";
joachim99@14 2016 $lines .= "\telif test -f \$(srcdir)/index.cache.bz2; then \\\n";
joachim99@14 2017 $lines .= "\techo \$(INSTALL_DATA) \$(srcdir)/index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n";
joachim99@14 2018 $lines .= "\t\$(INSTALL_DATA) \$(srcdir)/index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n";
joachim99@2 2019 $lines .= "\tfi\n";
joachim99@2 2020 $lines .= "\t-rm -f \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n";
joachim99@2 2021 $lines .= "\t\$(LN_S) \$(kde_libs_htmldir)/$kdelang/common \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n";
joachim99@2 2022
joachim99@2 2023 $lines .= "\n";
joachim99@2 2024 $lines .= "uninstall-docs:\n";
joachim99@2 2025 $lines .= "\t-rm -rf \$(kde_htmldir)/$kdelang/$appname\n";
joachim99@2 2026 $lines .= "\n";
joachim99@2 2027 $lines .= "clean-docs:\n";
joachim99@2 2028 $lines .= "\t-rm -f index.cache.bz2\n";
joachim99@2 2029 $lines .= "\n";
joachim99@2 2030 $target_adds{"install-data-am"} .= "install-docs ";
joachim99@2 2031 $target_adds{"uninstall"} .= "uninstall-docs ";
joachim99@2 2032 $target_adds{"clean-am"} .= "clean-docs ";
joachim99@2 2033 appendLines ($lines);
joachim99@2 2034 } else {
joachim99@2 2035 appendLines("docs-am: $files\n");
joachim99@2 2036 }
joachim99@2 2037
joachim99@14 2038 $target_adds{"install-data-am"} .= "install-nls ";
joachim99@2 2039 $target_adds{"uninstall"} .= "uninstall-nls ";
joachim99@2 2040
joachim99@2 2041 $tmp = "install-nls:\n";
joachim99@2 2042 $tmp .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n";
joachim99@2 2043 $tmp .= "\t\@for base in $files; do \\\n";
joachim99@2 2044 $tmp .= "\t echo \$(INSTALL_DATA) \$\$base \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n";
joachim99@2 2045 $tmp .= "\t \$(INSTALL_DATA) \$(srcdir)/\$\$base \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n";
joachim99@2 2046 $tmp .= "\tdone\n";
joachim99@2 2047 if ($appname eq 'common') {
joachim99@2 2048 $tmp .= "\t\@echo \"merging common and language specific dir\" ;\\\n";
joachim99@14 2049 $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";
joachim99@2 2050 $tmp .= "\t\@com_files=`cd \$(kde_htmldir)/en/common && echo *` ;\\\n";
joachim99@2 2051 $tmp .= "\tcd \$(DESTDIR)\$(kde_htmldir)/$kdelang/common ;\\\n";
joachim99@2 2052 $tmp .= "\tif test -n \"\$\$com_files\"; then for p in \$\$com_files ; do \\\n";
joachim99@2 2053 $tmp .= "\t case \" $files \" in \\\n";
joachim99@2 2054 $tmp .= "\t *\" \$\$p \"*) ;; \\\n";
joachim99@14 2055 $tmp .= "\t *) test ! -f \$\$p && echo \$(LN_S) ../../en/common/\$\$p \$(DESTDIR)\$(kde_htmldir)/$kdelang/common/\$\$p && \$(LN_S) ../../en/common/\$\$p \$\$p ;; \\\n";
joachim99@2 2056 $tmp .= "\t esac ; \\\n";
joachim99@2 2057 $tmp .= "\tdone ; fi ; true\n";
joachim99@2 2058 }
joachim99@2 2059 $tmp .= "\n";
joachim99@2 2060 $tmp .= "uninstall-nls:\n";
joachim99@2 2061 $tmp .= "\tfor base in $files; do \\\n";
joachim99@2 2062 $tmp .= "\t rm -f \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/\$\$base ;\\\n";
joachim99@2 2063 $tmp .= "\tdone\n\n";
joachim99@2 2064 appendLines ($tmp);
joachim99@2 2065
joachim99@2 2066 $target_adds{"distdir"} .= "distdir-nls ";
joachim99@2 2067
joachim99@2 2068 $tmp = "distdir-nls:\n";
joachim99@2 2069 $tmp .= "\tfor file in $files; do \\\n";
joachim99@2 2070 $tmp .= "\t cp \$(srcdir)/\$\$file \$(distdir); \\\n";
joachim99@2 2071 $tmp .= "\tdone\n";
joachim99@2 2072
joachim99@2 2073 appendLines ($tmp);
joachim99@2 2074
joachim99@2 2075 return 0;
joachim99@2 2076
joachim99@2 2077 nodocs:
joachim99@2 2078 appendLines("docs-am:\n");
joachim99@2 2079 return 1;
joachim99@2 2080 }
joachim99@2 2081
joachim99@2 2082 #-----------------------------------------------------------------------------
joachim99@2 2083 # Find headers in any of the source directories specified previously, that
joachim99@2 2084 # are candidates for "moc-ing".
joachim99@2 2085 sub findMocCandidates ()
joachim99@2 2086 {
joachim99@2 2087 foreach $dir (@headerdirs)
joachim99@2 2088 {
joachim99@2 2089 my @list = ();
joachim99@2 2090 opendir (SRCDIR, "$dir");
joachim99@2 2091 @hFiles = grep { /.+\.$hExt$/o && !/^\./ } readdir(SRCDIR);
joachim99@2 2092 closedir SRCDIR;
joachim99@2 2093 foreach $hf (@hFiles)
joachim99@2 2094 {
joachim99@2 2095 next if ($hf =~ /^\.\#/);
joachim99@2 2096 $hf =~ /(.*)\.[^\.]*$/; # Find name minus extension
joachim99@2 2097 next if ($uiFiles{$1});
joachim99@2 2098 open (HFIN, "$dir/$hf") || die "Could not open $dir/$hf: $!\n";
joachim99@2 2099 my $hfsize = 0;
joachim99@2 2100 seek(HFIN, 0, 2);
joachim99@2 2101 $hfsize = tell(HFIN);
joachim99@2 2102 seek(HFIN, 0, 0);
joachim99@2 2103 read HFIN, $hfData, $hfsize;
joachim99@2 2104 close HFIN;
joachim99@2 2105 # push (@list, $hf) if(index($hfData, "Q_OBJECT") >= 0); ### fast but doesn't handle //Q_OBJECT
joachim99@14 2106 # handle " { friend class blah; Q_OBJECT ", but don't match antlarr_Q_OBJECT (\b).
joachim99@14 2107 if ( $hfData =~ /{([^}]*)\bQ_OBJECT/s ) {
joachim99@14 2108 push (@list, $hf) unless $1 =~ m://[^\n]*Q_OBJECT[^\n]*$:s; ## reject "// Q_OBJECT"
joachim99@2 2109 }
joachim99@2 2110 }
joachim99@2 2111 # The assoc array of root of headerfile and header filename
joachim99@2 2112 foreach $hFile (@list)
joachim99@2 2113 {
joachim99@2 2114 $hFile =~ /(.*)\.[^\.]*$/; # Find name minus extension
joachim99@2 2115 if ($mocFiles{$1})
joachim99@2 2116 {
joachim99@2 2117 print STDERR "Warning: Multiple header files found for $1\n";
joachim99@2 2118 next; # Use the first one
joachim99@2 2119 }
joachim99@2 2120 $mocFiles{$1} = "$dir\035$hFile"; # Add relative dir
joachim99@2 2121 }
joachim99@2 2122 }
joachim99@2 2123
joachim99@2 2124 return 0;
joachim99@2 2125 }
joachim99@2 2126
joachim99@2 2127 #-----------------------------------------------------------------------------
joachim99@2 2128
joachim99@2 2129 # The programmer has specified a moc list. Prune out the moc candidates
joachim99@2 2130 # list that we found based on looking at the header files. This generates
joachim99@2 2131 # a warning if the programmer gets the list wrong, but this doesn't have
joachim99@2 2132 # to be fatal here.
joachim99@2 2133 sub pruneMocCandidates ($)
joachim99@2 2134 {
joachim99@2 2135 my %prunedMoc = ();
joachim99@2 2136 local @mocList = split(' ', $_[0]);
joachim99@2 2137
joachim99@2 2138 foreach $mocname (@mocList)
joachim99@2 2139 {
joachim99@2 2140 $mocname =~ s/\.moc$//;
joachim99@2 2141 if ($mocFiles{$mocname})
joachim99@2 2142 {
joachim99@2 2143 $prunedMoc{$mocname} = $mocFiles{$mocname};
joachim99@2 2144 }
joachim99@2 2145 else
joachim99@2 2146 {
joachim99@2 2147 my $print = $makefileDir;
joachim99@2 2148 $print =~ s/^\Q$topdir\E\\//;
joachim99@2 2149 # They specified a moc file but we can't find a header that
joachim99@2 2150 # will generate this moc file. That's possible fatal!
joachim99@2 2151 print STDERR "Warning: No moc-able header file for $print/$mocname\n";
joachim99@2 2152 }
joachim99@2 2153 }
joachim99@2 2154
joachim99@2 2155 undef %mocFiles;
joachim99@2 2156 %mocFiles = %prunedMoc;
joachim99@2 2157 }
joachim99@2 2158
joachim99@2 2159 #-----------------------------------------------------------------------------
joachim99@2 2160
joachim99@2 2161 # Finds the cpp files (If they exist).
joachim99@2 2162 # The cpp files get appended to the header file separated by \035
joachim99@2 2163 sub checkMocCandidates ()
joachim99@2 2164 {
joachim99@2 2165 my @cppFiles;
joachim99@2 2166 my $cpp2moc; # which c++ file includes which .moc files
joachim99@2 2167 my $moc2cpp; # which moc file is included by which c++ files
joachim99@2 2168
joachim99@2 2169 return unless (keys %mocFiles);
joachim99@2 2170 opendir(THISDIR, ".") || return;
joachim99@2 2171 @cppFiles = grep { /.+\.$cppExt$/o && !/.+\.moc\.$cppExt$/o
joachim99@2 2172 && !/.+\.all_$cppExt\.$cppExt$/o
joachim99@2 2173 && !/^\./ } readdir(THISDIR);
joachim99@2 2174 closedir THISDIR;
joachim99@2 2175 return unless (@cppFiles);
joachim99@2 2176 my $files = join (" ", @cppFiles);
joachim99@2 2177 $cpp2moc = {};
joachim99@2 2178 $moc2cpp = {};
joachim99@2 2179 foreach $cxxf (@cppFiles)
joachim99@2 2180 {
joachim99@2 2181 open (CXXFIN, $cxxf) || die "Could not open $cxxf: $!\n";
joachim99@2 2182 seek(CXXFIN, 0, 2);
joachim99@2 2183 my $cxxfsize = tell(CXXFIN);
joachim99@2 2184 seek(CXXFIN, 0, 0);
joachim99@2 2185 read CXXFIN, $cxxfData, $cxxfsize;
joachim99@2 2186 close CXXFIN;
joachim99@2 2187 while(($cxxfData =~ m/^[ \t]*\#include\s*[<\"](.*\.moc)[>\"]/gm)) {
joachim99@2 2188 $cpp2moc->{$cxxf}->{$1} = 1;
joachim99@2 2189 $moc2cpp->{$1}->{$cxxf} = 1;
joachim99@2 2190 }
joachim99@2 2191 }
joachim99@2 2192 foreach my $mocFile (keys (%mocFiles))
joachim99@2 2193 {
joachim99@2 2194 @cppFiles = keys %{$moc2cpp->{"$mocFile.moc"}};
joachim99@2 2195 if (@cppFiles == 1) {
joachim99@2 2196 $mocFiles{$mocFile} .= "\035" . $cppFiles[0];
joachim99@14 2197 push(@depend, $mocFile);
joachim99@2 2198 } elsif (@cppFiles == 0) {
joachim99@2 2199 push (@newObs, $mocFile); # Produce new object file
joachim99@2 2200 next if ($haveAutomocTag); # This is expected...
joachim99@2 2201 # But this is an error we can deal with - let them know
joachim99@2 2202 print STDERR
joachim99@2 2203 "Warning: No c++ file that includes $mocFile.moc\n";
joachim99@2 2204 } else {
joachim99@2 2205 # We can't decide which file to use, so it's fatal. Although as a
joachim99@2 2206 # guess we could use the mocFile.cpp file if it's in the list???
joachim99@2 2207 print STDERR
joachim99@2 2208 "Error: Multiple c++ files that include $mocFile.moc\n";
joachim99@2 2209 print STDERR "\t",join ("\t", @cppFiles),"\n";
joachim99@2 2210 $errorflag = 1;
joachim99@2 2211 delete $mocFiles{$mocFile};
joachim99@2 2212 # Let's continue and see what happens - They have been told!
joachim99@2 2213 }
joachim99@2 2214 }
joachim99@2 2215 }
joachim99@2 2216
joachim99@2 2217 #-----------------------------------------------------------------------------
joachim99@2 2218
joachim99@2 2219 # Add the rules for generating moc source from header files
joachim99@2 2220 # For Automoc output *.moc.cpp but normally we'll output *.moc
joachim99@2 2221 # (We must compile *.moc.cpp separately. *.moc files are included
joachim99@2 2222 # in the appropriate *.cpp file by the programmer)
joachim99@2 2223 sub addMocRules ()
joachim99@2 2224 {
joachim99@2 2225 my $cppFile;
joachim99@2 2226 my $hFile;
joachim99@2 2227
joachim99@2 2228 foreach $mocFile (keys (%mocFiles))
joachim99@2 2229 {
joachim99@2 2230 undef $cppFile;
joachim99@2 2231 ($dir, $hFile, $cppFile) = split ("\035", $mocFiles{$mocFile}, 3);
joachim99@2 2232 $dir =~ s#^\.#\$(srcdir)#;
joachim99@2 2233 if (defined ($cppFile))
joachim99@2 2234 {
joachim99@14 2235 $cppFile =~ s,\.[^.]*$,,;
joachim99@14 2236 $target_adds{"$cppFile.o"} .= "$mocFile.moc ";
joachim99@14 2237 $target_adds{"$cppFile.lo"} .= "$mocFile.moc ";
joachim99@14 2238 appendLines ("$mocFile.moc: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile.moc\n");
joachim99@14 2239 $cleanMoc .= " $mocFile.moc";
joachim99@14 2240 appendLines ("mocs: $mocFile.moc\n");
joachim99@2 2241 }
joachim99@2 2242 else
joachim99@2 2243 {
joachim99@2 2244 appendLines ("$mocFile$mocExt: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile$mocExt\n");
joachim99@2 2245 $cleanMoc .= " $mocFile$mocExt";
joachim99@14 2246 appendLines ("mocs: $mocFile$mocExt\n");
joachim99@2 2247 }
joachim99@2 2248 }
joachim99@2 2249 }
joachim99@2 2250
joachim99@14 2251 sub make_bcheck_target()
joachim99@14 2252 {
joachim99@14 2253 my $lookup = 'RECURSIVE_TARGETS\s*=[ \t]*(.*)';
joachim99@14 2254 my $bcheckdep = "bcheck-am";
joachim99@14 2255 $bcheckdep = "bcheck-recursive" if ($MakefileData =~ /\n$lookup/);
joachim99@14 2256
joachim99@14 2257 my $headers= "";
joachim99@14 2258 $headers = $1 if($MakefileData =~ /\nHEADERS\s*=[ \t]*(.+)/);
joachim99@14 2259 $headers =~ s/\$\((?:noinst|EXTRA)_HEADERS\)//g;
joachim99@14 2260
joachim99@14 2261 $target_adds{"clean-am"} .= "clean-bcheck ";
joachim99@14 2262
joachim99@14 2263 my $t = "clean-bcheck: \n" .
joachim99@14 2264 "\trm -f *.bchecktest.cc *.bchecktest.cc.class a.out\n\n" .
joachim99@14 2265 "bcheck: $bcheckdep\n\n" .
joachim99@14 2266 "bcheck-am:\n" .
joachim99@14 2267 "\t\@for i in $headers; do \\\n" .
joachim99@14 2268 "\t if test \$(srcdir)/\$\$i -nt \$\$i.bchecktest.cc; then \\\n" .
joachim99@14 2269 "\t echo \"int main() {return 0;}\" > \$\$i.bchecktest.cc ; \\\n" .
joachim99@14 2270 "\t echo \"#include \\\"\$\$i\\\"\" >> \$\$i.bchecktest.cc ; \\\n" .
joachim99@14 2271 "\t echo \"\$\$i\"; \\\n" .
joachim99@14 2272 "\t if ! ";
joachim99@14 2273 $t .= $cxxsuffix eq "KKK" ?
joachim99@14 2274 "\$(CXX) \$(DEFS) -I. -I\$(srcdir) -I\$(top_builddir) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(KDE_CXXFLAGS) " :
joachim99@14 2275 "\$(CXXCOMPILE) ";
joachim99@66 2276 $t .= " --dump-class-hierarchy -c \$\$i.bchecktest.cc; then \\\n" .
joachim99@14 2277 "\t rm -f \$\$i.bchecktest.cc; exit 1; \\\n" .
joachim99@14 2278 "\t fi ; \\\n" .
joachim99@14 2279 "\t echo \"\" >> \$\$i.bchecktest.cc.class; \\\n" .
joachim99@14 2280 "\t perl \$(top_srcdir)/admin/bcheck.pl \$\$i.bchecktest.cc.class || { rm -f \$\$i.bchecktest.cc; exit 1; }; \\\n" .
joachim99@14 2281 "\t rm -f a.out; \\\n" .
joachim99@14 2282 "\t fi ; \\\n" .
joachim99@14 2283 "\tdone\n";
joachim99@14 2284 appendLines("$t\n");
joachim99@14 2285 }
joachim99@14 2286
joachim99@2 2287 sub make_meta_classes ()
joachim99@2 2288 {
joachim99@2 2289 return if ($kdeopts{"qtonly"});
joachim99@2 2290
joachim99@2 2291 my $cppFile;
joachim99@2 2292 my $hFile;
joachim99@2 2293 my $moc_class_headers = "";
joachim99@2 2294 foreach $program (@programs) {
joachim99@2 2295 my $mocs = "";
joachim99@14 2296 my @progsources = split(/[\034\s]+/, $sources{$program});
joachim99@14 2297 my @depmocs = split(' ', $dependmocs{$program});
joachim99@2 2298 my %shash = (), %mhash = ();
joachim99@2 2299 @shash{@progsources} = 1; # we are only interested in the existence
joachim99@2 2300 @mhash{@depmocs} = 1;
joachim99@2 2301
joachim99@2 2302 print STDOUT "program=$program\n" if ($verbose);
joachim99@2 2303 print STDOUT "psources=[".join(' ', keys %shash)."]\n" if ($verbose);
joachim99@2 2304 print STDOUT "depmocs=[".join(' ', keys %mhash)."]\n" if ($verbose);
joachim99@2 2305 print STDOUT "globalmocs=[".join(' ', keys(%globalmocs))."]\n" if ($verbose);
joachim99@2 2306 foreach my $mocFile (keys (%globalmocs))
joachim99@2 2307 {
joachim99@14 2308 my ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3);
joachim99@2 2309 if (defined ($cppFile))
joachim99@2 2310 {
joachim99@2 2311 $mocs .= " $mocFile.moc" if exists $shash{$cppFile};
joachim99@2 2312 }
joachim99@2 2313 else
joachim99@2 2314 {
joachim99@2 2315 # Bah. This is the case, if no C++ file includes the .moc
joachim99@2 2316 # file. We make a .moc.cpp file for that. Unfortunately this
joachim99@2 2317 # is not included in the %sources hash, but rather is mentioned
joachim99@14 2318 # in %dependmocs. If the user wants to use AUTO he can't just
joachim99@2 2319 # use an unspecific METAINCLUDES. Instead he must use
joachim99@2 2320 # program_METAINCLUDES. Anyway, it's not working real nicely.
joachim99@2 2321 # E.g. Its not clear what happens if user specifies two
joachim99@2 2322 # METAINCLUDES=AUTO in the same Makefile.am.
joachim99@2 2323 $mocs .= " $mocFile.moc.$cxxsuffix"
joachim99@2 2324 if exists $mhash{$mocFile.".moc.$cxxsuffix"};
joachim99@2 2325 }
joachim99@2 2326 }
joachim99@2 2327 if ($mocs) {
joachim99@2 2328 print STDOUT "==> mocs=[".$mocs."]\n" if ($verbose);
joachim99@2 2329 }
joachim99@2 2330 print STDOUT "\n" if $verbose;
joachim99@2 2331 }
joachim99@2 2332 if ($moc_class_headers) {
joachim99@2 2333 appendLines ("$cleantarget-moc-classes:\n\t-rm -f $moc_class_headers\n");
joachim99@2 2334 $target_adds{"$cleantarget-am"} .= "$cleantarget-moc-classes ";
joachim99@2 2335 }
joachim99@2 2336 }
joachim99@2 2337
joachim99@2 2338 #-----------------------------------------------------------------------------
joachim99@2 2339
joachim99@2 2340 sub updateMakefile ()
joachim99@2 2341 {
joachim99@2 2342 return if ($dryrun);
joachim99@2 2343
joachim99@2 2344 open (FILEOUT, "> $makefile")
joachim99@2 2345 || die "Could not create $makefile: $!\n";
joachim99@2 2346
joachim99@14 2347 $MakefileData =~ s/\034/\\\n/g; # Restore continuation lines
joachim99@14 2348 # Append our $progId line, _below_ the "generated by automake" line
joachim99@14 2349 # because automake-1.6 relies on the first line to be his own.
joachim99@14 2350 my $progIdLine = "\# $progId - " . '$Revision$ '."\n";
joachim99@14 2351 if ( !( $MakefileData =~ s/^(.*generated .*by automake.*\n)/$1$progIdLine/ ) ) {
joachim99@14 2352 warn "automake line not found in $makefile\n";
joachim99@14 2353 # Fallback: first line
joachim99@14 2354 print FILEOUT $progIdLine;
joachim99@14 2355 };
joachim99@2 2356 print FILEOUT $MakefileData;
joachim99@2 2357 close FILEOUT;
joachim99@2 2358 }
joachim99@2 2359
joachim99@2 2360 #-----------------------------------------------------------------------------
joachim99@2 2361
joachim99@2 2362 # The given line needs to be removed from the makefile
joachim99@2 2363 # Do this by adding the special "removed line" comment at the line start.
joachim99@2 2364 sub removeLine ($$)
joachim99@2 2365 {
joachim99@2 2366 my ($lookup, $old) = @_;
joachim99@2 2367
joachim99@2 2368 $old =~ s/\034/\\\n#>- /g; # Fix continuation lines
joachim99@2 2369 $MakefileData =~ s/\n$lookup/\n#>\- $old/;
joachim99@2 2370 }
joachim99@2 2371
joachim99@2 2372 #-----------------------------------------------------------------------------
joachim99@2 2373
joachim99@2 2374 # Replaces the old line with the new line
joachim99@2 2375 # old line(s) are retained but tagged as removed. The new line(s) have the
joachim99@2 2376 # "added" tag placed before it.
joachim99@2 2377 sub substituteLine ($$)
joachim99@2 2378 {
joachim99@2 2379 my ($lookup, $new) = @_;
joachim99@2 2380
joachim99@2 2381 if ($MakefileData =~ /\n($lookup)/) {
joachim99@2 2382 $old = $1;
joachim99@2 2383 $old =~ s/\034/\\\n#>\- /g; # Fix continuation lines
joachim99@14 2384 my $newCount = ($new =~ tr/\034//) + ($new =~ tr/\n//) + 1;
joachim99@14 2385 $new =~ s/\\\n/\034/g;
joachim99@2 2386 $MakefileData =~ s/\n$lookup/\n#>- $old\n#>\+ $newCount\n$new/;
joachim99@2 2387 } else {
joachim99@14 2388 warn "Warning: substitution of \"$lookup\" in $printname failed\n";
joachim99@2 2389 }
joachim99@2 2390 }
joachim99@2 2391
joachim99@2 2392 #-----------------------------------------------------------------------------
joachim99@2 2393
joachim99@2 2394 # Slap new lines on the back of the file.
joachim99@2 2395 sub appendLines ($)
joachim99@2 2396 {
joachim99@2 2397 my ($new) = @_;
joachim99@14 2398 my $copynew = $new;
joachim99@14 2399 my $newCount = ($new =~ tr/\034//) + ($new =~ tr/\n//) + 1;
joachim99@14 2400 $new =~ s/\\\n/\034/g; # Fix continuation lines
joachim99@2 2401 $MakefileData .= "\n#>\+ $newCount\n$new";
joachim99@2 2402 }
joachim99@2 2403
joachim99@2 2404 #-----------------------------------------------------------------------------
joachim99@2 2405
joachim99@2 2406 # Restore the Makefile.in to the state it was before we fiddled with it
joachim99@2 2407 sub restoreMakefile ()
joachim99@2 2408 {
joachim99@2 2409 $MakefileData =~ s/# $progId[^\n\034]*[\n\034]*//g;
joachim99@2 2410 # Restore removed lines
joachim99@2 2411 $MakefileData =~ s/([\n\034])#>\- /$1/g;
joachim99@2 2412 # Remove added lines
joachim99@2 2413 while ($MakefileData =~ /[\n\034]#>\+ ([^\n\034]*)/)
joachim99@2 2414 {
joachim99@2 2415 my $newCount = $1;
joachim99@2 2416 my $removeLines = "";
joachim99@2 2417 while ($newCount--) {
joachim99@2 2418 $removeLines .= "[^\n\034]*([\n\034]|)";
joachim99@2 2419 }
joachim99@2 2420 $MakefileData =~ s/[\n\034]#>\+.*[\n\034]$removeLines/\n/;
joachim99@2 2421 }
joachim99@2 2422 }
joachim99@2 2423
joachim99@2 2424 #-----------------------------------------------------------------------------
joachim99@66 2425
joachim99@66 2426 # find the .kcfg file listed in the .kcfgc file
joachim99@66 2427 sub findKcfgFile($)
joachim99@66 2428 {
joachim99@66 2429 my ($kcfgf) = @_;
joachim99@66 2430 open (KCFGFIN, $kcfgf) || die "Could not open $kcfgf: $!\n";
joachim99@66 2431 seek(KCFGFIN, 0, 2);
joachim99@66 2432 my $kcfgfsize = tell(KCFGFIN);
joachim99@66 2433 seek(KCFGFIN, 0, 0);
joachim99@66 2434 read KCFGFIN, $kcfgfData, $kcfgfsize;
joachim99@66 2435 close KCFGFIN;
joachim99@66 2436 if(($kcfgfData =~ m/^File=(.*\.kcfg)/gm)) {
joachim99@66 2437 $kcfg = $1;
joachim99@66 2438 }
joachim99@66 2439 }