X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=test-build-install-use;h=b45957e2d6fbc383b0fb2e6e0a644a12757781ae;hp=15c0ddfab7bc6207468deee249838d909d1d384a;hb=c7857475c8b0f02cac3ce29a617a4d542fa59f37;hpb=ad17f52360ddd6f3fa75be5cc7baf72c5dc8e59f diff --git a/test-build-install-use b/test-build-install-use index 15c0ddf..b45957e 100755 --- a/test-build-install-use +++ b/test-build-install-use @@ -2,46 +2,99 @@ set -o errexit set -o nounset +# where is the source? (todo: we could checkout from svn) + +LIBT2NSRC="$PWD" +LIBT2N_EXAMPLES="$PWD/examples-codegen" +EXAMPLES=2 + +# general settings + # todo: safe temp dir creation INSTDIR="/tmp/jens-delme" +BUILDDIR="$INSTDIR/build" mkdir "$INSTDIR" -INSTPREFIX="/tmp/jens-delme/usr" -MAKE="dmake -d" -./configure --prefix="$INSTPREFIX" -$MAKE dist -$MAKE install - -VERSION="0.1" -TARFILE="libt2n-$VERSION.tar.gz" -cp "$TARFILE" "$INSTDIR" +mkdir "$BUILDDIR" +INSTPREFIX="$INSTDIR/usr" +MAKE="dmake" +DOCLEAN="true" -# now build example-client using installed libt2n -cd "$INSTDIR" - -function append() { +function prepend() { if [ "x$1" = "x" ]; then echo "$2" else - echo "$1:$2" + echo "$2:$1" fi } +function build() { + # newer autoreconf (autoconf) versions don't have the -M option and no real replacement :-( + # (you can only set ACLOCAL_AMFLAGS in the Makefile.am) + # todo: this IMHO should be filed as bug against autoconf + # ugly workaround + autoreconf -f -i $@ || { aclocal --force $(echo "$@"|sed 's,-M,-I,') && libtoolize --copy --force && autoconf --force && automake --add-missing --copy --force-missing; } + ./configure --prefix="$INSTPREFIX" + if $DOCLEAN; then + $MAKE distclean + ./configure --prefix="$INSTPREFIX" + $MAKE clean + # ensure make clean works twice (did not work at some point) + $MAKE clean + + # todo: at the moment distcheck does not work on a distclean source + $MAKE + $MAKE clean + $MAKE distcheck + fi + + $MAKE install +} -# adjust some environment variables -# (this is needed because we installed in non-standard directories) +# 1. build and install lib and codegen +cd "$LIBT2NSRC" +build +echo "OK: library and code generator compiled and installed" +# prepare environment to use installed libt2n and code generator in non-standard directory # temporarily disable nounset + set +o nounset -export PATH=$(append "$PATH" "$INSTPREFIX/bin") -export LD_LIBRARY_PATH=$(append "$LD_LIBRARY_PATH" "$INSTPREFIX/lib") -export PKG_CONFIG_PATH=$(append "$PKG_CONFIG_PATH" "$INSTPREFIX/lib/pkgconfig") +export PATH=$(prepend "$PATH" "$INSTPREFIX/bin") +export LD_LIBRARY_PATH=$(prepend "$LD_LIBRARY_PATH" "$INSTPREFIX/lib") +export PKG_CONFIG_PATH=$(prepend "$PKG_CONFIG_PATH" "$INSTPREFIX/lib/pkgconfig") set -o nounset -tar xzvf "$TARFILE" -mv "libt2n-$VERSION/example-codegen" . -cd example-codegen -autoreconf -f -i -M "$INSTDIR/usr/share/aclocal" -./configure -# todo: at the moment running make dist on clean source does not work -$MAKE -$MAKE distcheck +for EXAMPLE in $(seq 1 $EXAMPLES); do + + # 2. build example + + cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE" "$BUILDDIR" + cd "$BUILDDIR/example$EXAMPLE" + build -M "$INSTPREFIX/share/aclocal" + echo "OK: example $EXAMPLE using installed libt2n works" + + # 3. compile client using the now installed default lib + cp -af "$LIBT2N_EXAMPLES/example$EXAMPLE-client" "$BUILDDIR" + cd "$BUILDDIR/example$EXAMPLE-client" + build -M "$INSTPREFIX/share/aclocal" + echo "OK: example $EXAMPLE using installed example lib works" + + # 4. test installed server and client + libt2n-example$EXAMPLE-server & + SPID="$!" + # ugly + sleep 1 + if libt2n-example$EXAMPLE-client; then + echo "installed client and server work" + RET="0" + else + echo "installed client and server don't work" + RET="1" + fi + kill "$SPID" + if [ "$RET" = "1" ]; then + exit 1 + fi +done + +echo Everything is fine