check_logfiles: 3.7.5.1
[omd.git] / packages / python-modules / Makefile
blob5bb6a4b07e60a39ccb03edea739d30b74e0dc504
1 include ../../Makefile.omd
3 NAME = python-modules
4 SHELL = /bin/bash
5 VERSION = $(OMD_VERSION)
6 DISTRO = $(shell ../../distro)
7 PYTHON = LD_LIBRARY_PATH=$(shell pwd)/../python/tmp.python27/lib \
8 $(shell pwd)/../python/tmp.python27/bin/python
9 TMP_INSTALL_PATH = $(shell pwd)/tmp.python
11 MODULES =
12 # Modules really needed on all platforms
13 MODULES += pysphere-0.1.7.zip
14 MODULES += pyasn1-0.1.7.tar.gz
15 MODULES += pycrypto-2.6.1.tar.gz
16 MODULES += pysnmp-4.2.4.tar.gz
18 # Modules needed because of own packed python (would be available in OS)
19 MODULES += setuptools-22.0.5.tar.gz # needed by rrdtool bindings
21 LEGACY_LDAP=0
22 ifeq ($(DISTRO_CODE),el5)
23 LEGACY_LDAP=1
24 endif
26 ifeq ($(LEGACY_LDAP), 1)
27 MODULES += python-ldap-2.3.13.tar.gz
28 SKIP_PATCH=patches/0001-python-ldap-2.4.25-disable-sasl.dif
29 else
30 MODULES += python-ldap-2.4.25.tar.gz
31 SKIP_PATCH=patches/0001-python-ldap-2.3.13-disable-sasl.dif
32 endif
34 build: check-python
35 mkdir -p dest
36 cd dest && \
37 for M in $(MODULES); do \
38 echo "Unpacking $$M..." ; \
39 if echo $$M | grep .tar.gz; then \
40 tar xvzf ../src/$$M ; \
41 else \
42 unzip -o ../src/$$M ; \
43 fi \
44 done
46 set -e ; for p in patches/*.dif ; do \
47 if [ $$p != $(SKIP_PATCH) ]; then \
48 echo "applying $$p..." ; \
49 ( cd dest ; patch -p1 -b ) < $$p ; \
50 fi ; \
51 done
52 set -e ; cd dest && \
53 mkdir -p $(TMP_INSTALL_PATH)/lib || true; \
54 export PYTHONPATH=$$PYTHONPATH:$(TMP_INSTALL_PATH)/lib ; \
55 export PYTHONPATH=$$PYTHONPATH:$(DESTDIR)$(OMD_ROOT)/lib/python ; \
56 export PYTHONPATH=$$PYTHONPATH:$(shell pwd)/../python/tmp.python27/lib/python2.7 ; \
57 export LDFLAGS="-L$(shell pwd)/../python/tmp.python27/lib -L$(shell pwd)/../python/tmp.python27/lib/python2.7/config" ; \
58 for M in $(MODULES); do \
59 echo "Building $$M..." ; \
60 PKG=$${M//.tar.gz/} ; \
61 PKG=$${PKG//.zip/} ; \
62 if [ $$PKG = pysnmp-git ]; then \
63 PKG=pysnmp-master ; \
64 fi ; \
65 cd $$PKG ; \
66 $(PYTHON) setup.py build ; \
67 $(PYTHON) setup.py install --home=$(TMP_INSTALL_PATH) \
68 --prefix='' \
69 --install-platlib=$(TMP_INSTALL_PATH)/lib \
70 --install-purelib=$(TMP_INSTALL_PATH)/lib ; \
71 cd .. ; \
72 done
74 check-python:
75 @if [ ! -d ../python/tmp.python27 ]; then \
76 echo "ERROR: You need to build the \"python\" package first" ; \
77 exit 1 ; \
80 install:
81 mkdir -p $(DESTDIR)$(OMD_ROOT)/lib/python
82 set -e ; cd dest && \
83 export PYTHONPATH=$$PYTHONPATH:$(TMP_INSTALL_PATH)/lib ; \
84 export PYTHONPATH=$$PYTHONPATH:$(DESTDIR)$(OMD_ROOT)/lib/python ; \
85 export PYTHONPATH=$$PYTHONPATH:$(shell pwd)/../python/tmp.python27/lib/python2.7 ; \
86 for M in $$(ls); do \
87 echo "Installing $$M..." ; \
88 cd $$M ; \
89 $(PYTHON) setup.py install --home=$(DESTDIR)$(OMD_ROOT) \
90 --prefix='' \
91 --install-platlib=$(DESTDIR)$(OMD_ROOT)/lib/python \
92 --install-purelib=$(DESTDIR)$(OMD_ROOT)/lib/python ; \
93 cd .. ; \
94 done
96 # Cleanup some unwanted files (example scripts)
97 rm -f $(DESTDIR)$(OMD_ROOT)/bin/*.py || true
99 # Fix python interpreter for kept scripts
100 for F in $(DESTDIR)$(OMD_ROOT)/bin/easy_install \
101 $(DESTDIR)$(OMD_ROOT)/bin/easy_install-2.7 \
102 $(DESTDIR)$(OMD_ROOT)/bin/libsmi2pysnmp \
103 $(DESTDIR)$(OMD_ROOT)/bin/pip \
104 ; do \
105 if [ -f $$F ]; then \
106 sed -i "1s|^#!.*python|#!/usr/bin/env python|" $$F; \
107 fi ; \
108 done
110 # Cleanup build time paths in easy-install.pth
111 sed -i 's|^/.*/\(.*\.egg\)$$|./\1|g' $(DESTDIR)$(OMD_ROOT)/lib/python/easy-install.pth
113 skel:
115 clean:
116 rm -rf dest tmp.python