blob: 5a6c34d00de4812525dcb832f56fa12c174302d6 [file] [log] [blame]
Andrew Jeffery22778042017-01-13 22:37:26 +10301#!/bin/sh
2
3AUTOCONF_FILES="Makefile.in aclocal.m4 ar-lib autom4te.cache compile \
4 config.guess config.h.in config.sub configure depcomp install-sh \
5 ltmain.sh missing *libtool test-driver"
6
Andrew Jeffery58b3cc02017-05-29 16:41:30 +09307BOOTSTRAP_MODE=""
8
9if [ $# -gt 0 ];
10then
11 BOOTSTRAP_MODE="${1}"
12 shift 1
13fi
14
15case "${BOOTSTRAP_MODE}" in
Andrew Jeffery81589cc2017-05-29 16:06:48 +093016 dev)
17 AX_CODE_COVERAGE_PATH="$(aclocal --print-ac-dir)"/ax_code_coverage.m4
18 if [ ! -e ${AX_CODE_COVERAGE_PATH} ];
19 then
20 echo "Failed to find AX_CODE_COVERAGE macro file at ${AX_CODE_COVERAGE_PATH}" 1>&2
21 exit 1
22 fi
23 LCOV_VERSION=$(lcov --version | tr ' ' '\n' | tail -1)
24
25 # Ubuntu Zesty ships with lcov v1.13, but Zesty's autoconf-archive
26 # package (the provider of the AX_CODE_COVERAGE macro) doesn't support
27 # it.
28 #
29 # sed-patch ax_code_coverage.m4 as it's GPLv3, and this is an Apache v2
30 # licensed repository. The licenses are not compatible in our desired
31 # direction[1].
32 #
33 # [1] https://www.apache.org/licenses/GPL-compatibility.html
34
35 cp ${AX_CODE_COVERAGE_PATH} m4/
36 sed -ri 's|(lcov_version_list=)"([ 0-9.]+)"$|\1"'${LCOV_VERSION}'"|' \
37 m4/ax_code_coverage.m4
38 ;;
Andrew Jeffery22778042017-01-13 22:37:26 +103039 clean)
40 test -f Makefile && make maintainer-clean
41 test -d linux && find linux -type d -empty | xargs -r rm -rf
42 for file in ${AUTOCONF_FILES}; do
43 find -name "$file" | xargs -r rm -rf
44 done
45 exit 0
46 ;;
Andrew Jeffery58b3cc02017-05-29 16:41:30 +093047 *) ;;
Andrew Jeffery22778042017-01-13 22:37:26 +103048esac
49
50autoreconf -i
Andrew Jeffery56b2aa32017-04-13 13:25:05 +093051
Andrew Jeffery58b3cc02017-05-29 16:41:30 +093052case "${BOOTSTRAP_MODE}" in
Andrew Jeffery56b2aa32017-04-13 13:25:05 +093053 dev)
Andrew Jefferybcefd402017-05-29 16:42:14 +093054 FLAGS="-fsanitize=address -fsanitize=leak -fsanitize=undefined -Wall -Werror"
Andrew Jeffery56b2aa32017-04-13 13:25:05 +093055 ./configure \
56 CPPFLAGS="-UNDEBUG" \
Andrew Jefferybcefd402017-05-29 16:42:14 +093057 CFLAGS="${FLAGS}" \
58 CXXFLAGS="${FLAGS}" \
Andrew Jeffery58b3cc02017-05-29 16:41:30 +093059 --enable-code-coverage \
60 "$@"
Andrew Jeffery56b2aa32017-04-13 13:25:05 +093061 ;;
62 *)
63 echo 'Run "./configure ${CONFIGURE_FLAGS} && make"'
64 ;;
65esac