1 # override with `make BUILD=debug`
2 # override with `make PLATFORM=arduino`
3 # default to release build
4 # default to build for linux
16 #Arduino specific configurations
17 INCD_ARD_CORE = -I$(ARDUINO_DIR)/hardware/arduino/cores/arduino
18 INCD_ARD_VARIANT = -I$(ARDUINO_DIR)/hardware/arduino/variants/mega
19 INCD_ARD_SPI = -I$(ARDUINO_DIR)/libraries/SPI
20 INCD_ARD_ETH = -I$(ARDUINO_DIR)/libraries/Ethernet
21 INCD_ARD_ETH_UTIL = -I$(ARDUINO_DIR)/libraries/Ethernet/utility
22 INCD_ARD_TIME = -I$(ARDUINO_DIR)/libraries/Time
23 SDIR_ARD_TIME = $(ARDUINO_DIR)/libraries/Time
25 ifeq ($(PLATFORM),linux)
30 CFLAGS_PLATFORM = -DWITH_POSIX -std=c99
31 else ifeq ($(PLATFORM),arduino)
32 include local.properties
37 CFLAGS_PLATFORM = -std=c++0x -DATMEGA2560 -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=156 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -DWITH_ARDUINO -MMD -DNDEBUG
38 INC_DIR_PLATFORM = $(INCD_ARD_CORE) $(INCD_ARD_VARIANT) $(INCD_ARD_SPI) $(INCD_ARD_ETH) $(INCD_ARD_ETH_UTIL) $(INCD_ARD_TIME)
40 $(error Wrong value for PLATFORM !!)
43 OCLOGGER_DIR = $(ROOT_DIR)/logger
44 OCRANDOM_DIR = $(ROOT_DIR)/ocrandom
45 OCSOCKET_DIR = $(ROOT_DIR)/ocsocket
46 LCOAP_DIR = $(ROOT_DIR)/libcoap-4.1.1
47 OCCOAP_DIR = $(ROOT_DIR)/occoap
48 OCTBSTACK_DIR = $(ROOT_DIR)/stack
49 UTILS_DIR = $(ROOT_DIR)/../../oic-utilities/tb
50 CJSON_DIR = $(UTILS_DIR)/cJSON
52 OCCOAP_SRC = $(OCCOAP_DIR)/src
53 OCTBSTACK_SRC = $(OCTBSTACK_DIR)/src
54 CJSON_SRC = $(CJSON_DIR)
56 OCLOGGER_INC = $(OCLOGGER_DIR)/include
57 OCRANDOM_INC = $(OCRANDOM_DIR)/include
58 OCSOCKET_INC = $(OCSOCKET_DIR)/include
59 LCOAP_INC = $(LCOAP_DIR)
60 OCCOAP_INC = $(OCCOAP_DIR)/include
61 OCTBSTACK_INC = $(OCTBSTACK_DIR)/include
62 CJSON_INC = $(CJSON_DIR)
64 INC_DIRS := -I$(OCLOGGER_INC)
65 INC_DIRS += -I$(OCRANDOM_INC)
66 INC_DIRS += -I$(OCSOCKET_INC)
67 INC_DIRS += -I$(LCOAP_INC)
68 INC_DIRS += -I$(OCCOAP_INC)
69 INC_DIRS += -I$(OCTBSTACK_INC)
70 INC_DIRS += -I$(OCTBSTACK_INC)/internal
71 INC_DIRS += -I$(CJSON_INC)
73 CC_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -fpic -DTB_LOG
74 CC_FLAGS.release := -Os -Wall -c -fmessage-length=0 -fpic
76 CFLAGS += $(CC_FLAGS.$(BUILD)) $(INC_DIRS) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM)
79 CJSON_SOURCES := $(CJSON_SRC)/cJSON.c
81 OCCOAP_SOURCES := $(OCCOAP_SRC)/occoap.c
82 OCCOAP_SOURCES += $(OCCOAP_SRC)/occoaphelper.c
84 OCTBSTACK_SOURCES := $(OCTBSTACK_SRC)/ocstack.c
85 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/occlientcb.c
86 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocserverrequest.c
87 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocresource.c
88 OCTBSTACK_SOURCES += $(OCTBSTACK_SRC)/ocobserve.c
90 SOURCES := $(CJSON_SOURCES)
91 SOURCES += $(OCCOAP_SOURCES)
92 SOURCES += $(OCTBSTACK_SOURCES)
94 all: make_lcoap objdirs obj_build liboctbstack.a #print_vars
97 $(MAKE) -C $(LCOAP_DIR) "BUILD=$(BUILD)" "PLATFORM=$(PLATFORM)"
101 mkdir -p $(BUILD)/$(OBJ_DIR)
105 # Output all *.o files to $(OBJ_DIR)/$(BUILD)
106 $(foreach source,$(SOURCES), $(CC) $(LDLIBS) $(CFLAGS) $(source) -o $(patsubst %.c, %.o, $(patsubst %, $(BUILD)/$(OBJ_DIR)/%, $(notdir $(source))));)
110 # Unpackage libcoap.a to $(OBJ_DIR)/$(BUILD). The output objects from OCStack and OCCoap are already at this location
111 @cd $(BUILD)/$(OBJ_DIR) && ar -x $(LCOAP_DIR)/$(BUILD)/libcoap.a
112 # Repackage all the objects at this location into a single archive. This is OCStack, OCCoap, and LibCoap (LibCoap contains OCRandom, OCLogger, and OCSocket.).
113 ar -r $(BUILD)/$@ $(BUILD)/$(OBJ_DIR)/*.o
115 .PHONY: clean print_vars
121 deepclean: legacy_deepclean
125 legacy_clean: $(ROOT_DIR)
126 @echo "Cleaning all."
127 rm -f $(OBJ_DIR)/$(BUILD)/*.o
128 rm -f $(ROOT_DIR)/$(BUILD)/liboctbstack.a
131 legacy_deepclean: $(ROOT_DIR)
132 @echo "Deep-Cleaning all."
133 rm -f $(OBJ_DIR)/$(BUILD)/*.o
134 rm -f $(ROOT_DIR)/liboctbstack.a
136 $(MAKE) clean -C $(LCOAP_DIR)
140 @echo 'INCLUDES ARE: '$(value INC_DIRS)
142 @echo 'SOURCE FILES ARE: '$(value SOURCES)
144 @echo 'OBJ_DIR/BUILD is: '$(OBJ_DIR)'/'$(BUILD)
146 @echo 'ROOT_DIR is: '$(ROOT_DIR)