doxygen documentation cannot be built using a seperate build directory but we do...
[libt2n] / test-build-install-use
CommitLineData
8211c521
JT
1#!/bin/bash -x
2set -o errexit
3set -o nounset
4
5# where is the source? (todo: we could checkout from svn)
6
7LIBT2NSRC="$PWD"
8LIBT2N_EXAMPLES="$PWD/examples-codegen"
9EXAMPLES=2
10
11# general settings
12
13# todo: safe temp dir creation
14INSTDIR="/tmp/jens-delme"
15BUILDDIR="$INSTDIR/build"
16mkdir "$INSTDIR"
17mkdir "$BUILDDIR"
18INSTPREFIX="$INSTDIR/usr"
19MAKE="dmake"
20DOCLEAN="false"
21
22function prepend() {
23 if [ "x$1" = "x" ]; then
24 echo "$2"
25 else
26 echo "$2:$1"
27 fi
28}
29
30function build() {
31 autoreconf -f -i $@
32 ./configure --prefix="$INSTPREFIX"
33 if $DOCLEAN; then
34 $MAKE distclean
35 ./configure --prefix="$INSTPREFIX"
36 $MAKE clean
37 # ensure make clean works twice (did not work at some point)
38 $MAKE clean
39
40 # todo: at the moment distcheck does not work on a distclean source
41 $MAKE
42 $MAKE clean
43 $MAKE distcheck
8211c521
JT
44 fi
45
46 $MAKE install
47}
48
49# 1. build and install lib and codegen
50cd "$LIBT2NSRC"
51build
52echo "OK: library and code generator compiled and installed"
53
54# prepare environment to use installed libt2n and code generator in non-standard directory
55# temporarily disable nounset
56
57set +o nounset
58export PATH=$(prepend "$PATH" "$INSTPREFIX/bin")
59export LD_LIBRARY_PATH=$(prepend "$LD_LIBRARY_PATH" "$INSTPREFIX/lib")
60export PKG_CONFIG_PATH=$(prepend "$PKG_CONFIG_PATH" "$INSTPREFIX/lib/pkgconfig")
61set -o nounset
62
63for EXAMPLE in $(seq 1 $EXAMPLES); do
64
65 # 2. build example
66
67 cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE" "$BUILDDIR"
68 cd "$BUILDDIR/example$EXAMPLE"
69 build -M "$INSTPREFIX/share/aclocal"
70 echo "OK: example $EXAMPLE using installed libt2n works"
71
72 # 3. compile client using the now installed default lib
73 cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE-client" "$BUILDDIR"
74 cd "$BUILDDIR/example$EXAMPLE-client"
75 build -M "$INSTPREFIX/share/aclocal"
76 echo "OK: example $EXAMPLE using installed example lib works"
77
78 # 4. test installed server and client
79 libt2n-example$EXAMPLE-server &
80 SPID="$!"
81 # ugly
82 sleep 1
83 if libt2n-example$EXAMPLE-client; then
84 echo "installed client and server work"
85 RET="0"
86 else
87 echo "installed client and server don't work"
88 RET="1"
89 fi
90 kill "$SPID"
91 if [ "$RET" = "1" ]; then
92 exit 1
93 fi
94done
95
96echo Everything is fine