From 961255b85253cfb62db5b0122f34e9a6996e3790 Mon Sep 17 00:00:00 2001 From: sudeeps Date: Wed, 18 May 2016 10:49:34 +1000 Subject: [PATCH] 1) Makefile has been edited to compile using g++ 2) core/meta-utils.h has been chnaged to update an icorrect header file reference (connection/Request.h -> connection/request.h) --- hbase-native-client/Makefile | 115 ++++++++++++++++++++++++++-------- hbase-native-client/core/meta-utils.h | 2 +- 2 files changed, 91 insertions(+), 26 deletions(-) diff --git a/hbase-native-client/Makefile b/hbase-native-client/Makefile index 826233f..09c8cf7 100644 --- a/hbase-native-client/Makefile +++ b/hbase-native-client/Makefile @@ -1,22 +1,88 @@ -## -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -build: - $(shell buck build core/... ) +#use "gcc" to compile source files +CC:=g++ +LD:=g++ + +DEBUG_PATH = build/debug +RELEASE_PATH = build/release +MODULES = connection core if serde test-util utils +SRC_DIR = $(MODULES) +DEBUG_BUILD_DIR = $(addprefix $(DEBUG_PATH)/,$(MODULES)) +RELEASE_BUILD_DIR = $(addprefix $(RELEASE_PATH)/,$(MODULES)) +INCLUDE_DIR = /usr/src/hbase/hbase-native-client + +#flags to pass to the CPP compiler & linker +CPPFLAGS_DEBUG = -g -Wall -std=c++14 -pedantic -fPIC #-Weffc++ +CPPFLAGS_RELEASE = -DNDEBUG -Wall -std=c++14 -pedantic -fPIC #-Weffc++ +LDFLAGS = -lprotobuf -lzookeeper_mt -lsasl2 -lfolly -lwangle +LINKFLAG = -shared + +#define list of source files and object files +SRC = $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cc)) +DEBUG_OBJ = $(patsubst %.cc,$(DEBUG_PATH)/%.o,$(SRC)) +RELEASE_OBJ = $(patsubst %.cc,$(RELEASE_PATH)/%.o,$(SRC)) +INCLUDES = $(addprefix -I,$(INCLUDE_DIR)) + +LIB_DIR = /usr/local +LIB_LIBDIR = $(LIB_DIR)/lib +LIB_INCDIR = $(LIB_DIR)/include +LIB_RELEASE=$(RELEASE_PATH)/libHbaseClient.so +ARC_RELEASE=$(RELEASE_PATH)/libHbaseClient.a +LIB_DEBUG=$(DEBUG_PATH)/libHbaseClient_d.so +ARC_DEBUG=$(DEBUG_PATH)/libHbaseClient_d.a + +vpath %.cc $(SRC_DIR) + +$(LIB_DEBUG): $(DEBUG_BUILD_DIR) +define make-goal-dbg +$1/%.o: %.cc + $(CC) -c $$< -o $$@ $(CPPFLAGS_DEBUG) $(INCLUDES) +endef + +$(LIB_RELEASE): $(RELEASE_BUILD_DIR) +define make-goal-rel +$1/%.o: %.cc + $(CC) -c $$< -o $$@ $(CPPFLAGS_RELEASE) $(INCLUDES) +endef + +.PHONY: checkdirs all install clean check help test if +build: protobuf checkdirs $(LIB_DEBUG) $(LIB_RELEASE) $(ARC_DEBUG) $(ARC_RELEASE) + +checkdirs: $(DEBUG_BUILD_DIR) $(RELEASE_BUILD_DIR) + +protobuf: + $(shell protoc --proto_path=if --cpp_out=if if/*.proto) + +install: + cp $(LIB_RELEASE) $(LIB_LIBDIR)/libHbaseClient.so + cp $(ARC_RELEASE) $(LIB_LIBDIR)/libHbaseClient.a + cp $(LIB_DEBUG) $(LIB_LIBDIR)/libHbaseClient_d.so + cp $(ARC_DEBUG) $(LIB_LIBDIR)/libHbaseClient_d.a + +$(DEBUG_BUILD_DIR): + @mkdir -p $@ + +$(RELEASE_BUILD_DIR): + @mkdir -p $@ + +$(ARC_DEBUG): $(DEBUG_OBJ) + ar rcs $@ $^ + +$(ARC_RELEASE): $(RELEASE_OBJ) + ar rcs $@ $^ + +$(LIB_RELEASE): $(RELEASE_OBJ) + $(LD) $(LINKFLAG) -o $@ $(LDFLAGS) $(RELEASE_OBJ) + +$(LIB_DEBUG): $(DEBUG_OBJ) + $(LD) $(LINKFLAG) -o $@ $(LDFLAGS) $(DEBUG_OBJ) + +#to clean re-compilable files +clean: + @rm -rf $(DEBUG_BUILD_DIR) $(RELEASE_BUILD_DIR) $(LIB_RELEASE) $(LIB_DEBUG) $(ARC_RELEASE) $(ARC_DEBUG) docs + +$(foreach bdir,$(DEBUG_BUILD_DIR),$(eval $(call make-goal-dbg,$(bdir)))) + +$(foreach bdir,$(RELEASE_BUILD_DIR),$(eval $(call make-goal-rel,$(bdir)))) check: $(shell buck test --all --no-results-cache ) @@ -24,14 +90,13 @@ check: doc: $(shell doxygen hbase.doxygen > /dev/null ) -clean: - $(shell rm -rf docs ) - help: @echo "Available targets:" @echo "" - @echo " build : will build everything." - @echo " clean : will remove the docs folder" - @echo " check : will test everything." + @echo " build : will build everything." + @echo " clean : will remove the docs folder, object files and local libraries" + @echo " install : will copy the libs to $(LIB_LIBDIR). super user priviliege would be required." + @echo " check : will test everything." all: build doc check + diff --git a/hbase-native-client/core/meta-utils.h b/hbase-native-client/core/meta-utils.h index f6cc84f..294e17d 100644 --- a/hbase-native-client/core/meta-utils.h +++ b/hbase-native-client/core/meta-utils.h @@ -20,7 +20,7 @@ #include -#include "connection/Request.h" +#include "connection/request.h" #include "if/HBase.pb.h" #include "serde/table-name.h" -- 1.8.3.1