• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2
3# This script creates a libcoap archive, unpacks it and does an
4# out-of-tree build and installation afterwards. The environment
5# variables PLATFORM, TESTS, TLS and DOCS control the build
6# configuration. Suggested invocation from travis CI is:
7#
8# PLATFORM=posix TESTS=yes TLS=no DOCS=yes scripts/dist.sh
9#
10# Copyright (C) 2018 Olaf Bergmann <bergmann@tzi.org>
11#
12# This file is part of the CoAP C library libcoap. Please see README
13# and COPYING for terms of use.
14#
15
16if test "x${PLATFORM}" != "xposix"; then
17    exit 0
18fi
19
20# where to install the library
21WORK=`pwd`/libcoap-build
22mkdir -p $WORK || exit 1
23PREFIX="--prefix=`pwd`/libcoap-installation"
24SILENT="--enable-silent-rules"
25
26WITH_TESTS="`scripts/fix-cunit.sh` --enable-tests"
27test -f `pwd`/cunit.pc && echo cat `pwd`/cunit.pc
28
29case "x${TLS}" in
30    xno)       WITH_TLS="--disable-dtls"
31               ;;
32    xopenssl)  WITH_TLS="--with-openssl"
33               ;;
34    xgnutls)   WITH_TLS="--with-gnutls"
35               ;;
36    xmbedtls)  WITH_TLS="--with-mbedtls"
37               ;;
38    xtinydtls) WITH_TLS="--with-tinydtls --disable-shared"
39               ;;
40    *)         WITH_TLS="--with-gnutls"
41               ;;
42esac
43
44case "x${DOCS}" in
45    xyes)      WITH_DOCS="--enable-documentation"
46               ;;
47    *)         WITH_DOCS="--disable-documentation"
48               ;;
49esac
50
51config() {
52    echo "./configure $*"
53    ./configure $* || cat config.log
54}
55
56work_dir=$PWD
57config "$WITH_TESTS $SILENT --enable-documentation --enable-examples --disable-dtls" && make dist
58
59err=$?
60ARCHIVE=`ls -1t libcoap-*.tar.bz2 |head -1`
61echo $ARCHIVE
62if test $err = 0 -a "x$ARCHIVE" != "x"; then
63    DIR=`pwd`/`tar taf $ARCHIVE |cut -d/ -f1|head -1`
64    tar xaf $ARCHIVE && cd $WORK && \
65        $DIR/configure $PREFIX $WITH_TESTS $SILENT $WITH_DOCS --enable-examples $WITH_TLS && \
66        make && make install
67    err=$?
68fi
69
70exit $err
71