xref: /titanic_52/usr/src/tools/Makefile.python (revision 2fb4439d628ad2df0775287be1abd1ed95e7d267)
187ab3622SRichard Lowe#
287ab3622SRichard Lowe# CDDL HEADER START
387ab3622SRichard Lowe#
487ab3622SRichard Lowe# The contents of this file are subject to the terms of the
587ab3622SRichard Lowe# Common Development and Distribution License (the "License").
687ab3622SRichard Lowe# You may not use this file except in compliance with the License.
787ab3622SRichard Lowe#
887ab3622SRichard Lowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
987ab3622SRichard Lowe# or http://www.opensolaris.org/os/licensing.
1087ab3622SRichard Lowe# See the License for the specific language governing permissions
1187ab3622SRichard Lowe# and limitations under the License.
1287ab3622SRichard Lowe#
1387ab3622SRichard Lowe# When distributing Covered Code, include this CDDL HEADER in each
1487ab3622SRichard Lowe# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1587ab3622SRichard Lowe# If applicable, add the following below this CDDL HEADER, with the
1687ab3622SRichard Lowe# fields enclosed by brackets "[]" replaced with your own identifying
1787ab3622SRichard Lowe# information: Portions Copyright [yyyy] [name of copyright owner]
1887ab3622SRichard Lowe#
1987ab3622SRichard Lowe# CDDL HEADER END
2087ab3622SRichard Lowe#
2187ab3622SRichard Lowe
2287ab3622SRichard Lowe#
2387ab3622SRichard Lowe# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2487ab3622SRichard Lowe#
2587ab3622SRichard Lowe
2687ab3622SRichard Lowe#
2787ab3622SRichard Lowe# This Makefile provides a framework for building the onbld python
2887ab3622SRichard Lowe# modules with multiple versions of python.
2987ab3622SRichard Lowe#
3087ab3622SRichard Lowe# It expects as input:
3187ab3622SRichard Lowe#
3287ab3622SRichard Lowe#    PYSRCS   - List of python source files, these are also delivered as
3387ab3622SRichard Lowe#               build product.
3487ab3622SRichard Lowe#
3587ab3622SRichard Lowe#    PYOBJS   - List of compiled python (.pyc) files, with no directory prefix
3687ab3622SRichard Lowe#
3787ab3622SRichard Lowe#    PYTOPDIR - Absolute (including $(ROOT)) path to which files will
3887ab3622SRichard Lowe#               be installed, up until the version specific component.
3987ab3622SRichard Lowe#
4087ab3622SRichard Lowe#    PYMODDIR - Relative path to which files will be installed, below
4187ab3622SRichard Lowe#               the version specific component.
4287ab3622SRichard Lowe#
4387ab3622SRichard Lowe#    For example, to install to /opt/onbld/lib/onbld/python*/bar/
4487ab3622SRichard Lowe#
4587ab3622SRichard Lowe#          PYTOPDIR = $(ROOTONBLDLIB)
4687ab3622SRichard Lowe#          PYMODDIR = bar
4787ab3622SRichard Lowe#
4887ab3622SRichard Lowe#
4987ab3622SRichard Lowe# It provides as output:
5087ab3622SRichard Lowe#
5187ab3622SRichard Lowe#    ROOTPYFILES - The list of $(ROOT)-relative paths to which python
5287ab3622SRichard Lowe#                  source and binary files will be installed.  Your
5387ab3622SRichard Lowe#                  Makefile's 'install' target should depend upon
5487ab3622SRichard Lowe#                  this.
5587ab3622SRichard Lowe#
5687ab3622SRichard Lowe#    PYVERSOBJS  - The list of paths to compiled python build products,
5787ab3622SRichard Lowe#                  including their subdirectory.
5887ab3622SRichard Lowe#
5987ab3622SRichard Lowe#    pyclobber   - A target on which 'clobber' should depend, which
6087ab3622SRichard Lowe#                  removes the per-version python directories and the
6187ab3622SRichard Lowe#                  output within them.
6287ab3622SRichard Lowe#
6387ab3622SRichard Lowe
6487ab3622SRichard LowePYFILES = $(PYSRCS) $(PYOBJS)
6587ab3622SRichard Lowe
66*2fb4439dSAlexander PyhalovROOTPYDIR = $(PYTOPDIR)/python$(PYTHON_VERSION)/$(PYMODDIR)
67*2fb4439dSAlexander PyhalovROOTPYFILES	= $(PYFILES:%=$(ROOTPYDIR)/%)
6887ab3622SRichard Lowe
6987ab3622SRichard Lowe$(ROOTPYFILES) := FILEMODE = 0444
7087ab3622SRichard Lowe
71*2fb4439dSAlexander PyhalovPYVERSDIRS = python$(PYTHON_VERSION)
7287ab3622SRichard Lowe
73*2fb4439dSAlexander PyhalovPYVERSOBJS = $(PYOBJS:%=python$(PYTHON_VERSION)/%)
7487ab3622SRichard Lowe
7587ab3622SRichard LoweCLOBBERFILES += $(PYVERSOBJS)
7687ab3622SRichard LoweCLOBBERDIRS += $(PYVERSDIRS)
7787ab3622SRichard Lowe
7887ab3622SRichard Lowe.KEEP_STATE:
7987ab3622SRichard Lowe
80*2fb4439dSAlexander Pyhalovpython$(PYTHON_VERSION)/%.pyc: %.py
8187ab3622SRichard Lowe	@[ -d $(@D) ] || mkdir $(@D)
8287ab3622SRichard Lowe	$(RM) $@
8387ab3622SRichard Lowe	$(PYTHON) -mpy_compile $<
8487ab3622SRichard Lowe	$(MV) $(*).pyc $@
8587ab3622SRichard Lowe
86*2fb4439dSAlexander Pyhalov$(ROOTPYDIR)/%.pyc: python$(PYTHON_VERSION)/%.pyc
8787ab3622SRichard Lowe	$(INS.pyfile)
8887ab3622SRichard Lowe
89*2fb4439dSAlexander Pyhalov$(ROOTPYDIR)/%.py: %.py
9087ab3622SRichard Lowe	$(INS.pyfile)
9187ab3622SRichard Lowe
9287ab3622SRichard Lowepyclobber:
9387ab3622SRichard Lowe	$(RM) $(CLOBBERFILES)
9487ab3622SRichard Lowe	$(RM) -rf $(CLOBBERDIRS)
95