1b0d9d94065e0addfdb9001a5fa54d5a2218e55d
[openwrt/svn-archive/archive.git] / lang / python / python-package.mk
1 #
2 # Copyright (C) 2007 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id$
8
9 ifeq ($(DUMP),)
10
11 PYTHON:=$(STAGING_DIR)/usr/bin/hostpython
12
13 PYTHON_VERSION=2.5
14
15 PYTHON_INC_DIR:=$(STAGING_DIR)/usr/include/python$(PYTHON_VERSION)
16 PYTHON_LIB_DIR:=$(STAGING_DIR)/usr/lib/python$(PYTHON_VERSION)
17
18 PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
19
20 endif
21
22 define PyPackage
23 NAME:=$(1)
24 $(eval $(call PyPackage/$(1)))
25
26 define Package/$(1)
27 SUBMENU:=Python
28 TITLE:=$(TITLE)
29 SECTION:=lang
30 CATEGORY:=Languages
31 DEPENDS:=python
32 $(call PyPackage/$(1))
33 endef
34
35 ifdef PyPackage/$(1)/description
36 define Package/$(1)/description
37 $(call PyPackage/$(1)/description)
38 endef
39 endif
40
41 $(call shexport,PyPackage/$(1)/filespec)
42
43 define Package/$(1)/install
44 @getvar $$(call shvar,PyPackage/$(1)/filespec) | ( \
45 IFS='|'; \
46 while read fop fspec fperm; do \
47 if [ "$$$$$$$$fop" = "+" ]; then \
48 dpath=`dirname "$$$$$$$$fspec"`; \
49 if [ -n "$$$$$$$$fperm" ]; then \
50 dperm="-m$$$$$$$$fperm"; \
51 else \
52 dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
53 fi; \
54 mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
55 echo "copying: '$$$$$$$$fspec'"; \
56 cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
57 if [ -n "$$$$$$$$fperm" ]; then \
58 chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
59 fi; \
60 elif [ "$$$$$$$$fop" = "-" ]; then \
61 echo "removing: '$$$$$$$$fspec'"; \
62 rm -fR $$(1)$$$$$$$$fspec; \
63 elif [ "$$$$$$$$fop" = "=" ]; then \
64 echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
65 chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
66 fi; \
67 done; \
68 )
69 $(call PyPackage/$(1)/install,$$(1))
70 endef
71
72 $$(eval $$(call BuildPackage,$(1)))
73 endef
74
75 define Build/Compile/PyMod
76 ( cd $(PKG_BUILD_DIR)/$(1); \
77 CFLAGS="$(TARGET_CFLAGS)" \
78 CPPFLAGS="$(TARGET_CPPFLAGS)" \
79 LDFLAGS="$(TARGET_LDFLAGS)" \
80 $(3) \
81 $(PYTHON) ./setup.py $(2) \
82 );
83 endef