Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / resource / csdk / connectivity / lib / libcoap-4.1.1 / makefile_arduino.mak
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
5 BUILD    := release
6 #other options are android, arduino
7 PLATFORM=linux
8 # override with `make PLATFORM=arduinomega ARDUINOWIFI=1` to enable Arduino WiFi shield
9 ARDUINOWIFI := 0
10
11 OUT_DIR   := ./$(BUILD)
12 OBJ_DIR   := $(OUT_DIR)/obj
13
14 ROOT_DIR = ..
15
16 # Note for Arduino: The CC flag is set to the C++ compiler since Arduino build 
17 # includes Time.h header file which has C++ style definitions.
18 ifeq ($(PLATFORM),arduinomega)
19     include $(ROOT_DIR)/arduino/local.properties
20     include $(ROOT_DIR)/arduino/$(PLATFORM).properties
21         CC=$(ARDUINO_TOOLS_DIR)/avr-gcc
22 else ifeq ($(PLATFORM),arduinodue)
23     include $(ROOT_DIR)/local.properties
24     include $(ROOT_DIR)/$(PLATFORM).properties
25         CC=$(ARDUINO_TOOLS_DIR)/arm-none-eabi-g++
26 else
27    $(error Wrong value for PLATFORM !!)
28 endif
29
30 CC_FLAGS.debug := -O0 -g3 -Wall -ffunction-sections -fdata-sections -fno-exceptions -pedantic \
31 -DTB_LOG
32 CC_FLAGS.release := -Os -Wall -ffunction-sections -fdata-sections -fno-exceptions
33
34 SOURCES:= pdu.c net.c debug.c encode.c uri.c coap_list.c resource.c hashkey.c \
35           str.c option.c async.c subscribe.c block.c
36 #VPATH := $(OCSOCK_DIR)/src:$(LOGGER_DIR)/src:$(RANDOM_DIR)/src
37 ifeq (arduino, $(findstring arduino,$(PLATFORM)))
38         SOURCESCPP:= Time.cpp
39         OBJECTSCPP:= $(patsubst %.cpp, %.o, $(SOURCESCPP))
40         VPATH += $(SDIR_ARD_TIME)
41 endif
42
43 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
44
45 all: prep_dirs libcoap.a
46
47 prep_dirs:
48         -mkdir $(OUT_DIR)
49         -mkdir $(OBJ_DIR)
50
51 %.o: %.c
52         $(CC) -c $(CC_FLAGS.$(BUILD)) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $(OBJ_DIR)/$@
53
54 %.o: %.cpp
55         $(CCPLUS) -c $(CC_FLAGS.$(BUILD)) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $(OBJ_DIR)/$@
56
57 libcoap.a: $(OBJECTS) $(OBJECTSCPP)
58         $(AR) rcs $(OUT_DIR)/$@ $(addprefix $(OBJ_DIR)/,$^)
59         $(RANLIB) $(OUT_DIR)/$@
60
61 .PHONY: clean
62
63 clean:  legacy_clean
64         -rm -rf release
65         -rm -rf debug
66         
67 #There is no installation in LibCoap.
68 install: all
69         
70 legacy_clean:
71         rm -f *.o libcoap.a
72