reorg some code to support compilation from arduino.mk in Linux