1 #!/bin/sh 2 3 # Check -V option. 4 . "${srcdir=.}/init.sh" 5 6 run_prog_skip_if_failed date +%Y > /dev/null 7 year="$(date +%Y)" 8 9 run_strace -V > "$LOG" 10 11 getstr() 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. 22 getoption() 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 34 config_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 41 option_unwind=$(getoption USE_LIBUNWIND " stack-unwind") 42 option_demangle=$(getoption USE_DEMANGLE " stack-demangle") 43 44 option_m32= 45 option_mx32= 46 case "$STRACE_NATIVE_ARCH" in 47 x86_64) 48 option_m32=$(getoption HAVE_M32_MPERS ' m32-mpers' ' no-m32-mpers') 49 option_mx32=$(getoption HAVE_MX32_MPERS ' mx32-mpers' ' no-mx32-mpers') 50 ;; 51 aarch64|powerpc64|riscv|s390x|sparc64|tile|x32) 52 option_m32=$(getoption HAVE_M32_MPERS ' m32-mpers' ' no-m32-mpers') 53 ;; 54 esac 55 56 features="${option_unwind}${option_demangle}${option_m32}${option_mx32}" 57 [ -n "$features" ] || features=" (none)" 58 59 cat > "$EXP" << __EOF__ 60 $(getstr PACKAGE_NAME) -- version $(getstr PACKAGE_VERSION) 61 Copyright (c) 1991-${config_year} The strace developers <$(getstr PACKAGE_URL)>. 62 This is free software; see the source for copying conditions. There is NO 63 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 64 65 Optional features enabled:${features} 66 __EOF__ 67 68 match_diff "$LOG" "$EXP" 69