diff options
Diffstat (limited to 'templates/Makefile.template')
-rw-r--r-- | templates/Makefile.template | 101 |
1 files changed, 83 insertions, 18 deletions
diff --git a/templates/Makefile.template b/templates/Makefile.template index e51af39348..1e7a2a49bd 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -101,14 +101,23 @@ CPPFLAGS_opt = -O2 LDFLAGS_opt = DEFINES_opt = NDEBUG -VALID_CONFIG_latprof = 1 -CC_latprof = $(DEFAULT_CC) -CXX_latprof = $(DEFAULT_CXX) -LD_latprof = $(DEFAULT_CC) -LDXX_latprof = $(DEFAULT_CXX) -CPPFLAGS_latprof = -O2 -DGRPC_LATENCY_PROFILER -LDFLAGS_latprof = -DEFINES_latprof = NDEBUG +VALID_CONFIG_basicprof = 1 +CC_basicprof = $(DEFAULT_CC) +CXX_basicprof = $(DEFAULT_CXX) +LD_basicprof = $(DEFAULT_CC) +LDXX_basicprof = $(DEFAULT_CXX) +CPPFLAGS_basicprof = -O2 -DGRPC_BASIC_PROFILER +LDFLAGS_basicprof = +DEFINES_basicprof = NDEBUG + +VALID_CONFIG_stapprof = 1 +CC_stapprof = $(DEFAULT_CC) +CXX_stapprof = $(DEFAULT_CXX) +LD_stapprof = $(DEFAULT_CC) +LDXX_stapprof = $(DEFAULT_CXX) +CPPFLAGS_stapprof = -O2 -DGRPC_STAP_PROFILER +LDFLAGS_stapprof = +DEFINES_stapprof = NDEBUG VALID_CONFIG_dbg = 1 CC_dbg = $(DEFAULT_CC) @@ -188,7 +197,7 @@ LD_gcov = gcc LDXX_gcov = g++ CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage LDFLAGS_gcov = -fprofile-arcs -ftest-coverage -DEFINES_gcov = NDEBUG +DEFINES_gcov = _DEBUG DEBUG # General settings. @@ -197,6 +206,7 @@ DEFINES_gcov = NDEBUG prefix ?= /usr/local PROTOC = protoc +DTRACE = dtrace CONFIG ?= opt CC = $(CC_$(CONFIG)) CXX = $(CXX_$(CONFIG)) @@ -364,6 +374,8 @@ PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perfto PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) PROTOC_CHECK_CMD = which protoc > /dev/null PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3 +DTRACE_CHECK_CMD = which dtrace > /dev/null +SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS) ifeq ($(OPENSSL_REQUIRES_DL),true) OPENSSL_ALPN_CHECK_CMD += -ldl @@ -396,6 +408,18 @@ else HAS_VALID_PROTOC = false 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). +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 +ifeq ($(HAS_SYSTEMTAP_HEADERS),true) +ifeq ($(HAS_DTRACE),true) +HAS_SYSTEMTAP = true +endif +endif + ifeq ($(wildcard third_party/openssl/ssl/ssl.h),) HAS_EMBEDDED_OPENSSL_ALPN = false else @@ -575,6 +599,17 @@ protoc_dep_message: @echo " make run_dep_checks" @echo +systemtap_dep_error: + @echo + @echo "DEPENDENCY ERROR" + @echo + @echo "Under the '$(CONFIG)' configutation, the target you are trying " + @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other " + @echo "platforms such as Solaris and *BSD). " + @echo + @echo "Please consult INSTALL to get more information." + @echo + stop: @false @@ -863,6 +898,18 @@ endif % endfor +ifeq ($(CONFIG),stapprof) +src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h +ifeq ($(HAS_SYSTEMTAP),true) +$(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d + $(E) "[DTRACE] Compiling $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(DTRACE) -C -h -s $< -o $@ +else +$(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop +endif +endif + $(OBJDIR)/$(CONFIG)/%.o : %.c $(E) "[C] Compiling $<" $(Q) mkdir -p `dirname $@` @@ -883,7 +930,6 @@ $(OBJDIR)/$(CONFIG)/%.o : %.cc $(Q) mkdir -p `dirname $@` $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< - install: install_c install_cxx install-plugins install-certs verify-install install_c: install-headers_c install-static_c install-shared_c @@ -1215,7 +1261,8 @@ $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) % endfor </%def> -<%def name="maketarget(tgt)"> +<%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %> +% if not has_no_sources: ${tgt.name.upper()}_SRC = \\ % for src in tgt.src: @@ -1224,7 +1271,7 @@ ${tgt.name.upper()}_SRC = \\ % endfor ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC)))) - +% endif % if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check': ifeq ($(NO_SECURE),true) @@ -1254,9 +1301,15 @@ $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/${tgt.name}: $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\ +$(BINDIR)/$(CONFIG)/${tgt.name}: \ +% if not has_no_sources: +$(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\ +% endif % else: -$(BINDIR)/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\ +$(BINDIR)/$(CONFIG)/${tgt.name}: \ +% if not has_no_sources: +$(${tgt.name.upper()}_OBJS)\ +% endif % endif % for dep in tgt.deps: $(LIBDIR)/$(CONFIG)/lib${dep}.a\ @@ -1267,17 +1320,26 @@ $(BINDIR)/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\ % if tgt.build == 'protoc': $(E) "[HOSTLD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) $(${tgt.name.upper()}_OBJS)\ + $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \ +% if not has_no_sources: +$(${tgt.name.upper()}_OBJS)\ +% endif % else: $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\ + $(Q) $(LDXX) $(LDFLAGS) \ +% if not has_no_sources: +$(${tgt.name.upper()}_OBJS)\ +% endif % endif % else: ## C-only targets specificities. $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\ + $(Q) $(LD) $(LDFLAGS) \ +% if not has_no_sources: +$(${tgt.name.upper()}_OBJS)\ +% endif % endif % for dep in tgt.deps: $(LIBDIR)/$(CONFIG)/lib${dep}.a\ @@ -1319,9 +1381,11 @@ $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \ % endfor % endfor - +% if not has_no_sources: deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep) +% endif +% if not has_no_sources: % if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check': ifneq ($(NO_SECURE),true) % endif @@ -1331,6 +1395,7 @@ endif % if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check': endif % endif +% endif </%def> ifneq ($(OPENSSL_DEP),) |