1238106Sdes#
2238106Sdes# Makefile: compilation of pyUnbound and documentation, testing
3238106Sdes#
4238106Sdes# Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
5238106Sdes#                     Marek Vavrusa  (xvavru00 AT stud.fit.vutbr.cz)
6238106Sdes#
7238106Sdes# This software is open source.
8238106Sdes# 
9238106Sdes# Redistribution and use in source and binary forms, with or without
10238106Sdes# modification, are permitted provided that the following conditions
11238106Sdes# are met:
12238106Sdes# 
13238106Sdes#    * Redistributions of source code must retain the above copyright notice,
14238106Sdes#      this list of conditions and the following disclaimer.
15238106Sdes# 
16238106Sdes#    * Redistributions in binary form must reproduce the above copyright notice,
17238106Sdes#      this list of conditions and the following disclaimer in the documentation
18238106Sdes#      and/or other materials provided with the distribution.
19238106Sdes# 
20238106Sdes#    * Neither the name of the organization nor the names of its
21238106Sdes#      contributors may be used to endorse or promote products derived from this
22238106Sdes#      software without specific prior written permission.
23238106Sdes#
24238106Sdes# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25238106Sdes# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26238106Sdes# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27238106Sdes# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
28238106Sdes# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29238106Sdes# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30238106Sdes# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31238106Sdes# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32238106Sdes# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33238106Sdes# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34238106Sdes# POSSIBILITY OF SUCH DAMAGE.
35238106Sdes
36238106Sdeshelp:
37238106Sdes	@echo "Please use \`make <target>' where <target> is one of"
38238106Sdes	@echo "  testenv   to make test environment and run bash "
39294190Sdes	@echo "            useful in case you don't want to install unbound but want to test examples"
40238106Sdes	@echo "  doc       to make documentation"
41238106Sdes	@echo "  clean     clean all"
42238106Sdes
43238106Sdes.PHONY: testenv clean doc swig
44238106Sdes
45238106Sdes#_unbound.so:	../../Makefile
46238106Sdes	#$(MAKE) -C ../..
47238106Sdes
48238106Sdes#../../.libs/libunbound.so.0:	../../Makefile
49238106Sdes	#$(MAKE) -C ../..
50238106Sdes
51238106Sdesclean:
52238106Sdes	rm -rdf examples/unbound
53238106Sdes	rm -f _unbound.so libunbound_wrap.o
54238106Sdes	$(MAKE) -C ../.. clean
55238106Sdes
56291767Sdestestenv: ../../.libs/libunbound.so.2 ../../.libs/_unbound.so
57238106Sdes	rm -rdf examples/unbound
58291767Sdes	cd examples && mkdir unbound && ln -s ../../unbound.py unbound/__init__.py && ln -s ../../_unbound.so unbound/_unbound.so && ln -s ../../../../.libs/libunbound.so.2 unbound/libunbound.so.2 && ls -la
59238106Sdes	cd examples && if test -f ../../../.libs/_unbound.so; then cp ../../../.libs/_unbound.so . ; fi
60238106Sdes	@echo "Run a script by typing ./script_name.py"
61238106Sdes	cd examples && LD_LIBRARY_PATH=unbound bash
62238106Sdes	rm -rdf examples/unbound examples/_unbound.so
63238106Sdes
64238106Sdesdoc: ../../.libs/libunbound.so.0 _unbound.so
65238106Sdes	$(MAKE) -C docs html
66238106Sdes
67238106Sdes#for development only
68238106Sdesswig: libunbound.i 
69238106Sdes	swig -python -o libunbound_wrap.c -I../.. libunbound.i
70238106Sdes	gcc -c libunbound_wrap.c -O9 -fPIC -I../.. -I/usr/include/python2.5 -I. -o libunbound_wrap.o
71238106Sdes	gcc -shared libunbound_wrap.o -L../../.libs -lunbound -o _unbound.so 
72238106Sdes
73