scripts/showSamples.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Dec 20 00:07:29 2010 +0100 (2010-12-20)
changeset 2308 911b3a703497
parent 1846 4220dec659c6
child 2409 15f5f431ec9e
permissions -rwxr-xr-x
buildtools: the buildtools dir is in fact a prefix

Consider the buildtools install directory as a prefix directory,
that is, install buildtools in prefix/bin/, not in prefix/.

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