#!/bin/sh
#
# $Id: genxviews 589896 2007-10-29 22:44:55Z sebor $
#
########################################################################
#
#  Licensed to the Apache Software  Foundation (ASF) under one or more
#  contributor  license agreements.  See  the NOTICE  file distributed
#  with  this  work  for  additional information  regarding  copyright
#  ownership.   The ASF  licenses this  file to  you under  the Apache
#  License, Version  2.0 (the  "License"); you may  not use  this file
#  except in  compliance with the License.   You may obtain  a copy of
#  the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the  License is distributed on an  "AS IS" BASIS,
#  WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
#  implied.   See  the License  for  the  specific language  governing
#  permissions and limitations under the License.
#
########################################################################

CROSS=$HOME/bin/xbuildgen

OUTDIR=$HOME/public_html/stdcxx/results

cd $OUTDIR

cat<<EOF
<html>
  <body>
    <style type="text/css">

      table {
          border-width:0px;
          background:#000000;
          font-size:smaller;
      }
      th {
          font-size:smaller;
          background:#cccccc;
          text-align:center;
      }
      td {
          font-size:smaller;
          padding: 3px;
          text-align: center;
          background-color: lightblue;
      }
    </style>
    <h1>Available Multi-platform Build Result Views</h1>
    Generated `date`
    <hr>
    <table>
      <thead>
        <tr>
          <th>OS</td>
          <th>Architecture</td>
          <th>Compiler</td>
          <th>Build Results</td>
        </tr>
        </thead>
        <tbody>
EOF

process_results ()
{
    osname="$1"
    arch="$2"
    compiler="$3"
    alllogs="$4"
    outfile="$5"

    cat<<EOF
          <tr>
            <td>$osname</td>
            <td>$arch</td>
            <td>$compiler</td>
            <td><a href="$outfile">$outfile</a></td>
          </tr>

EOF

    # build types:
    #    8: not reentrant, optimized, no debugging info
    #   11: not reentrant, not optimized with debugging info
    #   12: reentrant, optimized, no debugging info
    #   15: reentrant, not optimized, with debugging info
    btypes="8 11 12 15"

    # a, A: AIX shared archive (32-bit and 64-bit, respectively)
    # d, D: shared library (.sl, .so, or .dll)
    # s, S: archive library (.a or .lib(
    suffixes="a A d D s S"

    unset buildlogs

    for b in $btypes; do
        for s in $suffixes; do
            log=`echo $alllogs | tr ' ' '\n' | grep "[-]$b$s-" \
                               | sort | tail -n 1`
            buildlogs="$buildlogs $log"
        done
    done

    $CROSS -o$OUTDIR/$outfile $buildlogs
}

# AIX ##################################################################
process_results "AIX 5.3" "PowerPC" "IBM XLC++ 9.0" \
                "aix-5.3-ppc-vacpp-*-9.0-*-*-log.gz.txt" \
                aix-5.3-ppc-vacpp-9.0.html

process_results "AIX 5.3" "PowerPC" "IBM XLC++ 8.0" \
                "aix-5.3-ppc-vacpp-*-8.0-*-*-log.gz.txt" \
                aix-5.3-ppc-vacpp-8.0.html

process_results "AIX 5.3" "PowerPC" "IBM XLC++ 7.0" \
                "aix-5.3-ppc-vacpp-*-7.0.0.0-*-*-log.gz.txt" \
                aix-5.3-ppc-vacpp-7.0.html

process_results "AIX 5.2" "PowerPC" "IBM VisualAge C++ 6.0" \
                "aix-5.2-ppc-visualage-*-6.0.0-*-*-log.gz.txt" \
                aix-5.2-ppc-visualage-6.0.html

# FreeBSD ##############################################################
process_results "FreeBSD 6.2" "x86" "gcc 3.4.4" \
                "freebsd-6.2-x86-gcc-*-3.4.4-*-*-log.gz.txt" \
                freebsd-6.2-x86-gcc-3.4.4.html

# HP-UX ################################################################
process_results "HP-UX 11.31" "PA-RISC" "HP aCC 3.74" \
                "hpux-11.31-pa-acc-*-3.74-*-*-log.gz.txt" \
                hpux-11.31-pa-acc-3.74.html

process_results "HP-UX 11.31" "PA-RISC" "HP aCC 3.73" \
                "hpux-11.31-pa-acc-*-3.73-*-*-log.gz.txt" \
                hpux-11.31-pa-acc-3.73.html

process_results "HP-UX 11.23" "IPF" "HP aCC 6.13" \
                "hpux-11.23-ia64-acc-64b-6.13-*-*-log.gz.txt" \
                hpux-11.23-ia64-acc-6.13.html

process_results "HP-UX 11.23" "IPF" "HP aCC 6.00" \
                "hpux-11.23-ia64-acc-64b-6.00-*-*-log.gz.txt" \
                hpux-11.23-ia64-acc-6.00.html

process_results "HP-UX 11.23" "IPF" "HP aCC 5.57" \
                "hpux-11.23-ia64-acc-64b-5.57-*-*-log.gz.txt" \
                hpux-11.23-ia64-acc-5.57.html

process_results "HP-UX 11.23" "PA-RISC" "HP aCC 3.73" \
                "hpux-11.23-pa-acc-*-3.73-*-*-log.gz.txt" \
                hpux-11.23-pa-acc-3.73.html

process_results "HP-UX 11.23" "PA-RISC" "HP aCC 3.63" \
                "hpux-11.23-pa-acc-*-3.63-*-*-log.gz.txt" \
                hpux-11.23-pa-acc-3.63.html

process_results "HP-UX 11.11" "PA-RISC" "HP aCC 3.73" \
                "hpux-11.11-pa-acc-*-3.73-*-*-log.gz.txt" \
                hpux-11.11-pa-acc-3.73.html

process_results "HP-UX 11.11" "PA-RISC" "HP aCC 3.63" \
                "hpux-11.11-pa-acc-*-3.63-*-*-log.gz.txt" \
                hpux-11.11-pa-acc-3.63.html

# IRIX #################################################################
process_results "IRIX 6.5.16" "MIPS" "SGI MIPSpro 7.41" \
                "irix-6.5.16-mips-mipspro-*-7.41-*-*-log.gz.txt" \
                irix-6.5.16-mips-mipspro-7.41.htm

# Red Hat Linux ########################################################
process_results "Red Hat EL 5.0" "EM64T" "gcc 4.1.1" \
                "linux_redhat_el-5.0-em64t-gcc-*-4.1.1-*-*-log.gz.txt" \
                linux_redhat_el-5.0-em64t-gcc-4.1.1.html

process_results "Red Hat AS 4 Update 4" "AMD64" "gcc 3.4.4" \
                "linux_redhat_el-4.4-amd64-gcc-*-3.4.4-*-*-log.gz.txt" \
                linux_redhat_el-4.4-amd64-gcc-3.4.4.html

process_results "Red Hat AS 4 Update 2" "AMD64" "gcc 3.4.6" \
                "linux_redhat_el-4.4-amd64-gcc-*-3.4.6-*-*-log.gz.txt" \
                linux_redhat_el-4.4-amd64-gcc-3.4.6.html

process_results "Red Hat AS 4 Update 2" "IA64" "gcc 3.4.4" \
                "linux_redhat_el-4.2-ia64-gcc-*-3.4.4-*-*-log.gz.txt" \
                linux_redhat_el-4.2-ia64-gcc-3.4.4.html

process_results "Red Hat AS 3 Update 8" "EM64T" "gcc 3.2.3" \
                "linux_redhat_el-3.8-em64t-gcc-3.2.3-*-*-log.gz.txt \
                 linux_redhat_el-3.8-em64t-gcc-64b-3.2.3-*-log.gz.txt" \
                linux_redhat_el-3.8-em64t-gcc-3.2.3.html

# Solaris ##############################################################
process_results "Solaris 10" "SPARC" "gcc 4.1.1" \
                "solaris-10-sparc-gcc-*-4.1.1-*-*-log.gz.txt" \
                solaris-10-sparc-gcc-4.1.1.html

process_results "Solaris 10" "SPARC" "Sun C++ 5.9" \
                "solaris-10-sparc-sunpro-*-5.9-*-*-log.gz.txt" \
                solaris-10-sparc-sunpro-5.9.html

process_results "Solaris 10" "SPARC" "Sun C++ 5.8" \
                "solaris-10-sparc-sunpro-*-5.8-*-*-log.gz.txt" \
                solaris-10-sparc-sunpro-5.8.html

process_results "Solaris 10" "SPARC" "Sun C++ 5.7" \
                "solaris-10-sparc-sunpro-*-5.7-*-*-log.gz.txt" \
                solaris-10-sparc-sunpro-5.7.html

process_results "Solaris 9" "SPARC" "Sun C++ 5.6" \
                "solaris-9-sparc-sunpro-*-5.6-*-*-log.gz.txt" \
                solaris-9-sparc-sunpro-5.6.html

# process_results "Solaris 9" "SPARC" "Sun C++ 5.5" \
#                 "solaris-9-sparc-sunpro-*-5.5-*-*-log.gz.txt" \
#                 solaris-9-sparc-sunpro-5.5.html

process_results "Solaris 9" "SPARC" "EDG eccp 3.9" \
                "solaris-9-sparc-eccp-*-3.9-*-*-log.gz.txt" \
                solaris-9-sparc-eccp--3.9.html

# process_results "Solaris 8" "SPARC" "Sun C++ 5.5" \
#                 "solaris-8-sparc-sunpro-*-5.5-*-*-log.gz.txt" \
#                 solaris-8-sparc-sunpro-5.5.html

process_results "Solaris 8" "SPARC" "Sun C++ 5.3" \
                "solaris-8-sparc-sunpro-*-5.3-*-*-log.gz.txt" \
                solaris-8-sparc-sunpro-5.3.html

# SuSE Linux ###########################################################
process_results "SuSE ES 10.0" "x86" "gcc 4.1.0" \
                "linux_suse-10.0-em64t-gcc-*-4.1.0-*-*-log.gz.txt" \
                linux_suse-10.0-em64t-gcc-4.1.0.html

process_results "SuSE ES 9.1" "AMD64" "gcc 3.3.3" \
                "linux_suse-9.1-amd64-gcc-3.3.3-43.28-*-*-log.gz.txt \
                 linux_suse-9.1-amd64-gcc-64b-3.3.3-*-*-log.gz.txt" \
                linux_suse-9.1-amd64-gcc-3.3.3.html

# CygWin ###############################################################
process_results "CygWin/Windows XP" "x86" "gcc 3.4.4" \
                "win_xp-2-x86-gcc-*-3.4.4-*-*-log.gz.txt" \
                 win_xp-2-x86-gcc-3.4.4.html

cat<<EOF
    </table>
  </body>
</html>
EOF
