Identifying Due in Libraries

avr_atmega328p is set by the compiler as a consequence of the -mmcu=atmega328p command-line option.

The arm-gcc compiler isn't quite so customized, so it looks like SAM3X8E is set explicitly with a -D command-line option.

The other symbols used in newer versions of the IDE (1.5+?), like ARDUINO_SAM_DUE or ARDUINO_AVR_UNO are also set from the command line using -D, based on the contents of the xxx.build.board variable defined in boards.txt and the recipes in platform.txt

The build command can be see by turning on verbose compilation in the preferences dialog. It looks like this:

"/Applications/arduino/Arduino-1.8.2.app/Contents/Java/portable/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf  -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L [color=red]-DARDUINO=10802 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM  -D__SAM3X8E__[/color] -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON '-DUSB_MANUFACTURER="Arduino LLC"' '-DUSB_PRODUCT="Arduino Due"' "-I/Applications/arduino/Arduino-1.8.2.app/Contents/Java/portable/packages/arduino/hardware/sam/1.6.11/system/libsam" "-I/Applications/arduino/Arduino-1.8.2.app/Contents/Java/portable/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/" "-I/Applications/arduino/Arduino-1.8.2.app/Contents/Java/portable/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/" "-I/Applications/arduino/Arduino-1.8.2.app/Contents/Java/portable/packages/arduino/hardware/sam/1.6.11/cores/arduino" "-I/Applications/arduino/Arduino-1.8.2.app/Contents/Java/portable/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x" "/var/folders/jz/5yb8f2hr8xjcpf0059bsfz4r0000gn/T/arduino_build_806983/sketch/stdio_test.ino.cpp" -o "/dev/null"