Repo Merge: Moving resource API down a directory
[platform/upstream/iotivity.git] / resource / csdk / occoap / 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=release`
22 # default to release build
23 BUILD := release
24
25 # You must create the file "local.properties" on your local machine which contains any local paths, etc
26 # local_settings.mk should NOT be committed to repo
27 include ./local.properties
28 # GTEST_DIR contains the path to Google Test libs and must be defined in local.properties
29 #  Example:
30 #  GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
31
32 # NOTE:  to run app, make sure that LD_LIBRARY_PATH env variable
33 #        contains $(GTEST_DIR)/lib/.libs
34                                 
35 CC := gcc
36 CXX     := g++
37
38 PROG := occoaptest
39
40 #SRC_DIR := ./src
41 TEST_DIR:= ./test
42 #INC_DIR := ./include
43 #LOG_DIR := ../logger
44 #STACK_DIR := ../stack
45
46 CC_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -std=c99 -fpic -DTB_LOG
47 CC_FLAGS.release := -Os -Wall -c -fmessage-length=0 -std=c99 -fpic 
48 CC_FLAGS := $(CC_FLAGS.$(BUILD))
49
50 CXX_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -std=c++0x -fpic -DTB_LOG
51 CXX_FLAGS.release := -Os -Wall -c -fmessage-length=0 -std=c++0x -fpic 
52 CXX_FLAGS := $(CXX_FLAGS.$(BUILD))
53
54 #INC    := -I$(SRC_DIR)  
55 #INC += -I$(TEST_DIR)
56 #INC += -I$(INC_DIR)
57 #INC += -I$(LOG_DIR)/include
58 #INC += -I$(STACK_DIR)/include
59 INC += -I$(GTEST_DIR)/include
60
61
62 # using make's computed variables to select object and bin folders
63 # depending on the build type
64 OBJ_DIR.debug := ./obj/debug
65 OBJ_DIR.release := ./obj/release
66 OBJ_DIR := $(OBJ_DIR.$(BUILD))
67
68 BIN_DIR.debug := ./bin/debug
69 BIN_DIR.release := ./bin/release
70 BIN_DIR := $(BIN_DIR.$(BUILD))
71
72 #C_FILES := $(wildcard $(LOG_DIR)/src/*.c)
73 #C_FILES += $(wildcard $(SRC_DIR)/*.c)
74 #CPP_FILES := $(wildcard $(SRC_DIR)/*.cpp)
75 CPP_FILES := $(wildcard $(TEST_DIR)/*.cpp)
76 #CPP_FILES += $(wildcard $(LOG_DIR)/src/*.c)
77 OBJ_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o) $(C_FILES:.c=.o)))
78 H_FILES := $(wildcard $(TEST_DIR)/*.h)
79 #H_FILES += $(wildcard $(INC_DIR)/*.h)
80 #H_FILES += $(wildcard $(LOG_DIR)/include/*.h)
81 LD_FLAGS := -L/usr/lib
82 LD_FLAGS += -L$(GTEST_DIR)/lib/.libs
83
84
85 LIBS := -lgtest
86 LIBS += -lgtest_main
87 LIBS += -lpthread
88
89
90 all: $(PROG)
91         mkdir -p ./$(OBJ_DIR)
92         mkdir -p ./$(BIN_DIR)
93         
94 $(PROG): $(OBJ_FILES)
95         $(CXX) -o $@ $^ $(LD_FLAGS) $(LIBS)     
96         mkdir -p ./$(BIN_DIR)
97         mv ./$(PROG) ./$(BIN_DIR)
98
99 #$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h $(H_FILES)
100 #       $(CXX) $(CXX_FLAGS) $(INC) -c -o $@ $<
101
102 #$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(INC_DIR)/%.h $(H_FILES)
103 #       $(CXX) $(CXX_FLAGS) $(INC) -c -o $@ $<
104
105 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/%.h $(H_FILES)
106         mkdir -p ./$(OBJ_DIR)
107         $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<    
108                 
109 $(OBJ_DIR)/%.o: $(LOG_DIR)/src/%.c $(LOG_DIR)/include/%.h $(H_FILES)
110         mkdir -p ./$(OBJ_DIR)
111         $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<    
112
113 $(OBJ_DIR)/%.o: $(TEST_DIR)/%.cpp $(H_FILES)
114         mkdir -p ./$(OBJ_DIR)
115         $(CXX) $(CXX_FLAGS) $(INC) -c -o $@ $<  
116         
117 .PHONY: clean
118 clean :
119         rm -rf ./obj/debug/*
120         rm -rf ./obj/release/*
121         rm -rf ./lib/*
122         rm -rf ./bin/debug/*
123         rm -rf ./bin/release/*
124
125
126 .PHONY: print_vars
127
128 print_vars:
129         @echo ""
130         @echo 'BUILD     = '$(value BUILD)
131         @echo 'INC       = '$(value INC)
132         @echo 'CPP_FILES = '$(value CPP_FILES)
133         @echo 'C_FILES   = '$(value C_FILES)
134         @echo 'LIBS      = '$(value LIBS)
135         @echo 'OBJ_FILES = '$(value OBJ_FILES)
136         @echo 'SRC_DIR   = '$(value SRC_DIR)
137         
138         
139