how about a specififier in each ebuild stating whether or not the ebuild is a library. Then when emerge clean is executed it checks whether each library is used or not, if the library is unused then it is removed from the system.
the problem with this is, what if the user writes their own code to utilize a library, but no other packages installed by gentoo do ? or what if the user installs packages to /usr/local that utilize these libraries ? granted the idea is pretty cool, but i think it is really impossible to do in practice (without scanning the entire harddrive, doin ldd on all executables ... but this of course assumes that the user does not link statically and the user does write code in interpreted languages (perl/php/python/etc...) that load libraries themselves
to combat the things not installed by portage problem how about an emerge parameter that can be used somthing like the following: emerge depend SDL creating a false dependancy for SDL and: emerge undepend SDL removing that false dependancy most people who install packages some other method than emerge will probably be capable of using depend/undepend.
umm, i dont know what you mean by your last comment 'things not installed by portage problem' are you refering to the `emerge --inject` functionality ? `emerge --help`: inject (-i short option) Add a stub entry for a package so that Portage thinks that it's installed when it really isn't. Handy if you roll your own packages. Example: emerge inject gentoo-sources-2.4.19
I agree this functionality is too complex to try and work out now... For a similar functionality that already exists try dep-clean in the gentoolkit package... it lists all packages that are not depended on by something else, and then you have to make the decision which ones can be unmerged safely. that moment of human decision is difficult to catagorize as you say everything being either being a library or a application
emerge depclean In portage-2.0.40+ Dangerous if you misuse it... but it does exactly what I think you want.