commit | author | age
|
e28f4f
|
1 |
# |
AP |
2 |
# CDDL HEADER START |
|
3 |
# |
|
4 |
# The contents of this file are subject to the terms of the |
|
5 |
# Common Development and Distribution License (the "License"). |
|
6 |
# You may not use this file except in compliance with the License. |
|
7 |
# |
|
8 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
# or http://www.opensolaris.org/os/licensing. |
|
10 |
# See the License for the specific language governing permissions |
|
11 |
# and limitations under the License. |
|
12 |
# |
|
13 |
# When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
# If applicable, add the following below this CDDL HEADER, with the |
|
16 |
# fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
# |
|
19 |
# CDDL HEADER END |
|
20 |
# |
|
21 |
# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. |
|
22 |
# |
|
23 |
|
|
24 |
GPATCH = /usr/gnu/bin/patch |
|
25 |
PATCH_LEVEL ?= 1 |
|
26 |
GPATCH_BACKUP = --backup --version-control=numbered |
|
27 |
GPATCH_FLAGS = --strip=$(PATCH_LEVEL) $(GPATCH_BACKUP) |
|
28 |
|
|
29 |
# |
|
30 |
# Rules for patching source that is downloaded and unpacked or pulled from |
|
31 |
# a source repository. Patches should be named |
|
32 |
# patches/{patch-file-name}.patch{version} where {patch-file-name} is a |
|
33 |
# meaningful name for the patch contents and {version} corresponds to the |
|
34 |
# COMPONENT_NAME{version} of the source to be patched. Typically, version |
|
35 |
# would be something like "_1", "_2", ... After all {version} patches have |
|
36 |
# been applied, a final set of patches without a {version} suffix may be |
|
37 |
# applied. |
|
38 |
# |
|
39 |
# PATCH_DIR can be overridden to move patches to a different location |
|
40 |
# PATCH_PATTERN can be overridden to adjust the patch naming scheme that the |
|
41 |
# build recognizes. |
e1ec34
|
42 |
# ADDITIONAL_PATCHES can be defined in the component Makefile to include |
e28f4f
|
43 |
# additional patches. |
AP |
44 |
# |
|
45 |
|
|
46 |
PATCH_PATTERN ?= *.patch* |
|
47 |
|
|
48 |
PATCH_DIR ?= patches |
|
49 |
# patches specific to parfait builds. |
|
50 |
ifeq ($(strip $(PARFAIT_BUILD)),yes) |
|
51 |
PARFAIT_PATCH_DIR = parfait |
|
52 |
endif |
|
53 |
|
|
54 |
PATCHES = $(shell find $(PATCH_DIR) $(PARFAIT_PATCH_DIR) -type f \ |
|
55 |
-name '$(PATCH_PATTERN)' 2>/dev/null | \ |
|
56 |
LC_COLLATE=C sort) |
|
57 |
|
|
58 |
PCH_SUFFIXES = $(patsubst .patch_%,%, $(filter-out .patch,$(suffix $(PATCHES)))) |
|
59 |
|
|
60 |
define patch-rule |
|
61 |
|
|
62 |
ifeq ($(1),_0) |
|
63 |
PATCH_PATTERN$(1) ?= %.patch |
|
64 |
PATCHES$(1) = $(filter %.patch,$(PATCHES)) |
|
65 |
else |
|
66 |
PATCH_PATTERN$(1) ?= %.patch$(1) |
|
67 |
PATCHES$(1) = $(filter %.patch$(1),$(PATCHES)) |
|
68 |
endif |
|
69 |
|
e1ec34
|
70 |
ifneq ($(strip $(ADDITIONAL_PATCHES$(1))),) |
K |
71 |
PATCHES$(1) += $(ADDITIONAL_PATCHES$(1)) |
|
72 |
endif |
|
73 |
|
e28f4f
|
74 |
ifneq ($$(PATCHES$(1)),) |
AP |
75 |
PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%) |
|
76 |
ifeq ($(strip $(PARFAIT_BUILD)),yes) |
|
77 |
PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PARFAIT_PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched-%) |
|
78 |
endif |
|
79 |
|
|
80 |
# We should unpack the source that we patch before we patch it. |
e20483
|
81 |
$$(PATCH_STAMPS$(1)): unpack |
e28f4f
|
82 |
|
AP |
83 |
# Adding MAKEFILE_PREREQ because gmake seems to evaluate the need to patch |
|
84 |
# before re-unpacking if the Makefile changed. The various stamps are |
|
85 |
# removed as part of the unpacking process, and it doesn't appear to |
|
86 |
# re-evaluate the need for patching. If we ever move the stamps to the build |
|
87 |
# directory, we may not need the dependency any more. |
|
88 |
$$(SOURCE_DIR$(1))/.patched-%: $(PATCH_DIR)/% $(MAKEFILE_PREREQ) |
|
89 |
$(GPATCH) -d $$(@D) $$(GPATCH_FLAGS) < $$< |
|
90 |
$(TOUCH) $$(@) |
|
91 |
|
|
92 |
$$(SOURCE_DIR$(1))/.patched-%: $(PARFAIT_PATCH_DIR)/% $(MAKEFILE_PREREQ) |
|
93 |
$(GPATCH) -d $$(@D) $$(GPATCH_FLAGS) < $$< |
|
94 |
$(TOUCH) $$(@) |
|
95 |
|
|
96 |
$$(SOURCE_DIR$(1))/.patched: $$(PATCH_STAMPS$(1)) |
|
97 |
$(TOUCH) $$(@) |
|
98 |
|
|
99 |
patch:: $$(SOURCE_DIR$(1))/.patched |
|
100 |
|
1349f8
|
101 |
USERLAND_REQUIRED_PACKAGES += text/gnu-patch |
e28f4f
|
102 |
|
AP |
103 |
endif |
|
104 |
endef |
|
105 |
|
|
106 |
# |
|
107 |
# Define the rules required to download any source archives and augment any |
|
108 |
# cleanup macros. |
|
109 |
# |
|
110 |
$(foreach suffix, $(PCH_SUFFIXES), $(eval $(call patch-rule,_$(suffix)))) |
|
111 |
$(eval $(call patch-rule,)) # this must be last so we don't drop *.patch_%. |