Andrzej Szeszo
2013-06-04 453bf5a3004107204e1858532a38b3e703e32995
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 #
6005c4 21 # Copyright (c) 2010, 2013, 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
74300c 26 $(BUILD_DIR)/$(MACH32)-%/.built:    BITS=32
NJ 27 $(BUILD_DIR)/$(MACH64)-%/.built:    BITS=64
9c75c0 28
4158c0 29 $(BUILD_DIR)/%-2.6/.installed:        PYTHON_VERSION=2.6
fa74c0 30 $(BUILD_DIR)/%-2.7/.installed:        PYTHON_VERSION=2.7
74300c 31 $(BUILD_DIR)/$(MACH32)-%/.installed:    BITS=32
NJ 32 $(BUILD_DIR)/$(MACH64)-%/.installed:    BITS=64
224ba0 33
74300c 34 BUILD_32 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.built)
NJ 35 BUILD_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.built)
ad2fa3 36 BUILD_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.built)
224ba0 37
74300c 38 INSTALL_32 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH32)-%/.installed)
NJ 39 INSTALL_64 = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH64)-%/.installed)
ad2fa3 40 INSTALL_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.installed)
NJ 41
42 TEST_NO_ARCH = $(PYTHON_VERSIONS:%=$(BUILD_DIR)/$(MACH)-%/.tested)
9c75c0 43
35a012 44 PYTHON_ENV =    CC="$(CC)"
NJ 45 PYTHON_ENV +=    CFLAGS="$(CFLAGS)"
ad2fa3 46
NJ 47 COMPONENT_BUILD_ENV += $(PYTHON_ENV)
48 COMPONENT_INSTALL_ENV += $(PYTHON_ENV)
49 COMPONENT_TEST_ENV += $(PYTHON_ENV)
fa74c0 50
NJ 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
35a012 58
a7216a 59 # Create a distutils config file specific to the combination of build
DD 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)/$*" > $@
67
9c75c0 68 # build the configured source
a7216a 69 $(BUILD_DIR)/%/.built:    $(SOURCE_DIR)/.prep $(BUILD_DIR)/config-%/$(CFG)
9c75c0 70     $(RM) -r $(@D) ; $(MKDIR) $(@D)
NJ 71     $(COMPONENT_PRE_BUILD_ACTION)
ad2fa3 72     (cd $(SOURCE_DIR) ; $(ENV) HOME=$(BUILD_DIR)/config-$* $(COMPONENT_BUILD_ENV) \
a7216a 73         $(PYTHON.$(BITS)) ./setup.py build)
9c75c0 74     $(COMPONENT_POST_BUILD_ACTION)
7999b2 75 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
MS 76     -$(PARFAIT) $(SOURCE_DIR)/$(@D:$(BUILD_DIR)/%=%)
77 endif
9c75c0 78     $(TOUCH) $@
NJ 79
ff17eb 80
e83e52 81 COMPONENT_INSTALL_ARGS +=    --root $(PROTO_DIR) 
NJ 82 COMPONENT_INSTALL_ARGS +=    --install-lib=$(PYTHON_LIB)
fa74c0 83 COMPONENT_INSTALL_ARGS +=    --install-purelib=$(PYTHON_LIB)
NJ 84 COMPONENT_INSTALL_ARGS +=    --install-platlib=$(PYTHON_LIB)
85 COMPONENT_INSTALL_ARGS +=    --install-data=$(PYTHON_DATA)
86 COMPONENT_INSTALL_ARGS +=    --force
e83e52 87
9c75c0 88 # install the built source into a prototype area
a7216a 89 $(BUILD_DIR)/%/.installed:    $(BUILD_DIR)/%/.built $(BUILD_DIR)/config-%/$(CFG)
9c75c0 90     $(COMPONENT_PRE_INSTALL_ACTION)
a7216a 91     (cd $(SOURCE_DIR) ; $(ENV) HOME=$(BUILD_DIR)/config-$* $(COMPONENT_INSTALL_ENV) \
e83e52 92         $(PYTHON.$(BITS)) ./setup.py install $(COMPONENT_INSTALL_ARGS))
9c75c0 93     $(COMPONENT_POST_INSTALL_ACTION)
NJ 94     $(TOUCH) $@
e83e52 95
59c102 96 COMPONENT_TEST_DEP =    $(BUILD_DIR)/%/.installed
AC 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
102
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) $@
111
7999b2 112 ifeq   ($(strip $(PARFAIT_BUILD)),yes)
MS 113 parfait: install
114     -$(PARFAIT) build
115 else
116 parfait:
117     $(MAKE) PARFAIT_BUILD=yes parfait
118 endif
119
35a012 120 clean::
NJ 121     $(RM) -r $(SOURCE_DIR) $(BUILD_DIR)
6005c4 122
JB 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)