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