base_url in settings.php with mobile version
How is your /sites folder structure? You can create subdomain m.example.com, and implement the mobile version in there. 

There are different approaches in implementing the subdomains in drupal. it may be multisite and shared database or multisite with different databases and single code and different databases .

what you are looking for is a shared database but different themes (multiple codes), Here is good discussion about this.