~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to admin/am_edit

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#    KDE_ICON = AUTO
19
19
#
20
20
# For documentation :
21
 
#    ...
 
21
#    http://developer.kde.org/documentation/other/developer-faq.html
22
22
#
23
23
# and more new tags TBD!
24
24
#
31
31
# Alex Zepeda  <jazepeda@pacbell.net>
32
32
# David Faure <faure@kde.org>
33
33
# Stephan Kulow <coolo@kde.org>
 
34
# Dirk Mueller <mueller@kde.org>
34
35
 
35
36
use Cwd;
36
37
use File::Find;
50
51
sub pruneMocCandidates ($);
51
52
sub checkMocCandidates ();
52
53
sub addMocRules ();
 
54
sub findKcfgFile($);
53
55
 
54
56
sub tag_AUTOMAKE ();
55
57
sub tag_META_INCLUDES ();
59
61
sub tag_LOCALINSTALL();
60
62
sub tag_IDLFILES();
61
63
sub tag_UIFILES();
 
64
sub tag_KCFGFILES();
62
65
sub tag_SUBDIRS();
63
66
sub tag_ICON();
64
67
sub tag_CLOSURE();
 
68
sub tag_NO_UNDEFINED();
 
69
sub tag_NMCHECK();
65
70
sub tag_DIST();
 
71
sub tag_KDEINIT();
66
72
 
67
73
# Some global globals...
68
74
$verbose    = 0;        # a debug flag
82
88
$cleantarget = "clean";
83
89
$dryrun     = 0;
84
90
$pathoption = 0;
 
91
$foreign_libtool = 0;
85
92
 
86
93
while (defined ($ARGV[0]))
87
94
{
98
105
                "Making it useful by Stephan Kulow <coolo\@kde.org> and\n",
99
106
                "Harri Porten <porten\@kde.org>\n",
100
107
                "Updated (Feb-1999), John Birch <jb.nz\@writeme.com>\n",
 
108
                "Fixes and Improvements by Dirk Mueller <mueller\@kde.org>\n",
101
109
                "Current Maintainer Stephan Kulow\n\n";
102
110
        exit 0;
103
111
    }
105
113
    {
106
114
        $verbose = 1;       # Oh is there a problem...?
107
115
    }
108
 
    elsif (/^-p(.+)$|^--path=(.+)$/)
 
116
    elsif (/^(?:-p|--path=)(.+)$/)
109
117
    {
110
 
        $thisProg = "$1/".basename($thisProg) if($1);
111
 
        $thisProg = "$2/".basename($thisProg) if($2);
 
118
        my $p = $1;
 
119
        $thisProg = $p . "/". basename($thisProg);
112
120
        warn ("$thisProg doesn't exist\n")      if (!(-f $thisProg));
 
121
        $thisProg .= " -p".$p;
113
122
        $pathoption=1;
114
123
    }
115
124
    elsif (/^--help$|^-h$/)
116
125
    {
117
126
        print STDOUT "Usage $thisProg [OPTION] ... [dir/Makefile.in]...\n",
118
127
                "\n",
119
 
                "Patches dir/Makefile.in generated from automake\n",
120
 
                "(where dir can be a full or relative directory name)",
 
128
                "Patches dir/Makefile.in generated by automake\n",
 
129
                "(where dir can be an absolute or relative directory name)\n",
121
130
                "\n",
122
131
                "  -v, --verbose      verbosely list files processed\n",
123
132
                "  -h, --help         print this help, then exit\n",
124
133
                "  --version          print version number, then exit\n",
125
134
                "  -p, --path=        use the path to am_edit if the path\n",
126
 
                "  --no-final         don't patch for --enable-final\n",
127
 
                "                     called from is not the one to be used\n";
 
135
                "                     called from is not the one to be used\n",
 
136
                "  --no-final         don't patch for --enable-final\n";
128
137
        
129
138
        exit 0;
130
139
    }
133
142
        $use_final = 0;
134
143
        $thisProg .= " --no-final";
135
144
    }
 
145
    elsif (/^--foreign-libtool$/)
 
146
    {
 
147
        $foreign_libtool = 1;
 
148
        $thisProg .= " --foreign-libtool";
 
149
    }
136
150
    elsif (/^-n$/)
137
151
    {
138
152
        $dryrun = 1;
162
176
    find (\&add_makefile, cwd());
163
177
    #chdir('$topdir');
164
178
} else {
165
 
    print STDOUT "Using user enter input files\n"   if ($verbose);
 
179
    print STDOUT "Using input files specified by user\n"   if ($verbose);
166
180
}
167
181
 
168
182
foreach $makefile (sort(@makefiles))
201
215
    local @programs = ();  # lists the names of programs and libraries
202
216
    local $program = "";
203
217
 
 
218
    local @kdeinits = (); # lists the kdeinit targets
 
219
 
204
220
    local %realObjs = ();  # lists the objects compiled into $program
205
221
    local %sources = ();   # lists the sources used for $program
206
222
    local %finalObjs = (); # lists the objects compiled when final
209
225
    local %globalmocs = ();# list of all mocfiles (in %mocFiles format)
210
226
    local %important = (); # list of files to be generated asap
211
227
    local %uiFiles = ();
 
228
    local %kcfgFiles = ();
212
229
 
213
230
    local $allidls = "";
214
231
    local $idl_output = "";# lists all idl generated files for cleantarget
215
232
    local $ui_output = "";# lists all uic generated files for cleantarget
 
233
    local $kcfg_output = "";# lists all kcfg generated files for cleantarget
216
234
 
217
 
    local %depedmocs = ();
 
235
    local %dependmocs = ();
218
236
    
219
237
    local $metasourceTags = 0;
220
238
    local $dep_files      = "";
221
239
    local $dep_finals     = "";
222
240
    local %target_adds    = (); # the targets to add
 
241
    local %rule_adds      = ();
223
242
    local $kdelang        = "";
224
243
    local @cleanfiles     = ();
225
244
    local $cleanMoc       = "";
226
245
    local $closure_output = "";
227
246
 
 
247
    local %varcontent     = ();
 
248
 
228
249
    $makefileDir = dirname($makefile);
229
250
    chdir ($makefileDir);
230
251
    $printname = $makefile;
232
253
    $makefile = basename($makefile);
233
254
 
234
255
    print STDOUT "Processing makefile $printname\n"   if ($verbose);
235
 
    
 
256
 
236
257
    # Setup and see if we need to do this.
237
258
    return      if (!initialise());
238
 
    
 
259
 
239
260
    tag_AUTOMAKE ();            # Allows a "make" to redo the Makefile.in
240
261
    tag_META_INCLUDES ();       # Supplies directories for src locations
241
 
    
 
262
 
242
263
    foreach $program (@programs) {
243
264
        $sources_changed{$program} = 0;
244
 
        $depedmocs{$program} = "";
 
265
        $dependmocs{$program} = "";
245
266
        $important{$program} = "";
246
267
        tag_IDLFILES();             # Sorts out idl rules
 
268
        tag_NO_UNDEFINED();
247
269
        tag_CLOSURE();
248
 
        tag_UIFILES();             # Sorts out ui rules
 
270
        tag_NMCHECK();
 
271
        tag_UIFILES();              # Sorts out ui rules
 
272
        tag_KCFGFILES();            # Sorts out kcfg rules
249
273
        tag_METASOURCES ();         # Sorts out the moc rules
250
274
        if ($sources_changed{$program}) {
251
 
            my $lookup = "$program" . '_SOURCES\s*=\s*(.*)';
252
 
            substituteLine($lookup, "$program\_SOURCES=" . $sources{$program});
 
275
            my $lookup = $program . '_SOURCES\s*=[ \t]*(.*)';
 
276
 
 
277
            if($program =~ /libkdeinit_(.*)/) {
 
278
                my $prog = $1;
 
279
                substituteLine($prog . '_SOURCES\s*=[ \t]*(.*)', 
 
280
                    "${prog}_SOURCES = ${prog}_dummy.$cxxsuffix\n" .
 
281
                    "libkdeinit_${prog}_SOURCES = " . $sources{$program});
 
282
                $sources{$prog} = "${prog}_dummy.$cxxsuffix";
 
283
            }
 
284
            else {
 
285
                substituteLine($lookup, "$program\_SOURCES=" . $sources{$program});
 
286
            }
253
287
        }
254
288
        if ($important{$program}) {
255
289
            local %source_dict = ();
279
313
        appendLines ("$cleantarget-metasources:\n\t-rm -f $cleanMoc\n");
280
314
        $target_adds{"$cleantarget-am"} .= "$cleantarget-metasources ";
281
315
    }
282
 
    tag_DIST();
 
316
    
 
317
    tag_DIST() unless ($kdeopts{"noautodist"});
283
318
 
284
319
    if ($idl_output) {
285
320
        appendLines ("$cleantarget-idl:\n\t-rm -f $idl_output\n");
291
326
        $target_adds{"$cleantarget-am"} .= "$cleantarget-ui ";
292
327
    }
293
328
 
 
329
    if ($kcfg_output) {
 
330
        appendLines ("$cleantarget-kcfg:\n\t-rm -f $kcfg_output\n");
 
331
        $target_adds{"$cleantarget-am"} .= "$cleantarget-kcfg ";
 
332
    }
 
333
 
294
334
    if ($closure_output) {
295
335
        appendLines ("$cleantarget-closures:\n\t-rm -f $closure_output\n");
296
336
        $target_adds{"$cleantarget-am"} .= "$cleantarget-closures ";
312
352
    $tmp   .= "\t$automkCall\n\tcd \$(top_srcdir) && perl $thisProg $printname\n\n";
313
353
    appendLines($tmp);
314
354
    
 
355
    make_bcheck_target();
315
356
    make_meta_classes();
 
357
    tag_COMPILE_FIRST();
316
358
    tag_FINAL() if (!$kdeopts{"nofinal"});
317
359
 
318
360
    my $final_lines = "final:\n\t\$(MAKE) ";
321
363
    my $nofinal_install_lines = "no-final-install:\n\t\$(MAKE) ";
322
364
 
323
365
    foreach $program (@programs) {
324
 
        
325
 
        my $lookup = "$program\_OBJECTS.*=[^\n]*";
326
 
        
 
366
        my $lookup = $program . '_OBJECTS\s*=[ \t]*.*';
327
367
        my $new = "";
328
 
        
329
368
        my @list = split(/[\034\s]+/, $realObjs{$program});
330
 
        
331
369
        if (!$kdeopts{"nofinal"} && @list > 1 && $finalObjs{$program}) {
332
 
            
333
370
            $new .= "$program\_final\_OBJECTS = " . $finalObjs{$program};
334
371
            $new .= "\n$program\_nofinal\_OBJECTS = " . $realObjs{$program};
335
372
            $new .= "\n\@KDE_USE_FINAL_FALSE\@$program\_OBJECTS = \$($program\_nofinal\_OBJECTS)";
336
373
            $new .= "\n\@KDE_USE_FINAL_TRUE\@$program\_OBJECTS = \$($program\_final\_OBJECTS)";
337
 
            
 
374
 
338
375
            $final_lines .= "$program\_OBJECTS=\"\$($program\_final_OBJECTS)\" ";
339
376
            $final_install_lines .= "$program\_OBJECTS=\"\$($program\_final_OBJECTS)\" ";
340
377
            $nofinal_lines .= "$program\_OBJECTS=\"\$($program\_nofinal\_OBJECTS)\" ";
342
379
        } else {
343
380
            $new = "$program\_OBJECTS = " . $realObjs{$program};
344
381
        }
345
 
        substituteLine ($lookup, $new);
 
382
        if($MakefileData =~ m/\n$lookup/) {
 
383
            substituteLine ($lookup, $new);
 
384
        }
 
385
        else {
 
386
            appendLines("$new\n");
 
387
        }
346
388
    }
347
 
    appendLines($final_lines . "all-am");
348
 
    appendLines($final_install_lines . "install-am");
349
 
    appendLines($nofinal_lines . "all-am");
350
 
    appendLines($nofinal_install_lines . "install-am");
351
 
    
352
 
    my $lookup = 'DEP_FILES\s*=([^\n]*)';
353
 
    if ($MakefileData =~ /\n$lookup\n/o) {
354
 
        $depfiles = $1;
355
 
        
 
389
    appendLines($final_lines . "all-am\n");
 
390
    appendLines($final_install_lines . "install-am\n");
 
391
    appendLines($nofinal_lines . "all-am\n");
 
392
    appendLines($nofinal_install_lines . "install-am\n");
 
393
 
 
394
    my $lookup = '(\@\S+\@)?DEP_FILES\s*=[ \t]*(.*)';
 
395
    if ($MakefileData =~ /\n$lookup/) {
 
396
        my $condition = $1;
 
397
        my $depfiles = $2;
 
398
        my $workfiles;
 
399
 
356
400
        if ($dep_finals) {
357
 
            $lines  = "\@KDE_USE_FINAL_TRUE\@DEP_FILES = $dep_files $dep_finals \034\t$depfiles\n";
358
 
            $lines .= "\@KDE_USE_FINAL_FALSE\@DEP_FILES = $dep_files $depfiles\n";
 
401
            # Add the conditions on every line, since
 
402
            # there may be line continuations in the list.
 
403
            $workfiles = "$dep_files $dep_finals $depfiles";
 
404
            $workfiles =~ s/\034/\034$condition\@KDE_USE_FINAL_TRUE\@\t/g;
 
405
            $lines  = "$condition\@KDE_USE_FINAL_TRUE\@DEP_FILES = $workfiles\n";
 
406
            $workfiles = "$dep_files $depfiles";
 
407
            $workfiles =~ s/\034/\034$condition\@KDE_USE_FINAL_FALSE\@\t/g;
 
408
            $lines .= "$condition\@KDE_USE_FINAL_FALSE\@DEP_FILES = $workfiles";
359
409
        } else {
360
 
            $lines = "DEP_FILES = $dep_files $depfiles\n";
 
410
            $workfiles = "$dep_files $depfiles";
 
411
            $workfiles =~ s/\034/\034$condition\t/g;
 
412
            $lines = $condition . "DEP_FILES = $workfiles";
361
413
        }
362
 
        
363
414
        substituteLine($lookup, $lines);
364
415
    }
365
 
    
 
416
 
 
417
    # new recursive targets
 
418
    $target_adds{ "nmcheck" } .= ""; # always create nmcheck target
 
419
    $target_adds{ "nmcheck-am" } .= "nmcheck";
 
420
    $lookup = 'RECURSIVE_TARGETS\s*=[ \t]*(.*)';
 
421
    if ($MakefileData =~ /\n$lookup/) {
 
422
      substituteLine($lookup, "RECURSIVE_TARGETS = $1 nmcheck-recursive bcheck-recursive");
 
423
    }
 
424
 
366
425
    my $cvs_lines = "cvs-clean:\n";
367
 
    $cvs_lines .= "\t\$(MAKE) -f \$(top_srcdir)/admin/Makefile.common cvs-clean\n";
 
426
    $cvs_lines .= "\t\$(MAKE) admindir=\$(top_srcdir)/admin -f \$(top_srcdir)/admin/Makefile.common cvs-clean\n";
368
427
    appendLines($cvs_lines);
369
 
    
 
428
 
370
429
    $cvs_lines  = "kde-rpo-clean:\n";
371
430
    $cvs_lines .= "\t-rm -f *.rpo\n";
372
431
    appendLines($cvs_lines);
373
432
    $target_adds{"clean"} .= "kde-rpo-clean ";
374
433
 
 
434
    my %target_dels = ("install-data-am" => "");
 
435
 
375
436
    # some strange people like to do a install-exec, and expect that also
376
437
    # all modules are installed.  automake doesn't know this, so we need to move
377
438
    # this here from install-data to install-exec.
378
439
    if ($MakefileData =~ m/\nkde_module_LTLIBRARIES\s*=/) {
379
 
      $target_adds{"install-exec-am"} .= "install-kde_moduleLTLIBRARIES";
380
 
      my $lookup = 'install-data-am:\s*(.*)';
381
 
      if ($MakefileData =~ /\n$lookup\n/) {
382
 
        my $newdeps = $1;
383
 
        $newdeps =~ s/\s*install-kde_moduleLTLIBRARIES\s*/ /g;
384
 
        substituteLine($lookup, "install-data-am: " . $newdeps);
 
440
#      $target_adds{"install-exec-am"} .= "install-kde_moduleLTLIBRARIES ";
 
441
#      don't use $target_adds here because we need to append the dependency, not
 
442
#      prepend it. Fixes #44342 , when a module depends on a lib in the same dir
 
443
#      and libtool needs it during relinking upon install (Simon)
 
444
      my $lookup = "install-exec-am:([^\n]*)";
 
445
      if($MakefileData =~ /\n$lookup\n/) {
 
446
        substituteLine("$lookup", "install-exec-am: $1 install-kde_moduleLTLIBRARIES");
385
447
      }
 
448
      $target_dels{"install-data-am"} .= "install-kde_moduleLTLIBRARIES ";
 
449
      $target_adds{"install-data-am"} .= " ";
386
450
    }
387
 
    
 
451
 
388
452
    my $lines = "";
389
453
 
390
454
    foreach $add (keys %target_adds) {
391
455
        my $lookup = quotemeta($add) . ':([^\n]*)';
392
456
        if ($MakefileData =~ /\n$lookup\n/) {
393
 
            substituteLine($lookup, "$add: " . $target_adds{$add} . $1);
 
457
          my $newlines = $1;
 
458
          my $oldlines = $lookup;
 
459
          if (defined $target_dels{$add}) {
 
460
            foreach $del (split(' ', $target_dels{$add})) {
 
461
              $newlines =~ s/\s*$del\s*/ /g;
 
462
            }
 
463
          }
 
464
          substituteLine($oldlines, "$add: " . $target_adds{$add} . $newlines);
394
465
        } else {
395
 
            $lines .= "$add: " . $target_adds{$add} . "\n";
 
466
          $lines .= "$add: " . $target_adds{$add} . "\n";
396
467
        }
397
468
    }
398
 
    if ($lines) {
399
 
        appendLines($lines);
400
 
    }
 
469
 
 
470
    appendLines($lines) if ($lines);
 
471
 
 
472
    $lines = join("\n", values %rule_adds);
 
473
    appendLines($lines) if ($lines);
401
474
 
402
475
    my $found = 1;
403
 
    
 
476
 
404
477
    while ($found) {
405
478
        if ($MakefileData =~ m/\n(.*)\$\(CXXFLAGS\)(.*)\n/) {
406
 
            my $vor = $1;   # "vor" means before in German
407
 
            my $nach = $2; # "nach" means after in German
 
479
            my $stuff_before = $1;
 
480
            my $stuff_after = $2;
408
481
            my $lookup = quotemeta("$1\$(CXXFLAGS)$2");
409
482
            my $replacement = "$1\$(KCXXFLAGS)$2";
410
483
            $MakefileData =~ s/$lookup/$replacement/;
411
484
            $lookup =~ s/\\\$\\\(CXXFLAGS\\\)/\\\$\\\(KCXXFLAGS\\\)/;
412
 
            $replacement = "$vor\$(KCXXFLAGS) \$(KDE_CXXFLAGS)$nach";
 
485
            $replacement = "$stuff_before\$(KCXXFLAGS) \$(KDE_CXXFLAGS)$stuff_after";
413
486
            substituteLine($lookup, $replacement);
414
487
        } else {
415
488
            $found = 0;
416
489
        }
417
490
    }
418
491
 
419
 
    $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=link) (\$\(CXXLD\).*\$\(KCXXFLAGS\))';
420
 
    
421
 
    if ($MakefileData =~ m/$lookup/ ) {
422
 
        $MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
423
 
    }
424
 
 
425
 
    $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=compile) (\$\(CXX\).*\$\(KCXXFLAGS\))';
426
 
    if ($MakefileData =~ m/$lookup/ ) {
427
 
        $MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
 
492
    if($foreign_libtool == 0) {
 
493
        $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=link) (\$\(CXXLD\).*\$\(KCXXFLAGS\))';
 
494
 
 
495
        if ($MakefileData =~ m/$lookup/ ) {
 
496
            $MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
 
497
        }
 
498
 
 
499
        $lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=compile)\s+(\$\(CXX\)\s+)';
 
500
        if ($MakefileData =~ m/$lookup/ ) {
 
501
            $MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
 
502
        }
428
503
    }
429
504
 
430
505
    $MakefileData =~ s/\$\(KCXXFLAGS\)/\$\(CXXFLAGS\)/g;
441
516
 
442
517
#-----------------------------------------------------------------------------
443
518
 
 
519
# Beware: This procedure is not complete.  E.g. it also parses lines
 
520
# containing a '=' in rules (for instance setting shell vars).  For our
 
521
# usage this us enough, though.
 
522
sub read_variables ()
 
523
{
 
524
    while ($MakefileData =~ /\n\s*(\S+)\s*=([^\n]*)/g) {
 
525
        $varcontent{$1} = $2;
 
526
    }
 
527
}
 
528
 
444
529
# Check to see whether we should process this make file.
445
530
# This is where we look for tags that we need to process.
446
531
# A small amount of initialising on the tags is also done here.
453
538
    }
454
539
 
455
540
    # Checking for files to process...
456
 
    open (FILEIN, $makefile)
457
 
      || die "Could not open $makefileDir/$makefile: $!\n";
 
541
 
 
542
    open (FILEIN, $makefile) || die "Can't open $makefileDir/$makefile: $!\n";
 
543
    # perl bug in 5.8.0: in utf8 mode it badly screws up
 
544
    binmode(FILEIN, ":bytes") if ($] >= 5.008);
458
545
    # Read the file
459
546
    # stat(FILEIN)[7] might look more elegant, but is slower as it 
460
547
    # requires stat'ing the file
467
554
 
468
555
    # Remove the line continuations, but keep them marked
469
556
    # Note: we lose the trailing spaces but that's ok.
470
 
    $MakefileData =~ s/\\\s*\n\s*/\034/g;
 
557
    # Don't mangle line-leading spaces (usually tabs)
 
558
    # since they're important.
 
559
    $MakefileData =~ s/\\\s*\n/\034/g;
471
560
 
472
561
    # If we've processed the file before...
473
562
    restoreMakefile ()      if ($MakefileData =~ /$progId/);
481
570
    %kdeopts = ();
482
571
    $kdeopts{"foreign"} = 0;
483
572
    $kdeopts{"qtonly"} = 0;
 
573
    $kdeopts{"noautodist"} = 0;
 
574
    $kdeopts{"foreign-libtool"} = $foreign_libtool;
484
575
    $kdeopts{"nofinal"} = !$use_final; # default
485
576
 
486
 
    if ($MakefileData =~ /\nKDE_OPTIONS\s*=\s*([^\n]*)\n/) {
487
 
        local @kde_options = split(/[\s\034]/, $1);
 
577
    read_variables();
 
578
 
 
579
    if ($MakefileData =~ /\nKDE_OPTIONS\s*=[ \t]*([^\n]*)\n/) {
 
580
        my $kde_options_str = $1;
 
581
        local @kde_options = split(/[\034\s]+/, $kde_options_str);
488
582
        if (grep(/^foreign$/, @kde_options)) {
489
583
            push(@foreignfiles, $makefileDir . "/");
490
584
            return 0; # don't touch me
511
605
      }
512
606
 
513
607
    while ($MakefileData =~ /\n\.SUFFIXES:([^\n]+)\n/g) {
514
 
        my @list=split(' ', $1);
 
608
        my $suffixes_str = $1;
 
609
        my @list=split(' ', $suffixes_str);
515
610
        foreach $ext (@list) {
516
611
            if ($ext =~ /^\.$cppExt$/) {
517
612
                $cxxsuffix = $ext;
521
616
            }
522
617
        }
523
618
    }
524
 
                                                     
525
 
    while ($MakefileData =~ /\n(\S*)_OBJECTS\s*=[ \t\034]*([^\n]*)\n/g) {
526
 
        
 
619
 
 
620
    tag_KDEINIT();
 
621
 
 
622
    while ($MakefileData =~ /\n(\S*)_OBJECTS\s*=[\034 \t]*([^\n]*)\n/g) {
 
623
 
527
624
        my $program = $1;
528
625
        my $objs = $2; # safe them
529
 
        
 
626
 
530
627
        my $ocv = 0;
531
 
        
532
 
        my @objlist = split(/[\s\034]+/, $objs);
 
628
 
 
629
        my @objlist = split(/[\034\s]+/, $objs);
533
630
        foreach $obj (@objlist) {
534
 
            if ($obj =~ /\$\((\S+)\)/ ) {
535
 
                my $variable = $1;
536
 
                if ($variable !~ 'OBJEXT') {
 
631
            if ($obj =~ /(\S*)\$\((\S+)\)/ ) {
 
632
                my $pre = $1;
 
633
                my $variable = $2;
 
634
                if ($pre eq '' && exists($varcontent{$variable})) {
 
635
                    my @addlist = split(/[\034\s]+/, $varcontent{$variable});
 
636
                    push(@objlist, @addlist);
 
637
                } elsif ($variable !~ 'OBJEXT') {
537
638
                    $ocv = 1;
538
 
                }
 
639
                }
539
640
            }
540
641
        }
541
 
        
 
642
 
542
643
        next if ($ocv);
 
644
        next if ($program =~ /^am_libkdeinit_/);
543
645
 
544
646
        $program =~ s/^am_// if ($program =~ /^am_/);
545
 
        
 
647
 
546
648
        my $sourceprogram = $program;
547
649
        $sourceprogram =~ s/\@am_/\@/ if($sourceprogram =~ /^.*\@am_.+/);
548
 
        
 
650
 
549
651
        print STDOUT "found program $program\n" if ($verbose);
550
652
        push(@programs, $program);
551
 
        
 
653
 
552
654
        $realObjs{$program} = $objs;
553
 
        
554
 
        if ($MakefileData =~ /\n$sourceprogram\_SOURCES\s*=\s*(.*)\n/) {
 
655
 
 
656
        if ($MakefileData =~ /\n$sourceprogram\_SOURCES\s*=[ \t]*(.*)\n/) {
555
657
            $sources{$program} = $1;
556
658
        } 
557
659
        else {
568
670
            $realname{$program} = "";
569
671
        }
570
672
    }
571
 
    
572
 
    my $lookup = '\nDEPDIR\s*=.*';
573
 
    if ($MakefileData !~ /($lookup)\n/o) {
574
 
        $lookup = '\nbindir\s*=.*';
575
 
        if ($MakefileData =~ /($lookup)\n/) {
576
 
            substituteLine ($lookup, "DEPDIR = .deps\n$1");
577
 
        }
578
 
    } 
 
673
 
 
674
    my $lookup = 'DEPDIR\s*=.*';
 
675
    if ($MakefileData !~ /\n$lookup/) {
 
676
        $lookup = 'bindir\s*=[ \t]*.*';
 
677
        substituteLine($lookup, "DEPDIR = .deps\n$1") if ($MakefileData =~ /\n($lookup)/);
 
678
    }
579
679
 
580
680
    my @marks = ('MAINTAINERCLEANFILES', 'CLEANFILES', 'DISTCLEANFILES');
581
681
    foreach $mark (@marks) {
582
 
        while ($MakefileData =~ /\n($mark)\s*=\s*([^\n]*)/g) {
583
 
            foreach $file (split('[\034\s]', $2)) {
 
682
        while ($MakefileData =~ /\n($mark)\s*=[ \t]*([^\n]*)/g) {
 
683
            my $clean_str = $2; 
 
684
            foreach $file (split('[\034\s]+', $clean_str)) {
584
685
                $file =~ s/\.\///;
585
686
                push(@cleanfiles, $file);
586
687
            }
599
700
# header files could be located.
600
701
sub tag_META_INCLUDES ()
601
702
{
602
 
    my $lookup = '[^=\n]*META_INCLUDES\s*=\s*(.*)';
603
 
    return 1    if ($MakefileData !~ /($lookup)\n/o);
 
703
    my $lookup = '[^=\n]*META_INCLUDES\s*=[ \t]*(.*)';
 
704
    return 1    if ($MakefileData !~ /($lookup)\n/);
604
705
    print STDOUT "META_INCLUDE processing <$1>\n"       if ($verbose);
605
706
 
606
707
    my $headerStr = $2;
607
708
    removeLine ($lookup, $1);
608
709
 
609
 
    $headerStr =~ tr/\034/ /;
610
 
    my @headerlist = split(' ', $headerStr);
 
710
    my @headerlist = split(/[\034\s]+/, $headerStr);
611
711
 
612
712
    foreach $dir (@headerlist)
613
713
    {
638
738
            print STDOUT "found ( in $program\_SOURCES. skipping\n" if ($verbose);
639
739
            next;
640
740
        }
641
 
        
642
 
        my $mocsources = "";
643
 
        
644
 
        my @progsources = split(/[\s\034]+/, $sources{$program});
 
741
 
 
742
        my $mocs = "";       # Moc files (in this program)
 
743
        my $moc_cpp_added = 0;  # If we added some .moc.cpp files, due to
 
744
                                # no other .cpp file including the .moc one.
 
745
        
 
746
        my @progsources = split(/[\034\s]+/, $sources{$program});
 
747
        my %shash = ();
 
748
        @shash{@progsources} = 1;  # we are only interested in the existence
645
749
        my %sourcelist = ();
 
750
        my %extradeps = ();
646
751
        
647
752
        foreach $source (@progsources) {
648
753
            my $suffix = $source;
649
754
            $suffix =~ s/^.*\.([^\.]+)$/$1/;
650
755
            
651
 
            if (defined($sourcelist{$suffix})) {
652
 
                $sourcelist{$suffix} .= " " . $source;
 
756
            $sourcelist{$suffix} .= "$source ";
 
757
        }
 
758
        foreach my $mocFile (keys (%globalmocs))
 
759
        {
 
760
            my ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3);
 
761
            if (defined ($cppFile)) {
 
762
                $mocs .= " $mocFile.moc" if exists $shash{$cppFile};
653
763
            } else {
654
 
                $sourcelist{$suffix} .= $source;
655
 
            }
656
 
        }
657
 
        
 
764
                $sourcelist{$cxxsuffix} .= "$mocFile.moc.$cxxsuffix ";
 
765
                $moc_cpp_added = 1;
 
766
            }
 
767
        }
 
768
 
 
769
        # scan for extra given dependencies and add them to our target
 
770
        while ($MakefileData =~ /\n\s*(\S+)\.(?:lo|o)\s*:([^\n]*)/g) {
 
771
            $extradeps{$1} = $2;
 
772
        }
 
773
 
658
774
        foreach $suffix (keys %sourcelist) {
659
 
            
660
 
            # See if this file contains c++ code. (ie Just check the files suffix against
 
775
            # See if this file contains c++ code. (i.e., just check the file's suffix against c++ extensions)
661
776
            my $suffix_is_cxx = 0;
662
777
            if($suffix =~ /($cppExt)$/) {
663
778
              $cxxsuffix = $1;
664
779
              $suffix_is_cxx = 1;
665
780
            }
666
781
            
667
 
            my $mocfiles_in = ($suffix eq $cxxsuffix) &&
668
 
              defined($depedmocs{$program});
 
782
            my $mocfiles_in = ($suffix eq $cxxsuffix) && $moc_cpp_added;
669
783
            
670
 
            my @sourcelist = split(/[\s\034]+/, $sourcelist{$suffix});
 
784
            my @sourcelist = split(/[\034\s]+/, $sourcelist{$suffix});
671
785
            
672
786
            if ((@sourcelist == 1 && !$mocfiles_in) || $suffix_is_cxx != 1 ) {
673
787
                
674
788
                # we support IDL on our own
675
 
                if ($suffix =~ /^skel$/ || $suffix =~ /^stub/ || $suffix =~ /^h$/
676
 
                    || $suffix =~ /^ui$/ ) {
 
789
                if ($suffix eq "skel" || $suffix =~ /^stub/
 
790
                    || $suffix =~ /^signals/ # obsolete, remove in KDE-4
 
791
                    || $suffix eq "h" || $suffix eq "ui" 
 
792
                    || $suffix eq "kcfgc" ) {
677
793
                    next;
678
794
                }
679
795
                
680
796
                foreach $file (@sourcelist) {
681
 
                    
682
797
                    $file =~ s/\Q$suffix\E$//;
683
798
                    
684
799
                    $finalObjs{$program} .= $file;
694
809
            my $source_deps = "";
695
810
            foreach $source (@sourcelist) {
696
811
                if (-f $source) {
697
 
                    $source_deps .= "\$(srcdir)/$source ";
 
812
                    $source_deps .= " \$(srcdir)/$source";
698
813
                } else {
699
 
                    $source_deps .= "$source ";
700
 
                }
701
 
            }
702
 
            
703
 
            $handling = "$program.all_$suffix.$suffix: \$(srcdir)/Makefile.in " . $source_deps . " ";
704
 
            
705
 
            if ($mocfiles_in) {
706
 
                $handling .= $depedmocs{$program};
707
 
                foreach $mocfile (split(' ', $depedmocs{$program})) {
708
 
                   
709
 
                    if ($mocfile =~ m/\.$suffix$/) {
710
 
                        $mocsources .= " " . $mocfile;
711
 
                    }
712
 
                }
713
 
            }
714
 
            
715
 
            $handling .= "\n";
 
814
                    $source_deps .= " $source";
 
815
                }
 
816
                my $plainsource = $source;
 
817
                $plainsource =~ s/\.$cppExt$//;
 
818
                $source_deps .= " " . $extradeps{$plainsource} if (exists($extradeps{$plainsource}));
 
819
            }
 
820
 
 
821
            $handling = "$program.all_$suffix.$suffix: \$(srcdir)/Makefile.in" . $source_deps . " " . join(' ', $mocs)  . "\n";
716
822
            $handling .= "\t\@echo 'creating $program.all_$suffix.$suffix ...'; \\\n";
717
823
            $handling .= "\trm -f $program.all_$suffix.files $program.all_$suffix.final; \\\n";
718
824
            $handling .= "\techo \"#define KDE_USE_FINAL 1\" >> $program.all_$suffix.final; \\\n";
719
 
            $handling .= "\tfor file in " . $sourcelist{$suffix} . " $mocsources; do \\\n";
 
825
            $handling .= "\tfor file in " . $sourcelist{$suffix} . "; do \\\n";
720
826
            $handling .= "\t  echo \"#include \\\"\$\$file\\\"\" >> $program.all_$suffix.files; \\\n";
721
827
            $handling .= "\t  test ! -f \$\(srcdir\)/\$\$file || egrep '^#pragma +implementation' \$\(srcdir\)/\$\$file >> $program.all_$suffix.final; \\\n";
722
828
            $handling .= "\tdone; \\\n";
723
 
            $handling .= "\tcat $program.all_$suffix.final $program.all_$suffix.files  > $program.all_$suffix.$suffix; \\\n";
 
829
            $handling .= "\tcat $program.all_$suffix.final $program.all_$suffix.files > $program.all_$suffix.$suffix; \\\n";
724
830
            $handling .= "\trm -f $program.all_$suffix.final $program.all_$suffix.files\n";
725
 
            
 
831
 
726
832
            appendLines($handling);
727
 
            
 
833
 
728
834
            push(@final_names, "$program.all_$suffix.$suffix");
729
 
            $finalObjs{$program} .= "$program.all_$suffix.";
 
835
            my $finalObj = "$program.all_$suffix.";
730
836
            if ($program =~ /_la$/) {
731
 
                $finalObjs{$program} .= "lo ";
 
837
                $finalObj .= "lo";
732
838
            } else {
733
 
                $finalObjs{$program} .= "o ";
 
839
                $finalObj .= "o";
734
840
            }
 
841
            $finalObjs{$program} .= $finalObj . " ";
735
842
        }
736
843
    }
737
844
    
749
856
    }
750
857
}
751
858
 
 
859
sub tag_KDEINIT()
 
860
{
 
861
    my @progs = ();
 
862
    my $ltlibs = "";
 
863
    my $lookup = 'kdeinit_LTLIBRARIES\s*=[ \t]*(.*)';
 
864
 
 
865
    if ($MakefileData =~ m/\n$lookup/) {
 
866
        @kdeinits = split(/[\034\s]+/, $1);
 
867
        my $lines = "";
 
868
        foreach my $kdeinit (@kdeinits) {
 
869
            if ($kdeinit =~ m/\.la$/) {
 
870
                $kdeinit =~ s/\.la$//;
 
871
                push(@progs, $kdeinit);
 
872
 
 
873
                $lines .= "\n${kdeinit}.la.$cxxsuffix:\n";
 
874
                $lines .= "\techo 'extern \"C\" int kdemain(int argc, char* argv[]);' > ${kdeinit}.la.$cxxsuffix; \\\n";
 
875
                $lines .= "\techo 'int main(int argc, char* argv[]) { return kdemain(argc,argv); }' >> ${kdeinit}.la.$cxxsuffix\n";
 
876
 
 
877
                $lines .= "\n${kdeinit}_dummy.$cxxsuffix:\n";
 
878
                $lines .= "\techo 'extern \"C\" int kdemain(int argc, char* argv[]);' > ${kdeinit}_dummy.$cxxsuffix; \\\n";
 
879
                $lines .= "\techo 'extern \"C\" int kdeinitmain(int argc, char* argv[]) { return kdemain(argc,argv); }' >> ${kdeinit}_dummy.$cxxsuffix\n";
 
880
 
 
881
                push(@cleanfiles, "${kdeinit}.la.$cxxsuffix");
 
882
                push(@cleanfiles, "${kdeinit}_dummy.$cxxsuffix");
 
883
 
 
884
                # add dependency
 
885
                $dep_files .= " \$(DEPDIR)/${kdeinit}.la.Po" if($dep_files !~/${kdeinit}.la.Po/ );
 
886
                $dep_files .= " \$(DEPDIR)/${kdeinit}_dummy.Plo" if($dep_files !~/${kdeinit}_dummy.Plo/ );
 
887
 
 
888
                # make library
 
889
                $lookup = $kdeinit . '_la_LIBADD\s*=[ \t]*(.*)';
 
890
                if($MakefileData =~ m/\n$lookup/) {
 
891
                    my $libadd = $1;
 
892
                    substituteLine($lookup, "${kdeinit}_la_LIBADD = libkdeinit_${kdeinit}.la");
 
893
                    appendLines("libkdeinit_${kdeinit}_la_LIBADD = $libadd\n");
 
894
                }
 
895
                appendLines("libkdeinit_${kdeinit}_la_LDFLAGS = -no-undefined -avoid-version \$(all_libraries)\n");
 
896
 
 
897
                # add library dependencies
 
898
                $lookup = $kdeinit . '_la_DEPENDENCIES\s*=[ \t]*(.*)';
 
899
                if($MakefileData =~ m/\n$lookup/) {
 
900
                    my $libdeps = $1;
 
901
                    substituteLine($lookup, "${kdeinit}_la_DEPENDENCIES = libkdeinit_${kdeinit}.la");
 
902
                    appendLines("libkdeinit_${kdeinit}_la_DEPENDENCIES = $libdeps\n");
 
903
                }
 
904
 
 
905
                # make library objects
 
906
                $lookup = "am_${kdeinit}_la_OBJECTS" . '\s*=[ \t]*(.*)';
 
907
                if($MakefileData =~ m/\n$lookup/) {
 
908
                    my $libobjects = $1;
 
909
                    substituteLine($lookup, "am_${kdeinit}_la_OBJECTS = ${kdeinit}_dummy.lo");
 
910
                    appendLines("am_libkdeinit_${kdeinit}_la_OBJECTS = $libobjects\n");
 
911
                    my $prog = "libkdeinit_${kdeinit}_la";
 
912
                    push(@programs, $prog);
 
913
                    $realObjs{$prog} = $libobjects;
 
914
                    $realname{$prog} = "libkdeinit_${kdeinit}.la";
 
915
                }
 
916
                $target_adds{"libkdeinit_${kdeinit}.la"} = "\$(libkdeinit_${kdeinit}_la_OBJECTS) \$(libkdeinit_${kdeinit}_la_DEPENDENCIES)\n" .
 
917
                        "\t\$(CXXLINK) -rpath \$(libdir) \$(libkdeinit_${kdeinit}_la_LDFLAGS) ".
 
918
                           "\$(libkdeinit_${kdeinit}_la_OBJECTS) " .
 
919
                           "\$(libkdeinit_${kdeinit}_la_LIBADD) " .
 
920
                           "\$(LIBS)\n";
 
921
 
 
922
                # make libkdeinit sources
 
923
                $lookup = $kdeinit . '_la_SOURCES\s*=[ \t]*(.*)';
 
924
                if($MakefileData =~ m/\n$lookup/) {
 
925
                    my $srces = $1;
 
926
                    $sources_changed{"libkdeinit_${kdeinit}_la"} = 1;
 
927
                    $sources{"libkdeinit_${kdeinit}_la"} = $srces;
 
928
                }
 
929
 
 
930
                # make libkdeinit metasources
 
931
                $lookup = $kdeinit . '_la_METASOURCES\s*=[ \t]*(.*)';
 
932
                substituteLine($lookup, "libkdeinit_${kdeinit}_la_METASOURCES = $1")
 
933
                    if($MakefileData =~ m/\n$lookup/);
 
934
 
 
935
=cut
 
936
                # make binary sources
 
937
                $lookup = $kdeinit. '_SOURCES\s*=[ \t]*(.*)';
 
938
                if($MakefileData =~ m/\n$lookup/) {
 
939
                    substituteLine($lookup, "${kdeinit}_SOURCES = ${kdeinit}.la.$cxxsuffix");
 
940
                    $lookup = 'SOURCES\s*=[ \t]*(.*)';
 
941
                    if($MakefileData =~ m/\n$lookup/) {
 
942
                        my $srces = $1;
 
943
                        $srces =~ s/\b$kdeinit\.c\b/\$(${kdeinit}_SOURCES)/;
 
944
                        $srces =~ s/\$\(${kdeinit}_la_SOURCES\)/\$(libkdeinit_${kdeinit}_la_SOURCES)/;
 
945
                        substituteLine($lookup, "SOURCES = $srces");
 
946
                    }
 
947
                    $lookup = 'DIST_SOURCES\s*=[ \t](.*)';
 
948
                    if($MakefileData =~ m/\n$lookup/) {
 
949
                        my $srces = $1;
 
950
                        $srces =~ s/\b$kdeinit\.c\b/\$(${kdeinit}_SOURCES)/;
 
951
                        $srces =~ s/\$\(${kdeinit}_la_SOURCES\)/\$(libkdeinit_${kdeinit}_la_SOURCES)/;
 
952
                        substituteLine($lookup, "DIST_SOURCES = $srces");
 
953
                    }
 
954
                }
 
955
 
 
956
                # make binary objects / libs
 
957
                $lookup = $kdeinit . '_OBJECTS\s*=[ \t]*.*';
 
958
                if($MakefileData =~ m/\n$lookup/) {
 
959
                    $realObjs{$kdeinit} = "${kdeinit}.la.\$(OBJEXT)";
 
960
                    substituteLine("${kdeinit}_LDFLAGS\\s*=.*", "${kdeinit}_LDFLAGS = \$(all_libraries)");
 
961
                    substituteLine("${kdeinit}_LDADD\\s*=.*", "${kdeinit}_LDADD = libkdeinit_${kdeinit}.la");
 
962
                    substituteLine("${kdeinit}_DEPENDENCIES\\s*=.*", "${kdeinit}_DEPENDENCIES = libkdeinit_${kdeinit}.la");
 
963
                }
 
964
=cut
 
965
                # add binary
 
966
                push(@programs, $kdeinit);
 
967
                $realObjs{$kdeinit} = "${kdeinit}.la.\$(OBJEXT)";
 
968
                $realname{$kdeinit} = $kdeinit;
 
969
                $sources{$kdeinit} = "${kdeinit}.la.$cxxsuffix";
 
970
 
 
971
                $lines .= "${kdeinit}_LDFLAGS = \$(KDE_RPATH) -no-undefined \$(all_libraries)\n";
 
972
                $lines .= "${kdeinit}_LDADD = libkdeinit_${kdeinit}.la\n";
 
973
                $lines .= "${kdeinit}_DEPENDENCIES = libkdeinit_${kdeinit}.la\n";
 
974
 
 
975
                $target_adds{"${kdeinit}\$(EXEEXT)"} =
 
976
                          "\$(${kdeinit}_OBJECTS) \$(${kdeinit}_DEPENDENCIES)\n" .
 
977
                          "\t\@rm -f ${kdeinit}\$(EXEEXT)\n" .
 
978
                          "\t\$(CXXLINK) \$(${kdeinit}_LDFLAGS) \$(${kdeinit}_OBJECTS) \$(${kdeinit}_LDADD) \$(LIBS)\n";
 
979
 
 
980
                $ltlibs .= " libkdeinit_${kdeinit}.la";
 
981
            }
 
982
        }
 
983
        appendLines($lines);
 
984
 
 
985
        # add libkdeinit target
 
986
        $lookup = 'lib_LTLIBRARIES\s*=[ \t]*(.*)';
 
987
        if($MakefileData =~ m/\n$lookup/) {
 
988
            substituteLine($lookup, "lib_LTLIBRARIES = $1 $ltlibs");
 
989
        }
 
990
        else {
 
991
            print STDERR
 
992
                "Error: lib_LTLIBRARIES missing in $printname (required for kdeinit_LTLIBRARIES).\n";
 
993
            $errorflag = 1;
 
994
        }
 
995
    }
 
996
 
 
997
    if($#progs >= 0) {
 
998
        if($MakefileData !~ m/\nbin_PROGRAMS\s*=/) {
 
999
            print STDERR "Error: bin_PROGRAMS missing in $printname (required for kdeinit_LTLIBRARIES).\n";
 
1000
            $errorflag = 1;
 
1001
        }
 
1002
        else {
 
1003
            # add our new progs to SOURCES, DIST_SOURCES and bin_PROGRAMS
 
1004
            my $progsources = "";
 
1005
            my $progexes = "";
 
1006
            foreach my $p (@progs) {
 
1007
                $progsources .= "\$(${p}_SOURCES) ";
 
1008
                $progexes .= "${p}\$(EXEEXT) ";
 
1009
            }
 
1010
            $lookup = 'SOURCES\s*=[ \t]*(.*)';
 
1011
            if($MakefileData =~ /\n$lookup/) {
 
1012
                substituteLine($lookup, "SOURCES = $1 $progsources");
 
1013
            }
 
1014
            $lookup = 'DIST_SOURCES\s*=[ \t]*(.*)';
 
1015
            if($MakefileData =~ /\n$lookup/) {
 
1016
                substituteLine($lookup, "DIST_SOURCES = $1 $progsources");
 
1017
            }
 
1018
            # bin_PROGRAMS is complicated, as it exists twice, so we do a little
 
1019
            # magic trick here
 
1020
            $lookup = 'PROGRAMS\s*=[ \t]*(.*)';
 
1021
            if ($MakefileData =~ /\n$lookup/) {
 
1022
                substituteLine($lookup, "bin_PROGRAMS += $progexes\nPROGRAMS = $1");
 
1023
            }
 
1024
        }
 
1025
    }
 
1026
}
 
1027
 
 
1028
#-----------------------------------------------------------------------------
 
1029
 
 
1030
sub tag_COMPILE_FIRST()
 
1031
{
 
1032
  foreach $program (@programs) {
 
1033
    my $lookup = "$program" . '_COMPILE_FIRST\s*=[ \t]*(.*)';
 
1034
    if ($MakefileData =~ m/\n$lookup\n/) {
 
1035
      my $compilefirst_str = $1;
 
1036
      my @compilefirst = split(/[\034\s]+/, $compilefirst_str);
 
1037
      my @progsources = split(/[\034\s]+/, $sources{$program});
 
1038
      my %donesources = ();
 
1039
      foreach $source (@progsources) {
 
1040
        my @deps  = ();
 
1041
        my $sdeps = "";
 
1042
        if (-f $source) {
 
1043
          $sdeps = "\$(srcdir)/$source";
 
1044
        } else {
 
1045
          $sdeps = "$source";
 
1046
        }
 
1047
        foreach $depend (@compilefirst) {
 
1048
          next if ($source eq $depend);
 
1049
          # avoid cyclic dependencies
 
1050
          next if defined($donesources{$depend});
 
1051
          push @deps, $depend;
 
1052
        }
 
1053
        $target_adds{$sdeps} .= join(' ', @deps) . ' ' if (@deps);
 
1054
        $donesources{$source} = 1;
 
1055
      }
 
1056
    }
 
1057
  }
 
1058
}
 
1059
 
 
1060
#-----------------------------------------------------------------------------
 
1061
 
 
1062
 
752
1063
# Organises the list of headers that we'll use to produce moc files
753
1064
# from.
754
1065
sub tag_METASOURCES ()
755
1066
{
756
1067
    local @newObs           = ();  # here we add to create object files
757
 
    local @deped            = ();  # here we add to create moc files
 
1068
    local @depend           = ();  # here we add to create moc files
758
1069
    local $mocExt           = ".moc";
759
1070
    local %mocFiles         = ();
760
1071
 
763
1074
 
764
1075
    my $lookup;
765
1076
    my $found = "";
766
 
 
767
1077
    if ($metasourceTags > 1) {
768
1078
        $lookup = $program . '_METASOURCES\s*=\s*(.*)';
769
1079
        return 1    if ($MakefileData !~ /\n($lookup)\n/);
772
1082
        $lookup = $program . '_METASOURCES\s*=\s*(.*)';
773
1083
        if ($MakefileData !~ /\n($lookup)\n/) {
774
1084
            $lookup = 'METASOURCES\s*=\s*(.*)';
775
 
            return 1    if ($MakefileData !~ /\n($lookup)\n/o);
 
1085
            return 1    if ($MakefileData !~ /\n($lookup)\n/);
776
1086
            $found = $1;
777
1087
            $metasourceTags = 0; # we can use the general target only once
778
1088
        } else {
812
1122
    if (@newObs) {
813
1123
        my $ext =  ($program =~ /_la$/) ? ".moc.lo " : ".moc.o ";
814
1124
        $realObjs{$program} .= "\034" . join ($ext, @newObs) . $ext;
815
 
        $depedmocs{$program} = join (".moc.$cxxsuffix " , @newObs) . ".moc.$cxxsuffix";
 
1125
        $dependmocs{$program} = join (".moc.$cxxsuffix " , @newObs) . ".moc.$cxxsuffix";
816
1126
        foreach $file (@newObs) {
817
1127
            $dep_files .= " \$(DEPDIR)/$file.moc.P" if($dep_files !~/$file.moc.P/);
818
1128
        }
819
1129
    }
820
 
    if (@deped) {
821
 
        $depedmocs{$program} .= " ";
822
 
        $depedmocs{$program} .= join('.moc ', @deped) . ".moc";
823
 
        $depedmocs{$program} .= " ";
 
1130
    if (@depend) {
 
1131
        $dependmocs{$program} .= " ";
 
1132
        $dependmocs{$program} .= join('.moc ', @depend) . ".moc";
 
1133
        $dependmocs{$program} .= " ";
824
1134
    }
825
1135
    addMocRules ();
826
1136
    @globalmocs{keys %mocFiles}=values %mocFiles;
832
1142
# Errors are logged in the global $errorflags
833
1143
sub tag_AUTOMAKE ()
834
1144
{
835
 
    my $lookup = '.*cd \$\(top_srcdir\)\s+&&[\s\034]+\$\(AUTOMAKE\)(.*)';
 
1145
    my $lookup = '.*cd \$\(top_srcdir\)\s+&&[\034\s]+\$\(AUTOMAKE\)(.*)';
836
1146
    return 1    if ($MakefileData !~ /\n($lookup)\n/);
837
1147
    print STDOUT "AUTOMAKE processing <$1>\n"        if ($verbose);
838
1148
 
839
1149
    my $newLine = $1."\n\tcd \$(top_srcdir) && perl $thisProg $printname";
 
1150
 
 
1151
    # automake 1.8.x adds another automake call. *sigh*
 
1152
    $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/;
840
1153
    substituteLine ($lookup, $newLine);
841
1154
    $automkCall = $1;
 
1155
 
 
1156
    $lookup = '.*cd \$\(srcdir\)\s+&&[\034\s]+\$\(AUTOCONF\)(.*)';
 
1157
    if ($MakefileData =~ /\n($lookup)\n/) {
 
1158
      $newLine  = "\tcd \$(srcdir) && rm -f configure\n";
 
1159
      $newLine .= "\tcd \$(top_srcdir) && \$(MAKE) -f admin/Makefile.common configure";
 
1160
      substituteLine ($lookup, $newLine);
 
1161
    }
 
1162
 
842
1163
    return 0;
843
1164
}
844
1165
 
899
1220
  }
900
1221
  closedir (THISDIR);
901
1222
 
902
 
  my $lines = "SUBDIRS =$subdirs\n";
903
 
  substituteLine('SUBDIRS\s*=.*', $lines);
 
1223
  substituteLine('SUBDIRS\s*=.*', "SUBDIRS =$subdirs");
904
1224
  return 0;
905
1225
}
906
1226
 
911
1231
    my @cppFiles = ();
912
1232
    
913
1233
    foreach $source (@psources) {
914
 
        
915
1234
        my $skel = ($source =~ m/\.skel$/);
 
1235
        my $stub = ($source =~ m/\.stub$/);
 
1236
        my $signals = ($source =~ m/\.signals$/); # obsolete, remove in KDE-4
916
1237
        
917
 
        if ($source =~ m/\.stub$/ || $skel) {
918
 
            
 
1238
        if ($stub || $skel || $signals) {
 
1239
 
919
1240
            my $qs = quotemeta($source);
920
1241
            $sources{$program} =~ s/$qs//;
921
1242
            $sources_changed{$program} = 1;
922
 
            
923
 
            print STDOUT "adding IDL file $source\n" if ($verbose);
924
 
            
925
 
            $source =~ s/\.(stub|skel)$//;
926
 
            
 
1243
 
 
1244
            $source =~ s/\.(stub|skel|signals)$//;
927
1245
            my $sourcename;
928
 
            
 
1246
 
929
1247
            if ($skel) {
930
1248
                $sourcename = "$source\_skel";
931
 
            } else {
 
1249
            } elsif ($stub) {
932
1250
                $sourcename = "$source\_stub";
 
1251
            } else {
 
1252
                $sourcename = "$source\_signals";
933
1253
            }
934
1254
            
935
1255
            my $sourcedir = '';
944
1264
            
945
1265
            if ($allidls !~ /$source\_kidl/) {
946
1266
                
947
 
                $dep_lines .= "$source.kidl: $sourcedir$source.h \$(DCOPIDL_DEPENDENCIES)\n";
948
 
                $dep_lines .= "\t\$(DCOPIDL) $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; /bin/false )\n";
 
1267
                $use_ng = ($MakefileData =~ /\n$source\_DCOPIDLNG\s*=\s*(\S+)\n/);
 
1268
                $dcopidl =  $use_ng ? "KDECONFIG=\"\$(KDECONFIG)\" \$(DCOPIDLNG)" : "\$(DCOPIDL)";
 
1269
 
 
1270
                $dep_lines .= "$source.kidl: $sourcedir$source.h \$(DCOP_DEPENDENCIES)\n";
 
1271
                $dep_lines .= "\t$dcopidl $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; false )\n";
949
1272
                
950
1273
                $allidls .= $source . "_kidl ";
951
1274
            }
952
1275
            
953
1276
            if ($allidls !~ /$sourcename/) {
954
1277
                
 
1278
                $dep_lines_tmp = "";
 
1279
 
955
1280
                if ($skel) {
956
1281
                    $dep_lines .= "$sourcename.$cxxsuffix: $source.kidl\n";
957
 
                    $dep_lines .= "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-stub $source.kidl\n";
958
 
                } else {
 
1282
                    $dep_lines .= "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-signals --no-stub $source.kidl\n";
 
1283
                } elsif ($stub) {
 
1284
                    $dep_lines_tmp = "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-signals --no-skel $source.kidl\n";
 
1285
                } else { # signals - obsolete, remove in KDE 4
 
1286
                    $dep_lines_tmp = "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-stub --no-skel $source.kidl\n";
 
1287
                }
 
1288
 
 
1289
                if ($stub || $signals) {
959
1290
                    $target_adds{"$sourcename.$cxxsuffix"} .= "$sourcename.h ";
960
1291
                    $dep_lines .= "$sourcename.h: $source.kidl\n";
961
 
                    $dep_lines .= "\t\$(DCOPIDL2CPP) --c++-suffix $cxxsuffix --no-skel $source.kidl\n";
 
1292
                    $dep_lines .= $dep_lines_tmp;
962
1293
                }
963
1294
                
964
1295
                $allidls .= $sourcename . " ";
1008
1339
sub tag_UIFILES ()
1009
1340
{
1010
1341
    my @psources = split(/[\034\s]+/, $sources{$program});
1011
 
    my $dep_lines = "";
1012
1342
    my @depFiles = ();
1013
1343
    
1014
1344
    foreach $source (@psources) {
1030
1360
 
1031
1361
            if (!$uiFiles{$source}) {
1032
1362
 
1033
 
                $dep_lines .= "$source.$cxxsuffix: $sourcedir$source.ui $source.h $source.moc\n";
 
1363
                my $dep_lines = "$source.$cxxsuffix: $sourcedir$source.ui $source.h $source.moc\n";
1034
1364
                $dep_lines .= "\trm -f $source.$cxxsuffix\n";
1035
1365
                if (!$kdeopts{"qtonly"}) {
1036
 
                    $dep_lines .= "\techo '#include <klocale.h>' > $source.$cxxsuffix\n";
1037
 
                    $dep_lines .= "\t\$(UIC) -tr \${UIC_TR} -i $source.h $sourcedir$source.ui | sed -e \"s,\${UIC_TR}( \\\"\\\" ),QString::null,g\" | sed -e \"s,\${UIC_TR}( \\\"\\\"\\, \\\"\\\" ),QString::null,g\" >> $source.$cxxsuffix || rm -f $source.$cxxsuffix\n";
 
1366
                    $dep_lines .= "\techo '#include <kdialog.h>' > $source.$cxxsuffix\n";
 
1367
                    $dep_lines .= "\techo '#include <klocale.h>' >> $source.$cxxsuffix\n";
 
1368
                    my ($mangled_source) = $source;
 
1369
                    $mangled_source =~ s/[^A-Za-z0-9]/_/g;  # get rid of garbage
 
1370
                    $dep_lines .= "\t\$(UIC) -tr \${UIC_TR} -i $source.h $sourcedir$source.ui > $source.$cxxsuffix.temp ; ret=\$\$?; \\\n";
 
1371
                    $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";
 
1372
                    $dep_lines .= "\trm -f $source.$cxxsuffix.temp ;\\\n";
1038
1373
                } else {
1039
 
                    $dep_lines .= "\t\$(UIC) -i $source.h $sourcedir$source.ui > $source.$cxxsuffix || rm -f $source.$cxxsuffix\n";
 
1374
                    $dep_lines .= "\t\$(UIC) -i $source.h $sourcedir$source.ui > $source.$cxxsuffix; ret=\$\$?; \\\n";
1040
1375
                }
1041
 
                $dep_lines .= "\techo '#include \"$source.moc\"' >> $source.$cxxsuffix\n\n";
 
1376
                $dep_lines .= "\tif test \"\$\$ret\" = 0; then echo '#include \"$source.moc\"' >> $source.$cxxsuffix; else rm -f $source.$cxxsuffix ; exit \$\$ret ; fi\n\n";
1042
1377
                $dep_lines .= "$source.h: $sourcedir$source.ui\n";
1043
 
                $dep_lines .= "\t\$(UIC) -o $source.h $sourcedir$source.ui\n\n";
 
1378
                $dep_lines .= "\trm -rf $source.h;\n";
 
1379
                $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";
 
1380
 
1044
1381
                $dep_lines .= "$source.moc: $source.h\n";
1045
1382
                $dep_lines .= "\t\$(MOC) $source.h -o $source.moc\n";
1046
1383
 
 
1384
                $rule_adds{"$source.$cxxsuffix"} = $dep_lines;
 
1385
 
1047
1386
                $uiFiles{$source} = 1;
1048
 
                $depedmocs{$program} .= " $source.moc";
 
1387
                $dependmocs{$program} .= " $source.moc";
1049
1388
                $globalmocs{$source} = "\035$source.h\035$source.cpp";
1050
1389
            }
1051
1390
            
1059
1398
            $important{$program} .= "$source.h ";
1060
1399
            $ui_output .= "\\\n\t$source.$cxxsuffix $source.h $source.moc ";
1061
1400
            push(@cleanfiles, "$source.$cxxsuffix");
1062
 
            push(@cleanfiles, "source.h");
 
1401
            push(@cleanfiles, "$source.h");
1063
1402
            push(@cleanfiles, "$source.moc");
1064
1403
            $dep_files .= " \$(DEPDIR)/$source.P" if($dep_files !~/$source.P/ );
1065
1404
        }
1066
1405
    }
1067
 
    if ($dep_lines) {
1068
 
        appendLines($dep_lines);
 
1406
}
 
1407
 
 
1408
sub tag_KCFGFILES ()
 
1409
{
 
1410
    my @psources = split(/[\034\s]+/, $sources{$program});
 
1411
    my @depFiles = ();
 
1412
    
 
1413
    foreach $source (@psources) {
 
1414
 
 
1415
        if ($source =~ m/\.kcfgc$/) {
 
1416
 
 
1417
            print STDERR "adding KCFG file $source\n" if ($verbose);
 
1418
 
 
1419
            my $qs = quotemeta($source);
 
1420
            $sources{$program} =~ s/$qs//;
 
1421
            $sources_changed{$program} = 1;
 
1422
      
 
1423
            $source =~ s/\.kcfgc$//;
 
1424
 
 
1425
            my $sourcedir = '';
 
1426
            if (-f "$makefileDir/$source.kcfgc") {
 
1427
                $sourcedir = '$(srcdir)/';
 
1428
            }
 
1429
 
 
1430
            if (!$kcfgFiles{$source}) {
 
1431
                $kcfg = "$program.kcfg";
 
1432
                findKcfgFile("$source.kcfgc");
 
1433
 
 
1434
                my $fixsuffix = "";
 
1435
                $fixsuffix = "else mv $source.cpp $source.$cxxsuffix ; " 
 
1436
                    unless "cpp" eq $cxxsuffix;
 
1437
 
 
1438
                my $dep_lines = "$source.$cxxsuffix: $source.h\n";
 
1439
                $dep_lines .= "$source.h: $sourcedir$kcfg $sourcedir$source.kcfgc \$(KCFG_DEPENDENCIES)\n";
 
1440
                $dep_lines .= "\t\$(KCONFIG_COMPILER) $sourcedir$kcfg $sourcedir$source.kcfgc; ret=\$\$?; \\\n";
 
1441
                $dep_lines .= "\tif test \"\$\$ret\" != 0; then rm -f $source.h ; exit \$\$ret ; $fixsuffix fi\n\n";
 
1442
 
 
1443
                $rule_adds{"$source.$cxxsuffix"} = $dep_lines;
 
1444
 
 
1445
                $kcfgFiles{$source} = 1;
 
1446
            }
 
1447
            
 
1448
            if ($program =~ /_la$/) {
 
1449
                $realObjs{$program} .= " $source.lo";
 
1450
            } else {
 
1451
                $realObjs{$program} .= " $source.\$(OBJEXT)";
 
1452
            }
 
1453
            $sources{$program} .= " $source.$cxxsuffix";
 
1454
            $sources_changed{$program} = 1;
 
1455
            $important{$program} .= "$source.h ";
 
1456
            $kcfg_output .= "\\\n\t$source.$cxxsuffix $source.h ";
 
1457
            push(@cleanfiles, "$source.$cxxsuffix");
 
1458
            push(@cleanfiles, "$source.h");
 
1459
            $dep_files .= " \$(DEPDIR)/$source.P" if($dep_files !~/$source.P/ );
 
1460
        }
1069
1461
    }
1070
1462
}
1071
1463
 
1072
1464
sub tag_ICON()
1073
1465
{
1074
 
    my $lookup = '([^\s]*)_ICON\s*=\s*([^\n]*)';
 
1466
    my $lookup = '([^\s]*)_ICON\s*=[ \t]*(.*)';
1075
1467
    my $install = "";
1076
1468
    my $uninstall = "";
1077
1469
 
1078
 
    while ($MakefileData =~ /\n$lookup/og) {
 
1470
    while ($MakefileData =~ /\n$lookup/g) {
1079
1471
        my $destdir;
1080
1472
        if ($1 eq "KDE") {
1081
1473
            $destdir = "kde_icondir";
1085
1477
        my $iconauto = ($2 =~ /AUTO\s*$/);
1086
1478
        my @appnames = ();
1087
1479
        if ( ! $iconauto ) {
1088
 
            my @_appnames = split(" ", $2);
 
1480
            my $appicon_str = $2;
 
1481
            my @_appnames = split(" ", $appicon_str);
1089
1482
            print STDOUT "KDE_ICON processing <@_appnames>\n"   if ($verbose);
1090
1483
            foreach $appname (@_appnames) {
1091
1484
                push(@appnames, quotemeta($appname));
1102
1495
            if ( $iconauto )
1103
1496
              {
1104
1497
                  push(@files, $entry)
1105
 
                    if ($entry =~ /\.xpm/ || $entry =~ /\.png/);
 
1498
                    if ($entry =~ /\.xpm/ || $entry =~ /\.png/ || $entry =~ /\.mng/ || $entry =~ /\.svg/);
1106
1499
              } else {
1107
1500
                  foreach $appname (@appnames) {
1108
1501
                      push(@files, $entry)
1109
 
                        if ($entry =~ /-$appname\.xpm/ || $entry =~ /-$appname\.png/);
 
1502
                        if ($entry =~ /-$appname\.xpm/ || $entry =~ /-$appname\.png/ || $entry =~ /-$appname\.mng/ || $entry =~ /-$appname\.svg/);
1110
1503
                  }
1111
1504
              }
1112
1505
        }
1117
1510
        foreach $file (@files) {
1118
1511
            my $newfile = $file;
1119
1512
            my $prefix = $file;
1120
 
            $prefix =~ s/\.(png|xpm)$//;
 
1513
            $prefix =~ s/\.(png|xpm|mng|svg|svgz)$//;
1121
1514
            my $appname = $prefix;
1122
1515
            $appname =~ s/^[^-]+-// if ($appname =~ /-/) ;
1123
1516
            $appname =~ s/^[^-]+-// if ($appname =~ /-/) ;
1142
1535
               'filesys' => 'filesystems',
1143
1536
               'mime' => 'mimetypes'
1144
1537
              );
1145
 
            
 
1538
 
1146
1539
            if (! defined $type_hash{$type} ) {
1147
1540
                print STDERR "unknown icon type $type in $printname ($file)\n";
1148
1541
                next;
1149
1542
            }
1150
 
            
 
1543
 
1151
1544
            my %dir_hash =
1152
1545
              (
1153
1546
               'los' => 'locolor/16x16',
1162
1555
               'hi32' => 'hicolor/32x32',
1163
1556
               'hi48' => 'hicolor/48x48',
1164
1557
               'hi64' => 'hicolor/64x64',
1165
 
               'hisc' => 'hicolor/scalable'
 
1558
               'hi128' => 'hicolor/128x128',
 
1559
               'hisc' => 'hicolor/scalable',
 
1560
               'cr16' => 'crystalsvg/16x16',
 
1561
               'cr22' => 'crystalsvg/22x22',
 
1562
               'cr32' => 'crystalsvg/32x32',
 
1563
               'cr48' => 'crystalsvg/48x48',
 
1564
               'cr64' => 'crystalsvg/64x64',
 
1565
               'cr128' => 'crystalsvg/128x128',
 
1566
               'crsc' => 'crystalsvg/scalable'
1166
1567
              );
1167
1568
            
1168
 
            $newfile =~ s@.*-($appname\.(png|xpm?))@$1@;
 
1569
            $newfile =~ s@.*-($appname\.(png|xpm|mng|svgz|svg?))@$1@;
1169
1570
            
1170
1571
            if (! defined $dir_hash{$prefix}) {
1171
1572
                print STDERR "unknown icon prefix $prefix in $printname\n";
1218
1619
    }
1219
1620
  appendLines ($tmp);
1220
1621
  my $lookup = 'POFILES\s*=([^\n]*)';
1221
 
  if ($MakefileData !~ /\n$lookup/o) {
 
1622
  if ($MakefileData !~ /\n$lookup/) {
1222
1623
    appendLines("$pofileLine\nGMOFILES =$allgmofiles");
1223
1624
  } else {
1224
1625
    substituteLine ($lookup, "$pofileLine\nGMOFILES =$allgmofiles");
1231
1632
 
1232
1633
        $target_adds{"maintainer-clean"} .= "clean-nls ";
1233
1634
 
1234
 
        $lookup = 'DISTFILES\s*=\s*(.*)';
1235
 
        if ($MakefileData =~ /\n$lookup\n/o) {
 
1635
        $lookup = 'DISTFILES\s*=[ \t]*(.*)';
 
1636
        if ($MakefileData =~ /\n$lookup/) {
1236
1637
          $tmp = "DISTFILES = \$(GMOFILES) \$(POFILES) $1";
1237
1638
          substituteLine ($lookup, $tmp);
1238
1639
        }
1254
1655
  $tmp .= "; do \\\n";
1255
1656
  if ($lang) {
1256
1657
    $tmp .= "\t  echo \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n";
1257
 
    $tmp .= "\t  test ! -f \$\$base.gmo || \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n"
 
1658
    $tmp .= "\t  if test -f \$\$base.gmo; then \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n";
 
1659
    $tmp .= "\t  elif test -f \$(srcdir)/\$\$base.gmo; then \$(INSTALL_DATA) \$(srcdir)/\$\$base.gmo \$(DESTDIR)\$(kde_locale)/$lang/LC_MESSAGES/\$\$base.mo ;\\\n";
 
1660
    $tmp .= "\t  fi ;\\\n";
1258
1661
  } else {
1259
1662
    $tmp .= "\t  echo \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n";
1260
1663
    $tmp .= "\t  \$(mkinstalldirs) \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES ; \\\n";
1261
 
    $tmp .= "\t  test ! -f \$\$base.gmo || \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n";
 
1664
    $tmp .= "\t  if test -f \$\$base.gmo; then \$(INSTALL_DATA) \$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n";
 
1665
    $tmp .= "\t  elif test -f \$(srcdir)/\$\$base.gmo; then \$(INSTALL_DATA) \$(srcdir)/\$\$base.gmo \$(DESTDIR)\$(kde_locale)/\$\$base/LC_MESSAGES/\$(PACKAGE).mo ;\\\n";
 
1666
    $tmp .= "\t  fi ;\\\n";
1262
1667
  }
1263
1668
  $tmp .= "\tdone\n\n";
1264
1669
  appendLines ($tmp);
1308
1713
sub tag_POFILES ()
1309
1714
{
1310
1715
    my $lookup = 'POFILES\s*=([^\n]*)';
1311
 
    return 1    if ($MakefileData !~ /\n$lookup/o);
 
1716
    return 1    if ($MakefileData !~ /\n$lookup/);
1312
1717
    print STDOUT "POFILES processing <$1>\n"   if ($verbose);
1313
1718
 
1314
1719
    my $tmp = $1;
1329
1734
        $pofiles =  join(" ", grep(/\.po$/, readdir(THISDIR)));
1330
1735
        closedir (THISDIR);
1331
1736
        print STDOUT "pofiles found = $pofiles\n"   if ($verbose);
1332
 
        if (-f "charset" && -f "kdelibs.po") {
 
1737
        if (-f "charset" && -f "kdelibs/kdelibs.po") {
1333
1738
            handle_TOPLEVEL();
1334
1739
        }
1335
1740
    }
1347
1752
 
1348
1753
sub helper_LOCALINSTALL($)
1349
1754
{
1350
 
  my $lookup = "\n" . $_[0] . ":";
1351
 
  if ($MakefileData =~ /($lookup)/) {
 
1755
  my $lookup = "\035" . $_[0] . " *:[^\035]*\035\t";
 
1756
  my $copy = $MakefileData;
 
1757
  $copy =~ s/\n/\035/g;
 
1758
  if ($copy =~ /($lookup.*)$/) {
1352
1759
 
1353
 
    my $install = $MakefileData;
1354
 
    $install =~ s/\n/\035/g;
1355
 
    $install =~ s/.*\035$_[0]:[^\035]*\035//;
 
1760
    $install = $1;
 
1761
    $install =~ s/\035$_[0] *:[^\035]*\035//;
1356
1762
    my $emptyline = 0;
1357
 
    while (! $emptyline) {
 
1763
    while (! $emptyline ) {
1358
1764
      if ($install =~ /([^\035]*)\035(.*)/) {
1359
1765
        local $line = $1;
1360
1766
        $install = $2;
1387
1793
      || $line =~ /^\s*(\@.*\@)*\s*\$\(INSTALL\S*\)/
1388
1794
      || $line =~ /^\s*(\@.*\@)*\s*(-?rm.*) \S*$/)
1389
1795
  {
1390
 
    $line =~ s/^(.*) ([^\s]*)\s*$/$1 \$(DESTDIR)$2/ if ($line !~ /\$\(DESTDIR\)/);
 
1796
    $line =~ s/^(.*) ([^\s]+)\s*$/$1 \$(DESTDIR)$2/ if ($line !~ /\$\(DESTDIR\)/);
1391
1797
  }
1392
1798
 
1393
1799
  if ($line ne $_[0]) {
1397
1803
}
1398
1804
 
1399
1805
#---------------------------------------------------------------------------
 
1806
# libtool is very hard to persuade it could use -Wl,--no-undefined for making
 
1807
# -no-undefined actually work
 
1808
# append $(KDE_NO_UNFINED) after every -no-undefined in LDFLAGS
 
1809
# this may go away if libtool ever does this on its own
 
1810
sub tag_NO_UNDEFINED () {
 
1811
    return if ($program !~ /_la$/);
 
1812
 
 
1813
    my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n";
 
1814
    $MakefileData =~ m/$lookup/;
 
1815
    return if (!defined($1));
 
1816
    return if ($1 !~ /CXXLINK/);
 
1817
 
 
1818
    if ($MakefileData !~ /\n$program\_LDFLAGS\s*=.*-no-undefined/ ) {
 
1819
        return;
 
1820
    }
 
1821
 
 
1822
    $lookup = $program . '\_LDFLAGS(\s*)=(.*)-no-undefined(.*)';
 
1823
    if ($MakefileData =~ /\n$lookup\n/) {
 
1824
        my $replace = $program . "\_LDFLAGS$1=$2-no-undefined \$(KDE_NO_UNDEFINED)$3";
 
1825
        substituteLine($lookup, $replace);
 
1826
    }
 
1827
}
 
1828
 
1400
1829
sub tag_CLOSURE () {
1401
1830
    return if ($program !~ /_la$/);
1402
 
    
 
1831
 
1403
1832
    my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n";
1404
1833
    $MakefileData =~ m/$lookup/;
 
1834
    return if (!defined($1));
1405
1835
    return if ($1 !~ /CXXLINK/);
1406
1836
 
1407
1837
    if ($MakefileData !~ /\n$program\_LDFLAGS\s*=.*-no-undefined/ &&
1409
1839
        print STDERR "Report: $program contains undefined in $printname\n" if ($program =~ /^lib/ && $dryrun);
1410
1840
        return;
1411
1841
    }
 
1842
 
1412
1843
    my $closure = $realname{$program} . ".closure";
1413
1844
    my $lines = "$closure: \$($program\_OBJECTS) \$($program\_DEPENDENCIES)\n";
1414
1845
    $lines .= "\t\@echo \"int main() {return 0;}\" > $program\_closure.$cxxsuffix\n";
1427
1858
    $closure_output .= " $closure";
1428
1859
}
1429
1860
 
 
1861
sub tag_NMCHECK () {
 
1862
    return if ($program !~ /_la$/);
 
1863
    my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n";
 
1864
    $MakefileData =~ m/$lookup/;
 
1865
    my $linkcmd = $1;
 
1866
    return if (!defined($1));
 
1867
    return if ($linkcmd !~ /CXXLINK/ && $linkcmd !~ /LINK/);
 
1868
 
 
1869
    $lookup = $program . '_NMCHECK\s*=([^\n]*)';
 
1870
    if( $MakefileData !~ m/\n$lookup\n/ ) {
 
1871
        return;
 
1872
    }
 
1873
    my $allowed = $1;
 
1874
    $allowed =~ s/^ *//;
 
1875
    $lookup = $program . '_NMCHECKWEAK\s*=([^\n]*)';
 
1876
    my $weak = "";
 
1877
    my $is_weak = 0;
 
1878
    if( $MakefileData =~ m/\n$lookup\n/ ) {
 
1879
        $weak = $1;
 
1880
        $is_weak = 1;
 
1881
    }
 
1882
    $weak =~ s/^ *//;
 
1883
 
 
1884
    if( $is_weak )
 
1885
    {
 
1886
        $weak = '--allowweak=\'' . $weak . '\' ';
 
1887
    }
 
1888
    my $nmline = "\@KDE_USE_NMCHECK_TRUE@\t\@\$(MAKE) \$(AM_MAKEFLAGS) nmcheck_$realname{$program} || ( rm -f $realname{$program}; exit 1 )";
 
1889
    $lookup = '(\t\$\(CXXLINK\)[^\n]*' . $program . '_OBJECTS[^\n]*)';
 
1890
    if( $MakefileData =~ /\n$lookup\n/ ) {
 
1891
        my $oldstuff = $1;
 
1892
        substituteLine( $lookup, $oldstuff . "\n" . $nmline );
 
1893
    }
 
1894
    $lookup = '(\t\$\(LINK\)[^\n]*' . $program . '_OBJECTS[^\n]*)';
 
1895
    if( $MakefileData =~ /\n$lookup\n/ ) {
 
1896
        my $oldstuff = $1;
 
1897
        substituteLine( $lookup, $oldstuff . "\n" . $nmline );
 
1898
    }
 
1899
    $nmline = "\@\$(top_srcdir)/admin/nmcheck $realname{$program} \'$allowed\' $weak";
 
1900
    appendLines( "\nnmcheck_$realname{$program}: $realname{$program} \n\t$nmline\n" );
 
1901
    $target_adds{ "nmcheck" } .= "nmcheck_$realname{$program} ";
 
1902
}
 
1903
 
1430
1904
sub tag_DIST () {
1431
1905
    my %foundfiles = ();
1432
1906
    opendir (THISDIR, ".");
1433
1907
    foreach $entry (readdir(THISDIR)) {
1434
 
        next if ($entry eq "CVS" || $entry =~ /^\./  || $entry =~ /^Makefile$$/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/);
 
1908
        next if ($entry eq "CVS" || $entry =~ /^\./  || $entry eq "Makefile" || $entry =~ /~$/ || $entry =~ /^\#.*\#$/);
1435
1909
        next if (! -f $entry);
1436
 
        next if ($entry =~ /\.moc/ || $entry =~ /\.lo$/ || $entry =~ /\.la$/ || $entry =~ /\.o/);
1437
 
        next if ($entry =~ /.+meta_unload.$cppExt$/ || $entry =~ /\.all_$cppExt\.$cppExt$/);
 
1910
        next if ($entry =~ /\.moc/ || $entry =~ /\.moc.$cppExt$/ || $entry =~ /\.lo$/ || $entry =~ /\.la$/ || $entry =~ /\.o/);
 
1911
        next if ($entry =~ /\.all_$cppExt\.$cppExt$/);
1438
1912
        $foundfiles{$entry} = 1;
1439
1913
    }
1440
1914
    closedir (THISDIR);
1441
1915
 
1442
 
    my @marks = ("EXTRA_DIST", "DIST_COMMON", '\S*_SOURCES', '\S*_HEADERS', 'MAINTAINERCLEANFILES', 'CLEANFILES', 'DISTCLEANFILES', '\S*_OBJECTS');
 
1916
    # doing this for MAINTAINERCLEANFILES would be wrong
 
1917
    my @marks = ("EXTRA_DIST", "DIST_COMMON", '\S*_SOURCES', '\S*_HEADERS', 'CLEANFILES', 'DISTCLEANFILES', '\S*_OBJECTS');
1443
1918
    foreach $mark (@marks) {
1444
 
        while ($MakefileData =~ /\n($mark)\s*=\s*([^\n]*)/g) {
1445
 
            foreach $file (split('[\034\s]', $2)) {
 
1919
        while ($MakefileData =~ /\n($mark)\s*=[ \t]*([^\n]*)/g) {
 
1920
            my $cleanfiles_str = $2;
 
1921
            foreach $file (split('[\034\s]+', $cleanfiles_str)) {
1446
1922
                $file =~ s/\.\///;
1447
1923
                $foundfiles{$file} = 0 if (defined $foundfiles{$file});
1448
1924
            }
1449
1925
        }
1450
1926
    }
1451
1927
    my @files = ("Makefile", "config.cache", "config.log", "stamp-h",
1452
 
                 "stamp-h1", "stamp-h1", "config.h", "Makefile", "config.status", "config.h", "libtool");
 
1928
                 "stamp-h1", "stamp-h1", "config.h", "Makefile", 
 
1929
                 "config.status", "config.h", "libtool", "core" );
1453
1930
    foreach $file (@files) {
1454
1931
        $foundfiles{$file} = 0 if (defined $foundfiles{$file});
1455
1932
    }
1462
1939
    }
1463
1940
    if ($KDE_DIST) {
1464
1941
        print "KDE_DIST $printname $KDE_DIST\n" if ($verbose);
1465
 
        
1466
 
        my $lookup = "DISTFILES *=(.*)";
1467
 
        if ($MakefileData =~ /\n$lookup\n/o) {
1468
 
            substituteLine($lookup, "KDE_DIST=$KDE_DIST\n\nDISTFILES=$1 \$(KDE_DIST)\n");
 
1942
 
 
1943
        my $lookup = 'DISTFILES\s*=[ \t]*(.*)';
 
1944
        if ($MakefileData =~ /\n$lookup/) {
 
1945
            substituteLine($lookup, "DISTFILES = $1 \$(KDE_DIST)");
 
1946
            appendLines("KDE_DIST=$KDE_DIST\n");
1469
1947
        }
1470
1948
    }
1471
1949
}
1475
1953
# Errors are logged in the global $errorflags
1476
1954
sub tag_DOCFILES ()
1477
1955
{
1478
 
#    if ($MakefileData =~ /\nSUBDIRS\s*=/) { # subdirs
1479
 
#      $MakefileData =~ /\n(.*-recursive:\s*)\n/;
1480
 
#      my $orig_rules = $1;
1481
 
#      my $rules = $orig_rules;
1482
 
#      $rules =~ s/:\s*$//;
1483
 
#      substituteLine($orig_rules, "$rules docs-recursive:");
1484
 
#      appendLines("docs: docs-recursive docs-am\n");
1485
 
#    } else {
1486
 
#      appendLines("docs: docs-am\n");
1487
 
#    }
1488
1956
    $target_adds{"all"} .= "docs-am ";
1489
1957
 
1490
 
    my $lookup = 'KDE_DOCS\s*=\s*([^\n]*)';
1491
 
    goto nodocs    if ($MakefileData !~ /\n$lookup/o);
 
1958
    my $lookup = 'KDE_DOCS\s*=[ \t]*([^\n]*)';
 
1959
    goto nodocs    if ($MakefileData !~ /\n$lookup/);
1492
1960
    print STDOUT "KDE_DOCS processing <$1>\n"   if ($verbose);
1493
1961
 
1494
1962
    my $tmp = $1;
1510
1978
    {
1511
1979
        opendir (THISDIR, ".");
1512
1980
        foreach $entry (readdir(THISDIR)) {
1513
 
          next if ($entry eq "CVS" || $entry =~ /^\./  || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/);
 
1981
          next if ($entry eq "CVS" || $entry =~ /^\./  || $entry =~ /^Makefile/ || $entry =~ /~$/ || $entry =~ /^\#.*\#$/ || $entry eq "core" || $entry eq "index.cache.bz2");
1514
1982
          next if (! -f $entry);
1515
1983
          $files .= "$entry ";
1516
1984
        }
1526
1994
    goto nodocs if (!$files);        # Nothing to do
1527
1995
 
1528
1996
    if ($files =~ /(^| )index\.docbook($| )/) {
1529
 
      
 
1997
 
1530
1998
      my $lines = "";
1531
1999
      my $lookup = 'MEINPROC\s*=';
1532
2000
      if ($MakefileData !~ /\n($lookup)/) {
1539
2007
      $lookup = '\nindex.cache.bz2:';
1540
2008
      if ($MakefileData !~ /\n($lookup)/) {
1541
2009
         $lines .= "index.cache.bz2: \$(srcdir)/index.docbook \$(KDE_XSL_STYLESHEET) $files\n";
1542
 
         $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";
 
2010
         $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";
1543
2011
         $lines .= "\n";
1544
2012
      }
1545
 
 
1546
 
      $lines .= "docs-am: index.cache.bz2\n";  
 
2013
 
 
2014
      $lines .= "docs-am: index.cache.bz2\n";
1547
2015
      $lines .= "\n";
1548
2016
      $lines .= "install-docs: docs-am install-nls\n";
1549
2017
      $lines .= "\t\$(mkinstalldirs) \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n";
1550
2018
      $lines .= "\t\@if test -f index.cache.bz2; then \\\n";
1551
2019
      $lines .= "\techo \$(INSTALL_DATA) index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n";
1552
2020
      $lines .= "\t\$(INSTALL_DATA) index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n";
 
2021
      $lines .= "\telif test -f  \$(srcdir)/index.cache.bz2; then \\\n";
 
2022
      $lines .= "\techo \$(INSTALL_DATA) \$(srcdir)/index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n";
 
2023
      $lines .= "\t\$(INSTALL_DATA) \$(srcdir)/index.cache.bz2 \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/; \\\n";
1553
2024
      $lines .= "\tfi\n";
1554
2025
      $lines .= "\t-rm -f \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n";
1555
2026
      $lines .= "\t\$(LN_S) \$(kde_libs_htmldir)/$kdelang/common \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname/common\n";
1569
2040
      appendLines("docs-am: $files\n");
1570
2041
    }
1571
2042
 
1572
 
    $target_adds{"install-data-am"} .= "install-nls";
 
2043
    $target_adds{"install-data-am"} .= "install-nls ";
1573
2044
    $target_adds{"uninstall"} .= "uninstall-nls ";
1574
2045
 
1575
2046
    $tmp = "install-nls:\n";
1580
2051
    $tmp .= "\tdone\n";
1581
2052
    if ($appname eq 'common') {
1582
2053
      $tmp .= "\t\@echo \"merging common and language specific dir\" ;\\\n";
1583
 
      $tmp .= "\tif test ! -e \$(kde_htmldir)/en/common/kde-common.css; then echo 'no english docs found in \$(kde_htmldir)/en/common/'; exit 1; fi \n";
 
2054
      $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";
1584
2055
      $tmp .= "\t\@com_files=`cd \$(kde_htmldir)/en/common && echo *` ;\\\n";
1585
2056
      $tmp .= "\tcd \$(DESTDIR)\$(kde_htmldir)/$kdelang/common ;\\\n";
1586
2057
      $tmp .= "\tif test -n \"\$\$com_files\"; then for p in \$\$com_files ; do \\\n";
1587
2058
      $tmp .= "\t  case \" $files \" in \\\n";
1588
2059
      $tmp .= "\t    *\" \$\$p \"*) ;; \\\n";
1589
 
      $tmp .= "\t    *) test ! -e \$\$p && echo \$(LN_S) ../../en/common/\$\$p \$(DESTDIR)\$(kde_htmldir)/$kdelang/common/\$\$p && \$(LN_S) ../../en/common/\$\$p \$\$p ;; \\\n";
 
2060
      $tmp .= "\t    *) test ! -f \$\$p && echo \$(LN_S) ../../en/common/\$\$p \$(DESTDIR)\$(kde_htmldir)/$kdelang/common/\$\$p && \$(LN_S) ../../en/common/\$\$p \$\$p ;; \\\n";
1590
2061
      $tmp .= "\t  esac ; \\\n";
1591
2062
      $tmp .= "\tdone ; fi ; true\n";
1592
2063
    }
1622
2093
    {
1623
2094
        my @list = ();
1624
2095
        opendir (SRCDIR, "$dir");
1625
 
        @hFiles = grep { /.+\.$hExt$/o } readdir(SRCDIR);
 
2096
        @hFiles = grep { /.+\.$hExt$/o && !/^\./ } readdir(SRCDIR);
1626
2097
        closedir SRCDIR;
1627
2098
        foreach $hf (@hFiles)
1628
2099
        {
1637
2108
            read HFIN, $hfData, $hfsize;
1638
2109
            close HFIN;
1639
2110
            # push (@list, $hf) if(index($hfData, "Q_OBJECT") >= 0); ### fast but doesn't handle //Q_OBJECT
1640
 
            if ( $hfData =~ /{([^}]*)Q_OBJECT/s ) {              ## handle " { friend class blah; Q_OBJECT "
1641
 
                push (@list, $hf) unless $1 =~ m://[^\n]*Q_OBJECT[^\n]*$:s;  ## handle "// Q_OBJECT"
 
2111
            # handle " { friend class blah; Q_OBJECT ", but don't match antlarr_Q_OBJECT (\b).
 
2112
            if ( $hfData =~ /{([^}]*)\bQ_OBJECT/s ) {
 
2113
                push (@list, $hf) unless $1 =~ m://[^\n]*Q_OBJECT[^\n]*$:s;  ## reject "// Q_OBJECT"
1642
2114
            }
1643
2115
        }
1644
2116
        # The assoc array of root of headerfile and header filename
1702
2174
    return unless (keys %mocFiles);
1703
2175
    opendir(THISDIR, ".") || return;
1704
2176
    @cppFiles = grep { /.+\.$cppExt$/o  && !/.+\.moc\.$cppExt$/o
1705
 
                         && !/.+\.all_$cppExt\.$cppExt$/o } readdir(THISDIR);
 
2177
                         && !/.+\.all_$cppExt\.$cppExt$/o
 
2178
                         && !/^\./  } readdir(THISDIR);
1706
2179
    closedir THISDIR;
1707
2180
    return unless (@cppFiles);
1708
2181
    my $files = join (" ", @cppFiles);
1726
2199
        @cppFiles = keys %{$moc2cpp->{"$mocFile.moc"}};
1727
2200
        if (@cppFiles == 1) {
1728
2201
            $mocFiles{$mocFile} .= "\035" . $cppFiles[0];
1729
 
            push(@deped, $mocFile);
 
2202
            push(@depend, $mocFile);
1730
2203
        } elsif (@cppFiles == 0) {
1731
2204
            push (@newObs, $mocFile);           # Produce new object file
1732
2205
            next    if ($haveAutomocTag);       # This is expected...
1764
2237
        $dir =~ s#^\.#\$(srcdir)#;
1765
2238
        if (defined ($cppFile))
1766
2239
        {
1767
 
            $target_adds{"\$(srcdir)/$cppFile"} .= "$mocFile.moc ";
1768
 
            appendLines ("$mocFile.moc: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile.moc\n");
1769
 
            $cleanMoc .= " $mocFile.moc";
 
2240
          $cppFile =~ s,\.[^.]*$,,;
 
2241
          $target_adds{"$cppFile.o"} .= "$mocFile.moc ";
 
2242
          $target_adds{"$cppFile.lo"} .= "$mocFile.moc ";
 
2243
          appendLines ("$mocFile.moc: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile.moc\n");
 
2244
          $cleanMoc .= " $mocFile.moc";
 
2245
          appendLines ("mocs: $mocFile.moc\n");
1770
2246
        }
1771
2247
        else
1772
2248
        {
1773
2249
            appendLines ("$mocFile$mocExt: $dir/$hFile\n\t\$(MOC) $dir/$hFile -o $mocFile$mocExt\n");
1774
2250
            $cleanMoc .= " $mocFile$mocExt";
 
2251
            appendLines ("mocs: $mocFile$mocExt\n");
1775
2252
        }
1776
2253
    }
1777
2254
}
1778
2255
 
 
2256
sub make_bcheck_target()
 
2257
{
 
2258
    my $lookup = 'RECURSIVE_TARGETS\s*=[ \t]*(.*)';
 
2259
    my $bcheckdep = "bcheck-am";
 
2260
    $bcheckdep = "bcheck-recursive" if ($MakefileData =~ /\n$lookup/);
 
2261
 
 
2262
    my $headers= "";
 
2263
    $headers = $1 if($MakefileData =~ /\nHEADERS\s*=[ \t]*(.+)/);
 
2264
    $headers =~ s/\$\((?:noinst|EXTRA)_HEADERS\)//g;
 
2265
 
 
2266
    $target_adds{"clean-am"} .= "clean-bcheck ";
 
2267
 
 
2268
    my $t = "clean-bcheck: \n" .
 
2269
            "\trm -f *.bchecktest.cc *.bchecktest.cc.class a.out\n\n" .
 
2270
            "bcheck: $bcheckdep\n\n" .
 
2271
            "bcheck-am:\n" .
 
2272
           "\t\@for i in $headers; do \\\n" .
 
2273
           "\t    if test \$(srcdir)/\$\$i -nt \$\$i.bchecktest.cc; then \\\n" . 
 
2274
           "\t        echo \"int main() {return 0;}\" > \$\$i.bchecktest.cc ; \\\n" .
 
2275
           "\t        echo \"#include \\\"\$\$i\\\"\" >> \$\$i.bchecktest.cc ; \\\n" .
 
2276
           "\t        echo \"\$\$i\"; \\\n" . 
 
2277
           "\t        if ! ";
 
2278
    $t .=  $cxxsuffix eq "KKK" ?
 
2279
           "\$(CXX) \$(DEFS) -I. -I\$(srcdir) -I\$(top_builddir) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(KDE_CXXFLAGS) " :
 
2280
           "\$(CXXCOMPILE) ";
 
2281
    $t .=  " --dump-class-hierarchy -c \$\$i.bchecktest.cc; then \\\n" .
 
2282
           "\t            rm -f \$\$i.bchecktest.cc; exit 1; \\\n" .
 
2283
           "\t        fi ; \\\n" .
 
2284
           "\t        echo \"\" >> \$\$i.bchecktest.cc.class; \\\n" .
 
2285
           "\t        perl \$(top_srcdir)/admin/bcheck.pl \$\$i.bchecktest.cc.class || { rm -f \$\$i.bchecktest.cc; exit 1; }; \\\n" .
 
2286
           "\t        rm -f a.out; \\\n" .
 
2287
           "\t    fi ; \\\n" .
 
2288
           "\tdone\n";
 
2289
    appendLines("$t\n");
 
2290
}
 
2291
 
1779
2292
sub make_meta_classes ()
1780
2293
{
1781
2294
    return if ($kdeopts{"qtonly"});
1785
2298
    my $moc_class_headers = "";
1786
2299
    foreach $program (@programs) {
1787
2300
        my $mocs = "";
1788
 
        my @progsources = split(/[\s\034]+/, $sources{$program});
1789
 
        my @depmocs = split(' ', $depedmocs{$program});
 
2301
        my @progsources = split(/[\034\s]+/, $sources{$program});
 
2302
        my @depmocs = split(' ', $dependmocs{$program});
1790
2303
        my %shash = (), %mhash = ();
1791
2304
        @shash{@progsources} = 1;  # we are only interested in the existence
1792
2305
        @mhash{@depmocs} = 1;
1797
2310
        print STDOUT "globalmocs=[".join(' ', keys(%globalmocs))."]\n" if ($verbose);
1798
2311
        foreach my $mocFile (keys (%globalmocs))
1799
2312
        {
1800
 
            undef $cppFile;
1801
 
            ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3);
1802
 
            $dir =~ s#^\.#\$(srcdir)#;
 
2313
            my ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3);
1803
2314
            if (defined ($cppFile))
1804
2315
            {
1805
2316
                $mocs .= " $mocFile.moc" if exists $shash{$cppFile};
1809
2320
                # Bah. This is the case, if no C++ file includes the .moc
1810
2321
                # file. We make a .moc.cpp file for that. Unfortunately this
1811
2322
                # is not included in the %sources hash, but rather is mentioned
1812
 
                # in %depedmocs. If the user wants to use AUTO he can't just
 
2323
                # in %dependmocs. If the user wants to use AUTO he can't just
1813
2324
                # use an unspecific METAINCLUDES. Instead he must use
1814
2325
                # program_METAINCLUDES. Anyway, it's not working real nicely.
1815
2326
                # E.g. Its not clear what happens if user specifies two
1820
2331
        }
1821
2332
        if ($mocs) {
1822
2333
            print STDOUT "==> mocs=[".$mocs."]\n" if ($verbose);
1823
 
            my $sourcename = $program."_meta_unload";
1824
 
            my $ext = ($program =~ /_la$/) ? ".lo" : ".o";
1825
 
            my $srcfile = $sourcename.".$cxxsuffix";
1826
 
            my $objfile = $sourcename.$ext;
1827
 
            $moc_class_headers .= " $srcfile";
1828
 
            my $appl;
1829
 
            $appl  = "$srcfile: $mocs\n";
1830
 
            $appl .= "\t\@echo 'creating $srcfile'\n";
1831
 
            $appl .= "\t\@-rm -f $srcfile\n";
1832
 
            $appl .= "\t\@if test \${kde_qtver} = 2; then \\\n";
1833
 
            $appl .= "\t\techo 'static const char * _metalist_$program\[\] = {' > $srcfile ;\\\n";
1834
 
            $appl .= "\t\tcat $mocs | grep 'char.*className' | ";
1835
 
            $appl .=  "sed -e 's/.*[^A-Za-z0-9_:]\\([A-Za-z0-9_:]*\\)::className.*\$\$/\\\"\\1\\\",/' | sort | uniq >> $srcfile ;\\\n";
1836
 
            $appl .= "\t\techo '0};' >> $srcfile ;\\\n";
1837
 
            $appl .= "\t\techo '#include <kunload.h>' >> $srcfile ;\\\n";
1838
 
            $appl .= "\t\techo '_UNLOAD($program)' >> $srcfile ;\\\n";
1839
 
            $appl .= "\telse echo > $srcfile; fi\n";
1840
 
            $appl .= "\n";
1841
 
            
1842
 
            $realObjs{$program} .= " \034" . $objfile . " ";
1843
 
            $sources{$program} .= " $srcfile";
1844
 
            $sources_changed{$program} = 1;
1845
 
            $dep_files .= " \$(DEPDIR)/$sourcename.P" if($dep_files !~/$sourcename.P/);
1846
 
            appendLines ($appl);
1847
2334
        }
1848
2335
        print STDOUT "\n" if $verbose;
1849
2336
    }
1862
2349
    open (FILEOUT, "> $makefile")
1863
2350
                        || die "Could not create $makefile: $!\n";
1864
2351
 
1865
 
    print FILEOUT "\# $progId - " . '$Revision: 1.265.2.2 $ '  . "\n";
1866
 
    $MakefileData =~ s/\034/\\\n\t/g;    # Restore continuation lines
 
2352
    $MakefileData =~ s/\034/\\\n/g;    # Restore continuation lines
 
2353
    # Append our $progId line, _below_ the "generated by automake" line
 
2354
    # because automake-1.6 relies on the first line to be his own.
 
2355
    my $progIdLine = "\# $progId - " . '$Revision: 1.412 $ '."\n";
 
2356
    if ( !( $MakefileData =~ s/^(.*generated .*by automake.*\n)/$1$progIdLine/ ) ) {
 
2357
        warn "automake line not found in $makefile\n";
 
2358
        # Fallback: first line
 
2359
        print FILEOUT $progIdLine;
 
2360
    };
1867
2361
    print FILEOUT $MakefileData;
1868
2362
    close FILEOUT;
1869
2363
}
1892
2386
    if ($MakefileData =~ /\n($lookup)/) {
1893
2387
      $old = $1;
1894
2388
      $old =~ s/\034/\\\n#>\- /g;         # Fix continuation lines
1895
 
      $new =~ s/\034/\\\n\t/g;
1896
 
      my $newCount = ($new =~ tr/\n//) + 1;
 
2389
      my $newCount = ($new =~ tr/\034//) + ($new =~ tr/\n//) + 1;
 
2390
      $new =~ s/\\\n/\034/g;
1897
2391
      $MakefileData =~ s/\n$lookup/\n#>- $old\n#>\+ $newCount\n$new/;
1898
2392
    } else {
1899
 
      print STDERR "Warning: substitution of \"$lookup\" in $printname failed\n";
 
2393
        warn "Warning: substitution of \"$lookup\" in $printname failed\n";
1900
2394
    }
1901
2395
}
1902
2396
 
1906
2400
sub appendLines ($)
1907
2401
{
1908
2402
  my ($new) = @_;
1909
 
  $new =~ s/\034/\\\n\t/g;        # Fix continuation lines
1910
 
  my $newCount = ($new =~ tr/\n//) + 1;
 
2403
  my $copynew = $new;
 
2404
  my $newCount = ($new =~ tr/\034//) + ($new =~ tr/\n//) + 1;
 
2405
  $new =~ s/\\\n/\034/g;        # Fix continuation lines
1911
2406
  $MakefileData .= "\n#>\+ $newCount\n$new";
1912
2407
}
1913
2408
 
1932
2427
}
1933
2428
 
1934
2429
#-----------------------------------------------------------------------------
 
2430
 
 
2431
# find the .kcfg file listed in the .kcfgc file
 
2432
sub findKcfgFile($)
 
2433
{
 
2434
  my ($kcfgf) = @_;
 
2435
  open (KCFGFIN, $kcfgf) || die "Could not open $kcfgf: $!\n";
 
2436
  seek(KCFGFIN, 0, 2);
 
2437
  my $kcfgfsize = tell(KCFGFIN);
 
2438
  seek(KCFGFIN, 0, 0);
 
2439
  read KCFGFIN, $kcfgfData, $kcfgfsize;
 
2440
  close KCFGFIN;
 
2441
  if(($kcfgfData =~ m/^File=(.*\.kcfg)/gm)) {
 
2442
    $kcfg = $1;
 
2443
  }
 
2444
}