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