Initial merge-commit of the OIC code. Should successfully do discovery for single...
[platform/upstream/iotivity.git] / csdk / ocrandom / test / android / makefile
1 # override with `make BUILD=release`
2 # default to debug build
3 BUILD := debug
4
5 # You must create the file "local.propertiessudo" on your local machine which contains any local paths, etc
6 # local_settings.mk should NOT be committed to repo
7 include ../../local.properties
8 # GTEST_DIR contains the path to Google Test libs and must be defined in local.properties
9 #  Example:
10 # GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
11
12 GTEST_DIR := $(GTEST_DIR_ANDROID)
13
14 # NOTE:  to run app, make sure that LD_LIBRARY_PATH env variable
15 #        contains $(GTEST_DIR)/lib/.libs
16
17 CC := $(ANDROID_NDK)/arm-linux-androideabi-gcc
18 CXX     := $(ANDROID_NDK)/arm-linux-androideabi-g++
19
20 PROG := randomtest
21
22 SRC_DIR := ../../src
23 TEST_DIR:= ../../test/android
24 INC_DIR := ../../include
25
26 #CC_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -std=c99 -fpic -D TB_LOG
27 CC_FLAGS.debug := -Os -Wall -Wno-write-strings -ffunction-sections -fdata-sections -fno-exceptions -D TB_LOG
28 #CC_FLAGS.release := -O0 -g3 -Wall -c -fmessage-length=0 -std=c99 -fpic 
29 CC_FLAGS := $(CC_FLAGS.$(BUILD))
30
31 #CXX_FLAGS.debug := -O0 -g3 -Wall -c -fmessage-length=0 -pedantic -std=c++0x -fpic -D TB_LOG
32 CXX_FLAGS.debug := -Os -Wall -Wno-write-strings -ffunction-sections -fdata-sections -fno-exceptions -D TB_LOG
33 #CXX_FLAGS.release := -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -fpic 
34 CXX_FLAGS := $(CXX_FLAGS.$(BUILD))
35
36 CFLAGS_ANDROID :=  -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -DGTEST_HAS_PTHREAD=0
37
38 INC     := -I$(SRC_DIR)  
39 INC += -I$(TEST_DIR)
40 INC += -I$(INC_DIR)
41 INC += -I$(GTEST_DIR)/include
42
43
44 # using make's computed variables to select object and bin folders
45 # depending on the build type
46 OBJ_DIR.debug := ./obj/debug
47 OBJ_DIR.release := ./obj/release
48 OBJ_DIR := $(OBJ_DIR.$(BUILD))
49
50 BIN_DIR.debug := ./bin/debug
51 BIN_DIR.release := ./bin/release
52 BIN_DIR := $(BIN_DIR.$(BUILD))
53
54 C_FILES := $(wildcard $(SRC_DIR)/*.c)
55 #CPP_FILES := $(wildcard $(SRC_DIR)/*.cpp)
56 CPP_FILES := $(wildcard $(TEST_DIR)/*.cpp)
57 OBJ_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o) $(C_FILES:.c=.o)))
58 H_FILES := $(wildcard $(TEST_DIR)/*.h)
59 H_FILES += $(wildcard $(INC_DIR)/*.h)
60 LD_FLAGS := -L/usr/lib
61 LD_FLAGS += -L$(GTEST_DIR)/lib/.libs
62 LDFLAGS_ANDROID := -march=armv7-a -Wl,--fix-cortex-a8
63
64 #LIBS := -lpthread
65 #LIBS := -lgtest
66 #LIBS += -lgtest_main
67
68 LIBS = $(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a
69 #LIBS = libgtest.a libgtest_main.a
70
71 all: $(PROG)
72         
73 $(PROG): $(OBJ_FILES)  
74         mkdir -p $(BIN_DIR)
75         $(CXX) -o $@ $^ $(LD_FLAGS) $(LDFLAGS_ANDROID) $(LIBS)  
76         mv ./$(PROG) ./$(BIN_DIR)
77
78 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/%.h $(H_FILES)
79         mkdir -p $(OBJ_DIR)
80         $(CC) $(CC_FLAGS) $(CFLAGS_ANDROID) $(INC) -c -o $@ $<
81
82 $(OBJ_DIR)/%.o: $(TEST_DIR)/%.cpp $(H_FILES)
83         mkdir -p $(OBJ_DIR)
84         $(CXX) $(CXX_FLAGS) $(CFLAGS_ANDROID) $(INC) -c -o $@ $<
85
86 install: all
87 #       adb remount
88         adb push $(BIN_DIR)/$(PROG) /data/local/tmp
89         
90 .PHONY: clean
91 clean :
92         rm -rf ./obj/debug/*
93         rm -rf ./obj/release/*
94         rm -rf ./lib/debug/*
95         rm -rf ./lib/release/*
96         rm -rf ./bin/debug/*
97         rm -rf ./bin/release/*
98         rm -rf ./test/tst_*.txt
99
100
101 .PHONY: print_vars
102
103 print_vars:
104         @echo ""
105         @echo 'BUILD     = '$(value BUILD)
106         @echo 'INC       = '$(value INC)
107         @echo 'CPP_FILES = '$(value CPP_FILES)
108         @echo 'LIBS      = '$(value LIBS)
109         
110