Merge pull request #2809 from alarcher/nvidia340.102
[unleashed-userland.git] / make-rules / setup.py.mk
bloba11f1e2517f40e6061b69d7ddbebfca60facacbf
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
21 # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
24 $(BUILD_DIR)/%-2.6/.built: PYTHON_VERSION=2.6
25 $(BUILD_DIR)/%-2.7/.built: PYTHON_VERSION=2.7
26 $(BUILD_DIR)/%-3.4/.built: PYTHON_VERSION=3.4
27 $(BUILD_DIR)/$(MACH32)-%/.built: BITS=32
28 $(BUILD_DIR)/$(MACH64)-%/.built: BITS=64
30 $(BUILD_DIR)/%-2.6/.installed: PYTHON_VERSION=2.6
31 $(BUILD_DIR)/%-2.7/.installed: PYTHON_VERSION=2.7
32 $(BUILD_DIR)/%-3.4/.installed: PYTHON_VERSION=3.4
33 $(BUILD_DIR)/$(MACH32)-%/.installed: BITS=32
34 $(BUILD_DIR)/$(MACH64)-%/.installed: BITS=64
36 $(BUILD_DIR)/%-2.6/.tested: PYTHON_VERSION=2.6
37 $(BUILD_DIR)/%-2.7/.tested: PYTHON_VERSION=2.7
38 $(BUILD_DIR)/%-3.4/.tested: PYTHON_VERSION=3.4
39 $(BUILD_DIR)/$(MACH32)-%/.tested: BITS=32
40 $(BUILD_DIR)/$(MACH64)-%/.tested: BITS=64
42 $(BUILD_DIR)/%-2.6/.tested-and-compared: PYTHON_VERSION=2.6
43 $(BUILD_DIR)/%-2.7/.tested-and-compared: PYTHON_VERSION=2.7
44 $(BUILD_DIR)/%-3.4/.tested-and-compared: PYTHON_VERSION=3.4
45 $(BUILD_DIR)/$(MACH32)-%/.tested-and-compared: BITS=32
46 $(BUILD_DIR)/$(MACH64)-%/.tested-and-compared: BITS=64
48 BUILD_32 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.built)
49 BUILD_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.built)
50 BUILD_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.built)
52 INSTALL_32 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.installed)
53 INSTALL_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.installed)
54 INSTALL_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.installed)
56 PYTHON_ENV = CC="$(CC)"
57 PYTHON_ENV += CFLAGS="$(CFLAGS)"
59 COMPONENT_BUILD_ENV += $(PYTHON_ENV)
60 COMPONENT_INSTALL_ENV += $(PYTHON_ENV)
61 COMPONENT_TEST_ENV += $(PYTHON_ENV)
63 # Reset arguments specified as environmnent variables
64 COMPONENT_BUILD_ARGS =
66 # If we are building Python 2.6 or 3.4 support, build them and install them
67 # before Python 2.7, so 2.7 is installed last and is the canonical version.
68 # When we change the default, the new default should go last.
69 ifneq ($(findstring 2.6,$(PYTHON_VERSIONS)),)
70 $(BUILD_DIR)/%-2.7/.built: $(BUILD_DIR)/%-2.6/.built
71 $(BUILD_DIR)/%-2.7/.installed: $(BUILD_DIR)/%-2.6/.installed
72 endif
73 ifneq ($(findstring 3.4,$(PYTHON_VERSIONS)),)
74 $(BUILD_DIR)/%-2.7/.built: $(BUILD_DIR)/%-3.4/.built
75 $(BUILD_DIR)/%-2.7/.installed: $(BUILD_DIR)/%-3.4/.installed
76 endif
78 # Create a distutils config file specific to the combination of build
79 # characteristics (bittedness x Python version), and put it in its own
80 # directory. We can set $HOME to point distutils at it later, allowing
81 # the install phase to find the temporary build directories.
82 CFG=.pydistutils.cfg
83 $(BUILD_DIR)/config-%/$(CFG):
84 $(MKDIR) $(@D)
85 echo "[build]\nbuild_base = $(BUILD_DIR)/$*" > $@
87 # build the configured source
88 $(BUILD_DIR)/%/.built: $(SOURCE_DIR)/.prep $(BUILD_DIR)/config-%/$(CFG)
89 $(RM) -r $(@D) ; $(MKDIR) $(@D)
90 $(COMPONENT_PRE_BUILD_ACTION)
91 (cd $(SOURCE_DIR) ; $(ENV) HOME=$(BUILD_DIR)/config-$* $(COMPONENT_BUILD_ENV) \
92 $(PYTHON.$(BITS)) ./setup.py build $(COMPONENT_BUILD_ARGS))
93 $(COMPONENT_POST_BUILD_ACTION)
94 ifeq ($(strip $(PARFAIT_BUILD)),yes)
95 -$(PARFAIT) $(SOURCE_DIR)/$(@D:$(BUILD_DIR)/%=%)
96 endif
97 $(TOUCH) $@
100 COMPONENT_INSTALL_ARGS += --root $(PROTO_DIR)
101 COMPONENT_INSTALL_ARGS += --install-lib=$(PYTHON_LIB)
102 COMPONENT_INSTALL_ARGS += --install-purelib=$(PYTHON_LIB)
103 COMPONENT_INSTALL_ARGS += --install-platlib=$(PYTHON_LIB)
104 COMPONENT_INSTALL_ARGS += --install-data=$(PYTHON_DATA)
105 COMPONENT_INSTALL_ARGS += --force
107 # install the built source into a prototype area
108 $(BUILD_DIR)/%/.installed: $(BUILD_DIR)/%/.built $(BUILD_DIR)/config-%/$(CFG)
109 $(COMPONENT_PRE_INSTALL_ACTION)
110 (cd $(SOURCE_DIR) ; $(ENV) HOME=$(BUILD_DIR)/config-$* $(COMPONENT_INSTALL_ENV) \
111 $(PYTHON.$(BITS)) ./setup.py install $(COMPONENT_INSTALL_ARGS))
112 $(COMPONENT_POST_INSTALL_ACTION)
113 $(TOUCH) $@
115 # Define bit specific and Python version specific filenames.
116 COMPONENT_TEST_MASTER = $(COMPONENT_TEST_RESULTS_DIR)/results-$(PYTHON_VERSION)-$(BITS).master
117 COMPONENT_TEST_OUTPUT = $(COMPONENT_TEST_BUILD_DIR)/test-$(PYTHON_VERSION)-$(BITS)-results
118 COMPONENT_TEST_DIFFS = $(COMPONENT_TEST_BUILD_DIR)/test-$(PYTHON_VERSION)-$(BITS)-diffs
119 COMPONENT_TEST_SNAPSHOT = $(COMPONENT_TEST_BUILD_DIR)/results-$(PYTHON_VERSION)-$(BITS).snapshot
120 COMPONENT_TEST_TRANSFORM_CMD = $(COMPONENT_TEST_BUILD_DIR)/transform-$(PYTHON_VERSION)-$(BITS)-results
122 COMPONENT_TEST_DEP = $(BUILD_DIR)/%/.installed
123 COMPONENT_TEST_DIR = $(COMPONENT_SRC)/test
124 COMPONENT_TEST_ENV_CMD = $(ENV)
125 COMPONENT_TEST_ENV += PYTHONPATH=$(PROTO_DIR)$(PYTHON_VENDOR_PACKAGES)
126 COMPONENT_TEST_CMD = $(PYTHON)
127 COMPONENT_TEST_ARGS += ./runtests.py
129 # determine the type of tests we want to run.
130 ifeq ($(strip $(wildcard $(COMPONENT_TEST_RESULTS_DIR)/results-*.master)),)
131 TEST_32 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested)
132 TEST_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested)
133 TEST_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested)
134 else
135 TEST_32 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.tested-and-compared)
136 TEST_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.tested-and-compared)
137 TEST_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested-and-compared)
138 endif
140 # test the built source
141 $(BUILD_DIR)/%/.tested-and-compared: $(COMPONENT_TEST_DEP)
142 $(RM) -rf $(COMPONENT_TEST_BUILD_DIR)
143 $(MKDIR) $(COMPONENT_TEST_BUILD_DIR)
144 $(COMPONENT_PRE_TEST_ACTION)
145 -(cd $(COMPONENT_TEST_DIR) ; \
146 $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
147 $(COMPONENT_TEST_CMD) $(COMPONENT_TEST_ARGS)) \
148 &> $(COMPONENT_TEST_OUTPUT)
149 $(COMPONENT_POST_TEST_ACTION)
150 $(COMPONENT_TEST_CREATE_TRANSFORMS)
151 $(COMPONENT_TEST_PERFORM_TRANSFORM)
152 $(COMPONENT_TEST_COMPARE)
153 $(COMPONENT_TEST_CLEANUP)
154 $(TOUCH) $@
156 $(BUILD_DIR)/%/.tested: $(COMPONENT_TEST_DEP)
157 $(COMPONENT_PRE_TEST_ACTION)
158 (cd $(COMPONENT_TEST_DIR) ; \
159 $(COMPONENT_TEST_ENV_CMD) $(COMPONENT_TEST_ENV) \
160 $(COMPONENT_TEST_CMD) $(COMPONENT_TEST_ARGS))
161 $(COMPONENT_POST_TEST_ACTION)
162 $(COMPONENT_TEST_CLEANUP)
163 $(TOUCH) $@
165 ifeq ($(strip $(PARFAIT_BUILD)),yes)
166 parfait: install
167 -$(PARFAIT) build
168 else
169 parfait:
170 $(MAKE) PARFAIT_BUILD=yes parfait
171 endif
173 clean::
174 $(RM) -r $(SOURCE_DIR) $(BUILD_DIR)
176 # Make it easy to construct a URL for a pypi source download.
177 PYPI_BASE = http://pypi.python.org/packages/source
178 pypi_url = $(PYPI_BASE)/$(shell echo $(COMPONENT_NAME) | cut -c1)/$(COMPONENT_NAME)/$(COMPONENT_ARCHIVE)