87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# CDDL HEADER START
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# The contents of this file are subject to the terms of the
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# Common Development and Distribution License (the "License").
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# You may not use this file except in compliance with the License.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# or http://www.opensolaris.org/os/licensing.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# See the License for the specific language governing permissions
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# and limitations under the License.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# When distributing Covered Code, include this CDDL HEADER in each
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# If applicable, add the following below this CDDL HEADER, with the
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# fields enclosed by brackets "[]" replaced with your own identifying
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# information: Portions Copyright [yyyy] [name of copyright owner]
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# CDDL HEADER END
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# This Makefile provides a framework for building the onbld python
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# modules with multiple versions of python.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# It expects as input:
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# PYSRCS - List of python source files, these are also delivered as
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# build product.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# PYOBJS - List of compiled python (.pyc) files, with no directory prefix
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# PYTOPDIR - Absolute (including $(ROOT)) path to which files will
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# be installed, up until the version specific component.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# PYMODDIR - Relative path to which files will be installed, below
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# the version specific component.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# For example, to install to /opt/onbld/lib/onbld/python*/bar/
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# PYTOPDIR = $(ROOTONBLDLIB)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# PYMODDIR = bar
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# It provides as output:
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# ROOTPYFILES - The list of $(ROOT)-relative paths to which python
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# source and binary files will be installed. Your
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# Makefile's 'install' target should depend upon
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# this.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# PYVERSOBJS - The list of paths to compiled python build products,
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# including their subdirectory.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# pyclobber - A target on which 'clobber' should depend, which
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# removes the per-version python directories and the
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe# output within them.
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe#
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard LowePYFILES = $(PYSRCS) $(PYOBJS)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
9f9230833b50b8271840dc2c12bd1e94d9df7d12Alexander PyhalovROOTPYDIR = $(PYTOPDIR)/python$(PYTHON_VERSION)/$(PYMODDIR)
9f9230833b50b8271840dc2c12bd1e94d9df7d12Alexander PyhalovROOTPYFILES = $(PYFILES:%=$(ROOTPYDIR)/%)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe$(ROOTPYFILES) := FILEMODE = 0444
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
9f9230833b50b8271840dc2c12bd1e94d9df7d12Alexander PyhalovPYVERSDIRS = python$(PYTHON_VERSION)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
9f9230833b50b8271840dc2c12bd1e94d9df7d12Alexander PyhalovPYVERSOBJS = $(PYOBJS:%=python$(PYTHON_VERSION)/%)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard LoweCLOBBERFILES += $(PYVERSOBJS)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard LoweCLOBBERDIRS += $(PYVERSDIRS)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe.KEEP_STATE:
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
9f9230833b50b8271840dc2c12bd1e94d9df7d12Alexander Pyhalovpython$(PYTHON_VERSION)/%.pyc: %.py
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe @[ -d $(@D) ] || mkdir $(@D)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe $(RM) $@
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe $(PYTHON) -mpy_compile $<
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe $(MV) $(*).pyc $@
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
9f9230833b50b8271840dc2c12bd1e94d9df7d12Alexander Pyhalov$(ROOTPYDIR)/%.pyc: python$(PYTHON_VERSION)/%.pyc
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe $(INS.pyfile)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
9f9230833b50b8271840dc2c12bd1e94d9df7d12Alexander Pyhalov$(ROOTPYDIR)/%.py: %.py
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe $(INS.pyfile)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowepyclobber:
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe $(RM) $(CLOBBERFILES)
87ab362234f761757d96ff1a758ab5c3bd85ed83Richard Lowe $(RM) -rf $(CLOBBERDIRS)