Procházet zdrojové kódy

ndb_cassandra: Makefile - use pkg-config if available

(cherry picked from commit 4b9fe7b72f8d9b53dbae24eb7bd269d527642f71)
Daniel-Constantin Mierla před 4 roky
rodič
revize
06921b71ee
1 změnil soubory, kde provedl 23 přidání a 9 odebrání
  1. 23 9
      src/modules/ndb_cassandra/Makefile

+ 23 - 9
src/modules/ndb_cassandra/Makefile

@@ -9,11 +9,25 @@ LD=g++
 auto_gen=
 NAME=ndb_cassandra.so
 
-THRIFT_DIR = /usr/local/include/thrift
-LIB_DIR = /usr/local/lib
-
-DEFS += -I${THRIFT_DIR} 
-LIBS += -L${LIB_DIR} thrift_wrapper.o cassandra_constants.o cassandra_types.o Cassandra.o -lthrift
+ifeq ($(CROSS_COMPILE),)
+	BUILDER = $(shell which pkg-config)
+ifneq ($(BUILDER),)
+	PKGLIBTHRIFT = $(shell $(BUILDER) --exists thrift > /dev/null 2>&1 ; echo $$? )
+ifneq ($(PKGLIBTHRIFT),0)
+	BUILDER =
+endif
+endif
+endif
+
+ifneq ($(BUILDER),)
+	THRIFT_INC = $(shell $(BUILDER) --cflags thrift)
+	DEFS += $(THRIFT_INC)
+	LIBS += $(shell $(BUILDER) --libs thrift)
+else
+	THRIFT_INC = -I/usr/local/include
+	DEFS += $(THRIFT_INC)
+	LIBS += -L/usr/local/lib thrift_wrapper.o cassandra_constants.o cassandra_types.o Cassandra.o -lthrift
+endif
 
 CXXFLAGS=$(CFLAGS:-Wno-deprecated option=)
 CXXFLAGS+=-Wno-write-strings -Wno-deprecated -Wno-unused-function -Wno-sign-compare -Wno-strict-aliasing
@@ -22,18 +36,18 @@ include ../../Makefile.modules
 
 cassandra_constants.o: cassandra_constants.cpp cassandra_constants.h
 	@echo "Compiling $<"
-	$(CXX) $(CXXFLAGS) -I/usr/local/include/thrift -c $< -o $@
+	$(CXX) $(CXXFLAGS) $(THRIFT_INC) -c $< -o $@
 
 cassandra_types.o: cassandra_types.cpp cassandra_types.h
 	@echo "Compiling $<"
-	$(CXX) $(CXXFLAGS) -I/usr/local/include/thrift -c $< -o $@
+	$(CXX) $(CXXFLAGS) $(THRIFT_INC) -c $< -o $@
 
 Cassandra.o: Cassandra.cpp Cassandra.h
 	@echo "Compiling $<"
-	$(CXX) $(CXXFLAGS) -I/usr/local/include/thrift -c $< -o $@
+	$(CXX) $(CXXFLAGS) $(THRIFT_INC) -c $< -o $@
 
 thrift_wrapper.o: thrift_wrapper.cpp thrift_wrapper.h
 	@echo "Compiling $<"
 	$(CXX) $(CXXFLAGS) $(CFLAGS) $(C_DEFS) $(DEFS) -c $< -o $@
 
-ndb_cassandra.so: thrift_wrapper.o cassandra_constants.o cassandra_types.o Cassandra.o	
+ndb_cassandra.so: thrift_wrapper.o cassandra_constants.o cassandra_types.o Cassandra.o