Initial merge-commit of the OIC code. Should successfully do discovery for single...
[platform/upstream/iotivity.git] / csdk / controller / core / makefile
1 # override with `make BUILD=release`
2 # default to debug build
3 BUILD := debug
4
5 CC := g++
6
7 PROG := core
8
9 SRC_DIR := ./src
10 TEST_DIR := ./test
11 TEMP_DIR := ./include/core
12
13 CC_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -pedantic -fpic
14 CC_FLAGS.release := -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -fpic
15 CC_FLAGS := $(CC_FLAGS.$(BUILD))
16
17 INC     := -I$(SRC_DIR)  
18 INC     += -I./include/core
19 INC += -I$(TEST_DIR)
20 INC += -I../include/controller
21
22 LIBS :=
23 #LIBS := -lpthread
24 #LIBS +=        -lboost_thread-mt
25 #LIBS += -lboost_thread
26
27 # using make's computed variables to select object and bin folders
28 # depending on the build type
29 OBJ_DIR.debug := ./obj/debug
30 OBJ_DIR.release := ./obj/release
31 OBJ_DIR := $(OBJ_DIR.$(BUILD))
32
33 BIN_DIR.debug := ./bin/debug
34 BIN_DIR.release := ./bin/release
35 BIN_DIR := $(BIN_DIR.$(BUILD))
36
37 CPP_FILES := $(wildcard $(SRC_DIR)/*.cpp)
38 CPP_FILES += $(wildcard $(TEST_DIR)/*.cpp)
39 CPP_FILES += $(wildcard $(TEMP_DIR)/*.cpp)
40 OBJ_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o)))
41 H_FILES := $(wildcard ./include/core/*.hpp)
42 H_FILES += $(wildcard ./include/core/*.h)
43 H_FILES += $(wildcard $(TEST_DIR)/*.h)
44 LD_FLAGS := -L/usr/lib
45
46
47 all: $(PROG)
48
49 $(PROG): $(OBJ_FILES)
50         $(CC) -o $@ $^ $(LD_FLAGS) $(LIBS)      
51         mv ./$(PROG) ./$(BIN_DIR)
52
53
54 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h $(H_FILES)
55         $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<
56
57 $(OBJ_DIR)/%.o: $(TEST_DIR)/%.cpp $(H_FILES)
58         $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<
59         
60 $(OBJ_DIR)/%.o: $(TEMP_DIR)/%.cpp $(H_FILES)
61         $(CC) $(CC_FLAGS) $(INC) -c -o $@ $<    
62
63 .PHONY: clean
64 clean :
65         rm -rf ./obj/debug/*
66         rm -rf ./obj/release/*
67         rm -rf ./bin/debug/*
68         rm -rf ./bin/release/*
69
70
71 .PHONY: print_vars
72
73 print_vars:
74         @echo ""
75         @echo 'BUILD     = '$(value BUILD)
76         @echo 'INC       = '$(value INC)
77         @echo 'CPP_FILES = '$(value CPP_FILES)
78         @echo 'LIBS      = '$(value LIBS)
79         
80