Makefile revision 5934
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# CDDL HEADER START
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# The contents of this file are subject to the terms of the
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Common Development and Distribution License (the "License").
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# You may not use this file except in compliance with the License.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# See the License for the specific language governing permissions
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# and limitations under the License.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# When distributing Covered Code, include this CDDL HEADER in each
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# If applicable, add the following below this CDDL HEADER, with the
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# fields enclosed by brackets "[]" replaced with your own identifying
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# information: Portions Copyright [yyyy] [name of copyright owner]
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# CDDL HEADER END
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCOMPONENT_SRC= $(COMPONENT_NAME)-$(COMPONENT_VERSION)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar sha256:962b4c45af50124ea61f11a30deb4342fc0bc21126790fa1d7f6c79809413f46
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCOMPONENT_ARCHIVE_URL= $(COMPONENT_PROJECT_URL)ftp/python/$(COMPONENT_VERSION)/$(COMPONENT_ARCHIVE)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Need to preserve timestamp for Grammar files. If the pickle files are older,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Python will try to rebuild them.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# We patch auto* files, so regenerate headers and configure
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCOMPONENT_PREP_ACTION = (cd $(@D) ; autoheader ; autoconf -f)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# we don't want to leak $(CC_BITS) into BASECFLAGS as it causes problems with
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# python-config
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# to find the ncurses headers
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# enable large files how they did in JDS
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# libffi for _ctypes
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCPPFLAGS += $(shell pkg-config --cflags-only-I libffi)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# because python links with $(CC) ... $(LDFLAGS) ...
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# The python build is profile-guided for studio; to see the benefits of that,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Python must be compiled with -xO5 and a different build target must be used.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Use of xprofile requires that the same options be used during compilation and
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# linking. The targets chosen are based on Solaris 11 minimum supported system
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# requirements.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarPYFLAGS.i386 = -xtarget=opteron -xarch=sse2 -xcache=generic
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Use the Studio VIS SDK in order to explicitly generate nonfaulting loads
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# that allow Python to work with ADI-aware memory allocators.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Python puts its header files in a special place.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# PYTHONPATH in the environment can be harmful, but setting it to empty via
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# _INSTALL_ENV causes problems too, so just ignore the entire environment.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Because of this, we need to specify PATH in multiple places below.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCONFIGURE_OPTIONS += --infodir=$(CONFIGURE_INFODIR)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCONFIGURE_OPTIONS += XPROFILE_DIR="$(XPROFILE_DIR)"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCOMPONENT_BUILD_ENV += XPROFILE_DIR="$(XPROFILE_DIR)"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# 64 bit shared objects need to go in a 64-bit directory
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCOMPONENT_INSTALL_ARGS.64 += DESTSHARED=$(CONFIGURE_PREFIX)/lib/python2.7/lib-dynload
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Simplify the definitions of CC, CXX, CFLAGS and LDFLAGS so they hard-code
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# neither paths from our build systems nor Studio-specific options.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar (cd $(@D) ; $(GSED) -i -e 's/^CC=.*/CC=\t\tcc/' \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar -e 's/^CFLAGS=.*/CFLAGS=\t\t\$$\(BASECFLAGS) \$$\(OPT) \$$\(EXTRA_CFLAGS)/' \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Because we stripped the Makefile above, we need to pass several things in the
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# environment, and use -e to tell gmake to pay attention to the environment.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# 1. Setup pyconfig.h file to support 32 & 64 bit.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# 2. If the /usr/lib/python2.7/lib2to3/*.pickle files are older than the
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# related *.txt files in the same directory, it will rebuild them any time
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# you try to build a Python module. So here we also touch the pickle files
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# to avoid this.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# 3. Strip build machine paths from _sysconfigdata.py & config/Makefile.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Note that although the 64-bit version is not used (and thus commented
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# out in the manifest), we still need to specify the 32-/64-bit paths,
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# otherwise the 64-bit build will fail to find the 32-bit path.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# 4. (Re)compile _sysconfigdata.py since we just updated it.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCONFIG_MAKEFILE.32= lib/python2.7/config/Makefile
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCONFIG_MAKEFILE.64= lib/$(MACH64)/python2.7/config/Makefile
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar $(MV) include/python2.7/pyconfig.h include/python2.7/pyconfig-$(BITS).h ; \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar $(GSED) -i -e 's|$(SOURCE_DIR)|.|g' -e 's|$(COMPONENT_DIR)|..|g' \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar -e 's|$(SPRO_VROOT)/bin/||g' lib/python2.7/_sysconfigdata.py \
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar $(PYTHON.2.7) -m py_compile lib/python2.7/_sysconfigdata.py)
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# common targets
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Using "-uall,-network" ensures all tests are run except the network tests.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# The network tests contain many expected failures when run behind a firewall.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# The "-v" ensures verbose mode. You can set TESTOPTS_PYTHON_TEST to a
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# particular test if you want to run just one test. For example, run gmake with
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# "-k" so it continues and does both 32-bit and 64-bit tests, even if there is a
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# failure, like this:
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# $ TESTOPTS_PYTHON_TEST=test_sys gmake -k test
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# Note that when a test succeeds, the builds/*/.tested file gets created. You
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# may need to remove these files, or run "gmake clobber" or "gmake clean"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# between tests.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCOMPONENT_TEST_ENV = EXTRATESTOPTS="-v -uall,-network $(TESTOPTS_PYTHON_TEST)"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# The distutils tests need $CC in $PATH.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCOMPONENT_TEST_ENV += PATH="$(SPRO_VROOT)/bin:$(PATH)"
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# The test output contains details from each test, in whatever order they
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# complete. The default _TRANSFORMER is not powerful enough to deal with
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# this; we need heavier artillery. Extract just the sections that start
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza Sabdar# with "tests OK." and end with "Makefile: " for comparison.
2654012f83cec5dc15b61dfe3e4a4915f186e7a6Reza SabdarCOMPONENT_TEST_TRANSFORMS = "'/tests OK./ {results = 1}; /Makefile:/ {results = 0} {if (results) print $0 } '"