Skip to content

Commit 410a5bd

Browse files
vkochan-mlnxlguohan
authored andcommitted
saithrift: make: Allow to specify SAI library install path (#270)
Add ability to specify SAI library path from command line like: make SAI_LIBRARY_DIR=/path or via SAI_PREFIX (if SAI headers and library are located in the same $(SAI_PREFIX) path): make SAI_PREFIX=/usr/local It might be useful for building saiserver with different versions of SAI library. Signed-off-by: Vadim Kochan <vadymk@mellanox.com>
1 parent 1c15e1b commit 410a5bd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/saithrift/Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CXX=g++
2-
SAI_HEADER_DIR = /usr/include/sai
2+
SAI_PREFIX = /usr
3+
SAI_HEADER_DIR ?= $(SAI_PREFIX)/include/sai
34
SAI_HEADERS = $(SAI_HEADER_DIR)/sai*.h
45
CFLAGS = -I$(SAI_HEADER_DIR) -I. -std=c++11
56
ifeq ($(platform),MLNX)
@@ -23,7 +24,9 @@ SAIDIR = ./include
2324
SRC = ./src
2425
THRIFT = /usr/bin/thrift
2526
CTYPESGEN = /usr/local/bin/ctypesgen.py
26-
LIBS = -lthrift -lpthread
27+
LIBS = -lthrift -lpthread -lsai
28+
SAI_LIBRARY_DIR ?= $(SAI_PREFIX)/lib
29+
LDFLAGS = -L$(SAI_LIBRARY_DIR) -Wl,-rpath=$(SAI_LIBRARY_DIR)
2730
CPP_SOURCES = \
2831
src/gen-cpp/switch_sai_constants.cpp \
2932
src/gen-cpp/switch_sai_constants.h \
@@ -75,8 +78,8 @@ $(ODIR)/librpcserver.a: $(ODIR)/switch_sai_rpc.o $(ODIR)/switch_sai_types.o $(OD
7578
ar rcs $(ODIR)/librpcserver.a $(ODIR)/switch_sai_rpc.o $(ODIR)/switch_sai_types.o $(ODIR)/switch_sai_constants.o $(ODIR)/switch_sai_rpc_server.o
7679

7780
saiserver: $(ODIR)/saiserver.o $(ODIR)/librpcserver.a
78-
$(CXX) $(ODIR)/switch_sai_rpc_server.o $(ODIR)/saiserver.o -o $@ \
79-
$(ODIR)/librpcserver.a $(LIBS) -lsai
81+
$(CXX) $(LDFLAGS) $(ODIR)/switch_sai_rpc_server.o $(ODIR)/saiserver.o -o $@ \
82+
$(ODIR)/librpcserver.a $(LIBS)
8083

8184
clean:
8285
rm -rf $(ODIR) $(SRC)/gen-cpp $(SRC)/gen-py saiserver dist

0 commit comments

Comments
 (0)