libraries - howto to implement for multiple hardware, e.g arduino, stm32 and arm

i was looking for a library to handle sh1106 displays, u8glib and found something curious, 3 ports(?) to arduino, avr and arm. . so i installed the arduino version and found it compiled for uno and due. as its spi i assume the low level interface is handled by different code, already supplied for arduino and due. . so if i had a library that required different low level code for each platform, how would you do it? using sketchbook/libraries and sketchbook/hardware with sub-directories for arm and arduino? . stephen

I notice that in 1.6.x the ARDUINO_ARCH_AVR or ARDUINO_ARCH_SAM is defined for you. Perhaps you could handle any differences with conditional compilation. I don't know if they support architecture-dependant library subdirectories.


The Arduino port of u8glib handles AVR and Atmal ARM (SAM) boards. The AVR port of u8glib should work without Arduino IDE and Arduino libraries. Same is true for the ARM port of u8glib, which should work with ARM controllers, but without Arduino Envionment.