2 # Copyright (C) 2007 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
10 PYTHON_DIR:=$(STAGING_DIR)/usr
11 PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin
12 PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
13 PYTHON_LIB_DIR:=$(PYTHON_DIR)/lib/python$(PYTHON_VERSION)
15 PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
17 PYTHON:=python$(PYTHON_VERSION)
19 HOST_PYTHON_BIN:=$(STAGING_DIR)/usr/bin/hostpython
22 ( export PYTHONPATH="$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR)"; \
23 export PYTHONOPTIMIZE=""; \
24 export PYTHONDONTWRITEBYTECODE=1; \
26 $(HOST_PYTHON_BIN) $(2); \
31 $(call shexport,PyPackage/$(1)/filespec)
33 define Package/$(1)/install
34 @$(SH_FUNC) getvar $$(call shvar,PyPackage/$(1)/filespec) | ( \
36 while read fop fspec fperm; do \
37 if [ "$$$$$$$$fop" = "+" ]; then \
38 dpath=`dirname "$$$$$$$$fspec"`; \
39 if [ -n "$$$$$$$$fperm" ]; then \
40 dperm="-m$$$$$$$$fperm"; \
42 dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
44 mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
45 echo "copying: '$$$$$$$$fspec'"; \
46 cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
47 if [ -n "$$$$$$$$fperm" ]; then \
48 chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
50 elif [ "$$$$$$$$fop" = "-" ]; then \
51 echo "removing: '$$$$$$$$fspec'"; \
52 rm -fR $$(1)$$$$$$$$fspec; \
53 elif [ "$$$$$$$$fop" = "=" ]; then \
54 echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
55 chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
59 $(call PyPackage/$(1)/install,$$(1))
63 # $(1) => build subdir
64 # $(2) => additional arguments to setup.py
65 # $(3) => additional variables
66 define Build/Compile/PyMod
68 cd $(PKG_BUILD_DIR)/$(strip $(1)); \
69 CFLAGS="$(TARGET_CFLAGS)" \
70 CPPFLAGS="$(TARGET_CPPFLAGS)" \
71 LDFLAGS="$(TARGET_LDFLAGS)" \
76 find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f