scripts/showSamples.sh
author Bart vdr. Meulen <bartvdrmeulen@gmail.com>
Sun Aug 02 16:45:43 2009 +0200 (2009-08-02)
changeset 1434 7e7290acccc1
parent 1188 a954ea1de05f
child 1519 d07d99f74f19
permissions -rwxr-xr-x
fix wrapper script for symlinks

The wrapper script placed around the target binaries when
using the companion libraries does not work for symbolic links
The wrapper scripts needs to follow the links before calling the
actual binary

Signed-off-by: Bart vdr. Meulen <bartvdrmeulen@gmail.com>

---
     1 #!/bin/sh
     2 # Yes, this is supposed to be a POSIX-compliant shell script.
     3 
     4 # Parses all samples on the command line, and for each of them, prints
     5 # the versions of the main tools
     6 
     7 # Use tools discovered by ./configure
     8 . "${CT_LIB_DIR}/paths.mk"
     9 
    10 [ "$1" = "-v" ] && opt="$1" && shift
    11 [ "$1" = "-w" ] && opt="$1" && shift
    12 
    13 # GREP_OPTIONS screws things up.
    14 export GREP_OPTIONS=
    15 
    16 # Dump a single sample
    17 dump_single_sample() {
    18     local verbose=0
    19     [ "$1" = "-v" ] && verbose=1 && shift
    20     [ "$1" = "-w" ] && wiki=1 && shift
    21     local width="$1"
    22     local sample="$2"
    23     if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then
    24         sample_top="${CT_TOP_DIR}"
    25         sample_type="l"
    26     else
    27         sample_top="${CT_LIB_DIR}"
    28         sample_type="g"
    29     fi
    30     . "${sample_top}/samples/${sample}/crosstool.config"
    31     if [ -z "${wiki}" ]; then
    32         printf "    %-*s  [%s" ${width} "${sample}" "${sample_type}"
    33         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf " "
    34         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf " "
    35         echo "]"
    36         if [ ${verbose} -ne 0 ]; then
    37             case "${CT_TOOLCHAIN_TYPE}" in
    38                 cross)  ;;
    39                 canadian)
    40                     printf "    Host      : ${CT_HOST}\n"
    41                     ;;
    42             esac
    43             echo    "    OS        : ${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}"
    44             if [ "${CT_GMP_MPFR}" = "y" ]; then
    45                 echo    "    GMP/MPFR  : gmp-${CT_GMP_VERSION} / mpfr-${CT_MPFR_VERSION}"
    46             fi
    47             echo    "    binutils  : binutils-${CT_BINUTILS_VERSION}"
    48             printf  "    C compiler: ${CT_CC}-${CT_CC_VERSION} (C"
    49             [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
    50             [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
    51             [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
    52             [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
    53             [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
    54             [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
    55             [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
    56             echo    ")"
    57             echo    "    C library : ${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}"
    58             printf  "    Tools     :"
    59             [ "${CT_LIBELF}"  ] && printf " libelf-${CT_LIBELF_VERSION}"
    60             [ "${CT_SSTRIP}"  ] && printf " sstrip"
    61             [ "${CT_DMALLOC}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}"
    62             [ "${CT_DUMA}"    ] && printf " duma-${CT_DUMA_VERSION}"
    63             [ "${CT_GDB}"     ] && printf " gdb-${CT_GDB_VERSION}"
    64             [ "${CT_LTRACE}"  ] && printf " ltrace-${CT_LTRACE_VERSION}"
    65             [ "${CT_STRACE}"  ] && printf " strace-${CT_STRACE_VERSION}"
    66             echo
    67         fi
    68     else
    69         printf "| ''${sample}''  "
    70         printf "|  "
    71         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X"
    72         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B"
    73         printf '  |  '
    74         case "${CT_TOOLCHAIN_TYPE}" in
    75             cross)      ;;
    76             canadian)   printf "${CT_HOST}";;
    77             *)          ;;
    78         esac
    79         printf "  |  ''${CT_KERNEL}''  |"
    80         if [ "${CT_KERNEL}" != "bare-metal" ];then
    81             if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
    82                 printf "  //custom//  "
    83             else
    84                 printf "  ${CT_KERNEL_VERSION}  "
    85             fi
    86         fi
    87         printf "|  ${CT_BINUTILS_VERSION}  "
    88         printf "|  ''${CT_CC}''  "
    89         printf "|  ${CT_CC_VERSION}  "
    90         printf "|  ''${CT_LIBC}''  |"
    91         if [ "${CT_LIBC}" != "none" ]; then
    92             printf "  ${CT_LIBC_VERSION}  "
    93         fi
    94         printf "|  ${CT_THREADS:-none}  "
    95         printf "|  ${CT_ARCH_FLOAT_HW:+hard}${CT_ARCH_FLOAT_SW:+soft} float  "
    96         printf "|  C"
    97         [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ", C++"
    98         [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran"
    99         [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ", Java"
   100         [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ", ADA"
   101         [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ", Objective-C"
   102         [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ", Objective-C++"
   103         [ -n "${CT_CC_LANG_OTHERS}"     ] && printf "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}"
   104         printf "  "
   105         ( . "${sample_top}/samples/${sample}/reported.by"
   106           if [ -n "${reporter_name}" ]; then
   107               if [ -n "${reporter_url}" ]; then
   108                   printf "|  [[${reporter_url}|${reporter_name}]]  "
   109               else
   110                   printf "|  ${reporter_name}  "
   111               fi
   112           else
   113               printf "|  [[http://ymorin.is-a-geek.org/|YEM]]  "
   114           fi
   115         )
   116         sample_updated="$( hg log -l 1 --template '{date|shortdate}' "${sample_top}/samples/${sample}" )"
   117         printf "|  ${sample_updated}  "
   118         echo "|"
   119     fi
   120 }
   121 
   122 # Get largest sample width
   123 width=0
   124 for sample in "${@}"; do
   125     [ ${#sample} -gt ${width} ] && width=${#sample}
   126 done
   127 
   128 if [ "${opt}" = -w ]; then
   129     echo "^ @@DATE@@  ^ |||||||||||||"
   130     printf "^ Target "
   131     printf "^  Status  "
   132     printf "^  Host  "
   133     printf "^  Kernel headers\\\\\\\\ version  ^"
   134     printf "^  binutils\\\\\\\\ version  "
   135     printf "^  C compiler\\\\\\\\ version  ^"
   136     printf "^  C library\\\\\\\\ version  ^"
   137     printf "^  Threading\\\\\\\\ model  "
   138     printf "^  Floating point\\\\\\\\ support  "
   139     printf "^  Languages  "
   140     printf "^  Initially\\\\\\\\ reported by  "
   141     printf "^  Last\\\\\\\\ updated  "
   142     echo   "^"
   143 fi
   144 
   145 for sample in "${@}"; do
   146     ( dump_single_sample ${opt} ${width} "${sample}" )
   147 done
   148 
   149 if [ "${opt}" = -w ]; then
   150     printf "^ Total: ${#@} samples  | ''X'': sample uses features marked as being EXPERIMENTAL.\\\\\\\\ ''B'': sample is curently BROKEN. |||||||||||||"
   151     echo   ""
   152 elif [ -z "${opt}" ]; then
   153     echo '      l (local)       : sample was found in current directory'
   154     echo '      g (global)      : sample was installed with crosstool-NG'
   155     echo '      X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
   156     echo '      B (BROKEN)      : sample is currently broken'
   157 fi