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