make-rules/prep-patch.mk
changeset 6911 7b878dfe6f0d
parent 6869 63619dbf968d
child 6991 cddc7c0c4e9d
equal deleted inserted replaced
6910:93182fb9923a 6911:7b878dfe6f0d
    18 #
    18 #
    19 # CDDL HEADER END
    19 # CDDL HEADER END
    20 #
    20 #
    21 
    21 
    22 #
    22 #
    23 # Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
    23 # Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
    24 #
    24 #
    25 
    25 
    26 GPATCH =	/usr/gnu/bin/patch
    26 GPATCH =	/usr/gnu/bin/patch
    27 PATCH_LEVEL ?=	1
    27 PATCH_LEVEL ?=	1
    28 GPATCH_BACKUP =	--backup --version-control=numbered
    28 GPATCH_BACKUP =	--backup --version-control=numbered
    61 # match the _X extensions to the COMPONENT_* make variables.  Find these
    61 # match the _X extensions to the COMPONENT_* make variables.  Find these
    62 # extensions, using $(sort) to uniq them to prevent multiple rules from
    62 # extensions, using $(sort) to uniq them to prevent multiple rules from
    63 # getting generated.
    63 # getting generated.
    64 PCH_SUFFIXES = $(sort $(patsubst .patch_%,%, $(filter-out .patch,$(suffix $(PATCHES)))))
    64 PCH_SUFFIXES = $(sort $(patsubst .patch_%,%, $(filter-out .patch,$(suffix $(PATCHES)))))
    65 
    65 
    66 define patch-rule
    66 define patch-variables
    67 
    67 
    68 ifeq ($(1),_0)
    68 ifeq ($(1),_0)
    69 PATCH_PATTERN$(1) ?=	%.patch
    69 PATCH_PATTERN$(1) ?=	%.patch
    70 PATCHES$(1) = $(filter %.patch,$(PATCHES))
    70 PATCHES$(1) = $(filter %.patch,$(PATCHES))
    71 else
    71 else
    76 ifneq ($$(PATCHES$(1)),)
    76 ifneq ($$(PATCHES$(1)),)
    77 PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%)
    77 PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%)
    78 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
    78 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
    79 PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PARFAIT_PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%)
    79 PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PARFAIT_PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%)
    80 endif 
    80 endif 
       
    81 endif
       
    82 endef
    81 
    83 
       
    84 define patch-rules
       
    85 ifneq ($$(PATCHES$(1)),)
    82 # We should unpack the source that we patch before we patch it.
    86 # We should unpack the source that we patch before we patch it.
    83 $$(PATCH_STAMPS$(1)::	$$(UNPACK_STAMP$(1)) unpack
    87 $$(PATCH_STAMPS$(1)::	$$(UNPACK_STAMP$(1)) unpack
    84 
    88 
    85 # Adding MAKEFILE_PREREQ because gmake seems to evaluate the need to patch
    89 # Adding MAKEFILE_PREREQ because gmake seems to evaluate the need to patch
    86 # before re-unpacking if the Makefile changed.  The various stamps are
    90 # before re-unpacking if the Makefile changed.  The various stamps are
   103 REQUIRED_PACKAGES += text/gnu-patch
   107 REQUIRED_PACKAGES += text/gnu-patch
   104 
   108 
   105 endif
   109 endif
   106 endef
   110 endef
   107 
   111 
   108 #
   112 # Evaluate the variable assignments immediately.
   109 # Define the rules required to download any source archives and augment any
   113 $(foreach suffix, $(PCH_SUFFIXES), $(eval $(call patch-variables,_$(suffix))))
   110 # cleanup macros.
   114 $(eval $(call patch-variables,))	# this must be last so we don't drop *.patch_%.
   111 #
   115 
   112 $(foreach suffix, $(PCH_SUFFIXES), $(eval $(call patch-rule,_$(suffix))))
   116 # Put the rule evaluations in a variable for deferred evaluation.
   113 $(eval $(call patch-rule,))	# this must be last so we don't drop *.patch_%.
   117 define eval-patch-rules
       
   118 $(foreach suffix, $(PCH_SUFFIXES), $(eval $(call patch-rules,_$(suffix))))
       
   119 $(eval $(call patch-rules,))	# this must be last so we don't drop *.patch_%.
       
   120 endef