Index: am_edit
===================================================================
RCS file: /home/kde/kde-common/admin/am_edit,v
retrieving revision 1.360
diff -u -u -b -r1.360 am_edit
--- am_edit	6 Mar 2003 17:51:02 -0000	1.360
+++ am_edit	16 Mar 2003 18:16:28 -0000
@@ -208,6 +208,7 @@
     local $cxxsuffix  = "KKK";
 
     local @programs = ();  # lists the names of programs and libraries
+    local @kdeinit_programs = (); # programs that will have a library gen'd
     local $program = "";
 
     local %realObjs = ();  # lists the objects compiled into $program
@@ -330,6 +331,9 @@
     make_bcheck_target();
     make_meta_classes();
     tag_COMPILE_FIRST();
+
+    tag_KDEINIT();
+
     tag_FINAL() if (!$kdeopts{"nofinal"});
 
     my $final_lines = "final:\n\t\$(MAKE) ";
@@ -361,6 +365,7 @@
         }
         substituteLine ($lookup, $new);
     }
+
     appendLines($final_lines . "all-am");
     appendLines($final_install_lines . "install-am");
     appendLines($nofinal_lines . "all-am");
@@ -539,6 +544,10 @@
 
     read_variables();
 
+    if ($MakefileData =~ /\nKDEINIT\s*=\s*([^\n]*)\n/) {
+      @kdeinit_programs = split(/[\s\034]/, $1);
+    }
+
     if ($MakefileData =~ /\nKDE_OPTIONS\s*=\s*([^\n]*)\n/) {
 	my $kde_options_str = $1;
         local @kde_options = split(/[\034\s]+/, $kde_options_str);
@@ -658,6 +667,94 @@
 
 #-----------------------------------------------------------------------------
 
+sub tag_KDEINIT ()
+{
+    # generate am code for "virtual" kdeinit libraries
+    foreach $program (@kdeinit_programs) {
+      local $kdeinit_libs;
+      local $kdeinit_deps;
+
+      if ($MakefileData =~ /\nlib_LTLIBRARIES\s*=([^\n]*)/) {
+        local $ltlibraries = $1;
+        substituteLine('lib_LTLIBRARIES\s*=([^\n]*)', "lib_LTLIBRARIES = $ltlibraries libkdeinit_${program}.la");
+      } else {
+        appendLines("lib_LTLIBRARIES = libkdeinit_${program}.la ${program}.la");
+      }
+
+      if ($MakefileData =~ /\nkde_module_LTLIBRARIES\s*=([^\n]*)/) {
+        local $ltmodules = $1;
+        substituteLine('kde_module_LTLIBRARIES\s*=([^\n]*)', "kde_module_LTLIBRARIES = $ltmodules ${program}.la");
+      } else {
+        appendLines("kde_module_LTLIBRARIES = ${program}.la");
+      }
+
+      if ($MakefileData =~ /\n${program}_LDADD\s*=([^\n]*)\n/) {
+        $kdeinit_libs = $1;
+#        print "kdeinit_libs = $kdeinit_libs\n";
+      }
+      if ($MakefileData =~ /\n${program}_DEPENDENCIES\s*=([^\n]*)\n/) {
+        $kdeinit_deps = $1;
+#        print "kdeinit_deps = $kdeinit_deps\n";
+      }
+
+      substituteLine ($program.'_SOURCES\s*=[^\n]*',       "${program}_SOURCES = kdeinit_${program}.cpp\n");
+      substituteLine ($program.'_LDADD\s*=[^\n]*',         "${program}_LDADD = libkdeinit_${program}.la\n");
+      substituteLine ('am_'.$program.'_OBJECTS\s*=[^\n]*', "am_${program}_OBJECTS = kdeinit_${program}.\$(OBJEXT)\n");
+      substituteLine ($program.'_DEPENDENCIES\s*=[^\n]*',  "${program}_DEPENDENCIES = libkdeinit_${program}.la\n");
+
+      if ($MakefileData =~ /\n(DIST_SOURCES\s*=[^\n]*)/) {
+        local $old = $1;
+        $MakefileData =~ s/\nDIST_SOURCES\s*=[^\n]*/\n$old \$(${program}_la_SOURCES) \$(libkdeinit_${program}_la_SOURCES)/g;
+      }
+
+      if ($MakefileData =~ /\n(SOURCES\s*=[^\n]*)/) {
+        local $old = $1;
+        $MakefileData =~ s/\nSOURCES\s*=[^\n]*/\n$old \$(${program}_la_SOURCES) \$(libkdeinit_${program}_la_SOURCES)/g;
+      }
+
+      $kdeinit_am_lines  = "libkdeinit_${program}_la_LDFLAGS = \$(${program}_LDFLAGS) -avoid-version\n";
+      $kdeinit_am_lines .= "libkdeinit_${program}_la_SOURCES = $sources{$program}\n";
+      $kdeinit_am_lines .= "libkdeinit_${program}_la_LIBADD  = $kdeinit_libs\n";
+      $kdeinit_am_lines .= "\n";
+      $kdeinit_am_lines .= "libkdeinit_${program}_la_DEPENDENCIES = $kdeinit_deps\n";
+      $kdeinit_am_lines .= "am_libkdeinit_${program}_la_OBJECTS = $realObjs{$program}\n";
+      $kdeinit_am_lines .= "libkdeinit_${program}_la_OBJECTS = \$(am_libkdeinit_${program}_la_OBJECTS)\n";
+      $kdeinit_am_lines .= "\n";
+      $kdeinit_am_lines .= "libkdeinit_${program}.la: \$(libkdeinit_${program}_la_OBJECTS) \$(libkdeinit_${program}_la_DEPENDENCIES) \n";
+      $kdeinit_am_lines .= "	\$(CXXLINK) -rpath \$(libdir) \$(libkdeinit_${program}_la_LDFLAGS) \$(libkdeinit_${program}_la_OBJECTS) \$(libkdeinit_${program}_la_LIBADD) \$(LIBS)\n";
+      $kdeinit_am_lines .= "\n";
+      $kdeinit_am_lines .= "${program}_la_LDFLAGS = \$(${program}_LDFLAGS) -avoid-version -module\n";
+      $kdeinit_am_lines .= "${program}_la_SOURCES = kdeinit_${program}_la.cpp\n";
+      $kdeinit_am_lines .= "${program}_la_LIBADD  = libkdeinit_${program}.la\n";
+      $kdeinit_am_lines .= "\n";
+      $kdeinit_am_lines .= "${program}_la_DEPENDENCIES = libkdeinit_${program}.la\n";
+      $kdeinit_am_lines .= "am_${program}_la_OBJECTS = libkdeinit_${program}.la.lo\n";
+      $kdeinit_am_lines .= "${program}_la_OBJECTS = \$(am_${program}_la_OBJECTS)\n";
+      $kdeinit_am_lines .= "\n";
+      $kdeinit_am_lines .= "${program}.la: \$(${program}_la_OBJECTS) \$(${program}_la_DEPENDENCIES) \n";
+      $kdeinit_am_lines .= "	\$(CXXLINK) -rpath \$(libdir) \$(${program}_la_LDFLAGS) \$(${program}_la_OBJECTS) \$(${program}_la_LIBADD) \$(LIBS)\n";
+      $kdeinit_am_lines .= "\n";
+      $kdeinit_am_lines .= "kdeinit_${program}.la.cpp kdeinit_${program}.cpp:\n";
+      $kdeinit_am_lines .= "	echo 'extern \"C\" int kdemain(int, char* []);' > \$@\n";
+      $kdeinit_am_lines .= "	echo 'int main( int argc, char* argv[] ) { return kdemain(argc, argv); }' >> \$@\n";
+
+      appendLines($kdeinit_am_lines);
+
+      push(@programs, "${program}_la", "libkdeinit_${program}_la");
+
+      $sources{"libkdeinit_${program}_la"} = $sources{$program};
+      $sources{"${program}_la"} = "kdeinit_${program}.la.cpp";
+      $sources{$program} = "kdeinit_${program}.cpp";
+
+      $realObjs{"libkdeinit_${program}_la"} = $realObjs{$program};
+      $realObjs{"${program}_la"} = "kdeinit_${program}.la.\$(OBJEXT)";
+      $realObjs{$program} = "kdeinit_${program}.\$(OBJEXT)";
+
+    }
+}
+
+#-----------------------------------------------------------------------------
+
 # Gets the list of user defined directories - relative to $srcdir - where
 # header files could be located.
 sub tag_META_INCLUDES ()
@@ -1044,7 +1141,7 @@
             if ($allidls !~ /$source\_kidl/) {
                 
                 $dep_lines .= "$source.kidl: $sourcedir$source.h \$(DCOP_DEPENDENCIES)\n";
-                $dep_lines .= "\t\$(DCOPIDL) $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; /bin/false )\n";
+                $dep_lines .= "\t\$(DCOPIDL) $sourcedir$source.h > $source.kidl || ( rm -f $source.kidl ; false )\n";
                 
                 $allidls .= $source . "_kidl ";
             }
