author  Mike Sullivan <Mike.Sullivan@Oracle.COM> 
Thu, 16 Jun 2016 23:00:26 0700  
changeset 6236  9ecffda25374 
parent 5682  94c0ca64c022 
child 6869  63619dbf968d 
permissions  rwrr 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

1 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

2 
# CDDL HEADER START 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

3 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

4 
# The contents of this file are subject to the terms of the 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

5 
# Common Development and Distribution License (the "License"). 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

6 
# You may not use this file except in compliance with the License. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

7 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

8 
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

9 
# or http://www.opensolaris.org/os/licensing. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

10 
# See the License for the specific language governing permissions 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

11 
# and limitations under the License. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

12 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

13 
# When distributing Covered Code, include this CDDL HEADER in each 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

14 
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

15 
# If applicable, add the following below this CDDL HEADER, with the 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

16 
# fields enclosed by brackets "[]" replaced with your own identifying 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

17 
# information: Portions Copyright [yyyy] [name of copyright owner] 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

18 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

19 
# CDDL HEADER END 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

20 
# 
5682
94c0ca64c022
15558602 TCL_LD_SEARCH_FLAGS is wrongly defined in tclConfig.sh
Shawn WalkerSalas <shawn.walker@oracle.com>
parents:
4357
diff
changeset

21 

94c0ca64c022
15558602 TCL_LD_SEARCH_FLAGS is wrongly defined in tclConfig.sh
Shawn WalkerSalas <shawn.walker@oracle.com>
parents:
4357
diff
changeset

22 
# 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

23 
# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

24 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

25 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

26 
GPATCH = /usr/gnu/bin/patch 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

27 
PATCH_LEVEL ?= 1 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

28 
GPATCH_BACKUP = backup versioncontrol=numbered 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

29 
GPATCH_FLAGS = strip=$(PATCH_LEVEL) $(GPATCH_BACKUP) 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

30 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

31 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

32 
# Rules for patching source that is downloaded and unpacked or pulled from 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

33 
# a source repository. Patches should be named 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

34 
# patches/{patchfilename}.patch{version} where {patchfilename} is a 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

35 
# meaningful name for the patch contents and {version} corresponds to the 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

36 
# COMPONENT_NAME{version} of the source to be patched. Typically, version 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

37 
# would be something like "_1", "_2", ... After all {version} patches have 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

38 
# been applied, a final set of patches without a {version} suffix may be 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

39 
# applied. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

40 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

41 
# PATCH_DIR can be overridden to move patches to a different location 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

42 
# PATCH_PATTERN can be overridden to adjust the patch naming scheme that the 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

43 
# build recognizes. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

44 
# EXTRA_PATCHES{version} can be defined in the component Makefile to include 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

45 
# additional patches. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

46 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

47 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

48 
PATCH_PATTERN ?= *.patch* 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

49 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

50 
PATCH_DIR ?= patches 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

51 
# patches specific to parfait builds. 
4254
f1fca132ea31
21020731 parfaitonly patching seems broken
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4252
diff
changeset

52 
ifeq ($(strip $(PARFAIT_BUILD)),yes) 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

53 
PARFAIT_PATCH_DIR = parfait 
4254
f1fca132ea31
21020731 parfaitonly patching seems broken
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4252
diff
changeset

54 
endif 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

55 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

56 
PATCHES = $(shell find $(PATCH_DIR) $(PARFAIT_PATCH_DIR) type f \ 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

57 
name '$(PATCH_PATTERN)' 2>/dev/null  \ 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

58 
LC_COLLATE=C sort) 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

59 

4251
2bf7e2c1ca74
21029374 probably shouldn't overload TMP_SUFFIXES in userland fragments
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4196
diff
changeset

60 
PCH_SUFFIXES = $(patsubst .patch_%,%, $(filterout .patch,$(suffix $(PATCHES)))) 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

61 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

62 
define patchrule 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

63 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

64 
ifeq ($(1),_0) 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

65 
PATCH_PATTERN$(1) ?= %.patch 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

66 
PATCHES$(1) = $(filter %.patch,$(PATCHES)) 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

67 
else 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

68 
PATCH_PATTERN$(1) ?= %.patch$(1) 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

69 
PATCHES$(1) = $(filter %.patch$(1),$(PATCHES)) 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

70 
endif 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

71 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

72 
ifneq ($$(PATCHES$(1)),) 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

73 
PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched%) 
4254
f1fca132ea31
21020731 parfaitonly patching seems broken
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4252
diff
changeset

74 
ifeq ($(strip $(PARFAIT_BUILD)),yes) 
f1fca132ea31
21020731 parfaitonly patching seems broken
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4252
diff
changeset

75 
PATCH_STAMPS$(1) += $$(PATCHES$(1):$(PARFAIT_PATCH_DIR)/%=$$(SOURCE_DIR$(1))/.patched%) 
f1fca132ea31
21020731 parfaitonly patching seems broken
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4252
diff
changeset

76 
endif 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

77 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

78 
# We should unpack the source that we patch before we patch it. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

79 
$$(PATCH_STAMPS$(1):: $$(UNPACK_STAMP$(1)) unpack 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

80 

4357
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

81 
# Adding MAKEFILE_PREREQ because gmake seems to evaluate the need to patch 
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

82 
# before reunpacking if the Makefile changed. The various stamps are 
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

83 
# removed as part of the unpacking process, and it doesn't appear to 
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

84 
# reevaluate the need for patching. If we ever move the stamps to the build 
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

85 
# directory, we may not need the dependency any more. 
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

86 
$$(SOURCE_DIR$(1))/.patched%: $(PATCH_DIR)/% $(MAKEFILE_PREREQ) 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

87 
$(GPATCH) d $$(@D) $$(GPATCH_FLAGS) < $$< 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

88 
$(TOUCH) $$(@) 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

89 

4357
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

90 
$$(SOURCE_DIR$(1))/.patched%: $(PARFAIT_PATCH_DIR)/% $(MAKEFILE_PREREQ) 
4254
f1fca132ea31
21020731 parfaitonly patching seems broken
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4252
diff
changeset

91 
$(GPATCH) d $$(@D) $$(GPATCH_FLAGS) < $$< 
f1fca132ea31
21020731 parfaitonly patching seems broken
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4252
diff
changeset

92 
$(TOUCH) $$(@) 
f1fca132ea31
21020731 parfaitonly patching seems broken
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4252
diff
changeset

93 

4357
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

94 
$$(SOURCE_DIR$(1))/.patched: $$(PATCH_STAMPS$(1)) 
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

95 
$(TOUCH) $$(@) 
417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

96 

417c7cb1b3aa
21086455 gmake prep doesn't always apply patches
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4254
diff
changeset

97 
patch:: $$(SOURCE_DIR$(1))/.patched 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

98 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

99 
REQUIRED_PACKAGES += text/gnupatch 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

100 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

101 
endif 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

102 
endef 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

103 

d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

104 
# 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

105 
# Define the rules required to download any source archives and augment any 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

106 
# cleanup macros. 
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

107 
# 
4251
2bf7e2c1ca74
21029374 probably shouldn't overload TMP_SUFFIXES in userland fragments
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
4196
diff
changeset

108 
$(foreach suffix, $(PCH_SUFFIXES), $(eval $(call patchrule,_$(suffix)))) 
4196
d697072a92f5
19782029 userland should be able to build from SCM repositories
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

109 
$(eval $(call patchrule,)) # this must be last so we don't drop *.patch_%. 