diff options
Diffstat (limited to 'templates/Makefile.template')
-rw-r--r-- | templates/Makefile.template | 60 |
1 files changed, 55 insertions, 5 deletions
diff --git a/templates/Makefile.template b/templates/Makefile.template index 10d7861f03..6b8f9fcac1 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -405,7 +405,7 @@ SHARED_VERSION_CPP = -${settings.cpp_version.major} SHARED_VERSION_CSHARP = -${settings.csharp_version.major} else ifeq ($(SYSTEM),Darwin) - EXECUTABLE_SUFFIX = + EXECUTABLE_SUFFIX = SHARED_EXT_CORE = dylib SHARED_EXT_CPP = dylib SHARED_EXT_CSHARP = dylib @@ -414,7 +414,7 @@ SHARED_VERSION_CPP = SHARED_VERSION_CSHARP = else - EXECUTABLE_SUFFIX = + EXECUTABLE_SUFFIX = SHARED_EXT_CORE = so.$(CORE_VERSION) SHARED_EXT_CPP = so.$(CPP_VERSION) SHARED_EXT_CSHARP = so.$(CSHARP_VERSION) @@ -435,6 +435,7 @@ OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0 protobuf + CARES_CHECK_CMD = $(PKG_CONFIG) --exists libcares else # HAS_PKG_CONFIG ifeq ($(SYSTEM),MINGW32) @@ -448,6 +449,7 @@ BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) ${defaults.boringssl.CPPFLAGS} $(CFLAGS) ${defaults.boringssl.CFLAGS} -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS) ZLIB_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS) PROTOBUF_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) + CARES_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/c-ares.c -lcares $(LDFLAGS) endif # HAS_PKG_CONFIG @@ -487,12 +489,17 @@ ifeq ($(HAS_SYSTEM_PROTOBUF),true) CACHE_MK += HAS_SYSTEM_PROTOBUF = true, endif + HAS_SYSTEM_CARES ?= $(shell $(CARES_CHECK_CMD) 2> /dev/null && echo true || echo false) + ifeq ($(HAS_SYSTEM_CARES),true) + CACHE_MK += HAS_SYSTEM_CARES = true, + endif else # override system libraries if the config requires a custom compiled library HAS_SYSTEM_OPENSSL_ALPN = false HAS_SYSTEM_OPENSSL_NPN = false HAS_SYSTEM_ZLIB = false HAS_SYSTEM_PROTOBUF = false + HAS_SYSTEM_CARES = false endif HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false) @@ -551,6 +558,12 @@ HAS_EMBEDDED_PROTOBUF = true endif + ifeq ($(wildcard third_party/cares/cares/ares.h),) + HAS_EMBEDDED_CARES = false + else + HAS_EMBEDDED_CARES = true + endif + PC_REQUIRES_GRPC = PC_LIBS_GRPC = @@ -583,6 +596,37 @@ endif endif + CARES_PKG_CONFIG = false + + ifeq ($(HAS_SYSTEM_CARES),false) + ifeq ($(HAS_EMBEDDED_CARES), true) + EMBED_CARES ?= true + else + DEP_MISSING += cares + EMBED_CARES ?= broken + endif + else + EMBED_CARES ?= false + endif + + ifeq ($(EMBED_CARES),true) + CARES_DEP = $(LIBDIR)/$(CONFIG)/libares.a + CARES_MERGE_OBJS = $(LIBARES_OBJS) + CARES_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libares.a + CPPFLAGS := -Ithird_party/cares -Ithird_party/cares/cares $(CPPFLAGS) + LDFLAGS := -L$(LIBDIR)/$(CONFIG)/c-ares $(LDFLAGS) + else + ifeq ($(HAS_PKG_CONFIG),true) + PC_REQUIRES_GRPC += libcares + CPPFLAGS += $(shell $(PKG_CONFIG) --cflags libcares) + LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L libcares) + LIBS += $(patsubst -l%,%,$(shell $(PKG_CONFIG) --libs-only-l libcares)) + else + PC_LIBS_GRPC += -lcares + LIBS += cares + endif + endif + OPENSSL_PKG_CONFIG = false PC_REQUIRES_SECURE = @@ -864,6 +908,7 @@ $(PERFTOOLS_CHECK_CMD) || true $(PROTOBUF_CHECK_CMD) || true $(PROTOC_CHECK_VERSION_CMD) || true + $(CARES_CHECK_CMD) || true third_party/protobuf/configure: $(E) "[AUTOGEN] Preparing protobuf" @@ -1453,6 +1498,9 @@ % if lib.name != 'z': $(ZLIB_DEP) \ % endif + % if lib.name != 'ares': + $(CARES_DEP) \ + % endif % endif % if lib.language == 'c++': $(PROTOBUF_DEP)\ @@ -1461,6 +1509,7 @@ % if lib.get('baselib', False): $(LIBGPR_OBJS) \ $(ZLIB_MERGE_OBJS) \ + $(CARES_MERGE_OBJS) \ % if lib.get('secure', 'check') == True: $(OPENSSL_MERGE_OBJS) \ % endif @@ -1473,6 +1522,7 @@ % if lib.get('baselib', False): $(LIBGPR_OBJS) \ $(ZLIB_MERGE_OBJS) \ + $(CARES_MERGE_OBJS) \ % if lib.get('secure', 'check') == True: $(OPENSSL_MERGE_OBJS) \ % endif @@ -1495,9 +1545,9 @@ common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)' link_libs = '' - lib_deps = ' $(ZLIB_DEP)' + lib_deps = ' $(ZLIB_DEP) $(CARES_DEP)' mingw_libs = '' - mingw_lib_deps = ' $(ZLIB_DEP)' + mingw_lib_deps = ' $(ZLIB_DEP) $(CARES_DEP)' if lib.language == 'c++': lib_deps += ' $(PROTOBUF_DEP)' mingw_lib_deps += ' $(PROTOBUF_DEP)' @@ -1522,7 +1572,7 @@ security = lib.get('secure', 'check') if security == True: common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)' - common = common + ' $(ZLIB_MERGE_LIBS)' + common = common + ' $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS)' if security in [True, 'check']: for src in lib.src: |