Bump version to 0.3.5next
[archipelago] / xseg / sys / user / python / Makefile
1 # Copyright 2012 GRNET S.A. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or
4 # without modification, are permitted provided that the following
5 # conditions are met:
6 #
7 #   1. Redistributions of source code must retain the above
8 #      copyright notice, this list of conditions and the following
9 #      disclaimer.
10 #
11 #   2. Redistributions in binary form must reproduce the above
12 #      copyright notice, this list of conditions and the following
13 #      disclaimer in the documentation and/or other materials
14 #      provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28 #
29 # The views and conclusions contained in the software and
30 # documentation are those of the authors and should not be
31 # interpreted as representing official policies, either expressed
32 # or implied, of GRNET S.A.
33 #
34
35 .PHONY: default all clean install install-src
36
37 include $(XSEG_HOME)/base.mk
38
39 FILES="Makefile"
40 FILES+=$(shell ls *.py)
41
42 SUBDIR:=$(subst $(XSEG_HOME),,$(CURDIR))
43
44
45 H2XML = h2xml
46 XML2PY = xml2py
47
48 default: all
49
50 all: xseg/xseg_api.py xseg/xprotocol.py
51         if [ ! -e xseg/version.py ] ; then \
52                 echo '__version__ = "'`devflow-version python`'"' > xseg/version.py ; \
53         fi
54         python setup.py build
55
56 $(BASE)/sys/user/libxseg.so:
57         make -C $(BASE)/sys/user libxseg.so
58
59 xseg.xml: $(BASE)/xseg/xseg.h $(BASE)/xtypes/xq.h $(BASE)/xtypes/xlock.h \
60         $(BASE)/xtypes/xpool.h $(BASE)/xtypes/xhash.h \
61         $(BASE)/xtypes/xheap.h $(BASE)/xtypes/xobj.h \
62         $(BASE)/sys/domain.h $(BASE)/sys/util.h $(BASE)/sys/user/_sysutil.h $(BASE)/xseg/protocol.h
63         $(H2XML) -c $(INC) -o $@ $(BASE)/xseg/xseg.h
64
65 xprotocol.xml: 
66         $(H2XML) -c $(INC) -o $@ $(BASE)/xseg/protocol.h
67
68 xseg/xseg_api.py: xseg.xml
69         $(XML2PY) -d -k defst -l $(BASE)/lib/user/libxseg.so.$(MAJOR) -c $< -o $@
70         sed -i -e 's/xseg_get_data_nonstatic.restype = STRING/xseg_get_data_nonstatic.restype = POINTER(c_char)/g' xseg/xseg_api.py
71         sed -i -e 's/xseg_get_target_nonstatic.restype = STRING/xseg_get_target_nonstatic.restype = POINTER(c_char)/g' xseg/xseg_api.py
72         sed -i -e 's/xseg_get_signal_desc_nonstatic.restype = STRING/xseg_get_signal_desc_nonstatic.restype = POINTER(c_char)/g' xseg/xseg_api.py
73         sed -i -e 's/STRING = 1//g' xseg/xseg_api.py
74         sed -i -e 's,$(BASE)/lib/user/libxseg.so.$(MAJOR),libxseg.so.$(MAJOR),g' xseg/xseg_api.py
75
76
77 xseg/xprotocol.py: xprotocol.xml
78         $(XML2PY) -d -k defst -c $< -o $@
79         sed -i -e 's/xseg_reply_map_scatterlist \* 0/POINTER(xseg_reply_map_scatterlist)/g' xseg/xprotocol.py
80
81
82 install:
83         if [ ! -e xseg/version.py ] ; then \
84                 echo '__version__ = "'`devflow-version python`'"' > xseg/version.py ; \
85         fi
86         python setup.py install --install-layout=deb --root=$(DESTDIR)
87
88 install-src:
89         install -d $(DESTDIR)$(srcdir)$(SUBDIR) ;
90         @for f in $(FILES) ; do \
91                 install -o 0 -g 0 -m 644 -t $(DESTDIR)$(srcdir)$(SUBDIR) $$f ; \
92         done
93         install -d $(DESTDIR)$(srcdir)$(SUBDIR)/xseg ;
94         install -o 0 -g 0 -m 644 -t $(DESTDIR)$(srcdir)$(SUBDIR)/xseg xseg/__init__.py ; \
95
96
97
98 clean:
99         rm -rf build/ xseg.egg-info/ xseg.xml xprotocol.xml xseg/xseg_api.py \
100                 xseg/xseg_api.pyc xseg/xprotocol.py xseg/xprotocol.pyc \
101                 xseg/__init__.pyc