1#!/bin/sh
2case "$1" in
3    --Debug   ) def_compress_others=yes; shift ;;
4    --Release ) def_compress_others=no;  shift ;;
5    *         ) def_compress_others= ;;
6esac
7
8ext='.gz'
9
10ws='[ 	]' # Contains a space and a tab.
11if [ -f ../../build_info ] \
12    && (grep "^$ws*PURPOSE$ws*=$ws*FINAL$ws*\$" ../../build_info \
13        &&  grep "^$ws*CODEBASE$ws*=$ws*PRODUCTION$ws*\$" ../../build_info \
14        &&  bzip2 --version </dev/null) >/dev/null 2>&1; then
15    # Some bzip2 releases still try to compress stdin with --version(!)
16    ext='.bz2'
17fi
18
19for dir in "$@"; do
20    if [ -n "$def_compress_others" ]; then
21        compress_others=$def_compress_others
22    else
23        case "$dir" in
24            *Debug* ) compress_others=yes ;;
25            *       ) compress_others=no  ;;
26        esac
27    fi
28    targets=''
29    for f in $dir/*; do
30        [ -f "$f" ]  ||  continue
31        case "`basename $f`" in
32            plugin_test | speedtest | streamtest | biosample_chk | objmgr_demo \
33                | testipub | test_basic_cleanup | test_checksum | test_mghbn \
34                | test_ncbi_connutil_hit | test_ncbi_crypt | test_ncbi_dblb \
35                | test_ncbi_http_get | *.*z* )
36                ;;
37            *test* | *demo* | *sample* \
38                | net*che*_c* | ns_*remote_job* | save_to_nc )
39                targets="$targets `basename $f`$ext"
40                ;;
41            *blast* | datatool | gbench* | id1_fetch | idwwwget | lbsmc \
42                | one2all | run_with_lock )
43                ;;
44            *)
45                test "$compress_others" = "no"  ||  \
46                    targets="$targets `basename $f`$ext"
47                ;;
48        esac
49    done
50    ${MAKE-make} -C $dir \
51       -f `dirname $0`/../../../src/build-system/Makefile.compress_tests \
52       $targets
53done
54