106
114
$verbose = 1; # Oh is there a problem...?
108
elsif (/^-p(.+)$|^--path=(.+)$/)
116
elsif (/^(?:-p|--path=)(.+)$/)
110
$thisProg = "$1/".basename($thisProg) if($1);
111
$thisProg = "$2/".basename($thisProg) if($2);
119
$thisProg = $p . "/". basename($thisProg);
112
120
warn ("$thisProg doesn't exist\n") if (!(-f $thisProg));
121
$thisProg .= " -p".$p;
115
124
elsif (/^--help$|^-h$/)
117
126
print STDOUT "Usage $thisProg [OPTION] ... [dir/Makefile.in]...\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",
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";
232
253
$makefile = basename($makefile);
234
255
print STDOUT "Processing makefile $printname\n" if ($verbose);
236
257
# Setup and see if we need to do this.
237
258
return if (!initialise());
239
260
tag_AUTOMAKE (); # Allows a "make" to redo the Makefile.in
240
261
tag_META_INCLUDES (); # Supplies directories for src locations
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
248
tag_UIFILES(); # Sorts out ui rules
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]*(.*)';
277
if($program =~ /libkdeinit_(.*)/) {
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";
285
substituteLine($lookup, "$program\_SOURCES=" . $sources{$program});
254
288
if ($important{$program}) {
255
289
local %source_dict = ();
343
380
$new = "$program\_OBJECTS = " . $realObjs{$program};
345
substituteLine ($lookup, $new);
382
if($MakefileData =~ m/\n$lookup/) {
383
substituteLine ($lookup, $new);
386
appendLines("$new\n");
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");
352
my $lookup = 'DEP_FILES\s*=([^\n]*)';
353
if ($MakefileData =~ /\n$lookup\n/o) {
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");
394
my $lookup = '(\@\S+\@)?DEP_FILES\s*=[ \t]*(.*)';
395
if ($MakefileData =~ /\n$lookup/) {
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";
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";
363
414
substituteLine($lookup, $lines);
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");
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);
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 ";
434
my %target_dels = ("install-data-am" => "");
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/) {
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");
448
$target_dels{"install-data-am"} .= "install-kde_moduleLTLIBRARIES ";
449
$target_adds{"install-data-am"} .= " ";
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);
458
my $oldlines = $lookup;
459
if (defined $target_dels{$add}) {
460
foreach $del (split(' ', $target_dels{$add})) {
461
$newlines =~ s/\s*$del\s*/ /g;
464
substituteLine($oldlines, "$add: " . $target_adds{$add} . $newlines);
395
$lines .= "$add: " . $target_adds{$add} . "\n";
466
$lines .= "$add: " . $target_adds{$add} . "\n";
470
appendLines($lines) if ($lines);
472
$lines = join("\n", values %rule_adds);
473
appendLines($lines) if ($lines);
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);
419
$lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=link) (\$\(CXXLD\).*\$\(KCXXFLAGS\))';
421
if ($MakefileData =~ m/$lookup/ ) {
422
$MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
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\))';
495
if ($MakefileData =~ m/$lookup/ ) {
496
$MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
499
$lookup = '(\n[^#].*\$\(LIBTOOL\) --mode=compile)\s+(\$\(CXX\)\s+)';
500
if ($MakefileData =~ m/$lookup/ ) {
501
$MakefileData =~ s/$lookup/$1 --tag=CXX $2/;
430
505
$MakefileData =~ s/\$\(KCXXFLAGS\)/\$\(CXXFLAGS\)/g;
525
while ($MakefileData =~ /\n(\S*)_OBJECTS\s*=[ \t\034]*([^\n]*)\n/g) {
622
while ($MakefileData =~ /\n(\S*)_OBJECTS\s*=[\034 \t]*([^\n]*)\n/g) {
527
624
my $program = $1;
528
625
my $objs = $2; # safe them
532
my @objlist = split(/[\s\034]+/, $objs);
629
my @objlist = split(/[\034\s]+/, $objs);
533
630
foreach $obj (@objlist) {
534
if ($obj =~ /\$\((\S+)\)/ ) {
536
if ($variable !~ 'OBJEXT') {
631
if ($obj =~ /(\S*)\$\((\S+)\)/ ) {
634
if ($pre eq '' && exists($varcontent{$variable})) {
635
my @addlist = split(/[\034\s]+/, $varcontent{$variable});
636
push(@objlist, @addlist);
637
} elsif ($variable !~ 'OBJEXT') {
644
next if ($program =~ /^am_libkdeinit_/);
544
646
$program =~ s/^am_// if ($program =~ /^am_/);
546
648
my $sourceprogram = $program;
547
649
$sourceprogram =~ s/\@am_/\@/ if($sourceprogram =~ /^.*\@am_.+/);
549
651
print STDOUT "found program $program\n" if ($verbose);
550
652
push(@programs, $program);
552
654
$realObjs{$program} = $objs;
554
if ($MakefileData =~ /\n$sourceprogram\_SOURCES\s*=\s*(.*)\n/) {
656
if ($MakefileData =~ /\n$sourceprogram\_SOURCES\s*=[ \t]*(.*)\n/) {
555
657
$sources{$program} = $1;
638
738
print STDOUT "found ( in $program\_SOURCES. skipping\n" if ($verbose);
644
my @progsources = split(/[\s\034]+/, $sources{$program});
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.
746
my @progsources = split(/[\034\s]+/, $sources{$program});
748
@shash{@progsources} = 1; # we are only interested in the existence
645
749
my %sourcelist = ();
647
752
foreach $source (@progsources) {
648
753
my $suffix = $source;
649
754
$suffix =~ s/^.*\.([^\.]+)$/$1/;
651
if (defined($sourcelist{$suffix})) {
652
$sourcelist{$suffix} .= " " . $source;
756
$sourcelist{$suffix} .= "$source ";
758
foreach my $mocFile (keys (%globalmocs))
760
my ($dir, $hFile, $cppFile) = split ("\035", $globalmocs{$mocFile}, 3);
761
if (defined ($cppFile)) {
762
$mocs .= " $mocFile.moc" if exists $shash{$cppFile};
654
$sourcelist{$suffix} .= $source;
764
$sourcelist{$cxxsuffix} .= "$mocFile.moc.$cxxsuffix ";
769
# scan for extra given dependencies and add them to our target
770
while ($MakefileData =~ /\n\s*(\S+)\.(?:lo|o)\s*:([^\n]*)/g) {
658
774
foreach $suffix (keys %sourcelist) {
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)$/) {
664
779
$suffix_is_cxx = 1;
667
my $mocfiles_in = ($suffix eq $cxxsuffix) &&
668
defined($depedmocs{$program});
782
my $mocfiles_in = ($suffix eq $cxxsuffix) && $moc_cpp_added;
670
my @sourcelist = split(/[\s\034]+/, $sourcelist{$suffix});
784
my @sourcelist = split(/[\034\s]+/, $sourcelist{$suffix});
672
786
if ((@sourcelist == 1 && !$mocfiles_in) || $suffix_is_cxx != 1 ) {
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" ) {
680
796
foreach $file (@sourcelist) {
682
797
$file =~ s/\Q$suffix\E$//;
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";
699
$source_deps .= "$source ";
703
$handling = "$program.all_$suffix.$suffix: \$(srcdir)/Makefile.in " . $source_deps . " ";
706
$handling .= $depedmocs{$program};
707
foreach $mocfile (split(' ', $depedmocs{$program})) {
709
if ($mocfile =~ m/\.$suffix$/) {
710
$mocsources .= " " . $mocfile;
814
$source_deps .= " $source";
816
my $plainsource = $source;
817
$plainsource =~ s/\.$cppExt$//;
818
$source_deps .= " " . $extradeps{$plainsource} if (exists($extradeps{$plainsource}));
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";
726
832
appendLines($handling);
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 ";
733
$finalObjs{$program} .= "o ";
841
$finalObjs{$program} .= $finalObj . " ";
863
my $lookup = 'kdeinit_LTLIBRARIES\s*=[ \t]*(.*)';
865
if ($MakefileData =~ m/\n$lookup/) {
866
@kdeinits = split(/[\034\s]+/, $1);
868
foreach my $kdeinit (@kdeinits) {
869
if ($kdeinit =~ m/\.la$/) {
870
$kdeinit =~ s/\.la$//;
871
push(@progs, $kdeinit);
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";
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";
881
push(@cleanfiles, "${kdeinit}.la.$cxxsuffix");
882
push(@cleanfiles, "${kdeinit}_dummy.$cxxsuffix");
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/ );
889
$lookup = $kdeinit . '_la_LIBADD\s*=[ \t]*(.*)';
890
if($MakefileData =~ m/\n$lookup/) {
892
substituteLine($lookup, "${kdeinit}_la_LIBADD = libkdeinit_${kdeinit}.la");
893
appendLines("libkdeinit_${kdeinit}_la_LIBADD = $libadd\n");
895
appendLines("libkdeinit_${kdeinit}_la_LDFLAGS = -no-undefined -avoid-version \$(all_libraries)\n");
897
# add library dependencies
898
$lookup = $kdeinit . '_la_DEPENDENCIES\s*=[ \t]*(.*)';
899
if($MakefileData =~ m/\n$lookup/) {
901
substituteLine($lookup, "${kdeinit}_la_DEPENDENCIES = libkdeinit_${kdeinit}.la");
902
appendLines("libkdeinit_${kdeinit}_la_DEPENDENCIES = $libdeps\n");
905
# make library objects
906
$lookup = "am_${kdeinit}_la_OBJECTS" . '\s*=[ \t]*(.*)';
907
if($MakefileData =~ m/\n$lookup/) {
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";
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) " .
922
# make libkdeinit sources
923
$lookup = $kdeinit . '_la_SOURCES\s*=[ \t]*(.*)';
924
if($MakefileData =~ m/\n$lookup/) {
926
$sources_changed{"libkdeinit_${kdeinit}_la"} = 1;
927
$sources{"libkdeinit_${kdeinit}_la"} = $srces;
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/);
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/) {
943
$srces =~ s/\b$kdeinit\.c\b/\$(${kdeinit}_SOURCES)/;
944
$srces =~ s/\$\(${kdeinit}_la_SOURCES\)/\$(libkdeinit_${kdeinit}_la_SOURCES)/;
945
substituteLine($lookup, "SOURCES = $srces");
947
$lookup = 'DIST_SOURCES\s*=[ \t](.*)';
948
if($MakefileData =~ m/\n$lookup/) {
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");
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");
966
push(@programs, $kdeinit);
967
$realObjs{$kdeinit} = "${kdeinit}.la.\$(OBJEXT)";
968
$realname{$kdeinit} = $kdeinit;
969
$sources{$kdeinit} = "${kdeinit}.la.$cxxsuffix";
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";
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";
980
$ltlibs .= " libkdeinit_${kdeinit}.la";
985
# add libkdeinit target
986
$lookup = 'lib_LTLIBRARIES\s*=[ \t]*(.*)';
987
if($MakefileData =~ m/\n$lookup/) {
988
substituteLine($lookup, "lib_LTLIBRARIES = $1 $ltlibs");
992
"Error: lib_LTLIBRARIES missing in $printname (required for kdeinit_LTLIBRARIES).\n";
998
if($MakefileData !~ m/\nbin_PROGRAMS\s*=/) {
999
print STDERR "Error: bin_PROGRAMS missing in $printname (required for kdeinit_LTLIBRARIES).\n";
1003
# add our new progs to SOURCES, DIST_SOURCES and bin_PROGRAMS
1004
my $progsources = "";
1006
foreach my $p (@progs) {
1007
$progsources .= "\$(${p}_SOURCES) ";
1008
$progexes .= "${p}\$(EXEEXT) ";
1010
$lookup = 'SOURCES\s*=[ \t]*(.*)';
1011
if($MakefileData =~ /\n$lookup/) {
1012
substituteLine($lookup, "SOURCES = $1 $progsources");
1014
$lookup = 'DIST_SOURCES\s*=[ \t]*(.*)';
1015
if($MakefileData =~ /\n$lookup/) {
1016
substituteLine($lookup, "DIST_SOURCES = $1 $progsources");
1018
# bin_PROGRAMS is complicated, as it exists twice, so we do a little
1020
$lookup = 'PROGRAMS\s*=[ \t]*(.*)';
1021
if ($MakefileData =~ /\n$lookup/) {
1022
substituteLine($lookup, "bin_PROGRAMS += $progexes\nPROGRAMS = $1");
1028
#-----------------------------------------------------------------------------
1030
sub tag_COMPILE_FIRST()
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) {
1043
$sdeps = "\$(srcdir)/$source";
1047
foreach $depend (@compilefirst) {
1048
next if ($source eq $depend);
1049
# avoid cyclic dependencies
1050
next if defined($donesources{$depend});
1051
push @deps, $depend;
1053
$target_adds{$sdeps} .= join(' ', @deps) . ' ' if (@deps);
1054
$donesources{$source} = 1;
1060
#-----------------------------------------------------------------------------
752
1063
# Organises the list of headers that we'll use to produce moc files
754
1065
sub tag_METASOURCES ()
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 = ();
1031
1361
if (!$uiFiles{$source}) {
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";
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";
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";
1044
1381
$dep_lines .= "$source.moc: $source.h\n";
1045
1382
$dep_lines .= "\t\$(MOC) $source.h -o $source.moc\n";
1384
$rule_adds{"$source.$cxxsuffix"} = $dep_lines;
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";
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/ );
1068
appendLines($dep_lines);
1408
sub tag_KCFGFILES ()
1410
my @psources = split(/[\034\s]+/, $sources{$program});
1413
foreach $source (@psources) {
1415
if ($source =~ m/\.kcfgc$/) {
1417
print STDERR "adding KCFG file $source\n" if ($verbose);
1419
my $qs = quotemeta($source);
1420
$sources{$program} =~ s/$qs//;
1421
$sources_changed{$program} = 1;
1423
$source =~ s/\.kcfgc$//;
1426
if (-f "$makefileDir/$source.kcfgc") {
1427
$sourcedir = '$(srcdir)/';
1430
if (!$kcfgFiles{$source}) {
1431
$kcfg = "$program.kcfg";
1432
findKcfgFile("$source.kcfgc");
1435
$fixsuffix = "else mv $source.cpp $source.$cxxsuffix ; "
1436
unless "cpp" eq $cxxsuffix;
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";
1443
$rule_adds{"$source.$cxxsuffix"} = $dep_lines;
1445
$kcfgFiles{$source} = 1;
1448
if ($program =~ /_la$/) {
1449
$realObjs{$program} .= " $source.lo";
1451
$realObjs{$program} .= " $source.\$(OBJEXT)";
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/ );
1074
my $lookup = '([^\s]*)_ICON\s*=\s*([^\n]*)';
1466
my $lookup = '([^\s]*)_ICON\s*=[ \t]*(.*)';
1075
1467
my $install = "";
1076
1468
my $uninstall = "";
1078
while ($MakefileData =~ /\n$lookup/og) {
1470
while ($MakefileData =~ /\n$lookup/g) {
1080
1472
if ($1 eq "KDE") {
1081
1473
$destdir = "kde_icondir";
1427
1858
$closure_output .= " $closure";
1861
sub tag_NMCHECK () {
1862
return if ($program !~ /_la$/);
1863
my $lookup = quotemeta($realname{$program}) . ":.*?\n\t.*?\\((.*?)\\) .*\n";
1864
$MakefileData =~ m/$lookup/;
1866
return if (!defined($1));
1867
return if ($linkcmd !~ /CXXLINK/ && $linkcmd !~ /LINK/);
1869
$lookup = $program . '_NMCHECK\s*=([^\n]*)';
1870
if( $MakefileData !~ m/\n$lookup\n/ ) {
1874
$allowed =~ s/^ *//;
1875
$lookup = $program . '_NMCHECKWEAK\s*=([^\n]*)';
1878
if( $MakefileData =~ m/\n$lookup\n/ ) {
1886
$weak = '--allowweak=\'' . $weak . '\' ';
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/ ) {
1892
substituteLine( $lookup, $oldstuff . "\n" . $nmline );
1894
$lookup = '(\t\$\(LINK\)[^\n]*' . $program . '_OBJECTS[^\n]*)';
1895
if( $MakefileData =~ /\n$lookup\n/ ) {
1897
substituteLine( $lookup, $oldstuff . "\n" . $nmline );
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} ";
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;
1440
1914
closedir (THISDIR);
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});
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});
1764
2237
$dir =~ s#^\.#\$(srcdir)#;
1765
2238
if (defined ($cppFile))
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");
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");
2256
sub make_bcheck_target()
2258
my $lookup = 'RECURSIVE_TARGETS\s*=[ \t]*(.*)';
2259
my $bcheckdep = "bcheck-am";
2260
$bcheckdep = "bcheck-recursive" if ($MakefileData =~ /\n$lookup/);
2263
$headers = $1 if($MakefileData =~ /\nHEADERS\s*=[ \t]*(.+)/);
2264
$headers =~ s/\$\((?:noinst|EXTRA)_HEADERS\)//g;
2266
$target_adds{"clean-am"} .= "clean-bcheck ";
2268
my $t = "clean-bcheck: \n" .
2269
"\trm -f *.bchecktest.cc *.bchecktest.cc.class a.out\n\n" .
2270
"bcheck: $bcheckdep\n\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" .
2278
$t .= $cxxsuffix eq "KKK" ?
2279
"\$(CXX) \$(DEFS) -I. -I\$(srcdir) -I\$(top_builddir) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(KDE_CXXFLAGS) " :
2281
$t .= " --dump-class-hierarchy -c \$\$i.bchecktest.cc; then \\\n" .
2282
"\t rm -f \$\$i.bchecktest.cc; exit 1; \\\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" .
2289
appendLines("$t\n");
1779
2292
sub make_meta_classes ()
1781
2294
return if ($kdeopts{"qtonly"});