Implementation of connectivity abstraction feature Release v0.3
[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)/local.properties
20     include $(ROOT_DIR)/$(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 else
42         #SOURCES += ocsocket.c
43 endif
44
45 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
46
47 all: prep_dirs libcoap.a
48
49 prep_dirs:
50         -mkdir $(OUT_DIR)
51         -mkdir $(OBJ_DIR)
52
53 %.o: %.c
54         $(CC) -c $(CC_FLAGS.$(BUILD)) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $(OBJ_DIR)/$@
55
56 %.o: %.cpp
57         $(CCPLUS) -c $(CC_FLAGS.$(BUILD)) $(CFLAGS_PLATFORM) $(INC_DIR_PLATFORM) $< -o $(OBJ_DIR)/$@
58
59 libcoap.a: $(OBJECTS) $(OBJECTSCPP)
60         $(AR) rcs $(OUT_DIR)/$@ $(addprefix $(OBJ_DIR)/,$^)
61         $(RANLIB) $(OUT_DIR)/$@
62
63 .PHONY: clean
64
65 clean:  legacy_clean
66         -rm -rf release
67         -rm -rf debug
68         
69 #There is no installation in LibCoap.
70 install: all
71         
72 legacy_clean:
73         rm -f *.o libcoap.a
74