Ideally the IDE should define a symbol that tells you the target/core/variant which is selected from the Tools > Boards menu. That's not a new idea... but it's never gone anywhere. I'm pretty sure it's in the issue tracker, but I'm not going to go look up the issue number right now.
For an immediate solution, after you include Arduino.h or WProgram.h, you can check for CORE_TEENSY to determine if a Teensy board is in use. For example:
#ifdef __AVR_ATmega32U4__
#ifdef CORE_TEENSY
// it's Teensy 2.0
#else
// it's probably Leonardo
#endif
#endif
Hopefully the IDE will someday provide more descriptive info about which board, or target/core/variant, or platform/target/core/variant, or whatever future schema combination, is in use.