Implementation of connectivity abstraction feature Release v0.3
[platform/upstream/iotivity.git] / resource / csdk / connectivity / build / arduino / Makefile
1 #
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
8 BUILD    := release
9 PLATFORM := arduinomega
10 TRANSPORT := BLE
11 OBJ_DIR := ./bin
12 APP_NAME := sample_main
13 ARDUINO_PORT := ttyACM0
14
15 include ./local.properties
16 include ./$(PLATFORM).properties
17
18 VPATH := $(SDIR_ARD_PLATFORM)
19
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
25 else
26 CFLAGS          := -Os -Wall -c -DTB_LOG -DOIC_ARDUINODUE -DINTERFACESAMPLE_ARDUINO -DARDUINO -DOIC_ARDUINODUE -D__ARDUINO__ -DWITH_ARDUINO -DETHERNET_ADAPTER
27 endif
28
29 all: prep_dirs core.a $(APP_NAME).o $(APP_NAME).elf $(APP_NAME).hex
30
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
35         $(RANLIB) $@
36
37 prep_dirs:
38         -mkdir $(OBJ_DIR)
39
40 %.c.o: %.c
41         $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
42
43 %.o: %.c
44         $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
45
46 %.o: %.cpp
47         $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
48
49 %.cpp.o: %.cpp
50         $(CCPLUS) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $@
51
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
56
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 $< $@
60
61 install: all
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
63
64
65 .PHONY: clean
66 clean:
67         @rm -f *.o *.d *.elf *.eep core.a *.hex *.bin *.map *-
68         @rm -rf $(OBJ_DIR)
69
70
71