# override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue`
# default to release build
# default to build for linux
+# default to ETHERNET for transport
BUILD := release
PLATFORM := linux
+TRANSPORT := ETHERNET
# override with `make PLATFORM=arduinomega ARDUINOWIFI=1` to enable Arduino WiFi shield
ARDUINOWIFI := 0
CC=gcc
AR=ar
RANLIB=ranlib
- CFLAGS_PLATFORM = -DWITH_POSIX -std=c99
+ CFLAGS_PLATFORM = -DWITH_POSIX -std=gnu99
PLATFORM_TYPE=linux
else ifeq ($(PLATFORM),arduinomega)
include local.properties
OCLOGGER_DIR = logger
OC_LOG_DIR = ../oc_logger
OCRANDOM_DIR = ocrandom
-OCSOCKET_DIR = ocsocket
-LCOAP_DIR = libcoap-4.1.1
-OCCOAP_DIR = occoap
OCTBSTACK_DIR = stack
OCMALLOC_DIR = ocmalloc
+OCSECURITY_DIR = security
EXTLIBS_DIR = ../../extlibs
CJSON_DIR = $(EXTLIBS_DIR)/cjson
TINYDTLS_DIR = $(EXTLIBS_DIR)/tinydtls
CONNECTIVITY_DIR = connectivity
-OCCOAP_SRC = $(OCCOAP_DIR)/src
OCTBSTACK_SRC = $(OCTBSTACK_DIR)/src
OCMALLOC_SRC = $(OCMALLOC_DIR)/src
+OCSECURITY_SRC = $(OCSECURITY_DIR)/src
CJSON_SRC = $(CJSON_DIR)
CONNECTIVITY_SRC = $(CONNECTIVITY_DIR)
-
+OCLOGGER_SRC = $(OCLOGGER_DIR)/src
+OCRANDOM_SRC = $(OCRANDOM_DIR)/src
OCLOGGER_INC = $(OCLOGGER_DIR)/include
OC_LOG_INC = $(OC_LOG_DIR)/include
OCRANDOM_INC = $(OCRANDOM_DIR)/include
-OCSOCKET_INC = $(OCSOCKET_DIR)/include
-LCOAP_INC = $(LCOAP_DIR)
-OCCOAP_INC = $(OCCOAP_DIR)/include
OCTBSTACK_INC = $(OCTBSTACK_DIR)/include
OCMALLOC_INC = $(OCMALLOC_DIR)/include
+OCSECURITY_INC = $(OCSECURITY_DIR)/include
CJSON_INC = $(CJSON_DIR)
CONNECTIVITY_INC = $(CONNECTIVITY_DIR)/inc
+LIBCOAP_INC = $(CONNECTIVITY_DIR)/lib/libcoap-4.1.1
INC_DIRS := -I$(OCLOGGER_INC)
INC_DIRS += -I$(OC_LOG_INC)
INC_DIRS += -I$(OCRANDOM_INC)
-INC_DIRS += -I$(OCSOCKET_INC)
-INC_DIRS += -I$(LCOAP_INC)
-INC_DIRS += -I$(OCCOAP_INC)
INC_DIRS += -I$(OCMALLOC_INC)
+INC_DIRS += -I$(OCSECURITY_INC)
+INC_DIRS += -I$(OCSECURITY_INC)/internal
INC_DIRS += -I$(OCTBSTACK_INC)
INC_DIRS += -I$(OCTBSTACK_INC)/internal
INC_DIRS += -I$(CJSON_INC)
INC_DIRS += -I$(CONNECTIVITY_INC)
INC_DIRS += -I$(CONNECTIVITY_DIR)/api
+INC_DIRS += -I$(LIBCOAP_INC)
# TODO-CA Remove -fstack-protector-all before merging to master
-# TODO-CA Remove CA_INT flag after CA merging is finalized
-CC_FLAGS.debug := -O0 -g3 -Wall -fstack-protector-all -c -fmessage-length=0 -pedantic -fpic -DTB_LOG -DCA_INT
+CC_FLAGS.debug := -O0 -g3 -Wall -fstack-protector-all -c -fmessage-length=0 -pedantic -fpic -DTB_LOG
# TODO-CA Remove -fstack-protector-all before merging to master
-CC_FLAGS.release := -Os -Wall -fstack-protector-all -c -fmessage-length=0 -fpic -DCA_INT
+CC_FLAGS.release := -Os -Wall -fstack-protector-all -c -fmessage-length=0 -fpic
CFLAGS += $(CC_FLAGS.$(BUILD)) $(INC_DIRS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM)
-LDLIBS += -lcoap
CJSON_SOURCES := $(CJSON_SRC)/cJSON.c
-OCCOAP_SOURCES := $(OCCOAP_SRC)/occoap.c
-OCCOAP_SOURCES += $(OCCOAP_SRC)/occoaphelper.c
-
OCTBSTACK_SOURCES := $(OCTBSTACK_SRC)/ocstack.c
OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/occlientcb.c
OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocresource.c
OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocserverrequest.c
OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/occollection.c
OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/oicgroup.c
+OCTBSTACK_SOURCES += $(OCSECURITY_SRC)/ocsecurity.c
+OCTBSTACK_SOURCES += $(OCMALLOC_SRC)/ocmalloc.c
+OCTBSTACK_SOURCES += $(OCLOGGER_SRC)/logger.c
+OCTBSTACK_SOURCES += $(OCRANDOM_SRC)/ocrandom.c
SOURCES := $(CJSON_SOURCES)
-SOURCES += $(OCCOAP_SOURCES)
SOURCES += $(OCTBSTACK_SOURCES)
-all: make_lcoap objdirs obj_build ca liboctbstack.a
+all: objdirs obj_build ca liboctbstack.a
buildScript_all: objdirs obj_build ca liboctbstack.a
-make_lcoap:
- @echo "Building $@"
- $(MAKE) -C $(LCOAP_DIR) "BUILD=$(BUILD)" "PLATFORM=$(PLATFORM)" "ARDUINOWIFI=$(ARDUINOWIFI)" "CA_INT_DTLS=$(CA_INT_DTLS)"
-
objdirs:
mkdir -p $(PLATFORM)
mkdir -p $(PLATFORM)/$(ARDUINO_SHIELD_TYPE)
ca:
@echo "Building $@"
- @cd $(CONNECTIVITY_SRC)/lib/libcoap-4.1.1 && $(MAKE)
- @cd $(CONNECTIVITY_SRC)/build/linux && $(MAKE)
- @cd $(CONNECTIVITY_SRC)/samples/linux && $(MAKE)
-
+ ifeq ($(PLATFORM),linux)
+ @cd $(CONNECTIVITY_SRC)/lib/libcoap-4.1.1 && $(MAKE)
+ @cd $(CONNECTIVITY_SRC)/build/linux && $(MAKE) "BUILD=$(BUILD)" "PLATFORM=linux"
+ @cd $(CONNECTIVITY_SRC)/samples/linux && $(MAKE)
+ else
+ @cd $(CONNECTIVITY_SRC)/build/ && $(MAKE) "PLATFORM=$(PLATFORM)" "ARDUINO_DIR=$(ARDUINO_DIR)" "TRANSPORT=$(TRANSPORT)"
+ endif
liboctbstack.a:
@echo "Building $@"
- # Unpackage libcoap.a to $(OBJ_DIR)/$(BUILD). The output objects from OCStack and OCCoap are already at this location
- @cd $(OBJ_DIR) && $(AR) -x $(PLATFORM_SPECIFIC_BACKOUT)$(LCOAP_DIR)/$(PLATFORM)$(ARDUINO_SHIELD_TYPE)/$(BUILD)/libcoap.a
- # Repackage all the objects at this location into a single archive. This is OCStack, OCCoap, and LibCoap (LibCoap contains OCRandom, OCLogger, and OCSocket.).
$(AR) -r $(OUT_DIR)/$@ $(OBJ_DIR)/*.o
ifeq ($(CA_INT_DTLS),0)
-rm -rf linux
-rm -rf arduinomega
-rm -rf arduinodue
+ @cd $(CONNECTIVITY_SRC)/build/ && $(MAKE) clean "PLATFORM=arduinomega"
+ @cd $(CONNECTIVITY_SRC)/samples/linux && $(MAKE) "clean"
deepclean: legacy_deepclean
-rm -rf linux
cd $(CONNECTIVITY_SRC)/build/linux && $(MAKE) clean
cd $(CONNECTIVITY_SRC)/samples/linux && $(MAKE) clean
rm -rf $(OBJ_DIR)
- $(MAKE) clean -C $(LCOAP_DIR)
rm -rf release
rm -rf debug
+