Shared admin folder
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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