1. you can create a sandbox solution and deploy it to specific web application.
2. if you cannot convert it into sandbox solution and need globally deployed, create feature scoped at web application level, or have feature dependency so that you can validate the activation accordingly.
Check this out it might give an insight for what you want http://stackoverflow.com/questions/4086460/creating-a-solution-that-deploys-to-selected-webapplications-but-copies-the-asse/4165281#4165281
Raghavendra Shanbhag | Blog: www.SharePointColumn.com
Please click "Propose As Answer " if a post solves your problem or "Vote As Helpful" if a post has been useful to you.
Disclaimer: This posting is provided "AS IS" with no warranties.