make-rules/prep.mk
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Tue, 17 Apr 2012 10:40:54 -0700
changeset 774 d0cbca26a17c
parent 461 edabdd6aff23
child 789 5f074ca23733
permissions -rw-r--r--
7035978 parfait support for userland bits
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     1
#
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     2
# CDDL HEADER START
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     3
#
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     4
# The contents of this file are subject to the terms of the
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     5
# Common Development and Distribution License (the "License").
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     6
# You may not use this file except in compliance with the License.
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     7
#
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     8
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
     9
# or http://www.opensolaris.org/os/licensing.
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    10
# See the License for the specific language governing permissions
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    11
# and limitations under the License.
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    12
#
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    13
# When distributing Covered Code, include this CDDL HEADER in each
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    14
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    15
# If applicable, add the following below this CDDL HEADER, with the
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    16
# fields enclosed by brackets "[]" replaced with your own identifying
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    17
# information: Portions Copyright [yyyy] [name of copyright owner]
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    18
#
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    19
# CDDL HEADER END
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    20
#
774
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    21
# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    22
#
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    23
34
d20b10eba317 prepare for zone based component builds
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 18
diff changeset
    24
UNPACK =	$(WS_TOOLS)/userland-unpack
d20b10eba317 prepare for zone based component builds
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 18
diff changeset
    25
FETCH =		$(WS_TOOLS)/userland-fetch
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    26
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    27
ARCHIVES += $(COMPONENT_ARCHIVE)
59
7500d63edb42 7012375 userland build and proto areas should be outside of unpacked source dirs
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 42
diff changeset
    28
CLEAN_PATHS += $(SOURCE_DIR)
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    29
198
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    30
# In order to override PATCH_DIR and PATCH_PATTERN in component makefiles, they
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    31
# need to be conditionally set here.  This means that the override needs to
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    32
# happen prior to including prep.mk.  Otherwise other variables set here which
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    33
# are based on those will be expanded too early for the override to take effect.
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    34
# You also can't override PATCHES after including prep.mk; if you want to
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    35
# append filenames to PATCHES, you'll have to set $(EXTRA_PATCHES) prior to
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    36
# inclusion.
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    37
PATCH_DIR ?=	patches
774
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    38
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    39
# we may need patches only for use with parfait
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    40
ifeq   ($(strip $(PARFAIT_BUILD)),yes)
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    41
PARFAIT_PATCH_DIR =	parfait
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    42
endif
198
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    43
PATCH_PATTERN ?=	*.patch
774
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    44
PATCHES =	$(shell find $(PATCH_DIR) $(PARFAIT_PATCH_DIR) -type f -name '$(PATCH_PATTERN)' \
198
172fc01ce997 7016732 move vim from sfw to userland
Danek Duvall <danek.duvall@oracle.com>
parents: 142
diff changeset
    45
				2>/dev/null | sort) $(EXTRA_PATCHES)
115
c360825c3a3f 7022166 userland patches should move to subdirs
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 59
diff changeset
    46
STAMPS =	$(PATCHES:$(PATCH_DIR)/%=$(SOURCE_DIR)/.%ed)
774
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    47
ifeq   ($(strip $(PARFAIT_BUILD)),yes)
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    48
STAMPS +=	$(PATCHES:$(PARFAIT_PATCH_DIR)/%=$(SOURCE_DIR)/.%ed)
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    49
endif
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    50
115
c360825c3a3f 7022166 userland patches should move to subdirs
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 59
diff changeset
    51
$(SOURCE_DIR)/.%ed:	$(PATCH_DIR)/%
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    52
	$(GPATCH) -d $(@D) $(GPATCH_FLAGS) < $<
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    53
	$(TOUCH) [email protected]
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    54
774
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    55
ifeq   ($(strip $(PARFAIT_BUILD)),yes)
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    56
$(SOURCE_DIR)/.%ed:	$(PARFAIT_PATCH_DIR)/%
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    57
	$(GPATCH) -d $(@D) $(GPATCH_FLAGS) < $<
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    58
	$(TOUCH) [email protected]
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    59
endif
d0cbca26a17c 7035978 parfait support for userland bits
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 461
diff changeset
    60
142
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    61
# template for download rules. add new rules with $(call download-rule, suffix)
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    62
define download-rule
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    63
ARCHIVES += $$(COMPONENT_ARCHIVE$(1))
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    64
CLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1))
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    65
$$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)):	Makefile
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    66
	$$(FETCH) --file [email protected] \
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    67
		$$(COMPONENT_ARCHIVE_URL$(1):%=--url %) \
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    68
		$$(COMPONENT_ARCHIVE_HASH$(1):%=--hash %)
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    69
	$$(TOUCH) [email protected]
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    70
endef
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    71
142
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    72
# Generate the download rules from the above template
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    73
NUM_ARCHIVES =	1 2 3 4 5 6 7
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    74
$(eval $(call download-rule,))
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    75
$(foreach suffix,$(NUM_ARCHIVES),$(eval $(call download-rule,_$(suffix))))
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    76
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    77
$(SOURCE_DIR)/.unpacked:	download Makefile $(PATCHES)
59
7500d63edb42 7012375 userland build and proto areas should be outside of unpacked source dirs
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 42
diff changeset
    78
	$(RM) -r $(SOURCE_DIR)
42
566ce4d2ff99 fix using/downloading shared archives
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 38
diff changeset
    79
	$(UNPACK) $(UNPACK_ARGS) $(USERLAND_ARCHIVES)$(COMPONENT_ARCHIVE)
461
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents: 198
diff changeset
    80
	$(COMPONENT_POST_UNPACK_ACTION)
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    81
	$(TOUCH) [email protected]
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    82
59
7500d63edb42 7012375 userland build and proto areas should be outside of unpacked source dirs
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 42
diff changeset
    83
$(SOURCE_DIR)/.patched:	$(SOURCE_DIR)/.unpacked $(STAMPS)
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    84
	$(TOUCH) [email protected]
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    85
59
7500d63edb42 7012375 userland build and proto areas should be outside of unpacked source dirs
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 42
diff changeset
    86
$(SOURCE_DIR)/.prep:	$(SOURCE_DIR)/.patched
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    87
	$(COMPONENT_PREP_ACTION)
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    88
	$(TOUCH) [email protected]
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    89
59
7500d63edb42 7012375 userland build and proto areas should be outside of unpacked source dirs
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 42
diff changeset
    90
prep::	$(SOURCE_DIR)/.prep
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    91
142
6f1cb90a0ef3 7026996 move tomcat to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents: 115
diff changeset
    92
download::	$(ARCHIVES:%=$(USERLAND_ARCHIVES)%)
9
97fb557d9979 lcms download link has changed
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents: 2
diff changeset
    93
2
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    94
clean::
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    95
	$(RM) -r $(CLEAN_PATHS)
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    96
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    97
clobber::	clean
125cd5d2cd9e include gmake example
Norm Jacobs <Norm.Jacobs@Sun.COM>
parents:
diff changeset
    98
	$(RM) -r $(CLOBBER_PATHS)