From 504f81a775df94630b1f53b25340a08d29b59ec3 Mon Sep 17 00:00:00 2001 From: alquerci Date: Mon, 6 Oct 2014 09:22:26 +0200 Subject: [PATCH] Added a error when attempt to create a distribution on a sub directory --- Makefile.in | 4 ++-- bootstrap.mk.in | 15 +++++++++++++-- doc/Makefile.in | 4 ++-- src/Makefile.in | 4 ++-- tools/Makefile.in | 4 ++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index f981010..64408ef 100644 --- a/Makefile.in +++ b/Makefile.in @@ -25,10 +25,10 @@ install: installdirs $(POST_INSTALL) # Post-install commands follow. dist: FORCE - $(fn_remove_dist_archive) + $(fn_pre_dist) dir='$(srcdir)' && $(fn_append_files_to_dist_archive) \ $(notdir $(INSTALL_DOCS)) - $(fn_finalize_dist_archive) + $(fn_post_dist) installdirs: $(INSTALL) -d '$(DESTDIR)$(docdir)' diff --git a/bootstrap.mk.in b/bootstrap.mk.in index 53f8f20..4a35341 100644 --- a/bootstrap.mk.in +++ b/bootstrap.mk.in @@ -201,11 +201,21 @@ maintainer-clean-generic: @echo 'deletes files that may need special tools to rebuild.' -fn_remove_dist_archive = rm -f '$(DIST_ARCHIVE)' +fn_top_pre_dist = \ + test x"$(builddir)" = x"$(top_builddir)" || { \ + echo "ERROR: cannot create a distribution on a sub directory"; \ + echo ' $$ cd $(top_builddir) && make dist'; \ + exit 1; \ + } >&2 + +fn_pre_dist = \ + @$(fn_top_pre_dist); \ + echo 'rm -f $(DIST_ARCHIVE)'; \ + rm -f '$(DIST_ARCHIVE)' fn_append_files_to_dist_archive = tar -C $$dir -rf '$(DIST_ARCHIVE)' --transform s,'^','$(distdir)/', -fn_finalize_dist_archive = \ +fn_post_dist = \ @echo 'dir="$(srcdir)" && $(fn_append_files_to_dist_archive)'; \ echo ' Makefile.in'; \ dir='$(srcdir)' && $(fn_append_files_to_dist_archive) \ @@ -258,6 +268,7 @@ fn_titlelize = { sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'; } distdir="$(distdir)/$$subdir" \ fn_finalize_top_dist_archive=':' \ TOP_DISTCLEAN_FILES='' \ + fn_top_pre_dist=':' \ ; \ done; diff --git a/doc/Makefile.in b/doc/Makefile.in index c049b3c..5ebeb4d 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -23,10 +23,10 @@ install: all installdirs $(POST_INSTALL) # Post-install commands follow. dist: FORCE - $(fn_remove_dist_archive) + $(fn_pre_dist) dir='$(srcdir)' && $(fn_append_files_to_dist_archive) \ man.1 - $(fn_finalize_dist_archive) + $(fn_post_dist) $(builddir)/$(PACKAGE)$(man1ext).gz: $(srcdir)/man.1 gzip -c $^ > $@ diff --git a/src/Makefile.in b/src/Makefile.in index 0eb6fbf..3aac407 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -55,7 +55,7 @@ installcheck: install cd '$(DESTDIR)$(pkglibdir)' && $(PYTHON) $(PYTHONFLAGS) $(TEST_SCRIPT) $(ARGUMENTS) dist: $(srcdir)/setup.py FORCE - $(fn_remove_dist_archive) + $(fn_pre_dist) rm -rf $(srcdir)/build $(PYTHON) $(PYTHONFLAGS) $(srcdir)/setup.py build dir='$(srcdir)/build/lib' && $(fn_append_files_to_dist_archive) \ @@ -65,7 +65,7 @@ dist: $(srcdir)/setup.py FORCE main.in \ postinstall.sh.in \ setup.py.in - $(fn_finalize_dist_archive) + $(fn_post_dist) $(builddir)/$(PACKAGE): $(srcdir)/main.in cat $^ \ diff --git a/tools/Makefile.in b/tools/Makefile.in index 0461938..a90154c 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -23,10 +23,10 @@ install: all installdirs $(POST_INSTALL) # Post-install commands follow. dist: FORCE - $(fn_remove_dist_archive) + $(fn_pre_dist) dir='$(srcdir)' && $(fn_append_files_to_dist_archive) \ completion.bash - $(fn_finalize_dist_archive) + $(fn_post_dist) $(builddir)/$(PACKAGE): $(srcdir)/completion.bash cp $^ $@