Andrew Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Andrew Jeffery | 57d608b | 2017-05-29 16:56:36 +0930 | [diff] [blame] | 3 | set -eu |
| 4 | |
Andrew Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 5 | AUTOCONF_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 Jeffery | b18ab44 | 2017-05-29 16:41:30 +0930 | [diff] [blame] | 9 | BOOTSTRAP_MODE="" |
| 10 | |
| 11 | if [ $# -gt 0 ]; |
| 12 | then |
| 13 | BOOTSTRAP_MODE="${1}" |
| 14 | shift 1 |
| 15 | fi |
| 16 | |
| 17 | case "${BOOTSTRAP_MODE}" in |
Andrew Jeffery | 942223f | 2017-05-29 16:06:48 +0930 | [diff] [blame^] | 18 | 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 Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 41 | 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 Jeffery | b18ab44 | 2017-05-29 16:41:30 +0930 | [diff] [blame] | 49 | *) ;; |
Andrew Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 50 | esac |
| 51 | |
| 52 | autoreconf -i |
Andrew Jeffery | 56b2aa3 | 2017-04-13 13:25:05 +0930 | [diff] [blame] | 53 | |
Andrew Jeffery | b18ab44 | 2017-05-29 16:41:30 +0930 | [diff] [blame] | 54 | case "${BOOTSTRAP_MODE}" in |
Andrew Jeffery | 56b2aa3 | 2017-04-13 13:25:05 +0930 | [diff] [blame] | 55 | dev) |
Andrew Jeffery | 385b46e | 2017-05-29 16:42:14 +0930 | [diff] [blame] | 56 | FLAGS="-fsanitize=address -fsanitize=leak -fsanitize=undefined -Wall -Werror" |
Andrew Jeffery | 56b2aa3 | 2017-04-13 13:25:05 +0930 | [diff] [blame] | 57 | ./configure \ |
| 58 | CPPFLAGS="-UNDEBUG" \ |
Andrew Jeffery | 385b46e | 2017-05-29 16:42:14 +0930 | [diff] [blame] | 59 | CFLAGS="${FLAGS}" \ |
| 60 | CXXFLAGS="${FLAGS}" \ |
Andrew Jeffery | b18ab44 | 2017-05-29 16:41:30 +0930 | [diff] [blame] | 61 | --enable-code-coverage \ |
| 62 | "$@" |
Andrew Jeffery | 56b2aa3 | 2017-04-13 13:25:05 +0930 | [diff] [blame] | 63 | ;; |
| 64 | *) |
| 65 | echo 'Run "./configure ${CONFIGURE_FLAGS} && make"' |
| 66 | ;; |
| 67 | esac |