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 sed -ri 's|(lcov_version_list=)"([ 0-9.]+)"$|\1"'${LCOV_VERSION}'"|' \ 39 m4/ax_code_coverage.m4 40 ;; 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 ;; 49 *) ;; 50esac 51 52autoreconf -i 53 54case "${BOOTSTRAP_MODE}" in 55 dev) 56 FLAGS="-fsanitize=address -fsanitize=leak -fsanitize=undefined -Wall -Werror" 57 ./configure \ 58 CFLAGS="${FLAGS}" \ 59 CXXFLAGS="${FLAGS}" \ 60 --enable-code-coverage \ 61 "$@" 62 ;; 63 *) 64 echo 'Run "./configure ${CONFIGURE_FLAGS} && make"' 65 ;; 66esac 67