Detect if Serial1 and Serial2 are defined, at compile time
HardwareSerial.h in Arduino AVR boards core defines HAVE_HWSERIALX
example
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif
HardwareSerial.h in Arduino AVR boards core defines HAVE_HWSERIALX
example
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif