Andrew Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Andrew Jeffery | 72b854b | 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 | 58b3cc0 | 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 | 81589cc | 2017-05-29 16:06:48 +0930 | [diff] [blame] | 18 | dev) |
| 19 | AX_CODE_COVERAGE_PATH="$(aclocal --print-ac-dir)"/ax_code_coverage.m4 |
Patrick Williams | ad5dd0f | 2022-12-04 15:07:33 -0600 | [diff] [blame] | 20 | if [ ! -e "${AX_CODE_COVERAGE_PATH}" ]; |
Andrew Jeffery | 81589cc | 2017-05-29 16:06:48 +0930 | [diff] [blame] | 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 | |
Patrick Williams | ad5dd0f | 2022-12-04 15:07:33 -0600 | [diff] [blame] | 37 | cp "${AX_CODE_COVERAGE_PATH}" m4/ |
| 38 | # shellcheck disable=SC2086 |
Andrew Jeffery | 81589cc | 2017-05-29 16:06:48 +0930 | [diff] [blame] | 39 | sed -ri 's|(lcov_version_list=)"([ 0-9.]+)"$|\1"'${LCOV_VERSION}'"|' \ |
| 40 | m4/ax_code_coverage.m4 |
| 41 | ;; |
Andrew Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 42 | clean) |
| 43 | test -f Makefile && make maintainer-clean |
Patrick Williams | ad5dd0f | 2022-12-04 15:07:33 -0600 | [diff] [blame] | 44 | test -d linux && find linux -type d -empty -exec rm -rf {} \; |
Andrew Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 45 | for file in ${AUTOCONF_FILES}; do |
Patrick Williams | ad5dd0f | 2022-12-04 15:07:33 -0600 | [diff] [blame] | 46 | find . -name "$file" -exec rm -rf {} \; |
Andrew Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 47 | done |
| 48 | exit 0 |
| 49 | ;; |
Andrew Jeffery | 58b3cc0 | 2017-05-29 16:41:30 +0930 | [diff] [blame] | 50 | *) ;; |
Andrew Jeffery | 2277804 | 2017-01-13 22:37:26 +1030 | [diff] [blame] | 51 | esac |
| 52 | |
| 53 | autoreconf -i |
Andrew Jeffery | 56b2aa3 | 2017-04-13 13:25:05 +0930 | [diff] [blame] | 54 | |
Andrew Jeffery | 58b3cc0 | 2017-05-29 16:41:30 +0930 | [diff] [blame] | 55 | case "${BOOTSTRAP_MODE}" in |
Andrew Jeffery | 56b2aa3 | 2017-04-13 13:25:05 +0930 | [diff] [blame] | 56 | dev) |
Andrew Jeffery | bcefd40 | 2017-05-29 16:42:14 +0930 | [diff] [blame] | 57 | FLAGS="-fsanitize=address -fsanitize=leak -fsanitize=undefined -Wall -Werror" |
Andrew Jeffery | 56b2aa3 | 2017-04-13 13:25:05 +0930 | [diff] [blame] | 58 | ./configure \ |
Andrew Jeffery | bcefd40 | 2017-05-29 16:42:14 +0930 | [diff] [blame] | 59 | CFLAGS="${FLAGS}" \ |
| 60 | CXXFLAGS="${FLAGS}" \ |
Andrew Jeffery | 58b3cc0 | 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 | *) |
Patrick Williams | ad5dd0f | 2022-12-04 15:07:33 -0600 | [diff] [blame] | 65 | # shellcheck disable=SC2016 |
Andrew Jeffery | 56b2aa3 | 2017-04-13 13:25:05 +0930 | [diff] [blame] | 66 | echo 'Run "./configure ${CONFIGURE_FLAGS} && make"' |
| 67 | ;; |
| 68 | esac |