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