Bring mtr from sustaining oi-build
[unleashed-userland.git] / make-rules / setup.py.mk
blob0d24d4ac64b8f194898ef8db7a5adbe46b05156a
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, 2013, 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)/$(MACH32)-%/.built: BITS=32
27 $(BUILD_DIR)/$(MACH64)-%/.built: BITS=64
29 $(BUILD_DIR)/%-2.6/.installed: PYTHON_VERSION=2.6
30 $(BUILD_DIR)/%-2.7/.installed: PYTHON_VERSION=2.7
31 $(BUILD_DIR)/$(MACH32)-%/.installed: BITS=32
32 $(BUILD_DIR)/$(MACH64)-%/.installed: BITS=64
34 BUILD_32 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.built)
35 BUILD_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.built)
36 BUILD_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.built)
38 INSTALL_32 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.installed)
39 INSTALL_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.installed)
40 INSTALL_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.installed)
42 TEST_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested)
44 PYTHON_ENV = CC="$(CC)"
45 PYTHON_ENV += CFLAGS="$(CFLAGS)"
47 COMPONENT_BUILD_ENV += $(PYTHON_ENV)
48 COMPONENT_INSTALL_ENV += $(PYTHON_ENV)
49 COMPONENT_TEST_ENV += $(PYTHON_ENV)
51 # if we are building python 2.7 support, build it and install it first
52 # so that python 2.6 is installed last and is the canonical version.
53 # when we switch to 2.7 as the default, it should go last.
54 ifneq ($(findstring 2.7,$(PYTHON_VERSIONS)),)
55 $(BUILD_DIR)/%-2.6/.build: $(BUILD_DIR)/%-2.7/.build
56 $(BUILD_DIR)/%-2.6/.installed: $(BUILD_DIR)/%-2.7/.installed
57 endif
59 # Create a distutils config file specific to the combination of build
60 # characteristics (bittedness x Python version), and put it in its own
61 # directory. We can set $HOME to point distutils at it later, allowing
62 # the install phase to find the temporary build directories.
63 CFG=.pydistutils.cfg
64 $(BUILD_DIR)/config-%/$(CFG):
65 $(MKDIR) $(@D)
66 echo "[build]\nbuild_base = $(BUILD_DIR)/$*" > $@
68 # build the configured source
69 $(BUILD_DIR)/%/.built: $(SOURCE_DIR)/.prep $(BUILD_DIR)/config-%/$(CFG)
70 $(RM) -r $(@D) ; $(MKDIR) $(@D)
71 $(COMPONENT_PRE_BUILD_ACTION)
72 (cd $(SOURCE_DIR) ; $(ENV) HOME=$(BUILD_DIR)/config-$* $(COMPONENT_BUILD_ENV) \
73 $(PYTHON.$(BITS)) ./setup.py build)
74 $(COMPONENT_POST_BUILD_ACTION)
75 ifeq ($(strip $(PARFAIT_BUILD)),yes)
76 -$(PARFAIT) $(SOURCE_DIR)/$(@D:$(BUILD_DIR)/%=%)
77 endif
78 $(TOUCH) $@
81 COMPONENT_INSTALL_ARGS += --root $(PROTO_DIR)
82 COMPONENT_INSTALL_ARGS += --install-lib=$(PYTHON_LIB)
83 COMPONENT_INSTALL_ARGS += --install-purelib=$(PYTHON_LIB)
84 COMPONENT_INSTALL_ARGS += --install-platlib=$(PYTHON_LIB)
85 COMPONENT_INSTALL_ARGS += --install-data=$(PYTHON_DATA)
86 COMPONENT_INSTALL_ARGS += --force
88 # install the built source into a prototype area
89 $(BUILD_DIR)/%/.installed: $(BUILD_DIR)/%/.built $(BUILD_DIR)/config-%/$(CFG)
90 $(COMPONENT_PRE_INSTALL_ACTION)
91 (cd $(SOURCE_DIR) ; $(ENV) HOME=$(BUILD_DIR)/config-$* $(COMPONENT_INSTALL_ENV) \
92 $(PYTHON.$(BITS)) ./setup.py install $(COMPONENT_INSTALL_ARGS))
93 $(COMPONENT_POST_INSTALL_ACTION)
94 $(TOUCH) $@
96 COMPONENT_TEST_DEP = $(BUILD_DIR)/%/.installed
97 COMPONENT_TEST_DIR = $(COMPONENT_SRC)/test
98 COMPONENT_TEST_ENV_CMD = $(ENV) -
99 COMPONENT_TEST_ENV += PYTHONPATH=$(PROTO_DIR)$(PYTHON_VENDOR_PACKAGES)
100 COMPONENT_TEST_CMD = $(PYTHON)
101 COMPONENT_TEST_ARGS += ./runtests.py
103 # test the built source
104 $(BUILD_DIR)/%/.tested: $(COMPONENT_TEST_DEP)
105 $(COMPONENT_PRE_TEST_ACTION)
106 (cd $(COMPONENT_TEST_DIR); $(COMPONENT_TEST_ENV_CMD) \
107 $(COMPONENT_TEST_ENV) \
108 $(COMPONENT_TEST_CMD) $(COMPONENT_TEST_ARGS) )
109 $(COMPONENT_POST_TEST_ACTION)
110 $(TOUCH) $@
112 ifeq ($(strip $(PARFAIT_BUILD)),yes)
113 parfait: install
114 -$(PARFAIT) build
115 else
116 parfait:
117 $(MAKE) PARFAIT_BUILD=yes parfait
118 endif
120 clean::
121 $(RM) -r $(SOURCE_DIR) $(BUILD_DIR)
123 # Make it easy to construct a URL for a pypi source download.
124 PYPI_BASE = http://pypi.python.org/packages/source
125 pypi_url = $(PYPI_BASE)/$(shell echo $(COMPONENT_NAME) | cut -c1)/$(COMPONENT_NAME)/$(COMPONENT_ARCHIVE)