1 # //******************************************************************
3 # // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # // Licensed under the Apache License, Version 2.0 (the "License");
8 # // you may not use this file except in compliance with the License.
9 # // You may obtain a copy of the License at
11 # // http://www.apache.org/licenses/LICENSE-2.0
13 # // Unless required by applicable law or agreed to in writing, software
14 # // distributed under the License is distributed on an "AS IS" BASIS,
15 # // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # // See the License for the specific language governing permissions and
17 # // limitations under the License.
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 PLATFORM := arduinomega
25 include $(ROOT_DIR)/local.properties
26 LIBCOAP_DIR = $(ROOT_DIR)/libcoap-4.1.1
27 OCSOCK_DIR = $(ROOT_DIR)/ocsocket
28 OCCOAP_DIR = $(ROOT_DIR)/occoap
29 LOGGER_DIR = $(ROOT_DIR)/logger
30 RANDOM_DIR = $(ROOT_DIR)/ocrandom
31 JSON_DIR = $(ROOT_DIR)/../../extlibs/cjson
32 OCSTACK_DIR = $(ROOT_DIR)/stack
33 BIN_DIR = $(OCSTACK_DIR)/bin/arduino/
34 OBJ_DIR = $(OCSTACK_DIR)/obj/arduino/
37 SDIR_ARD_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
38 SDIR_ARD_SPI = $(ARDUINO_DIR)/libraries/SPI
39 SDIR_ARD_ETH = $(ARDUINO_DIR)/libraries/Ethernet
40 SDIR_ARD_ETH_UTIL = $(ARDUINO_DIR)/libraries/Ethernet/utility
41 SDIR_ARD_TIME = $(ARDUINO_DIR)/libraries/Time
43 VPATH = $(SDIR_ARD_CORE):$(SDIR_ARD_SPI):$(SDIR_ARD_ETH):$(SDIR_ARD_ETH_UTIL):$(SDIR_ARD_TIME):$(RANDOM_DIR)/src:$(OCSTACK_DIR)/src:$(OCCOAP_DIR)/src:$(JSON_DIR)
46 IDIR_ARD_CORE = $(ARDUINO_DIR)/hardware/arduino/cores/arduino
47 IDIR_ARD_VARIANT = $(ARDUINO_DIR)/hardware/arduino/variants/mega
48 IDIR_ARD_SPI = $(ARDUINO_DIR)/libraries/SPI
49 IDIR_ARD_ETH = $(ARDUINO_DIR)/libraries/Ethernet
50 IDIR_ARD_ETH_UTIL = $(ARDUINO_DIR)/libraries/Ethernet/utility
51 IDIR_ARD_TIME = $(ARDUINO_DIR)/libraries/Time
53 INC_DIRS = -I$(IDIR_ARD_CORE) -I$(IDIR_ARD_VARIANT) -I$(IDIR_ARD_SPI) \
54 -I$(IDIR_ARD_ETH) -I$(IDIR_ARD_ETH_UTIL) -I$(IDIR_ARD_TIME) \
55 -I$(OCSOCK_DIR)/include -I$(LOGGER_DIR)/include -I$(RANDOM_DIR)/include \
56 -I$(OCSTACK_DIR)/include -I$(OCSTACK_DIR)/include/internal \
57 -I$(LIBCOAP_DIR)/ -I$(OCCOAP_DIR)/include -I$(JSON_DIR)
59 #Compiler/Linker flags
60 COPTIONS_ARDUINO = -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=156 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -MMD -DNDEBUG
61 CFLAGS += -c -Os -Wall -Wno-write-strings -ffunction-sections -fdata-sections -fno-exceptions -felide-constructors -std=c++0x -DATMEGA2560 -DTB_LOG -DWITH_ARDUINO
71 CORE_COBJ = WInterrupts.o wiring.o wiring_digital.o
72 CORE_CPPOBJ = main.o Stream.o WMath.o WString.o HardwareSerial.o Print.o SPI.o IPAddress.o wiring_analog.o
73 ETH_CPPOBJ = Dhcp.o Dns.o Ethernet.o EthernetUdp.o
74 ETH_UTIL_CPPOBJ = socket.o w5100.o
75 OCSTACK_CPPOBJ = ocrandom.o ocresource.o occollection.o ocobserve.o ocstack.o occoaphelper.o occoap.o occlientcb.o
76 OCDEPENDENT_CPPOBJ = wiring_analog.o
79 all: core.a $(TESTAPP).o $(TESTAPP).elf $(TESTAPP).hex
81 cp $(TESTAPP).hex $(BIN_DIR)
86 # Note for Arduino: The C files are compiled using C++ compiler since Arduino
87 # build includes Time.h header file which has C++ style definitions.
89 $(CXX) $(CFLAGS) $(COPTIONS_ARDUINO) $(INC_DIRS) $< -o $@
92 $(CXX) $(CFLAGS) $(COPTIONS_ARDUINO) $(INC_DIRS) $< -o $@
94 core.a: $(CORE_COBJ) $(CORE_CPPOBJ) $(ETH_CPPOBJ) $(ETH_UTIL_CPPOBJ) $(LIBCOAP_DIR)/$(BUILD)/libcoap.a
98 $(TESTAPP).elf: $(TESTAPP).o core.a $(OCSTACK_CPPOBJ) $(OCDEPENDENT_CPPOBJ) $(LIBCOAP_DIR)/$(BUILD)/libcoap.a $(CJSON_COBJ)
99 $(CC) -Os -Wl,--gc-sections,--relax $(COPTIONS_ARDUINO) $^ -lm -o $@
101 $(TESTAPP).hex: $(TESTAPP).elf
102 avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $< $(TESTAPP).eep
103 avr-objcopy -O ihex -R .eeprom $< $@
106 avrdude -C$(ARDUINO_DIR)/hardware/tools/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P/dev/ttyACM0 -b115200 -D -Uflash:w:$(TESTAPP).hex:i
111 rm -f *.o *.d *.elf *.eep *.a *.hex *-