From 49cfbe9870cf5e5fd75386869b09c5ab463c39ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 11 Mar 2020 17:47:54 +0100 Subject: [PATCH] build: Introduce rules-source macro. --- build/makefile_base.mak | 9 ++++--- make/rules-source.mk | 56 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 make/rules-source.mk diff --git a/build/makefile_base.mak b/build/makefile_base.mak index 271dfd06..a0cc30a4 100644 --- a/build/makefile_base.mak +++ b/build/makefile_base.mak @@ -36,6 +36,7 @@ ifeq ($(SRCDIR),) endif include $(SRC)/make/utility.mk +include $(SRC)/make/rules-source.mk # If CC is coming from make's defaults or nowhere, use our own default. Otherwise respect environment. ifeq ($(ENABLE_CCACHE),1) @@ -489,12 +490,12 @@ redist: dist | $(filter-out dist deploy install redist,$(MAKECMDGOALS)) .PHONY: module32 module64 module -module32: SHELL = $(CONTAINER_SHELL) -module32: +module32: private SHELL := $(CONTAINER_SHELL) +module32: all-source +$(MAKE) -C $(WINE_OBJ32)/dlls/$(module) -module64: SHELL = $(CONTAINER_SHELL) -module64: +module64: private SHELL := $(CONTAINER_SHELL) +module64: all-source +$(MAKE) -C $(WINE_OBJ64)/dlls/$(module) module: module32 module64 diff --git a/make/rules-source.mk b/make/rules-source.mk new file mode 100644 index 00000000..e84f8855 --- /dev/null +++ b/make/rules-source.mk @@ -0,0 +1,56 @@ +# parameters: +# $(1): lowercase package name +# $(2): uppercase package name +# $(3): source directory +# +# inputs: +# $(PKG): variable, package source folder +# +# outputs: +# $($(2)_SRC): variable, absolute rsynced source folder +# $(1)-rebuild: target, call it to force package rebuild +# $(1)-source: target, tracking package source changes +# $(1)-clean: target, clean package and force rebuild +# +define create-rules-source +$(2)_SRC = $$(OBJ)/src-$(1) + +ifeq ($(CONTAINER),) +$(1)-rebuild: +.PHONY: $(1)-rebuild + +$$(OBJ)/.$(1)-source: SHELL := $$(SHELL) +$$(OBJ)/.$(1)-source: $$(if $$(NO_MAKEFILE_DEPENDENCY),,$$(MAKEFILE_LIST)) +$$(OBJ)/.$(1)-source: $$(shell echo -n 'syncing $(1)... ' >&2 && \ + rsync --dry-run --filter=:C --exclude '*~' --exclude .git $$($(2)_SOURCE_ARGS) --info=name -Oarx --delete "$$(abspath $(3))/" "$$($(2)_SRC)" | \ + grep -v -e ^$$$$ | grep -q ^ && echo $(1)-rebuild && \ + echo 'done, dirty' >&2 || echo 'done' >&2) + rsync --filter=:C --exclude '*~' --exclude .git $$($(2)_SOURCE_ARGS) --info=name -Oarx --delete "$$(abspath $(3))/" "$$($(2)_SRC)" + touch $$@ + +$$(OBJ)/.$(1)-post-source: $$(OBJ)/.$(1)-source +container-build: $$(OBJ)/.$(1)-post-source + +$(1)-source: $$(OBJ)/.$(1)-post-source +.PHONY: $(1)-source + +all-source: $(1)-source +.PHONY: all-source + +all: all-source +.PHONY: all + +$(1)-clean:: +$(1)-distclean:: + rm -rf $$($(2)_SRC) + +clean: $(1)-clean +distclean: $(1)-distclean +.PHONY: clean distclean +endif +endef + +rules-source = $(call create-rules-source,$(1),$(call toupper,$(1)),$(2)) + +$(OBJ)/.%-post-source: + touch $@