diff --git a/Makefile.lib b/Makefile.lib index 92811269f..7fcd01f43 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -93,9 +93,10 @@ INCLUDE_ALL=1 endif ifneq ($(findstring init,$(MAKECMDGOALS)),) -# FIXME: Detect when $(subdir)/Makefile is $(srcdir)/$(subdir)/Makefile -# and error out so the user won't overwrite the 'master' Makefiles. INCLUDE_ALL=1 +ifndef SRC +SRC = $(shell cd $(top_srcdir) && pwd) +endif endif ifdef INCLUDE_ALL @@ -130,7 +131,8 @@ all-default: $(LIB_O) $(PROGS) $(MAN1) $(MAN5) init-default: @$(foreach subdir,$(sort $(SUBDIRS)), \ $(MKINSTALLDIRS) $(subdir) >/dev/null; \ - echo 'include $(SRC)/$(RELPATH)/$(subdir)/Makefile' > $(subdir)/Makefile;) + test -e "$(subdir)/Makefile" \ + || echo 'include $(SRC)/$(RELPATH)/$(subdir)/Makefile' > $(subdir)/Makefile;) clean-default cleanall-default: @-test -z "$(CLEAN)" || $(RM) $(CLEAN)