1#!/bin/sh 2 3set -eu 4 5AUTOCONF_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 9BOOTSTRAP_MODE="" 10 11if [ $# -gt 0 ]; 12then 13 BOOTSTRAP_MODE="${1}" 14 shift 1 15fi 16 17case "${BOOTSTRAP_MODE}" in 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 # shellcheck disable=SC2086 39 sed -ri 's|(lcov_version_list=)"([ 0-9.]+)"$|\1"'${LCOV_VERSION}'"|' \ 40 m4/ax_code_coverage.m4 41 ;; 42 clean) 43 test -f Makefile && make maintainer-clean 44 test -d linux && find linux -type d -empty -exec rm -rf {} \; 45 for file in ${AUTOCONF_FILES}; do 46 find . -name "$file" -exec rm -rf {} \; 47 done 48 exit 0 49 ;; 50 *) ;; 51esac 52 53autoreconf -i 54 55case "${BOOTSTRAP_MODE}" in 56 dev) 57 FLAGS="-fsanitize=address -fsanitize=leak -fsanitize=undefined -Wall -Werror" 58 ./configure \ 59 CFLAGS="${FLAGS}" \ 60 CXXFLAGS="${FLAGS}" \ 61 --enable-code-coverage \ 62 "$@" 63 ;; 64 *) 65 # shellcheck disable=SC2016 66 echo 'Run "./configure ${CONFIGURE_FLAGS} && make"' 67 ;; 68esac 69