# ********************************************************************** # # Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** # # If multiple versions of Python are installed and you want a specific # version to be used for building the Ice extension, set PYTHON to the # location of the python interpreter. # PYTHON ?= python # ---------------------------------------------------------------------- # Don't change anything below this line! # ---------------------------------------------------------------------- -include $(lang_srcdir)/config/Make.rules.$(os) python-call = $(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write($1)") PYTHON_VERSION ?= python$(PYTHON_BASE_VERSION) PYTHON_BASE_VERSION ?= $(call python-call,ds.get_python_version()) PYTHON_INCLUDE_DIR ?= $(call python-call,ds.get_python_inc()) PYTHON_LIB_DIR ?= $(call python-call,ds.get_config_var('LIBPL')) PYTHON_LIB_SUFFIX ?= $(call python-call,sys.__dict__['abiflags'] if 'abiflags' in sys.__dict__ else '') PYTHON_LIB_NAME ?= $(PYTHON_VERSION)$(PYTHON_LIB_SUFFIX) python_cppflags := -I$(PYTHON_INCLUDE_DIR) python_ldflags := -L$(PYTHON_LIB_DIR) -l$(PYTHON_LIB_NAME) # # Python installation directory # install_pythondir = $(if $(usr_dir_install),$(shell $(PYTHON) $(lang_srcdir)/config/install_dir),$(prefix)/python) # # Rules to build a python module. We just compute the name of the python module # and delegate to make-shared-module. # mkpymodulename ?= $(patsubst lib%,%,$(call mkshlibname,$(1))) make-shared-python-module = $(call make-shared-module,$(call mkpymodulename,$1),$2,$3,$4,$5,$6,$7,$8,$9) get-shared-python-module-targets = $(call get-shared-module-targets,$(call mkpymodulename,$1),$2,$3,$4) install-shared-python-module = $(call install-shared-module,$(call mkpymodulename,$1),$2,$3,$4,$5) $(DESTDIR)$(install_pythondir): $(Q)$(MKDIR) -p $@ installdirs += $(install_pythondir) # # $(call make-python-package,$1=slicedir,$2=generateddir,$3=package,$4=sliceflags) # # Compile slice files from $(slicedir)/ to python/. # define make-python-package $2/$3/.depend/%.ice.d: | $2/$3/.depend ; $2/$3/.depend: $(Q)$(MKDIR) -p $$@ .PRECIOUS: $2/$3/.depend/%.ice.d ifeq ($(filter %clean,$(MAKECMDGOALS)),) # Include the dependencies -include $(addprefix $2/.depend/,$(call source-to-dependency,$(wildcard $1/$3/*.ice))) endif $$(eval $$(call make-python-slice,$1,$2,$3,,$4)) distclean clean:: $(E) "Cleaning package $3" $(Q)$(RM) -r $2/$3/.depend $(Q)$(if $(findstring --no-package,$4),,$(RM) $2/$3/__init__.py) $(Q)$(RM) $(patsubst $1/$3/%.ice,$2/$3/%_ice.py,$(wildcard $1/$3/*.ice)) generate-srcs srcs all:: $(patsubst $1/$3/%.ice,$2/$3/%_ice.py,$(wildcard $1/$3/*.ice)) $$(eval $$(call install-data-files,$(patsubst $1/$3/%.ice,$2/$3/%_ice.py,$(wildcard $1/$3/*.ice)),$2,$(install_pythondir),install)) # If we also generate a package directory with an __init__.py, install it. ifeq ($(findstring --no-package,$4),) $$(eval $$(call install-data-files,$2/$3/__init__.py,$2,$(install_pythondir),install)) endif endef # # $(call make-python-slice,$1=slicedir,$2=generateddir,$3=package,$4=file,$5=sliceflags) # define make-python-slice $2/$3/$(or $4,%)_ice.py: $1/$3/$(or $4,%).ice $2/$3/.depend/$(or $4,%).ice.d $(slice2py_path) $(E) "Compiling $$<" $(Q)$(slice2py_path) -I$1 --output-dir $2 $5 --depend $$< > $2/$3/.depend/$(or $4,$$(*F)).ice.d $(Q)$(slice2py_path) -I$1 --output-dir $2 --checksum $5 $$< endef