Browse code

ndb_cassandra: Makefile - use pkg-config if available

(cherry picked from commit 4b9fe7b72f8d9b53dbae24eb7bd269d527642f71)

Daniel-Constantin Mierla authored on 05/05/2021 07:12:25
Showing 1 changed files
... ...
@@ -9,11 +9,25 @@ LD=g++
9 9
 auto_gen=
10 10
 NAME=ndb_cassandra.so
11 11
 
12
-THRIFT_DIR = /usr/local/include/thrift
13
-LIB_DIR = /usr/local/lib
14
-
15
-DEFS += -I${THRIFT_DIR} 
16
-LIBS += -L${LIB_DIR} thrift_wrapper.o cassandra_constants.o cassandra_types.o Cassandra.o -lthrift
12
+ifeq ($(CROSS_COMPILE),)
13
+	BUILDER = $(shell which pkg-config)
14
+ifneq ($(BUILDER),)
15
+	PKGLIBTHRIFT = $(shell $(BUILDER) --exists thrift > /dev/null 2>&1 ; echo $$? )
16
+ifneq ($(PKGLIBTHRIFT),0)
17
+	BUILDER =
18
+endif
19
+endif
20
+endif
21
+
22
+ifneq ($(BUILDER),)
23
+	THRIFT_INC = $(shell $(BUILDER) --cflags thrift)
24
+	DEFS += $(THRIFT_INC)
25
+	LIBS += $(shell $(BUILDER) --libs thrift)
26
+else
27
+	THRIFT_INC = -I/usr/local/include
28
+	DEFS += $(THRIFT_INC)
29
+	LIBS += -L/usr/local/lib thrift_wrapper.o cassandra_constants.o cassandra_types.o Cassandra.o -lthrift
30
+endif
17 31
 
18 32
 CXXFLAGS=$(CFLAGS:-Wno-deprecated option=)
19 33
 CXXFLAGS+=-Wno-write-strings -Wno-deprecated -Wno-unused-function -Wno-sign-compare -Wno-strict-aliasing
... ...
@@ -22,18 +36,18 @@ include ../../Makefile.modules
22 36
 
23 37
 cassandra_constants.o: cassandra_constants.cpp cassandra_constants.h
24 38
 	@echo "Compiling $<"
25
-	$(CXX) $(CXXFLAGS) -I/usr/local/include/thrift -c $< -o $@
39
+	$(CXX) $(CXXFLAGS) $(THRIFT_INC) -c $< -o $@
26 40
 
27 41
 cassandra_types.o: cassandra_types.cpp cassandra_types.h
28 42
 	@echo "Compiling $<"
29
-	$(CXX) $(CXXFLAGS) -I/usr/local/include/thrift -c $< -o $@
43
+	$(CXX) $(CXXFLAGS) $(THRIFT_INC) -c $< -o $@
30 44
 
31 45
 Cassandra.o: Cassandra.cpp Cassandra.h
32 46
 	@echo "Compiling $<"
33
-	$(CXX) $(CXXFLAGS) -I/usr/local/include/thrift -c $< -o $@
47
+	$(CXX) $(CXXFLAGS) $(THRIFT_INC) -c $< -o $@
34 48
 
35 49
 thrift_wrapper.o: thrift_wrapper.cpp thrift_wrapper.h
36 50
 	@echo "Compiling $<"
37 51
 	$(CXX) $(CXXFLAGS) $(CFLAGS) $(C_DEFS) $(DEFS) -c $< -o $@
38 52
 
39
-ndb_cassandra.so: thrift_wrapper.o cassandra_constants.o cassandra_types.o Cassandra.o	
53
+ndb_cassandra.so: thrift_wrapper.o cassandra_constants.o cassandra_types.o Cassandra.o