iotivity 0.9.0
[platform/upstream/iotivity.git] / resource / csdk / stack / test / 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 # override with `make BUILD=debug`
22 # default to release build
23 BUILD    := release
24 PLATFORM := linux
25 CC       := g++
26
27 ifeq ($(ROOT_DIR), )
28 ROOT_DIR        = $(PWD)/../..
29 endif
30
31 # You must create the file "local.properties" on your local machine which contains any local paths, etc
32 # local.properties should NOT be committed to repo
33 include $(ROOT_DIR)/local.properties
34 # GTEST_DIR contains the path to Google Test libs and must be defined in local.properties
35 #  Example:
36 #  GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
37
38 # NOTE:  to run app, make sure that LD_LIBRARY_PATH env variable
39 #        contains $(GTEST_DIR)/lib/.libs
40
41 OUT_DIR   := $(PWD)/$(BUILD)
42 OBJ_DIR   := $(OUT_DIR)/obj
43
44
45 OUT_DIR   := $(PWD)
46
47 LOGGER_DIR      = $(ROOT_DIR)/logger
48 OC_LOG_DIR      = $(ROOT_DIR)/../oc_logger
49 OCRANDOM_DIR    = $(ROOT_DIR)/ocrandom
50 OCSOCKET_DIR    = $(ROOT_DIR)/ocsocket
51 LCOAP_DIR       = $(ROOT_DIR)/libcoap-4.1.1
52 OCCOAP_DIR      = $(ROOT_DIR)/occoap
53 OCTBSTACK_DIR   = $(ROOT_DIR)/stack
54
55 LOGGER_INC      = $(LOGGER_DIR)/include
56 OC_LOG_INC      = $(OC_LOG_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
63 INC_DIRS        := -I$(LOGGER_INC)
64 INC_DIRS        += -I$(OC_LOG_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$(GTEST_DIR)/include
72
73 CC_FLAGS.debug      := -g -O0 -g3 -Wall -ffunction-sections -fdata-sections -fno-exceptions \
74                         -std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) -DTB_LOG
75 CC_FLAGS.release    := -Os -Wall -fdata-sections -Wl,--gc-sections -Wl,-s -fno-exceptions \
76                         -std=c++0x $(INC_DIRS) -L$(ROOT_DIR)/linux/$(BUILD) 
77                                         
78 LDLIBS          += -loctbstack -lpthread -lgtest -lgtest_main
79 CPPFLAGS        += $(CC_FLAGS.$(BUILD)) $(LDLIBS) -L$(GTEST_DIR)/lib/.libs
80
81 SOURCES := stacktests.cpp
82
83 OBJECTS:= $(patsubst %.c, $(OBJ_DIR)/%.o, $(SOURCES))
84
85 PROGRAMS := stacktests
86
87 all:    prep_dirs $(OBJECTS) $(PROGRAMS) 
88
89 prep_dirs:
90         -mkdir -p $(OUT_DIR)
91         -mkdir -p $(OBJ_DIR)
92
93 $(OBJ_DIR)/%.o: %.cpp
94         $(CC) -c $(CPPFLAGS) $< -o $@
95
96 stacktests: $(OBJ_DIR)/stacktests.o 
97         $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
98
99 .PHONY: clean
100
101 clean: legacy_clean
102         -rm -rf release
103         -rm -rf debug
104
105 legacy_clean:
106         rm -f *.o $(PROGRAMS)