scripts/showSamples.sh
author Titus von Boxberg <tvb377@gmx.de>
Wed Feb 03 00:24:24 2010 +0100 (2010-02-03)
changeset 1799 226c8f5861e5
parent 1788 9547490131d9
child 1804 da584d1d6ab8
permissions -rwxr-xr-x
scripts: use kernel name (uname -s) when system name (uname -o) is not availabe

'uname -o' is a GNU extension.
     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     case "${sample}" in
    24         current)
    25             sample_type="l"
    26             sample="${current_tuple}"
    27             width="${#sample}"
    28             . .config
    29             ;;
    30         *)  if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then
    31                 sample_top="${CT_TOP_DIR}"
    32                 sample_type="l"
    33             else
    34                 sample_top="${CT_LIB_DIR}"
    35                 sample_type="g"
    36             fi
    37             . "${sample_top}/samples/${sample}/crosstool.config"
    38             ;;
    39     esac
    40     if [ -z "${wiki}" ]; then
    41         t_width=13
    42         printf "%-*s  [%s" ${width} "${sample}" "${sample_type}"
    43         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "B" || printf " "
    44         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "X" || printf " "
    45         echo "]"
    46         if [ ${verbose} -ne 0 ]; then
    47             case "${CT_TOOLCHAIN_TYPE}" in
    48                 cross)  ;;
    49                 canadian)
    50                     printf "    %-*s : %s\n" ${t_width} "Host" "${CT_HOST}"
    51                     ;;
    52             esac
    53             printf "    %-*s : %s\n" ${t_width} "OS" "${CT_KERNEL}${CT_KERNEL_VERSION:+-}${CT_KERNEL_VERSION}"
    54             if [ "${CT_GMP_MPFR}" = "y" ]; then
    55                 printf    "    %-*s : %s\n" ${t_width} "GMP/MPFR" "gmp-${CT_GMP_VERSION} / mpfr-${CT_MPFR_VERSION}"
    56             fi
    57             if [ "${CT_PPL_CLOOG_MPC}" = "y" ]; then
    58                 printf    "    %-*s : %s\n" ${t_width} "PPL/CLOOG/MPC" "ppl-${CT_PPL_VERSION} / cloog-${CT_CLOOG_VERSION} / mpc-${CT_MPC_VERSION}"
    59             fi
    60             printf  "    %-*s : %s\n" ${t_width} "binutils" "binutils-${CT_BINUTILS_VERSION}"
    61             printf  "    %-*s : %s" ${t_width} "C compiler" "${CT_CC}-${CT_CC_VERSION} (C"
    62             [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ",C++"
    63             [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ",Fortran"
    64             [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ",Java"
    65             [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ",ADA"
    66             [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ",Objective-C"
    67             [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ",Objective-C++"
    68             [ -n "${CT_CC_LANG_OTHERS}"     ] && printf ",${CT_CC_LANG_OTHERS}"
    69             printf ")\n"
    70             printf  "    %-*s : %s\n" ${t_width} "C library" "${CT_LIBC}${CT_LIBC_VERSION:+-}${CT_LIBC_VERSION}"
    71             printf  "    %-*s :" ${t_width} "Tools"
    72             [ "${CT_TOOL_libelf}"   ] && printf " libelf-${CT_LIBELF_VERSION}"
    73             [ "${CT_TOOL_sstrip}"   ] && printf " sstrip"
    74             [ "${CT_DEBUG_dmalloc}" ] && printf " dmalloc-${CT_DMALLOC_VERSION}"
    75             [ "${CT_DEBUG_duma}"    ] && printf " duma-${CT_DUMA_VERSION}"
    76             [ "${CT_DEBUG_gdb}"     ] && printf " gdb-${CT_GDB_VERSION}"
    77             [ "${CT_DEBUG_ltrace}"  ] && printf " ltrace-${CT_LTRACE_VERSION}"
    78             [ "${CT_DEBUG_strace}"  ] && printf " strace-${CT_STRACE_VERSION}"
    79             printf "\n"
    80         fi
    81     else
    82         case "${CT_TOOLCHAIN_TYPE}" in
    83             cross)
    84                 printf "| ''${sample}''  | "
    85                 ;;
    86             canadian)
    87                 printf "| ''"
    88                 printf "${sample}" |sed -r -e 's/.*,//'
    89                 printf "''  | ${CT_HOST}  "
    90                 ;;
    91             *)          ;;
    92         esac
    93         printf "|  "
    94         [ "${CT_EXPERIMENTAL}" = "y" ] && printf "**X**"
    95         [ -f "${sample_top}/samples/${sample}/broken" ] && printf "**B**"
    96         printf "  |  ''${CT_KERNEL}''  |"
    97         if [ "${CT_KERNEL}" != "bare-metal" ];then
    98             if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" = "y" ]; then
    99                 printf "  //custom//  "
   100             else
   101                 printf "  ${CT_KERNEL_VERSION}  "
   102             fi
   103         fi
   104         printf "|  ${CT_BINUTILS_VERSION}  "
   105         printf "|  ''${CT_CC}''  "
   106         printf "|  ${CT_CC_VERSION}  "
   107         printf "|  ''${CT_LIBC}''  |"
   108         if [ "${CT_LIBC}" != "none" ]; then
   109             printf "  ${CT_LIBC_VERSION}  "
   110         fi
   111         printf "|  ${CT_THREADS:-none}  "
   112         printf "|  ${CT_ARCH_FLOAT_HW:+hard}${CT_ARCH_FLOAT_SW:+soft} float  "
   113         printf "|  C"
   114         [ "${CT_CC_LANG_CXX}" = "y"     ] && printf ", C++"
   115         [ "${CT_CC_LANG_FORTRAN}" = "y" ] && printf ", Fortran"
   116         [ "${CT_CC_LANG_JAVA}" = "y"    ] && printf ", Java"
   117         [ "${CT_CC_LANG_ADA}" = "y"     ] && printf ", ADA"
   118         [ "${CT_CC_LANG_OBJC}" = "y"    ] && printf ", Objective-C"
   119         [ "${CT_CC_LANG_OBJCXX}" = "y"  ] && printf ", Objective-C++"
   120         [ -n "${CT_CC_LANG_OTHERS}"     ] && printf "\\\\\\\\ Others: ${CT_CC_LANG_OTHERS}"
   121         printf "  "
   122         ( . "${sample_top}/samples/${sample}/reported.by"
   123           if [ -n "${reporter_name}" ]; then
   124               if [ -n "${reporter_url}" ]; then
   125                   printf "|  [[${reporter_url}|${reporter_name}]]  "
   126               else
   127                   printf "|  ${reporter_name}  "
   128               fi
   129           else
   130               printf "|  [[http://ymorin.is-a-geek.org/|YEM]]  "
   131           fi
   132         )
   133         sample_updated="$( hg log -l 1 --template '{date|shortdate}' "${sample_top}/samples/${sample}" )"
   134         printf "|  ${sample_updated}  "
   135         echo "|"
   136     fi
   137 }
   138 
   139 # Get largest sample width
   140 width=0
   141 for sample in "${@}"; do
   142     [ ${#sample} -gt ${width} ] && width=${#sample}
   143 done
   144 
   145 if [ "${opt}" = -w ]; then
   146     printf "^ %s  |||||||||||||||\n" "$( date "+%Y%m%d.%H%M %z" )"
   147     printf "^ Target  "
   148     printf "^ Host  "
   149     printf "^  Status  "
   150     printf "^  Kernel headers\\\\\\\\ version  ^"
   151     printf "^  binutils\\\\\\\\ version  "
   152     printf "^  C compiler\\\\\\\\ version  ^"
   153     printf "^  C library\\\\\\\\ version  ^"
   154     printf "^  Threading\\\\\\\\ model  "
   155     printf "^  Floating point\\\\\\\\ support  "
   156     printf "^  Languages  "
   157     printf "^  Initially\\\\\\\\ reported by  "
   158     printf "^  Last\\\\\\\\ updated  "
   159     echo   "^"
   160 fi
   161 
   162 for sample in "${@}"; do
   163     ( dump_single_sample ${opt} ${width} "${sample}" )
   164 done
   165 
   166 if [ "${opt}" = -w ]; then
   167     printf "^ Total: ${#@} samples  || **X**: sample uses features marked as being EXPERIMENTAL.\\\\\\\\ **B**: sample is curently BROKEN. |||||||||||||"
   168     echo   ""
   169 elif [ -z "${opt}" ]; then
   170     echo '      l (local)       : sample was found in current directory'
   171     echo '      g (global)      : sample was installed with crosstool-NG'
   172     echo '      X (EXPERIMENTAL): sample may use EXPERIMENTAL features'
   173     echo '      B (BROKEN)      : sample is currently broken'
   174 fi