Alexander Pyhalov
2018-09-06 44f1c2ebd9a7a3036f44c216d9fcf4b228cd5432
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 #
8beffa 21 # Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
9c75c0 22 #
NJ 23
74300c 24 $(BUILD_DIR)/%-2.6/.built:        PYTHON_VERSION=2.6
fa74c0 25 $(BUILD_DIR)/%-2.7/.built:        PYTHON_VERSION=2.7
8d70f8 26 $(BUILD_DIR)/%-3.4/.built:        PYTHON_VERSION=3.4
44f1c2 27 $(BUILD_DIR)/%-3.5/.built:        PYTHON_VERSION=3.5
74300c 28 $(BUILD_DIR)/$(MACH32)-%/.built:    BITS=32
NJ 29 $(BUILD_DIR)/$(MACH64)-%/.built:    BITS=64
9c75c0 30
4158c0 31 $(BUILD_DIR)/%-2.6/.installed:        PYTHON_VERSION=2.6
fa74c0 32 $(BUILD_DIR)/%-2.7/.installed:        PYTHON_VERSION=2.7
8d70f8 33 $(BUILD_DIR)/%-3.4/.installed:        PYTHON_VERSION=3.4
44f1c2 34 $(BUILD_DIR)/%-3.5/.installed:        PYTHON_VERSION=3.5
74300c 35 $(BUILD_DIR)/$(MACH32)-%/.installed:    BITS=32
NJ 36 $(BUILD_DIR)/$(MACH64)-%/.installed:    BITS=64
8d70f8 37
RB 38 $(BUILD_DIR)/%-2.6/.tested:        PYTHON_VERSION=2.6
39 $(BUILD_DIR)/%-2.7/.tested:        PYTHON_VERSION=2.7
40 $(BUILD_DIR)/%-3.4/.tested:        PYTHON_VERSION=3.4
44f1c2 41 $(BUILD_DIR)/%-3.5/.tested:        PYTHON_VERSION=3.5
8d70f8 42 $(BUILD_DIR)/$(MACH32)-%/.tested:    BITS=32
RB 43 $(BUILD_DIR)/$(MACH64)-%/.tested:    BITS=64
44
45 $(BUILD_DIR)/%-2.6/.tested-and-compared:    PYTHON_VERSION=2.6
46 $(BUILD_DIR)/%-2.7/.tested-and-compared:    PYTHON_VERSION=2.7
47 $(BUILD_DIR)/%-3.4/.tested-and-compared:    PYTHON_VERSION=3.4
44f1c2 48 $(BUILD_DIR)/%-3.5/.tested-and-compared:    PYTHON_VERSION=3.5
8d70f8 49 $(BUILD_DIR)/$(MACH32)-%/.tested-and-compared:    BITS=32
RB 50 $(BUILD_DIR)/$(MACH64)-%/.tested-and-compared:    BITS=64
224ba0 51
44f1c2 52 PYTHON_32_VERSIONS = $(filter-out $(PYTHON_64_ONLY_VERSIONS), $(PYTHON_VERSIONS))
AP 53
54 BUILD_32 = $(PYTHON_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.built)
74300c 55 BUILD_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.built)
ad2fa3 56 BUILD_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.built)
224ba0 57
44f1c2 58 ifeq ($(PYTHON_VERSION),3.5)
AP 59 BUILD_32_and_64 = $(BUILD_64)
60 endif
61
62 INSTALL_32 = $(PYTHON_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.installed)
74300c 63 INSTALL_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.installed)
ad2fa3 64 INSTALL_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.installed)
9c75c0 65
35a012 66 PYTHON_ENV =    CC="$(CC)"
NJ 67 PYTHON_ENV +=    CFLAGS="$(CFLAGS)"
ad2fa3 68
NJ 69 COMPONENT_BUILD_ENV += $(PYTHON_ENV)
70 COMPONENT_INSTALL_ENV += $(PYTHON_ENV)
71 COMPONENT_TEST_ENV += $(PYTHON_ENV)
fa74c0 72
253d56 73 # Reset arguments specified as environmnent variables
AS 74 COMPONENT_BUILD_ARGS =
75
44f1c2 76 # If we are building Python 3.4 or 3.5 support, build them and install them
f2dd52 77 # before Python 2.7, so 2.7 is installed last and is the canonical version.
8d70f8 78 # When we change the default, the new default should go last.
RB 79 ifneq ($(findstring 3.4,$(PYTHON_VERSIONS)),)
f2dd52 80 $(BUILD_DIR)/%-2.7/.built:     $(BUILD_DIR)/%-3.4/.built
AP 81 $(BUILD_DIR)/%-2.7/.installed: $(BUILD_DIR)/%-3.4/.installed
44f1c2 82 endif
AP 83 ifneq ($(findstring 3.5,$(PYTHON_VERSIONS)),)
84 $(BUILD_DIR)/%-2.7/.built:     $(BUILD_DIR)/%-3.5/.built
85 $(BUILD_DIR)/%-2.7/.installed: $(BUILD_DIR)/%-3.5/.installed
fa74c0 86 endif
35a012 87
a7216a 88 # Create a distutils config file specific to the combination of build
DD 89 # characteristics (bittedness x Python version), and put it in its own
90 # directory.  We can set $HOME to point distutils at it later, allowing
91 # the install phase to find the temporary build directories.
92 CFG=.pydistutils.cfg
93 $(BUILD_DIR)/config-%/$(CFG):
94     $(MKDIR) $(@D)
95     echo "[build]\nbuild_base = $(BUILD_DIR)/$*" > $@
96
9c75c0 97 # build the configured source
a7216a 98 $(BUILD_DIR)/%/.built:    $(SOURCE_DIR)/.prep $(BUILD_DIR)/config-%/$(CFG)
9c75c0 99     $(RM) -r $(@D) ; $(MKDIR) $(@D)
NJ 100     $(COMPONENT_PRE_BUILD_ACTION)
ad2fa3 101     (cd $(SOURCE_DIR) ; $(ENV) HOME=$(BUILD_DIR)/config-$* $(COMPONENT_BUILD_ENV) \
9b6294 102         $(PYTHON.$(BITS)) ./setup.py build $(COMPONENT_BUILD_ARGS))
9c75c0 103     $(COMPONENT_POST_BUILD_ACTION)
7999b2 104 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
MS 105     -$(PARFAIT) $(SOURCE_DIR)/$(@D:$(BUILD_DIR)/%=%)
106 endif
9c75c0 107     $(TOUCH) $@
NJ 108
ff17eb 109
e83e52 110 COMPONENT_INSTALL_ARGS +=    --root $(PROTO_DIR) 
NJ 111 COMPONENT_INSTALL_ARGS +=    --install-lib=$(PYTHON_LIB)
fa74c0 112 COMPONENT_INSTALL_ARGS +=    --install-purelib=$(PYTHON_LIB)
NJ 113 COMPONENT_INSTALL_ARGS +=    --install-platlib=$(PYTHON_LIB)
114 COMPONENT_INSTALL_ARGS +=    --install-data=$(PYTHON_DATA)
115 COMPONENT_INSTALL_ARGS +=    --force
e83e52 116
9c75c0 117 # install the built source into a prototype area
a7216a 118 $(BUILD_DIR)/%/.installed:    $(BUILD_DIR)/%/.built $(BUILD_DIR)/config-%/$(CFG)
9c75c0 119     $(COMPONENT_PRE_INSTALL_ACTION)
a7216a 120     (cd $(SOURCE_DIR) ; $(ENV) HOME=$(BUILD_DIR)/config-$* $(COMPONENT_INSTALL_ENV) \
e83e52 121         $(PYTHON.$(BITS)) ./setup.py install $(COMPONENT_INSTALL_ARGS))
9c75c0 122     $(COMPONENT_POST_INSTALL_ACTION)
NJ 123     $(TOUCH) $@
e83e52 124
8d70f8 125 # Define bit specific and Python version specific filenames.
RB 126 COMPONENT_TEST_MASTER =    $(COMPONENT_TEST_RESULTS_DIR)/results-$(PYTHON_VERSION)-$(BITS).master
237543 127 COMPONENT_TEST_OUTPUT =    $(COMPONENT_TEST_BUILD_DIR)/test-$(PYTHON_VERSION)-$(BITS)-results
AP 128 COMPONENT_TEST_DIFFS =    $(COMPONENT_TEST_BUILD_DIR)/test-$(PYTHON_VERSION)-$(BITS)-diffs
129 COMPONENT_TEST_SNAPSHOT = $(COMPONENT_TEST_BUILD_DIR)/results-$(PYTHON_VERSION)-$(BITS).snapshot
130 COMPONENT_TEST_TRANSFORM_CMD = $(COMPONENT_TEST_BUILD_DIR)/transform-$(PYTHON_VERSION)-$(BITS)-results
8d70f8 131
59c102 132 COMPONENT_TEST_DEP =    $(BUILD_DIR)/%/.installed
AC 133 COMPONENT_TEST_DIR =    $(COMPONENT_SRC)/test
8d70f8 134 COMPONENT_TEST_ENV_CMD =    $(ENV)
59c102 135 COMPONENT_TEST_ENV +=    PYTHONPATH=$(PROTO_DIR)$(PYTHON_VENDOR_PACKAGES)
AC 136 COMPONENT_TEST_CMD =    $(PYTHON)
137 COMPONENT_TEST_ARGS +=    ./runtests.py
138
8d70f8 139 # determine the type of tests we want to run.
RB 140 ifeq ($(strip $(wildcard $(COMPONENT_TEST_RESULTS_DIR)/results-*.master)),)
44f1c2 141 TEST_32 = $(PYTHON_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested)
8d70f8 142 TEST_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested)
RB 143 TEST_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested)
144 else
44f1c2 145 TEST_32 = $(PYTHON_32_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested-and-compared)
8d70f8 146 TEST_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested-and-compared)
RB 147 TEST_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested-and-compared)
148 endif
149
59c102 150 # test the built source
8d70f8 151 $(BUILD_DIR)/%/.tested-and-compared:    $(COMPONENT_TEST_DEP)
237543 152     $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
AP 153     $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
59c102 154     $(COMPONENT_PRE_TEST_ACTION)
8d70f8 155     -(cd $(COMPONENT_TEST_DIR) ; \
RB 156         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
157         $(COMPONENT_TEST_CMD) $(COMPONENT_TEST_ARGS)) \
158         &> $(COMPONENT_TEST_OUTPUT)
59c102 159     $(COMPONENT_POST_TEST_ACTION)
8d70f8 160     $(COMPONENT_TEST_CREATE_TRANSFORMS)
RB 161     $(COMPONENT_TEST_PERFORM_TRANSFORM)
162     $(COMPONENT_TEST_COMPARE)
163     $(COMPONENT_TEST_CLEANUP)
164     $(TOUCH) $@
165
166 $(BUILD_DIR)/%/.tested:    $(COMPONENT_TEST_DEP)
167     $(COMPONENT_PRE_TEST_ACTION)
168     (cd $(COMPONENT_TEST_DIR) ; \
169         $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
170         $(COMPONENT_TEST_CMD) $(COMPONENT_TEST_ARGS))
171     $(COMPONENT_POST_TEST_ACTION)
172     $(COMPONENT_TEST_CLEANUP)
59c102 173     $(TOUCH) $@
AC 174
7999b2 175 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
MS 176 parfait: install
177     -$(PARFAIT) build
178 else
179 parfait:
180     $(MAKE) PARFAIT_BUILD=yes parfait
181 endif
182
35a012 183 clean::
NJ 184     $(RM) -r $(SOURCE_DIR) $(BUILD_DIR)
6005c4 185
8beffa 186 # Make it easy to construct a URL for a pypi source download. This
DD 187 # construct supports an optional call to a number from
188 # NUM_EXTRA_ARCHIVES for multiple archive downloads.
189 pypi_url_multi = pypi:///$(COMPONENT_NAME_$(1))==$(COMPONENT_VERSION_$(1))
190 pypi_url_single = pypi:///$(COMPONENT_NAME)==$(COMPONENT_VERSION)
191 pypi_url = $(if $(COMPONENT_NAME_$(1)),$(pypi_url_multi),$(pypi_url_single))