iotivity 0.9.0
[platform/upstream/iotivity.git] / resource / oc_logger / samples / 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 # override with `make BUILD=debug`
22 # default to release build
23 BUILD    := release
24 PLATFORM := linux
25 CC       := g++
26 OUT_DIR   := $(BUILD)
27 OBJ_DIR   := $(OUT_DIR)/obj
28
29 ifeq ($(ROOT_DIR), )
30 ROOT_DIR        = ../../../csdk
31 endif
32
33 OUT_DIR = ./
34
35 OCLOGGER_DIR    = $(ROOT_DIR)/logger
36 OC_LOG_DIR              = $(ROOT_DIR)/../oc_logger
37 OCRANDOM_DIR    = $(ROOT_DIR)/ocrandom
38 OCSOCKET_DIR    = $(ROOT_DIR)/ocsocket
39 LCOAP_DIR               = $(ROOT_DIR)/libcoap-4.1.1
40 OCCOAP_DIR              = $(ROOT_DIR)/occoap
41 OCTBSTACK_DIR   = $(ROOT_DIR)/stack
42
43 OC_LOG_INC              = $(OC_LOG_DIR)/include
44 OC_LOG_LIB              = $(OC_LOG_DIR)/lib/oc_logger.a  
45
46 OCLOGGER_INC    = $(OCLOGGER_DIR)/include
47 OCRANDOM_INC    = $(OCRANDOM_DIR)/include
48 OCSOCKET_INC    = $(OCSOCKET_DIR)/include
49 LCOAP_INC               = $(LCOAP_DIR)
50 OCCOAP_INC              = $(OCCOAP_DIR)/include
51 OCTBSTACK_INC   = $(OCTBSTACK_DIR)/include
52
53 INC_DIRS                := -I$(OCLOGGER_INC)
54 INC_DIRS                += -I$(OC_LOG_INC)
55 INC_DIRS                += -I$(OCRANDOM_INC)
56 INC_DIRS                += -I$(OCSOCKET_INC)
57 INC_DIRS                += -I$(LCOAP_INC)
58 INC_DIRS                += -I$(OCCOAP_INC)
59 INC_DIRS                += -I$(OCTBSTACK_INC)
60
61 CC_FLAGS.debug      := -O0 -g3 -Wall -ffunction-sections -fdata-sections \
62                         -std=c99 $(INC_DIRS) -L$(ROOT_DIR)/$(PLATFORM)/$(BUILD) -DTB_LOG
63 CC_FLAGS.release    := -Os -Wall -fdata-sections -Wl,--gc-sections -Wl,-s \
64                         -std=c99 $(INC_DIRS) -L$(ROOT_DIR)/$(PLATFORM)/$(BUILD)
65
66 LDLIBS          += $(OC_LOG_LIB) -loctbstack -lpthread 
67 CPPFLAGS        += $(CC_FLAGS.$(BUILD)) $(LDLIBS)
68
69 SOURCES     := test_logging.c
70
71 OBJECTS:= $(patsubst %.c, $(OBJ_DIR)/%.o, $(SOURCES))
72
73 PROGRAMS        += test_logging
74
75 all:    prep_dirs $(OBJECTS) $(PROGRAMS)
76
77 prep_dirs:
78         -mkdir -p $(OUT_DIR)
79         -mkdir -p $(OBJ_DIR)
80
81 $(OBJ_DIR)/%.o: %.c
82         $(CC) -c $(CPPFLAGS) $< -o $@
83
84 test_logging: $(OBJ_DIR)/test_logging.o 
85         $(CC) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
86
87 .PHONY: clean
88
89 clean: legacy_clean
90         -rm -rf release
91         -rm -rf debug
92
93 legacy_clean:
94         rm -f *.o $(PROGRAMS)