1#!/bin/sh 2 3# Check -V option. 4. "${srcdir=.}/init.sh" 5 6run_prog_skip_if_failed date +%Y > /dev/null 7year="$(date +%Y)" 8 9run_strace -V > "$LOG" 10 11getstr() 12{ 13 sed -r -n 's/#define[[:space:]]*'"$1"'[[:space:]]*"([^"]*)".*/\1/p' \ 14 ../../config.h 15} 16 17# getoption OPTION YES_STRING [NO_STRING] 18# 19# Returns YES_STRING in case OPTION is enabled (present in config.h and has 20# a non-zero numeric value). Otherwise, NO_STRING (or empty string, if not 21# specified) is returned. 22getoption() 23{ 24 local opt 25 opt=$(sed -r -n 's/#define[[:space:]]*'"$1"'[[:space:]]*([0-9]+)$/\1/p' \ 26 ../../config.h) 27 if [ -n "$opt" -a "$opt" -ne 0 ]; then 28 printf "%s" "$2" 29 else 30 printf "%s" "${3-}" 31 fi 32} 33 34config_year=$(getstr COPYRIGHT_YEAR) 35 36[ "$year" -ge "$config_year" ] && [ "$config_year" -ge 2017 ] || { 37 echo >&2 "The year derived from config.h (${config_year}) does not pass sanity checks." 38 exit 1 39} 40 41option_unwind=$(getoption ENABLE_STACKTRACE \ 42 " stack-trace=$(getstr USE_UNWINDER)") 43option_demangle=$(getoption USE_DEMANGLE " stack-demangle") 44 45option_m32= 46option_mx32= 47case "$STRACE_NATIVE_ARCH" in 48x86_64) 49 option_m32=$(getoption HAVE_M32_MPERS ' m32-mpers' ' no-m32-mpers') 50 option_mx32=$(getoption HAVE_MX32_MPERS ' mx32-mpers' ' no-mx32-mpers') 51 ;; 52aarch64|powerpc64|riscv|s390x|sparc64|tile|x32) 53 option_m32=$(getoption HAVE_M32_MPERS ' m32-mpers' ' no-m32-mpers') 54 ;; 55esac 56 57features="${option_unwind}${option_demangle}${option_m32}${option_mx32}" 58[ -n "$features" ] || features=" (none)" 59 60cat > "$EXP" << __EOF__ 61$(getstr PACKAGE_NAME) -- version $(getstr PACKAGE_VERSION) 62Copyright (c) 1991-${config_year} The strace developers <$(getstr PACKAGE_URL)>. 63This is free software; see the source for copying conditions. There is NO 64warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 65 66Optional features enabled:${features} 67__EOF__ 68 69match_diff "$LOG" "$EXP" 70