I'm working on a library to support both Yún and non-Yún Arduinos. The code for the two cases is quite different (for the Yún I use the Bridge library which isn't available for other Arduinos).
To accommodate this, I use #ifdef ... #else ... #endif and put the Yún code in one part and the non-Yún code in the other part. Normally, I would use one of the symbols the compiler creates for type of processor, etc. to determine which board was being used. But, since the Yún and Leonardo share the same processor, the only symbol I could come up with unique to the Yún was SERIAL_PORT_LINUXBRIDGE (defined in Arduino.h). So, I have something like:
... Yún-specific code
... Non-Yún code
This works, but seems a little shaky to me. Does anyone have a suggestion about a better way to handle this?