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/coap3/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 tests/test_common.h 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 47man/.deps 48man/tmp 49src/.deps/ src/.libs/ 50tests/.deps/ 51" 52 53# checking for cleaner argument 54echo 55if [ "$1" = "--clean" ]; then 56 echo "removing autogenerated files ..." 57 rm -rf $AUTOGEN_FILES $AUTOGEN_DIRS 58 echo "done" 59 exit 60else 61 echo "[HINT] You can run 'autogen.sh --clean' to remove all generated files by the autotools." 62 echo 63fi 64 65# checking for autoreconf 66check_helper autoconf 67if [ "$RET" = "1" ]; then 68 echo "You probably need to install the package 'autoconf'." 69 ERROR=1 70else 71 echo "Found 'autoconf'." 72fi 73 74# checking for aclocal 75check_helper aclocal 76if [ "$RET" = "1" ]; then 77 echo "You probably need to install the package 'automake'." 78 ERROR=1 79else 80 echo "Found 'aclocal'." 81fi 82 83# checking for pkg-config 84check_helper pkg-config 85if [ "$RET" = "1" ]; then 86 echo "You probably need to install the package 'pkg-config|pkgconf'." 87 ERROR=1 88else 89 echo "Found 'pkg-config'." 90fi 91 92# checking for libtool 93# The libtool helper maybe installed as 'libtoolize', checking for 'libtool' first. 94check_helper libtool 95if [ "$RET" = "1" ]; then 96 # O.k. libtool not found, searching for libtoolize. 97 check_helper libtoolize 98 if [ "$RET" = "1" ]; then 99 echo "You probably need to install the package 'libtool'." 100 # That's bad, we found nothing! 101 ERROR=1 102 else 103 echo "Found 'libtoolize'." 104 break 105 fi 106else 107 echo "Found 'libtool'." 108fi 109 110# exit if one tool isn't available 111if [ "$ERROR" = "1" ]; then 112 echo 113 echo "One or more needed tools are missing, exiting ..." 114 echo "Please install the needed software packages and restart 'autogen.sh' again." 115 echo 116 exit 1 117fi 118 119echo 120echo " ---> Found all needed tools! That's fine." 121echo 122 123# countinue otherwise 124test -n "$srcdir" || srcdir=`dirname "$0"` 125test -n "$srcdir" || srcdir=. 126 127# Creating the directory m4 before calling autoreconf to 128# not struggle with old versions of aclocal. 129mkdir -p $srcdir/m4 130 131# create ar-lib if not present to avoid autoreconf throwing an error 132# when the file is missing. As autoreconf is called with --force 133# the file will get updated with the proper contents afterwards. 134touch ar-lib 135 136echo "Generating needed autotools files for $PROJECT by running autoreconf ..." 137autoreconf --force --install --verbose "$srcdir" 138 139echo 140echo "You can now run './configure --help' to see possible configuration options." 141echo "Otherwise process the configure script to create the makefiles and generated helper files." 142echo 143