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