There are many libraries who do this and you could take as an example. E.g. my MobaTools lib. Look into MobaTools.h to distinguish between different architectures.
Usually there are defines for the architecture and for the specific board. One way to see what is defined is to mark 'Show verbose output during compilation'. These defines are set as -D options when starting gcc, which you can see when this mark is set.
E.g. for a Nano: ... -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR ...
Thanks #MicroBahner but I'm not much further forward. #elif defined ARDUINO_ARCH_ESP32 - I know this refers to the ESP32 boards, but there are different ones with different pin-outs.
I DONT know how to write a similar define for eg a Micro Pro board.
And I've looked at libraries 'til I'm getting snow blind, without finding something simple that sets up an IO library to cover a range of "beginner" boards like the Uno, MEga, Nano & Micro. @jremington I remember you showed me a library (or sketch) like this a while back?
Did you have a look at the 'Show verbose output during compilation'? Every information you search is contained there. E.g. for the ESP32 Pico board: -DARDUINO_ESP32_PICO -DARDUINO_ARCH_ESP32
And there are even more board specific defines.
The lines with this information are fairly long. The easiest way ist to copy one line of a compiler call into an editor and search for '-D'
Of course you must have the boards installed and selected which you are searching for.
It's not as easy to find this information in the board specific core files, because these defines are concatenated from different sources. So in my opinion the easiest way is to have a look at the compiler calls.