#!/bin/sh srcdir="$(cd "${0%/*}" && pwd)" driver="$srcdir/driver.sh" srcdir="$srcdir/tests" sim= rm_logs=true dst=. testflags= usage() { cat < Options: -h, --help Print this message and exit. --srcdir The source directory of the tests (default: $srcdir). --sim Path to an executable that is prepended to the test execution binary (default: none). --keep-intermediate-logs Keep intermediate logs. --testflags Force initial TESTFLAGS contents. -d , --destination Destination for the generated Makefile. If the directory does not exist it is created (default: $dst). EOF } while [ $# -gt 0 ]; do case "$1" in -h|--help) usage exit ;; --testflags) testflags="$2" shift ;; --testflags=*) testflags="${1#--testflags=}" ;; -d|--destination) dst="$2" shift ;; --destination=*) dst="${1#--destination=}" ;; --keep-intermediate-logs) rm_logs=false ;; --srcdir) srcdir="$2" shift ;; --srcdir=*) srcdir="${1#--srcdir=}" ;; --sim) sim="$2" shift ;; --sim=*) sim="${1#--sim=}" ;; --) shift break ;; *) break ;; esac shift done mkdir -p "$dst" pch="$dst/pch.h" dst="$dst/Makefile" if [ -f "$dst" ]; then echo "Error: $dst already exists. Aborting." 1>&2 exit 1 fi CXX="$1" shift cat >> "$pch" <> "$dst" echo CXXFLAGS = "$@" -include pch.h "\$(test_flags)" >> "$dst" [ -n "$sim" ] && echo "export GCC_TEST_SIMULATOR = $sim" >> "$dst" cat >> "$dst" < \$@ @cat \$(^:log=sum) > \$(@:log=sum)${rmline} EOF all_tests | while read file && read name; do echo -n "$name.log:" all_types "$file" | while read t && read type; do echo -n " $name-$type.log" done cat < \$@ @cat \$(^:log=sum) > \$(@:log=sum)${rmline} EOF done all_types | while read t && read type; do cat < \$@ @cat \$(^:log=sum) > \$(@:log=sum)${rmline} EOF for i in $(seq 0 9); do cat < "$dsthelp" use DRIVEROPTS= to pass the following options: -q, --quiet Disable same-line progress output (default if stdout is not a tty). -p, --percentage Add percentage to default same-line progress output. -v, --verbose Print one line per test and minimal extra information on failure. -vv Print all compiler and test output. -k, --keep-failed Keep executables of failed tests. --sim Path to an executable that is prepended to the test execution binary (default: the value of GCC_TEST_SIMULATOR). --timeout-factor Multiply the default timeout with x. -x, --run-expensive Compile and run tests marked as expensive (default: true if GCC_TEST_RUN_EXPENSIVE is set, false otherwise). -o , --only Compile and run only tests matching the given pattern. use TESTFLAGS= to pass additional compiler flags The following are some of the valid targets for this Makefile: ... all ... clean ... help" EOF N=$(((0$( all_tests | while read file && read name; do all_types "$file" | printf " + %d" $(wc -l) done) ) * 5)) all_tests | while read file && read name; do echo "... run-${name}" all_types "$file" | while read t && read type; do echo "... run-${name}-${type}" for i in $(seq 0 9); do echo "... run-${name}-${type}-$i" done done done >> "$dsthelp" cat < .progress .progress_total: @echo $N > .progress_total clean: rm -f -- *.sum *.log *.exe .progress .progress_total .PHONY: all clean help .progress .progress_total .PRECIOUS: %.log %.sum EOF } >> "$dst"