1#!/bin/sh -e
2
3# uncomment the set command for debugging
4#set -x
5
6# function to check for needed helper tools
7check_helper() {
8#echo "Checking for $1 ..."
9TOOL=`which "$1" || echo none`
10
11if [ "$TOOL" = "none" ]; then
12    echo
13    echo "Couldn't find '$1'!"
14    RET=1
15else
16    RET=0
17fi
18}
19
20PROJECT="libcoap"
21
22AUTOGEN_FILES="
23INSTALL
24aclocal.m4 ar-lib
25coap_config.h coap_config.h.in* compile config.guess config.h* config.log config.status config.sub configure
26depcomp
27doc/Doxyfile doc/doxyfile.stamp doc/doxygen_sqlite3.db doc/Makefile doc/Makefile.in
28examples/*.o  examples/coap-client examples/coap-server examples/coap-rd
29examples/coap-*.5 examples/coap-*.txt examples/Makefile.in
30include/coap/coap.h
31install-sh
32libcoap-1.pc libtool ltmain.sh
33missing
34Makefile Makefile.in
35stamp-h1 src/.dirstamp libcoap*.la* src/*.*o
36tests/*.o tests/Makefile tests/testdriver
37m4/libtool.m4 m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4
38"
39
40AUTOGEN_DIRS="
41.deps
42.libs autom4te.cache/
43doc/html/
44examples/.deps/ examples/.libs
45src/.deps/ src/.libs/
46tests/.deps/
47"
48
49# checking for cleaner argument
50echo
51if [ "$1" = "--clean" ]; then
52    echo "removing autogerated files ..."
53    rm -rf $AUTOGEN_FILES $AUTOGEN_DIRS
54    echo "done"
55    exit
56else
57    echo "[HINT] You can run 'autogen.sh --clean' to remove all generated files by the autotools."
58    echo
59fi
60
61# checking for autoreconf
62check_helper autoconf
63if [ "$RET" = "1" ]; then
64    echo "You probably need to install the package 'autoconf'."
65    ERROR=1
66else
67    echo "Found 'autoconf'."
68fi
69
70# checking for aclocal
71check_helper aclocal
72if [ "$RET" = "1" ]; then
73    echo "You probably need to install the package 'automake'."
74    ERROR=1
75else
76    echo "Found 'aclocal'."
77fi
78
79# checking for libtool
80# The libtool helper maybe installed as 'libtoolize', checking for 'libtool' first.
81check_helper libtool
82if [ "$RET" = "1" ]; then
83    # O.k. libtool not found, searching for libtoolize.
84    check_helper libtoolize
85    if [ "$RET" = "1" ]; then
86        echo "You probably need to install the package 'libtool'."
87        # That's bad, we found nothing!
88        ERROR=1
89    else
90        echo "Found 'libtoolize'."
91        break
92    fi
93else
94    echo "Found 'libtool'."
95fi
96
97# exit if one tool isn't available
98if [ "$ERROR" = "1" ]; then
99    echo
100    echo "One or more needed tools are missing, exiting ..."
101    echo "Please install the needed software packages and restart 'autogen.sh' again."
102    echo
103    exit
104fi
105
106echo
107echo "  --->  Found all needed tools! That's fine."
108echo
109
110# countinue otherwise
111test -n "$srcdir" || srcdir=`dirname "$0"`
112test -n "$srcdir" || srcdir=.
113
114# Creating the directory m4 before calling autoreconf to
115# not struggle with old versions of aclocal.
116mkdir -p $srcdir/m4
117
118echo "Generating needed autotools files for $PROJECT by running autoreconf ..."
119autoreconf --force --install --verbose "$srcdir"
120
121echo
122echo "You can now run 'configure --help' to see possible configuration options."
123echo "Otherwise process the configure script to create the makefiles and generated helper files."
124echo
125