1 # override with `make BUILD=debug`
2 # override with `make PLATFORM=arduinomega` or `make PLATFORM=arduinodue`
3 # default to release build
4 # default to build for linux
8 # override with `make PLATFORM=arduinomega ARDUINOWIFI=1` to enable Arduino WiFi shield
20 ifeq ($(PLATFORM),linux)
25 CFLAGS_PLATFORM = -DWITH_POSIX -std=c99
26 else ifeq ($(PLATFORM),arduinomega)
27 include local.properties
28 include $(PLATFORM).properties
29 CC=$(ARDUINO_TOOLS_DIR)/avr-g++
30 else ifeq ($(PLATFORM),arduinodue)
31 include local.properties
32 include $(PLATFORM).properties
33 CC=$(ARDUINO_TOOLS_DIR)/arm-none-eabi-g++
35 $(error Wrong value for PLATFORM !!)
38 OCLOGGER_DIR = $(ROOT_DIR)/logger
39 OCRANDOM_DIR = $(ROOT_DIR)/ocrandom
40 OCSOCKET_DIR = $(ROOT_DIR)/ocsocket
41 LCOAP_DIR = $(ROOT_DIR)/libcoap-4.1.1
42 OCCOAP_DIR = $(ROOT_DIR)/occoap
43 OCTBSTACK_DIR = $(ROOT_DIR)/stack
44 UTILS_DIR = $(ROOT_DIR)/../../oic-utilities/tb
45 CJSON_DIR = $(UTILS_DIR)/cJSON
47 OCCOAP_SRC = $(OCCOAP_DIR)/src
48 OCTBSTACK_SRC = $(OCTBSTACK_DIR)/src
49 CJSON_SRC = $(CJSON_DIR)
51 OCLOGGER_INC = $(OCLOGGER_DIR)/include
52 OCRANDOM_INC = $(OCRANDOM_DIR)/include
53 OCSOCKET_INC = $(OCSOCKET_DIR)/include
54 LCOAP_INC = $(LCOAP_DIR)
55 OCCOAP_INC = $(OCCOAP_DIR)/include
56 OCTBSTACK_INC = $(OCTBSTACK_DIR)/include
57 CJSON_INC = $(CJSON_DIR)
59 INC_DIRS := -I$(OCLOGGER_INC)
60 INC_DIRS += -I$(OCRANDOM_INC)
61 INC_DIRS += -I$(OCSOCKET_INC)
62 INC_DIRS += -I$(LCOAP_INC)
63 INC_DIRS += -I$(OCCOAP_INC)
64 INC_DIRS += -I$(OCTBSTACK_INC)
65 INC_DIRS += -I$(OCTBSTACK_INC)/internal
66 INC_DIRS += -I$(CJSON_INC)
68 CC_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -fpic -DTB_LOG
69 CC_FLAGS.release := -Os -Wall -c -fmessage-length=0 -fpic
71 CFLAGS += $(CC_FLAGS.$(BUILD)) $(INC_DIRS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM)
74 CJSON_SOURCES := $(CJSON_SRC)/cJSON.c
76 OCCOAP_SOURCES := $(OCCOAP_SRC)/occoap.c
77 OCCOAP_SOURCES += $(OCCOAP_SRC)/occoaphelper.c
79 OCTBSTACK_SOURCES := $(OCTBSTACK_SRC)/ocstack.c
80 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/occlientcb.c
81 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocresource.c
82 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocobserve.c
83 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/occollection.c
85 SOURCES := $(CJSON_SOURCES)
86 SOURCES += $(OCCOAP_SOURCES)
87 SOURCES += $(OCTBSTACK_SOURCES)
89 all: make_lcoap objdirs obj_build liboctbstack.a #print_vars
92 $(MAKE) -C $(LCOAP_DIR) "BUILD=$(BUILD)" "PLATFORM=$(PLATFORM)" "ARDUINOWIFI=$(ARDUINOWIFI)"
96 mkdir -p $(BUILD)/$(OBJ_DIR)
100 # Output all *.o files to $(OBJ_DIR)/$(BUILD)
101 $(foreach source,$(SOURCES), $(CC) $(LDLIBS) $(CFLAGS) $(source) -o $(patsubst %.c, %.o, $(patsubst %, $(BUILD)/$(OBJ_DIR)/%, $(notdir $(source))));)
105 # Unpackage libcoap.a to $(OBJ_DIR)/$(BUILD). The output objects from OCStack and OCCoap are already at this location
106 @cd $(BUILD)/$(OBJ_DIR) && $(AR) -x $(LCOAP_DIR)/$(BUILD)/libcoap.a
107 # Repackage all the objects at this location into a single archive. This is OCStack, OCCoap, and LibCoap (LibCoap contains OCRandom, OCLogger, and OCSocket.).
108 $(AR) -r $(BUILD)/$@ $(BUILD)/$(OBJ_DIR)/*.o
110 .PHONY: clean print_vars
116 deepclean: legacy_deepclean
120 legacy_clean: $(ROOT_DIR)
121 @echo "Cleaning all."
122 rm -f $(OBJ_DIR)/$(BUILD)/*.o
123 rm -f $(ROOT_DIR)/$(BUILD)/liboctbstack.a
126 legacy_deepclean: $(ROOT_DIR)
127 @echo "Deep-Cleaning all."
128 rm -f $(OBJ_DIR)/$(BUILD)/*.o
129 rm -f $(ROOT_DIR)/liboctbstack.a
131 $(MAKE) clean -C $(LCOAP_DIR)
135 @echo 'INCLUDES ARE: '$(value INC_DIRS)
137 @echo 'SOURCE FILES ARE: '$(value SOURCES)
139 @echo 'OBJ_DIR/BUILD is: '$(OBJ_DIR)'/'$(BUILD)
141 @echo 'ROOT_DIR is: '$(ROOT_DIR)