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 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 # override with `make BUILD=debug`
22 # override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue`
23 # default to release build
24 # default to build for linux
26 #other options are android, arduino
28 # override with `make PLATFORM=arduinomega ARDUINOWIFI=1` to enable Arduino WiFi shield
32 OBJ_DIR := $(OUT_DIR)/obj
35 OCSOCK_DIR = $(ROOT_DIR)/ocsocket
36 LOGGER_DIR = $(ROOT_DIR)/logger
37 RANDOM_DIR = $(ROOT_DIR)/ocrandom
38 STACK_DIR = $(ROOT_DIR)/stack
39 INC_DIRS = -I$(OCSOCK_DIR)/include/ -I$(LOGGER_DIR)/include -I$(RANDOM_DIR)/include
41 # Note for Arduino: The CC flag is set to the C++ compiler since Arduino build
42 # includes Time.h header file which has C++ style definitions.
43 ifeq ($(PLATFORM),android)
44 CCPLUS=arm-linux-androideabi-g++
45 CC=arm-linux-androideabi-gcc
46 AR=arm-linux-androideabi-ar
47 RANLIB=arm-linux-androideabi-ranlib
48 CFLAGS_PLATFORM = -DWITH_POSIX -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
49 LDFLAGS_PLATFORM = -march=armv7-a -Wl,--fix-cortex-a8 -llog
50 else ifeq ($(PLATFORM),linux)
55 CFLAGS_PLATFORM = -std=gnu99 -DWITH_POSIX
56 else ifeq ($(PLATFORM),arduinomega)
57 include $(ROOT_DIR)/local.properties
58 include $(ROOT_DIR)/$(PLATFORM).properties
59 CC=$(ARDUINO_TOOLS_DIR)/avr-g++
60 else ifeq ($(PLATFORM),arduinodue)
61 include $(ROOT_DIR)/local.properties
62 include $(ROOT_DIR)/$(PLATFORM).properties
63 CC=$(ARDUINO_TOOLS_DIR)/arm-none-eabi-g++
65 $(error Wrong value for PLATFORM !!)
68 CC_FLAGS.debug := -O0 -g3 -Wall -ffunction-sections -fdata-sections -fno-exceptions -pedantic \
70 CC_FLAGS.release := -Os -Wall -ffunction-sections -fdata-sections -fno-exceptions
72 SOURCES:= pdu.c net.c debug.c encode.c uri.c coap_list.c resource.c hashkey.c \
73 str.c option.c async.c subscribe.c block.c logger.c ocrandom.c
74 VPATH := $(OCSOCK_DIR)/src:$(LOGGER_DIR)/src:$(RANDOM_DIR)/src
75 ifeq (arduino, $(findstring arduino,$(PLATFORM)))
76 ifeq ($(ARDUINOWIFI),1)
77 SOURCES += ocsocket_arduino_wifi.c
79 SOURCES += ocsocket_arduino.c
82 OBJECTSCPP:= $(patsubst %.cpp, %.o, $(SOURCESCPP))
83 VPATH += $(SDIR_ARD_TIME)
88 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
90 all: prep_dirs libcoap.a
97 $(CC) -c $(CC_FLAGS.$(BUILD)) $(CFLAGS_PLATFORM) $(INC_DIRS) $(INC_DIR_PLATFORM) $< -o $(OBJ_DIR)/$@
100 $(CCPLUS) -c $(CC_FLAGS.$(BUILD)) $(CFLAGS_PLATFORM) $(INC_DIRS) $(INC_DIR_PLATFORM) $< -o $(OBJ_DIR)/$@
102 libcoap.a: $(OBJECTS) $(OBJECTSCPP)
103 $(AR) rcs $(OUT_DIR)/$@ $(addprefix $(OBJ_DIR)/,$^)
104 $(RANLIB) $(OUT_DIR)/$@