#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
# The golang build process just doesn't work with Parfait.
COMPONENT_MAJOR_VERSION= $(shell echo $(COMPONENT_VERSION) | $(GSED) -e 's/\([0-9]\+\.[0-9]\+\).*/\1/')
# Go has a number of supplementary tools and packages that are located in
# separate archives or source repositories. Because Go currently forces a
# recompile of all packages whenever the compiler changes, building and
# delivering them within the same build component build process is the best
# option for now.
# The long-term plan for packaging Go is roughly as follows:
#
# - when SPARC support is integrated into Go upstream, build upstream version
# using system Go for x86, then build Go for SPARC using upstream version
# just built for x86 (cross-compilation), package both at the same time
# - after SPARC version has been available for at least a few builds in the
# WOS, switch to building Go with system version for x86 and SPARC
#
# Supplementary packages; these are delivered as source only for now as the
# paths to the compiled packages are written directly into the binaries and
# there's no way (currently) to fix that during the build process.
COMPONENT_LABEL_$(1)=
# Desired "revision" of Go's "community" libraries; these are arbitrary
# revisions chosen from the last commit to the respective repository at the
# same time that this component was updated as there is no formal release
# process for these packages. Whenever Go is updated, these should be as well.
# Resulting hash of related git commit once archived.
# Go package imports for lint are found in github directory.
# Go's "not well-formed" elf objects confuse elfsign, which then causes
# problems for RE. For now, we workaround this by adding the
# 'com.oracle.elfsign=false' tag to every elf object.
# We're x86-only for now.
else
# Bake in where Go package will be installed.
# Enable easier stack unwinding for debugging.
COMPONENT_BUILD_ENV += \
# Install root for supplementary packages.
# For convenience during installation of supplementary packages.
# Simplify source copying for install by eliding patch detritus.
# Enable local transforms.
PKG_OPTIONS += -I $(COMPONENT_DIR)
# Avoid some of the default transforms:
# - facet.devel serves no useful purpose for a development package
# - facet.doc wrongly assumes all things in a doc directory are documentation;
# in Go's case, some are binaries
#
# This requires completely redefining PUBLISH_TRANSFORMS for now.
cd $(PROTO_DIR); \
$(GSED) -e 's/^..\(.*\):.*$$/<transform file path=\1$$ -> \\\
default com.oracle.elfsign false>/' > $@
# Building go from the source repository version requires that we set an
# effective version and add some sort of unique identifier (in the case of
# pre-release versions), so we use 'devel' + archive hash + date similar to how
# Go internally determines one normally from git revision info. Uncomment the
# block below when building from the upstream source repository:
#COMPONENT_POST_UNPACK_ACTION= \
# $(MV) go-master $(COMPONENT_SRC) && \
# $(TOUCH) $(COMPONENT_SRC)/VERSION && \
# echo "devel $(shell digest -a md5 $(COMPONENT_ARCHIVE)) \
# $(shell date -u +'%a %b %e %T %Z %Y')" > \
# $(COMPONENT_SRC)/VERSION
# We have to fiddle with the package archives to get them into the same source
# directory so that we can use the standard build targets. We're effectively
# building multiple components using a single target.
# Fixup compressed data affected by patches.
cd $(COMPONENT_SRC) && \
# Go doesn't have a standard Makefile-based build process, so override the
# default.
# We can't do any ASLR'ing as the Go 6l linker has no understanding of the
# -z aslr=... option. So just override where needed in the .p5m files.
# The timestamp is generated immediately once when the Makefile is evaluated to
# ensure every package gets the same one.
# Make sure the source code and object files have identical timestamps so
# the Go compiler doesn't try to rebuild them.
# Extra macros for packaging convenience.
# COMPONENT_MAJOR_VERSION suitable for use in regular expressions.
# Go's test suite does not have deterministic output or order, and as such,
# success can only be determined by exit code, not by output comparison.
# clear COMPONENT_POST_INSTALL_ACTION so we can append PERL_SCRIPTS_PROCESS
# at the end
#
# Magic to deliver supplemental package source into proto area.
#
$(MANIFEST_BASE)-$(1)-15.mogrified: PKG_PROTO_DIRS= $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC_$(1))
# Install supplementary packages (this cannot be done one-by-one); install
# technically a build and install, but go's build command won't "install"
# results, it only verifies a target can be built and dumps it into a temporary
# directory.
#
# The -trimpath option used here ensures that the paths recorded in the
# pre-built packages do not contain the containing directory; the result is a
# path that Go will evaluate relative to $GOPATH and so will pass the "stale"
# object checks that Go performs at build time allowing reuse of the pre-built
# packages.
PERL_SCRIPTS= \
# Go's test suite is currently designed to be run from the build area.
# Used during the build.
# Go 1.5 now bootstraps itself using 1.5; 1.6 will bootstrap using 1.5 as well.
# Used in this Makefile.
# Required to build man pages.
# There's a single test script which requires perl.
REQUIRED_PACKAGES += $(PERL_PKG)
# Used for cgo support at runtime; we don't add a package dependency since cgo
# support is optional.