112
114
$verbose = 1; # Oh is there a problem...?
114
elsif (/^-p(.+)$|^--path=(.+)$/)
116
elsif (/^(?:-p|--path=)(.+)$/)
116
$thisProg = "$1/".basename($thisProg) if($1);
117
$thisProg = "$2/".basename($thisProg) if($2);
119
$thisProg = $p . "/". basename($thisProg);
118
120
warn ("$thisProg doesn't exist\n") if (!(-f $thisProg));
121
$thisProg .= " -p".$p;
121
124
elsif (/^--help$|^-h$/)
222
225
local %globalmocs = ();# list of all mocfiles (in %mocFiles format)
223
226
local %important = (); # list of files to be generated asap
224
227
local %uiFiles = ();
228
local %kcfgFiles = ();
226
230
local $allidls = "";
227
231
local $idl_output = "";# lists all idl generated files for cleantarget
228
232
local $ui_output = "";# lists all uic generated files for cleantarget
233
local $kcfg_output = "";# lists all kcfg generated files for cleantarget
230
235
local %dependmocs = ();
263
268
tag_NO_UNDEFINED();
266
tag_UIFILES(); # Sorts out ui rules
271
tag_UIFILES(); # Sorts out ui rules
272
tag_KCFGFILES(); # Sorts out kcfg rules
267
273
tag_METASOURCES (); # Sorts out the moc rules
268
274
if ($sources_changed{$program}) {
269
275
my $lookup = $program . '_SOURCES\s*=[ \t]*(.*)';
271
277
if($program =~ /libkdeinit_(.*)/) {
273
substituteLine($prog . '_SOURCES\s*=[ \t]*.*',
279
substituteLine($prog . '_SOURCES\s*=[ \t]*(.*)',
274
280
"${prog}_SOURCES = ${prog}_dummy.$cxxsuffix\n" .
275
281
"libkdeinit_${prog}_SOURCES = " . $sources{$program});
276
282
$sources{$prog} = "${prog}_dummy.$cxxsuffix";
320
326
$target_adds{"$cleantarget-am"} .= "$cleantarget-ui ";
330
appendLines ("$cleantarget-kcfg:\n\t-rm -f $kcfg_output\n");
331
$target_adds{"$cleantarget-am"} .= "$cleantarget-kcfg ";
323
334
if ($closure_output) {
324
335
appendLines ("$cleantarget-closures:\n\t-rm -f $closure_output\n");
325
336
$target_adds{"$cleantarget-am"} .= "$cleantarget-closures ";
411
422
substituteLine($lookup, "RECURSIVE_TARGETS = $1 nmcheck-recursive bcheck-recursive");
414
my $cvs_lines = "cvs-clean:\n";
415
$cvs_lines .= "\t\$(MAKE) admindir=\$(top_srcdir)/admin -f \$(top_srcdir)/admin/Makefile.common cvs-clean\n";
416
appendLines($cvs_lines);
418
425
$cvs_lines = "kde-rpo-clean:\n";
419
426
$cvs_lines .= "\t-rm -f *.rpo\n";
420
427
appendLines($cvs_lines);
472
479
$MakefileData =~ s/$lookup/$replacement/;
473
480
$lookup =~ s/\\\$\\\(CXXFLAGS\\\)/\\\$\\\(KCXXFLAGS\\\)/;
474
481
$replacement = "$stuff_before\$(KCXXFLAGS) \$(KDE_CXXFLAGS)$stuff_after";
482
next if ($stuff_before =~ /\$\(KDE_CXXFLAGS\)/ or $stuff_after =~ /\$\(KDE_CXXFLAGS\)/);
475
483
substituteLine($lookup, $replacement);
529
537
# Checking for files to process...
530
open (FILEIN, $makefile)
531
|| die "Could not open $makefileDir/$makefile: $!\n";
539
open (FILEIN, $makefile) || die "Can't open $makefileDir/$makefile: $!\n";
540
# perl bug in 5.8.0: in utf8 mode it badly screws up
541
binmode(FILEIN, ":bytes") if ($] >= 5.008);
533
543
# stat(FILEIN)[7] might look more elegant, but is slower as it
534
544
# requires stat'ing the file
621
631
if ($pre eq '' && exists($varcontent{$variable})) {
622
632
my @addlist = split(/[\034\s]+/, $varcontent{$variable});
623
633
push(@objlist, @addlist);
624
} elsif ($variable !~ 'OBJEXT') {
634
} elsif ($variable !~ 'OBJEXT' && $variable !~ /am__objects_\d+/ ) {
751
762
$moc_cpp_added = 1;
766
# scan for extra given dependencies and add them to our target
767
while ($MakefileData =~ /\n\s*(\S+)\.(?:lo|o)\s*:([^\n]*)/g) {
754
771
foreach $suffix (keys %sourcelist) {
756
772
# See if this file contains c++ code. (i.e., just check the file's suffix against c++ extensions)
757
773
my $suffix_is_cxx = 0;
758
774
if($suffix =~ /($cppExt)$/) {
769
785
# we support IDL on our own
770
786
if ($suffix eq "skel" || $suffix =~ /^stub/
771
787
|| $suffix =~ /^signals/ # obsolete, remove in KDE-4
772
|| $suffix eq "h" || $suffix eq "ui" ) {
788
|| $suffix eq "h" || $suffix eq "ui"
789
|| $suffix eq "kcfgc" ) {
794
811
$source_deps .= " $source";
813
my $plainsource = $source;
814
$plainsource =~ s/\.$cppExt$//;
815
$source_deps .= " " . $extradeps{$plainsource} if (exists($extradeps{$plainsource}));
798
818
$handling = "$program.all_$suffix.$suffix: \$(srcdir)/Makefile.in" . $source_deps . " " . join(' ', $mocs) . "\n";
852
872
$lines .= "\techo 'int main(int argc, char* argv[]) { return kdemain(argc,argv); }' >> ${kdeinit}.la.$cxxsuffix\n";
854
874
$lines .= "\n${kdeinit}_dummy.$cxxsuffix:\n";
855
$lines .= "\t echo > ${kdeinit}_dummy.$cxxsuffix\n";
875
$lines .= "\techo '#include <kdemacros.h>' > ${kdeinit}_dummy.$cxxsuffix; \\\n";
876
$lines .= "\techo 'extern \"C\" int kdemain(int argc, char* argv[]);' >> ${kdeinit}_dummy.$cxxsuffix; \\\n";
877
$lines .= "\techo 'extern \"C\" KDE_EXPORT int kdeinitmain(int argc, char* argv[]) { return kdemain(argc,argv); }' >> ${kdeinit}_dummy.$cxxsuffix\n";
857
879
push(@cleanfiles, "${kdeinit}.la.$cxxsuffix");
858
880
push(@cleanfiles, "${kdeinit}_dummy.$cxxsuffix");
868
890
substituteLine($lookup, "${kdeinit}_la_LIBADD = libkdeinit_${kdeinit}.la");
869
891
appendLines("libkdeinit_${kdeinit}_la_LIBADD = $libadd\n");
871
appendLines("libkdeinit_${kdeinit}_la_LDFLAGS = \$(all_libraries)\n");
893
appendLines("libkdeinit_${kdeinit}_la_LDFLAGS = -no-undefined -avoid-version \$(all_libraries)\n");
873
895
# add library dependencies
874
896
$lookup = $kdeinit . '_la_DEPENDENCIES\s*=[ \t]*(.*)';
944
966
$realname{$kdeinit} = $kdeinit;
945
967
$sources{$kdeinit} = "${kdeinit}.la.$cxxsuffix";
947
$lines .= "${kdeinit}_LDFLAGS = \$(all_libraries)\n";
969
$lines .= "${kdeinit}_LDFLAGS = \$(KDE_RPATH) -no-undefined \$(all_libraries)\n";
948
970
$lines .= "${kdeinit}_LDADD = libkdeinit_${kdeinit}.la\n";
949
971
$lines .= "${kdeinit}_DEPENDENCIES = libkdeinit_${kdeinit}.la\n";
1026
1048
next if defined($donesources{$depend});
1027
1049
push @deps, $depend;
1029
$target_adds{$sdeps} = join(' ', @deps) if (@deps);
1051
$target_adds{$sdeps} .= join(' ', @deps) . ' ' if (@deps);
1030
1052
$donesources{$source} = 1;
1123
1145
print STDOUT "AUTOMAKE processing <$1>\n" if ($verbose);
1125
1147
my $newLine = $1."\n\tcd \$(top_srcdir) && perl $thisProg $printname";
1149
# automake 1.8.x adds another automake call. *sigh*
1150
$newLine =~ s/;([\034\s]+cd\s+\$\(srcdir\)\s+&&[\034\s]+\$\(AUTOMAKE\).*)[\034\s]+\&\&[\034\s]+exit[\034\s]+0;([\034\s]+exit\s+1)/; \034 ( $1 ) || exit 1; echo \' cd \$(top_srcdir) && perl $thisProg \'; cd \$(top_srcdir) && perl $thisProg && exit 0; $2/;
1126
1151
substituteLine ($lookup, $newLine);
1127
1152
$automkCall = $1;
1129
1154
$lookup = '.*cd \$\(srcdir\)\s+&&[\034\s]+\$\(AUTOCONF\)(.*)';
1130
1155
if ($MakefileData =~ /\n($lookup)\n/) {
1131
$newLine = "\tcd \$(srcdir) && rm -f configure && \$(MAKE) -f admin/Makefile.common configure";
1156
$newLine = "\tcd \$(srcdir) && rm -f configure\n";
1157
$newLine .= "\tcd \$(top_srcdir) && \$(MAKE) -f admin/Makefile.common configure";
1132
1158
substituteLine ($lookup, $newLine);
1237
1263
if ($allidls !~ /$source\_kidl/) {
1265
$use_ng = ($MakefileData =~ /\n$source\_DCOPIDLNG\s*=\s*(\S+)\n/);
1266
$dcopidl = $use_ng ? "KDECONFIG=\"\$(KDECONFIG)\" \$(DCOPIDLNG)" : "\$(DCOPIDL)";
1239
1268
$dep_lines .= "$source.kidl: $sourcedir$source.h \$(DCOP_DEPENDENCIES)\n";
1240
$dep_lines .= "\t\$(DCOPIDL) $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; false )\n";
1269
$dep_lines .= "\t$dcopidl $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; false )\n";
1242
1271
$allidls .= $source . "_kidl ";
1332
1361
my $dep_lines = "$source.$cxxsuffix: $sourcedir$source.ui $source.h $source.moc\n";
1333
1362
$dep_lines .= "\trm -f $source.$cxxsuffix\n";
1334
1363
if (!$kdeopts{"qtonly"}) {
1335
$dep_lines .= "\techo '#include <klocale.h>' > $source.$cxxsuffix\n";
1364
$dep_lines .= "\techo '#include <kdialog.h>' > $source.$cxxsuffix\n";
1365
$dep_lines .= "\techo '#include <klocale.h>' >> $source.$cxxsuffix\n";
1336
1366
my ($mangled_source) = $source;
1337
1367
$mangled_source =~ s/[^A-Za-z0-9]/_/g; # get rid of garbage
1338
1368
$dep_lines .= "\t\$(UIC) -tr \${UIC_TR} -i $source.h $sourcedir$source.ui > $source.$cxxsuffix.temp ; ret=\$\$?; \\\n";
1339
$dep_lines .= "\tsed -e \"s,\${UIC_TR}( \\\"\\\" ),QString::null,g\" $source.$cxxsuffix.temp | sed -e \"s,\${UIC_TR}( \\\"\\\"\\, \\\"\\\" ),QString::null,g\" | sed -e \"s,image\\([0-9][0-9]*\\)_data,img\\1_" . $mangled_source . ",g\" >> $source.$cxxsuffix ;\\\n";
1369
$dep_lines .= "\t\$(PERL) -pe \"s,\${UIC_TR}( \\\"\\\" ),QString::null,g\" $source.$cxxsuffix.temp | \$(PERL) -pe \"s,\${UIC_TR}( \\\"\\\"\\, \\\"\\\" ),QString::null,g\" | \$(PERL) -pe \"s,image([0-9][0-9]*)_data,img\\\$\$1_" . $mangled_source . ",g\" | \$(PERL) -pe \"s,: QWizard\\(,: KWizard(,g\" >> $source.$cxxsuffix ;\\\n";
1340
1370
$dep_lines .= "\trm -f $source.$cxxsuffix.temp ;\\\n";
1342
1372
$dep_lines .= "\t\$(UIC) -i $source.h $sourcedir$source.ui > $source.$cxxsuffix; ret=\$\$?; \\\n";
1344
1374
$dep_lines .= "\tif test \"\$\$ret\" = 0; then echo '#include \"$source.moc\"' >> $source.$cxxsuffix; else rm -f $source.$cxxsuffix ; exit \$\$ret ; fi\n\n";
1345
1375
$dep_lines .= "$source.h: $sourcedir$source.ui\n";
1346
$dep_lines .= "\t\$(UIC) -o $source.h $sourcedir$source.ui\n\n";
1376
$dep_lines .= "\trm -rf $source.h;\n";
1377
if (!$kdeopts{"qtonly"}) {
1378
$dep_lines .= "\t\$(UIC) $sourcedir$source.ui | \$(PERL) -pi -e \"s,public QWizard,public KWizard,g; s,#include <qwizard.h>,#include <kwizard.h>,g\" >> $source.h ;\n";
1380
$dep_lines .= "\t\$(UIC) -o $source.h $sourcedir$source.ui\n";
1347
1382
$dep_lines .= "$source.moc: $source.h\n";
1348
1383
$dep_lines .= "\t\$(MOC) $source.h -o $source.moc\n";
1364
1399
$important{$program} .= "$source.h ";
1365
1400
$ui_output .= "\\\n\t$source.$cxxsuffix $source.h $source.moc ";
1366
1401
push(@cleanfiles, "$source.$cxxsuffix");
1367
push(@cleanfiles, "source.h");
1402
push(@cleanfiles, "$source.h");
1368
1403
push(@cleanfiles, "$source.moc");
1369
1404
$dep_files .= " \$(DEPDIR)/$source.P" if($dep_files !~/$source.P/ );
1409
sub tag_KCFGFILES ()
1411
my @psources = split(/[\034\s]+/, $sources{$program});
1414
foreach $source (@psources) {
1416
if ($source =~ m/\.kcfgc$/) {
1418
print STDERR "adding KCFG file $source\n" if ($verbose);
1420
my $qs = quotemeta($source);
1421
$sources{$program} =~ s/$qs//;
1422
$sources_changed{$program} = 1;
1424
$source =~ s/\.kcfgc$//;
1427
if (-f "$makefileDir/$source.kcfgc") {
1428
$sourcedir = '$(srcdir)/';
1431
if (!$kcfgFiles{$source}) {
1432
$kcfg = "$program.kcfg";
1433
findKcfgFile("$source.kcfgc");
1436
$fixsuffix = "else mv $source.cpp $source.$cxxsuffix ; "
1437
unless "cpp" eq $cxxsuffix;
1439
my $dep_lines = "$source.$cxxsuffix: $source.h\n";
1440
$dep_lines .= "$source.h: $sourcedir$kcfg $sourcedir$source.kcfgc \$(KCFG_DEPENDENCIES)\n";
1441
$dep_lines .= "\t\$(KCONFIG_COMPILER) $sourcedir$kcfg $sourcedir$source.kcfgc; ret=\$\$?; \\\n";
1442
$dep_lines .= "\tif test \"\$\$ret\" != 0; then rm -f $source.h ; exit \$\$ret ; $fixsuffix fi\n\n";
1444
$rule_adds{"$source.$cxxsuffix"} = $dep_lines;
1446
$kcfgFiles{$source} = 1;
1449
if ($program =~ /_la$/) {
1450
$realObjs{$program} .= " $source.lo";
1452
$realObjs{$program} .= " $source.\$(OBJEXT)";
1454
$sources{$program} .= " $source.$cxxsuffix";
1455
$sources_changed{$program} = 1;
1456
$important{$program} .= "$source.h ";
1457
$kcfg_output .= "\\\n\t$source.$cxxsuffix $source.h ";
1458
push(@cleanfiles, "$source.$cxxsuffix");
1459
push(@cleanfiles, "$source.h");
1460
$dep_files .= " \$(DEPDIR)/$source.P" if($dep_files !~/$source.P/ );
1376
1467
my $lookup = '([^\s]*)_ICON\s*=[ \t]*(.*)';
1644
1735
$pofiles = join(" ", grep(/\.po$/, readdir(THISDIR)));
1645
1736
closedir (THISDIR);
1646
1737
print STDOUT "pofiles found = $pofiles\n" if ($verbose);
1647
if (-f "charset" && -f "kdelibs.po") {
1738
if (-f "charset" && -f "kdelibs/kdelibs.po") {
1648
1739
handle_TOPLEVEL();
1938
2029
$lines .= "\n";
1939
2030
$lines .= "uninstall-docs:\n";
1940
$lines .= "\t-rm -rf \$(kde_htmldir)/$kdelang/$appname\n";
2031
$lines .= "\t-rm -rf \$(DESTDIR)\$(kde_htmldir)/$kdelang/$appname\n";
1941
2032
$lines .= "\n";
1942
2033
$lines .= "clean-docs:\n";
1943
2034
$lines .= "\t-rm -f index.cache.bz2\n";
2186
2277
"\t echo \"\$\$i\"; \\\n" .
2188
2279
$t .= $cxxsuffix eq "KKK" ?
2189
"\$(CXX) \$(DEFS) -I. -I\$(srcdir) -I\$(top_builddir) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(KDE_CXXFLAGS) " :
2280
"\$(CXX) \$(DEFS) -I. -I\$(srcdir) -I\$(top_builddir) \$(INCLUDES) \$(AM_CPPFLAGS) \$(CPPFLAGS) \$(CXXFLAGS) \$(KDE_CXXFLAGS) " :
2190
2281
"\$(CXXCOMPILE) ";
2191
$t .= " --dump-class-hierarchy \$\$i.bchecktest.cc; then \\\n" .
2282
$t .= " --dump-class-hierarchy -c \$\$i.bchecktest.cc; then \\\n" .
2192
2283
"\t rm -f \$\$i.bchecktest.cc; exit 1; \\\n" .
2193
2284
"\t fi ; \\\n" .
2194
2285
"\t echo \"\" >> \$\$i.bchecktest.cc.class; \\\n" .
2262
2353
$MakefileData =~ s/\034/\\\n/g; # Restore continuation lines
2263
2354
# Append our $progId line, _below_ the "generated by automake" line
2264
2355
# because automake-1.6 relies on the first line to be his own.
2265
my $progIdLine = "\# $progId - " . '$Revision: 1.3 $ '."\n";
2356
my $progIdLine = "\# $progId - " . '$Revision: 1.4 $ '."\n";
2266
2357
if ( !( $MakefileData =~ s/^(.*generated .*by automake.*\n)/$1$progIdLine/ ) ) {
2267
2358
warn "automake line not found in $makefile\n";
2268
2359
# Fallback: first line
2339
2430
#-----------------------------------------------------------------------------
2432
# find the .kcfg file listed in the .kcfgc file
2436
open (KCFGFIN, $kcfgf) || die "Could not open $kcfgf: $!\n";
2437
seek(KCFGFIN, 0, 2);
2438
my $kcfgfsize = tell(KCFGFIN);
2439
seek(KCFGFIN, 0, 0);
2440
read KCFGFIN, $kcfgfData, $kcfgfsize;
2442
if(($kcfgfData =~ m/^File=(.*\.kcfg)/gm)) {