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