• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/Makefile examples/Makefile.in
30include/coap2/coap.h
31install-sh
32libcoap-*.pc libtool ltmain.sh
33man/coap*.[357] man/coap*.txt man/Makefile man/Makefile.in
34missing
35Makefile Makefile.in
36stamp-h1 src/.dirstamp libcoap*.la* src/*.*o
37tests/*.o tests/Makefile tests/Makefile.in tests/testdriver
38tests/oss-fuzz/Makefile.ci
39m4/libtool.m4 m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4
40"
41
42AUTOGEN_DIRS="
43.deps
44.libs autom4te.cache/
45doc/html/
46examples/.deps/ examples/.libs
47src/.deps/ src/.libs/
48tests/.deps/
49"
50
51# checking for cleaner argument
52echo
53if [ "$1" = "--clean" ]; then
54    echo "removing autogerated files ..."
55    rm -rf $AUTOGEN_FILES $AUTOGEN_DIRS
56    echo "done"
57    exit
58else
59    echo "[HINT] You can run 'autogen.sh --clean' to remove all generated files by the autotools."
60    echo
61fi
62
63# checking for autoreconf
64check_helper autoconf
65if [ "$RET" = "1" ]; then
66    echo "You probably need to install the package 'autoconf'."
67    ERROR=1
68else
69    echo "Found 'autoconf'."
70fi
71
72# checking for aclocal
73check_helper aclocal
74if [ "$RET" = "1" ]; then
75    echo "You probably need to install the package 'automake'."
76    ERROR=1
77else
78    echo "Found 'aclocal'."
79fi
80
81# checking for pkg-config
82check_helper pkg-config
83if [ "$RET" = "1" ]; then
84    echo "You probably need to install the package 'pkg-config|pkgconf'."
85    ERROR=1
86else
87    echo "Found 'pkg-config'."
88fi
89
90# checking for libtool
91# The libtool helper maybe installed as 'libtoolize', checking for 'libtool' first.
92check_helper libtool
93if [ "$RET" = "1" ]; then
94    # O.k. libtool not found, searching for libtoolize.
95    check_helper libtoolize
96    if [ "$RET" = "1" ]; then
97        echo "You probably need to install the package 'libtool'."
98        # That's bad, we found nothing!
99        ERROR=1
100    else
101        echo "Found 'libtoolize'."
102        break
103    fi
104else
105    echo "Found 'libtool'."
106fi
107
108# exit if one tool isn't available
109if [ "$ERROR" = "1" ]; then
110    echo
111    echo "One or more needed tools are missing, exiting ..."
112    echo "Please install the needed software packages and restart 'autogen.sh' again."
113    echo
114    exit 1
115fi
116
117echo
118echo "  --->  Found all needed tools! That's fine."
119echo
120
121# countinue otherwise
122test -n "$srcdir" || srcdir=`dirname "$0"`
123test -n "$srcdir" || srcdir=.
124
125# Creating the directory m4 before calling autoreconf to
126# not struggle with old versions of aclocal.
127mkdir -p $srcdir/m4
128
129echo "Generating needed autotools files for $PROJECT by running autoreconf ..."
130autoreconf --force --install --verbose "$srcdir"
131
132echo
133echo "You can now run 'configure --help' to see possible configuration options."
134echo "Otherwise process the configure script to create the makefiles and generated helper files."
135echo
136