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