From 099c6ced849aaa9a6063fd1e63a3db571be70dde Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 29 Jun 2015 08:46:48 -0600 Subject: `make dist` wasn't working --- .gitignore | 1 + Makefile | 7 +++++++ common.bottom.mk | 36 +++++++++++++++++++++++++----------- common.once.mk | 7 ------- common.top.mk | 4 +++- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index bbcb9a2..c594882 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /config.sh *.o .*.mk +/*.tar.* diff --git a/Makefile b/Makefile index 1f84a37..57993c8 100644 --- a/Makefile +++ b/Makefile @@ -23,5 +23,12 @@ subdirs = wrapper src_files = Makefile src_files += common.top.mk common.bottom.mk config.mk configure src_files += COPYING HACKING README +obj_files = config.sh config.h + +config_vars = $(shell $(SED) -n 's/^\s*\([a-z][^ !?:=]*\).*=.*/\1/p' $(topobjdir)/config.mk) PACKAGE VERSION DESTDIR +$(objdir)/config.sh: $(objdir)/config.mk + $(PRINTF) '%s=%s\n' $(foreach v,$(config_vars),$v $($v)) | LC_ALL=C $(SORT) > $@ +$(objdir)/config.h: $(objdir)/config.sh + . $(abspath $<) && $(PRINTF) '#define %s "%s"\n' $(foreach v,$(config_vars),$v '$($v)') PACKAGE_UPPER $${PACKAGE^^} | LC_ALL=C $(SORT) > $@ include $(topsrcdir)/common.bottom.mk diff --git a/common.bottom.mk b/common.bottom.mk index 0e2c039..016e093 100644 --- a/common.bottom.mk +++ b/common.bottom.mk @@ -39,9 +39,6 @@ $(parent)_clean_files := $($(parent)_clean_files) $($(module)_clean_files) $(parent)_slow_files := $($(parent)_slow_files) $($(module)_slow_files) $(parent)_conf_files := $($(parent)_conf_files) $($(module)_conf_files) $(parent)_dist_files := $($(parent)_dist_files) $($(module)_dist_files) -$(info added <$(module)> to <$(parent)>) -$(info $(parent)_clean_files => $($(parent)_clean_files)) -$(info $(parent)_obj_files => $($(parent)_obj_files)) endif modules := $(modules) $(module) @@ -53,19 +50,36 @@ define _nl endef +define _include_makefile +ifeq ($(filter $(abspath $1),$(included_makefiles)),) +include $(if $(call _is_subdir,.,$1),$(call _relto,.,$1),$(topobjdir)/$(call _relto,$(topobjdir),$1)) +endif +endef $(eval \ _COMMON_MK_NOONCE = n$(_nl)\ - $(foreach dir,$(subdirs),parent=$(module)$(_nl)include $(objdir)/$(dir)/Makefile$(_nl)) \ - $(foreach dir,$(depdirs),parent=dep $(_nl)include $(objdir)/$(dir)/Makefile$(_nl)) \ + $(foreach dir,$(subdirs),parent=$(module)$(_nl)$(call _include_makefile,$(objdir)/$(dir)/Makefile)$(_nl))\ + parent=dep$(_nl)\ + $(call _include_makefile,$(topobjdir)/$(dir)/Makefile)$(_nl)\ _COMMON_MK_NOONCE = $(_COMMON_MK_NOONCE)) -# This only gets evaluated once, after all of the other Makefiles a read +# This only gets evaluated once, after all of the other Makefiles are read ifeq ($(_COMMON_MK_NOONCE),) - -.phony = build install uninstall mostlyclean clean distclean maintainer-clean check +# Empty module-level variables +objdir = /bogus +srcdir = /bogus +subdirs = +depdirs = +src_files = +obj_files = +sys_files = +clean_files = +slow_files = +conf_files = +dist_files = # Declare phony targets +.phony = build install uninstall mostlyclean clean distclean maintainer-clean check define module_rules .PHONY: $(addsuffix -%(module),$(.phony)) # Constructive phony targets @@ -93,11 +107,11 @@ $(topobjdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topobjdir)/$(PACKAGE)-$(VERSION) $(TAR) czf $@ -C $( $@ -$(topobjdir)/config.h: $(topobjdir)/config.sh - . $(abspath $<) && $(PRINTF) '#define %s "%s"\n' $(foreach v,$(config_vars),$v '$($v)') PACKAGE_UPPER $${PACKAGE^^} | LC_ALL=C $(SORT) > $@ - # Should be on by default .DELETE_ON_ERROR: diff --git a/common.top.mk b/common.top.mk index 931bc84..a83abb6 100644 --- a/common.top.mk +++ b/common.top.mk @@ -29,8 +29,10 @@ endif objdir := $(call _noslash,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) srcdir := $(firstword $(call _relto,., $(topsrcdir)/$(call _relto,$(topobjdir),$(objdir)) ) .) +included_makefiles := $(included_makefiles) $(abspath $(objdir)/Makefile) + ## Set module name -module := $(firstword $(subst /,_,$(if $(call _is_subdir,.,$(objdir)),$(call _relto,.,$(objdir)),dep-$(call _relto,$(topobjdir),$(objdir)))) all) +module := $(subst /,_,$(if $(call _is_subdir,.,$(objdir)),$(firstword $(call _relto,.,$(objdir)) all),dep-$(firstword $(call _relto,$(topobjdir),$(objdir)) top))) ## Empty variables for use by the module subdirs = -- cgit v1.1-4-g5e80