diff options
author | murgatroid99 <mlumish@google.com> | 2015-07-10 14:49:12 -0700 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2015-07-10 14:49:12 -0700 |
commit | aa5215770d839351d6990f3920e202a865fcebdc (patch) | |
tree | 77a71e219757015e3ddfbb83c78f43e866785186 /templates | |
parent | a4ae29bb91da3b2a02e01b2e3f8e42beaefc7c2b (diff) |
Add caching for Makefile dependency detection
Diffstat (limited to 'templates')
-rw-r--r-- | templates/Makefile.template | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/templates/Makefile.template b/templates/Makefile.template index 84822ab80f..a8ec8788a0 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -346,7 +346,15 @@ HOST_LDLIBS = $(LDLIBS) # These are automatically computed variables. # There shouldn't be any need to change anything from now on. -HAS_PKG_CONFIG = $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false) +-include cache.mk + +CACHE_MK = + +HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false) + +ifeq ($(HAS_PKG_CONFIG), true) +CACHE_MK += HAS_PKG_CONFIG = true\n +endif PC_TEMPLATE = prefix=$(prefix)\n\ exec_prefix=${'\$${prefix}'}\n\ @@ -430,23 +438,34 @@ DTRACE_CHECK_CMD = which dtrace > /dev/null SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS) ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) -HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) +HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) ifeq ($(HAS_SYSTEM_PERFTOOLS),true) DEFINES += GRPC_HAVE_PERFTOOLS LIBS += profiler +CACHE_MK += HAS_SYSTEM_PERFTOOLS = true\n endif endif HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false) ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) -HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false) +HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false) ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true) HAS_SYSTEM_OPENSSL_NPN = true +CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true\n else -HAS_SYSTEM_OPENSSL_NPN = $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false) +HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false) +endif +ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true) +CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true\n +endif +HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false) +ifeq ($(HAS_SYSTEM_ZLIB),true) +CACHE_MK += HAS_SYSTEM_ZLIB = true\n +endif +HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY) +ifeq ($(HAS_SYSTEM_PROTOBUF),true) +CACHE_MK += HAS_SYSTEM_PROTOBUF = true\n endif -HAS_SYSTEM_ZLIB = $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false) -HAS_SYSTEM_PROTOBUF = $(HAS_SYSTEM_PROTOBUF_VERIFY) else # override system libraries if the config requires a custom compiled library HAS_SYSTEM_OPENSSL_ALPN = false @@ -455,9 +474,13 @@ HAS_SYSTEM_ZLIB = false HAS_SYSTEM_PROTOBUF = false endif -HAS_PROTOC = $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false) +HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false) ifeq ($(HAS_PROTOC),true) -HAS_VALID_PROTOC = $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false) +CACHE_MK += HAS_PROTOC = true\n +HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false) +ifeq ($(HAS_VALID_PROTOC),true) +CACHE_MK += HAS_VALID_PROTOC = true\n +endif else HAS_VALID_PROTOC = false endif @@ -465,6 +488,7 @@ endif # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap # distribution. It's part of the base system on BSD/Solaris machines). +ifndef HAS_SYSTEMTAP HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEMTAP = false @@ -473,6 +497,7 @@ ifeq ($(HAS_DTRACE),true) HAS_SYSTEMTAP = true endif endif +endif # Note that for testing purposes, one can do: # make HAS_EMBEDDED_OPENSSL_ALPN=false @@ -842,7 +867,7 @@ $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure static: static_c static_cxx -static_c: pc_c pc_c_unsecure \ +static_c: pc_c pc_c_unsecure cache.mk \ % for lib in libs: % if lib.build == 'all' and lib.language == 'c': $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ @@ -850,7 +875,7 @@ static_c: pc_c pc_c_unsecure \ % endfor -static_cxx: pc_cxx pc_cxx_unsecure pc_gpr\ +static_cxx: pc_cxx pc_cxx_unsecure pc_gpr cache.mk \ % for lib in libs: % if lib.build == 'all' and lib.language == 'c++': $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ @@ -860,7 +885,7 @@ static_cxx: pc_cxx pc_cxx_unsecure pc_gpr\ shared: shared_c shared_cxx -shared_c: pc_c pc_c_unsecure pc_gpr\ +shared_c: pc_c pc_c_unsecure pc_gpr cache.mk\ % for lib in libs: % if lib.build == 'all' and lib.language == 'c': $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\ @@ -868,7 +893,7 @@ shared_c: pc_c pc_c_unsecure pc_gpr\ % endfor -shared_cxx: pc_cxx pc_cxx_unsecure \ +shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\ % for lib in libs: % if lib.build == 'all' and lib.language == 'c++': $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\ @@ -1077,6 +1102,10 @@ ifeq ($(CONFIG),opt) % endfor endif +cache.mk:: + $(E) "[MAKE] Generating $@" + $(Q) echo -e "$(CACHE_MK)" >$@ + $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc: $(E) "[MAKE] Generating $@" $(Q) mkdir -p $(@D) @@ -1288,7 +1317,7 @@ endif clean: $(E) "[CLEAN] Cleaning build directories." - $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) + $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk # The various libraries |