| 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 " useful 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 examples/test_pkt.py examples/test_resolver.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 |
@cd examples && LD_LIBRARY_PATH=ldns ./test_pkt.py 2>/dev/null |
| 70 |
@cd examples && LD_LIBRARY_PATH=ldns ./test_resolver.py 2>/dev/null |
| 71 |
@rm -rf examples/ldns |
| 72 |
|
| 73 |
doc: ../../.libs/libldns.so.1 _ldns.so |
| 74 |
echo @VERSION_MAJOR@ |
| 75 |
rm -f _ldns.so |
| 76 |
ln -s ../../.libs/_ldns.so |
| 77 |
$(MAKE) -C docs html |
| 78 |
rm -f _ldns.so |
| 79 |
|
| 80 |
# For development only: |
| 81 |
|
| 82 |
# Test environment, does not build the wrapper from dependencies. |
| 83 |
te: |
| 84 |
rm -rf examples/ldns |
| 85 |
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 |
| 86 |
@echo "Run a script by typing ./script_name.py" |
| 87 |
cd examples && LD_LIBRARY_PATH=ldns bash |
| 88 |
rm -rf examples/ldns |
| 89 |
|
| 90 |
# Builds Python 2 wrapper from present wrapper C code. |
| 91 |
bw: |
| 92 |
gcc -c ldns_wrapper.c -O9 -fPIC -I../.. -I../../ldns -I/usr/include/python2.7 -I. -o ldns_wrapper.o |
| 93 |
mkdir -p ../../.libs |
| 94 |
ld -shared ldns_wrapper.o -L../../.libs -lldns -o ../../.libs/_ldns.so |
| 95 |
|
| 96 |
# Builds Python 3 wrapper from present wrapper C code. |
| 97 |
bw3: |
| 98 |
gcc -c ldns_wrapper.c -O9 -fPIC -I../.. -I../../ldns -I/usr/include/python3.2 -I. -o ldns_wrapper.o |
| 99 |
mkdir -p ../../.libs |
| 100 |
ld -shared ldns_wrapper.o -L../../.libs -ldns -o ../../.libs/_ldns.so |
| 101 |
|
| 102 |
# Builds Python 2 wrapper from interface file. |
| 103 |
sw: ldns.i |
| 104 |
swig -python -o ldns_wrapper.c -I../.. ldns.i |
| 105 |
$(MAKE) bw |
| 106 |
|
| 107 |
# Builds Python 3 wrapper from interface file. |
| 108 |
sw3: ldns.i |
| 109 |
swig -python -py3 -DPY3 -o ldns_wrapper.c -I../.. ldns.i |
| 110 |
$(MAKE) bw3 |