Skip to content

Commit

Permalink
fix: homebrew build
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmikhalevich authored and vfusco committed Dec 13, 2023
1 parent 2eb2121 commit 97b661b
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,43 @@ CXX_Darwin=clang++
INCS_Darwin=

ifeq ($(UNAME),Darwin)

ifeq ($(MACOSX_DEPLOYMENT_TARGET),)
export MACOSX_DEPLOYMENT_TARGET := $(shell sw_vers -productVersion | sed -r "s/([[:digit:]]+)\.([[:digit:]]+)\..+/\1.\2.0/")
endif

SOLDFLAGS_Darwin+=-Wl,-rpath,$(BUILDDIR)/lib -Wl,-rpath,$(CURDIR)

# Homebrew installation
ifneq (,$(wildcard /usr/local/opt/boost/lib))
BOOST_LIB_DIR_Darwin=-L/usr/local/opt/boost/lib
BOOST_INC_Darwin=-I/usr/local/opt/boost/include
CRYPTOPP_LIB_Darwin:=-L/usr/local/opt/cryptopp/lib -lcryptopp
CRYPTOPP_INC_Darwin:=-I/usr/local/opt/cryptopp/include
else # Macports installation
BOOST_LIB_DIR_Darwin=-L/opt/local/libexec/boost/1.81/lib
BOOST_INC_Darwin=-I/opt/local/libexec/boost/1.81/include
CRYPTOPP_LIB_Darwin:=-L/opt/local/lib -lcryptopp
CRYPTOPP_INC_Darwin:=-I/opt/local/include
ifneq (,$(shell which brew))
BREW_PREFIX := $(shell brew --prefix)
BOOST_LIB_DIR_Darwin=-L$(BREW_PREFIX)/lib
BOOST_INC_Darwin=-I$(BREW_PREFIX)/include
CRYPTOPP_LIB_Darwin:=-L$(BREW_PREFIX)/lib -lcryptopp
CRYPTOPP_INC_Darwin:=-I$(BREW_PREFIX)/include
PROTOBUF_LIB_Darwin:=$(shell pkg-config --libs protobuf)
GRPC_INC_Darwin:=$(shell pkg-config --cflags-only-I grpc++)
GRPC_LIB_Darwin:=$(shell pkg-config --libs grpc++)

# Macports installation
else ifneq (,$(shell which port))
PORT_PREFIX=/opt/local
BOOST_LIB_DIR_Darwin=-L$(PORT_PREFIX)/libexec/boost/1.81/lib
BOOST_INC_Darwin=-I$(PORT_PREFIX)/libexec/boost/1.81/include
CRYPTOPP_LIB_Darwin:=-L$(PORT_PREFIX)/lib -lcryptopp
CRYPTOPP_INC_Darwin:=-I$(PORT_PREFIX)/include
PROTOBUF_LIB_Darwin:=-L$(PORT_PREFIX)/lib -lprotobuf -lpthread
GRPC_INC_Darwin=-I$(dir $(GRPC_CPP_PLUGIN))../include
GRPC_LIB_Darwin=-L$(dir $(GRPC_CPP_PLUGIN))../lib -lgrpc++ -lgrpc -lgpr -lprotobuf -lpthread -labsl_synchronization
else
$(error Neither Homebrew nor MacPorts is installed)
endif
endif

BOOST_CORO_LIB_Darwin:=$(BOOST_LIB_DIR_Darwin) -lboost_coroutine-mt -lboost_context-mt
BOOST_FILESYSTEM_LIB_Darwin:=$(BOOST_LIB_DIR_Darwin) -lboost_system-mt -lboost_filesystem-mt
BOOST_LOG_LIB_Darwin:=$(BOOST_LIB_DIR_Darwin) -lboost_log-mt -lboost_log_setup-mt -lboost_thread-mt
BOOST_PROCESS_LIB_Darwin:=-lpthread
GRPC_INC_Darwin=-I$(dir $(GRPC_CPP_PLUGIN))../include
GRPC_LIB_Darwin=-L$(dir $(GRPC_CPP_PLUGIN))../lib -lgrpc++ -lgrpc -lgpr -lprotobuf -lpthread -labsl_synchronization
PROTOBUF_LIB_Darwin:=-L/opt/local/lib -lprotobuf -lpthread
CARTESI_EXECUTABLE_LDFLAGS_Darwin=-Wl,-rpath,$(BUILDDIR)/lib -Wl,-rpath,$(CURDIR)
PROFILE_DATA_Darwin=default.profdata

Expand Down Expand Up @@ -107,8 +119,8 @@ GRPC_INC=$(GRPC_INC_$(UNAME))
PROTOBUF_LIB=$(PROTOBUF_LIB_$(UNAME))
CARTESI_EXECUTABLE_LDFLAGS=$(CARTESI_EXECUTABLE_LDFLAGS_$(UNAME))

SERVER_MANAGER_LIBS:=$(CRYPTOPP_LIB) $(GRPC_LIB) $(BOOST_CORO_LIB) $(BOOST_LOG_LIB) $(BOOST_FILESYSTEM_LIB) -ldl
TEST_SERVER_MANAGER_LIBS:=$(CRYPTOPP_LIB) $(GRPC_LIB) -ldl
SERVER_MANAGER_LIBS:=$(CRYPTOPP_LIB) $(GRPC_LIB) $(BOOST_CORO_LIB) $(BOOST_LOG_LIB) $(BOOST_FILESYSTEM_LIB) $(PROTOBUF_LIB) -ldl
TEST_SERVER_MANAGER_LIBS:=$(CRYPTOPP_LIB) $(GRPC_LIB) $(PROTOBUF_LIB) -ldl

WARNS=-W -Wall -pedantic

Expand Down

0 comments on commit 97b661b

Please sign in to comment.