Craig Mohrman
2011-08-06 d248e608916d6a0b5dad6d3c2ac2d86e2e46c10e
commit | author | age
9c75c0 1 #
NJ 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 #
74300c 21 # Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
9c75c0 22 #
NJ 23
79b849 24 UNPACK =    $(WS_TOOLS)/userland-unpack
NJ 25 FETCH =        $(WS_TOOLS)/userland-fetch
9c75c0 26
NJ 27 ARCHIVES += $(COMPONENT_ARCHIVE)
74300c 28 CLEAN_PATHS += $(SOURCE_DIR)
9c75c0 29
58da5e 30 # In order to override PATCH_DIR and PATCH_PATTERN in component makefiles, they
DD 31 # need to be conditionally set here.  This means that the override needs to
32 # happen prior to including prep.mk.  Otherwise other variables set here which
33 # are based on those will be expanded too early for the override to take effect.
34 # You also can't override PATCHES after including prep.mk; if you want to
35 # append filenames to PATCHES, you'll have to set $(EXTRA_PATCHES) prior to
36 # inclusion.
37 PATCH_DIR ?=    patches
38 PATCH_PATTERN ?=    *.patch
2c0111 39 PATCHES =    $(shell find $(PATCH_DIR) -type f -name '$(PATCH_PATTERN)' \
58da5e 40                 2>/dev/null | sort) $(EXTRA_PATCHES)
2c0111 41 STAMPS =    $(PATCHES:$(PATCH_DIR)/%=$(SOURCE_DIR)/.%ed)
9c75c0 42
2c0111 43 $(SOURCE_DIR)/.%ed:    $(PATCH_DIR)/%
9c75c0 44     $(GPATCH) -d $(@D) $(GPATCH_FLAGS) < $<
NJ 45     $(TOUCH) $@
46
2515dc 47 # template for download rules. add new rules with $(call download-rule, suffix)
PS 48 define download-rule
49 ARCHIVES += $$(COMPONENT_ARCHIVE$(1))
50 CLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1))
51 $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)):    Makefile
52     $$(FETCH) --file $$@ \
53         $$(COMPONENT_ARCHIVE_URL$(1):%=--url %) \
54         $$(COMPONENT_ARCHIVE_HASH$(1):%=--hash %)
55     $$(TOUCH) $$@
56 endef
9c75c0 57
2515dc 58 # Generate the download rules from the above template
PS 59 NUM_ARCHIVES =    1 2 3 4 5 6 7
60 $(eval $(call download-rule,))
61 $(foreach suffix,$(NUM_ARCHIVES),$(eval $(call download-rule,_$(suffix))))
62
63 $(SOURCE_DIR)/.unpacked:    download Makefile $(PATCHES)
74300c 64     $(RM) -r $(SOURCE_DIR)
6ddf48 65     $(UNPACK) $(UNPACK_ARGS) $(USERLAND_ARCHIVES)$(COMPONENT_ARCHIVE)
d248e6 66     $(COMPONENT_POST_UNPACK_ACTION)
9c75c0 67     $(TOUCH) $@
NJ 68
74300c 69 $(SOURCE_DIR)/.patched:    $(SOURCE_DIR)/.unpacked $(STAMPS)
9c75c0 70     $(TOUCH) $@
NJ 71
74300c 72 $(SOURCE_DIR)/.prep:    $(SOURCE_DIR)/.patched
9c75c0 73     $(COMPONENT_PREP_ACTION)
NJ 74     $(TOUCH) $@
75
74300c 76 prep::    $(SOURCE_DIR)/.prep
9c75c0 77
2515dc 78 download::    $(ARCHIVES:%=$(USERLAND_ARCHIVES)%)
ef9858 79
9c75c0 80 clean::
NJ 81     $(RM) -r $(CLEAN_PATHS)
82
83 clobber::    clean
84     $(RM) -r $(CLOBBER_PATHS)