added apache and python
[librewrt/.git] / packages / lang / python / files / 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
8 PYTHON_VERSION=2.6
9
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)
14
15 PYTHON:=python$(PYTHON_VERSION)
16
17 PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
18
19 define PyPackage
20   $(call shexport,PyPackage/$(1)/filespec)
21
22   define Package/$(1)/install
23         @$(SH_FUNC) getvar $$(call shvar,PyPackage/$(1)/filespec) | ( \
24                 IFS='|'; \
25                 while read fop fspec fperm; do \
26                   if [ "$$$$$$$$fop" = "+" ]; then \
27                         dpath=`dirname "$$$$$$$$fspec"`; \
28                         if [ -n "$$$$$$$$fperm" ]; then \
29                           dperm="-m$$$$$$$$fperm"; \
30                         else \
31                           dperm=`stat -c "%a" $(PKG_INSTALL_DIR)$$$$$$$$dpath`; \
32                         fi; \
33                         mkdir -p $$$$$$$$$dperm $$(1)$$$$$$$$dpath; \
34                         echo "copying: '$$$$$$$$fspec'"; \
35                         cp -fpR $(PKG_INSTALL_DIR)$$$$$$$$fspec $$(1)$$$$$$$$dpath/; \
36                         if [ -n "$$$$$$$$fperm" ]; then \
37                           chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
38                         fi; \
39                   elif [ "$$$$$$$$fop" = "-" ]; then \
40                         echo "removing: '$$$$$$$$fspec'"; \
41                         rm -fR $$(1)$$$$$$$$fspec; \
42                   elif [ "$$$$$$$$fop" = "=" ]; then \
43                         echo "setting permissions: '$$$$$$$$fperm' on '$$$$$$$$fspec'"; \
44                         chmod -R $$$$$$$$fperm $$(1)$$$$$$$$fspec; \
45                   fi; \
46                 done; \
47         )
48         $(call PyPackage/$(1)/install,$$(1))
49   endef
50 endef
51
52 define Build/Compile/PyMod
53         ( cd $(PKG_BUILD_DIR)/$(1); \
54                 CFLAGS="$(TARGET_CFLAGS)" \
55                 CPPFLAGS="$(TARGET_CPPFLAGS)" \
56                 LDFLAGS="$(TARGET_LDFLAGS)" \
57                 $(3) \
58                 $(PYTHON) ./setup.py $(2) && \
59                 find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f \
60         );
61 endef