Commit | Line | Data |
---|---|---|
8211c521 JT |
1 | #!/bin/bash -x |
2 | set -o errexit | |
3 | set -o nounset | |
4 | ||
5 | # where is the source? (todo: we could checkout from svn) | |
6 | ||
7 | LIBT2NSRC="$PWD" | |
8 | LIBT2N_EXAMPLES="$PWD/examples-codegen" | |
9 | EXAMPLES=2 | |
10 | ||
11 | # general settings | |
12 | ||
13 | # todo: safe temp dir creation | |
14 | INSTDIR="/tmp/jens-delme" | |
15 | BUILDDIR="$INSTDIR/build" | |
16 | mkdir "$INSTDIR" | |
17 | mkdir "$BUILDDIR" | |
18 | INSTPREFIX="$INSTDIR/usr" | |
19 | MAKE="dmake" | |
20 | DOCLEAN="false" | |
21 | ||
22 | function prepend() { | |
23 | if [ "x$1" = "x" ]; then | |
24 | echo "$2" | |
25 | else | |
26 | echo "$2:$1" | |
27 | fi | |
28 | } | |
29 | ||
30 | function 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 | |
44 | else | |
45 | $MAKE dist | |
46 | fi | |
47 | ||
48 | $MAKE install | |
49 | } | |
50 | ||
51 | # 1. build and install lib and codegen | |
52 | cd "$LIBT2NSRC" | |
53 | build | |
54 | echo "OK: library and code generator compiled and installed" | |
55 | ||
56 | # prepare environment to use installed libt2n and code generator in non-standard directory | |
57 | # temporarily disable nounset | |
58 | ||
59 | set +o nounset | |
60 | export PATH=$(prepend "$PATH" "$INSTPREFIX/bin") | |
61 | export LD_LIBRARY_PATH=$(prepend "$LD_LIBRARY_PATH" "$INSTPREFIX/lib") | |
62 | export PKG_CONFIG_PATH=$(prepend "$PKG_CONFIG_PATH" "$INSTPREFIX/lib/pkgconfig") | |
63 | set -o nounset | |
64 | ||
65 | for EXAMPLE in $(seq 1 $EXAMPLES); do | |
66 | ||
67 | # 2. build example | |
68 | ||
69 | cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE" "$BUILDDIR" | |
70 | cd "$BUILDDIR/example$EXAMPLE" | |
71 | build -M "$INSTPREFIX/share/aclocal" | |
72 | echo "OK: example $EXAMPLE using installed libt2n works" | |
73 | ||
74 | # 3. compile client using the now installed default lib | |
75 | cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE-client" "$BUILDDIR" | |
76 | cd "$BUILDDIR/example$EXAMPLE-client" | |
77 | build -M "$INSTPREFIX/share/aclocal" | |
78 | echo "OK: example $EXAMPLE using installed example lib works" | |
79 | ||
80 | # 4. test installed server and client | |
81 | libt2n-example$EXAMPLE-server & | |
82 | SPID="$!" | |
83 | # ugly | |
84 | sleep 1 | |
85 | if libt2n-example$EXAMPLE-client; then | |
86 | echo "installed client and server work" | |
87 | RET="0" | |
88 | else | |
89 | echo "installed client and server don't work" | |
90 | RET="1" | |
91 | fi | |
92 | kill "$SPID" | |
93 | if [ "$RET" = "1" ]; then | |
94 | exit 1 | |
95 | fi | |
96 | done | |
97 | ||
98 | echo Everything is fine |