annotate kdiff3/admin/am_edit @ 69:8febbfb1148c

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