]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/python/Makefile
import ldns 1.6.16
[FreeBSD/FreeBSD.git] / contrib / python / Makefile
1 # Makefile: compilation of sources and documentation, test environment
2 #
3 # Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
4 #                     Karel Slany    (slany AT fit.vutbr.cz)
5 # All rights reserved.
6
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9
10 #     * Redistributions of source code must retain the above copyright notice,
11 #       this list of conditions and the following disclaimer.
12 #     * Redistributions in binary form must reproduce the above copyright
13 #       notice, this list of conditions and the following disclaimer in the
14 #       documentation and/or other materials provided with the distribution.
15 #     * Neither the name of the organization nor the names of its
16 #       contributors may be used to endorse or promote products derived from this
17 #       software without specific prior written permission.
18
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 # POSSIBILITY OF SUCH DAMAGE.
30
31
32 .PHONY: help clean testenv test doc te bw bw3 sw sw3
33
34 help:
35         @echo "Please use \`make <target>' where <target> is one of"
36         @echo "  testenv   to make test environment and run bash "
37         @echo "            usefull in case you don't want to install ldns but want to test examples"
38         @echo "  doc       to make documentation"
39         @echo "  clean     clean all"
40
41 ../../Makefile: ../../configure
42         cd ../.. && ./configure --with-python
43         
44 _ldns.so:       ../../Makefile
45         $(MAKE) -C ../..
46
47 ../../.libs/libldns.so.1:       ../../Makefile
48         $(MAKE) -C ../..
49
50 clean:
51         rm -rf examples/ldns
52         rm -f _ldns.so ldns_wrapper.o
53         $(MAKE) -C ../.. clean
54
55 testenv: ../../.libs/libldns.so.1 _ldns.so
56         rm -rf examples/ldns
57         cd examples && mkdir ldns && ln -s ../../ldns.py ldns/__init__.py && ln -s ../../../../.libs/_ldns.so ldns/_ldns.so && ln -s ../../../../.libs/libldns.so.1 ldns/libldns.so.1 && ls -la
58         @echo "Run a script by typing ./script_name.py"
59         cd examples && LD_LIBRARY_PATH=ldns bash
60         rm -rf examples/ldns
61
62 test: ../../.libs/libldns.so.1 _ldns.so examples/test_buffer.py examples/test_rdf.py examples/test_dname.py examples/test_rr.py
63         @rm -rf examples/ldns
64         @cd examples && mkdir ldns && ln -s ../../ldns.py ldns/__init__.py && ln -s ../../../../.libs/_ldns.so ldns/_ldns.so && ln -s ../../../../.libs/libldns.so.1 ldns/libldns.so.1
65         @cd examples && LD_LIBRARY_PATH=ldns ./test_buffer.py 2>/dev/null
66         @cd examples && LD_LIBRARY_PATH=ldns ./test_rdf.py 2>/dev/null
67         @cd examples && LD_LIBRARY_PATH=ldns ./test_dname.py 2>/dev/null
68         @cd examples && LD_LIBRARY_PATH=ldns ./test_rr.py 2>/dev/null
69         @rm -rf examples/ldns
70
71 doc: ../../.libs/libldns.so.1 _ldns.so
72         echo @VERSION_MAJOR@
73         rm -f _ldns.so
74         ln -s ../../.libs/_ldns.so
75         $(MAKE) -C docs html
76         rm -f _ldns.so
77
78 # For development only:
79
80 # Test environment, does not build the wrapper from dependencies.
81 te:
82         rm -rf examples/ldns
83         cd examples && mkdir ldns && ln -s ../../ldns.py ldns/__init__.py && ln -s ../../../../.libs/_ldns.so ldns/_ldns.so && ln -s ../../../../.libs/libldns.so.1 ldns/libldns.so.1 && ls -la
84         @echo "Run a script by typing ./script_name.py"
85         cd examples && LD_LIBRARY_PATH=ldns bash
86         rm -rf examples/ldns
87
88 # Builds Python 2 wrapper from present wrapper C code.
89 bw:
90         gcc -c ldns_wrapper.c -O9 -fPIC -I../.. -I../../ldns -I/usr/include/python2.7 -I. -o ldns_wrapper.o
91         mkdir -p ../../.libs
92         ld -shared ldns_wrapper.o -L../../.libs -lldns -o ../../.libs/_ldns.so
93
94 # Builds Python 3 wrapper from present wrapper C code.
95 bw3:
96         gcc -c ldns_wrapper.c -O9 -fPIC -I../.. -I../../ldns -I/usr/include/python3.2 -I. -o ldns_wrapper.o
97         mkdir -p ../../.libs
98         ld -shared ldns_wrapper.o -L../../.libs -ldns -o ../../.libs/_ldns.so
99
100 # Builds Python 2 wrapper from interface file.
101 sw: ldns.i
102         swig -python -o ldns_wrapper.c -I../.. ldns.i
103         $(MAKE) bw
104
105 # Builds Python 3 wrapper from interface file.
106 sw3: ldns.i
107         swig -python -py3 -DPY3 -o ldns_wrapper.c -I../.. ldns.i
108         $(MAKE) bw3