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
28 # override with `make PLATFORM=arduinomega ARDUINOWIFI=1` to enable Arduino WiFi shield
40 ifeq ($(PLATFORM),linux)
45 CFLAGS_PLATFORM = -DWITH_POSIX -std=c99
46 else ifeq ($(PLATFORM),arduinomega)
47 include local.properties
48 include $(PLATFORM).properties
49 CC=$(ARDUINO_TOOLS_DIR)/avr-g++
50 ifeq ($(wildcard $(ARDUINO_DIR)/libraries/Time/Time/),)
51 $(error Arduino Time library needs to be moved from <ARDUINO_DIR>/libraries/Time \
52 to <ARDUINO_DIR>/libraries/Time/Time. You may need to create \
53 <ARDUINO_DIR>/libraries/Time/Time directory. Please refer to the wiki or readme \
56 else ifeq ($(PLATFORM),arduinodue)
57 include local.properties
58 include $(PLATFORM).properties
59 CC=$(ARDUINO_TOOLS_DIR)/arm-none-eabi-g++
61 $(error Wrong value for PLATFORM !!)
64 OCLOGGER_DIR = $(ROOT_DIR)/logger
65 OCRANDOM_DIR = $(ROOT_DIR)/ocrandom
66 OCSOCKET_DIR = $(ROOT_DIR)/ocsocket
67 LCOAP_DIR = $(ROOT_DIR)/libcoap-4.1.1
68 OCCOAP_DIR = $(ROOT_DIR)/occoap
69 OCTBSTACK_DIR = $(ROOT_DIR)/stack
70 UTILS_DIR = $(ROOT_DIR)/../../oic-utilities/tb
71 CJSON_DIR = $(UTILS_DIR)/cJSON
73 OCCOAP_SRC = $(OCCOAP_DIR)/src
74 OCTBSTACK_SRC = $(OCTBSTACK_DIR)/src
75 CJSON_SRC = $(CJSON_DIR)
77 OCLOGGER_INC = $(OCLOGGER_DIR)/include
78 OCRANDOM_INC = $(OCRANDOM_DIR)/include
79 OCSOCKET_INC = $(OCSOCKET_DIR)/include
80 LCOAP_INC = $(LCOAP_DIR)
81 OCCOAP_INC = $(OCCOAP_DIR)/include
82 OCTBSTACK_INC = $(OCTBSTACK_DIR)/include
83 CJSON_INC = $(CJSON_DIR)
85 INC_DIRS := -I$(OCLOGGER_INC)
86 INC_DIRS += -I$(OCRANDOM_INC)
87 INC_DIRS += -I$(OCSOCKET_INC)
88 INC_DIRS += -I$(LCOAP_INC)
89 INC_DIRS += -I$(OCCOAP_INC)
90 INC_DIRS += -I$(OCTBSTACK_INC)
91 INC_DIRS += -I$(OCTBSTACK_INC)/internal
92 INC_DIRS += -I$(CJSON_INC)
94 CC_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -fpic -DTB_LOG
95 CC_FLAGS.release := -Os -Wall -c -fmessage-length=0 -fpic
97 CFLAGS += $(CC_FLAGS.$(BUILD)) $(INC_DIRS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM)
100 CJSON_SOURCES := $(CJSON_SRC)/cJSON.c
102 OCCOAP_SOURCES := $(OCCOAP_SRC)/occoap.c
103 OCCOAP_SOURCES += $(OCCOAP_SRC)/occoaphelper.c
105 OCTBSTACK_SOURCES := $(OCTBSTACK_SRC)/ocstack.c
106 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/occlientcb.c
107 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocresource.c
108 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocobserve.c
109 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/occollection.c
111 SOURCES := $(CJSON_SOURCES)
112 SOURCES += $(OCCOAP_SOURCES)
113 SOURCES += $(OCTBSTACK_SOURCES)
115 all: make_lcoap objdirs obj_build liboctbstack.a #print_vars
118 $(MAKE) -C $(LCOAP_DIR) "BUILD=$(BUILD)" "PLATFORM=$(PLATFORM)" "ARDUINOWIFI=$(ARDUINOWIFI)"
122 mkdir -p $(BUILD)/$(OBJ_DIR)
126 # Output all *.o files to $(OBJ_DIR)/$(BUILD)
127 $(foreach source,$(SOURCES), $(CC) $(LDLIBS) $(CFLAGS) $(source) -o $(patsubst %.c, %.o, $(patsubst %, $(BUILD)/$(OBJ_DIR)/%, $(notdir $(source))));)
131 # Unpackage libcoap.a to $(OBJ_DIR)/$(BUILD). The output objects from OCStack and OCCoap are already at this location
132 @cd $(BUILD)/$(OBJ_DIR) && $(AR) -x $(LCOAP_DIR)/$(BUILD)/libcoap.a
133 # Repackage all the objects at this location into a single archive. This is OCStack, OCCoap, and LibCoap (LibCoap contains OCRandom, OCLogger, and OCSocket.).
134 $(AR) -r $(BUILD)/$@ $(BUILD)/$(OBJ_DIR)/*.o
136 .PHONY: clean print_vars
142 deepclean: legacy_deepclean
146 legacy_clean: $(ROOT_DIR)
147 @echo "Cleaning all."
148 rm -f $(OBJ_DIR)/$(BUILD)/*.o
149 rm -f $(ROOT_DIR)/$(BUILD)/liboctbstack.a
152 legacy_deepclean: $(ROOT_DIR)
153 @echo "Deep-Cleaning all."
154 rm -f $(OBJ_DIR)/$(BUILD)/*.o
155 rm -f $(ROOT_DIR)/liboctbstack.a
157 $(MAKE) clean -C $(LCOAP_DIR)
161 @echo 'INCLUDES ARE: '$(value INC_DIRS)
163 @echo 'SOURCE FILES ARE: '$(value SOURCES)
165 @echo 'OBJ_DIR/BUILD is: '$(OBJ_DIR)'/'$(BUILD)
167 @echo 'ROOT_DIR is: '$(ROOT_DIR)