diff options
Diffstat (limited to 'templates/Makefile.template')
-rw-r--r-- | templates/Makefile.template | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/templates/Makefile.template b/templates/Makefile.template index 7aa6ad71e2..c54c146620 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -187,6 +187,12 @@ CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) + CHECK_SHADOW_WORKS_CMD = $(CC) -std=c99 -Werror -Wshadow -o $(TMPOUT) -c test/build/shadow.c + HAS_WORKING_SHADOW = $(shell $(CHECK_SHADOW_WORKS_CMD) 2> /dev/null && echo true || echo false) + ifeq ($(HAS_WORKING_SHADOW),true) + W_SHADOW=-Wshadow + endif + CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD = $(CC) -std=c99 -Werror -Wno-shift-negative-value -o $(TMPOUT) -c test/build/empty.c HAS_NO_SHIFT_NEGATIVE_VALUE = $(shell $(CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD) 2> /dev/null && echo true || echo false) ifeq ($(HAS_NO_SHIFT_NEGATIVE_VALUE),true) @@ -207,7 +213,7 @@ DEFINES += $(EXTRA_DEFINES) endif - CFLAGS += -std=c99 -Wsign-conversion -Wconversion -Wshadow + CFLAGS += -std=c99 -Wsign-conversion -Wconversion $(W_SHADOW) ifeq ($(HAS_CXX11),true) CXXFLAGS += -std=c++11 else @@ -352,6 +358,7 @@ OPENSSL_ALPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS) OPENSSL_NPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS) + 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) @@ -436,10 +443,13 @@ # Note that for testing purposes, one can do: # make HAS_EMBEDDED_OPENSSL_ALPN=false # to emulate the fact we do not have OpenSSL in the third_party folder. - ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),) + ifneq ($(wildcard third_party/${openssl_fallback.extraction_dir}/libssl.a),) + HAS_EMBEDDED_OPENSSL_ALPN = third_party/${openssl_fallback.extraction_dir} + else ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),) HAS_EMBEDDED_OPENSSL_ALPN = false else - HAS_EMBEDDED_OPENSSL_ALPN = true + CAN_COMPILE_EMBEDDED_OPENSSL ?= $(shell $(BORINGSSL_COMPILE_CHECK_CMD) 2> /dev/null && echo true || echo false) + HAS_EMBEDDED_OPENSSL_ALPN = $(CAN_COMPILE_EMBEDDED_OPENSSL) endif ifeq ($(wildcard third_party/zlib/zlib.h),) @@ -498,8 +508,8 @@ EMBED_OPENSSL ?= false NO_SECURE ?= false else # HAS_SYSTEM_OPENSSL_ALPN=false - ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true) - EMBED_OPENSSL ?= true + ifneq ($(HAS_EMBEDDED_OPENSSL_ALPN),false) + EMBED_OPENSSL ?= $(HAS_EMBEDDED_OPENSSL_ALPN) NO_SECURE ?= false else # HAS_EMBEDDED_OPENSSL_ALPN=false ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true) @@ -520,6 +530,12 @@ OPENSSL_MERGE_OBJS += $(LIBBORINGSSL_OBJS) # need to prefix these to ensure overriding system libraries CPPFLAGS := -Ithird_party/boringssl/include $(CPPFLAGS) + else ifneq ($(EMBED_OPENSSL),false) + OPENSSL_DEP += $(EMBED_OPENSSL)/libssl.a $(EMBED_OPENSSL)/libcrypto.a + OPENSSL_MERGE_LIBS += $(EMBED_OPENSSL)/libssl.a $(EMBED_OPENSSL)/libcrypto.a + OPENSSL_MERGE_OBJS += $(wildcard $(EMBED_OPENSSL)/grpc_obj/*.o) + # need to prefix these to ensure overriding system libraries + CPPFLAGS := -I$(EMBED_OPENSSL)/include $(CPPFLAGS) else # EMBED_OPENSSL=false ifeq ($(HAS_PKG_CONFIG),true) OPENSSL_PKG_CONFIG = true @@ -706,8 +722,9 @@ @echo @echo "DEPENDENCY ERROR" @echo - @echo "The target you are trying to run requires OpenSSL." - @echo "Your system doesn't have it, and neither does the third_party directory." + @echo "The target you are trying to run requires an OpenSSL implementation." + @echo "Your system doesn't have one, and either the third_party directory" + @echo "doesn't have it, or your compiler can't build BoringSSL." @echo @echo "Please consult INSTALL to get more information." @echo @@ -1846,3 +1863,9 @@ strip_cxx strip-shared_cxx strip-static_cxx \ dep_c dep_cxx bins_dep_c bins_dep_cxx \ clean + + .PHONY: printvars + printvars: + @$(foreach V,$(sort $(.VARIABLES)), \ + $(if $(filter-out environment% default automatic, \ + $(origin $V)),$(warning $V=$($V) ($(value $V))))) |