| | |
| | | # PATCH_DIR can be overridden to move patches to a different location |
| | | # PATCH_PATTERN can be overridden to adjust the patch naming scheme that the |
| | | # build recognizes. |
| | | # EXTRA_PATCHES{version} can be defined in the component Makefile to include |
| | | # ADDITIONAL_PATCHES can be defined in the component Makefile to include |
| | | # additional patches. |
| | | # |
| | | |
| | | PATCH_PATTERN ?= *.patch* |
| | | |
| | | PATCH_DIR ?= patches |
| | | # patches specific to parfait builds. |
| | | ifeq ($(strip $(PARFAIT_BUILD)),yes) |
| | | PARFAIT_PATCH_DIR = parfait |
| | | endif |
| | | |
| | | PATCHES = $(shell find $(PATCH_DIR) $(PARFAIT_PATCH_DIR) -type f \ |
| | | PATCHES = $(shell find $(PATCH_DIR) -type f \ |
| | | -name '$(PATCH_PATTERN)' 2>/dev/null | \ |
| | | LC_COLLATE=C sort) |
| | | |
| | |
| | | PATCHES$(1) = $(filter %.patch$(1),$(PATCHES)) |
| | | endif |
| | | |
| | | ifneq ($$(PATCHES$(1)),) |
| | | PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%) |
| | | ifeq ($(strip $(PARFAIT_BUILD)),yes) |
| | | PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PARFAIT_PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%) |
| | | ifneq ($(strip $(ADDITIONAL_PATCHES$(1))),) |
| | | PATCHES$(1) += $(ADDITIONAL_PATCHES$(1)) |
| | | endif |
| | | |
| | | ifneq ($$(PATCHES$(1)),) |
| | | PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%) |
| | | |
| | | # We should unpack the source that we patch before we patch it. |
| | | $$(PATCH_STAMPS$(1):: $$(UNPACK_STAMP$(1)) unpack |
| | | $$(PATCH_STAMPS$(1)): unpack |
| | | |
| | | # Adding MAKEFILE_PREREQ because gmake seems to evaluate the need to patch |
| | | # before re-unpacking if the Makefile changed. The various stamps are |
| | |
| | | $(GPATCH) -d $$(@D) $$(GPATCH_FLAGS) < $$< |
| | | $(TOUCH) $$(@) |
| | | |
| | | $$(SOURCE_DIR$(1))/.patched-%: $(PARFAIT_PATCH_DIR)/% $(MAKEFILE_PREREQ) |
| | | $$(SOURCE_DIR$(1))/.patched-%: $(MAKEFILE_PREREQ) |
| | | $(GPATCH) -d $$(@D) $$(GPATCH_FLAGS) < $$< |
| | | $(TOUCH) $$(@) |
| | | |
| | |
| | | |
| | | patch:: $$(SOURCE_DIR$(1))/.patched |
| | | |
| | | REQUIRED_PACKAGES += text/gnu-patch |
| | | USERLAND_REQUIRED_PACKAGES += text/gnu-patch |
| | | |
| | | endif |
| | | endef |
| | |
| | | # |
| | | $(foreach suffix, $(PCH_SUFFIXES), $(eval $(call patch-rule,_$(suffix)))) |
| | | $(eval $(call patch-rule,)) # this must be last so we don't drop *.patch_%. |
| | | |
| | | # Helper target for patches refresh |
| | | refresh-patches: $(QUILT) patch |
| | | # Unapply all patches |
| | | for p in $(PATCHES) ; do \ |
| | | echo $$p ; \ |
| | | done | $(TAC) | while read p ; do \ |
| | | $(GPATCH) -d $(SOURCE_DIR) --strip=$(PATCH_LEVEL) --reverse < $$p ; \ |
| | | done |
| | | # Make sure the series file does not exist |
| | | $(RM) $(COMPONENT_DIR)/$(PATCH_DIR)/series |
| | | # Apply and refresh patches, then unapply them |
| | | cd $(SOURCE_DIR) ; for p in $(PATCHES) ; do \ |
| | | QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) import --quiltrc /dev/null "../$$p" ; \ |
| | | QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) push --quiltrc /dev/null -q ; \ |
| | | QUILT_PATCHES=../$(PATCH_DIR) $(QUILT) refresh --quiltrc /dev/null -p 1 --no-timestamps --no-index ; \ |
| | | done ; \ |
| | | [ ! -e $(COMPONENT_DIR)/$(PATCH_DIR)/series ] || QUILT_PATCHES=../$(PATCH_DIR) quilt pop --quiltrc /dev/null -a -q |
| | | # cleanup |
| | | $(RM) -r $(SOURCE_DIR)/.pc |
| | | $(RM) $(COMPONENT_DIR)/$(PATCH_DIR)/series |
| | | # Apply and refresh patches again to get the desired patch format |
| | | for p in $(PATCHES) ; do \ |
| | | QUILT_PATCHES=$(PATCH_DIR) $(QUILT) import --quiltrc /dev/null -p 0 "$$p" ; \ |
| | | QUILT_PATCHES=$(PATCH_DIR) $(QUILT) push --quiltrc /dev/null -q ; \ |
| | | QUILT_PATCHES=$(PATCH_DIR) $(QUILT) refresh --quiltrc /dev/null -p 0 --no-timestamps --no-index ; \ |
| | | done |
| | | # final cleanup |
| | | $(RM) -r $(COMPONENT_DIR)/.pc |
| | | $(RM) $(COMPONENT_DIR)/$(PATCH_DIR)/series |