newer automake versions define a seperate additional variable DEFAULT_INCLUDES =...
[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() {
5abe4a1f
JT
31 # newer autoreconf (autoconf) versions don't have the -M option and no replacement :-(
32 # todo: this IMHO should be filed as bug against autoconf
33 # ugly workaround
177f7aeb 34 autoreconf -f -i $@ || (autoreconf -f -i && aclocal --force $(echo "$@"|sed 's,-M,-I,'))
8211c521
JT
35 ./configure --prefix="$INSTPREFIX"
36 if $DOCLEAN; then
37 $MAKE distclean
38 ./configure --prefix="$INSTPREFIX"
39 $MAKE clean
40 # ensure make clean works twice (did not work at some point)
41 $MAKE clean
42
43 # todo: at the moment distcheck does not work on a distclean source
44 $MAKE
45 $MAKE clean
46 $MAKE distcheck
8211c521
JT
47 fi
48
49 $MAKE install
50}
51
52# 1. build and install lib and codegen
53cd "$LIBT2NSRC"
54build
55echo "OK: library and code generator compiled and installed"
56
57# prepare environment to use installed libt2n and code generator in non-standard directory
58# temporarily disable nounset
59
60set +o nounset
61export PATH=$(prepend "$PATH" "$INSTPREFIX/bin")
62export LD_LIBRARY_PATH=$(prepend "$LD_LIBRARY_PATH" "$INSTPREFIX/lib")
63export PKG_CONFIG_PATH=$(prepend "$PKG_CONFIG_PATH" "$INSTPREFIX/lib/pkgconfig")
64set -o nounset
65
66for EXAMPLE in $(seq 1 $EXAMPLES); do
67
68 # 2. build example
69
70 cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE" "$BUILDDIR"
71 cd "$BUILDDIR/example$EXAMPLE"
72 build -M "$INSTPREFIX/share/aclocal"
73 echo "OK: example $EXAMPLE using installed libt2n works"
74
75 # 3. compile client using the now installed default lib
76 cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE-client" "$BUILDDIR"
77 cd "$BUILDDIR/example$EXAMPLE-client"
78 build -M "$INSTPREFIX/share/aclocal"
79 echo "OK: example $EXAMPLE using installed example lib works"
80
81 # 4. test installed server and client
82 libt2n-example$EXAMPLE-server &
83 SPID="$!"
84 # ugly
85 sleep 1
86 if libt2n-example$EXAMPLE-client; then
87 echo "installed client and server work"
88 RET="0"
89 else
90 echo "installed client and server don't work"
91 RET="1"
92 fi
93 kill "$SPID"
94 if [ "$RET" = "1" ]; then
95 exit 1
96 fi
97done
98
99echo Everything is fine