From cab11fd17e760cfe8599d765d640eeefca17d9e3 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 2 Aug 2012 10:55:57 -0700 Subject: [PATCH] stapdyn & staprun: Use the top-level git_version.h Yo dawg, I herd you like Makefile recursion, so I put some recursion in your recursion so you can version while you version. Less duplication + more recursion == win? Another option is to flatten stapdyn and staprun Makefiles altogether into the root Makefile, but for now, this is less invasive. Changing the includes to ../git_version.h is not strictly necessary, since we also have "-I..", but this way developers won't get burned by old git_version.h files sitting in staprun/ or stapdyn/. --- stapdyn/Makefile.am | 33 +++------------------------------ stapdyn/Makefile.in | 33 +++------------------------------ stapdyn/stapdyn.cxx | 2 +- staprun/Makefile.am | 32 +++----------------------------- staprun/Makefile.in | 34 +++++----------------------------- staprun/common.c | 2 +- 6 files changed, 16 insertions(+), 120 deletions(-) diff --git a/stapdyn/Makefile.am b/stapdyn/Makefile.am index e2a770b96..00b4bb120 100644 --- a/stapdyn/Makefile.am +++ b/stapdyn/Makefile.am @@ -33,35 +33,8 @@ dynsdt_LDADD = -lelf $(dyninst_LIBS) endif # HAVE_DYNINST BUILT_SOURCES = -CLEANFILES = -# Arrange for git_version.h to be regenerated at every "make". -# Code fragment is based upon RadeonHD.am. - -# The stamp file which is never created ensures that git_version.h is updated -# before every build. Having git_version.h in foo_SOURCES ensures a recompile -# of foo-bar.c if it is newer than the foo-bar.o file. Using noinst_foo_SOURCES -# instead of foo_SOURCES prevents shipping git_version.h in dist tarballs, -# which may cause false GIT_FOO readings. +# Arrange for the top-level git_version.h to be regenerated at every "make". BUILT_SOURCES += git_version.stamp -CLEANFILES += git_version.h -GIT_VERSION_CMD = $(SHELL) $(top_srcdir)/git_version.sh -git_version.stamp: - @if test -f "$(srcdir)/git_version.h"; then \ - if test -f "git_version.h"; then :; \ - else \ - cp "$(srcdir)/git_version.h" "git_version.h"; \ - fi; \ - fi - $(GIT_VERSION_CMD) -k -s $(top_srcdir) -o git_version.h - @if test -s "$(srcdir)/git_version.h"; then \ - if cmp "$(srcdir)/git_version.h" "git_version.h"; then :; \ - else \ - echo "Error: $(srcdir)/git_version.h and git_version.h differ."; \ - echo " You probably want to remove the former."; \ - exit 1; \ - fi; \ - fi - -git_version.h: - $(srcdir)/git_version.sh -k --srcdir $(srcdir)/.. -o git_version.h +git_version.stamp ../git_version.h: + $(MAKE) -C .. $@ diff --git a/stapdyn/Makefile.in b/stapdyn/Makefile.in index f61c468ec..24d5149a9 100644 --- a/stapdyn/Makefile.in +++ b/stapdyn/Makefile.in @@ -269,17 +269,8 @@ AM_LDFLAGS = @PIELDFLAGS@ @HAVE_DYNINST_TRUE@dynsdt_LDFLAGS = $(AM_LDFLAGS) @DYNINST_LDFLAGS@ @HAVE_DYNINST_TRUE@dynsdt_LDADD = -lelf $(dyninst_LIBS) -# Arrange for git_version.h to be regenerated at every "make". -# Code fragment is based upon RadeonHD.am. - -# The stamp file which is never created ensures that git_version.h is updated -# before every build. Having git_version.h in foo_SOURCES ensures a recompile -# of foo-bar.c if it is newer than the foo-bar.o file. Using noinst_foo_SOURCES -# instead of foo_SOURCES prevents shipping git_version.h in dist tarballs, -# which may cause false GIT_FOO readings. +# Arrange for the top-level git_version.h to be regenerated at every "make". BUILT_SOURCES = git_version.stamp -CLEANFILES = git_version.h -GIT_VERSION_CMD = $(SHELL) $(top_srcdir)/git_version.sh all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am @@ -552,7 +543,6 @@ install-strip: mostlyclean-generic: clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -646,25 +636,8 @@ uninstall-am: uninstall-binPROGRAMS mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS -git_version.stamp: - @if test -f "$(srcdir)/git_version.h"; then \ - if test -f "git_version.h"; then :; \ - else \ - cp "$(srcdir)/git_version.h" "git_version.h"; \ - fi; \ - fi - $(GIT_VERSION_CMD) -k -s $(top_srcdir) -o git_version.h - @if test -s "$(srcdir)/git_version.h"; then \ - if cmp "$(srcdir)/git_version.h" "git_version.h"; then :; \ - else \ - echo "Error: $(srcdir)/git_version.h and git_version.h differ."; \ - echo " You probably want to remove the former."; \ - exit 1; \ - fi; \ - fi - -git_version.h: - $(srcdir)/git_version.sh -k --srcdir $(srcdir)/.. -o git_version.h +git_version.stamp ../git_version.h: + $(MAKE) -C .. $@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/stapdyn/stapdyn.cxx b/stapdyn/stapdyn.cxx index 04482c928..f3b69e6b2 100644 --- a/stapdyn/stapdyn.cxx +++ b/stapdyn/stapdyn.cxx @@ -19,7 +19,7 @@ extern "C" { #include #include "config.h" -#include "git_version.h" +#include "../git_version.h" #include "dynutil.h" diff --git a/staprun/Makefile.am b/staprun/Makefile.am index b4219e01f..d63e78a83 100644 --- a/staprun/Makefile.am +++ b/staprun/Makefile.am @@ -51,36 +51,10 @@ stapsh_LDADD = BUILT_SOURCES = CLEANFILES = -# Arrange for git_version.h to be regenerated at every "make". -# Code fragment is based upon RadeonHD.am. - -# The stamp file which is never created ensures that git_version.h is updated -# before every build. Having git_version.h in foo_SOURCES ensures a recompile -# of foo-bar.c if it is newer than the foo-bar.o file. Using noinst_foo_SOURCES -# instead of foo_SOURCES prevents shipping git_version.h in dist tarballs, -# which may cause false GIT_FOO readings. +# Arrange for the top-level git_version.h to be regenerated at every "make". BUILT_SOURCES += git_version.stamp -CLEANFILES += git_version.h -GIT_VERSION_CMD = $(SHELL) $(top_srcdir)/git_version.sh -git_version.stamp: - @if test -f "$(srcdir)/git_version.h"; then \ - if test -f "git_version.h"; then :; \ - else \ - cp "$(srcdir)/git_version.h" "git_version.h"; \ - fi; \ - fi - $(GIT_VERSION_CMD) -k -s $(top_srcdir) -o git_version.h - @if test -s "$(srcdir)/git_version.h"; then \ - if cmp "$(srcdir)/git_version.h" "git_version.h"; then :; \ - else \ - echo "Error: $(srcdir)/git_version.h and git_version.h differ."; \ - echo " You probably want to remove the former."; \ - exit 1; \ - fi; \ - fi - -git_version.h: - $(srcdir)/git_version.sh -k --srcdir $(srcdir)/.. -o git_version.h +git_version.stamp ../git_version.h: + $(MAKE) -C .. $@ # Why the "id -u" condition? This way, an unprivileged user can run diff --git a/staprun/Makefile.in b/staprun/Makefile.in index 8e7aff0a6..819d67dde 100644 --- a/staprun/Makefile.in +++ b/staprun/Makefile.in @@ -233,6 +233,7 @@ PUBLICAN_BRAND = @PUBLICAN_BRAND@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ +STAP_EXTRA_VERSION = @STAP_EXTRA_VERSION@ STAP_PREFIX = @STAP_PREFIX@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ @@ -337,17 +338,9 @@ stapsh_CFLAGS = $(AM_CFLAGS) stapsh_LDFLAGS = $(AM_LDFLAGS) stapsh_LDADD = -# Arrange for git_version.h to be regenerated at every "make". -# Code fragment is based upon RadeonHD.am. - -# The stamp file which is never created ensures that git_version.h is updated -# before every build. Having git_version.h in foo_SOURCES ensures a recompile -# of foo-bar.c if it is newer than the foo-bar.o file. Using noinst_foo_SOURCES -# instead of foo_SOURCES prevents shipping git_version.h in dist tarballs, -# which may cause false GIT_FOO readings. +# Arrange for the top-level git_version.h to be regenerated at every "make". BUILT_SOURCES = git_version.stamp -CLEANFILES = git_version.h -GIT_VERSION_CMD = $(SHELL) $(top_srcdir)/git_version.sh +CLEANFILES = all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am @@ -882,25 +875,8 @@ uninstall-man: uninstall-man8 tags uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-man uninstall-man8 uninstall-pkglibexecPROGRAMS -git_version.stamp: - @if test -f "$(srcdir)/git_version.h"; then \ - if test -f "git_version.h"; then :; \ - else \ - cp "$(srcdir)/git_version.h" "git_version.h"; \ - fi; \ - fi - $(GIT_VERSION_CMD) -k -s $(top_srcdir) -o git_version.h - @if test -s "$(srcdir)/git_version.h"; then \ - if cmp "$(srcdir)/git_version.h" "git_version.h"; then :; \ - else \ - echo "Error: $(srcdir)/git_version.h and git_version.h differ."; \ - echo " You probably want to remove the former."; \ - exit 1; \ - fi; \ - fi - -git_version.h: - $(srcdir)/git_version.sh -k --srcdir $(srcdir)/.. -o git_version.h +git_version.stamp ../git_version.h: + $(MAKE) -C .. $@ # Why the "id -u" condition? This way, an unprivileged user can run # make install, and have "sudo stap ...." or "sudo staprun ...." work later. diff --git a/staprun/common.c b/staprun/common.c index 7635e41b8..f2fe88a39 100644 --- a/staprun/common.c +++ b/staprun/common.c @@ -16,7 +16,7 @@ #include #include #include -#include "git_version.h" +#include "../git_version.h" /* variables needed by parse_args() */ int verbose; -- 2.43.5