2 # override with `make BUILD=debug`
3 # override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue`
4 # TRANSPORT can be ETHERNET, WIFI, BT, BLE. Include Corresponding Transport during compilation. For Eg: `make PLATFORM=arduinomega TRANSPORT=BLE
5 # default to release build
6 # default to build for arduinomega
7 # default to build for BLE Transport
9 PLATFORM := arduinomega
12 APP_NAME := sample_main
13 ARDUINO_PORT := ttyACM0
15 include ./local.properties
16 include ./$(PLATFORM).properties
18 VPATH := $(SDIR_ARD_PLATFORM)
20 #Include __ARDUINO_BLE__ flag for BLE Transport. Currently, BLE Sample APP is segregated with this MACRO
21 ifeq ($(TRANSPORT),BLE)
22 CFLAGS := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -D__ARDUINO_BLE__ -DLE_ADAPTER
23 else ifeq ($(TRANSPORT),WIFI)
24 CFLAGS := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -DWIFI_ADAPTER
26 CFLAGS := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -DETHERNET_ADAPTER
29 all: prep_dirs core.a $(APP_NAME).o $(APP_NAME).elf $(APP_NAME).hex
31 $(info *********PLATFORM_OBJS!!**********)
32 core.a: $(PLATFORM_OBJS)
33 @cd $(OBJ_DIR) && $(AR) -x ../../../lib/libcoap-4.1.1/release/libcoap.a
34 $(AR) rcs $@ $(CORE_COBJ) $(CORE_CPPOBJ) $(PLATFORM_OBJS) $(OBJ_DIR)/*.o
41 $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
44 $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
47 $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
50 $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
52 # core.a and $(APP_NAME).cpp.o are combined to generate $(APP_NAME).elf.
53 # For Integration with Top Layer, we can link top layer with core.a
54 $(APP_NAME).elf: $(APP_NAME).cpp.o core.a
55 $(CC) -w -Os -Wl,--gc-sections,--relax -mmcu=atmega2560 -o $@ $^ -L$(ARDUINO_DIR)/libraries -lm
57 $(APP_NAME).hex: $(APP_NAME).elf
58 $(AVR_OBJCOPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $< $(APP_NAME).eep
59 $(AVR_OBJCOPY) -O ihex -R .eeprom $< $@
62 $(AVR_PROGRAMMER) -C$(ARDUINO_DIR)/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P/dev/$(ARDUINO_PORT) -b115200 -D -Uflash:w:$(APP_NAME).hex:i
67 @rm -f *.o *.d *.elf *.eep core.a *.hex *.bin *.map *-