Finding a solution in the general case can be quite challenging. It's not about detecting the browser, which can be done using various methods. The real challenge lies in determining screen sizes, HTML support, and overall device capabilities.
A notable open-source project, known as WFURL, keeps a comprehensive database of supported devices and their features, making integration easier.
One approach is to utilize a framework like JQuery Mobile, which offers a consistent user experience across different phones. However, this framework is still in its early stages of development.
Major websites such as Mercedes Benz, eBay, MTV India, and Google often use tools like [NetBiscuits] (http://www.netbiscuits.com/) to create mobile-friendly sites. With NetBiscuits, developers can write code once (in BiscuitML) and let the platform handle device detection and site optimization. You can see examples of companies using NetBiscuits at this link.
While NetBiscuits is a popular choice, there are other frameworks available (such as IBM's solution in websphere portal server) that offer similar functionalities.