2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
4070N/A
4070N/A#
3996N/A# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
2N/A#
2N/A
830N/A# One must do all unpack and patch in sequence.
830N/A.NOTPARALLEL: (SOURCE_DIR)/.prep
830N/A
34N/AUNPACK = $(WS_TOOLS)/userland-unpack
34N/AFETCH = $(WS_TOOLS)/userland-fetch
2N/A
2N/AARCHIVES += $(COMPONENT_ARCHIVE)
59N/ACLEAN_PATHS += $(SOURCE_DIR)
2N/A
198N/A# In order to override PATCH_DIR and PATCH_PATTERN in component makefiles, they
198N/A# need to be conditionally set here. This means that the override needs to
198N/A# happen prior to including prep.mk. Otherwise other variables set here which
4070N/A# are based on those will be expanded too early for the override to take
830N/A# effect.
198N/A# You also can't override PATCHES after including prep.mk; if you want to
198N/A# append filenames to PATCHES, you'll have to set $(EXTRA_PATCHES) prior to
198N/A# inclusion.
198N/APATCH_DIR ?= patches
814N/A
814N/A# we may need patches only for use with parfait
814N/Aifeq ($(strip $(PARFAIT_BUILD)),yes)
814N/APARFAIT_PATCH_DIR = parfait
814N/Aendif
198N/APATCH_PATTERN ?= *.patch
814N/APATCHES = $(shell find $(PATCH_DIR) $(PARFAIT_PATCH_DIR) -type f -name '$(PATCH_PATTERN)' \
198N/A 2>/dev/null | sort) $(EXTRA_PATCHES)
2N/A
830N/A# Rule to perform the patching.
115N/A$(SOURCE_DIR)/.%ed: $(PATCH_DIR)/%
2N/A $(GPATCH) -d $(@D) $(GPATCH_FLAGS) < $<
2N/A $(TOUCH) $@
2N/A
830N/A# Parfait patches rule: TODO - Integrate with other patch rules
814N/Aifeq ($(strip $(PARFAIT_BUILD)),yes)
814N/A$(SOURCE_DIR)/.%ed: $(PARFAIT_PATCH_DIR)/%
814N/A $(GPATCH) -d $(@D) $(GPATCH_FLAGS) < $<
814N/A $(TOUCH) $@
814N/Aendif
814N/A
830N/A# Template for download rules.
142N/Adefine download-rule
142N/AARCHIVES += $$(COMPONENT_ARCHIVE$(1))
142N/ACLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1))
3996N/A$$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)): $(MAKEFILE_PREREQ)
142N/A $$(FETCH) --file $$@ \
142N/A $$(COMPONENT_ARCHIVE_URL$(1):%=--url %) \
142N/A $$(COMPONENT_ARCHIVE_HASH$(1):%=--hash %)
142N/A $$(TOUCH) $$@
142N/Aendef
2N/A
4070N/A# Template for patching rules, note that patching is actually done by the
830N/A# %.ed pattern rule above.
830N/A# To maintain backwards compatibility, the flag PATCH_EACH_ARCHIVE must
830N/A# be non-empty in order to activate individual archive patching.
830N/Adefine patch-rule
830N/Aifneq ($(strip $$(PATCH_EACH_ARCHIVE)),)
830N/A# Prepend the patch directory to each archive patch.
830N/A#$$(COMPONENT_PATCHES$(1):%=$$(PATCH_DIR)/%)
830N/A#PATCHDIR_PATCHES$(1) += $$(COMPONENT_PATCHES)
830N/APATCHDIR_PATCHES$(1) += $$(foreach patch,$$(COMPONENT_PATCHES$(1)), \
830N/A $$(PATCH_DIR)/$$(patch))
830N/Aelse
830N/APATCHDIR_PATCHES = $$(PATCHES)
830N/Aendif
830N/A# Substitute the patch dir for the source dir on the patches
830N/ASTAMPS$(1)+= $$(PATCHDIR_PATCHES$(1):$$(PATCH_DIR)/%=$$(SOURCE_DIR)/.%ed)
830N/Aifeq ($(strip $(PARFAIT_BUILD)),yes)
830N/ASTAMPS$(1)+= $$(PATCHDIR_PATCHES$(1):$$(PARFAIT_PATCH_DIR)/%=$$(SOURCE_DIR)/.%ed)
830N/Aendif
830N/A$$(SOURCE_DIR)/.patched$(1): $$(SOURCE_DIR)/.unpacked$(1) $$(STAMPS$(1))
830N/A $$(TOUCH) $$@
830N/Aendef
142N/A
830N/A# Template for unpacking rules.
830N/Adefine unpack-rule
4070N/A$$(SOURCE_DIR)/.unpacked$(1): download $(MAKEFILE_PREREQ) $$(PATCHDIR_PATCHES$(1))
830N/A $$(RM) -r $$(COMPONENT_SRC$(1))
830N/A $$(UNPACK) $$(UNPACK_ARGS$(1)) \
830N/A $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1))
830N/A $$(COMPONENT_POST_UNPACK_ACTION$(1))
830N/A $$(TOUCH) $$@
830N/Aendef
2N/A
830N/A# If an archive is defined, create a download, unpack and patch rule.
830N/Adefine archive-rule
830N/Aifneq ($(strip $$(COMPONENT_ARCHIVE$(1))),)
830N/A$(eval $(call download-rule,$(1)))
830N/A$(eval $(call unpack-rule,$(1)))
830N/A$(eval $(call patch-rule,$(1)))
830N/AARCHIVE_STAMPS +=$$(SOURCE_DIR)/.patched$(1)
830N/Aendif
830N/Aendef
2N/A
830N/A# Calculate the number of defined archives.
830N/A# Always generate at least the basic prep rules.
830N/A# Work out if there are any other archives to be downloaded and patched.
4070N/ANUM_EXTRA_ARCHIVES ?= 1 2 3 4 5 6 7 8 9
830N/A$(eval $(call archive-rule,))
830N/Aifneq ($(strip $(PATCH_EACH_ARCHIVE)),)
830N/A$(foreach suffix,$(NUM_EXTRA_ARCHIVES), \
830N/A $(eval $(call archive-rule,_$(suffix))))
830N/Aelse
830N/A# Backwards compatibility - only download, do not unpack or patch automatically
830N/A$(foreach suffix,$(NUM_EXTRA_ARCHIVES), \
830N/A $(eval $(call download-rule,_$(suffix))))
830N/Aendif
830N/A
830N/A$(SOURCE_DIR)/.prep: $(ARCHIVE_STAMPS)
2N/A $(COMPONENT_PREP_ACTION)
2N/A $(TOUCH) $@
2N/A
59N/Aprep:: $(SOURCE_DIR)/.prep
2N/A
142N/Adownload:: $(ARCHIVES:%=$(USERLAND_ARCHIVES)%)
9N/A
2N/Aclean::
2N/A $(RM) -r $(CLEAN_PATHS)
2N/A
2N/Aclobber:: clean
2N/A $(RM) -r $(CLOBBER_PATHS)
3996N/A
3996N/AREQUIRED_PACKAGES += archiver/gnu-tar
3996N/AREQUIRED_PACKAGES += compress/bzip2
3996N/AREQUIRED_PACKAGES += compress/gzip
3996N/AREQUIRED_PACKAGES += compress/p7zip
3996N/AREQUIRED_PACKAGES += compress/unzip
3996N/AREQUIRED_PACKAGES += compress/xz
3996N/AREQUIRED_PACKAGES += developer/java/jdk
3996N/AREQUIRED_PACKAGES += runtime/ruby
3996N/AREQUIRED_PACKAGES += text/gnu-patch