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. 24*00ff2212SAndy Fiddaman# Copyright 2018 OmniOS Community Edition (OmniOSce) Association. 2587ab3622SRichard Lowe# 2687ab3622SRichard Lowe 2787ab3622SRichard Lowe# 2887ab3622SRichard Lowe# This Makefile provides a framework for building the onbld python 2987ab3622SRichard Lowe# modules with multiple versions of python. 3087ab3622SRichard Lowe# 3187ab3622SRichard Lowe# It expects as input: 3287ab3622SRichard Lowe# 3387ab3622SRichard Lowe# PYSRCS - List of python source files, these are also delivered as 3487ab3622SRichard Lowe# build product. 3587ab3622SRichard Lowe# 3687ab3622SRichard Lowe# PYOBJS - List of compiled python (.pyc) files, with no directory prefix 3787ab3622SRichard Lowe# 3887ab3622SRichard Lowe# PYTOPDIR - Absolute (including $(ROOT)) path to which files will 3987ab3622SRichard Lowe# be installed, up until the version specific component. 4087ab3622SRichard Lowe# 4187ab3622SRichard Lowe# PYMODDIR - Relative path to which files will be installed, below 4287ab3622SRichard Lowe# the version specific component. 4387ab3622SRichard Lowe# 4487ab3622SRichard Lowe# For example, to install to /opt/onbld/lib/onbld/python*/bar/ 4587ab3622SRichard Lowe# 4687ab3622SRichard Lowe# PYTOPDIR = $(ROOTONBLDLIB) 4787ab3622SRichard Lowe# PYMODDIR = bar 4887ab3622SRichard Lowe# 4987ab3622SRichard Lowe# 5087ab3622SRichard Lowe# It provides as output: 5187ab3622SRichard Lowe# 5287ab3622SRichard Lowe# ROOTPYFILES - The list of $(ROOT)-relative paths to which python 5387ab3622SRichard Lowe# source and binary files will be installed. Your 5487ab3622SRichard Lowe# Makefile's 'install' target should depend upon 5587ab3622SRichard Lowe# this. 5687ab3622SRichard Lowe# 5787ab3622SRichard Lowe# PYVERSOBJS - The list of paths to compiled python build products, 5887ab3622SRichard Lowe# including their subdirectory. 5987ab3622SRichard Lowe# 6087ab3622SRichard Lowe# pyclobber - A target on which 'clobber' should depend, which 6187ab3622SRichard Lowe# removes the per-version python directories and the 6287ab3622SRichard Lowe# output within them. 6387ab3622SRichard Lowe# 6487ab3622SRichard Lowe 6587ab3622SRichard LowePYFILES = $(PYSRCS) $(PYOBJS) 6687ab3622SRichard Lowe 67*00ff2212SAndy FiddamanROOTPYDIR = $(PYTOPDIR)/python$(PYVER)/$(PYMODDIR) 6824bb1048SAlexander PyhalovROOTPYFILES = $(PYFILES:%=$(ROOTPYDIR)/%) 6987ab3622SRichard Lowe 7087ab3622SRichard Lowe$(ROOTPYFILES) := FILEMODE = 0444 7187ab3622SRichard Lowe 72*00ff2212SAndy FiddamanPYVERSDIRS = python$(PYVER) 7387ab3622SRichard Lowe 74*00ff2212SAndy FiddamanPYVERSOBJS = $(PYOBJS:%=python$(PYVER)/%) 7587ab3622SRichard Lowe 7687ab3622SRichard LoweCLOBBERFILES += $(PYVERSOBJS) 7787ab3622SRichard LoweCLOBBERDIRS += $(PYVERSDIRS) 7887ab3622SRichard Lowe 7987ab3622SRichard Lowe.KEEP_STATE: 8087ab3622SRichard Lowe 81*00ff2212SAndy Fiddaman$(ROOTPYDIR)/%.py: ../%.py 8287ab3622SRichard Lowe $(INS.pyfile) 8387ab3622SRichard Lowe 8487ab3622SRichard Lowepyclobber: 8587ab3622SRichard Lowe $(RM) $(CLOBBERFILES) 8687ab3622SRichard Lowe $(RM) -rf $(CLOBBERDIRS) 87*00ff2212SAndy Fiddaman 88*00ff2212SAndy Fiddaman# Python 2 module compilation 89*00ff2212SAndy Fiddaman 90*00ff2212SAndy Fiddamanpython$(PYVER)/%.pyc: ../%.py 91*00ff2212SAndy Fiddaman @[ -d $(@D) ] || mkdir $(@D) 92*00ff2212SAndy Fiddaman $(RM) $@ 93*00ff2212SAndy Fiddaman $(PYTHON) -mpy_compile $< 94*00ff2212SAndy Fiddaman $(MV) ../$(*).pyc $@ 95*00ff2212SAndy Fiddaman 96*00ff2212SAndy Fiddaman$(ROOTPYDIR)/%.pyc: python$(PYVER)/%.pyc 97*00ff2212SAndy Fiddaman $(INS.pyfile) 98*00ff2212SAndy Fiddaman 99*00ff2212SAndy Fiddaman# Python 3 module compilation 100*00ff2212SAndy Fiddaman 101*00ff2212SAndy Fiddamanpython$(PYVER)/__pycache__/%.cpython$(PYPKGVERS).pyc: ../%.py 102*00ff2212SAndy Fiddaman @[ -d $(@D) ] || mkdir -p $(@D) 103*00ff2212SAndy Fiddaman $(RM) $@ 104*00ff2212SAndy Fiddaman $(PYTHON3) -mpy_compile $< 105*00ff2212SAndy Fiddaman $(MV) ../__pycache__/$(*).cpython$(PYPKGVERS).pyc $@ 106*00ff2212SAndy Fiddaman 107*00ff2212SAndy Fiddaman$(ROOTPYDIR)/__pycache__/%.pyc: python$(PYVER)/__pycache__/%.pyc 108*00ff2212SAndy Fiddaman $(INS.pyfile) 109*00ff2212SAndy Fiddaman 110