iotivity 0.9.0
[platform/upstream/iotivity.git] / resource / csdk / stack / test / linux / makefile
1 # //******************************************************************
2 # //
3 # // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 # //
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 # //
7 # // Licensed under the Apache License, Version 2.0 (the "License");
8 # // you may not use this file except in compliance with the License.
9 # // You may obtain a copy of the License at
10 # //
11 # //      http://www.apache.org/licenses/LICENSE-2.0
12 # //
13 # // Unless required by applicable law or agreed to in writing, software
14 # // distributed under the License is distributed on an "AS IS" BASIS,
15 # // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # // See the License for the specific language governing permissions and
17 # // limitations under the License.
18 # //
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 #
21 VERSION:=4.1.1
22
23 # override with `make BUILD=release`
24 # default to release build
25 BUILD    := release
26
27 #other options are android, arduino
28 PLATFORM=linux
29
30 ROOT_DIR = ../../..
31 OCSOCK_DIR = $(ROOT_DIR)/ocsocket
32 OCSTACK_DIR = $(ROOT_DIR)/stack
33 LOGGER_DIR = $(ROOT_DIR)/logger
34 OC_LOG_DIR = $(ROOT_DIR)/../oc_logger
35 RANDOM_DIR = $(ROOT_DIR)/ocrandom
36
37 OBJ_DIR = ./
38
39 INC_DIRS := -I$(OCSTACK_DIR)/include
40 INC_DIRS += -I$(OCSOCK_DIR)/include
41 INC_DIRS += -I$(LOGGER_DIR)/include
42 INC_DIRS += -I$(OC_LOG_DIR)/include
43 INC_DIRS += -I$(RANDOM_DIR)/include
44
45 ifeq ($(PLATFORM),android)
46         CXX=arm-linux-androideabi-g++
47         CC=arm-linux-androideabi-gcc
48         AR=arm-linux-androideabi-ar
49         RANLIB=arm-linux-androideabi-ranlib
50         CFLAGS_ANDROID =  -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
51         LDFLAGS_ANDROID = -march=armv7-a -Wl,--fix-cortex-a8 -llog
52 else ifeq ($(PLATFORM),linux)
53         CXX=g++
54         CC=gcc
55         AR=ar
56         RANLIB=ranlib
57 else
58    $(error Wrong value for PLATFORM !!)
59 endif
60
61 DEP_LIBS = $(ROOT_DIR)/linux/$(BUILD)/liboctbstack.a
62
63 CFLAGS += -Os -Wall -Wno-write-strings -ffunction-sections -fdata-sections -fno-exceptions \
64         -Wextra -Wno-variadic-macros -pedantic -std=gnu99 -DWITH_POSIX -DTB_LOG
65
66 PROGRAMS = ocserver occlient
67
68 SOURCES:= occlient.c ocserver.c
69
70 OBJECTS:= $(patsubst %.c, %.o, $(SOURCES))
71
72 all: objdirs $(PROGRAMS)
73
74 %.o: %.c
75         $(CC) -c $(CFLAGS) $(CFLAGS_ANDROID) $(INC_DIRS) $< -o $(BUILD)/$@
76
77 objdirs: $(ROOT_DIR)
78         mkdir -p $(BUILD)
79         
80 ##Added -lm as needed by json calling floor()
81 occlient: occlient.o $(DEP_LIBS)
82         $(CC) -Os -Wl,--gc-sections $(LDFLAGS_ANDROID) $(BUILD)/$^ -o $(BUILD)/$@ -lm
83
84 ocserver: ocserver.o $(DEP_LIBS)
85         $(CC) -Os -Wl,--gc-sections $(LDFLAGS_ANDROID) $(BUILD)/$^ -o $(BUILD)/$@ -lm
86
87 install: all
88         @echo "Installing for PLATFORM $(PLATFORM)"
89 ifeq ($(PLATFORM),android)
90         adb push coap-client /data/local/tmp/
91         adb push coap-server /data/local/tmp/
92 endif
93
94 .PHONY: clean
95
96 clean:
97         rm -rf debug
98         rm -rf release