xref: /titanic_44/usr/src/tools/Makefile.python (revision 87ab362234f761757d96ff1a758ab5c3bd85ed83)
1*87ab3622SRichard Lowe#
2*87ab3622SRichard Lowe# CDDL HEADER START
3*87ab3622SRichard Lowe#
4*87ab3622SRichard Lowe# The contents of this file are subject to the terms of the
5*87ab3622SRichard Lowe# Common Development and Distribution License (the "License").
6*87ab3622SRichard Lowe# You may not use this file except in compliance with the License.
7*87ab3622SRichard Lowe#
8*87ab3622SRichard Lowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*87ab3622SRichard Lowe# or http://www.opensolaris.org/os/licensing.
10*87ab3622SRichard Lowe# See the License for the specific language governing permissions
11*87ab3622SRichard Lowe# and limitations under the License.
12*87ab3622SRichard Lowe#
13*87ab3622SRichard Lowe# When distributing Covered Code, include this CDDL HEADER in each
14*87ab3622SRichard Lowe# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*87ab3622SRichard Lowe# If applicable, add the following below this CDDL HEADER, with the
16*87ab3622SRichard Lowe# fields enclosed by brackets "[]" replaced with your own identifying
17*87ab3622SRichard Lowe# information: Portions Copyright [yyyy] [name of copyright owner]
18*87ab3622SRichard Lowe#
19*87ab3622SRichard Lowe# CDDL HEADER END
20*87ab3622SRichard Lowe#
21*87ab3622SRichard Lowe
22*87ab3622SRichard Lowe#
23*87ab3622SRichard Lowe# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*87ab3622SRichard Lowe#
25*87ab3622SRichard Lowe
26*87ab3622SRichard Lowe#
27*87ab3622SRichard Lowe# This Makefile provides a framework for building the onbld python
28*87ab3622SRichard Lowe# modules with multiple versions of python.
29*87ab3622SRichard Lowe#
30*87ab3622SRichard Lowe# It expects as input:
31*87ab3622SRichard Lowe#
32*87ab3622SRichard Lowe#    PYSRCS   - List of python source files, these are also delivered as
33*87ab3622SRichard Lowe#               build product.
34*87ab3622SRichard Lowe#
35*87ab3622SRichard Lowe#    PYOBJS   - List of compiled python (.pyc) files, with no directory prefix
36*87ab3622SRichard Lowe#
37*87ab3622SRichard Lowe#    PYTOPDIR - Absolute (including $(ROOT)) path to which files will
38*87ab3622SRichard Lowe#               be installed, up until the version specific component.
39*87ab3622SRichard Lowe#
40*87ab3622SRichard Lowe#    PYMODDIR - Relative path to which files will be installed, below
41*87ab3622SRichard Lowe#               the version specific component.
42*87ab3622SRichard Lowe#
43*87ab3622SRichard Lowe#    For example, to install to /opt/onbld/lib/onbld/python*/bar/
44*87ab3622SRichard Lowe#
45*87ab3622SRichard Lowe#          PYTOPDIR = $(ROOTONBLDLIB)
46*87ab3622SRichard Lowe#          PYMODDIR = bar
47*87ab3622SRichard Lowe#
48*87ab3622SRichard Lowe#
49*87ab3622SRichard Lowe# It provides as output:
50*87ab3622SRichard Lowe#
51*87ab3622SRichard Lowe#    ROOTPYFILES - The list of $(ROOT)-relative paths to which python
52*87ab3622SRichard Lowe#                  source and binary files will be installed.  Your
53*87ab3622SRichard Lowe#                  Makefile's 'install' target should depend upon
54*87ab3622SRichard Lowe#                  this.
55*87ab3622SRichard Lowe#
56*87ab3622SRichard Lowe#    PYVERSOBJS  - The list of paths to compiled python build products,
57*87ab3622SRichard Lowe#                  including their subdirectory.
58*87ab3622SRichard Lowe#
59*87ab3622SRichard Lowe#    pyclobber   - A target on which 'clobber' should depend, which
60*87ab3622SRichard Lowe#                  removes the per-version python directories and the
61*87ab3622SRichard Lowe#                  output within them.
62*87ab3622SRichard Lowe#
63*87ab3622SRichard Lowe
64*87ab3622SRichard LowePYFILES = $(PYSRCS) $(PYOBJS)
65*87ab3622SRichard Lowe
66*87ab3622SRichard LoweROOTPYDIR_24 = $(PYTOPDIR)/python2.4/$(PYMODDIR)
67*87ab3622SRichard LoweROOTPYFILES_24 = $(PYFILES:%=$(ROOTPYDIR_24)/%)
68*87ab3622SRichard Lowe
69*87ab3622SRichard LoweROOTPYDIR_26 = $(PYTOPDIR)/python2.6/$(PYMODDIR)
70*87ab3622SRichard LoweROOTPYFILES_26	= $(PYFILES:%=$(ROOTPYDIR_26)/%)
71*87ab3622SRichard Lowe
72*87ab3622SRichard LoweROOTPYFILES = $(ROOTPYFILES_24) $(ROOTPYFILES_26)
73*87ab3622SRichard Lowe$(ROOTPYFILES) := FILEMODE = 0444
74*87ab3622SRichard Lowe
75*87ab3622SRichard LowePYVERSDIRS = python2.4 python2.6
76*87ab3622SRichard Lowe
77*87ab3622SRichard LowePY24OBJS = $(PYOBJS:%=python2.4/%)
78*87ab3622SRichard Lowe$(PY24OBJS) := PYTHON = $(PYTHON_24)
79*87ab3622SRichard Lowe
80*87ab3622SRichard LowePY26OBJS = $(PYOBJS:%=python2.6/%)
81*87ab3622SRichard Lowe$(PY26OBJS) := PYTHON = $(PYTHON_26)
82*87ab3622SRichard Lowe
83*87ab3622SRichard LowePYVERSOBJS = $(PY24OBJS) $(PY26OBJS)
84*87ab3622SRichard Lowe
85*87ab3622SRichard LoweCLOBBERFILES += $(PYVERSOBJS)
86*87ab3622SRichard LoweCLOBBERDIRS += $(PYVERSDIRS)
87*87ab3622SRichard Lowe
88*87ab3622SRichard Lowe.KEEP_STATE:
89*87ab3622SRichard Lowe
90*87ab3622SRichard Lowepython2.4/%.pyc python2.6/%.pyc: %.py
91*87ab3622SRichard Lowe	@[ -d $(@D) ] || mkdir $(@D)
92*87ab3622SRichard Lowe	$(RM) $@
93*87ab3622SRichard Lowe	$(PYTHON) -mpy_compile $<
94*87ab3622SRichard Lowe	$(MV) $(*).pyc $@
95*87ab3622SRichard Lowe
96*87ab3622SRichard Lowe$(ROOTPYDIR_24)/%.pyc: python2.4/%.pyc
97*87ab3622SRichard Lowe	$(INS.pyfile)
98*87ab3622SRichard Lowe
99*87ab3622SRichard Lowe$(ROOTPYDIR_26)/%.pyc: python2.6/%.pyc
100*87ab3622SRichard Lowe	$(INS.pyfile)
101*87ab3622SRichard Lowe
102*87ab3622SRichard Lowe$(ROOTPYDIR_24)/%.py $(ROOTPYDIR_26)/%.py: %.py
103*87ab3622SRichard Lowe	$(INS.pyfile)
104*87ab3622SRichard Lowe
105*87ab3622SRichard Lowepyclobber:
106*87ab3622SRichard Lowe	$(RM) $(CLOBBERFILES)
107*87ab3622SRichard Lowe	$(RM) -rf $(CLOBBERDIRS)
108