A few questions to consider:
1. do you plan to do any racing with the car? (drag, track, autocross)
2. do you contend with inclimate weather? or is this an additional vehicle
3. are you okay with the risk of potentially expensive repairs (aka BMW M3)
4. do you need a trunk or the ability to haul anything?
5. preference of new or used?
In the world of the internet, Miata is often times called M.I.A.T.A. or "Miata is always the answer" now before you tell me that you want more power not less, if you plan to track or autocross the car the Miata is a ton of fun to drive. An alternative to the Miata is the Toyota 86/Subaru FR-S. These are both small 4 cyl. sports cars that harken back to the basic cars that are alot of fun to drive and in expensive to own. It is alot more fun to drive a slow car fast then it is to drive a fast car slow.
The others have already discussed the camaro & mustang and both are great cars, both are very capable, and both can be had for $40k with v8's.The other new car that I would add to the list is the Nissan 370z. However, it is a dated platform compared to the much more competitive Mustang & Camaro chassis.
However, if you go into the used market, $40k can buy alot of car. BMW M3, Chevrolet Corvette, Audi S5, and Cadillac CTS-V are 2 door cars that are available in manual transmissions and will provide a variety of options.
The Chevrolet Corvette is a great car, and you can certainly get a c6 and might be able to find a c7 in your budget. The BMW & Audi are going to be more expensive options requiring you to go back at least 1 generation. They are most likely to provide features and comforts that are beyond what you are looking for. THe CTS-V is a brutal car (550+ supercharged horsepower, very nice interior, etc.) but will not have the handling capabilities of the M3 or corvette.
If it were my money, I would probably look at the M3 and compare a used one /w extended warranty to the Camaro/Mustang, but if it was not your only car, the Corvette/Miata is probably going to provide the most rewarding driving experience.
I hope this helps.